@warp-ds/elements 2.10.0-next.2 → 2.10.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/custom-elements.json +140 -69
  2. package/dist/docs/combobox/accessibility.md +71 -0
  3. package/dist/docs/combobox/api.md +60 -30
  4. package/dist/docs/combobox/combobox.md +203 -30
  5. package/dist/docs/combobox/examples.md +44 -0
  6. package/dist/docs/combobox/usage.md +28 -0
  7. package/dist/docs/icon/accessibility.md +5 -0
  8. package/dist/docs/icon/api.md +37 -0
  9. package/dist/docs/icon/examples.md +45 -0
  10. package/dist/docs/icon/icon.md +107 -0
  11. package/dist/docs/icon/usage.md +11 -0
  12. package/dist/docs/link/api.md +18 -22
  13. package/dist/docs/link/examples.md +75 -0
  14. package/dist/docs/link/link.md +111 -22
  15. package/dist/docs/link/usage.md +18 -0
  16. package/dist/index.d.ts +443 -171
  17. package/dist/packages/affix/affix.js +3 -3
  18. package/dist/packages/affix/affix.js.map +3 -3
  19. package/dist/packages/alert/alert.js +1 -1
  20. package/dist/packages/alert/alert.js.map +3 -3
  21. package/dist/packages/attention/attention.js.map +3 -3
  22. package/dist/packages/button/button.js.map +2 -2
  23. package/dist/packages/checkbox/checkbox.d.ts +40 -11
  24. package/dist/packages/checkbox/checkbox.js.map +2 -2
  25. package/dist/packages/checkbox-group/checkbox-group.d.ts +30 -5
  26. package/dist/packages/checkbox-group/checkbox-group.js.map +2 -2
  27. package/dist/packages/combobox/combobox.a11y.test.js +24 -0
  28. package/dist/packages/combobox/combobox.d.ts +65 -45
  29. package/dist/packages/combobox/combobox.hydration.test.js +39 -1
  30. package/dist/packages/combobox/combobox.js +13 -13
  31. package/dist/packages/combobox/combobox.js.map +3 -3
  32. package/dist/packages/combobox/combobox.stories.js +28 -15
  33. package/dist/packages/combobox/combobox.test.js +110 -0
  34. package/dist/packages/datepicker/datepicker.js.map +3 -3
  35. package/dist/packages/expandable/expandable.js +2 -2
  36. package/dist/packages/expandable/expandable.js.map +3 -3
  37. package/dist/packages/icon/icon.d.ts +13 -3
  38. package/dist/packages/icon/icon.js +2 -2
  39. package/dist/packages/icon/icon.js.map +3 -3
  40. package/dist/packages/icon/icon.react.stories.d.ts +1 -1
  41. package/dist/packages/icon/react.d.ts +2 -2
  42. package/dist/packages/link/link.d.ts +15 -16
  43. package/dist/packages/link/link.js.map +2 -2
  44. package/dist/packages/modal-header/modal-header.js +1 -1
  45. package/dist/packages/modal-header/modal-header.js.map +3 -3
  46. package/dist/packages/pagination/pagination.js.map +3 -3
  47. package/dist/packages/pill/pill.js.map +3 -3
  48. package/dist/packages/select/select.js.map +3 -3
  49. package/dist/packages/step/step.js +1 -1
  50. package/dist/packages/step/step.js.map +3 -3
  51. package/dist/packages/toast/toast.js +3 -3
  52. package/dist/packages/toast/toast.js.map +3 -3
  53. package/dist/packages/toast/toast.stories.d.ts +1 -5
  54. package/dist/packages/toast/toast.stories.js +0 -17
  55. package/dist/web-types.json +129 -72
  56. package/package.json +1 -1
@@ -1 +1,72 @@
1
1
  ## Accessibility
2
+
3
+ Combobox renders an input with `role="combobox"` and a popup list with `role="listbox"`. Each suggestion is rendered with `role="option"`, and the active suggestion is connected to the input with `aria-activedescendant`.
4
+
5
+ ### Provide A Label
6
+
7
+ Always provide a visible label.
8
+
9
+ ```html
10
+ <w-combobox label="Country" placeholder="Search">
11
+ <option value="no">Norway</option>
12
+ <option value="se">Sweden</option>
13
+ <option value="dk">Denmark</option>
14
+ </w-combobox>
15
+ ```
16
+
17
+ Do not rely on placeholder text as the only label. Placeholder text disappears as soon as the user types and is not a reliable accessible name.
18
+
19
+ ### Help Text And Errors
20
+
21
+ Use `help-text` for extra guidance or validation feedback.
22
+
23
+ ```html
24
+ <w-combobox label="Country" help-text="Start typing to filter countries">
25
+ <option value="no">Norway</option>
26
+ <option value="se">Sweden</option>
27
+ <option value="dk">Denmark</option>
28
+ </w-combobox>
29
+ ```
30
+
31
+ When the combobox is invalid, pair `invalid` with help text that explains how to correct the error.
32
+
33
+ ```html
34
+ <w-combobox label="Country" invalid help-text="Select a country from the list">
35
+ <option value="no">Norway</option>
36
+ <option value="se">Sweden</option>
37
+ <option value="dk">Denmark</option>
38
+ </w-combobox>
39
+ ```
40
+
41
+ Do not rely on invalid styling alone.
42
+
43
+ ### Keyboard Interaction
44
+
45
+ The input follows common combobox keyboard behavior:
46
+
47
+ - Arrow Down and Arrow Up open the list and move between suggestions.
48
+ - Home and End move to the first and last suggestion.
49
+ - Page Up and Page Down move through suggestions in larger steps.
50
+ - Enter selects the active suggestion.
51
+ - Escape closes the list. When the list is already closed, Escape clears the value.
52
+ - Tab closes the list and moves focus onward.
53
+
54
+ ### Suggestions
55
+
56
+ The component announces the number of available suggestions through a screen-reader-only status message while the list is open.
57
+
58
+ Keep option labels short and unique enough to distinguish. If the submitted `value` differs from what users should read, provide a clear option label.
59
+
60
+ ```html
61
+ <w-combobox label="Country" placeholder="Search">
62
+ <option value="us" label="United States">US</option>
63
+ <option value="uk" label="United Kingdom">UK</option>
64
+ <option value="no">Norway</option>
65
+ </w-combobox>
66
+ ```
67
+
68
+ ### Disabled Comboboxes
69
+
70
+ Avoid disabled comboboxes where possible. Disabled controls can be hard to discover and do not explain why the field is unavailable.
71
+
72
+ Prefer leaving the combobox enabled and showing validation or explanatory feedback when the user tries to continue.
@@ -6,125 +6,155 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
6
6
 
7
7
  | Name | Type | Default | Summary |
8
8
  |-|-|-|-|
9
- | autocomplete | `string \| undefined` | `'off'` | Autocomplete attribute for the input field |
10
- | disable-static-filtering | `boolean` | `false` | Disable client-side static filtering |
11
- | disabled | `boolean` | `false` | Whether the element is disabled |
12
- | help-text | `string \| undefined` | `''` | The content to display as the help text |
13
- | invalid | `boolean` | `false` | Renders the input field in an invalid state |
14
- | label | `string \| undefined` | `''` | Label above input |
15
- | match-text-segments | `boolean` | `false` | Whether the matching text segments in the options should be highlighted |
16
- | name | `string \| undefined` | `''` | Name attribute for form submission |
17
- | open-on-focus | `boolean` | `false` | Whether the popover opens when focus is on the text field |
18
- | optional | `boolean` | `false` | Whether to show optional text |
19
- | options | `ComboboxOption[]` | `[]` | The available options to select from |
20
- | placeholder | `string \| undefined` | `''` | Input placeholder |
21
- | required | `boolean` | `false` | Whether the element is required |
22
- | select-on-blur | `boolean` | `true` | Select active option on blur |
23
- | value | `string` | `''` | The input value |
9
+ | autocomplete | `string \| undefined` | `'off'` | The autocomplete attribute passed to the internal input. |
10
+ | disable-static-filtering | `boolean` | `false` | Whether built-in client-side filtering is disabled. |
11
+ | disabled | `boolean` | `false` | Whether the combobox is disabled. |
12
+ | help-text | `string \| undefined` | `''` | Help text displayed below the input. |
13
+ | invalid | `boolean` | `false` | Whether the combobox is visually invalid. |
14
+ | label | `string \| undefined` | `''` | The label displayed above the input. |
15
+ | match-text-segments | `boolean` | `false` | Whether matching text segments in options are highlighted. |
16
+ | name | `string \| undefined` | `''` | The name submitted with the combobox value. |
17
+ | open-on-focus | `boolean` | `false` | Whether the option list opens when the input receives focus. |
18
+ | optional | `boolean` | `false` | Whether to show optional text next to the label. |
19
+ | options | `ComboboxOption[]` | `[]` | The available options to select from. |
20
+ | placeholder | `string \| undefined` | `''` | Placeholder text displayed when the input is empty. |
21
+ | required | `boolean` | `false` | Whether the combobox is required before form submission. |
22
+ | select-on-blur | `boolean` | `true` | Whether the active option is selected when the input loses focus. |
23
+ | value | `string` | `''` | The selected or typed value. |
24
24
 
25
25
  ### Property Details
26
26
 
27
27
  #### autocomplete
28
28
 
29
- Autocomplete attribute for the input field
29
+ The autocomplete attribute passed to the internal input.
30
+
31
+ Defaults to `off`. Set this when browser autocomplete should be enabled or scoped to a specific autocomplete token.
30
32
 
31
33
  - Type: `string | undefined`
32
34
  - Default: `'off'`
33
35
 
34
36
  #### disable-static-filtering
35
37
 
36
- Disable client-side static filtering
38
+ Whether built-in client-side filtering is disabled.
39
+
40
+ Use this for remote search or externally filtered results. When disabled, all entries in `options` are rendered as provided.
37
41
 
38
42
  - Type: `boolean`
39
43
  - Default: `false`
40
44
 
41
45
  #### disabled
42
46
 
43
- Whether the element is disabled
47
+ Whether the combobox is disabled.
48
+
49
+ Disabled comboboxes cannot be focused, changed, or submitted with form data.
44
50
 
45
51
  - Type: `boolean`
46
52
  - Default: `false`
47
53
 
48
54
  #### help-text
49
55
 
50
- The content to display as the help text
56
+ Help text displayed below the input.
57
+
58
+ Use this for supporting guidance or validation feedback.
51
59
 
52
60
  - Type: `string | undefined`
53
61
  - Default: `''`
54
62
 
55
63
  #### invalid
56
64
 
57
- Renders the input field in an invalid state
65
+ Whether the combobox is visually invalid.
66
+
67
+ Use this to show an externally managed validation error. Pair it with `help-text` to explain how to fix the error.
58
68
 
59
69
  - Type: `boolean`
60
70
  - Default: `false`
61
71
 
62
72
  #### label
63
73
 
64
- Label above input
74
+ The label displayed above the input.
75
+
76
+ Use this to give the combobox a visible and accessible name.
65
77
 
66
78
  - Type: `string | undefined`
67
79
  - Default: `''`
68
80
 
69
81
  #### match-text-segments
70
82
 
71
- Whether the matching text segments in the options should be highlighted
83
+ Whether matching text segments in options are highlighted.
84
+
85
+ Use this to visually emphasize the part of each option that matches the current input value.
72
86
 
73
87
  - Type: `boolean`
74
88
  - Default: `false`
75
89
 
76
90
  #### name
77
91
 
78
- Name attribute for form submission
92
+ The name submitted with the combobox value.
93
+
94
+ Use this when the combobox belongs to a form and its value should be included in form data.
79
95
 
80
96
  - Type: `string | undefined`
81
97
  - Default: `''`
82
98
 
83
99
  #### open-on-focus
84
100
 
85
- Whether the popover opens when focus is on the text field
101
+ Whether the option list opens when the input receives focus.
102
+
103
+ Use this when users should see available options before they start typing.
86
104
 
87
105
  - Type: `boolean`
88
106
  - Default: `false`
89
107
 
90
108
  #### optional
91
109
 
92
- Whether to show optional text
110
+ Whether to show optional text next to the label.
111
+
112
+ Use this to indicate that the combobox is not required.
93
113
 
94
114
  - Type: `boolean`
95
115
  - Default: `false`
96
116
 
97
117
  #### options
98
118
 
99
- The available options to select from
119
+ The available options to select from.
120
+
121
+ Use this for framework usage, application state, or remote search results. When `options` contains entries, it is used instead of child `<option>` elements.
100
122
 
101
123
  - Type: `ComboboxOption[]`
102
124
  - Default: `[]`
103
125
 
104
126
  #### placeholder
105
127
 
106
- Input placeholder
128
+ Placeholder text displayed when the input is empty.
129
+
130
+ Use this as a short hint for the expected input. Do not use placeholder text as a replacement for a label.
107
131
 
108
132
  - Type: `string | undefined`
109
133
  - Default: `''`
110
134
 
111
135
  #### required
112
136
 
113
- Whether the element is required
137
+ Whether the combobox is required before form submission.
138
+
139
+ Use this when the user must provide a value before submitting the form.
114
140
 
115
141
  - Type: `boolean`
116
142
  - Default: `false`
117
143
 
118
144
  #### select-on-blur
119
145
 
120
- Select active option on blur
146
+ Whether the active option is selected when the input loses focus.
147
+
148
+ When enabled, the combobox selects the keyboard-highlighted option, or an option whose value exactly matches the current input value, on blur.
121
149
 
122
150
  - Type: `boolean`
123
151
  - Default: `true`
124
152
 
125
153
  #### value
126
154
 
127
- The input value
155
+ The selected or typed value.
156
+
157
+ When an option is selected, this is set to the option value. The displayed text may differ when the option has a separate label.
128
158
 
129
159
  - Type: `string`
130
160
  - Default: `''`
@@ -8,10 +8,153 @@ A combobox element for text input with selectable options.
8
8
 
9
9
  ## Usage
10
10
 
11
+ Use child `<option>` elements for declarative HTML usage.
12
+
13
+ <elements-example>
14
+
15
+ ```html
16
+ <w-combobox label="Country" placeholder="Search">
17
+ <option value="no">Norway</option>
18
+ <option value="se">Sweden</option>
19
+ <option value="dk">Denmark</option>
20
+ </w-combobox>
21
+ ```
22
+
23
+ </elements-example>
24
+
25
+ The option text is used as the visible suggestion. The `value` attribute is used as the submitted and selected value.
26
+
27
+ For framework usage or dynamic data, you may set the `options` property instead.
28
+
29
+ ```js
30
+ combobox.options = [
31
+ { value: 'no', label: 'Norway' },
32
+ { value: 'se', label: 'Sweden' },
33
+ { value: 'dk', label: 'Denmark' },
34
+ ];
35
+ ```
36
+
37
+ When `options` contains entries, it is used instead of child `<option>` elements.
38
+
11
39
  ## Accessibility
12
40
 
41
+ Combobox renders an input with `role="combobox"` and a popup list with `role="listbox"`. Each suggestion is rendered with `role="option"`, and the active suggestion is connected to the input with `aria-activedescendant`.
42
+
43
+ ### Provide A Label
44
+
45
+ Always provide a visible label.
46
+
47
+ ```html
48
+ <w-combobox label="Country" placeholder="Search">
49
+ <option value="no">Norway</option>
50
+ <option value="se">Sweden</option>
51
+ <option value="dk">Denmark</option>
52
+ </w-combobox>
53
+ ```
54
+
55
+ Do not rely on placeholder text as the only label. Placeholder text disappears as soon as the user types and is not a reliable accessible name.
56
+
57
+ ### Help Text And Errors
58
+
59
+ Use `help-text` for extra guidance or validation feedback.
60
+
61
+ ```html
62
+ <w-combobox label="Country" help-text="Start typing to filter countries">
63
+ <option value="no">Norway</option>
64
+ <option value="se">Sweden</option>
65
+ <option value="dk">Denmark</option>
66
+ </w-combobox>
67
+ ```
68
+
69
+ When the combobox is invalid, pair `invalid` with help text that explains how to correct the error.
70
+
71
+ ```html
72
+ <w-combobox label="Country" invalid help-text="Select a country from the list">
73
+ <option value="no">Norway</option>
74
+ <option value="se">Sweden</option>
75
+ <option value="dk">Denmark</option>
76
+ </w-combobox>
77
+ ```
78
+
79
+ Do not rely on invalid styling alone.
80
+
81
+ ### Keyboard Interaction
82
+
83
+ The input follows common combobox keyboard behavior:
84
+
85
+ - Arrow Down and Arrow Up open the list and move between suggestions.
86
+ - Home and End move to the first and last suggestion.
87
+ - Page Up and Page Down move through suggestions in larger steps.
88
+ - Enter selects the active suggestion.
89
+ - Escape closes the list. When the list is already closed, Escape clears the value.
90
+ - Tab closes the list and moves focus onward.
91
+
92
+ ### Suggestions
93
+
94
+ The component announces the number of available suggestions through a screen-reader-only status message while the list is open.
95
+
96
+ Keep option labels short and unique enough to distinguish. If the submitted `value` differs from what users should read, provide a clear option label.
97
+
98
+ ```html
99
+ <w-combobox label="Country" placeholder="Search">
100
+ <option value="us" label="United States">US</option>
101
+ <option value="uk" label="United Kingdom">UK</option>
102
+ <option value="no">Norway</option>
103
+ </w-combobox>
104
+ ```
105
+
106
+ ### Disabled Comboboxes
107
+
108
+ Avoid disabled comboboxes where possible. Disabled controls can be hard to discover and do not explain why the field is unavailable.
109
+
110
+ Prefer leaving the combobox enabled and showing validation or explanatory feedback when the user tries to continue.
111
+
13
112
  ## Examples
14
113
 
114
+ <elements-example>
115
+
116
+ ```html
117
+ <w-combobox label="Fruit" placeholder="Type to search">
118
+ <option value="apple">Apple</option>
119
+ <option value="banana">Banana</option>
120
+ <option value="orange">Orange</option>
121
+ </w-combobox>
122
+ ```
123
+
124
+ </elements-example>
125
+
126
+ ### Different label and value
127
+
128
+ Use the `label` attribute when the visible suggestion should differ from the selected value.
129
+
130
+ <elements-example>
131
+
132
+ ```html
133
+ <w-combobox label="Country" placeholder="Search">
134
+ <option value="us" label="United States">US</option>
135
+ <option value="uk" label="United Kingdom">UK</option>
136
+ <option value="no">Norway</option>
137
+ </w-combobox>
138
+ ```
139
+
140
+ </elements-example>
141
+
142
+ ### Dynamic options
143
+
144
+ Use the `options` property when options come from application state or a remote search.
145
+
146
+ ```js
147
+ const combobox = document.querySelector('w-combobox');
148
+
149
+ combobox.options = [
150
+ { value: 'apple', label: 'Apple' },
151
+ { value: 'banana', label: 'Banana' },
152
+ { value: 'orange', label: 'Orange' },
153
+ ];
154
+ ```
155
+
156
+ Child option content is plain text. Rich option content is not supported.
157
+
15
158
  ## `<w-combobox>` API
16
159
 
17
160
  Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
@@ -20,125 +163,155 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
20
163
 
21
164
  | Name | Type | Default | Summary |
22
165
  |-|-|-|-|
23
- | autocomplete | `string \| undefined` | `'off'` | Autocomplete attribute for the input field |
24
- | disable-static-filtering | `boolean` | `false` | Disable client-side static filtering |
25
- | disabled | `boolean` | `false` | Whether the element is disabled |
26
- | help-text | `string \| undefined` | `''` | The content to display as the help text |
27
- | invalid | `boolean` | `false` | Renders the input field in an invalid state |
28
- | label | `string \| undefined` | `''` | Label above input |
29
- | match-text-segments | `boolean` | `false` | Whether the matching text segments in the options should be highlighted |
30
- | name | `string \| undefined` | `''` | Name attribute for form submission |
31
- | open-on-focus | `boolean` | `false` | Whether the popover opens when focus is on the text field |
32
- | optional | `boolean` | `false` | Whether to show optional text |
33
- | options | `ComboboxOption[]` | `[]` | The available options to select from |
34
- | placeholder | `string \| undefined` | `''` | Input placeholder |
35
- | required | `boolean` | `false` | Whether the element is required |
36
- | select-on-blur | `boolean` | `true` | Select active option on blur |
37
- | value | `string` | `''` | The input value |
166
+ | autocomplete | `string \| undefined` | `'off'` | The autocomplete attribute passed to the internal input. |
167
+ | disable-static-filtering | `boolean` | `false` | Whether built-in client-side filtering is disabled. |
168
+ | disabled | `boolean` | `false` | Whether the combobox is disabled. |
169
+ | help-text | `string \| undefined` | `''` | Help text displayed below the input. |
170
+ | invalid | `boolean` | `false` | Whether the combobox is visually invalid. |
171
+ | label | `string \| undefined` | `''` | The label displayed above the input. |
172
+ | match-text-segments | `boolean` | `false` | Whether matching text segments in options are highlighted. |
173
+ | name | `string \| undefined` | `''` | The name submitted with the combobox value. |
174
+ | open-on-focus | `boolean` | `false` | Whether the option list opens when the input receives focus. |
175
+ | optional | `boolean` | `false` | Whether to show optional text next to the label. |
176
+ | options | `ComboboxOption[]` | `[]` | The available options to select from. |
177
+ | placeholder | `string \| undefined` | `''` | Placeholder text displayed when the input is empty. |
178
+ | required | `boolean` | `false` | Whether the combobox is required before form submission. |
179
+ | select-on-blur | `boolean` | `true` | Whether the active option is selected when the input loses focus. |
180
+ | value | `string` | `''` | The selected or typed value. |
38
181
 
39
182
  ### Property Details
40
183
 
41
184
  #### autocomplete
42
185
 
43
- Autocomplete attribute for the input field
186
+ The autocomplete attribute passed to the internal input.
187
+
188
+ Defaults to `off`. Set this when browser autocomplete should be enabled or scoped to a specific autocomplete token.
44
189
 
45
190
  - Type: `string | undefined`
46
191
  - Default: `'off'`
47
192
 
48
193
  #### disable-static-filtering
49
194
 
50
- Disable client-side static filtering
195
+ Whether built-in client-side filtering is disabled.
196
+
197
+ Use this for remote search or externally filtered results. When disabled, all entries in `options` are rendered as provided.
51
198
 
52
199
  - Type: `boolean`
53
200
  - Default: `false`
54
201
 
55
202
  #### disabled
56
203
 
57
- Whether the element is disabled
204
+ Whether the combobox is disabled.
205
+
206
+ Disabled comboboxes cannot be focused, changed, or submitted with form data.
58
207
 
59
208
  - Type: `boolean`
60
209
  - Default: `false`
61
210
 
62
211
  #### help-text
63
212
 
64
- The content to display as the help text
213
+ Help text displayed below the input.
214
+
215
+ Use this for supporting guidance or validation feedback.
65
216
 
66
217
  - Type: `string | undefined`
67
218
  - Default: `''`
68
219
 
69
220
  #### invalid
70
221
 
71
- Renders the input field in an invalid state
222
+ Whether the combobox is visually invalid.
223
+
224
+ Use this to show an externally managed validation error. Pair it with `help-text` to explain how to fix the error.
72
225
 
73
226
  - Type: `boolean`
74
227
  - Default: `false`
75
228
 
76
229
  #### label
77
230
 
78
- Label above input
231
+ The label displayed above the input.
232
+
233
+ Use this to give the combobox a visible and accessible name.
79
234
 
80
235
  - Type: `string | undefined`
81
236
  - Default: `''`
82
237
 
83
238
  #### match-text-segments
84
239
 
85
- Whether the matching text segments in the options should be highlighted
240
+ Whether matching text segments in options are highlighted.
241
+
242
+ Use this to visually emphasize the part of each option that matches the current input value.
86
243
 
87
244
  - Type: `boolean`
88
245
  - Default: `false`
89
246
 
90
247
  #### name
91
248
 
92
- Name attribute for form submission
249
+ The name submitted with the combobox value.
250
+
251
+ Use this when the combobox belongs to a form and its value should be included in form data.
93
252
 
94
253
  - Type: `string | undefined`
95
254
  - Default: `''`
96
255
 
97
256
  #### open-on-focus
98
257
 
99
- Whether the popover opens when focus is on the text field
258
+ Whether the option list opens when the input receives focus.
259
+
260
+ Use this when users should see available options before they start typing.
100
261
 
101
262
  - Type: `boolean`
102
263
  - Default: `false`
103
264
 
104
265
  #### optional
105
266
 
106
- Whether to show optional text
267
+ Whether to show optional text next to the label.
268
+
269
+ Use this to indicate that the combobox is not required.
107
270
 
108
271
  - Type: `boolean`
109
272
  - Default: `false`
110
273
 
111
274
  #### options
112
275
 
113
- The available options to select from
276
+ The available options to select from.
277
+
278
+ Use this for framework usage, application state, or remote search results. When `options` contains entries, it is used instead of child `<option>` elements.
114
279
 
115
280
  - Type: `ComboboxOption[]`
116
281
  - Default: `[]`
117
282
 
118
283
  #### placeholder
119
284
 
120
- Input placeholder
285
+ Placeholder text displayed when the input is empty.
286
+
287
+ Use this as a short hint for the expected input. Do not use placeholder text as a replacement for a label.
121
288
 
122
289
  - Type: `string | undefined`
123
290
  - Default: `''`
124
291
 
125
292
  #### required
126
293
 
127
- Whether the element is required
294
+ Whether the combobox is required before form submission.
295
+
296
+ Use this when the user must provide a value before submitting the form.
128
297
 
129
298
  - Type: `boolean`
130
299
  - Default: `false`
131
300
 
132
301
  #### select-on-blur
133
302
 
134
- Select active option on blur
303
+ Whether the active option is selected when the input loses focus.
304
+
305
+ When enabled, the combobox selects the keyboard-highlighted option, or an option whose value exactly matches the current input value, on blur.
135
306
 
136
307
  - Type: `boolean`
137
308
  - Default: `true`
138
309
 
139
310
  #### value
140
311
 
141
- The input value
312
+ The selected or typed value.
313
+
314
+ When an option is selected, this is set to the option value. The displayed text may differ when the option has a separate label.
142
315
 
143
316
  - Type: `string`
144
317
  - Default: `''`
@@ -1 +1,45 @@
1
1
  ## Examples
2
+
3
+ <elements-example>
4
+
5
+ ```html
6
+ <w-combobox label="Fruit" placeholder="Type to search">
7
+ <option value="apple">Apple</option>
8
+ <option value="banana">Banana</option>
9
+ <option value="orange">Orange</option>
10
+ </w-combobox>
11
+ ```
12
+
13
+ </elements-example>
14
+
15
+ ### Different label and value
16
+
17
+ Use the `label` attribute when the visible suggestion should differ from the selected value.
18
+
19
+ <elements-example>
20
+
21
+ ```html
22
+ <w-combobox label="Country" placeholder="Search">
23
+ <option value="us" label="United States">US</option>
24
+ <option value="uk" label="United Kingdom">UK</option>
25
+ <option value="no">Norway</option>
26
+ </w-combobox>
27
+ ```
28
+
29
+ </elements-example>
30
+
31
+ ### Dynamic options
32
+
33
+ Use the `options` property when options come from application state or a remote search.
34
+
35
+ ```js
36
+ const combobox = document.querySelector('w-combobox');
37
+
38
+ combobox.options = [
39
+ { value: 'apple', label: 'Apple' },
40
+ { value: 'banana', label: 'Banana' },
41
+ { value: 'orange', label: 'Orange' },
42
+ ];
43
+ ```
44
+
45
+ Child option content is plain text. Rich option content is not supported.
@@ -1 +1,29 @@
1
1
  ## Usage
2
+
3
+ Use child `<option>` elements for declarative HTML usage.
4
+
5
+ <elements-example>
6
+
7
+ ```html
8
+ <w-combobox label="Country" placeholder="Search">
9
+ <option value="no">Norway</option>
10
+ <option value="se">Sweden</option>
11
+ <option value="dk">Denmark</option>
12
+ </w-combobox>
13
+ ```
14
+
15
+ </elements-example>
16
+
17
+ The option text is used as the visible suggestion. The `value` attribute is used as the submitted and selected value.
18
+
19
+ For framework usage or dynamic data, you may set the `options` property instead.
20
+
21
+ ```js
22
+ combobox.options = [
23
+ { value: 'no', label: 'Norway' },
24
+ { value: 'se', label: 'Sweden' },
25
+ { value: 'dk', label: 'Denmark' },
26
+ ];
27
+ ```
28
+
29
+ When `options` contains entries, it is used instead of child `<option>` elements.
@@ -0,0 +1,5 @@
1
+ ## Accessibility
2
+
3
+ Icons ship with a localized descriptive `<title>`.
4
+
5
+ Note that the description is about the icon itself, not its semantic meaning in every given context. If you for example make an icon button, make sure to include an `aria-label` on your button that describes its action.