diff --git a/.dumirc.ts b/.dumirc.ts index a19c09d21..61866c52e 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -134,6 +134,7 @@ export default defineConfig({ { title: '数据录入', children: [ + { title: 'Cascader 级联选择', link: '/components/cascader' }, { title: 'Form 表单', link: '/components/form' }, { title: 'Input 输入框', link: '/components/input' }, { title: 'InputNumber 数字输入框', link: '/components/input-number' }, diff --git a/packages/design/src/cascader/demo/basic.tsx b/packages/design/src/cascader/demo/basic.tsx new file mode 100644 index 000000000..f76fe861f --- /dev/null +++ b/packages/design/src/cascader/demo/basic.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { Cascader } from '@oceanbase/design'; + +interface Option { + value: string | number; + label: string; + children?: Option[]; +} + +const options: Option[] = [ + { + value: 'zhejiang', + label: 'Zhejiang', + children: [ + { + value: 'hangzhou', + label: 'Hangzhou', + children: [ + { + value: 'xihu', + label: 'West Lake', + }, + ], + }, + ], + }, + { + value: 'jiangsu', + label: 'Jiangsu', + children: [ + { + value: 'nanjing', + label: 'Nanjing', + children: [ + { + value: 'zhonghuamen', + label: 'Zhong Hua Men', + }, + ], + }, + ], + }, +]; + +const onChange = (value: (string | number)[]) => { + console.log(value); +}; + +const App: React.FC = () => ( + +); + +export default App; diff --git a/packages/design/src/cascader/demo/multiple.tsx b/packages/design/src/cascader/demo/multiple.tsx new file mode 100644 index 000000000..0c1193a4b --- /dev/null +++ b/packages/design/src/cascader/demo/multiple.tsx @@ -0,0 +1,65 @@ +import React from 'react'; +import { Cascader } from '@oceanbase/design'; +import type { MultipleCascaderProps } from '@oceanbase/design/es/cascader'; + +interface Option { + value: string | number; + label: string; + children?: Option[]; + disableCheckbox?: boolean; +} + +const options: Option[] = [ + { + label: 'Light', + value: 'light', + children: new Array(20) + .fill(null) + .map((_, index) => ({ label: `Number ${index}`, value: index })), + }, + { + label: 'Bamboo', + value: 'bamboo', + children: [ + { + label: 'Little', + value: 'little', + children: [ + { + label: 'Toy Fish', + value: 'fish', + disableCheckbox: true, + }, + { + label: 'Toy Cards', + value: 'cards', + }, + { + label: 'Toy Bird', + value: 'bird', + }, + ], + }, + ], + }, +]; + +const onChange: MultipleCascaderProps