@aurodesignsystem/auro-formkit 3.4.1 → 3.5.0-rc-627.1.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.
- package/CHANGELOG.md +3 -1756
- package/components/checkbox/README.md +1 -1
- package/components/checkbox/demo/api.md +1 -1
- package/components/checkbox/demo/api.min.js +17 -7
- package/components/checkbox/demo/index.min.js +17 -7
- package/components/checkbox/demo/readme.md +1 -1
- package/components/checkbox/dist/auro-checkbox.d.ts +13 -6
- package/components/checkbox/dist/index.js +17 -7
- package/components/checkbox/dist/registered.js +17 -7
- package/components/combobox/README.md +1 -1
- package/components/combobox/demo/api.md +25 -25
- package/components/combobox/demo/api.min.js +20 -11
- package/components/combobox/demo/index.min.js +20 -11
- package/components/combobox/demo/readme.md +1 -1
- package/components/combobox/dist/auro-combobox.d.ts +2 -4
- package/components/combobox/dist/index.js +19 -10
- package/components/combobox/dist/registered.js +19 -10
- package/components/counter/README.md +1 -1
- package/components/counter/demo/readme.md +1 -1
- package/components/datepicker/README.md +1 -1
- package/components/datepicker/demo/api.min.js +17 -10
- package/components/datepicker/demo/index.min.js +17 -10
- package/components/datepicker/demo/readme.md +1 -1
- package/components/datepicker/dist/index.js +17 -10
- package/components/datepicker/dist/registered.js +17 -10
- package/components/dropdown/README.md +1 -1
- package/components/dropdown/demo/readme.md +1 -1
- package/components/form/README.md +1 -1
- package/components/form/demo/api.md +1 -5
- package/components/form/demo/api.min.js +8 -2
- package/components/form/demo/index.html +1 -0
- package/components/form/demo/index.md +321 -27
- package/components/form/demo/index.min.js +8 -2
- package/components/form/demo/readme.md +1 -1
- package/components/form/demo/registerDemoDeps.js +1 -0
- package/components/form/dist/auro-form.d.ts +12 -6
- package/components/form/dist/index.js +8 -2
- package/components/form/dist/registered.js +8 -2
- package/components/input/README.md +1 -1
- package/components/input/demo/api.md +1 -1
- package/components/input/demo/api.min.js +17 -10
- package/components/input/demo/index.min.js +17 -10
- package/components/input/demo/readme.md +1 -1
- package/components/input/dist/base-input.d.ts +13 -6
- package/components/input/dist/index.js +17 -10
- package/components/input/dist/registered.js +17 -10
- package/components/menu/README.md +1 -1
- package/components/menu/demo/api.md +11 -17
- package/components/menu/demo/api.min.js +1 -1
- package/components/menu/demo/index.min.js +1 -1
- package/components/menu/demo/readme.md +1 -1
- package/components/menu/dist/auro-menu.d.ts +1 -1
- package/components/menu/dist/index.js +1 -1
- package/components/menu/dist/registered.js +1 -1
- package/components/radio/README.md +1 -1
- package/components/radio/demo/api.md +1 -1
- package/components/radio/demo/api.min.js +18 -3
- package/components/radio/demo/index.min.js +18 -3
- package/components/radio/demo/readme.md +1 -1
- package/components/radio/dist/auro-radio.d.ts +14 -3
- package/components/radio/dist/index.js +18 -3
- package/components/radio/dist/registered.js +18 -3
- package/components/select/README.md +1 -1
- package/components/select/demo/api.html +15 -0
- package/components/select/demo/api.md +178 -0
- package/components/select/demo/api.min.js +70 -2
- package/components/select/demo/index.html +15 -0
- package/components/select/demo/index.md +177 -0
- package/components/select/demo/index.min.js +70 -2
- package/components/select/demo/readme.md +1 -1
- package/components/select/dist/auro-select.d.ts +27 -0
- package/components/select/dist/index.js +70 -1
- package/components/select/dist/registered.js +70 -1
- package/package.json +1 -1
|
@@ -17,23 +17,89 @@ It automatically "scrapes" its inner content for any auro form elements, and sur
|
|
|
17
17
|
them (along with events) to the parent form element as a JSON object.
|
|
18
18
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
19
19
|
|
|
20
|
-
## Form
|
|
20
|
+
## Form value generation
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Auro form exists to make a developer's life easier through surfacing all Auro form elements in a given form as a single
|
|
23
|
+
JSON object.
|
|
24
|
+
The most common use case the Auro team identified when building Form was the need to collect form data in
|
|
25
|
+
a structured way.
|
|
24
26
|
|
|
25
|
-
The following is required
|
|
27
|
+
The following is required on each Auro form element in a form for it to be collected automatically:
|
|
26
28
|
|
|
27
|
-
1. It
|
|
28
|
-
2. It
|
|
29
|
+
1. It **must** have a `name` attribute. This is required if vanilla HTML forms, and we follow the same pattern.
|
|
30
|
+
2. It **must** be an Auro form element. See the section on custom elements for more information.
|
|
29
31
|
|
|
30
32
|
That being said, we do _not_ require form elements to be direct children of `auro-form`.
|
|
31
33
|
They can be nested within other elements for styling, such as a `div`, `span` or `fieldset`.
|
|
32
34
|
|
|
35
|
+
### Form data structure
|
|
36
|
+
|
|
37
|
+
In a correctly registered scenario, `auro-form`
|
|
38
|
+
will automatically recognize the auro form elements and collect data from each on the form's `value` key as a JSON object.
|
|
39
|
+
|
|
40
|
+
Each element will be added using the element's `name` attribute as the key, and the element's `value` as the value.
|
|
41
|
+
|
|
42
|
+
A real-world example of this might be:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"hotelCity": "New York",
|
|
47
|
+
"dates": ["2022-01-01", "2022-01-15"],
|
|
48
|
+
"numberOfGuests": 2
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If your project uses TypeScript, consider using a type like this to represent the form data:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Generic type for form values
|
|
56
|
+
type AuroFormValue<T> = T | null;
|
|
57
|
+
|
|
58
|
+
// Example types
|
|
59
|
+
type AuroInputValue = AuroFormValue<string | number>;
|
|
60
|
+
type AuroDatePickerValue = AuroFormValue<string[]>;
|
|
61
|
+
|
|
62
|
+
// This is the type returned from the `AuroForm.value` getter
|
|
63
|
+
interface AuroFormState {
|
|
64
|
+
// value varies based on form element
|
|
65
|
+
hotelCity: AuroInputValue;
|
|
66
|
+
dates: AuroDatePickerValue;
|
|
67
|
+
numberOfGuests: AuroInputValue;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Accessing form data
|
|
72
|
+
|
|
73
|
+
As Auro components are designed to be framework-agnostic, data can be retrieved using simple vanilla JavaScript patterns.
|
|
74
|
+
If you have ever worked with a standard HTML5 form, you are already equipped to work with Auro forms!
|
|
75
|
+
|
|
76
|
+
Once you have a reference to the form element (React ref, querySelector, etc.),
|
|
77
|
+
you can access the form data using the following methods:
|
|
78
|
+
|
|
79
|
+
**Data keys + get methods**:
|
|
80
|
+
- `.value` - Getter which returns the current form data as a JSON object.
|
|
81
|
+
- `.validity` - Returns the current validity state of the form (`valid` or `invalid`).
|
|
82
|
+
|
|
83
|
+
**Extra information**:
|
|
84
|
+
- `.isInitialState` - Returns a boolean indicating if the form is in its initial state.
|
|
85
|
+
|
|
86
|
+
**Events**
|
|
87
|
+
- `input` - Fires when the form state changes.
|
|
88
|
+
- `reset` - Fires when the form is reset.
|
|
89
|
+
- `submit` - Fires when the form is submitted.
|
|
90
|
+
|
|
91
|
+
**Advanced features**:
|
|
92
|
+
- `.formState` - This is the internal form state. It includes extra `required` and `validity` information for each form element.
|
|
93
|
+
This key is not required for normal form usage, but can add additional context for more complex forms.
|
|
94
|
+
|
|
33
95
|
## Important note for custom elements
|
|
34
96
|
|
|
35
|
-
|
|
36
|
-
|
|
97
|
+
This **only applies to custom-named elements**.
|
|
98
|
+
|
|
99
|
+
When consuming custom-named Auro form elements (like `auro-input` registered as `my-custom-input`),
|
|
100
|
+
these elements _must_ be registered BEFORE auro-form due to rendering order limitations.
|
|
101
|
+
Auro form elements are automatically recognized based on their tag name (e.g. `auro-input`) or special auro attributes
|
|
102
|
+
which are only assigned during the initial render.
|
|
37
103
|
|
|
38
104
|
For example, the following is correct:
|
|
39
105
|
|
|
@@ -53,25 +119,6 @@ import {AuroForm} from '@aurodesignsystem/auro-form';
|
|
|
53
119
|
|
|
54
120
|
AuroForm.register(); // forms start rendering, looking for auro inputs, or custom-named inputs
|
|
55
121
|
AuroInput.register('my-custom-input'); // too late, form has already rendered and did not find the custom element
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
In a correctly registered scenario, `auro-form` will automatically recognize the custom element and collect its data in the following shape:
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
interface AuroFormState {
|
|
62
|
-
// value varies based on form element
|
|
63
|
-
[key: string]: string | string[] | number | boolean | null;
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
A real-world example of this might be:
|
|
68
|
-
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"hotelCity": "New York",
|
|
72
|
-
"dates": ["2022-01-01", "2022-01-15"],
|
|
73
|
-
"numberOfGuests": 2
|
|
74
|
-
}
|
|
75
122
|
```
|
|
76
123
|
|
|
77
124
|
## Examples
|
|
@@ -106,4 +153,251 @@ By default, Auro Form connects a `submit` event to all `type="submit"` buttons w
|
|
|
106
153
|
</auro-form>
|
|
107
154
|
```
|
|
108
155
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
156
|
+
</auro-accordion>
|
|
157
|
+
|
|
158
|
+
### Form with column layout
|
|
159
|
+
Auro Form is designed to be completely unstyled by default, allowing developers to use divs, structural elements, or
|
|
160
|
+
custom CSS to style the form.
|
|
161
|
+
|
|
162
|
+
This example shows that you can use advanced layouts with Auro Form, such as a column layout.
|
|
163
|
+
|
|
164
|
+
<div class="exampleWrapper">
|
|
165
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/column-layout.html) -->
|
|
166
|
+
<!-- The below content is automatically added from ./../apiExamples/column-layout.html -->
|
|
167
|
+
<style>
|
|
168
|
+
.columned-form {
|
|
169
|
+
display: grid;
|
|
170
|
+
grid-template-columns: 1fr 1fr;
|
|
171
|
+
gap: 1rem;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.columned-form div {
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
padding: 1rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.controls {
|
|
181
|
+
display: flex;
|
|
182
|
+
justify-content: flex-end;
|
|
183
|
+
margin-top: 1rem;
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
186
|
+
<auro-form>
|
|
187
|
+
<div class="columned-form">
|
|
188
|
+
<div>
|
|
189
|
+
<auro-input id="search-box" name="searchBox" required>
|
|
190
|
+
<span slot="label">Search flights</span>
|
|
191
|
+
</auro-input>
|
|
192
|
+
<auro-input id="last-name" name="lastName" required>
|
|
193
|
+
<span slot="label">Last Name</span>
|
|
194
|
+
</auro-input>
|
|
195
|
+
</div>
|
|
196
|
+
<div>
|
|
197
|
+
<div class="datepickerBlock">
|
|
198
|
+
<h4>Pick a date range</h4>
|
|
199
|
+
<auro-datepicker id="date-range" name="dateRange" required range>
|
|
200
|
+
<span slot="fromLabel">Start</span>
|
|
201
|
+
<span slot="toLabel">End</span>
|
|
202
|
+
<span slot="bib.fullscreen.dateLabel">Choose a range</span>
|
|
203
|
+
</auro-datepicker>
|
|
204
|
+
</div>
|
|
205
|
+
<div class="controls">
|
|
206
|
+
<auro-button type="submit">Submit</auro-button>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
</auro-form>
|
|
211
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
212
|
+
</div>
|
|
213
|
+
<auro-accordion alignRight>
|
|
214
|
+
<span slot="trigger">See code</span>
|
|
215
|
+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/column-layout.html) -->
|
|
216
|
+
<!-- The below code snippet is automatically added from ./../apiExamples/column-layout.html -->
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<style>
|
|
220
|
+
.columned-form {
|
|
221
|
+
display: grid;
|
|
222
|
+
grid-template-columns: 1fr 1fr;
|
|
223
|
+
gap: 1rem;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.columned-form div {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-direction: column;
|
|
229
|
+
padding: 1rem;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.controls {
|
|
233
|
+
display: flex;
|
|
234
|
+
justify-content: flex-end;
|
|
235
|
+
margin-top: 1rem;
|
|
236
|
+
}
|
|
237
|
+
</style>
|
|
238
|
+
<auro-form>
|
|
239
|
+
<div class="columned-form">
|
|
240
|
+
<div>
|
|
241
|
+
<auro-input id="search-box" name="searchBox" required>
|
|
242
|
+
<span slot="label">Search flights</span>
|
|
243
|
+
</auro-input>
|
|
244
|
+
<auro-input id="last-name" name="lastName" required>
|
|
245
|
+
<span slot="label">Last Name</span>
|
|
246
|
+
</auro-input>
|
|
247
|
+
</div>
|
|
248
|
+
<div>
|
|
249
|
+
<div class="datepickerBlock">
|
|
250
|
+
<h4>Pick a date range</h4>
|
|
251
|
+
<auro-datepicker id="date-range" name="dateRange" required range>
|
|
252
|
+
<span slot="fromLabel">Start</span>
|
|
253
|
+
<span slot="toLabel">End</span>
|
|
254
|
+
<span slot="bib.fullscreen.dateLabel">Choose a range</span>
|
|
255
|
+
</auro-datepicker>
|
|
256
|
+
</div>
|
|
257
|
+
<div class="controls">
|
|
258
|
+
<auro-button type="submit">Submit</auro-button>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
</auro-form>
|
|
263
|
+
```
|
|
264
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
265
|
+
</auro-accordion>
|
|
266
|
+
|
|
267
|
+
### Complex form
|
|
268
|
+
Finally, a more complex form example with multiple form elements, including a date picker and a select element.
|
|
269
|
+
|
|
270
|
+
<div class="exampleWrapper">
|
|
271
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/complex.html) -->
|
|
272
|
+
<!-- The below content is automatically added from ./../apiExamples/complex.html -->
|
|
273
|
+
<style>
|
|
274
|
+
.submitBlock {
|
|
275
|
+
margin-top: 1rem;
|
|
276
|
+
display: flex;
|
|
277
|
+
justify-content: flex-end;
|
|
278
|
+
gap: 1rem;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.datepickerBlock {
|
|
282
|
+
margin-top: 1rem;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.complex-form {
|
|
286
|
+
display: block;
|
|
287
|
+
width: 100%;
|
|
288
|
+
padding: 1rem;
|
|
289
|
+
border: 1px solid #2a2a2a;
|
|
290
|
+
border-radius: 1rem;
|
|
291
|
+
}
|
|
292
|
+
</style>
|
|
293
|
+
<h2>auro-form testing</h2>
|
|
294
|
+
<auro-form class="complex-form">
|
|
295
|
+
<auro-input id="first-name" name="firstName" required>
|
|
296
|
+
<span slot="label">First Name</span>
|
|
297
|
+
</auro-input>
|
|
298
|
+
<div>
|
|
299
|
+
<auro-input id="last-name" name="lastName" required>
|
|
300
|
+
<span slot="label">Last Name</span>
|
|
301
|
+
</auro-input>
|
|
302
|
+
</div>
|
|
303
|
+
<div>
|
|
304
|
+
<div>
|
|
305
|
+
<auro-input id="occupation" name="occupation" required>
|
|
306
|
+
<span slot="label">Occupation</span>
|
|
307
|
+
</auro-input>
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
<auro-input-two id="cool-fact" name="coolFact" required>
|
|
311
|
+
<span slot="label">Cool Fact</span>
|
|
312
|
+
</auro-input-two>
|
|
313
|
+
<div class="datepickerBlock">
|
|
314
|
+
<h4>Pick a cool date</h4>
|
|
315
|
+
<auro-datepicker id="date-example" name="dateExample" required>
|
|
316
|
+
<span slot="fromLabel">Choose a date</span>
|
|
317
|
+
<span slot="bib.fullscreen.dateLabel">Choose a date</span>
|
|
318
|
+
</auro-datepicker>
|
|
319
|
+
</div>
|
|
320
|
+
<div class="datepickerBlock">
|
|
321
|
+
<h4>Pick a date range</h4>
|
|
322
|
+
<auro-datepicker id="date-range" name="dateRange" required range>
|
|
323
|
+
<span slot="fromLabel">Start</span>
|
|
324
|
+
<span slot="toLabel">End</span>
|
|
325
|
+
<span slot="bib.fullscreen.dateLabel">Choose a range</span>
|
|
326
|
+
</auro-datepicker>
|
|
327
|
+
</div>
|
|
328
|
+
<div class="submitBlock">
|
|
329
|
+
<auro-button type="reset">Reset</auro-button>
|
|
330
|
+
<auro-button type="submit">Submit</auro-button>
|
|
331
|
+
</div>
|
|
332
|
+
</auro-form>
|
|
333
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
334
|
+
</div>
|
|
335
|
+
<auro-accordion alignRight>
|
|
336
|
+
<span slot="trigger">See code</span>
|
|
337
|
+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/complex.html) -->
|
|
338
|
+
<!-- The below code snippet is automatically added from ./../apiExamples/complex.html -->
|
|
339
|
+
|
|
340
|
+
```html
|
|
341
|
+
<style>
|
|
342
|
+
.submitBlock {
|
|
343
|
+
margin-top: 1rem;
|
|
344
|
+
display: flex;
|
|
345
|
+
justify-content: flex-end;
|
|
346
|
+
gap: 1rem;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.datepickerBlock {
|
|
350
|
+
margin-top: 1rem;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.complex-form {
|
|
354
|
+
display: block;
|
|
355
|
+
width: 100%;
|
|
356
|
+
padding: 1rem;
|
|
357
|
+
border: 1px solid #2a2a2a;
|
|
358
|
+
border-radius: 1rem;
|
|
359
|
+
}
|
|
360
|
+
</style>
|
|
361
|
+
<h2>auro-form testing</h2>
|
|
362
|
+
<auro-form class="complex-form">
|
|
363
|
+
<auro-input id="first-name" name="firstName" required>
|
|
364
|
+
<span slot="label">First Name</span>
|
|
365
|
+
</auro-input>
|
|
366
|
+
<div>
|
|
367
|
+
<auro-input id="last-name" name="lastName" required>
|
|
368
|
+
<span slot="label">Last Name</span>
|
|
369
|
+
</auro-input>
|
|
370
|
+
</div>
|
|
371
|
+
<div>
|
|
372
|
+
<div>
|
|
373
|
+
<auro-input id="occupation" name="occupation" required>
|
|
374
|
+
<span slot="label">Occupation</span>
|
|
375
|
+
</auro-input>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
<auro-input-two id="cool-fact" name="coolFact" required>
|
|
379
|
+
<span slot="label">Cool Fact</span>
|
|
380
|
+
</auro-input-two>
|
|
381
|
+
<div class="datepickerBlock">
|
|
382
|
+
<h4>Pick a cool date</h4>
|
|
383
|
+
<auro-datepicker id="date-example" name="dateExample" required>
|
|
384
|
+
<span slot="fromLabel">Choose a date</span>
|
|
385
|
+
<span slot="bib.fullscreen.dateLabel">Choose a date</span>
|
|
386
|
+
</auro-datepicker>
|
|
387
|
+
</div>
|
|
388
|
+
<div class="datepickerBlock">
|
|
389
|
+
<h4>Pick a date range</h4>
|
|
390
|
+
<auro-datepicker id="date-range" name="dateRange" required range>
|
|
391
|
+
<span slot="fromLabel">Start</span>
|
|
392
|
+
<span slot="toLabel">End</span>
|
|
393
|
+
<span slot="bib.fullscreen.dateLabel">Choose a range</span>
|
|
394
|
+
</auro-datepicker>
|
|
395
|
+
</div>
|
|
396
|
+
<div class="submitBlock">
|
|
397
|
+
<auro-button type="reset">Reset</auro-button>
|
|
398
|
+
<auro-button type="submit">Submit</auro-button>
|
|
399
|
+
</div>
|
|
400
|
+
</auro-form>
|
|
401
|
+
```
|
|
402
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
109
403
|
</auro-accordion>
|
|
@@ -153,7 +153,10 @@ class AuroForm extends i {
|
|
|
153
153
|
/** @type {HTMLButtonElement[]} */
|
|
154
154
|
this._resetElements = [];
|
|
155
155
|
|
|
156
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* @private
|
|
158
|
+
* @type {MutationObserver[]}
|
|
159
|
+
*/
|
|
157
160
|
this.mutationObservers = [];
|
|
158
161
|
|
|
159
162
|
// Bind listeners
|
|
@@ -268,7 +271,7 @@ class AuroForm extends i {
|
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
/**
|
|
271
|
-
*
|
|
274
|
+
* Returns a collection of elements that will reset the form
|
|
272
275
|
* @returns {HTMLButtonElement[]}
|
|
273
276
|
*/
|
|
274
277
|
get resetElements() {
|
|
@@ -498,6 +501,7 @@ class AuroForm extends i {
|
|
|
498
501
|
|
|
499
502
|
/**
|
|
500
503
|
* Shared input listener for all form elements.
|
|
504
|
+
* @private
|
|
501
505
|
* @param {Event} event - The event that is fired from the form element.
|
|
502
506
|
*/
|
|
503
507
|
sharedInputListener(event) {
|
|
@@ -530,6 +534,7 @@ class AuroForm extends i {
|
|
|
530
534
|
|
|
531
535
|
/**
|
|
532
536
|
* Shared validation listener for all form elements.
|
|
537
|
+
* @private
|
|
533
538
|
* @param {Event} event - The event that is fired from the form element.
|
|
534
539
|
*/
|
|
535
540
|
sharedValidationListener(event) {
|
|
@@ -585,6 +590,7 @@ class AuroForm extends i {
|
|
|
585
590
|
* root-level elements are added/removed. This is a workaround to ensure
|
|
586
591
|
* nested form elements are also observed.
|
|
587
592
|
*
|
|
593
|
+
* @private
|
|
588
594
|
* @returns {void}
|
|
589
595
|
*/
|
|
590
596
|
mutationEventListener() {
|
|
@@ -109,7 +109,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
109
109
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
110
110
|
|
|
111
111
|
```html
|
|
112
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@
|
|
112
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@0.0.0/auro-form/+esm"></script>
|
|
113
113
|
```
|
|
114
114
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
115
115
|
|
|
@@ -61,8 +61,11 @@ export class AuroForm extends LitElement {
|
|
|
61
61
|
_submitelements: HTMLButtonElement[];
|
|
62
62
|
/** @type {HTMLButtonElement[]} */
|
|
63
63
|
_resetElements: HTMLButtonElement[];
|
|
64
|
-
/**
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* @private
|
|
66
|
+
* @type {MutationObserver[]}
|
|
67
|
+
*/
|
|
68
|
+
private mutationObservers;
|
|
66
69
|
/**
|
|
67
70
|
* Reset fires an event called `reset` - just as you would expect from a normal form.
|
|
68
71
|
*/
|
|
@@ -73,22 +76,25 @@ export class AuroForm extends LitElement {
|
|
|
73
76
|
submit(): void;
|
|
74
77
|
/**
|
|
75
78
|
* Shared input listener for all form elements.
|
|
79
|
+
* @private
|
|
76
80
|
* @param {Event} event - The event that is fired from the form element.
|
|
77
81
|
*/
|
|
78
|
-
sharedInputListener
|
|
82
|
+
private sharedInputListener;
|
|
79
83
|
/**
|
|
80
84
|
* Shared validation listener for all form elements.
|
|
85
|
+
* @private
|
|
81
86
|
* @param {Event} event - The event that is fired from the form element.
|
|
82
87
|
*/
|
|
83
|
-
sharedValidationListener
|
|
88
|
+
private sharedValidationListener;
|
|
84
89
|
/**
|
|
85
90
|
* Mutation observer for form elements. Slot change does not trigger unless
|
|
86
91
|
* root-level elements are added/removed. This is a workaround to ensure
|
|
87
92
|
* nested form elements are also observed.
|
|
88
93
|
*
|
|
94
|
+
* @private
|
|
89
95
|
* @returns {void}
|
|
90
96
|
*/
|
|
91
|
-
mutationEventListener
|
|
97
|
+
private mutationEventListener;
|
|
92
98
|
/**
|
|
93
99
|
* Compare tag name with element to identify it (for API purposes).
|
|
94
100
|
* @param {string} elementTag - The HTML tag name like `auro-datepicker`.
|
|
@@ -140,7 +146,7 @@ export class AuroForm extends LitElement {
|
|
|
140
146
|
*/
|
|
141
147
|
get submitElements(): HTMLButtonElement[];
|
|
142
148
|
/**
|
|
143
|
-
*
|
|
149
|
+
* Returns a collection of elements that will reset the form
|
|
144
150
|
* @returns {HTMLButtonElement[]}
|
|
145
151
|
*/
|
|
146
152
|
get resetElements(): HTMLButtonElement[];
|
|
@@ -129,7 +129,10 @@ class AuroForm extends LitElement {
|
|
|
129
129
|
/** @type {HTMLButtonElement[]} */
|
|
130
130
|
this._resetElements = [];
|
|
131
131
|
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* @private
|
|
134
|
+
* @type {MutationObserver[]}
|
|
135
|
+
*/
|
|
133
136
|
this.mutationObservers = [];
|
|
134
137
|
|
|
135
138
|
// Bind listeners
|
|
@@ -244,7 +247,7 @@ class AuroForm extends LitElement {
|
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
/**
|
|
247
|
-
*
|
|
250
|
+
* Returns a collection of elements that will reset the form
|
|
248
251
|
* @returns {HTMLButtonElement[]}
|
|
249
252
|
*/
|
|
250
253
|
get resetElements() {
|
|
@@ -474,6 +477,7 @@ class AuroForm extends LitElement {
|
|
|
474
477
|
|
|
475
478
|
/**
|
|
476
479
|
* Shared input listener for all form elements.
|
|
480
|
+
* @private
|
|
477
481
|
* @param {Event} event - The event that is fired from the form element.
|
|
478
482
|
*/
|
|
479
483
|
sharedInputListener(event) {
|
|
@@ -506,6 +510,7 @@ class AuroForm extends LitElement {
|
|
|
506
510
|
|
|
507
511
|
/**
|
|
508
512
|
* Shared validation listener for all form elements.
|
|
513
|
+
* @private
|
|
509
514
|
* @param {Event} event - The event that is fired from the form element.
|
|
510
515
|
*/
|
|
511
516
|
sharedValidationListener(event) {
|
|
@@ -561,6 +566,7 @@ class AuroForm extends LitElement {
|
|
|
561
566
|
* root-level elements are added/removed. This is a workaround to ensure
|
|
562
567
|
* nested form elements are also observed.
|
|
563
568
|
*
|
|
569
|
+
* @private
|
|
564
570
|
* @returns {void}
|
|
565
571
|
*/
|
|
566
572
|
mutationEventListener() {
|
|
@@ -129,7 +129,10 @@ class AuroForm extends LitElement {
|
|
|
129
129
|
/** @type {HTMLButtonElement[]} */
|
|
130
130
|
this._resetElements = [];
|
|
131
131
|
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* @private
|
|
134
|
+
* @type {MutationObserver[]}
|
|
135
|
+
*/
|
|
133
136
|
this.mutationObservers = [];
|
|
134
137
|
|
|
135
138
|
// Bind listeners
|
|
@@ -244,7 +247,7 @@ class AuroForm extends LitElement {
|
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
/**
|
|
247
|
-
*
|
|
250
|
+
* Returns a collection of elements that will reset the form
|
|
248
251
|
* @returns {HTMLButtonElement[]}
|
|
249
252
|
*/
|
|
250
253
|
get resetElements() {
|
|
@@ -474,6 +477,7 @@ class AuroForm extends LitElement {
|
|
|
474
477
|
|
|
475
478
|
/**
|
|
476
479
|
* Shared input listener for all form elements.
|
|
480
|
+
* @private
|
|
477
481
|
* @param {Event} event - The event that is fired from the form element.
|
|
478
482
|
*/
|
|
479
483
|
sharedInputListener(event) {
|
|
@@ -506,6 +510,7 @@ class AuroForm extends LitElement {
|
|
|
506
510
|
|
|
507
511
|
/**
|
|
508
512
|
* Shared validation listener for all form elements.
|
|
513
|
+
* @private
|
|
509
514
|
* @param {Event} event - The event that is fired from the form element.
|
|
510
515
|
*/
|
|
511
516
|
sharedValidationListener(event) {
|
|
@@ -561,6 +566,7 @@ class AuroForm extends LitElement {
|
|
|
561
566
|
* root-level elements are added/removed. This is a workaround to ensure
|
|
562
567
|
* nested form elements are also observed.
|
|
563
568
|
*
|
|
569
|
+
* @private
|
|
564
570
|
* @returns {void}
|
|
565
571
|
*/
|
|
566
572
|
mutationEventListener() {
|
|
@@ -99,7 +99,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
99
99
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
100
100
|
|
|
101
101
|
```html
|
|
102
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@
|
|
102
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@0.0.0/auro-input/+esm"></script>
|
|
103
103
|
```
|
|
104
104
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
105
105
|
|
|
@@ -29,7 +29,7 @@ Generate unique names for dependency components.
|
|
|
29
29
|
| [errorMessage](#errorMessage) | `errorMessage` | `string` | | Contains the help text message for the current validity error. |
|
|
30
30
|
| [format](#format) | `format` | `string` | | Specifies the input mask format. |
|
|
31
31
|
| [icon](#icon) | `icon` | `boolean` | false | If set, will render an icon inside the input to the left of the value. Support is limited to auro-input instances with credit card format. |
|
|
32
|
-
| [id](#id) | `id` | `string` | |
|
|
32
|
+
| [id](#id) | `id` | `string` | | The id global attribute defines an identifier (ID) which must be unique in the whole document. |
|
|
33
33
|
| [inputmode](#inputmode) | `inputmode` | `string` | | Exposes inputmode attribute for input. |
|
|
34
34
|
| [lang](#lang) | `lang` | `string` | | Defines the language of an element. |
|
|
35
35
|
| [max](#max) | `max` | `string` | "undefined" | The maximum value allowed. This only applies for inputs with a type of `number` and all date formats. |
|
|
@@ -4978,6 +4978,9 @@ class AuroFormValidation {
|
|
|
4978
4978
|
* @attr {Boolean} bordered - Applies bordered UI variant.
|
|
4979
4979
|
* @attr {Boolean} borderless - Applies borderless UI variant.
|
|
4980
4980
|
*
|
|
4981
|
+
* @prop {string} id - The id global attribute defines an identifier (ID) which must be unique in the whole document.
|
|
4982
|
+
* @attr id
|
|
4983
|
+
*
|
|
4981
4984
|
* @slot helptext - Sets the help text displayed below the input.
|
|
4982
4985
|
* @slot label - Sets the label text for the input.
|
|
4983
4986
|
*
|
|
@@ -5168,13 +5171,6 @@ class BaseInput extends i {
|
|
|
5168
5171
|
reflect: true
|
|
5169
5172
|
},
|
|
5170
5173
|
|
|
5171
|
-
/**
|
|
5172
|
-
* Sets the unique ID of the element.
|
|
5173
|
-
*/
|
|
5174
|
-
id: {
|
|
5175
|
-
type: String
|
|
5176
|
-
},
|
|
5177
|
-
|
|
5178
5174
|
/** Exposes inputmode attribute for input. */
|
|
5179
5175
|
inputmode: {
|
|
5180
5176
|
type: String,
|
|
@@ -5395,6 +5391,16 @@ class BaseInput extends i {
|
|
|
5395
5391
|
type: Boolean,
|
|
5396
5392
|
reflect: true,
|
|
5397
5393
|
attribute: false
|
|
5394
|
+
},
|
|
5395
|
+
|
|
5396
|
+
/**
|
|
5397
|
+
* @private
|
|
5398
|
+
* id for input node
|
|
5399
|
+
*/
|
|
5400
|
+
inputId: {
|
|
5401
|
+
type: String,
|
|
5402
|
+
reflect: false,
|
|
5403
|
+
attribute: false
|
|
5398
5404
|
}
|
|
5399
5405
|
};
|
|
5400
5406
|
}
|
|
@@ -5426,6 +5432,7 @@ class BaseInput extends i {
|
|
|
5426
5432
|
if (this.tagName.toLowerCase() !== 'auro-input') {
|
|
5427
5433
|
this.setAttribute('auro-input', true);
|
|
5428
5434
|
}
|
|
5435
|
+
this.inputId = this.id ? `${this.id}-input` : window.crypto.randomUUID();
|
|
5429
5436
|
|
|
5430
5437
|
this.inputElement = this.renderRoot.querySelector('input');
|
|
5431
5438
|
this.labelElement = this.shadowRoot.querySelector('label');
|
|
@@ -7091,7 +7098,7 @@ class AuroInput extends BaseInput {
|
|
|
7091
7098
|
: undefined
|
|
7092
7099
|
}
|
|
7093
7100
|
</div>
|
|
7094
|
-
<label for=${this.
|
|
7101
|
+
<label for=${this.inputId} class="${e$2(labelClasses)}" part="label">
|
|
7095
7102
|
<slot name="label">
|
|
7096
7103
|
${this.label}
|
|
7097
7104
|
</slot>
|
|
@@ -7101,7 +7108,7 @@ class AuroInput extends BaseInput {
|
|
|
7101
7108
|
@input="${this.handleInput}"
|
|
7102
7109
|
@focusin="${this.handleFocusin}"
|
|
7103
7110
|
@blur="${this.handleBlur}"
|
|
7104
|
-
id="${this.
|
|
7111
|
+
id="${this.inputId}"
|
|
7105
7112
|
name="${o$3(this.name)}"
|
|
7106
7113
|
type="${this.type === 'password' && this.showPassword ? 'text' : this.getInputType(this.type)}"
|
|
7107
7114
|
pattern="${o$3(this.definePattern())}"
|
|
@@ -7169,7 +7176,7 @@ class AuroInput extends BaseInput {
|
|
|
7169
7176
|
variant="flat"
|
|
7170
7177
|
?onDark="${this.onDark}"
|
|
7171
7178
|
class="notificationBtn clearBtn"
|
|
7172
|
-
|
|
7179
|
+
arialabel="${i18n(this.lang, 'clearInput')}"
|
|
7173
7180
|
@click="${this.handleClickClear}">
|
|
7174
7181
|
<${this.iconTag}
|
|
7175
7182
|
customColor
|