@warp-ds/elements 2.9.0-next.5 → 2.9.0-next.6
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.
- package/dist/custom-elements.json +159 -97
- package/dist/docs/affix/affix.md +25 -23
- package/dist/docs/affix/api.md +25 -23
- package/dist/docs/alert/alert.md +12 -12
- package/dist/docs/alert/api.md +12 -12
- package/dist/docs/attention/api.md +46 -46
- package/dist/docs/attention/attention.md +46 -46
- package/dist/docs/badge/accessibility.md +44 -0
- package/dist/docs/badge/api.md +12 -8
- package/dist/docs/badge/badge.md +191 -10
- package/dist/docs/badge/examples.md +82 -0
- package/dist/docs/badge/usage.md +53 -0
- package/dist/docs/button/api.md +46 -42
- package/dist/docs/button/button.md +46 -42
- package/dist/docs/card/api.md +11 -11
- package/dist/docs/card/card.md +11 -11
- package/dist/docs/combobox/api.md +62 -62
- package/dist/docs/combobox/combobox.md +62 -62
- package/dist/docs/datepicker/api.md +74 -66
- package/dist/docs/datepicker/datepicker.md +74 -66
- package/dist/docs/expandable/api.md +26 -26
- package/dist/docs/expandable/expandable.md +26 -26
- package/dist/docs/link/api.md +28 -28
- package/dist/docs/link/link.md +28 -28
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/page-indicator.md +6 -6
- package/dist/docs/pagination/api.md +3 -3
- package/dist/docs/pagination/pagination.md +3 -3
- package/dist/docs/pill/api.md +19 -15
- package/dist/docs/pill/pill.md +19 -15
- package/dist/docs/select/api.md +44 -44
- package/dist/docs/select/select.md +44 -44
- package/dist/docs/slider/api.md +80 -78
- package/dist/docs/slider/slider.md +80 -78
- package/dist/docs/slider-thumb/api.md +28 -76
- package/dist/docs/slider-thumb/slider-thumb.md +28 -76
- package/dist/docs/switch/api.md +16 -16
- package/dist/docs/switch/switch.md +16 -16
- package/dist/docs/tab/api.md +26 -40
- package/dist/docs/tab/tab.md +26 -40
- package/dist/docs/tab-panel/api.md +1 -17
- package/dist/docs/tab-panel/tab-panel.md +1 -17
- package/dist/docs/tabs/api.md +3 -3
- package/dist/docs/tabs/tabs.md +3 -3
- package/dist/docs/textarea/api.md +42 -40
- package/dist/docs/textarea/textarea.md +42 -40
- package/dist/docs/textfield/accessibility.md +15 -0
- package/dist/docs/textfield/api.md +86 -83
- package/dist/docs/textfield/examples.md +147 -0
- package/dist/docs/textfield/textfield.md +279 -86
- package/dist/docs/textfield/usage.md +30 -0
- package/dist/index.d.ts +220 -196
- package/dist/packages/badge/badge.d.ts +7 -5
- package/dist/packages/badge/badge.js.map +2 -2
- package/dist/packages/datepicker/datepicker.js +1 -1
- package/dist/packages/datepicker/datepicker.js.map +2 -2
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +9 -1
- package/dist/packages/datepicker/react.d.ts +4 -0
- package/dist/packages/datepicker/react.js +4 -0
- package/dist/packages/textfield/textfield.d.ts +57 -60
- package/dist/packages/textfield/textfield.js +5 -5
- package/dist/packages/textfield/textfield.js.map +2 -2
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/web-types.json +392 -116
- package/package.json +1 -1
|
@@ -2,142 +2,360 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
A single
|
|
6
|
-
|
|
7
|
-
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-textfield--docs)
|
|
5
|
+
A single-line input component used for entering and editing textual or numeric data.
|
|
8
6
|
|
|
9
7
|
## Usage
|
|
10
8
|
|
|
9
|
+
<style-isolate>
|
|
10
|
+
<w-textfield label="Email" type="email"></w-textfield>
|
|
11
|
+
</style-isolate>
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<w-textfield label="Email" type="email"></w-textfield>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Validation
|
|
18
|
+
|
|
19
|
+
Set the `invalid` attribute to display a textfield as invalid.
|
|
20
|
+
|
|
21
|
+
`invalid` should be paired with `help-text` to provide feedback to the user about how to correct the error.
|
|
22
|
+
|
|
23
|
+
<style-isolate>
|
|
24
|
+
<w-textfield
|
|
25
|
+
label="Email"
|
|
26
|
+
invalid
|
|
27
|
+
help-text="An email should have an @ sign and a domain name, for example ola.nordmann@finn.no"
|
|
28
|
+
></w-textfield>
|
|
29
|
+
</style-isolate>
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<w-textfield
|
|
33
|
+
label="Email"
|
|
34
|
+
invalid
|
|
35
|
+
help-text="An email should have an @ sign and a domain name, for example ola.nordmann@finn.no"
|
|
36
|
+
></w-textfield>
|
|
37
|
+
```
|
|
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
|
+
|
|
43
|
+
- Always provide a visible label (do not rely on `placeholder` alone).
|
|
44
|
+
- Do not rely on color alone for interaction feedback (e.g. error states).
|
|
45
|
+
- Interaction patterns should follow platform-native expectations (e.g. tap zones, keyboard navigation, etc) and must not block accessibility tools.
|
|
46
|
+
|
|
47
|
+
### When used with an affix
|
|
48
|
+
|
|
49
|
+
When `search` or `clear` set on the [affix](#with-affix) component it renders a button and a default `aria-label`. If the `aria-label` incorrect for your context, you may provide your own describing the action.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<w-affix search aria-label="Ad Search"></w-affix>
|
|
53
|
+
<w-affix clear aria-label="Clear text input"></w-affix>
|
|
54
|
+
```
|
|
55
|
+
|
|
13
56
|
## Examples
|
|
14
57
|
|
|
58
|
+
### Placeholder
|
|
59
|
+
|
|
60
|
+
Placeholder text can be used to describe the expected value or formatting for the textfield.
|
|
61
|
+
|
|
62
|
+
Placeholder text will only appear when the textfield is empty, and must not be used as a
|
|
63
|
+
substitute for labeling the element with a visible label.
|
|
64
|
+
|
|
65
|
+
<style-isolate>
|
|
66
|
+
<w-textfield label="Email" placeholder="ola.nordmann@finn.no"></w-textfield>
|
|
67
|
+
</style-isolate>
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<w-textfield label="Email" placeholder="ola.nordmann@finn.no"></w-textfield>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Prefix label
|
|
74
|
+
|
|
75
|
+
<style-isolate>
|
|
76
|
+
<w-textfield label="Price">
|
|
77
|
+
<w-affix slot="prefix" label="kr"></w-affix>
|
|
78
|
+
</w-textfield>
|
|
79
|
+
</style-isolate>
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<w-textfield label="Price">
|
|
83
|
+
<w-affix slot="prefix" label="kr"></w-affix>
|
|
84
|
+
</w-textfield>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Suffix Label
|
|
88
|
+
|
|
89
|
+
<style-isolate>
|
|
90
|
+
<w-textfield label="Price">
|
|
91
|
+
<w-affix slot="suffix" label="kr"></w-affix>
|
|
92
|
+
</w-textfield>
|
|
93
|
+
</style-isolate>
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<w-textfield label="Price">
|
|
97
|
+
<w-affix slot="suffix" label="kr"></w-affix>
|
|
98
|
+
</w-textfield>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Prefix Search Icon
|
|
102
|
+
|
|
103
|
+
<style-isolate>
|
|
104
|
+
<w-textfield label="Search">
|
|
105
|
+
<w-affix slot="prefix" search></w-affix>
|
|
106
|
+
</w-textfield>
|
|
107
|
+
</style-isolate>
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<w-textfield label="Search">
|
|
111
|
+
<w-affix slot="prefix" search></w-affix>
|
|
112
|
+
</w-textfield>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Suffix Search Icon
|
|
116
|
+
|
|
117
|
+
If you wrap the textfield with affix in a form element, clicking the search button will automatically submit the form
|
|
118
|
+
|
|
119
|
+
<style-isolate>
|
|
120
|
+
<form>
|
|
121
|
+
<w-textfield label="Search">
|
|
122
|
+
<w-affix slot="suffix" search></w-affix>
|
|
123
|
+
</w-textfield>
|
|
124
|
+
</form>
|
|
125
|
+
</style-isolate>
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<form>
|
|
129
|
+
<w-textfield label="Search">
|
|
130
|
+
<w-affix slot="prefix" search></w-affix>
|
|
131
|
+
</w-textfield>
|
|
132
|
+
</form>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Suffix Clear Icon
|
|
136
|
+
|
|
137
|
+
Clicking the clear button will reset the textfield
|
|
138
|
+
|
|
139
|
+
<style-isolate>
|
|
140
|
+
<w-textfield label="Search input">
|
|
141
|
+
<w-affix slot="suffix" clear></w-affix>
|
|
142
|
+
</w-textfield>
|
|
143
|
+
</style-isolate>
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<w-textfield label="Search input">
|
|
147
|
+
<w-affix slot="suffix" clear></w-affix>
|
|
148
|
+
</w-textfield>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Affix with arbitrary icon
|
|
152
|
+
|
|
153
|
+
<style-isolate>
|
|
154
|
+
<w-textfield label="Award">
|
|
155
|
+
<w-affix slot="prefix" icon="AwardMedal"></w-affix>
|
|
156
|
+
</w-textfield>
|
|
157
|
+
</style-isolate>
|
|
158
|
+
|
|
159
|
+
```html
|
|
160
|
+
<w-textfield label="Award">
|
|
161
|
+
<w-affix slot="prefix" icon="AwardMedal"></w-affix>
|
|
162
|
+
</w-textfield>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Disabled
|
|
166
|
+
|
|
167
|
+
Keep in mind that using disabled in its current form is an anti-pattern.
|
|
168
|
+
|
|
169
|
+
There will always be users who don't understand why an element is disabled, or users who can't even see that
|
|
170
|
+
it is disabled because of poor lighting conditions or other reasons.
|
|
171
|
+
|
|
172
|
+
Please consider more informative alternatives before choosing to use disabled on an element.
|
|
173
|
+
|
|
174
|
+
<style-isolate>
|
|
175
|
+
<div class="flex flex-col space-y-32">
|
|
176
|
+
<w-textfield label="Email" disabled value="ola.nordmann@finn.no"></w-textfield>
|
|
177
|
+
<w-textfield label="Email" disabled></w-textfield>
|
|
178
|
+
</div>
|
|
179
|
+
</style-isolate>
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<div class="flex flex-col space-y-32">
|
|
183
|
+
<w-textfield label="Email" disabled value="ola.nordmann@finn.no"></w-textfield>
|
|
184
|
+
<w-textfield label="Email" disabled></w-textfield>
|
|
185
|
+
</div>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Read only
|
|
189
|
+
|
|
190
|
+
The readonly boolean attribute makes the w-textfield's text content immutable. Unlike disabled the w-textfield remains focusable and the contents can still be copied. See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/readOnly) for more information.
|
|
191
|
+
|
|
192
|
+
<style-isolate>
|
|
193
|
+
<w-textfield label="Email" type="email" value="ola.nordmann@finn.no" readonly></w-textfield>
|
|
194
|
+
</style-isolate>
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<w-textfield
|
|
198
|
+
label="Email"
|
|
199
|
+
type="email"
|
|
200
|
+
value="ola.nordmann@finn.no"
|
|
201
|
+
readonly
|
|
202
|
+
></w-textfield>
|
|
203
|
+
```
|
|
204
|
+
|
|
15
205
|
## API Documentation
|
|
16
206
|
|
|
17
207
|
### Properties
|
|
18
208
|
|
|
19
209
|
| Name | Type | Default | Summary |
|
|
20
210
|
|-|-|-|-|
|
|
21
|
-
|
|
|
22
|
-
| disabled | `boolean` | `false` |
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
| step | `number` | `-` |
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
| _hasPrefix | `unknown` | `-` | - |
|
|
44
|
-
| _hasSuffix | `unknown` | `-` | - |
|
|
211
|
+
| autocomplete | `string \| undefined` | `-` | A space-separated string that hints to browsers [what type of content it can suggest](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete#value) to autofill. |
|
|
212
|
+
| disabled | `boolean` | `false` | Makes the element not focusable and hides it from form submits |
|
|
213
|
+
| formatter | `(value: string) => string` | `-` | Function to format value when the input field |
|
|
214
|
+
| helpText | `string` | `-` | Description shown below the input field |
|
|
215
|
+
| invalid | `boolean` | `false` | Mark the form field as invalid. |
|
|
216
|
+
| label | `string` | `-` | Either a `label` or an `aria-label` must be provided. |
|
|
217
|
+
| max | `number` | `-` | Use with `type="number"` to set the [maximum allowed value](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength). |
|
|
218
|
+
| maxLength | `number` | `-` | **Deprecated**: Use the native `maxlength` attribute |
|
|
219
|
+
| maxlength | `number` | `-` | For `text`, `search`, `url`, `tel`, `email` and `password` fields, sets the [maximum string length](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength) allowed. |
|
|
220
|
+
| min | `number` | `-` | Use with `type="number"` to set the [minimum allowed value](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#minlength). |
|
|
221
|
+
| minLength | `number` | `-` | **Deprecated**: Use the native `minlength` attribute |
|
|
222
|
+
| minlength | `number` | `-` | For `text`, `search`, `url`, `tel`, `email` and `password` fields, sets the [minimum string length](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#minlength) required. |
|
|
223
|
+
| 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. |
|
|
224
|
+
| pattern | `string` | `-` | Sets a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) that the input's value must [match to pass validation](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#pattern) |
|
|
225
|
+
| placeholder | `string` | `-` | Shown in the textfield when it doesn't have a value |
|
|
226
|
+
| readOnly | `boolean` | `false` | **Deprecated**: Use the native readonly attribute instead. |
|
|
227
|
+
| readonly | `boolean` | `false` | Whether the input can be selected but not changed by the user. |
|
|
228
|
+
| required | `boolean` | `false` | Whether user input is required on the input before form submission. |
|
|
229
|
+
| size | `string` | `-` | Sets the [size](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#size) (width) of the input field to fit the expected length of inputs. |
|
|
230
|
+
| step | `number` | `-` | Forces `number` inputs to be a whole number of `step` |
|
|
231
|
+
| type | `string` | `-` | The [type of input](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types). |
|
|
232
|
+
| value | `string` | `-` | Lets you set the current value. |
|
|
45
233
|
|
|
46
234
|
### Property Details
|
|
47
235
|
|
|
48
|
-
####
|
|
49
|
-
|
|
236
|
+
#### autocomplete
|
|
50
237
|
|
|
238
|
+
A space-separated string that hints to browsers [what type of content it can suggest](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete#value) to autofill.
|
|
51
239
|
|
|
52
|
-
- Type: `
|
|
53
|
-
- Default:
|
|
240
|
+
- Type: `string \| undefined`
|
|
241
|
+
- Default: `-`
|
|
54
242
|
|
|
55
243
|
#### disabled
|
|
56
244
|
|
|
245
|
+
Keep in mind that using disabled in its current form is an anti-pattern.
|
|
57
246
|
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
Please consider more informative alternatives before choosing to use disabled on an element.
|
|
58
250
|
|
|
59
251
|
- Type: `boolean`
|
|
60
252
|
- Default: `false`
|
|
61
253
|
|
|
62
|
-
####
|
|
63
|
-
|
|
254
|
+
#### formatter
|
|
64
255
|
|
|
256
|
+
Function to format value when the input field.
|
|
65
257
|
|
|
66
|
-
|
|
67
|
-
|
|
258
|
+
Only active when the input field does not have focus,
|
|
259
|
+
similar to the accessible input [masking example from Filament Group](https://filamentgroup.github.io/politespace/demo/demo.html).
|
|
68
260
|
|
|
69
|
-
|
|
261
|
+
- Type: `(value: string) => string`
|
|
262
|
+
- Default: `-`
|
|
70
263
|
|
|
264
|
+
#### helpText
|
|
71
265
|
|
|
266
|
+
Use in combination with `invalid` to show as a validation error message,
|
|
267
|
+
or on its own to show a help text.
|
|
72
268
|
|
|
73
269
|
- Type: `string`
|
|
74
270
|
- Default: `-`
|
|
75
271
|
|
|
76
|
-
####
|
|
272
|
+
#### invalid
|
|
273
|
+
|
|
274
|
+
Mark the form field as invalid. Make sure to also set a `help-text` to help users fix the validation problem.
|
|
275
|
+
|
|
276
|
+
- Type: `boolean`
|
|
277
|
+
- Default: `false`
|
|
77
278
|
|
|
279
|
+
#### label
|
|
78
280
|
|
|
281
|
+
Either a `label` or an `aria-label` must be provided.
|
|
79
282
|
|
|
80
283
|
- Type: `string`
|
|
81
284
|
- Default: `-`
|
|
82
285
|
|
|
83
|
-
####
|
|
84
|
-
|
|
286
|
+
#### max
|
|
85
287
|
|
|
288
|
+
Use with `type="number"` to set the [maximum allowed value](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength).
|
|
86
289
|
|
|
87
|
-
- Type: `
|
|
290
|
+
- Type: `number`
|
|
88
291
|
- Default: `-`
|
|
89
292
|
|
|
90
|
-
####
|
|
293
|
+
#### maxLength
|
|
91
294
|
|
|
295
|
+
**Deprecated**: Use the native `maxlength` attribute
|
|
92
296
|
|
|
93
297
|
|
|
94
|
-
- Type: `string`
|
|
95
|
-
- Default: `-`
|
|
96
298
|
|
|
97
|
-
|
|
299
|
+
- Type: `number`
|
|
300
|
+
- Default: `-`
|
|
98
301
|
|
|
302
|
+
#### maxlength
|
|
99
303
|
|
|
304
|
+
For `text`, `search`, `url`, `tel`, `email` and `password` fields, sets the [maximum string length](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#maxlength) allowed.
|
|
100
305
|
|
|
101
306
|
- Type: `number`
|
|
102
307
|
- Default: `-`
|
|
103
308
|
|
|
104
309
|
#### min
|
|
105
310
|
|
|
106
|
-
|
|
311
|
+
Use with `type="number"` to set the [minimum allowed value](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#minlength).
|
|
107
312
|
|
|
108
313
|
- Type: `number`
|
|
109
314
|
- Default: `-`
|
|
110
315
|
|
|
111
316
|
#### minLength
|
|
112
317
|
|
|
318
|
+
**Deprecated**: Use the native `minlength` attribute
|
|
319
|
+
|
|
113
320
|
|
|
114
321
|
|
|
115
322
|
- Type: `number`
|
|
116
323
|
- Default: `-`
|
|
117
324
|
|
|
118
|
-
####
|
|
119
|
-
|
|
325
|
+
#### minlength
|
|
120
326
|
|
|
327
|
+
For `text`, `search`, `url`, `tel`, `email` and `password` fields, sets the [minimum string length](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#minlength) required.
|
|
121
328
|
|
|
122
329
|
- Type: `number`
|
|
123
330
|
- Default: `-`
|
|
124
331
|
|
|
125
|
-
####
|
|
332
|
+
#### name
|
|
126
333
|
|
|
334
|
+
The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the input field when submitting the form.
|
|
127
335
|
|
|
336
|
+
- Type: `string`
|
|
337
|
+
- Default: `-`
|
|
338
|
+
|
|
339
|
+
#### pattern
|
|
340
|
+
|
|
341
|
+
Sets a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions) that the input's value must [match to pass validation](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#pattern)
|
|
128
342
|
|
|
129
343
|
- Type: `string`
|
|
130
344
|
- Default: `-`
|
|
131
345
|
|
|
132
346
|
#### placeholder
|
|
133
347
|
|
|
348
|
+
Set a text that is shown in the textfield when it doesn't have a value.
|
|
134
349
|
|
|
350
|
+
Placeholder text should not be used as a substitute for labeling the element with a visible label.
|
|
135
351
|
|
|
136
352
|
- Type: `string`
|
|
137
353
|
- Default: `-`
|
|
138
354
|
|
|
139
355
|
#### readOnly
|
|
140
356
|
|
|
357
|
+
**Deprecated**: Use the native readonly attribute instead.
|
|
358
|
+
|
|
141
359
|
|
|
142
360
|
|
|
143
361
|
- Type: `boolean`
|
|
@@ -145,72 +363,47 @@ A single line text input element.
|
|
|
145
363
|
|
|
146
364
|
#### readonly
|
|
147
365
|
|
|
148
|
-
|
|
366
|
+
Whether the input can be selected but not changed by the user.
|
|
149
367
|
|
|
150
368
|
- Type: `boolean`
|
|
151
369
|
- Default: `false`
|
|
152
370
|
|
|
153
371
|
#### required
|
|
154
372
|
|
|
155
|
-
|
|
373
|
+
Whether user input is required on the input before form submission.
|
|
156
374
|
|
|
157
375
|
- Type: `boolean`
|
|
158
376
|
- Default: `false`
|
|
159
377
|
|
|
160
|
-
####
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
- Type: `string`
|
|
165
|
-
- Default: `-`
|
|
166
|
-
|
|
167
|
-
#### value
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
- Type: `string`
|
|
172
|
-
- Default: `-`
|
|
173
|
-
|
|
174
|
-
#### name
|
|
175
|
-
|
|
378
|
+
#### size
|
|
176
379
|
|
|
380
|
+
Sets the [size](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#size) (width) of the input field to fit the expected length of inputs.
|
|
177
381
|
|
|
178
382
|
- Type: `string`
|
|
179
383
|
- Default: `-`
|
|
180
384
|
|
|
181
385
|
#### step
|
|
182
386
|
|
|
387
|
+
When used with `number` this attribute forces inputs to be a whole number of `step`.
|
|
183
388
|
|
|
389
|
+
For example with a `step="5"` only values that divide evenly on 5 are allowed.
|
|
390
|
+
Using arrow up and down in the input field increments and decrements by 5.
|
|
184
391
|
|
|
185
392
|
- Type: `number`
|
|
186
393
|
- Default: `-`
|
|
187
394
|
|
|
188
|
-
####
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
- Type: `string | undefined`
|
|
193
|
-
- Default: `-`
|
|
194
|
-
|
|
195
|
-
#### formatter
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
- Type: `(value: string) => string`
|
|
200
|
-
- Default: `-`
|
|
201
|
-
|
|
202
|
-
#### _hasPrefix
|
|
203
|
-
|
|
395
|
+
#### type
|
|
204
396
|
|
|
397
|
+
The [type of input](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types).
|
|
205
398
|
|
|
206
|
-
- Type: `
|
|
399
|
+
- Type: `string`
|
|
207
400
|
- Default: `-`
|
|
208
401
|
|
|
209
|
-
####
|
|
210
|
-
|
|
402
|
+
#### value
|
|
211
403
|
|
|
404
|
+
Lets you set the current value.
|
|
212
405
|
|
|
213
|
-
- Type: `
|
|
406
|
+
- Type: `string`
|
|
214
407
|
- Default: `-`
|
|
215
408
|
|
|
216
409
|
### Types
|
|
@@ -1 +1,31 @@
|
|
|
1
1
|
## Usage
|
|
2
|
+
|
|
3
|
+
<style-isolate>
|
|
4
|
+
<w-textfield label="Email" type="email"></w-textfield>
|
|
5
|
+
</style-isolate>
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<w-textfield label="Email" type="email"></w-textfield>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Validation
|
|
12
|
+
|
|
13
|
+
Set the `invalid` attribute to display a textfield as invalid.
|
|
14
|
+
|
|
15
|
+
`invalid` should be paired with `help-text` to provide feedback to the user about how to correct the error.
|
|
16
|
+
|
|
17
|
+
<style-isolate>
|
|
18
|
+
<w-textfield
|
|
19
|
+
label="Email"
|
|
20
|
+
invalid
|
|
21
|
+
help-text="An email should have an @ sign and a domain name, for example ola.nordmann@finn.no"
|
|
22
|
+
></w-textfield>
|
|
23
|
+
</style-isolate>
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<w-textfield
|
|
27
|
+
label="Email"
|
|
28
|
+
invalid
|
|
29
|
+
help-text="An email should have an @ sign and a domain name, for example ola.nordmann@finn.no"
|
|
30
|
+
></w-textfield>
|
|
31
|
+
```
|