From 331ef3b628706adfad2aa2a8fd33c4b78eecda7b Mon Sep 17 00:00:00 2001 From: Justineo Date: Wed, 4 Nov 2020 18:02:44 +0800 Subject: [PATCH] feat: add `expanded` prop and `toggle` event for dropdowns --- one/docs/components/autocomplete.md | 16 +++++++++++++--- one/docs/components/date-picker.md | 10 ++++++++++ one/docs/components/dropdown.md | 12 +++++++++++- one/docs/components/search-box.md | 10 ++++++++++ one/docs/components/select.md | 10 ++++++++++ one/docs/components/time-picker.md | 10 ++++++++++ one/docs/components/uploader.md | 1 + one/docs/en-US/components/date-picker.md | 10 ++++++++++ one/docs/en-US/components/dropdown.md | 10 ++++++++++ one/docs/en-US/components/search-box.md | 10 ++++++++++ one/docs/en-US/components/select.md | 10 ++++++++++ 11 files changed, 105 insertions(+), 4 deletions(-) diff --git a/one/docs/components/autocomplete.md b/one/docs/components/autocomplete.md index 3cfc0a5..3ce0ee7 100644 --- a/one/docs/components/autocomplete.md +++ b/one/docs/components/autocomplete.md @@ -18,6 +18,7 @@ | `placeholder` | `string=` | | 输入占位符。 | | `select-on-focus` | `boolean=` | `false` | 聚焦时是否自动选中输入框文本。 | | `composition` | `boolean=` | `false` | 是否感知输入法输入过程的值。 | +| `expanded` | `boolean=` | `false` | [^expanded] | | `clearable` | `boolean=` | `false` | 是否显示清除按钮。 | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 | @@ -42,6 +43,14 @@ 当前选中的值。 ^^^ +^^^expanded +:::badges +`.sync` +::: + +建议面板是否展开(如果 `suggestions` 中没有待选项,则即使为 `true` 时面板也会关闭)。 +^^^ + ### 插槽 | 名称 | 描述 | @@ -78,9 +87,10 @@ | 名称 | 描述 | | -- | -- | -| input | [^event-input] | -| suggest | 采纳建议时触发,参数是当前值。 | -| clear | 清除当前值时触发。 | +| `input` | [^event-input] | +| `suggest` | 采纳建议时触发,参数是当前值。 | +| `toggle` | 提示面板展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发提示面板展开还是收起。 | +| `clear` | 清除当前值时触发。 | ^^^event-input :::badges diff --git a/one/docs/components/date-picker.md b/one/docs/components/date-picker.md index 18a2d9c..e16d60c 100644 --- a/one/docs/components/date-picker.md +++ b/one/docs/components/date-picker.md @@ -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)。传入函数可自定义格式化逻辑。 | | `parse` | `function(string): Date=` | - | 自定义将输入字符串解析为 `Date` 对象的函数。 | | `shortcuts` | `Array` | `datepicker.shortcuts` | [^shortcuts] | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 | @@ -157,6 +158,14 @@ ] ``` +^^^expanded +:::badges +`.sync` +::: + +下拉浮层是否展开。 +^^^ + ### 插槽 | 名称 | 描述 | @@ -184,6 +193,7 @@ | `select` | [^event-select] | | `selectstart` | 选择日期范围时,选择完起始日期时触发,回调参数 `(picking: Date)`,表示已选的起始项日期。 | | `selectprogress` | [^event-selectprogress] | +| `toggle` | 下拉浮层展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉浮层展开还是收起。 | ^^^event-select :::badges diff --git a/one/docs/components/dropdown.md b/one/docs/components/dropdown.md index 3342275..2ab5491 100644 --- a/one/docs/components/dropdown.md +++ b/one/docs/components/dropdown.md @@ -53,6 +53,7 @@ | `label` | `string` | - | 下拉按钮的描述文本。 | | `trigger` | `string=` | `'click'` | 触发下拉框展开的时机,可选值为 `'click'`/`'hover'`。 | | `split` | `boolean=` | `false` | 是否将下拉按钮分离为指令按钮和切换下拉按钮两部分。 | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `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` | 选项列表前的内容。无默认内容。 | | `after` | 选项列表后的内容。无默认内容。 | | `label` | [^scoped-slot-label] | @@ -160,6 +169,7 @@ | 名称 | 描述 | | -- | -- | | `click` | 点击选项后触发,回调参数为 `(value: *=)`。`value` 为当前已选项 `value` 字段的值。当 `split` 属性为 `true` 时,直接点击指令按钮部分也会触发,但不会携带 `value` 参数。 | +| `toggle` | 下拉菜单展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉菜单展开还是收起。 | ### 图标 diff --git a/one/docs/components/search-box.md b/one/docs/components/search-box.md index b485f93..dd498ee 100644 --- a/one/docs/components/search-box.md +++ b/one/docs/components/search-box.md @@ -38,6 +38,7 @@ | `suggestions` | `Array|Array` | - | [^suggestions] | | `replace-on-select` | `boolean` | `true` | 选择推荐项时是否自动使用其内容填充文本框。 | | `suggest-trigger` | `Array|string` | `input` | [^suggest-trigger] | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 | @@ -86,6 +87,14 @@ +++ ^^^ +^^^expanded +:::badges +`.sync` +::: + +建议面板是否展开(如果 `suggestions` 中没有待选项,则即使为 `true` 时面板也会关闭)。 +^^^ + ### 插槽 | 名称 | 描述 | @@ -127,6 +136,7 @@ | `suggest` | [^event-suggest] | | `select` | [^event-select] | | `search` | [^event-search] | +| `toggle` | 提示面板展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发提示面板展开还是收起。 | ^^^event-input 输入框中文本发生变化时触发该事件,回调参数为 `(value: string)`。 diff --git a/one/docs/components/select.md b/one/docs/components/select.md index d36cb39..ccb477c 100644 --- a/one/docs/components/select.md +++ b/one/docs/components/select.md @@ -45,6 +45,7 @@ | `clearable` | `boolean` | `false` | 是否可以清除已选内容。 | | `searchable` | `boolean` | `false` | 是否允许搜索选项。 | | `filter` | `function` | - | 选项过滤函数,签名为 `function(option: Object): boolean`。`option` 类型与 `options` 属性中的项相同。返回值表示是否将结果保留在下拉选项列表中。 | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 | | `overlay-class` | `string|Array|Object=` | - | 参考 [Overlay](./overlay) 组件的 [`overlay-class` 属性](./overlay#属性)。 | @@ -83,6 +84,14 @@ 已选值。 ^^^ +^^^expanded +:::badges +`.sync` +::: + +下拉菜单是否展开。 +^^^ + ### 插槽 | 名称 | 描述 | @@ -166,6 +175,7 @@ | 名称 | 描述 | | -- | -- | | `change` | [^event-change] | +| `toggle` | 下拉菜单展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉菜单展开还是收起。 | ^^^event-change :::badges diff --git a/one/docs/components/time-picker.md b/one/docs/components/time-picker.md index c1c055f..cf1c50e 100644 --- a/one/docs/components/time-picker.md +++ b/one/docs/components/time-picker.md @@ -37,6 +37,7 @@ | `max` | `string` | - | 最大值限制。 | | `autofocus` | `boolean` | `false` | 是否自动获得焦点。 | | `clearable` | `boolean` | `false` | 已选值是否可以清除。 | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | 是否为禁用状态。 | | `readonly` | `boolean=` | `false` | 是否为只读状态。 | @@ -59,6 +60,14 @@ 当前选中的值。 ^^^ +^^^expanded +:::badges +`.sync` +::: + +下拉浮层是否展开。 +^^^ + ### 插槽 | 名称 | 描述 | @@ -85,6 +94,7 @@ | -- | -- | | `input` | [^event-input] | | `change` | 若当前选中的值发生变化,在时间选择下拉面板关闭时会触发该事件,参数是当前选中值。 | +| `toggle` | 下拉浮层展开状态切换时触发,回调参数为 `(expanded: boolean)`。`expanded` 表示操作将触发下拉浮层展开还是收起。 | | `clear` | 清除当前选中的值。 | ^^^event-input diff --git a/one/docs/components/uploader.md b/one/docs/components/uploader.md index d93aac2..5f07057 100644 --- a/one/docs/components/uploader.md +++ b/one/docs/components/uploader.md @@ -182,6 +182,7 @@ | 字段 | 类型 | 描述 | | -- | -- | -- | | `name` | `string` | 操作项的名称,点击该按钮后会抛出同名的事件,事件的回调参数为 `(file: Object, index: number)`, `file` 为触发事件的文件对象,`index` 为文件在列表中的序号。 | +| `label` | `string` | 操作项的文字描述。 | | `icon` | `string` | 操作项使用的图标。 | | `disabled` | `boolean=` | 操作项是否被禁用。如果该字段为空,则该操作项的禁用状态跟随组件整体的禁用状态。 | ^^^ diff --git a/one/docs/en-US/components/date-picker.md b/one/docs/en-US/components/date-picker.md index 8cd91a3..d0de2d0 100644 --- a/one/docs/en-US/components/date-picker.md +++ b/one/docs/en-US/components/date-picker.md @@ -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. | | `shortcuts` | `Array=` | `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). | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | Whether the date picker is disabled. | | `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 | Name | Description | @@ -185,6 +194,7 @@ The content of each date cell in the dropdown overlay. Displays the correspondin | `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. | | `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 :::badges diff --git a/one/docs/en-US/components/dropdown.md b/one/docs/en-US/components/dropdown.md index 81c7e7a..c08797d 100644 --- a/one/docs/en-US/components/dropdown.md +++ b/one/docs/en-US/components/dropdown.md @@ -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. | | `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. | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | Whether the dropdown is disabled. | | `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 | Name | Description | @@ -153,6 +162,7 @@ Additionally, custom properties in current option, apart from the listed ones, w | 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. | +| `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 diff --git a/one/docs/en-US/components/search-box.md b/one/docs/en-US/components/search-box.md index f029ba4..25921f6 100644 --- a/one/docs/en-US/components/search-box.md +++ b/one/docs/en-US/components/search-box.md @@ -38,6 +38,7 @@ Available size values for the `ui` prop: `xs`/`s`/`m`/`l`. | `suggestions` | `Array|Array` | - | [^suggestions] | | `replace-on-select` | `boolean` | `true` | Whether to replace the content with suggestion item value when it's selected. | | `suggest-trigger` | `Array|string` | `input` | [^suggest-trigger] | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | Whether the search box is disabled. | | `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 | Name | Description | @@ -128,6 +137,7 @@ When `suggestions` is an `Array`, the `label` and `value` of the suggest | `suggest` | [^event-suggest] | | `select` | [^event-select] | | `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 Triggers when the input value changes. The callback parameter list is `(value: string)`. diff --git a/one/docs/en-US/components/select.md b/one/docs/en-US/components/select.md index 81cef79..ba36ad3 100644 --- a/one/docs/en-US/components/select.md +++ b/one/docs/en-US/components/select.md @@ -45,6 +45,7 @@ Use the `multiple` prop to enable multiple selections. | `clearable` | `boolean` | `false` | Whether the select is clearable. | | `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. | +| `expanded` | `boolean=` | `false` | [^expanded] | | `disabled` | `boolean=` | `false` | Whether the select is disabled. | | `readonly` | `boolean=` | `false` | Whether the select is read-only. | | `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. ^^^ +^^^expanded +:::badges +`.sync` +::: + +Whether the dropdown menu is expanded. +^^^ + ### Slots | Name | Description | @@ -157,6 +166,7 @@ Additionally, custom properties in current option, apart from the listed ones, w | Name | Description | | -- | -- | | `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 :::badges