From 4f9f27d40dc16bdd80f2ec6e41016ab7f70a50d1 Mon Sep 17 00:00:00 2001 From: Alan Wang Date: Tue, 18 Jan 2022 11:24:54 +0800 Subject: [PATCH] feat: [el-select-v2]add reserve-keyword and change docs (#5308) * feat: [el-select-v2]add reserve-keyword and change docs * fix(components): [el-select-v2]add test case --- docs/en-US/component/select-v2.md | 79 ++++++++++--------- docs/examples/select-v2/allow-create.vue | 59 +++++++++----- .../select-v2/__tests__/select.spec.ts | 66 ++++++++++++++++ packages/components/select-v2/src/defaults.ts | 5 +- .../components/select-v2/src/useSelect.ts | 2 +- 5 files changed, 153 insertions(+), 58 deletions(-) diff --git a/docs/en-US/component/select-v2.md b/docs/en-US/component/select-v2.md index b0c27dff2a..10d46ddb75 100644 --- a/docs/en-US/component/select-v2.md +++ b/docs/en-US/component/select-v2.md @@ -98,7 +98,15 @@ select-v2/clearable Create and select new items that are not included in select options -:::demo By using the `allow-create` attribute, users can create new items by typing in the input box. Note that for `allow-create` to work, `filterable` must be `true`. +By using the `allow-create` attribute, users can create new items by typing in the input box. Note that for `allow-create` to work, `filterable` must be `true`. + +:::tip + +It will be better to set `:reserve-keyword="false"` when use `allow-create` + +::: + +:::demo select-v2/allow-create @@ -116,39 +124,37 @@ select-v2/remote-search ## SelectV2 Attributes -| Param | Description | Type | Accepted Values | Default | -| --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------- | ------------- | -| model-value / v-model | biding value | string / number / boolean / object | — | — | -| multiple | is multiple | boolean | — | false | -| disabled | is disabled | boolean | — | false | -| value-key | unique identity key name for value, required when value is an object | string | — | value | -| size | input box size | string | large/default/small | default | -| clearable | whether select can be cleared | boolean | — | false | -| collapse-tags | whether to collapse tags to a text when multiple selecting | boolean | — | false | -| multiple-limit | maximum number of options user can select when multiple is true. No limit when set to 0 | number | — | 0 | -| name | the name attribute of select input | string | — | — | -| autocomplete | select input 的 autocomplete 属性 | string | — | off | -| placeholder | the autocomplete attribute of select input | string | — | Please select | -| filterable | is filterable | boolean | — | false | -| allow-create | whether creating new items is allowed. To use this, `filterable` must be true | boolean | — | false | -| no-data-text | displayed text when there is no options, you can also use slot empty | string | — | No Data | -| popper-class | custom class name for Select's dropdown | string | — | — | -| popper-append-to-body | whether to append the popper menu to body. If the positioning of the popper is wrong, you can try to set this prop to false | boolean | - | false | -| popper-options | Customized popper option see more at [popper.js](https://popper.js.org/documentation.html) | object | - | - | -| automatic-dropdown | for non-filterable Select, this prop decides if the option menu pops up when the input is focused | boolean | - | false | -| clear-icon | Customized clear icon component | string / Component | — | CircleClose | -| height | The height of the dropdown panel, 34px for each item | number | - | 170 | -| scrollbar-always-on | Controls whether the scrollbar is always displayed | boolean | - | false | +| Param | Description | Type | Accepted Values | Default | +| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------- | ------------- | +| model-value / v-model | biding value | string / number / boolean / object | — | — | +| multiple | is multiple | boolean | — | false | +| disabled | is disabled | boolean | — | false | +| value-key | unique identity key name for value, required when value is an object | string | — | value | +| size | input box size | string | large/default/small | default | +| clearable | whether select can be cleared | boolean | — | false | +| clear-icon | custom clear icon | string / component | — | CircleClose | +| collapse-tags | whether to collapse tags to a text when multiple selecting | boolean | — | false | +| multiple-limit | maximum number of options user can select when multiple is true. No limit when set to 0 | number | — | 0 | +| name | the name attribute of select input | string | — | — | +| autocomplete | autocomplete of select input | string | — | off | +| placeholder | the autocomplete attribute of select input | string | — | Please select | +| filterable | is filterable | boolean | — | false | +| allow-create | whether creating new items is allowed. To use this, `filterable` must be true | boolean | — | false | +| reserve-keyword | whether reserve the keyword after select filtered option. | boolean | — | true | +| no-data-text | displayed text when there is no options, you can also use slot empty | string | — | No Data | +| popper-class | custom class name for Select's dropdown | string | — | — | +| popper-append-to-body | whether to append the popper menu to body. If the positioning of the popper is wrong, you can try to set this prop to false | boolean | - | false | +| popper-options | Customized popper option see more at [popper.js](https://popper.js.org/documentation.html) | object | - | - | +| automatic-dropdown | for non-filterable Select, this prop decides if the option menu pops up when the input is focused | boolean | - | false | +| clear-icon | Customized clear icon component | string / Component | — | CircleClose | +| height | The height of the dropdown panel, 34px for each item | number | - | 170 | +| scrollbar-always-on | Controls whether the scrollbar is always displayed | boolean | - | false | +| remote | whether search data from server | boolean | — | false | +| remote-method | function that gets called when the input value changes. Its parameter is the current input value. To use this, `filterable` must be true | function(keyword: string) | — | — | - - @@ -166,9 +172,8 @@ select-v2/remote-search ## SelectV2 Slots -| name | 说明 | -| ------- | ------------------ | -| default | Option renderer | -| empty | 无 Option 时的列表 | - - +| name | Description | +| ------- | ----------------------------- | +| default | Option renderer | +| empty | content when options is empty | +| prefix | prefix content of input | diff --git a/docs/examples/select-v2/allow-create.vue b/docs/examples/select-v2/allow-create.vue index 02f3a45ace..6a69b5a65a 100644 --- a/docs/examples/select-v2/allow-create.vue +++ b/docs/examples/select-v2/allow-create.vue @@ -1,23 +1,43 @@