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
11 changed files with 105 additions and 4 deletions

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. |
| `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). |
| `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

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. |
| `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

View File

@@ -38,6 +38,7 @@ Available size values for the `ui` prop: `xs`/`s`/`m`/`l`.
| `suggestions` | `Array<string>|Array<Object>` | - | [^suggestions] |
| `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] |
| `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<string>`, 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)`.

View File

@@ -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