From d14633b21470acb392b038ed63273e388a5dd5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Mon, 20 Feb 2023 16:11:58 +0800 Subject: [PATCH] chore: dumi 1.x -> 2.x (#391) * chore: dumi 1.x -> 2.x * chore: update dep --- .dumirc.ts | 14 +++++++++++++ .gitignore | 4 ++++ .umirc.gh.ts | 4 ---- .umirc.ts | 21 ------------------- docs/CHANGELOG.md | 1 + docs/demo/adjust-overflow.md | 9 ++++++-- docs/demo/animation.md | 9 ++++++-- docs/demo/change-on-select.md | 9 ++++++-- docs/demo/custom-arrow-icon.md | 9 ++++++-- docs/demo/custom-field-name.md | 9 ++++++-- docs/demo/debug.md | 9 ++++++-- docs/demo/default-expand-single-option.md | 9 ++++++-- docs/demo/defaultValue.md | 9 ++++++-- docs/demo/disabled.md | 9 ++++++-- docs/demo/dropdown-render.md | 9 ++++++-- docs/demo/dynamic-options.md | 9 ++++++-- docs/demo/hover.md | 9 ++++++-- docs/demo/multiple.md | 9 ++++++-- docs/demo/rc-form.md | 9 ++++++-- docs/demo/simple.md | 9 ++++++-- docs/demo/text-trigger.md | 9 ++++++-- docs/demo/value.md | 9 ++++++-- docs/demo/visible.md | 9 ++++++-- docs/index.md | 4 +++- ...djust-overflow.jsx => adjust-overflow.tsx} | 3 ++- examples/{animation.jsx => animation.tsx} | 0 ...nge-on-select.jsx => change-on-select.tsx} | 0 ...m-arrow-icon.jsx => custom-arrow-icon.tsx} | 0 ...m-field-name.jsx => custom-field-name.tsx} | 0 ...n.jsx => default-expand-single-option.tsx} | 0 .../{defaultValue.jsx => defaultValue.tsx} | 0 examples/{disabled.jsx => disabled.tsx} | 0 ...ropdown-render.jsx => dropdown-render.tsx} | 0 ...ynamic-options.jsx => dynamic-options.tsx} | 0 examples/{hover.jsx => hover.tsx} | 0 examples/{rc-form.jsx => rc-form.tsx} | 10 ++++----- examples/{simple.jsx => simple.tsx} | 0 .../{text-trigger.jsx => text-trigger.tsx} | 0 examples/{value.jsx => value.tsx} | 2 +- examples/{visible.jsx => visible.tsx} | 2 +- now.json | 2 +- package.json | 5 +++-- src/Cascader.tsx | 2 ++ tests/{demoOptions.js => demoOptions.ts} | 6 ++++-- tests/{keyboard.spec.js => keyboard.spec.tsx} | 1 - 45 files changed, 167 insertions(+), 76 deletions(-) create mode 100644 .dumirc.ts delete mode 100644 .umirc.gh.ts delete mode 100644 .umirc.ts create mode 100644 docs/CHANGELOG.md rename examples/{adjust-overflow.jsx => adjust-overflow.tsx} (93%) rename examples/{animation.jsx => animation.tsx} (100%) rename examples/{change-on-select.jsx => change-on-select.tsx} (100%) rename examples/{custom-arrow-icon.jsx => custom-arrow-icon.tsx} (100%) rename examples/{custom-field-name.jsx => custom-field-name.tsx} (100%) rename examples/{default-expand-single-option.jsx => default-expand-single-option.tsx} (100%) rename examples/{defaultValue.jsx => defaultValue.tsx} (100%) rename examples/{disabled.jsx => disabled.tsx} (100%) rename examples/{dropdown-render.jsx => dropdown-render.tsx} (100%) rename examples/{dynamic-options.jsx => dynamic-options.tsx} (100%) rename examples/{hover.jsx => hover.tsx} (100%) rename examples/{rc-form.jsx => rc-form.tsx} (95%) rename examples/{simple.jsx => simple.tsx} (100%) rename examples/{text-trigger.jsx => text-trigger.tsx} (100%) rename examples/{value.jsx => value.tsx} (100%) rename examples/{visible.jsx => visible.tsx} (100%) rename tests/{demoOptions.js => demoOptions.ts} (92%) rename tests/{keyboard.spec.js => keyboard.spec.tsx} (99%) diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 00000000..81392343 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,14 @@ +import { defineConfig } from 'dumi'; +import path from 'path'; + +export default defineConfig({ + alias: { + 'rc-cascader$': path.resolve('src'), + 'rc-cascader/es': path.resolve('src'), + }, + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], + themeConfig: { + name: 'Cascader', + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + }, +}); diff --git a/.gitignore b/.gitignore index fb945893..1ede7ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ coverage .umi-test .env.local .doc + +# dumi +.dumi/tmp +.dumi/tmp-production \ No newline at end of file diff --git a/.umirc.gh.ts b/.umirc.gh.ts deleted file mode 100644 index 3839b3f4..00000000 --- a/.umirc.gh.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default { - base: '/cascader/', - publicPath: '/cascader/', -}; diff --git a/.umirc.ts b/.umirc.ts deleted file mode 100644 index feed5f92..00000000 --- a/.umirc.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { defineConfig } from 'dumi'; - -export default defineConfig({ - title: 'rc-cascader', - favicon: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - logo: - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - exportStatic: {}, - outputPath: '.doc', - resolve: { - examples: ['none'], - }, - styles: [ - ` - .markdown table { - width: auto !important; - } - `, - ] -}); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md new file mode 100644 index 00000000..817bd8d2 --- /dev/null +++ b/docs/CHANGELOG.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/demo/adjust-overflow.md b/docs/demo/adjust-overflow.md index 7b39cf8d..be380b0c 100644 --- a/docs/demo/adjust-overflow.md +++ b/docs/demo/adjust-overflow.md @@ -1,3 +1,8 @@ -## adjust-overflow +--- +title: adjust-overflow +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/animation.md b/docs/demo/animation.md index 2a9eaf69..303ab448 100644 --- a/docs/demo/animation.md +++ b/docs/demo/animation.md @@ -1,3 +1,8 @@ -## animation +--- +title: animation +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/change-on-select.md b/docs/demo/change-on-select.md index 33adac20..827744a3 100644 --- a/docs/demo/change-on-select.md +++ b/docs/demo/change-on-select.md @@ -1,3 +1,8 @@ -## change-on-select +--- +title: change-on-select +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/custom-arrow-icon.md b/docs/demo/custom-arrow-icon.md index c026b18a..25424473 100644 --- a/docs/demo/custom-arrow-icon.md +++ b/docs/demo/custom-arrow-icon.md @@ -1,3 +1,8 @@ -## custom-arrow-icon +--- +title: custom-arrow-icon +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/custom-field-name.md b/docs/demo/custom-field-name.md index fc040ce0..7b17ddac 100644 --- a/docs/demo/custom-field-name.md +++ b/docs/demo/custom-field-name.md @@ -1,3 +1,8 @@ -## custom-field-name +--- +title: custom-field-name +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/debug.md b/docs/demo/debug.md index 6dd26237..380f8042 100644 --- a/docs/demo/debug.md +++ b/docs/demo/debug.md @@ -1,3 +1,8 @@ -## debug +--- +title: debug +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/default-expand-single-option.md b/docs/demo/default-expand-single-option.md index def424c7..ca223581 100644 --- a/docs/demo/default-expand-single-option.md +++ b/docs/demo/default-expand-single-option.md @@ -1,3 +1,8 @@ -## default-expand-single-option +--- +title: default-expand-single-option +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/defaultValue.md b/docs/demo/defaultValue.md index c50d8c2f..7d67228f 100644 --- a/docs/demo/defaultValue.md +++ b/docs/demo/defaultValue.md @@ -1,3 +1,8 @@ -## defaultValue +--- +title: defaultValue +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/disabled.md b/docs/demo/disabled.md index 0f56fbfc..bdca2745 100644 --- a/docs/demo/disabled.md +++ b/docs/demo/disabled.md @@ -1,3 +1,8 @@ -## disabled +--- +title: disabled +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/dropdown-render.md b/docs/demo/dropdown-render.md index fc745fee..ee9f20f0 100644 --- a/docs/demo/dropdown-render.md +++ b/docs/demo/dropdown-render.md @@ -1,3 +1,8 @@ -## dropdown-render +--- +title: dropdown-render +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/dynamic-options.md b/docs/demo/dynamic-options.md index 479a74cc..126ce8cc 100644 --- a/docs/demo/dynamic-options.md +++ b/docs/demo/dynamic-options.md @@ -1,3 +1,8 @@ -## dynamic-options +--- +title: dynamic-options +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/hover.md b/docs/demo/hover.md index 5becd373..c3c84a6b 100644 --- a/docs/demo/hover.md +++ b/docs/demo/hover.md @@ -1,3 +1,8 @@ -## hover +--- +title: hover +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/multiple.md b/docs/demo/multiple.md index 2d2a6f72..22e8e470 100644 --- a/docs/demo/multiple.md +++ b/docs/demo/multiple.md @@ -1,3 +1,8 @@ -## multiple +--- +title: multiple +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/rc-form.md b/docs/demo/rc-form.md index 0775740f..632f7813 100644 --- a/docs/demo/rc-form.md +++ b/docs/demo/rc-form.md @@ -1,3 +1,8 @@ -## rc-form +--- +title: rc-form +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/simple.md b/docs/demo/simple.md index 168a530a..c020a580 100644 --- a/docs/demo/simple.md +++ b/docs/demo/simple.md @@ -1,3 +1,8 @@ -## simple +--- +title: animated +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/text-trigger.md b/docs/demo/text-trigger.md index e95d98ba..a18bf758 100644 --- a/docs/demo/text-trigger.md +++ b/docs/demo/text-trigger.md @@ -1,3 +1,8 @@ -## text-trigger +--- +title: text-trigger +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/value.md b/docs/demo/value.md index 97c03c87..190d4cba 100644 --- a/docs/demo/value.md +++ b/docs/demo/value.md @@ -1,3 +1,8 @@ -## value +--- +title: value +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/demo/visible.md b/docs/demo/visible.md index c2f12738..8eb8cb6a 100644 --- a/docs/demo/visible.md +++ b/docs/demo/visible.md @@ -1,3 +1,8 @@ -## visible +--- +title: visible +nav: + title: Demo + path: /demo +--- - + diff --git a/docs/index.md b/docs/index.md index a7aec0e7..3611ae59 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,7 @@ --- -title: rc-cascader +hero: + title: rc-cascader + description: React cascader Component --- diff --git a/examples/adjust-overflow.jsx b/examples/adjust-overflow.tsx similarity index 93% rename from examples/adjust-overflow.jsx rename to examples/adjust-overflow.tsx index a1d51d31..7e789ff8 100644 --- a/examples/adjust-overflow.jsx +++ b/examples/adjust-overflow.tsx @@ -1,4 +1,5 @@ /* eslint-disable no-console, react/prop-types */ +import type { BuildInPlacements } from 'rc-trigger/lib/interface'; import React from 'react'; import '../assets/index.less'; import Cascader from '../src'; @@ -57,7 +58,7 @@ const addressOptions = [ }, ]; -class MyCascader extends React.Component { +class MyCascader extends React.Component<{ builtinPlacements?: BuildInPlacements }> { state = { inputValue: '', }; diff --git a/examples/animation.jsx b/examples/animation.tsx similarity index 100% rename from examples/animation.jsx rename to examples/animation.tsx diff --git a/examples/change-on-select.jsx b/examples/change-on-select.tsx similarity index 100% rename from examples/change-on-select.jsx rename to examples/change-on-select.tsx diff --git a/examples/custom-arrow-icon.jsx b/examples/custom-arrow-icon.tsx similarity index 100% rename from examples/custom-arrow-icon.jsx rename to examples/custom-arrow-icon.tsx diff --git a/examples/custom-field-name.jsx b/examples/custom-field-name.tsx similarity index 100% rename from examples/custom-field-name.jsx rename to examples/custom-field-name.tsx diff --git a/examples/default-expand-single-option.jsx b/examples/default-expand-single-option.tsx similarity index 100% rename from examples/default-expand-single-option.jsx rename to examples/default-expand-single-option.tsx diff --git a/examples/defaultValue.jsx b/examples/defaultValue.tsx similarity index 100% rename from examples/defaultValue.jsx rename to examples/defaultValue.tsx diff --git a/examples/disabled.jsx b/examples/disabled.tsx similarity index 100% rename from examples/disabled.jsx rename to examples/disabled.tsx diff --git a/examples/dropdown-render.jsx b/examples/dropdown-render.tsx similarity index 100% rename from examples/dropdown-render.jsx rename to examples/dropdown-render.tsx diff --git a/examples/dynamic-options.jsx b/examples/dynamic-options.tsx similarity index 100% rename from examples/dynamic-options.jsx rename to examples/dynamic-options.tsx diff --git a/examples/hover.jsx b/examples/hover.tsx similarity index 100% rename from examples/hover.jsx rename to examples/hover.tsx diff --git a/examples/rc-form.jsx b/examples/rc-form.tsx similarity index 95% rename from examples/rc-form.jsx rename to examples/rc-form.tsx index fb1770fe..fc995413 100644 --- a/examples/rc-form.jsx +++ b/examples/rc-form.tsx @@ -1,8 +1,8 @@ /* eslint-disable no-console, react/no-multi-comp, react/prop-types, react/button-has-type,prefer-destructuring,max-len, max-classes-per-file */ -import React, { Component } from 'react'; +import arrayTreeFilter from 'array-tree-filter'; import { createForm } from 'rc-form'; +import { Component } from 'react'; import '../assets/index.less'; -import arrayTreeFilter from 'array-tree-filter'; import Cascader from '../src'; const addressOptions = [ @@ -59,7 +59,7 @@ const addressOptions = [ ]; class CascaderInput extends Component { - onChange = (value) => { + onChange = value => { const props = this.props; if (props.onChange) { props.onChange(value); @@ -70,7 +70,7 @@ class CascaderInput extends Component { const props = this.props; const value = props.value || []; return arrayTreeFilter(props.options, (o, level) => o.value === value[level]) - .map((o) => o.label) + .map(o => o.label) .join(', '); } @@ -85,7 +85,7 @@ class CascaderInput extends Component { } class Form extends Component { - onSubmit = (e) => { + onSubmit = e => { const props = this.props; const { form } = props; e.preventDefault(); diff --git a/examples/simple.jsx b/examples/simple.tsx similarity index 100% rename from examples/simple.jsx rename to examples/simple.tsx diff --git a/examples/text-trigger.jsx b/examples/text-trigger.tsx similarity index 100% rename from examples/text-trigger.jsx rename to examples/text-trigger.tsx diff --git a/examples/value.jsx b/examples/value.tsx similarity index 100% rename from examples/value.jsx rename to examples/value.tsx index 4a4efec5..2025ce4c 100644 --- a/examples/value.jsx +++ b/examples/value.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console,react/button-has-type */ -import React from 'react'; import arrayTreeFilter from 'array-tree-filter'; +import React from 'react'; import '../assets/index.less'; import Cascader from '../src'; diff --git a/examples/visible.jsx b/examples/visible.tsx similarity index 100% rename from examples/visible.jsx rename to examples/visible.tsx index 98391b34..763ce8eb 100644 --- a/examples/visible.jsx +++ b/examples/visible.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console */ -import React from 'react'; import arrayTreeFilter from 'array-tree-filter'; +import React from 'react'; import '../assets/index.less'; import Cascader from '../src'; diff --git a/now.json b/now.json index 9a52d135..c7e38d0a 100644 --- a/now.json +++ b/now.json @@ -5,7 +5,7 @@ { "src": "package.json", "use": "@now/static-build", - "config": { "distDir": ".doc" } + "config": { "distDir": "dist" } } ], "routes": [ diff --git a/package.json b/package.json index 6362b0e3..7002edac 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@types/react-dom": "^17.0.11", "@types/warning": "^3.0.0", "cross-env": "^7.0.0", - "dumi": "^1.1.12", + "dumi": "^2.1.10", "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.0.2", "enzyme-to-json": "^3.2.1", @@ -61,7 +61,8 @@ "rc-trigger": "^5.0.4", "react": "^16.0.0", "react-dom": "^16.0.0", - "typescript": "^4.4.2" + "typescript": "^4.4.2", + "less": "^3.13.1" }, "dependencies": { "@babel/runtime": "^7.12.5", diff --git a/src/Cascader.tsx b/src/Cascader.tsx index 778e8370..3c131689 100644 --- a/src/Cascader.tsx +++ b/src/Cascader.tsx @@ -3,6 +3,7 @@ import { BaseSelect } from 'rc-select'; import type { DisplayValueType, Placement } from 'rc-select/lib/BaseSelect'; import useId from 'rc-select/lib/hooks/useId'; import { conductCheck } from 'rc-tree/lib/utils/conductUtil'; +import type { BuildInPlacements } from 'rc-trigger/lib/interface'; import useMergedState from 'rc-util/lib/hooks/useMergedState'; import * as React from 'react'; import CascaderContext from './context'; @@ -100,6 +101,7 @@ interface BaseCascaderProps void; diff --git a/tests/demoOptions.js b/tests/demoOptions.ts similarity index 92% rename from tests/demoOptions.js rename to tests/demoOptions.ts index d121659e..e0fa4ffd 100644 --- a/tests/demoOptions.js +++ b/tests/demoOptions.ts @@ -1,4 +1,6 @@ -export const optionsForActiveMenuItems = [ +import type { DefaultOptionType } from '@/Cascader'; + +export const optionsForActiveMenuItems: DefaultOptionType[] = [ { value: '1', label: '1', @@ -33,7 +35,7 @@ export const optionsForActiveMenuItems = [ }, ]; -export const addressOptions = [ +export const addressOptions: DefaultOptionType[] = [ { label: '福建', value: 'fj', diff --git a/tests/keyboard.spec.js b/tests/keyboard.spec.tsx similarity index 99% rename from tests/keyboard.spec.js rename to tests/keyboard.spec.tsx index 7b025e0b..08e47ad6 100644 --- a/tests/keyboard.spec.js +++ b/tests/keyboard.spec.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { mount } from 'enzyme'; import KeyCode from 'rc-util/lib/KeyCode'; import Cascader from '../src';