@aurodesignsystem-dev/auro-formkit 0.0.0-pr1451.20 → 0.0.0-pr1451.21

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 (59) hide show
  1. package/components/checkbox/demo/api.min.js +1 -1
  2. package/components/checkbox/demo/index.min.js +1 -1
  3. package/components/checkbox/dist/index.js +1 -1
  4. package/components/checkbox/dist/registered.js +1 -1
  5. package/components/combobox/demo/api.min.js +3 -3
  6. package/components/combobox/demo/customize.min.js +3 -3
  7. package/components/combobox/demo/getting-started.min.js +3 -3
  8. package/components/combobox/demo/index.min.js +3 -3
  9. package/components/combobox/dist/index.js +3 -3
  10. package/components/combobox/dist/registered.js +3 -3
  11. package/components/counter/demo/api.min.js +2 -2
  12. package/components/counter/demo/index.min.js +2 -2
  13. package/components/counter/dist/index.js +2 -2
  14. package/components/counter/dist/registered.js +2 -2
  15. package/components/datepicker/demo/api.min.js +3 -3
  16. package/components/datepicker/demo/index.min.js +3 -3
  17. package/components/datepicker/dist/index.js +3 -3
  18. package/components/datepicker/dist/registered.js +3 -3
  19. package/components/dropdown/demo/api.min.js +1 -1
  20. package/components/dropdown/demo/index.min.js +1 -1
  21. package/components/dropdown/dist/index.js +1 -1
  22. package/components/dropdown/dist/registered.js +1 -1
  23. package/components/form/README.md +9 -9
  24. package/components/form/demo/accessibility.html +51 -0
  25. package/components/form/demo/accessibility.md +23 -0
  26. package/components/form/demo/api.html +11 -14
  27. package/components/form/demo/api.md +0 -276
  28. package/components/form/demo/api.min.js +13 -13
  29. package/components/form/demo/customize.html +54 -0
  30. package/components/form/demo/customize.md +246 -0
  31. package/components/form/demo/demo-support.js +60 -0
  32. package/components/form/demo/getting-started.html +54 -0
  33. package/components/form/demo/getting-started.md +291 -0
  34. package/components/form/demo/index.html +12 -14
  35. package/components/form/demo/index.md +66 -96
  36. package/components/form/demo/index.min.js +13 -13
  37. package/components/form/demo/keyboard-behavior.html +51 -0
  38. package/components/form/demo/readme.html +12 -17
  39. package/components/form/demo/readme.md +9 -9
  40. package/components/form/demo/styles.css +974 -0
  41. package/components/form/demo/voiceover.html +51 -0
  42. package/components/form/demo/voiceover.md +36 -0
  43. package/components/input/demo/api.min.js +1 -1
  44. package/components/input/demo/customize.min.js +1 -1
  45. package/components/input/demo/getting-started.min.js +1 -1
  46. package/components/input/demo/index.min.js +1 -1
  47. package/components/input/dist/index.js +1 -1
  48. package/components/input/dist/registered.js +1 -1
  49. package/components/radio/demo/api.min.js +1 -1
  50. package/components/radio/demo/index.min.js +1 -1
  51. package/components/radio/dist/index.js +1 -1
  52. package/components/radio/dist/registered.js +1 -1
  53. package/components/select/demo/customize.min.js +2 -2
  54. package/components/select/demo/getting-started.min.js +2 -2
  55. package/components/select/demo/index.min.js +2 -2
  56. package/components/select/dist/index.js +2 -2
  57. package/components/select/dist/registered.js +2 -2
  58. package/custom-elements.json +1489 -1489
  59. package/package.json +1 -1
@@ -0,0 +1,291 @@
1
+ <auro-header level="1" id="overview">Form - Getting Started</auro-header>
2
+ <div class="contentWrapper">
3
+ <nav>
4
+ <auro-nav anchorNavContent=".scrollWrapper">
5
+ <span slot="mobileToggleCollapsed">View More</span>
6
+ <span slot="mobileToggleExpanded">View Less</span>
7
+ <auro-anchorlink fluid href="#setup">Setup</auro-anchorlink>
8
+ <auro-anchorlink fluid href="#recommendedSetup" class="level2 body-xs" onclick="openAccordion('recommendedAccordion')">Recommended</auro-anchorlink>
9
+ <auro-anchorlink fluid href="#autoSetup" class="level2 body-xs" onclick="openAccordion('autoAccordion')">Auto</auro-anchorlink>
10
+ <auro-anchorlink fluid href="#cdnSetup" class="level2 body-xs" onclick="openAccordion('cdnAccordion')">CDN</auro-anchorlink>
11
+ <auro-anchorlink fluid href="#minimalConfig">Minimal Configuration</auro-anchorlink>
12
+ <auro-anchorlink fluid href="#slots">Slots</auro-anchorlink>
13
+ <auro-anchorlink fluid href="#functions">Functions</auro-anchorlink>
14
+ <auro-anchorlink fluid href="#fnSubmit" class="level2 body-xs">submit()</auro-anchorlink>
15
+ <auro-anchorlink fluid href="#fnReset" class="level2 body-xs">reset()</auro-anchorlink>
16
+ </auro-nav>
17
+ </nav>
18
+ <div class="mainContent">
19
+ <div class="scrollWrapper">
20
+ <section>
21
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/getting-started/install.md) -->
22
+ <!-- The below content is automatically added from ./../docs/partials/getting-started/install.md -->
23
+ <auro-header level="2" id="setup">Setup</auro-header>
24
+ <auro-accordion-group Emphasis>
25
+ <auro-accordion expanded class="section" id="recommendedAccordion">
26
+ <span slot="trigger">Recommended Installation and Implementation</span>
27
+ <div class="accordion-content">
28
+ <auro-header level="3">Install</auro-header>
29
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../../../docs/templates/componentInstall.md) -->
30
+ <!-- The below content is automatically added from ./../../../docs/templates/componentInstall.md -->
31
+
32
+ <pre class="language-shell"><code class="language-shell">$ npm i @aurodesignsystem/auro-formkit</code></pre>
33
+ <!-- AURO-GENERATED-CONTENT:END -->
34
+ <auro-header level="3">Implementation</auro-header>
35
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/customRegistration.md) -->
36
+ <!-- The below content is automatically added from ./../docs/partials/customRegistration.md -->
37
+
38
+ ## Custom Component Registration for Version Management
39
+
40
+ There are two key parts to every Auro component: the <auro-hyperlink href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes" target="_blank">class</auro-hyperlink> and the custom element definition. The class defines the component's behavior, while the custom element registers it under a specific name so it can be used in HTML.
41
+
42
+ You can do this by importing only the component class and using the <code>register(name)</code> method with a unique name:
43
+
44
+ <pre class="language-js"><code class="language-js">// Import the class only
45
+ import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
46
+
47
+ // Register with a custom name if desired
48
+ AuroForm.register('[custom]-form');</code></pre>
49
+
50
+ This will create a new custom element `<custom-form>` that behaves exactly like `<auro-form>`, allowing both to coexist on the same page without interfering with each other.
51
+
52
+ ### Using Custom-Named Child Form Elements
53
+
54
+ When consuming custom-named Auro form elements (like `auro-input` registered as `custom-input`),
55
+ these elements _must_ be registered BEFORE auro-form due to rendering order limitations.
56
+ Auro form elements are automatically recognized based on their tag name (e.g. `auro-input`) or special auro attributes which are only assigned during the initial render.
57
+
58
+ For example, the following is correct:
59
+
60
+ <pre class="language-javascript"><code class="language-javascript">import { AuroInput } from '@aurodesignsystem/auro-formkit/auro-input/class';
61
+ import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
62
+
63
+ AuroInput.register('[custom]-input'); // adds an internal identifier auro-form uses to recognize the custom element
64
+ AuroForm.register('[custom]-form'); // render looks for said identifier</code></pre>
65
+
66
+ The following is NOT correct and will result in forms not working as expected:
67
+
68
+ <pre class="language-javascript"><code class="language-javascript">import { AuroInput } from '@aurodesignsystem/auro-formkit/auro-input/class';
69
+ import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
70
+
71
+ AuroForm.register('[custom]-form'); // forms start rendering, looking for auro inputs, or custom-named inputs
72
+ AuroInput.register('[custom]-input'); // too late, form has already rendered and did not find the custom element</code></pre>
73
+ <!-- AURO-GENERATED-CONTENT:END -->
74
+ </div>
75
+ </auro-accordion>
76
+ <auro-accordion class="section" id="autoAccordion">
77
+ <span slot="trigger">Auto Installation and Implementation</span>
78
+ <div class="accordion-content">
79
+ <p class="warning"><strong>Warning:</strong> Default registration can cause conflicts if another package registers the same tag name using a different version of the component, leading to unexpected behavior. Use custom registration to avoid this risk.</p>
80
+ <auro-header level="3">Install</auro-header>
81
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../../../docs/templates/componentInstall.md) -->
82
+ <!-- The below content is automatically added from ./../../../docs/templates/componentInstall.md -->
83
+
84
+ <pre class="language-shell"><code class="language-shell">$ npm i @aurodesignsystem/auro-formkit</code></pre>
85
+ <!-- AURO-GENERATED-CONTENT:END -->
86
+ <auro-header level="3">Implementation</auro-header>
87
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/getting-started/defaultRegistration.md) -->
88
+ <!-- The below content is automatically added from ./../docs/partials/getting-started/defaultRegistration.md -->
89
+ Import the component, then register the custom element:
90
+
91
+ <pre class="language-js"><code class="language-js">import '@aurodesignsystem/auro-formkit/auro-form';</code></pre>
92
+
93
+ Then use the element in your HTML:
94
+
95
+ <pre class="language-html"><code class="language-html">&lt;auro-form&gt;
96
+ &lt;auro-input name="searchBox" required&gt;
97
+ &lt;span slot="label"&gt;Search flights&lt;/span&gt;
98
+ &lt;/auro-input&gt;
99
+ &lt;br /&gt;
100
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
101
+ &lt;/auro-form&gt;</code></pre>
102
+ <!-- AURO-GENERATED-CONTENT:END -->
103
+ </div>
104
+ </auro-accordion>
105
+ <auro-accordion class="section" id="cdnAccordion">
106
+ <span slot="trigger">CDN Installation and Implementation</span>
107
+ <div class="accordion-content">
108
+ <p class="warning"><strong>Warning:</strong> CDN install & registration can cause conflicts if another package registers the same tag name using a different version of the component, leading to unexpected behavior. Use custom registration to avoid this risk.</p>
109
+ <auro-header level="3">Install & Implementation</auro-header>
110
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/getting-started/cdnRegistration.md) -->
111
+ <!-- The below content is automatically added from ./../docs/partials/getting-started/cdnRegistration.md -->
112
+ <p>Add the following script tag to your HTML to load the component directly from a CDN:</p>
113
+
114
+ <pre class="language-html"><code class="language-html">&lt;script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@latest/auro-form/+esm"&gt;&lt;/script&gt;</code></pre>
115
+ <p>This script registers the <code>&lt;auro-form&gt;</code> custom element globally. You can then use it in your HTML:</p>
116
+
117
+ <pre class="language-html"><code class="language-html">&lt;auro-form&gt;
118
+ &lt;auro-input name="searchBox" required&gt;
119
+ &lt;span slot="label"&gt;Search flights&lt;/span&gt;
120
+ &lt;/auro-input&gt;
121
+ &lt;br /&gt;
122
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
123
+ &lt;/auro-form&gt;</code></pre>
124
+ <!-- AURO-GENERATED-CONTENT:END -->
125
+ </div>
126
+ </auro-accordion>
127
+ </auro-accordion-group>
128
+ <!-- AURO-GENERATED-CONTENT:END -->
129
+ </section>
130
+ <section>
131
+ <auro-header level="2" id="minimalConfig">Minimal Configuration</auro-header>
132
+ <p>The most basic use of <code>auro-form</code> requires one or more named Auro form elements inside the form. Add a button with <code>type="submit"</code> to trigger form submission.</p>
133
+ <div class="exampleWrapper">
134
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic.html) -->
135
+ <!-- The below content is automatically added from ./../apiExamples/basic.html -->
136
+ <auro-form>
137
+ <auro-input id="search-box" name="searchBox" required>
138
+ <span slot="label">Search flights</span>
139
+ </auro-input>
140
+ <br />
141
+ <auro-button type="submit">Submit</auro-button>
142
+ </auro-form>
143
+ <!-- AURO-GENERATED-CONTENT:END -->
144
+ </div>
145
+ <auro-accordion alignRight>
146
+ <span slot="trigger">See code</span>
147
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/basic.html) -->
148
+ <!-- The below code snippet is automatically added from ./../apiExamples/basic.html -->
149
+ <pre class="language-html"><code class="language-html">&lt;auro-form&gt;
150
+ &lt;auro-input id="search-box" name="searchBox" required&gt;
151
+ &lt;span slot="label"&gt;Search flights&lt;/span&gt;
152
+ &lt;/auro-input&gt;
153
+ &lt;br /&gt;
154
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
155
+ &lt;/auro-form&gt;</code></pre>
156
+ <!-- AURO-GENERATED-CONTENT:END -->
157
+ </auro-accordion>
158
+ </section>
159
+ <section>
160
+ <auro-header level="2" id="slots">Slots</auro-header>
161
+ <p>The <code>default</code> slot accepts any Auro form elements (e.g., <code>auro-input</code>, <code>auro-select</code>, <code>auro-datepicker</code>, <code>auro-counter-group</code>) as well as any HTML elements for layout and structure.</p>
162
+ <div class="exampleWrapper">
163
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/complex.html) -->
164
+ <!-- The below content is automatically added from ./../apiExamples/complex.html -->
165
+ <style>
166
+ .submitBlock {
167
+ margin-top: 1rem;
168
+ display: flex;
169
+ justify-content: flex-end;
170
+ gap: 1rem;
171
+ }
172
+ .datepickerBlock {
173
+ margin-top: 1rem;
174
+ }
175
+ .complex-form {
176
+ display: block;
177
+ padding: 1rem;
178
+ border: 1px solid #2a2a2a;
179
+ border-radius: 1rem;
180
+ }
181
+ </style>
182
+ <auro-form class="complex-form">
183
+ <auro-input id="first-name" name="firstName" required>
184
+ <span slot="label">First Name</span>
185
+ </auro-input>
186
+ <br />
187
+ <auro-input id="last-name" name="lastName" required>
188
+ <span slot="label">Last Name</span>
189
+ </auro-input>
190
+ <br />
191
+ <auro-input id="occupation" name="occupation" required>
192
+ <span slot="label">Occupation</span>
193
+ </auro-input>
194
+ <br />
195
+ <auro-input-two id="cool-fact" name="coolFact" required>
196
+ <span slot="label">Cool Fact</span>
197
+ </auro-input-two>
198
+ <div class="datepickerBlock">
199
+ <h4>Pick a cool date</h4>
200
+ <auro-datepicker id="date-example" name="dateExample" required>
201
+ <span slot="fromLabel">Choose a date</span>
202
+ <span slot="bib.fullscreen.fromLabel">Choose a date</span>
203
+ </auro-datepicker>
204
+ </div>
205
+ <div class="datepickerBlock">
206
+ <h4>Pick a date range</h4>
207
+ <auro-datepicker id="date-range" name="dateRange" required range>
208
+ <span slot="fromLabel">Start</span>
209
+ <span slot="toLabel">End</span>
210
+ <span slot="bib.fullscreen.fromLabel">Start</span>
211
+ <span slot="bib.fullscreen.toLabel">End</span>
212
+ </auro-datepicker>
213
+ </div>
214
+ <div class="submitBlock">
215
+ <auro-button type="reset">Reset</auro-button>
216
+ <auro-button type="submit">Submit</auro-button>
217
+ </div>
218
+ </auro-form>
219
+ <!-- AURO-GENERATED-CONTENT:END -->
220
+ </div>
221
+ <auro-accordion alignRight>
222
+ <span slot="trigger">See code</span>
223
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/complex.html) -->
224
+ <!-- The below code snippet is automatically added from ./../apiExamples/complex.html -->
225
+ <pre class="language-html"><code class="language-html">&lt;style&gt;
226
+ .submitBlock {
227
+ margin-top: 1rem;
228
+ display: flex;
229
+ justify-content: flex-end;
230
+ gap: 1rem;
231
+ }
232
+ .datepickerBlock {
233
+ margin-top: 1rem;
234
+ }
235
+ .complex-form {
236
+ display: block;
237
+ padding: 1rem;
238
+ border: 1px solid #2a2a2a;
239
+ border-radius: 1rem;
240
+ }
241
+ &lt;/style&gt;
242
+ &lt;auro-form class="complex-form"&gt;
243
+ &lt;auro-input id="first-name" name="firstName" required&gt;
244
+ &lt;span slot="label"&gt;First Name&lt;/span&gt;
245
+ &lt;/auro-input&gt;
246
+ &lt;br /&gt;
247
+ &lt;auro-input id="last-name" name="lastName" required&gt;
248
+ &lt;span slot="label"&gt;Last Name&lt;/span&gt;
249
+ &lt;/auro-input&gt;
250
+ &lt;br /&gt;
251
+ &lt;auro-input id="occupation" name="occupation" required&gt;
252
+ &lt;span slot="label"&gt;Occupation&lt;/span&gt;
253
+ &lt;/auro-input&gt;
254
+ &lt;br /&gt;
255
+ &lt;auro-input-two id="cool-fact" name="coolFact" required&gt;
256
+ &lt;span slot="label"&gt;Cool Fact&lt;/span&gt;
257
+ &lt;/auro-input-two&gt;
258
+ &lt;div class="datepickerBlock"&gt;
259
+ &lt;h4&gt;Pick a cool date&lt;/h4&gt;
260
+ &lt;auro-datepicker id="date-example" name="dateExample" required&gt;
261
+ &lt;span slot="fromLabel"&gt;Choose a date&lt;/span&gt;
262
+ &lt;span slot="bib.fullscreen.fromLabel"&gt;Choose a date&lt;/span&gt;
263
+ &lt;/auro-datepicker&gt;
264
+ &lt;/div&gt;
265
+ &lt;div class="datepickerBlock"&gt;
266
+ &lt;h4&gt;Pick a date range&lt;/h4&gt;
267
+ &lt;auro-datepicker id="date-range" name="dateRange" required range&gt;
268
+ &lt;span slot="fromLabel"&gt;Start&lt;/span&gt;
269
+ &lt;span slot="toLabel"&gt;End&lt;/span&gt;
270
+ &lt;span slot="bib.fullscreen.fromLabel"&gt;Start&lt;/span&gt;
271
+ &lt;span slot="bib.fullscreen.toLabel"&gt;End&lt;/span&gt;
272
+ &lt;/auro-datepicker&gt;
273
+ &lt;/div&gt;
274
+ &lt;div class="submitBlock"&gt;
275
+ &lt;auro-button type="reset"&gt;Reset&lt;/auro-button&gt;
276
+ &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
277
+ &lt;/div&gt;
278
+ &lt;/auro-form&gt;</code></pre>
279
+ <!-- AURO-GENERATED-CONTENT:END -->
280
+ </auro-accordion>
281
+ </section>
282
+ <section>
283
+ <auro-header level="2" id="functions">Functions</auro-header>
284
+ <auro-header level="3" id="fnSubmit">submit()</auro-header>
285
+ <p>Validates all form elements. If all are valid, fires a <code>submit</code> event with <code>detail.value</code> containing the current form values. If any element is invalid, its error state is surfaced and the <code>submit</code> event is not fired.</p>
286
+ <auro-header level="3" id="fnReset">reset()</auro-header>
287
+ <p>Resets all form elements to their initial state and fires a <code>reset</code> event. The event's <code>detail.previousValue</code> contains the form values captured immediately before the reset.</p>
288
+ </section>
289
+ </div>
290
+ </div>
291
+ </div>
@@ -18,8 +18,8 @@
18
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
19
19
  <title>Auro Web Component Demo | auro-form</title>
20
20
 
21
- <!-- Prism.js Stylesheet -->
22
- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/prismjs@1.24.1/themes/prism.css"/>
21
+ <!-- highlight.js Stylesheet -->
22
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github.min.css"/>
23
23
 
24
24
  <!-- Legacy reference is still needed to support auro-form's use of legacy token values at this time -->
25
25
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/legacy/auro-classic/CSSCustomProperties.css"/>
@@ -32,25 +32,23 @@
32
32
 
33
33
  <!-- Demo Specific Styles -->
34
34
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/demoWrapper.css" />
35
- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/elementDemoStyles.css" />
36
- </head>
35
+ <link rel="stylesheet" type="text/css" href="./styles.css" />
36
+ </head>
37
37
  <body class="auro-markdown">
38
38
  <main></main>
39
39
 
40
40
  <script type="module">
41
- import 'https://cdn.jsdelivr.net/npm/marked@latest/marked.min.js';
42
- import 'https://cdn.jsdelivr.net/npm/prismjs@latest/prism.js';
43
- fetch('./index.md')
44
- .then((response) => response.text())
45
- .then((text) => {
46
- const rawHtml = marked.parse(text);
47
- document.querySelector('main').innerHTML = rawHtml;
48
- Prism.highlightAll();
49
- });
41
+ import { renderPage } from './demo-support.js';
42
+ await renderPage('./index.md');
50
43
  </script>
51
- <script type="module" data-demo-script="true" src="./index.min.js"></script>
52
44
 
53
45
  <!-- If additional elements are needed for the demo, add them here. -->
54
46
  <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
47
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-nav@latest/+esm" type="module"></script>
48
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-header@latest/+esm" type="module"></script>
49
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/+esm" type="module"></script>
50
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-button@latest/+esm" type="module"></script>
51
+
52
+ <script src="./index.min.js" data-demo-script="true" type="module"></script>
55
53
  </body>
56
54
  </html>
@@ -1,99 +1,66 @@
1
- <!--
2
- The index.md file is a compiled document. No edits should be made directly to this file.
3
-
4
- index.md is created by running `npm run build:markdownDocs`.
5
-
6
- This file is generated based on a template fetched from `./docs/partials/index.md`
7
- -->
8
-
9
- # Form
10
-
1
+ <auro-header level="1" id="overview">Form</auro-header>
2
+ <div class="contentWrapper">
3
+ <nav>
4
+ <auro-nav anchorNavContent=".scrollWrapper">
5
+ <span slot="mobileToggleCollapsed">View More</span>
6
+ <span slot="mobileToggleExpanded">View Less</span>
7
+ <auro-anchorlink fluid href="#description">Description</auro-anchorlink>
8
+ <auro-anchorlink fluid href="#formValueGeneration">Form Value Generation</auro-anchorlink>
9
+ <auro-anchorlink fluid href="#formDataStructure" class="level2 body-xs">Form Data Structure</auro-anchorlink>
10
+ <auro-anchorlink fluid href="#accessingFormData">Accessing Form Data</auro-anchorlink>
11
+ <auro-anchorlink fluid href="#basicExample">Basic Form Example</auro-anchorlink>
12
+ </auro-nav>
13
+ </nav>
14
+ <div class="mainContent">
15
+ <div class="scrollWrapper">
16
+ <section>
17
+ <auro-header level="2" id="description">Description</auro-header>
11
18
  <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/partials/description.md) -->
12
19
  <!-- The below content is automatically added from ./../docs/partials/description.md -->
13
- `<auro-form>` is a [HTML custom element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) designed to
14
- serve as the base logic for all auro-constructed forms.
15
-
20
+ <code>&lt;auro-form&gt;</code> is a <auro-hyperlink href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements" target="_blank">HTML custom element</auro-hyperlink> designed to
21
+ serve as the base logic for all auro-constructed forms.
22
+
16
23
  It automatically "scrapes" its inner content for any auro form elements, and surfaces
17
24
  them (along with events) to the parent form element as a JSON object.
18
- <!-- AURO-GENERATED-CONTENT:END -->
19
-
20
- ## Form Value Generation
21
-
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.
26
-
27
- The following is required on each Auro form element in a form for it to be collected automatically:
28
-
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.
31
-
32
- That being said, we do _not_ require form elements to be direct children of `auro-form`.
33
- They can be nested within other elements for styling, such as a `div`, `span` or `fieldset`.
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
- <pre class="language-json"><code class="language-json">{
45
- "hotelCity": "New York",
46
- "dates": ["2022-01-01", "2022-01-15"],
47
- "numberOfGuests": 2
48
- }</code></pre>
49
-
50
- If your project uses TypeScript, consider using a type like this to represent the form data:
51
-
52
- <pre class="language-typescript"><code class="language-typescript">// Generic type for form values
53
- type AuroFormValue&lt;T&gt; = T | null;
54
-
55
- // Example types
56
- type AuroInputValue = AuroFormValue&lt;string | number&gt;;
57
- type AuroDatePickerValue = AuroFormValue&lt;string[]&gt;;
58
-
59
- // This is the type returned from the `AuroForm.value` getter
60
- interface AuroFormState {
61
- // value varies based on form element
62
- hotelCity: AuroInputValue;
63
- dates: AuroDatePickerValue;
64
- numberOfGuests: AuroInputValue;
65
- }</code></pre>
66
-
67
- ## Accessing Form Data
68
-
69
- As Auro components are designed to be framework-agnostic, data can be retrieved using simple vanilla JavaScript patterns.
70
- If you have ever worked with a standard HTML5 form, you are already equipped to work with Auro forms!
71
-
72
- Once you have a reference to the form element (React ref, querySelector, etc.),
73
- you can access the form data using the following methods:
74
-
75
- **Data Keys + Get Methods**:
76
- - `.value` - Getter which returns the current form data as a JSON object.
77
- - `.validity` - Returns the current validity state of the form (`valid` or `invalid`).
78
-
79
- **Extra Information**:
80
- - `.isInitialState` - Returns a boolean indicating if the form is in its initial state.
81
-
82
- **Events**
83
- - `input` - Fires when the form state changes.
84
- - `reset` - Fires when the form is reset.
85
- - `submit` - Fires when the form is submitted.
86
-
87
- **Advanced Features**:
88
- - `.formState` - This is the internal form state. It includes extra `required` and `validity` information for each form element.
89
- This key is not required for normal form usage, but can add additional context for more complex forms.
90
-
91
- ### Basic Form Example
92
-
93
- The most basic form implementation requires an `auro-input` and an optional auro button with `type="submit"`.
94
-
95
- By default, Auro Form connects a `submit` event to all `type="submit"` buttons within the form.
96
-
25
+ <!-- AURO-GENERATED-CONTENT:END -->
26
+ </section>
27
+ <section>
28
+ <auro-header level="2" id="formValueGeneration">Form Value Generation</auro-header>
29
+ <p>Auro form exists to make a developer's life easier through surfacing all Auro form elements in a given form as a single JSON object. The most common use case the Auro team identified when building Form was the need to collect form data in a structured way.</p>
30
+ <p>The following is required on each Auro form element in a form for it to be collected automatically:</p>
31
+ <ol>
32
+ <li>It <strong>must</strong> have a <code>name</code> attribute. This is required in vanilla HTML forms, and we follow the same pattern.</li>
33
+ <li>It <strong>must</strong> be an Auro form element. See the section on custom elements for more information.</li>
34
+ </ol>
35
+ <p>That being said, we do <em>not</em> require form elements to be direct children of <code>auro-form</code>. They can be nested within other elements for styling, such as a <code>div</code>, <code>span</code> or <code>fieldset</code>.</p>
36
+ <auro-header level="3" id="formDataStructure">Form Data Structure</auro-header>
37
+ <p>In a correctly registered scenario, <code>auro-form</code> will automatically recognize the auro form elements and collect data from each on the form's <code>value</code> key as a JSON object.</p>
38
+ <p>Each element will be added using the element's <code>name</code> attribute as the key, and the element's <code>value</code> as the value.</p>
39
+ </section>
40
+ <section>
41
+ <auro-header level="2" id="accessingFormData">Accessing Form Data</auro-header>
42
+ <p>As Auro components are designed to be framework-agnostic, data can be retrieved using simple vanilla JavaScript patterns. If you have ever worked with a standard HTML5 form, you are already equipped to work with Auro forms!</p>
43
+ <p>Once you have a reference to the form element (React ref, querySelector, etc.), you can access the form data using the following methods:</p>
44
+ <p><strong>Data Keys + Get Methods</strong>:</p>
45
+ <ul>
46
+ <li><code>.value</code> - Getter which returns the current form data as a JSON object.</li>
47
+ <li><code>.validity</code> - Returns the current validity state of the form (<code>valid</code> or <code>invalid</code>).</li>
48
+ </ul>
49
+ <p><strong>Extra Information</strong>:</p>
50
+ <ul>
51
+ <li><code>.isInitialState</code> - Returns a boolean indicating if the form is in its initial state.</li>
52
+ </ul>
53
+ <p><strong>Events</strong>:</p>
54
+ <ul>
55
+ <li><code>input</code> - Fires when the form state changes.</li>
56
+ <li><code>reset</code> - Fires when the form is reset.</li>
57
+ <li><code>submit</code> - Fires when the form is submitted.</li>
58
+ </ul>
59
+ </section>
60
+ <section>
61
+ <auro-header level="2" id="basicExample">Basic Form Example</auro-header>
62
+ <p>The most basic form implementation requires an <code>auro-input</code> and an optional auro button with <code>type="submit"</code>.</p>
63
+ <p>By default, Auro Form connects a <code>submit</code> event to all <code>type="submit"</code> buttons within the form.</p>
97
64
  <div class="exampleWrapper">
98
65
  <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic.html) -->
99
66
  <!-- The below content is automatically added from ./../apiExamples/basic.html -->
@@ -105,18 +72,21 @@ By default, Auro Form connects a `submit` event to all `type="submit"` buttons w
105
72
  <auro-button type="submit">Submit</auro-button>
106
73
  </auro-form>
107
74
  <!-- AURO-GENERATED-CONTENT:END -->
108
- </div>
75
+ </div>
109
76
  <auro-accordion alignRight>
110
77
  <span slot="trigger">See code</span>
111
78
  <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/basic.html) -->
112
- <!-- The below code snippet is automatically added from ./../apiExamples/basic.html -->
113
-
79
+ <!-- The below code snippet is automatically added from ./../apiExamples/basic.html -->
114
80
  <pre class="language-html"><code class="language-html">&lt;auro-form&gt;
115
81
  &lt;auro-input id="search-box" name="searchBox" required&gt;
116
82
  &lt;span slot="label"&gt;Search flights&lt;/span&gt;
117
83
  &lt;/auro-input&gt;
118
84
  &lt;br /&gt;
119
85
  &lt;auro-button type="submit"&gt;Submit&lt;/auro-button&gt;
120
- &lt;/auro-form&gt;</code></pre>
86
+ &lt;/auro-form&gt;</code></pre>
121
87
  <!-- AURO-GENERATED-CONTENT:END -->
122
88
  </auro-accordion>
89
+ </section>
90
+ </div>
91
+ </div>
92
+ </div>