feat: add expanded prop and toggle event for dropdowns

This commit is contained in:
Justineo 2020-11-04 18:02:44 +08:00
parent 2ce16fa0b3
commit 331ef3b628
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA
11 changed files with 105 additions and 4 deletions

View File

@ -18,6 +18,7 @@
| `placeholder` | `string=` | | 输入占位符。 | | `placeholder` | `string=` | | 输入占位符。 |
| `select-on-focus` | `boolean=` | `false` | 聚焦时是否自动选中输入框文本。 | | `select-on-focus` | `boolean=` | `false` | 聚焦时是否自动选中输入框文本。 |
| `composition` | `boolean=` | `false` | 是否感知输入法输入过程的值。 | | `composition` | `boolean=` | `false` | 是否感知输入法输入过程的值。 |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `clearable` | `boolean=` | `false` | 是否显示清除按钮。 | | `clearable` | `boolean=` | `false` | 是否显示清除按钮。 |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 |
@ -42,6 +43,14 @@
当前选中的值。 当前选中的值。
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
建议面板是否展开(如果 `suggestions` 中没有待选项,则即使为 `true` 时面板也会关闭)。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
@ -78,9 +87,10 @@
| 名称 | 描述 | | 名称 | 描述 |
| -- | -- | | -- | -- |
| input | [^event-input] | | `input` | [^event-input] |
| suggest | 采纳建议时触发,参数是当前值。 | | `suggest` | 采纳建议时触发,参数是当前值。 |
| clear | 清除当前值时触发。 | | `toggle` | 提示面板展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发提示面板展开还是收起。 |
| `clear` | 清除当前值时触发。 |
^^^event-input ^^^event-input
:::badges :::badges

View File

@ -39,6 +39,7 @@
| `format` | `string|function(Date): string=` | `'yyyy-MM-dd'`/`'yyyy-MM'`/`'yyyy'` | 使用字符串时,表示用于格式化/解析的字符串表达式,具体格式可以参见 [date-fns 的文档](https://date-fns.org/v2.12.0/docs/format)。传入函数可自定义格式化逻辑。 | | `format` | `string|function(Date): string=` | `'yyyy-MM-dd'`/`'yyyy-MM'`/`'yyyy'` | 使用字符串时,表示用于格式化/解析的字符串表达式,具体格式可以参见 [date-fns 的文档](https://date-fns.org/v2.12.0/docs/format)。传入函数可自定义格式化逻辑。 |
| `parse` | `function(string): Date=` | - | 自定义将输入字符串解析为 `Date` 对象的函数。 | | `parse` | `function(string): Date=` | - | 自定义将输入字符串解析为 `Date` 对象的函数。 |
| `shortcuts` | `Array<Object>` | `datepicker.shortcuts` | [^shortcuts] | | `shortcuts` | `Array<Object>` | `datepicker.shortcuts` | [^shortcuts] |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 |
@ -157,6 +158,14 @@
] ]
``` ```
^^^expanded
:::badges
`.sync`
:::
下拉浮层是否展开。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
@ -184,6 +193,7 @@
| `select` | [^event-select] | | `select` | [^event-select] |
| `selectstart` | 选择日期范围时,选择完起始日期时触发,回调参数 `(picking: Date)`,表示已选的起始项日期。 | | `selectstart` | 选择日期范围时,选择完起始日期时触发,回调参数 `(picking: Date)`,表示已选的起始项日期。 |
| `selectprogress` | [^event-selectprogress] | | `selectprogress` | [^event-selectprogress] |
| `toggle` | 下拉浮层展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉浮层展开还是收起。 |
^^^event-select ^^^event-select
:::badges :::badges

View File

@ -53,6 +53,7 @@
| `label` | `string` | - | 下拉按钮的描述文本。 | | `label` | `string` | - | 下拉按钮的描述文本。 |
| `trigger` | `string=` | `'click'` | 触发下拉框展开的时机,可选值为 `'click'`/`'hover'`。 | | `trigger` | `string=` | `'click'` | 触发下拉框展开的时机,可选值为 `'click'`/`'hover'`。 |
| `split` | `boolean=` | `false` | 是否将下拉按钮分离为指令按钮和切换下拉按钮两部分。 | | `split` | `boolean=` | `false` | 是否将下拉按钮分离为指令按钮和切换下拉按钮两部分。 |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `overlay-class` | `string|Array|Object=` | - | 参考 [Overlay](./overlay) 组件的 [`overlay-class` 属性](./overlay#属性)。 | | `overlay-class` | `string|Array|Object=` | - | 参考 [Overlay](./overlay) 组件的 [`overlay-class` 属性](./overlay#属性)。 |
@ -84,11 +85,19 @@
+++ +++
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
下拉菜单是否展开。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
| -- | -- | | -- | -- |
| `default` | 选项列表的内容。在没有指定 `options` 属性时,可以用来直接内联 `Option``OptionGroup` | | `default` | 选项列表的内容。在没有指定 `options` 属性时,可以用来直接内联 `Option``OptionGroup` |
| `before` | 选项列表前的内容。无默认内容。 | | `before` | 选项列表前的内容。无默认内容。 |
| `after` | 选项列表后的内容。无默认内容。 | | `after` | 选项列表后的内容。无默认内容。 |
| `label` | [^scoped-slot-label] | | `label` | [^scoped-slot-label] |
@ -160,6 +169,7 @@
| 名称 | 描述 | | 名称 | 描述 |
| -- | -- | | -- | -- |
| `click` | 点击选项后触发,回调参数为 `(value: *=)`。`value` 为当前已选项 `value` 字段的值。当 `split` 属性为 `true` 时,直接点击指令按钮部分也会触发,但不会携带 `value` 参数。 | | `click` | 点击选项后触发,回调参数为 `(value: *=)`。`value` 为当前已选项 `value` 字段的值。当 `split` 属性为 `true` 时,直接点击指令按钮部分也会触发,但不会携带 `value` 参数。 |
| `toggle` | 下拉菜单展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉菜单展开还是收起。 |
### 图标 ### 图标

View File

@ -38,6 +38,7 @@
| `suggestions` | `Array<string>|Array<Object>` | - | [^suggestions] | | `suggestions` | `Array<string>|Array<Object>` | - | [^suggestions] |
| `replace-on-select` | `boolean` | `true` | 选择推荐项时是否自动使用其内容填充文本框。 | | `replace-on-select` | `boolean` | `true` | 选择推荐项时是否自动使用其内容填充文本框。 |
| `suggest-trigger` | `Array<string>|string` | `input` | [^suggest-trigger] | | `suggest-trigger` | `Array<string>|string` | `input` | [^suggest-trigger] |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 |
@ -86,6 +87,14 @@
+++ +++
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
建议面板是否展开(如果 `suggestions` 中没有待选项,则即使为 `true` 时面板也会关闭)。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
@ -127,6 +136,7 @@
| `suggest` | [^event-suggest] | | `suggest` | [^event-suggest] |
| `select` | [^event-select] | | `select` | [^event-select] |
| `search` | [^event-search] | | `search` | [^event-search] |
| `toggle` | 提示面板展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发提示面板展开还是收起。 |
^^^event-input ^^^event-input
输入框中文本发生变化时触发该事件,回调参数为 `(value: string)` 输入框中文本发生变化时触发该事件,回调参数为 `(value: string)`

View File

@ -45,6 +45,7 @@
| `clearable` | `boolean` | `false` | 是否可以清除已选内容。 | | `clearable` | `boolean` | `false` | 是否可以清除已选内容。 |
| `searchable` | `boolean` | `false` | 是否允许搜索选项。 | | `searchable` | `boolean` | `false` | 是否允许搜索选项。 |
| `filter` | `function` | - | 选项过滤函数,签名为 `function(option: Object): boolean`。`option` 类型与 `options` 属性中的项相同。返回值表示是否将结果保留在下拉选项列表中。 | | `filter` | `function` | - | 选项过滤函数,签名为 `function(option: Object): boolean`。`option` 类型与 `options` 属性中的项相同。返回值表示是否将结果保留在下拉选项列表中。 |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 |
| `overlay-class` | `string|Array|Object=` | - | 参考 [Overlay](./overlay) 组件的 [`overlay-class` 属性](./overlay#属性)。 | | `overlay-class` | `string|Array|Object=` | - | 参考 [Overlay](./overlay) 组件的 [`overlay-class` 属性](./overlay#属性)。 |
@ -83,6 +84,14 @@
已选值。 已选值。
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
下拉菜单是否展开。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
@ -166,6 +175,7 @@
| 名称 | 描述 | | 名称 | 描述 |
| -- | -- | | -- | -- |
| `change` | [^event-change] | | `change` | [^event-change] |
| `toggle` | 下拉菜单展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉菜单展开还是收起。 |
^^^event-change ^^^event-change
:::badges :::badges

View File

@ -37,6 +37,7 @@
| `max` | `string` | - | 最大值限制。 | | `max` | `string` | - | 最大值限制。 |
| `autofocus` | `boolean` | `false` | 是否自动获得焦点。 | | `autofocus` | `boolean` | `false` | 是否自动获得焦点。 |
| `clearable` | `boolean` | `false` | 已选值是否可以清除。 | | `clearable` | `boolean` | `false` | 已选值是否可以清除。 |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 |
| `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 |
@ -59,6 +60,14 @@
当前选中的值。 当前选中的值。
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
下拉浮层是否展开。
^^^
### 插槽 ### 插槽
| 名称 | 描述 | | 名称 | 描述 |
@ -85,6 +94,7 @@
| -- | -- | | -- | -- |
| `input` | [^event-input] | | `input` | [^event-input] |
| `change` | 若当前选中的值发生变化,在时间选择下拉面板关闭时会触发该事件,参数是当前选中值。 | | `change` | 若当前选中的值发生变化,在时间选择下拉面板关闭时会触发该事件,参数是当前选中值。 |
| `toggle` | 下拉浮层展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉浮层展开还是收起。 |
| `clear` | 清除当前选中的值。 | | `clear` | 清除当前选中的值。 |
^^^event-input ^^^event-input

View File

@ -182,6 +182,7 @@
| 字段 | 类型 | 描述 | | 字段 | 类型 | 描述 |
| -- | -- | -- | | -- | -- | -- |
| `name` | `string` | 操作项的名称,点击该按钮后会抛出同名的事件,事件的回调参数为 `(file: Object, index: number)` `file` 为触发事件的文件对象,`index` 为文件在列表中的序号。 | | `name` | `string` | 操作项的名称,点击该按钮后会抛出同名的事件,事件的回调参数为 `(file: Object, index: number)` `file` 为触发事件的文件对象,`index` 为文件在列表中的序号。 |
| `label` | `string` | 操作项的文字描述。 |
| `icon` | `string` | 操作项使用的图标。 | | `icon` | `string` | 操作项使用的图标。 |
| `disabled` | `boolean=` | 操作项是否被禁用。如果该字段为空,则该操作项的禁用状态跟随组件整体的禁用状态。 | | `disabled` | `boolean=` | 操作项是否被禁用。如果该字段为空,则该操作项的禁用状态跟随组件整体的禁用状态。 |
^^^ ^^^

View File

@ -40,6 +40,7 @@ When selecting a date range, the `shortcuts` prop can be used to provide predefi
| `parse` | `function(string): Date=` | Custom function to parse the input string expressions into `Date` objects. | | `parse` | `function(string): Date=` | Custom function to parse the input string expressions into `Date` objects. |
| `shortcuts` | `Array<Object>=` | `datepicker.shortcuts` | [^shortcuts] | | `shortcuts` | `Array<Object>=` | `datepicker.shortcuts` | [^shortcuts] |
| `shortcuts-position` | `string=` | `datepicker.shortcutsPosition` | The position of shortcuts. Can be either `'before'` or `'after'`, corresponding to the before or after the content of the month panel respectively. Can be [globally configured](./calendar#global-config). | | `shortcuts-position` | `string=` | `datepicker.shortcutsPosition` | The position of shortcuts. Can be either `'before'` or `'after'`, corresponding to the before or after the content of the month panel respectively. Can be [globally configured](./calendar#global-config). |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | Whether the date picker is disabled. | | `disabled` | `boolean=` | `false` | Whether the date picker is disabled. |
| `readonly` | `boolean=` | `false` | Whether the date picker is read-only. | | `readonly` | `boolean=` | `false` | Whether the date picker is read-only. |
@ -160,6 +161,14 @@ The following example with `label`s may help to better understand the calculatio
] ]
``` ```
^^^expanded
:::badges
`.sync`
:::
Whether the dropdown overlay is expanded.
^^^
### Slots ### Slots
| Name | Description | | Name | Description |
@ -185,6 +194,7 @@ The content of each date cell in the dropdown overlay. Displays the correspondin
| `select` | [^event-select] | | `select` | [^event-select] |
| `selectstart` | Triggered when selecting a date range and a start date is selected. The callback parameter list is `(picking: Date)`, being the selected start date. | | `selectstart` | Triggered when selecting a date range and a start date is selected. The callback parameter list is `(picking: Date)`, being the selected start date. |
| `selectprogress` | [^event-selectprogress] | | `selectprogress` | [^event-selectprogress] |
| `toggle` | Triggered when the expanded state is going to change. The callback parameter list is `(expanded: boolean)`. `expanded` denotes whether the dropdown overlay is to be expanded or collapsed. |
^^^event-select ^^^event-select
:::badges :::badges

View File

@ -53,6 +53,7 @@ Use the `trigger` prop to specify when to open the dropdown menu. Use the `split
| `label` | `string` | - | The descriptive label of the dropdown button. | | `label` | `string` | - | The descriptive label of the dropdown button. |
| `trigger` | `string=` | `'click'` | When to trigger the dropdown to open. Available values are `'click'`/`'hover'`. | | `trigger` | `string=` | `'click'` | When to trigger the dropdown to open. Available values are `'click'`/`'hover'`. |
| `split` | `boolean=` | `false` | Whether to split the dropdown button into a command button and a toggle button for the dropdown layer. | | `split` | `boolean=` | `false` | Whether to split the dropdown button into a command button and a toggle button for the dropdown layer. |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | Whether the dropdown is disabled. | | `disabled` | `boolean=` | `false` | Whether the dropdown is disabled. |
| `overlay-class` | `string|Array|Object=` | - | See the `overlay-class` prop of [`Overlay`](./overlay). | | `overlay-class` | `string|Array|Object=` | - | See the `overlay-class` prop of [`Overlay`](./overlay). |
@ -83,6 +84,14 @@ The list of options with the option type being `{label, value, dropdown, disable
+++ +++
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
Whether the dropdown menu is expanded.
^^^
### Slots ### Slots
| Name | Description | | Name | Description |
@ -153,6 +162,7 @@ Additionally, custom properties in current option, apart from the listed ones, w
| Name | Description | | Name | Description |
| -- | -- | | -- | -- |
| `click` | Triggered when an option is clicked. The callback parameter list is `(value: *=)`. `value` is the `value` property of the option being clicked. Also triggered when `split` is `true` and the command button is clicked, in this case there won't be a `value` argument. | | `click` | Triggered when an option is clicked. The callback parameter list is `(value: *=)`. `value` is the `value` property of the option being clicked. Also triggered when `split` is `true` and the command button is clicked, in this case there won't be a `value` argument. |
| `toggle` | Triggered when the expanded state is going to change. The callback parameter list is `(expanded: boolean)`. `expanded` denotes whether the dropdown menu is to be expanded or collapsed. |
### Icons ### Icons

View File

@ -38,6 +38,7 @@ Available size values for the `ui` prop: `xs`/`s`/`m`/`l`.
| `suggestions` | `Array<string>|Array<Object>` | - | [^suggestions] | | `suggestions` | `Array<string>|Array<Object>` | - | [^suggestions] |
| `replace-on-select` | `boolean` | `true` | Whether to replace the content with suggestion item value when it's selected. | | `replace-on-select` | `boolean` | `true` | Whether to replace the content with suggestion item value when it's selected. |
| `suggest-trigger` | `Array<string>|string` | `input` | [^suggest-trigger] | | `suggest-trigger` | `Array<string>|string` | `input` | [^suggest-trigger] |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | Whether the search box is disabled. | | `disabled` | `boolean=` | `false` | Whether the search box is disabled. |
| `readonly` | `boolean=` | `false` | Whether the search box is read-only. | | `readonly` | `boolean=` | `false` | Whether the search box is read-only. |
@ -87,6 +88,14 @@ Specifies when the suggestion list is displayed. Can be either an event name or
+++ +++
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
Whether the suggestion list is expanded (if there are no items in `suggestions`, the list won't be expanded even the value is `false`).
^^^
### Slots ### Slots
| Name | Description | | Name | Description |
@ -128,6 +137,7 @@ When `suggestions` is an `Array<string>`, the `label` and `value` of the suggest
| `suggest` | [^event-suggest] | | `suggest` | [^event-suggest] |
| `select` | [^event-select] | | `select` | [^event-select] |
| `search` | [^event-search] | | `search` | [^event-search] |
| `toggle` | Triggered when the expanded state is going to change. The callback parameter list is `(expanded: boolean)`. `expanded` denotes whether the suggestion list is to be expanded or collapsed. |
^^^event-input ^^^event-input
Triggers when the input value changes. The callback parameter list is `(value: string)`. Triggers when the input value changes. The callback parameter list is `(value: string)`.

View File

@ -45,6 +45,7 @@ Use the `multiple` prop to enable multiple selections.
| `clearable` | `boolean` | `false` | Whether the select is clearable. | | `clearable` | `boolean` | `false` | Whether the select is clearable. |
| `searchable` | `boolean` | `false` | Whether the options are searchable. | | `searchable` | `boolean` | `false` | Whether the options are searchable. |
| `filter` | `function` | - | Filter function for the options. The type is `function(option: Object): boolean`. The type of `option` is the same as the `options` prop. The return value denotes whether the option is shown inside the options dropdown. | | `filter` | `function` | - | Filter function for the options. The type is `function(option: Object): boolean`. The type of `option` is the same as the `options` prop. The return value denotes whether the option is shown inside the options dropdown. |
| `expanded` | `boolean=` | `false` | [^expanded] |
| `disabled` | `boolean=` | `false` | Whether the select is disabled. | | `disabled` | `boolean=` | `false` | Whether the select is disabled. |
| `readonly` | `boolean=` | `false` | Whether the select is read-only. | | `readonly` | `boolean=` | `false` | Whether the select is read-only. |
| `overlay-class` | `string|Array|Object=` | - | See the `overlay-class` prop of [`Overlay`](./overlay). | | `overlay-class` | `string|Array|Object=` | - | See the `overlay-class` prop of [`Overlay`](./overlay). |
@ -82,6 +83,14 @@ The list of options with the option type being `{label, value, options, disabled
The value of the selected option. The value of the selected option.
^^^ ^^^
^^^expanded
:::badges
`.sync`
:::
Whether the dropdown menu is expanded.
^^^
### Slots ### Slots
| Name | Description | | Name | Description |
@ -157,6 +166,7 @@ Additionally, custom properties in current option, apart from the listed ones, w
| Name | Description | | Name | Description |
| -- | -- | | -- | -- |
| `change` | [^event-change] | | `change` | [^event-change] |
| `toggle` | Triggered when the expanded state is going to change. The callback parameter list is `(expanded: boolean)`. `expanded` denotes whether the dropdown menu is to be expanded or collapsed. |
^^^event-change ^^^event-change
:::badges :::badges