@aurodesignsystem-dev/auro-formkit 0.0.0-pr1506.0 → 0.0.0-pr1506.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/components/checkbox/demo/customize.html +1 -2
  2. package/components/checkbox/demo/customize.min.js +1 -1
  3. package/components/checkbox/demo/getting-started.min.js +1 -1
  4. package/components/checkbox/demo/index.min.js +1 -1
  5. package/components/checkbox/dist/index.js +1 -1
  6. package/components/checkbox/dist/registered.js +1 -1
  7. package/components/combobox/demo/customize.html +1 -2
  8. package/components/combobox/demo/customize.md +108 -132
  9. package/components/combobox/demo/customize.min.js +26 -130
  10. package/components/combobox/demo/getting-started.min.js +26 -130
  11. package/components/combobox/demo/index.min.js +26 -130
  12. package/components/combobox/dist/index.js +26 -130
  13. package/components/combobox/dist/registered.js +26 -130
  14. package/components/counter/demo/customize.min.js +2 -2
  15. package/components/counter/demo/index.min.js +2 -2
  16. package/components/counter/dist/index.js +2 -2
  17. package/components/counter/dist/registered.js +2 -2
  18. package/components/datepicker/demo/customize.min.js +12 -124
  19. package/components/datepicker/demo/index.min.js +12 -124
  20. package/components/datepicker/dist/index.js +12 -124
  21. package/components/datepicker/dist/registered.js +12 -124
  22. package/components/dropdown/demo/customize.min.js +1 -1
  23. package/components/dropdown/demo/getting-started.min.js +1 -1
  24. package/components/dropdown/demo/index.min.js +1 -1
  25. package/components/dropdown/dist/index.js +1 -1
  26. package/components/dropdown/dist/registered.js +1 -1
  27. package/components/form/demo/customize.html +6 -6
  28. package/components/form/demo/customize.js +19 -0
  29. package/components/form/demo/customize.md +203 -51
  30. package/components/form/demo/customize.min.js +489 -419
  31. package/components/form/demo/getting-started.min.js +417 -419
  32. package/components/form/demo/index.min.js +417 -419
  33. package/components/form/demo/registerDemoDeps.min.js +54 -382
  34. package/components/form/dist/auro-form.d.ts +122 -4
  35. package/components/form/dist/index.js +363 -37
  36. package/components/form/dist/registered.js +363 -37
  37. package/components/input/demo/customize.html +1 -2
  38. package/components/input/demo/customize.min.js +10 -122
  39. package/components/input/demo/getting-started.min.js +10 -122
  40. package/components/input/demo/index.min.js +10 -122
  41. package/components/input/dist/base-input.d.ts +1 -49
  42. package/components/input/dist/index.js +10 -122
  43. package/components/input/dist/registered.js +10 -122
  44. package/components/radio/demo/customize.min.js +1 -1
  45. package/components/radio/demo/getting-started.min.js +1 -1
  46. package/components/radio/demo/index.min.js +1 -1
  47. package/components/radio/dist/index.js +1 -1
  48. package/components/radio/dist/registered.js +1 -1
  49. package/components/select/demo/customize.html +1 -2
  50. package/components/select/demo/customize.min.js +2 -2
  51. package/components/select/demo/getting-started.min.js +2 -2
  52. package/components/select/demo/index.min.js +2 -2
  53. package/components/select/dist/index.js +2 -2
  54. package/components/select/dist/registered.js +2 -2
  55. package/custom-elements.json +123 -266
  56. package/package.json +1 -1
@@ -7,6 +7,11 @@
7
7
  <auro-anchorlink fluid href="#layout">Layout</auro-anchorlink>
8
8
  <auro-anchorlink fluid href="#columnLayout" class="level2 body-xs">Column Layout</auro-anchorlink>
9
9
  <auro-anchorlink fluid href="#complexForm" class="level2 body-xs">Complex Form</auro-anchorlink>
10
+ <auro-anchorlink fluid href="#fieldState">Field State</auro-anchorlink>
11
+ <auro-anchorlink fluid href="#disabledFields" class="level2 body-xs">Disabled Fields</auro-anchorlink>
12
+ <auro-anchorlink fluid href="#disableAfterEdit" class="level2 body-xs">Disabling After User Edits</auro-anchorlink>
13
+ <auro-anchorlink fluid href="#behaviorChangesV6" class="level2 body-xs">Behavior Changes in v6</auro-anchorlink>
14
+ <auro-anchorlink fluid href="#runtimeMutations" class="level2 body-xs">Runtime DOM Mutations</auro-anchorlink>
10
15
  </auro-nav>
11
16
  </nav>
12
17
  <div class="mainContent">
@@ -24,16 +29,14 @@
24
29
  display: grid;
25
30
  grid-template-columns: 1fr 1fr;
26
31
  gap: 1rem;
32
+ align-items: start;
27
33
  }
28
34
 
29
- .columned-form div {
30
- display: flex;
31
- flex-direction: column;
32
- padding: 1rem;
33
- gap: 1rem;
35
+ .columned-form .span-2 {
36
+ grid-column: span 2;
34
37
  }
35
38
 
36
- .controls {
39
+ .columned-form-controls {
37
40
  display: flex;
38
41
  justify-content: flex-end;
39
42
  margin-top: 1rem;
@@ -41,29 +44,25 @@
41
44
  </style>
42
45
  <auro-form>
43
46
  <div class="columned-form">
44
- <div>
45
- <auro-input id="search-box" name="searchBox" required>
46
- <span slot="label">Search flights</span>
47
+ <auro-input id="cl-first-name" name="firstName" required>
48
+ <span slot="label">First Name</span>
47
49
  </auro-input>
48
- <auro-input id="last-name" name="lastName" required>
50
+ <auro-input id="cl-last-name" name="lastName" required>
49
51
  <span slot="label">Last Name</span>
50
- </auro-input>
51
- </div>
52
- <div>
53
- <div class="datepickerBlock">
54
- <h4>Pick a date range</h4>
55
- <auro-datepicker id="date-range" name="dateRange" required range>
56
- <span slot="fromLabel">Start</span>
57
- <span slot="toLabel">End</span>
58
- <span slot="bib.fullscreen.fromLabel">Start</span>
59
- <span slot="bib.fullscreen.toLabel">End</span>
52
+ </auro-input>
53
+ <auro-input id="cl-email" name="email" type="email" class="span-2" required>
54
+ <span slot="label">Email</span>
55
+ </auro-input>
56
+ <auro-datepicker id="cl-date-range" name="dateRange" class="span-2" required range>
57
+ <span slot="fromLabel">Departure</span>
58
+ <span slot="toLabel">Return</span>
59
+ <span slot="bib.fullscreen.fromLabel">Departure</span>
60
+ <span slot="bib.fullscreen.toLabel">Return</span>
60
61
  </auro-datepicker>
61
62
  </div>
62
- <div class="controls">
63
+ <div class="columned-form-controls">
63
64
  <auro-button type="submit">Submit</auro-button>
64
65
  </div>
65
- </div>
66
- </div>
67
66
  </auro-form>
68
67
  <!-- AURO-GENERATED-CONTENT:END -->
69
68
  </div>
@@ -76,16 +75,14 @@
76
75
  display: grid;
77
76
  grid-template-columns: 1fr 1fr;
78
77
  gap: 1rem;
78
+ align-items: start;
79
79
  }
80
80
 
81
- .columned-form div {
82
- display: flex;
83
- flex-direction: column;
84
- padding: 1rem;
85
- gap: 1rem;
81
+ .columned-form .span-2 {
82
+ grid-column: span 2;
86
83
  }
87
84
 
88
- .controls {
85
+ .columned-form-controls {
89
86
  display: flex;
90
87
  justify-content: flex-end;
91
88
  margin-top: 1rem;
@@ -93,28 +90,24 @@
93
90
  &lt;/style&gt;
94
91
  &lt;auro-form&gt;
95
92
  &lt;div class="columned-form"&gt;
96
- &lt;div&gt;
97
- &lt;auro-input id="search-box" name="searchBox" required&gt;
98
- &lt;span slot="label"&gt;Search flights&lt;/span&gt;
99
- &lt;/auro-input&gt;
100
- &lt;auro-input id="last-name" name="lastName" required&gt;
101
- &lt;span slot="label"&gt;Last Name&lt;/span&gt;
102
- &lt;/auro-input&gt;
103
- &lt;/div&gt;
104
- &lt;div&gt;
105
- &lt;div class="datepickerBlock"&gt;
106
- &lt;h4&gt;Pick a date range&lt;/h4&gt;
107
- &lt;auro-datepicker id="date-range" name="dateRange" required range&gt;
108
- &lt;span slot="fromLabel"&gt;Start&lt;/span&gt;
109
- &lt;span slot="toLabel"&gt;End&lt;/span&gt;
110
- &lt;span slot="bib.fullscreen.fromLabel"&gt;Start&lt;/span&gt;
111
- &lt;span slot="bib.fullscreen.toLabel"&gt;End&lt;/span&gt;
112
- &lt;/auro-datepicker&gt;
113
- &lt;/div&gt;
114
- &lt;div class="controls"&gt;
115
- &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
116
- &lt;/div&gt;
117
- &lt;/div&gt;
93
+ &lt;auro-input id="cl-first-name" name="firstName" required&gt;
94
+ &lt;span slot="label"&gt;First Name&lt;/span&gt;
95
+ &lt;/auro-input&gt;
96
+ &lt;auro-input id="cl-last-name" name="lastName" required&gt;
97
+ &lt;span slot="label"&gt;Last Name&lt;/span&gt;
98
+ &lt;/auro-input&gt;
99
+ &lt;auro-input id="cl-email" name="email" type="email" class="span-2" required&gt;
100
+ &lt;span slot="label"&gt;Email&lt;/span&gt;
101
+ &lt;/auro-input&gt;
102
+ &lt;auro-datepicker id="cl-date-range" name="dateRange" class="span-2" required range&gt;
103
+ &lt;span slot="fromLabel"&gt;Departure&lt;/span&gt;
104
+ &lt;span slot="toLabel"&gt;Return&lt;/span&gt;
105
+ &lt;span slot="bib.fullscreen.fromLabel"&gt;Departure&lt;/span&gt;
106
+ &lt;span slot="bib.fullscreen.toLabel"&gt;Return&lt;/span&gt;
107
+ &lt;/auro-datepicker&gt;
108
+ &lt;/div&gt;
109
+ &lt;div class="columned-form-controls"&gt;
110
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
118
111
  &lt;/div&gt;
119
112
  &lt;/auro-form&gt;</code></pre>
120
113
  <!-- AURO-GENERATED-CONTENT:END -->
@@ -241,6 +234,165 @@
241
234
  <!-- AURO-GENERATED-CONTENT:END -->
242
235
  </auro-accordion>
243
236
  </section>
237
+ <section>
238
+ <auro-header level="2" id="fieldState">Field State</auro-header>
239
+ <p>Per the <auro-hyperlink href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/disabled" target="_blank">HTML spec</auro-hyperlink>, form controls with the <code>disabled</code> attribute are excluded from form submission and are not validated. <code>auro-form</code> mirrors that behavior.</p>
240
+ <auro-header level="3" id="disabledFields">Disabled Fields</auro-header>
241
+ <p>When a child form element has the <code>disabled</code> attribute:</p>
242
+ <ul>
243
+ <li>Its <code>name</code> is omitted from <code>form.value</code> and from the <code>submit</code> event's <code>detail.value</code>, even if the element carries a value.</li>
244
+ <li>It does not contribute to <code>validity</code> — a disabled <code>required</code> field will not block submission.</li>
245
+ <li>A disabled field carrying its <strong>default</strong> (attribute-declared) value does not taint <code>isInitialState</code> — the form is still in its initial state. However, a field that the user has already edited and then becomes disabled <em>does</em> still count toward the form being non-initial. Disabling a field does not clear its dirty state, matching HTML's <code>dirtyValueFlag</code> semantics.</li>
246
+ </ul>
247
+ <p>In the example below the Mileage Plan number is preset and disabled. Fill in the remaining required fields and submit the form — the output region below the form will show the contents of the <code>submit</code> event's <code>detail.value</code>. Notice that only <code>firstName</code> and <code>lastName</code> appear; <code>loyaltyNumber</code> is omitted even though the field has a value. See the <auro-hyperlink href="#behaviorChangesV6">Behavior changes in v6</auro-hyperlink> section below for the full set of migration notes, including the recommended replacement for using <code>disabled</code> to carry values through to submission.</p>
248
+ <div class="exampleWrapper">
249
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/disabled.html) -->
250
+ <!-- The below content is automatically added from ./../apiExamples/disabled.html -->
251
+ <auro-form id="disabledExampleForm">
252
+ <auro-input id="first-name" name="firstName" required>
253
+ <span slot="label">First Name</span>
254
+ </auro-input>
255
+ <br />
256
+ <auro-input id="last-name" name="lastName" required>
257
+ <span slot="label">Last Name</span>
258
+ </auro-input>
259
+ <br />
260
+ <auro-input id="loyalty-number" name="loyaltyNumber" value="AS-123456" disabled>
261
+ <span slot="label">Mileage Plan number</span>
262
+ <span slot="helpText">Account number is read-only and is not submitted with the form.</span>
263
+ </auro-input>
264
+ <br />
265
+ <auro-button type="submit">Submit</auro-button>
266
+ </auro-form>
267
+ <output id="disabledExampleOutput" aria-live="polite">Submit the form to see what data gets stored.</output>
268
+ <style>
269
+ #disabledExampleOutput {
270
+ display: block;
271
+ margin-top: 2rem;
272
+ padding: 1rem 1.25rem;
273
+ border-left: 4px solid #2a2a2a;
274
+ border-radius: 0.25rem;
275
+ background: #f5f5f5;
276
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
277
+ font-size: 0.875rem;
278
+ white-space: pre-wrap;
279
+ }
280
+ </style>
281
+ <!-- AURO-GENERATED-CONTENT:END -->
282
+ </div>
283
+ <auro-accordion alignRight>
284
+ <span slot="trigger">See code</span>
285
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/disabled.html) -->
286
+ <!-- The below code snippet is automatically added from ./../apiExamples/disabled.html -->
287
+ <pre class="language-html"><code class="language-html">&lt;auro-form id="disabledExampleForm"&gt;
288
+ &lt;auro-input id="first-name" name="firstName" required&gt;
289
+ &lt;span slot="label"&gt;First Name&lt;/span&gt;
290
+ &lt;/auro-input&gt;
291
+ &lt;br /&gt;
292
+ &lt;auro-input id="last-name" name="lastName" required&gt;
293
+ &lt;span slot="label"&gt;Last Name&lt;/span&gt;
294
+ &lt;/auro-input&gt;
295
+ &lt;br /&gt;
296
+ &lt;auro-input id="loyalty-number" name="loyaltyNumber" value="AS-123456" disabled&gt;
297
+ &lt;span slot="label"&gt;Mileage Plan number&lt;/span&gt;
298
+ &lt;span slot="helpText"&gt;Account number is read-only and is not submitted with the form.&lt;/span&gt;
299
+ &lt;/auro-input&gt;
300
+ &lt;br /&gt;
301
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
302
+ &lt;/auro-form&gt;
303
+ &lt;output id="disabledExampleOutput" aria-live="polite"&gt;Submit the form to see what data gets stored.&lt;/output&gt;
304
+ &lt;style&gt;
305
+ #disabledExampleOutput {
306
+ display: block;
307
+ margin-top: 2rem;
308
+ padding: 1rem 1.25rem;
309
+ border-left: 4px solid #2a2a2a;
310
+ border-radius: 0.25rem;
311
+ background: #f5f5f5;
312
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
313
+ font-size: 0.875rem;
314
+ white-space: pre-wrap;
315
+ }
316
+ &lt;/style&gt;</code></pre>
317
+ <!-- AURO-GENERATED-CONTENT:END -->
318
+ </auro-accordion>
319
+ <auro-header level="3" id="disableAfterEdit">Disabling a field after user edits</auro-header>
320
+ <p>If a field is disabled <em>after</em> the user has edited it, the value is still excluded from <code>form.value</code>, validation, and the submit payload — but the form correctly reports as non-initial and Reset remains enabled. Type into the field below, then click "Disable field" to observe the behavior. Submit to see the form's current <code>value</code> and <code>isInitialState</code>.</p>
321
+ <div class="exampleWrapper">
322
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/disabled-after-edit.html) -->
323
+ <!-- The below content is automatically added from ./../apiExamples/disabled-after-edit.html -->
324
+ <auro-form id="disableAfterEditForm">
325
+ <auro-input id="dae-field" name="comment">
326
+ <span slot="label">Comment</span>
327
+ </auro-input>
328
+ <br />
329
+ <auro-button id="dae-toggle" type="button">Disable field</auro-button>
330
+ <auro-button type="submit">Submit</auro-button>
331
+ <auro-button type="reset">Reset</auro-button>
332
+ </auro-form>
333
+ <output id="disableAfterEditOutput" aria-live="polite">Type something, then click "Disable field". The form correctly reports as non-initial, Reset stays enabled, and the field is excluded from the submit payload.</output>
334
+ <style>
335
+ #disableAfterEditOutput {
336
+ display: block;
337
+ margin-top: 2rem;
338
+ padding: 1rem 1.25rem;
339
+ border-left: 4px solid #2a2a2a;
340
+ border-radius: 0.25rem;
341
+ background: #f5f5f5;
342
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
343
+ font-size: 0.875rem;
344
+ white-space: pre-wrap;
345
+ }
346
+ </style>
347
+ <!-- AURO-GENERATED-CONTENT:END -->
348
+ </div>
349
+ <auro-accordion alignRight>
350
+ <span slot="trigger">See code</span>
351
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/disabled-after-edit.html) -->
352
+ <!-- The below code snippet is automatically added from ./../apiExamples/disabled-after-edit.html -->
353
+ <pre class="language-html"><code class="language-html">&lt;auro-form id="disableAfterEditForm"&gt;
354
+ &lt;auro-input id="dae-field" name="comment"&gt;
355
+ &lt;span slot="label"&gt;Comment&lt;/span&gt;
356
+ &lt;/auro-input&gt;
357
+ &lt;br /&gt;
358
+ &lt;auro-button id="dae-toggle" type="button"&gt;Disable field&lt;/auro-button&gt;
359
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
360
+ &lt;auro-button type="reset"&gt;Reset&lt;/auro-button&gt;
361
+ &lt;/auro-form&gt;
362
+ &lt;output id="disableAfterEditOutput" aria-live="polite"&gt;Type something, then click "Disable field". The form correctly reports as non-initial, Reset stays enabled, and the field is excluded from the submit payload.&lt;/output&gt;
363
+ &lt;style&gt;
364
+ #disableAfterEditOutput {
365
+ display: block;
366
+ margin-top: 2rem;
367
+ padding: 1rem 1.25rem;
368
+ border-left: 4px solid #2a2a2a;
369
+ border-radius: 0.25rem;
370
+ background: #f5f5f5;
371
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
372
+ font-size: 0.875rem;
373
+ white-space: pre-wrap;
374
+ }
375
+ &lt;/style&gt;</code></pre>
376
+ <!-- AURO-GENERATED-CONTENT:END -->
377
+ </auro-accordion>
378
+ <auro-header level="3" id="behaviorChangesV6">Behavior changes in v6</auro-header>
379
+ <p>This release brings <code>auro-form</code> closer to native HTML form semantics. The following are consumer-visible behavior changes from previous versions:</p>
380
+ <ul>
381
+ <li><strong><code>form.value</code> omits disabled fields.</strong> Any control with the <code>disabled</code> attribute is excluded from <code>form.value</code> and from the <code>submit</code> event's <code>detail.value</code>. <em>Migration:</em> if you were using <code>disabled</code> on a populated field to carry a value through to submission (for example, a read-only account number or a preset reference id), switch that field to <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/hidden"><code>&lt;input type="hidden"&gt;</code></a> — hidden inputs are submitted with the form even though they are not interactive, which is the native pattern for "include this value, but don't show or validate it."</li>
382
+ <li><strong>Disabled required fields no longer block submission.</strong> A form whose only invalid field is a <code>disabled</code> + <code>required</code> field is now submittable. Per the HTML spec, disabled controls do not participate in constraint validation.</li>
383
+ <li><strong><code>isInitialState</code> uses a dirty-value-flag model.</strong> A field taints the form only when its current value diverges from its captured initial value (or enters an error validity state). A pre-filled form whose user has not yet edited anything reports <code>isInitialState === true</code>; previously, any non-null value would mark the form as non-initial. Disabling a previously-edited field does <em>not</em> clear the dirty flag — the form correctly remains non-initial. <em>Migration:</em> if you were using <code>isInitialState === false</code> as a proxy for "user has interacted with the form," use a per-field <code>touched</code> signal on each <code>auro-input</code> instead.</li>
384
+ <li><strong>Submit availability depends on validity alone.</strong> The Submit button is enabled when no enabled field has an unmet constraint, regardless of <code>isInitialState</code>. Pre-filled valid forms (for example, forms pre-populated from a logged-in user's profile) can be submitted on first render without a prior user edit. Empty forms with only optional fields also have Submit enabled at first render. Previously both cases would have been blocked.</li>
385
+ <li><strong>Focus/blur on an optional field no longer taints the form.</strong> Tabbing through an optional field that the user did not edit no longer flips <code>isInitialState</code> to <code>false</code>. Required fields are unaffected — focusing then blurring an empty required field still taints, because the resulting <code>'valueMissing'</code> validity is an error state. <em>Migration:</em> if you needed "user has engaged with the form" as a signal, use per-field <code>touched</code> state on each <code>auro-input</code>.</li>
386
+ </ul>
387
+ <auro-header level="3" id="runtimeMutations">Runtime DOM mutations</auro-header>
388
+ <p><code>auro-form</code> tracks its child form elements through a subtree <code>MutationObserver</code> on <code>name</code> and <code>disabled</code> attributes, plus a slot-change listener. The following runtime patterns are supported without any consumer-side reinitialization:</p>
389
+ <ul>
390
+ <li><strong>Runtime renames.</strong> Changing the <code>name</code> attribute on a tracked field re-keys <code>formState</code> and migrates the captured initial value to the new key, preserving <code>isInitialState</code> semantics across the rename. <code>form.value</code> reflects the new key on the next render. Removing the <code>name</code> attribute drops the field from <code>formState</code> and prunes its captured initial.</li>
391
+ <li><strong>Late name attachment.</strong> An element that initially renders without a <code>name</code> is invisible to <code>auro-form</code> (it queries via <code>form</code>). When the consumer adds a <code>name</code> attribute later, the field is picked up automatically — both <code>formState</code> registration and the <code>input</code>/<code>auroFormElement-validated</code>/<code>keydown</code> listeners are wired up via the same attribute observer.</li>
392
+ <li><strong>Reset gating.</strong> The Reset button is enabled whenever the form is dirty (<code>isInitialState === false</code>), or any non-disabled field carries a current or default value. A disabled field carrying only its captured initial value does <em>not</em> enable Reset; a previously-edited field that has since been disabled <em>does</em> (the dirty flag persists across disabling, so the user always has a UI path back to the initial state).</li>
393
+ <li><strong>Enter-to-submit on disabled fields.</strong> Pressing Enter inside a disabled form field never submits the form, matching native HTML behavior. Disabled controls do not dispatch the implicit submit, so the user must move focus to an enabled field (or click Submit) to trigger submission.</li>
394
+ </ul>
395
+ </section>
244
396
  </div>
245
397
  </div>
246
398
  </div>