@warp-ds/elements 2.9.0-next.6 → 2.9.0

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.
@@ -2,26 +2,17 @@
2
2
 
3
3
  ### Basic
4
4
 
5
- <style-isolate>
6
- <w-badge>New</w-badge>
7
- </style-isolate>
8
-
5
+ <elements-example>
6
+
9
7
  ```html
10
8
  <w-badge>New</w-badge>
11
9
  ```
12
10
 
11
+ </elements-example>
12
+
13
13
  ### Status Variants
14
14
 
15
- <style-isolate>
16
- <div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
17
- <w-badge variant="neutral">Neutral</w-badge>
18
- <w-badge variant="info">Info</w-badge>
19
- <w-badge variant="positive">Approved</w-badge>
20
- <w-badge variant="warning">Pending</w-badge>
21
- <w-badge variant="negative">Rejected</w-badge>
22
- <w-badge variant="disabled">Unavailable</w-badge>
23
- </div>
24
- </style-isolate>
15
+ <elements-example>
25
16
 
26
17
  ```html
27
18
  <w-badge variant="neutral">Neutral</w-badge>
@@ -32,52 +23,48 @@
32
23
  <w-badge variant="disabled">Unavailable</w-badge>
33
24
  ```
34
25
 
35
- ### Price
26
+ </elements-example>
36
27
 
37
- <style-isolate>
38
- <w-badge variant="price">1 200 kr</w-badge>
39
- </style-isolate>
28
+ ### Price
40
29
 
30
+ <elements-example>
31
+
41
32
  ```html
42
33
  <w-badge variant="price">1 200 kr</w-badge>
43
34
  ```
44
35
 
45
- ### Sponsored
36
+ </elements-example>
46
37
 
47
- <style-isolate>
48
- <w-badge variant="sponsored">Sponsored</w-badge>
49
- </style-isolate>
38
+ ### Sponsored
50
39
 
40
+ <elements-example>
41
+
51
42
  ```html
52
43
  <w-badge variant="sponsored">Sponsored</w-badge>
53
44
  ```
54
45
 
46
+ </elements-example>
47
+
55
48
  ### Positioned
56
49
 
57
- <style-isolate>
58
- <div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
59
- <w-badge variant="price" position="top-right">1 200 kr</w-badge>
60
- </div>
61
- </style-isolate>
50
+ <elements-example>
62
51
 
63
52
  ```html
64
- <div style="position: relative;">
65
- <img src="listing.jpg" alt="Living room with large windows" />
53
+ <div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
66
54
  <w-badge variant="price" position="top-right">1 200 kr</w-badge>
67
55
  </div>
68
56
  ```
69
57
 
58
+ </elements-example>
59
+
70
60
  ### Positioned Sponsored Badge
71
61
 
72
- <style-isolate>
73
- <div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
74
- <w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
75
- </div>
76
- </style-isolate>
62
+ <elements-example>
77
63
 
78
64
  ```html
79
- <div style="position: relative;">
80
- <img src="listing.jpg" alt="Living room with large windows" />
65
+ <div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
81
66
  <w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
82
67
  </div>
83
68
  ```
69
+
70
+ </elements-example>
@@ -1 +1,6 @@
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.
4
+
5
+ - Always provide a visible label (do not rely on `placeholder` alone).
6
+ - Do not rely on color alone for interaction feedback (e.g. error states).
@@ -4,107 +4,99 @@
4
4
 
5
5
  | Name | Type | Default | Summary |
6
6
  |-|-|-|-|
7
- | disabled | `boolean` | `false` | - |
8
- | helpText | `string` | `-` | - |
9
- | invalid | `boolean` | `false` | - |
10
- | label | `string` | `-` | - |
11
- | maxHeight | `unknown` | `-` | - |
12
- | maxRows | `number` | `-` | - |
13
- | minHeight | `unknown` | `-` | - |
14
- | minRows | `number` | `-` | - |
15
- | name | `string` | `-` | - |
16
- | optional | `boolean` | `false` | - |
17
- | placeholder | `string` | `-` | - |
18
- | readOnly | `boolean` | `false` | **Deprecated**: Use the native readonly attribute instead. Here for API consistency with `w-textfield`. |
19
- | readonly | `boolean` | `false` | - |
20
- | required | `boolean` | `false` | - |
21
- | shadowRootOptions | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
7
+ | disabled | `boolean` | `false` | Makes the element not focusable and hides it from form submits |
8
+ | helpText | `string` | `-` | Description shown below the input field |
9
+ | invalid | `boolean` | `false` | Mark the form field as invalid. |
10
+ | label | `string` | `-` | Either a `label` or an `aria-label` must be provided. |
11
+ | maxRows | `number` | `-` | Sets the maximum number of text rows before the content starts scrolling. |
12
+ | minRows | `number` | `-` | Sets the minimum number of text rows the textarea should display |
13
+ | name | `string` | `-` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the input field when submitting the form |
14
+ | optional | `boolean` | `false` | Show an icon behind the label indicating the field is optional |
15
+ | placeholder | `string` | `-` | Shown in the textarea when it doesn't have a value |
16
+ | readOnly | `boolean` | `false` | **Deprecated**: Use the native `readonly` attribute instead |
17
+ | readonly | `boolean` | `false` | Whether the input can be selected but not changed by the user |
18
+ | required | `boolean` | `false` | Whether user input is required on the input before form submission |
22
19
  | validationMessage | `string` | `-` | Returns the validation message if the textarea is invalid, otherwise an empty string |
23
20
  | validity | `ValidityState` | `-` | Returns the validity state of the textarea |
24
- | value | `string` | `-` | - |
21
+ | value | `string` | `-` | Lets you set the current value |
25
22
 
26
23
  ### Property Details
27
24
 
28
25
  #### disabled
29
26
 
27
+ Keep in mind that using disabled in its current form is an anti-pattern.
30
28
 
29
+ There will always be users who don't understand why an element is disabled, or users who can't even see that it is disabled because of poor lighting conditions or other reasons.
30
+
31
+ Please consider more informative alternatives before choosing to use disabled on an element.
31
32
 
32
33
  - Type: `boolean`
33
34
  - Default: `false`
34
35
 
35
36
  #### helpText
36
37
 
37
-
38
+ Use in combination with `invalid` to show as a validation error message,
39
+ or on its own to show a help text.
38
40
 
39
41
  - Type: `string`
40
42
  - Default: `-`
41
43
 
42
44
  #### invalid
43
45
 
46
+ Mark the form field as invalid.
44
47
 
48
+ Make sure to also set a `help-text` to help users fix the validation problem.
45
49
 
46
50
  - Type: `boolean`
47
51
  - Default: `false`
48
52
 
49
53
  #### label
50
54
 
51
-
55
+ Either a `label` or an `aria-label` must be provided.
52
56
 
53
57
  - Type: `string`
54
58
  - Default: `-`
55
59
 
56
- #### maxHeight
57
-
58
-
59
-
60
- - Type: `unknown`
61
- - Default: `-`
62
-
63
60
  #### maxRows
64
61
 
65
-
62
+ Sets the maximum number of text rows before the content starts scrolling.
66
63
 
67
64
  - Type: `number`
68
65
  - Default: `-`
69
66
 
70
- #### minHeight
71
-
72
-
73
-
74
- - Type: `unknown`
75
- - Default: `-`
76
-
77
67
  #### minRows
78
68
 
79
-
69
+ Sets the minimum number of text rows the textarea should display
80
70
 
81
71
  - Type: `number`
82
72
  - Default: `-`
83
73
 
84
74
  #### name
85
75
 
86
-
76
+ The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the input field when submitting the form
87
77
 
88
78
  - Type: `string`
89
79
  - Default: `-`
90
80
 
91
81
  #### optional
92
82
 
93
-
83
+ Show an icon behind the label indicating the field is optional
94
84
 
95
85
  - Type: `boolean`
96
86
  - Default: `false`
97
87
 
98
88
  #### placeholder
99
89
 
90
+ Set a text that is shown in the textarea when it doesn't have a value.
100
91
 
92
+ Placeholder text should not be used as a substitute for labeling the element with a visible label.
101
93
 
102
94
  - Type: `string`
103
95
  - Default: `-`
104
96
 
105
97
  #### readOnly
106
98
 
107
- **Deprecated**: Use the native readonly attribute instead. Here for API consistency with `w-textfield`.
99
+ **Deprecated**: Use the native `readonly` attribute instead
108
100
 
109
101
 
110
102
 
@@ -113,25 +105,18 @@
113
105
 
114
106
  #### readonly
115
107
 
116
-
108
+ Whether the input can be selected but not changed by the user
117
109
 
118
110
  - Type: `boolean`
119
111
  - Default: `false`
120
112
 
121
113
  #### required
122
114
 
123
-
115
+ Whether user input is required on the input before form submission
124
116
 
125
117
  - Type: `boolean`
126
118
  - Default: `false`
127
119
 
128
- #### shadowRootOptions
129
-
130
-
131
-
132
- - Type: `object`
133
- - Default: `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }`
134
-
135
120
  #### validationMessage
136
121
 
137
122
  Returns the validation message if the textarea is invalid, otherwise an empty string
@@ -148,7 +133,7 @@ Returns the validity state of the textarea
148
133
 
149
134
  #### value
150
135
 
151
-
136
+ Lets you set the current value
152
137
 
153
138
  - Type: `string`
154
139
  - Default: `-`
@@ -1 +1,82 @@
1
1
  ## Examples
2
+
3
+ <elements-example>
4
+
5
+ ```html
6
+ <w-textarea label="Description"></w-textarea>
7
+ ```
8
+
9
+ </elements-example>
10
+
11
+ ### Placeholder
12
+
13
+ Text hint that appears when the textarea is empty. Placeholder text should not be used as a substitute for a visible label.
14
+
15
+ <elements-example>
16
+
17
+ ```html
18
+ <w-textarea
19
+ label="Description"
20
+ placeholder="Give as much detail as you can"
21
+ ></w-textarea>
22
+ ```
23
+
24
+ </elements-example>
25
+
26
+ ### Height
27
+
28
+ You can control the height of the input field by setting either `minimum-rows` or `maximum-rows`
29
+
30
+ <elements-example>
31
+
32
+ ```html
33
+ <w-textarea label="Description" minimum-rows="3"></w-textarea>
34
+ ```
35
+
36
+ </elements-example>
37
+
38
+ With `maximum-rows` the content will start scrolling when it passes the limit. Note that the field stops being resizable. Setting `minimum-rows` is redundant when you set `maximum-rows`.
39
+
40
+ <elements-example>
41
+
42
+ ```html
43
+ <w-textarea label="Description" maximum-rows="3" value="Line 1
44
+ Line 2
45
+ Line 3
46
+ Line 4
47
+ Line 5"></w-textarea>
48
+ ```
49
+
50
+ </elements-example>
51
+
52
+ ### Disabled
53
+
54
+ Consider using more informative alternatives before choosing to use disabled, as some users may not understand why an element is disabled.
55
+
56
+ <elements-example>
57
+
58
+ ```html
59
+ <w-textarea
60
+ label="Description"
61
+ value="This form field is ignored"
62
+ disabled
63
+ ></w-textarea>
64
+ ```
65
+
66
+ </elements-example>
67
+
68
+ ### Read only
69
+
70
+ Makes the textarea content immutable while remaining focusable. The contents can still be copied.
71
+
72
+ <elements-example>
73
+
74
+ ```html
75
+ <w-textarea
76
+ label="Description"
77
+ value="This content is read only"
78
+ readonly
79
+ ></w-textarea>
80
+ ```
81
+
82
+ </elements-example>
@@ -2,123 +2,214 @@
2
2
 
3
3
  ## Description
4
4
 
5
- A single line text input element.
5
+ A multi-line text input with built-in form validation, auto-resizing, and styling support.
6
6
 
7
- [See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-textfield--docs)
7
+ The component automatically handles:
8
+ - Form integration
9
+ - Auto-resizing based on content and row constraints
10
+ - Built-in validation with customizable error messages
11
+ - Accessibility attributes and labeling
8
12
 
9
13
  ## Usage
10
14
 
15
+ A multi-line text input with built-in form validation, auto-resizing, and styling support.
16
+
17
+ The component automatically handles:
18
+
19
+ - Form integration
20
+ - Auto-resizing based on content and row constraints
21
+ - Built-in validation with customizable error messages
22
+ - Accessibility attributes and labeling
23
+
11
24
  ## Accessibility
12
25
 
26
+ 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.
27
+
28
+ - Always provide a visible label (do not rely on `placeholder` alone).
29
+ - Do not rely on color alone for interaction feedback (e.g. error states).
30
+
13
31
  ## Examples
14
32
 
33
+ <elements-example>
34
+
35
+ ```html
36
+ <w-textarea label="Description"></w-textarea>
37
+ ```
38
+
39
+ </elements-example>
40
+
41
+ ### Placeholder
42
+
43
+ Text hint that appears when the textarea is empty. Placeholder text should not be used as a substitute for a visible label.
44
+
45
+ <elements-example>
46
+
47
+ ```html
48
+ <w-textarea
49
+ label="Description"
50
+ placeholder="Give as much detail as you can"
51
+ ></w-textarea>
52
+ ```
53
+
54
+ </elements-example>
55
+
56
+ ### Height
57
+
58
+ You can control the height of the input field by setting either `minimum-rows` or `maximum-rows`
59
+
60
+ <elements-example>
61
+
62
+ ```html
63
+ <w-textarea label="Description" minimum-rows="3"></w-textarea>
64
+ ```
65
+
66
+ </elements-example>
67
+
68
+ With `maximum-rows` the content will start scrolling when it passes the limit. Note that the field stops being resizable. Setting `minimum-rows` is redundant when you set `maximum-rows`.
69
+
70
+ <elements-example>
71
+
72
+ ```html
73
+ <w-textarea label="Description" maximum-rows="3" value="Line 1
74
+ Line 2
75
+ Line 3
76
+ Line 4
77
+ Line 5"></w-textarea>
78
+ ```
79
+
80
+ </elements-example>
81
+
82
+ ### Disabled
83
+
84
+ Consider using more informative alternatives before choosing to use disabled, as some users may not understand why an element is disabled.
85
+
86
+ <elements-example>
87
+
88
+ ```html
89
+ <w-textarea
90
+ label="Description"
91
+ value="This form field is ignored"
92
+ disabled
93
+ ></w-textarea>
94
+ ```
95
+
96
+ </elements-example>
97
+
98
+ ### Read only
99
+
100
+ Makes the textarea content immutable while remaining focusable. The contents can still be copied.
101
+
102
+ <elements-example>
103
+
104
+ ```html
105
+ <w-textarea
106
+ label="Description"
107
+ value="This content is read only"
108
+ readonly
109
+ ></w-textarea>
110
+ ```
111
+
112
+ </elements-example>
113
+
15
114
  ## API Documentation
16
115
 
17
116
  ### Properties
18
117
 
19
118
  | Name | Type | Default | Summary |
20
119
  |-|-|-|-|
21
- | disabled | `boolean` | `false` | - |
22
- | helpText | `string` | `-` | - |
23
- | invalid | `boolean` | `false` | - |
24
- | label | `string` | `-` | - |
25
- | maxHeight | `unknown` | `-` | - |
26
- | maxRows | `number` | `-` | - |
27
- | minHeight | `unknown` | `-` | - |
28
- | minRows | `number` | `-` | - |
29
- | name | `string` | `-` | - |
30
- | optional | `boolean` | `false` | - |
31
- | placeholder | `string` | `-` | - |
32
- | readOnly | `boolean` | `false` | **Deprecated**: Use the native readonly attribute instead. Here for API consistency with `w-textfield`. |
33
- | readonly | `boolean` | `false` | - |
34
- | required | `boolean` | `false` | - |
35
- | shadowRootOptions | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
120
+ | disabled | `boolean` | `false` | Makes the element not focusable and hides it from form submits |
121
+ | helpText | `string` | `-` | Description shown below the input field |
122
+ | invalid | `boolean` | `false` | Mark the form field as invalid. |
123
+ | label | `string` | `-` | Either a `label` or an `aria-label` must be provided. |
124
+ | maxRows | `number` | `-` | Sets the maximum number of text rows before the content starts scrolling. |
125
+ | minRows | `number` | `-` | Sets the minimum number of text rows the textarea should display |
126
+ | name | `string` | `-` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the input field when submitting the form |
127
+ | optional | `boolean` | `false` | Show an icon behind the label indicating the field is optional |
128
+ | placeholder | `string` | `-` | Shown in the textarea when it doesn't have a value |
129
+ | readOnly | `boolean` | `false` | **Deprecated**: Use the native `readonly` attribute instead |
130
+ | readonly | `boolean` | `false` | Whether the input can be selected but not changed by the user |
131
+ | required | `boolean` | `false` | Whether user input is required on the input before form submission |
36
132
  | validationMessage | `string` | `-` | Returns the validation message if the textarea is invalid, otherwise an empty string |
37
133
  | validity | `ValidityState` | `-` | Returns the validity state of the textarea |
38
- | value | `string` | `-` | - |
134
+ | value | `string` | `-` | Lets you set the current value |
39
135
 
40
136
  ### Property Details
41
137
 
42
138
  #### disabled
43
139
 
140
+ Keep in mind that using disabled in its current form is an anti-pattern.
141
+
142
+ There will always be users who don't understand why an element is disabled, or users who can't even see that it is disabled because of poor lighting conditions or other reasons.
44
143
 
144
+ Please consider more informative alternatives before choosing to use disabled on an element.
45
145
 
46
146
  - Type: `boolean`
47
147
  - Default: `false`
48
148
 
49
149
  #### helpText
50
150
 
51
-
151
+ Use in combination with `invalid` to show as a validation error message,
152
+ or on its own to show a help text.
52
153
 
53
154
  - Type: `string`
54
155
  - Default: `-`
55
156
 
56
157
  #### invalid
57
158
 
159
+ Mark the form field as invalid.
58
160
 
161
+ Make sure to also set a `help-text` to help users fix the validation problem.
59
162
 
60
163
  - Type: `boolean`
61
164
  - Default: `false`
62
165
 
63
166
  #### label
64
167
 
65
-
168
+ Either a `label` or an `aria-label` must be provided.
66
169
 
67
170
  - Type: `string`
68
171
  - Default: `-`
69
172
 
70
- #### maxHeight
71
-
72
-
73
-
74
- - Type: `unknown`
75
- - Default: `-`
76
-
77
173
  #### maxRows
78
174
 
79
-
175
+ Sets the maximum number of text rows before the content starts scrolling.
80
176
 
81
177
  - Type: `number`
82
178
  - Default: `-`
83
179
 
84
- #### minHeight
85
-
86
-
87
-
88
- - Type: `unknown`
89
- - Default: `-`
90
-
91
180
  #### minRows
92
181
 
93
-
182
+ Sets the minimum number of text rows the textarea should display
94
183
 
95
184
  - Type: `number`
96
185
  - Default: `-`
97
186
 
98
187
  #### name
99
188
 
100
-
189
+ The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the input field when submitting the form
101
190
 
102
191
  - Type: `string`
103
192
  - Default: `-`
104
193
 
105
194
  #### optional
106
195
 
107
-
196
+ Show an icon behind the label indicating the field is optional
108
197
 
109
198
  - Type: `boolean`
110
199
  - Default: `false`
111
200
 
112
201
  #### placeholder
113
202
 
203
+ Set a text that is shown in the textarea when it doesn't have a value.
114
204
 
205
+ Placeholder text should not be used as a substitute for labeling the element with a visible label.
115
206
 
116
207
  - Type: `string`
117
208
  - Default: `-`
118
209
 
119
210
  #### readOnly
120
211
 
121
- **Deprecated**: Use the native readonly attribute instead. Here for API consistency with `w-textfield`.
212
+ **Deprecated**: Use the native `readonly` attribute instead
122
213
 
123
214
 
124
215
 
@@ -127,25 +218,18 @@ A single line text input element.
127
218
 
128
219
  #### readonly
129
220
 
130
-
221
+ Whether the input can be selected but not changed by the user
131
222
 
132
223
  - Type: `boolean`
133
224
  - Default: `false`
134
225
 
135
226
  #### required
136
227
 
137
-
228
+ Whether user input is required on the input before form submission
138
229
 
139
230
  - Type: `boolean`
140
231
  - Default: `false`
141
232
 
142
- #### shadowRootOptions
143
-
144
-
145
-
146
- - Type: `object`
147
- - Default: `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }`
148
-
149
233
  #### validationMessage
150
234
 
151
235
  Returns the validation message if the textarea is invalid, otherwise an empty string
@@ -162,7 +246,7 @@ Returns the validity state of the textarea
162
246
 
163
247
  #### value
164
248
 
165
-
249
+ Lets you set the current value
166
250
 
167
251
  - Type: `string`
168
252
  - Default: `-`
@@ -1 +1,10 @@
1
1
  ## Usage
2
+
3
+ A multi-line text input with built-in form validation, auto-resizing, and styling support.
4
+
5
+ The component automatically handles:
6
+
7
+ - Form integration
8
+ - Auto-resizing based on content and row constraints
9
+ - Built-in validation with customizable error messages
10
+ - Accessibility attributes and labeling