@warp-ds/elements 2.9.1-next.6 → 2.9.2-next.1

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 (32) hide show
  1. package/dist/custom-elements.json +72 -226
  2. package/dist/docs/radio/accessibility.md +1 -0
  3. package/dist/docs/radio/api.md +57 -0
  4. package/dist/docs/radio/examples.md +1 -0
  5. package/dist/docs/radio/radio.md +69 -0
  6. package/dist/docs/radio/usage.md +1 -0
  7. package/dist/docs/radio-group/accessibility.md +1 -0
  8. package/dist/docs/radio-group/api.md +69 -0
  9. package/dist/docs/radio-group/examples.md +68 -0
  10. package/dist/docs/radio-group/radio-group.md +311 -0
  11. package/dist/docs/radio-group/styling.md +118 -0
  12. package/dist/docs/radio-group/usage.md +44 -0
  13. package/dist/docs/select/accessibility.md +2 -0
  14. package/dist/docs/select/api.md +20 -16
  15. package/dist/docs/select/examples.md +116 -0
  16. package/dist/docs/select/select.md +168 -18
  17. package/dist/docs/select/usage.md +30 -0
  18. package/dist/index.d.ts +136 -185
  19. package/dist/packages/radio/radio.d.ts +51 -13
  20. package/dist/packages/radio/radio.js +3 -3
  21. package/dist/packages/radio/radio.js.map +3 -3
  22. package/dist/packages/radio/radio.react.stories.d.ts +1 -1
  23. package/dist/packages/radio/radio.stories.d.ts +2 -2
  24. package/dist/packages/radio/react.d.ts +2 -2
  25. package/dist/packages/radio-group/radio-group.d.ts +43 -5
  26. package/dist/packages/radio-group/radio-group.js +7 -7
  27. package/dist/packages/radio-group/radio-group.js.map +3 -3
  28. package/dist/packages/radio-group/react.d.ts +4 -4
  29. package/dist/packages/select/select.d.ts +32 -48
  30. package/dist/packages/select/select.js.map +2 -2
  31. package/dist/web-types.json +78 -46
  32. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ ## Usage
2
+
3
+ A radio input typically consists of two components:
4
+
5
+ - `<w-radio-group>` - A grouping wrapper that manages labeling, help text, roving keyboard focus, and validation for child radios.
6
+ - `<w-radio>` - A single radio with required and invalid states.
7
+
8
+ In advanced cases you may use `<w-radio>` without `<w-radio-group>`. If you're unsure what's correct in your case, always wrap `<w-radio>` in a `<w-radio-group>`.
9
+
10
+ The components automatically handle:
11
+
12
+ - Form integration and constraint validation
13
+ - Required state handling with validation messages
14
+ - Accessibility attributes, keyboard interaction, and labeling
15
+
16
+ <elements-example>
17
+
18
+ ```html
19
+ <w-radio-group label="Select an option" name="usage">
20
+ <w-radio value="one">Option 1</w-radio>
21
+ <w-radio value="two">Option 2</w-radio>
22
+ <w-radio value="three">Option 3</w-radio>
23
+ </w-radio-group>
24
+ ```
25
+
26
+ </elements-example>
27
+
28
+ ### Validation
29
+
30
+ Set the `invalid` attribute to display a radio group as invalid, for example if nothing was selected and the group was `required`.
31
+
32
+ `invalid` can be paired with `help-text` to provide feedback to the user about how to correct the error. However, since the `invalid` + `required` use case is so common you can omit `help-text` to use a generic built-in one.
33
+
34
+ <elements-example>
35
+
36
+ ```html
37
+ <w-radio-group label="Select an option" name="usage" required invalid>
38
+ <w-radio value="one">Option 1</w-radio>
39
+ <w-radio value="two">Option 2</w-radio>
40
+ <w-radio value="three">Option 3</w-radio>
41
+ </w-radio-group>
42
+ ```
43
+
44
+ </elements-example>
@@ -1 +1,3 @@
1
1
  ## Accessibility
2
+
3
+ If a visible label isn't specified, an `aria-label` must be provided to the text field for accessibility. If the field is labeled by a separate element, an `aria-labelledby` property must be provided using the `id` of the labeling element instead.
@@ -6,19 +6,19 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
6
6
 
7
7
  | Name | Type | Default | Summary |
8
8
  |-|-|-|-|
9
- | always | `boolean` | `false` | Whether to always show a hint.. **Deprecated**: Use `help-text` instead and only set it if you want to display the help text. |
10
- | auto-focus | `boolean` | `false` | Whether the element should receive focus on render.. **Deprecated**: Use the native `autofocus` attribute instead. |
9
+ | always | `boolean` | `false` | Whether to always show a hint. **Deprecated**: Use `help-text` instead and only set it if you want to display the help text. |
10
+ | auto-focus | `boolean` | `false` | Whether the element should receive focus on render. **Deprecated**: Use the native `autofocus` attribute instead. |
11
11
  | autofocus | `boolean` | `false` | Whether the element should receive focus on render |
12
12
  | disabled | `boolean` | `false` | Renders the field in a disabled state. |
13
- | help-text | `string` | `-` | The content displayed as the help text. Paired with `invalid` to show the text as a validation error. |
14
- | hint | `string` | `-` | The content displayed as the help text.. **Deprecated**: Use `help-text` instead. |
15
- | invalid | `boolean` | `false` | Renders the field in an invalid state. Paired with `help-text` to provide feedback about the error. |
16
- | label | `string` | `-` | The content to disply as the label |
17
- | name | `string` | `-` | - |
18
- | optional | `boolean` | `false` | Whether to show optional text |
19
- | read-only | `boolean` | `false` | Renders the field in a readonly state.. **Deprecated**: Use the native readonly attribute instead. |
13
+ | help-text | `string` | `-` | The content displayed as the help text. |
14
+ | hint | `string` | `-` | The content displayed as the help text. **Deprecated**: Use `help-text` instead. |
15
+ | invalid | `boolean` | `false` | Renders the field in an invalid state. |
16
+ | label | `string` | `-` | The content to display as the label. |
17
+ | name | `string` | `-` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form. |
18
+ | optional | `boolean` | `false` | Whether to show the optional indicator after the label. |
19
+ | read-only | `boolean` | `false` | Renders the field in a readonly state. **Deprecated**: Use the native readonly attribute instead. |
20
20
  | readonly | `boolean` | `false` | Renders the field in a readonly state. |
21
- | value | `string` | `-` | - |
21
+ | value | `string` | `-` | Lets you set the current value. |
22
22
 
23
23
  ### Property Details
24
24
 
@@ -56,7 +56,9 @@ Renders the field in a disabled state.
56
56
 
57
57
  #### help-text
58
58
 
59
- The content displayed as the help text. Paired with `invalid` to show the text as a validation error.
59
+ The content displayed as the help text.
60
+
61
+ Paired with `invalid` to show the text as a validation error.
60
62
 
61
63
  - Type: `string`
62
64
  - Default: `-`
@@ -72,28 +74,30 @@ The content displayed as the help text.
72
74
 
73
75
  #### invalid
74
76
 
75
- Renders the field in an invalid state. Paired with `help-text` to provide feedback about the error.
77
+ Renders the field in an invalid state.
78
+
79
+ Paired with `help-text` to provide feedback about the error.
76
80
 
77
81
  - Type: `boolean`
78
82
  - Default: `false`
79
83
 
80
84
  #### label
81
85
 
82
- The content to disply as the label
86
+ The content to display as the label.
83
87
 
84
88
  - Type: `string`
85
89
  - Default: `-`
86
90
 
87
91
  #### name
88
92
 
89
-
93
+ The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
90
94
 
91
95
  - Type: `string`
92
96
  - Default: `-`
93
97
 
94
98
  #### optional
95
99
 
96
- Whether to show optional text
100
+ Whether to show the optional indicator after the label.
97
101
 
98
102
  - Type: `boolean`
99
103
  - Default: `false`
@@ -116,7 +120,7 @@ Renders the field in a readonly state.
116
120
 
117
121
  #### value
118
122
 
119
-
123
+ Lets you set the current value.
120
124
 
121
125
  - Type: `string`
122
126
  - Default: `-`
@@ -1 +1,117 @@
1
1
  ## Examples
2
+
3
+ <elements-example>
4
+
5
+ ```html
6
+ <w-select label="Berries">
7
+ <option value="raspberries">Raspberries</option>
8
+ <option value="strawberries">Strawberries</option>
9
+ <option value="cloudberries">Cloudberries</option>
10
+ </w-select>
11
+ ```
12
+
13
+ </elements-example>
14
+
15
+ ### Placeholder
16
+
17
+ A select doesn't have a `placeholder` as such, but an `<option>` with an empty value gives a similar result.
18
+
19
+ <elements-example>
20
+
21
+ ```html
22
+ <w-select label="Berries">
23
+ <option value="">Select an option</option>
24
+ <option value="raspberries">Raspberries</option>
25
+ <option value="strawberries">Strawberries</option>
26
+ <option value="cloudberries">Cloudberries</option>
27
+ </w-select>
28
+ ```
29
+
30
+ </elements-example>
31
+
32
+ ### Optional
33
+
34
+ Add the `optional` prop to indicate that the select is not required. To make the select optional you must add an `<option>` with an empty value.
35
+
36
+ <elements-example>
37
+
38
+ ```html
39
+ <w-select label="Berries" optional>
40
+ <option value="">Select an option</option>
41
+ <option value="raspberries">Raspberries</option>
42
+ <option value="strawberries">Strawberries</option>
43
+ <option value="cloudberries">Cloudberries</option>
44
+ </w-select>
45
+ ```
46
+
47
+ </elements-example>
48
+
49
+ ### Help text
50
+
51
+ Use `help-text` to give additional context when the label and options are not enough.
52
+
53
+ <elements-example>
54
+
55
+ ```html
56
+ <w-select label="Berries" help-text="We assume this is your jam">
57
+ <option value="raspberries">Raspberries</option>
58
+ <option value="strawberries">Strawberries</option>
59
+ <option value="cloudberries">Cloudberries</option>
60
+ </w-select>
61
+ ```
62
+
63
+ </elements-example>
64
+
65
+ ### No visual label
66
+
67
+ You must set either an `aria-label` or an [`aria-labelledby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby).
68
+
69
+ <elements-example>
70
+
71
+ ```html
72
+ <w-select aria-label="Berries">
73
+ <option value="raspberries">Raspberries</option>
74
+ <option value="strawberries" selected>Strawberries</option>
75
+ <option value="cloudberries">Cloudberries</option>
76
+ </w-select>
77
+ ```
78
+
79
+ </elements-example>
80
+
81
+
82
+ ### Disabled
83
+
84
+ Keep in mind that using disabled is an anti-pattern.
85
+
86
+ There will always be users who don't understand why an element is disabled, or users who can't even see that
87
+ it is disabled because of poor lighting conditions or other reasons.
88
+
89
+ Please consider more informative alternatives before choosing to use disabled on an element.
90
+
91
+ <elements-example>
92
+
93
+ ```html
94
+ <w-select label="Berries" disabled>
95
+ <option value="raspberries">Raspberries</option>
96
+ <option value="strawberries">Strawberries</option>
97
+ <option value="cloudberries">Cloudberries</option>
98
+ </w-select>
99
+ ```
100
+
101
+ </elements-example>
102
+
103
+ ### Read only
104
+
105
+ The `readonly` boolean attribute makes the selection immutable. Unlike disabled the select remains focusable. See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/readOnly) for more information.
106
+
107
+ <elements-example>
108
+
109
+ ```html
110
+ <w-select label="Berries" readonly>
111
+ <option value="raspberries">Raspberries</option>
112
+ <option value="strawberries">Strawberries</option>
113
+ <option value="cloudberries">Cloudberries</option>
114
+ </w-select>
115
+ ```
116
+
117
+ </elements-example>
@@ -4,14 +4,160 @@
4
4
 
5
5
  A dropdown component for selecting a single value.
6
6
 
7
- [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-select--docs)
8
-
9
7
  ## Usage
10
8
 
9
+ <elements-example>
10
+
11
+ ```html
12
+ <w-select label="Berries">
13
+ <option value="raspberries">Raspberries</option>
14
+ <option value="strawberries">Strawberries</option>
15
+ <option value="cloudberries">Cloudberries</option>
16
+ </w-select>
17
+ ```
18
+
19
+ </elements-example>
20
+
21
+ ### Validation
22
+
23
+ Set the `invalid` attribute to display a textfield as invalid.
24
+
25
+ `invalid` should be paired with `help-text` to provide feedback to the user about how to correct the error.
26
+
27
+ <elements-example>
28
+
29
+ ```html
30
+ <w-select label="Berries" invalid help-text="Select a red berry">
31
+ <option value="raspberries">Raspberries</option>
32
+ <option value="strawberries">Strawberries</option>
33
+ <option value="cloudberries" selected>Cloudberries</option>
34
+ </w-select>
35
+ ```
36
+
37
+ </elements-example>
38
+
11
39
  ## Accessibility
12
40
 
41
+ If a visible label isn't specified, an `aria-label` must be provided to the text field for accessibility. If the field is labeled by a separate element, an `aria-labelledby` property must be provided using the `id` of the labeling element instead.
42
+
13
43
  ## Examples
14
44
 
45
+ <elements-example>
46
+
47
+ ```html
48
+ <w-select label="Berries">
49
+ <option value="raspberries">Raspberries</option>
50
+ <option value="strawberries">Strawberries</option>
51
+ <option value="cloudberries">Cloudberries</option>
52
+ </w-select>
53
+ ```
54
+
55
+ </elements-example>
56
+
57
+ ### Placeholder
58
+
59
+ A select doesn't have a `placeholder` as such, but an `<option>` with an empty value gives a similar result.
60
+
61
+ <elements-example>
62
+
63
+ ```html
64
+ <w-select label="Berries">
65
+ <option value="">Select an option</option>
66
+ <option value="raspberries">Raspberries</option>
67
+ <option value="strawberries">Strawberries</option>
68
+ <option value="cloudberries">Cloudberries</option>
69
+ </w-select>
70
+ ```
71
+
72
+ </elements-example>
73
+
74
+ ### Optional
75
+
76
+ Add the `optional` prop to indicate that the select is not required. To make the select optional you must add an `<option>` with an empty value.
77
+
78
+ <elements-example>
79
+
80
+ ```html
81
+ <w-select label="Berries" optional>
82
+ <option value="">Select an option</option>
83
+ <option value="raspberries">Raspberries</option>
84
+ <option value="strawberries">Strawberries</option>
85
+ <option value="cloudberries">Cloudberries</option>
86
+ </w-select>
87
+ ```
88
+
89
+ </elements-example>
90
+
91
+ ### Help text
92
+
93
+ Use `help-text` to give additional context when the label and options are not enough.
94
+
95
+ <elements-example>
96
+
97
+ ```html
98
+ <w-select label="Berries" help-text="We assume this is your jam">
99
+ <option value="raspberries">Raspberries</option>
100
+ <option value="strawberries">Strawberries</option>
101
+ <option value="cloudberries">Cloudberries</option>
102
+ </w-select>
103
+ ```
104
+
105
+ </elements-example>
106
+
107
+ ### No visual label
108
+
109
+ You must set either an `aria-label` or an [`aria-labelledby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby).
110
+
111
+ <elements-example>
112
+
113
+ ```html
114
+ <w-select aria-label="Berries">
115
+ <option value="raspberries">Raspberries</option>
116
+ <option value="strawberries" selected>Strawberries</option>
117
+ <option value="cloudberries">Cloudberries</option>
118
+ </w-select>
119
+ ```
120
+
121
+ </elements-example>
122
+
123
+
124
+ ### Disabled
125
+
126
+ Keep in mind that using disabled is an anti-pattern.
127
+
128
+ There will always be users who don't understand why an element is disabled, or users who can't even see that
129
+ it is disabled because of poor lighting conditions or other reasons.
130
+
131
+ Please consider more informative alternatives before choosing to use disabled on an element.
132
+
133
+ <elements-example>
134
+
135
+ ```html
136
+ <w-select label="Berries" disabled>
137
+ <option value="raspberries">Raspberries</option>
138
+ <option value="strawberries">Strawberries</option>
139
+ <option value="cloudberries">Cloudberries</option>
140
+ </w-select>
141
+ ```
142
+
143
+ </elements-example>
144
+
145
+ ### Read only
146
+
147
+ The `readonly` boolean attribute makes the selection immutable. Unlike disabled the select remains focusable. See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/readOnly) for more information.
148
+
149
+ <elements-example>
150
+
151
+ ```html
152
+ <w-select label="Berries" readonly>
153
+ <option value="raspberries">Raspberries</option>
154
+ <option value="strawberries">Strawberries</option>
155
+ <option value="cloudberries">Cloudberries</option>
156
+ </w-select>
157
+ ```
158
+
159
+ </elements-example>
160
+
15
161
  ## `<w-select>` API
16
162
 
17
163
  Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
@@ -20,19 +166,19 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
20
166
 
21
167
  | Name | Type | Default | Summary |
22
168
  |-|-|-|-|
23
- | always | `boolean` | `false` | Whether to always show a hint.. **Deprecated**: Use `help-text` instead and only set it if you want to display the help text. |
24
- | auto-focus | `boolean` | `false` | Whether the element should receive focus on render.. **Deprecated**: Use the native `autofocus` attribute instead. |
169
+ | always | `boolean` | `false` | Whether to always show a hint. **Deprecated**: Use `help-text` instead and only set it if you want to display the help text. |
170
+ | auto-focus | `boolean` | `false` | Whether the element should receive focus on render. **Deprecated**: Use the native `autofocus` attribute instead. |
25
171
  | autofocus | `boolean` | `false` | Whether the element should receive focus on render |
26
172
  | disabled | `boolean` | `false` | Renders the field in a disabled state. |
27
- | help-text | `string` | `-` | The content displayed as the help text. Paired with `invalid` to show the text as a validation error. |
28
- | hint | `string` | `-` | The content displayed as the help text.. **Deprecated**: Use `help-text` instead. |
29
- | invalid | `boolean` | `false` | Renders the field in an invalid state. Paired with `help-text` to provide feedback about the error. |
30
- | label | `string` | `-` | The content to disply as the label |
31
- | name | `string` | `-` | - |
32
- | optional | `boolean` | `false` | Whether to show optional text |
33
- | read-only | `boolean` | `false` | Renders the field in a readonly state.. **Deprecated**: Use the native readonly attribute instead. |
173
+ | help-text | `string` | `-` | The content displayed as the help text. |
174
+ | hint | `string` | `-` | The content displayed as the help text. **Deprecated**: Use `help-text` instead. |
175
+ | invalid | `boolean` | `false` | Renders the field in an invalid state. |
176
+ | label | `string` | `-` | The content to display as the label. |
177
+ | name | `string` | `-` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form. |
178
+ | optional | `boolean` | `false` | Whether to show the optional indicator after the label. |
179
+ | read-only | `boolean` | `false` | Renders the field in a readonly state. **Deprecated**: Use the native readonly attribute instead. |
34
180
  | readonly | `boolean` | `false` | Renders the field in a readonly state. |
35
- | value | `string` | `-` | - |
181
+ | value | `string` | `-` | Lets you set the current value. |
36
182
 
37
183
  ### Property Details
38
184
 
@@ -70,7 +216,9 @@ Renders the field in a disabled state.
70
216
 
71
217
  #### help-text
72
218
 
73
- The content displayed as the help text. Paired with `invalid` to show the text as a validation error.
219
+ The content displayed as the help text.
220
+
221
+ Paired with `invalid` to show the text as a validation error.
74
222
 
75
223
  - Type: `string`
76
224
  - Default: `-`
@@ -86,28 +234,30 @@ The content displayed as the help text.
86
234
 
87
235
  #### invalid
88
236
 
89
- Renders the field in an invalid state. Paired with `help-text` to provide feedback about the error.
237
+ Renders the field in an invalid state.
238
+
239
+ Paired with `help-text` to provide feedback about the error.
90
240
 
91
241
  - Type: `boolean`
92
242
  - Default: `false`
93
243
 
94
244
  #### label
95
245
 
96
- The content to disply as the label
246
+ The content to display as the label.
97
247
 
98
248
  - Type: `string`
99
249
  - Default: `-`
100
250
 
101
251
  #### name
102
252
 
103
-
253
+ The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
104
254
 
105
255
  - Type: `string`
106
256
  - Default: `-`
107
257
 
108
258
  #### optional
109
259
 
110
- Whether to show optional text
260
+ Whether to show the optional indicator after the label.
111
261
 
112
262
  - Type: `boolean`
113
263
  - Default: `false`
@@ -130,7 +280,7 @@ Renders the field in a readonly state.
130
280
 
131
281
  #### value
132
282
 
133
-
283
+ Lets you set the current value.
134
284
 
135
285
  - Type: `string`
136
286
  - Default: `-`
@@ -1 +1,31 @@
1
1
  ## Usage
2
+
3
+ <elements-example>
4
+
5
+ ```html
6
+ <w-select label="Berries">
7
+ <option value="raspberries">Raspberries</option>
8
+ <option value="strawberries">Strawberries</option>
9
+ <option value="cloudberries">Cloudberries</option>
10
+ </w-select>
11
+ ```
12
+
13
+ </elements-example>
14
+
15
+ ### Validation
16
+
17
+ Set the `invalid` attribute to display a textfield as invalid.
18
+
19
+ `invalid` should be paired with `help-text` to provide feedback to the user about how to correct the error.
20
+
21
+ <elements-example>
22
+
23
+ ```html
24
+ <w-select label="Berries" invalid help-text="Select a red berry">
25
+ <option value="raspberries">Raspberries</option>
26
+ <option value="strawberries">Strawberries</option>
27
+ <option value="cloudberries" selected>Cloudberries</option>
28
+ </w-select>
29
+ ```
30
+
31
+ </elements-example>