From d027f286e368427019d613a2078d047c9a75e89f Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Tue, 11 Jan 2022 17:59:38 +0800 Subject: [PATCH] refactor: select --- components/select/demo/label-in-value.vue | 9 +- components/select/demo/option-label-prop.vue | 29 +- components/select/demo/size.vue | 5 +- components/select/index.en-US.md | 1 + components/select/index.tsx | 68 +- components/select/index.zh-CN.md | 1 + components/select/style/index.less | 10 +- components/select/style/multiple.less | 5 +- components/select/style/single.less | 8 +- components/vc-select copy/Select.tsx | 162 --- components/vc-select copy/generate.tsx | 1246 ----------------- .../vc-select copy/interface1/generator.ts | 73 - components/vc-select copy/interface1/index.ts | 62 - .../BaseSelect.tsx | 27 +- .../OptGroup.tsx | 0 .../{vc-select copy => vc-select2}/Option.tsx | 0 .../OptionList.tsx | 20 +- components/vc-select2/Select.tsx | 642 +++++++++ .../SelectContext.ts | 0 .../SelectTrigger.tsx | 0 .../Selector/Input.tsx | 0 .../Selector/MultipleSelector.tsx | 8 +- .../Selector/SingleSelector.tsx | 0 .../Selector/index.tsx | 0 .../Selector/interface.ts | 0 .../TransBtn.tsx | 0 .../hooks/useBaseProps.ts | 0 .../hooks/useCache.ts | 0 .../hooks/useDelayReset.ts | 0 .../hooks/useFilterOptions.ts | 0 .../hooks/useId.ts | 0 .../hooks/useLock.ts | 0 .../hooks/useOptions.ts | 35 +- .../hooks/useSelectTriggerControl.ts | 0 .../{vc-select copy => vc-select2}/index.ts | 0 .../interface.ts | 0 .../utils/commonUtil.ts | 0 .../utils/keyUtil.ts | 0 .../utils/legacyUtil.ts | 2 +- .../utils/platformUtil.ts | 0 .../utils/valueUtil.ts | 0 .../utils/warningPropsUtil.ts | 0 42 files changed, 786 insertions(+), 1627 deletions(-) delete mode 100644 components/vc-select copy/Select.tsx delete mode 100644 components/vc-select copy/generate.tsx delete mode 100644 components/vc-select copy/interface1/generator.ts delete mode 100644 components/vc-select copy/interface1/index.ts rename components/{vc-select copy => vc-select2}/BaseSelect.tsx (98%) rename components/{vc-select copy => vc-select2}/OptGroup.tsx (100%) rename components/{vc-select copy => vc-select2}/Option.tsx (100%) rename components/{vc-select copy => vc-select2}/OptionList.tsx (94%) create mode 100644 components/vc-select2/Select.tsx rename components/{vc-select copy => vc-select2}/SelectContext.ts (100%) rename components/{vc-select copy => vc-select2}/SelectTrigger.tsx (100%) rename components/{vc-select copy => vc-select2}/Selector/Input.tsx (100%) rename components/{vc-select copy => vc-select2}/Selector/MultipleSelector.tsx (97%) rename components/{vc-select copy => vc-select2}/Selector/SingleSelector.tsx (100%) rename components/{vc-select copy => vc-select2}/Selector/index.tsx (100%) rename components/{vc-select copy => vc-select2}/Selector/interface.ts (100%) rename components/{vc-select copy => vc-select2}/TransBtn.tsx (100%) rename components/{vc-select copy => vc-select2}/hooks/useBaseProps.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useCache.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useDelayReset.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useFilterOptions.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useId.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useLock.ts (100%) rename components/{vc-select copy => vc-select2}/hooks/useOptions.ts (52%) rename components/{vc-select copy => vc-select2}/hooks/useSelectTriggerControl.ts (100%) rename components/{vc-select copy => vc-select2}/index.ts (100%) rename components/{vc-select copy => vc-select2}/interface.ts (100%) rename components/{vc-select copy => vc-select2}/utils/commonUtil.ts (100%) rename components/{vc-select copy => vc-select2}/utils/keyUtil.ts (100%) rename components/{vc-select copy => vc-select2}/utils/legacyUtil.ts (98%) rename components/{vc-select copy => vc-select2}/utils/platformUtil.ts (100%) rename components/{vc-select copy => vc-select2}/utils/valueUtil.ts (100%) rename components/{vc-select copy => vc-select2}/utils/warningPropsUtil.ts (100%) diff --git a/components/select/demo/label-in-value.vue b/components/select/demo/label-in-value.vue index 3bf2dff80..d28ec2312 100644 --- a/components/select/demo/label-in-value.vue +++ b/components/select/demo/label-in-value.vue @@ -31,11 +31,6 @@ The label of the selected item will be packed as an object for passing to the on import type { SelectProps } from 'ant-design-vue'; import { defineComponent, ref } from 'vue'; -interface Value { - value?: string; - label?: string; -} - export default defineComponent({ setup() { const options = ref([ @@ -48,11 +43,11 @@ export default defineComponent({ label: 'Lucy (101)', }, ]); - const handleChange = (value: Value) => { + const handleChange: SelectProps['onChange'] = value => { console.log(value); // { key: "lucy", label: "Lucy (101)" } }; return { - value: ref({ value: 'lucy' }), + value: ref({ value: 'lucy' }), options, handleChange, }; diff --git a/components/select/demo/option-label-prop.vue b/components/select/demo/option-label-prop.vue index b9813ebcf..5647a4db0 100644 --- a/components/select/demo/option-label-prop.vue +++ b/components/select/demo/option-label-prop.vue @@ -10,10 +10,13 @@ title: 使用 `optionLabelProp` 指定回填到选择框的 `Option` 属性。 +或者使用 `tagRender` 插槽自定义渲染节点 + ## en-US Spacified the prop name of Option which will be rendered in select box. +or use `tagRender` slot for custom rendering of tags.