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