@aurodesignsystem-dev/auro-formkit 0.0.0-pr1422.0 → 0.0.0-pr1422.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.
- package/components/bibtemplate/dist/auro-bibtemplate.d.ts +66 -0
- package/components/bibtemplate/dist/buttonVersion.d.ts +2 -0
- package/components/bibtemplate/dist/headerVersion.d.ts +2 -0
- package/components/bibtemplate/dist/iconVersion.d.ts +2 -0
- package/components/bibtemplate/dist/index.d.ts +2 -0
- package/components/bibtemplate/dist/index.js +395 -0
- package/components/bibtemplate/dist/registered.js +395 -0
- package/components/bibtemplate/dist/styles/color-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/style-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/tokens-css.d.ts +2 -0
- package/components/checkbox/demo/api.md +489 -0
- package/components/checkbox/demo/api.min.js +2133 -0
- package/components/checkbox/demo/index.md +55 -0
- package/components/checkbox/demo/index.min.js +2108 -0
- package/components/checkbox/demo/keyboardBehavior.md +0 -0
- package/components/checkbox/demo/readme.md +142 -0
- package/components/checkbox/dist/auro-checkbox-group.d.ts +176 -0
- package/components/checkbox/dist/auro-checkbox.d.ts +209 -0
- package/components/checkbox/dist/index.d.ts +3 -0
- package/components/checkbox/dist/index.js +2057 -0
- package/components/checkbox/dist/registered.js +2058 -0
- package/components/checkbox/dist/styles/auro-checkbox-css.d.ts +2 -0
- package/components/checkbox/dist/styles/auro-checkbox-group-css.d.ts +2 -0
- package/components/checkbox/dist/styles/color-css.d.ts +2 -0
- package/components/checkbox/dist/styles/colorGroup-css.d.ts +2 -0
- package/components/checkbox/dist/styles/tokens-css.d.ts +2 -0
- package/components/combobox/demo/api.md +2287 -0
- package/components/combobox/demo/api.min.js +18025 -0
- package/components/combobox/demo/index.md +196 -0
- package/components/combobox/demo/index.min.js +17930 -0
- package/components/combobox/demo/keyboardBehavior.md +281 -0
- package/components/combobox/demo/readme.md +158 -0
- package/components/combobox/dist/auro-combobox.d.ts +578 -0
- package/components/combobox/dist/comboboxKeyboardStrategy.d.ts +9 -0
- package/components/combobox/dist/index.d.ts +2 -0
- package/components/combobox/dist/index.js +15845 -0
- package/components/combobox/dist/registered.js +15847 -0
- package/components/combobox/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/combobox/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/combobox/dist/styles/style-css.d.ts +2 -0
- package/components/counter/demo/api.md +1285 -0
- package/components/counter/demo/api.min.js +8237 -0
- package/components/counter/demo/index.md +92 -0
- package/components/counter/demo/index.min.js +8218 -0
- package/components/counter/demo/keyboardBehavior.md +127 -0
- package/components/counter/demo/readme.md +161 -0
- package/components/counter/dist/auro-counter-button.d.ts +14 -0
- package/components/counter/dist/auro-counter-group.d.ts +390 -0
- package/components/counter/dist/auro-counter-wrapper.d.ts +17 -0
- package/components/counter/dist/auro-counter.d.ts +136 -0
- package/components/counter/dist/buttonVersion.d.ts +2 -0
- package/components/counter/dist/iconVersion.d.ts +2 -0
- package/components/counter/dist/index.d.ts +3 -0
- package/components/counter/dist/index.js +8140 -0
- package/components/counter/dist/keyboardStrategy.d.ts +4 -0
- package/components/counter/dist/registered.js +8141 -0
- package/components/counter/dist/styles/color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-group-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-css.d.ts +2 -0
- package/components/counter/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/counter/dist/styles/style-css.d.ts +2 -0
- package/components/counter/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/demo/api.md +1824 -0
- package/components/datepicker/demo/api.min.js +24654 -0
- package/components/datepicker/demo/index.md +158 -0
- package/components/datepicker/demo/index.min.js +24375 -0
- package/components/datepicker/demo/keyboardBehavior.md +19 -0
- package/components/datepicker/demo/readme.md +137 -0
- package/components/datepicker/dist/auro-calendar-cell.d.ts +169 -0
- package/components/datepicker/dist/auro-calendar-month.d.ts +20 -0
- package/components/datepicker/dist/auro-calendar.d.ts +173 -0
- package/components/datepicker/dist/auro-datepicker.d.ts +716 -0
- package/components/datepicker/dist/buttonVersion.d.ts +2 -0
- package/components/datepicker/dist/datepickerKeyboardStrategy.d.ts +1 -0
- package/components/datepicker/dist/iconVersion.d.ts +2 -0
- package/components/datepicker/dist/index.d.ts +2 -0
- package/components/datepicker/dist/index.js +24290 -0
- package/components/datepicker/dist/popoverVersion.d.ts +2 -0
- package/components/datepicker/dist/registered.js +24290 -0
- package/components/datepicker/dist/styles/classic/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/classic/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/datepicker/dist/styles/snowflake/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/dist/utilities.d.ts +78 -0
- package/components/datepicker/dist/utilitiesCalendar.d.ts +38 -0
- package/components/datepicker/dist/utilitiesCalendarRender.d.ts +50 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/day.d.ts +5 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-calendar.d.ts +60 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-cell.d.ts +1 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker.d.ts +57 -0
- package/components/dropdown/demo/api.md +1358 -0
- package/components/dropdown/demo/api.min.js +5019 -0
- package/components/dropdown/demo/index.md +283 -0
- package/components/dropdown/demo/index.min.js +4954 -0
- package/components/dropdown/demo/keyboardBehavior.md +77 -0
- package/components/dropdown/demo/readme.md +160 -0
- package/components/dropdown/dist/auro-dropdown.d.ts +482 -0
- package/components/dropdown/dist/auro-dropdownBib.d.ts +128 -0
- package/components/dropdown/dist/dropdownBibKeyboardStrategy.d.ts +7 -0
- package/components/dropdown/dist/iconVersion.d.ts +2 -0
- package/components/dropdown/dist/index.d.ts +2 -0
- package/components/dropdown/dist/index.js +4847 -0
- package/components/dropdown/dist/registered.js +4847 -0
- package/components/dropdown/dist/styles/classic/bibColors-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/bibStyles-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/color-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/color-css.d.ts +2 -0
- package/components/dropdown/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/dropdown/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/tokens-css.d.ts +2 -0
- package/components/form/demo/api.md +319 -0
- package/components/form/demo/api.min.js +71170 -0
- package/components/form/demo/index.md +128 -0
- package/components/form/demo/index.min.js +71170 -0
- package/components/form/demo/keyboardBehavior.md +0 -0
- package/components/form/demo/readme.md +145 -0
- package/components/form/dist/auro-form.d.ts +280 -0
- package/components/form/dist/index.d.ts +2 -0
- package/components/form/dist/index.js +718 -0
- package/components/form/dist/registered.d.ts +1 -0
- package/components/form/dist/registered.js +718 -0
- package/components/form/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/auro-helptext.d.ts +69 -0
- package/components/helptext/dist/index.d.ts +2 -0
- package/components/helptext/dist/index.js +231 -0
- package/components/helptext/dist/registered.js +231 -0
- package/components/helptext/dist/styles/color-css.d.ts +2 -0
- package/components/helptext/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/demo/api.md +1397 -0
- package/components/input/demo/api.min.js +7473 -0
- package/components/input/demo/index.md +161 -0
- package/components/input/demo/index.min.js +7393 -0
- package/components/input/demo/keyboardBehavior.md +0 -0
- package/components/input/demo/readme.md +134 -0
- package/components/input/dist/auro-input.d.ts +207 -0
- package/components/input/dist/base-input.d.ts +628 -0
- package/components/input/dist/buttonVersion.d.ts +2 -0
- package/components/input/dist/i18n.d.ts +18 -0
- package/components/input/dist/iconVersion.d.ts +2 -0
- package/components/input/dist/index.d.ts +2 -0
- package/components/input/dist/index.js +7305 -0
- package/components/input/dist/registered.js +7305 -0
- package/components/input/dist/styles/classic/color-css.d.ts +2 -0
- package/components/input/dist/styles/classic/style-css.d.ts +2 -0
- package/components/input/dist/styles/color-css.d.ts +2 -0
- package/components/input/dist/styles/default/borders-css.d.ts +2 -0
- package/components/input/dist/styles/default/color-css.d.ts +2 -0
- package/components/input/dist/styles/default/mixins-css.d.ts +2 -0
- package/components/input/dist/styles/default/notificationIcons-css.d.ts +2 -0
- package/components/input/dist/styles/default/style-css.d.ts +2 -0
- package/components/input/dist/styles/emphasized/color-css.d.ts +2 -0
- package/components/input/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/input/dist/styles/mixins-css.d.ts +2 -0
- package/components/input/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/input/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/input/dist/styles/style-css.d.ts +2 -0
- package/components/input/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/dist/utilities.d.ts +25 -0
- package/components/layoutElement/dist/auroElement.d.ts +40 -0
- package/components/layoutElement/dist/index.d.ts +2 -0
- package/components/layoutElement/dist/index.js +107 -0
- package/components/layoutElement/dist/registered.js +107 -0
- package/components/menu/demo/api.md +1201 -0
- package/components/menu/demo/api.min.js +2397 -0
- package/components/menu/demo/index.md +72 -0
- package/components/menu/demo/index.min.js +2290 -0
- package/components/menu/demo/keyboardBehavior.md +0 -0
- package/components/menu/demo/readme.md +145 -0
- package/components/menu/dist/auro-menu-utils.d.ts +34 -0
- package/components/menu/dist/auro-menu.context.d.ts +239 -0
- package/components/menu/dist/auro-menu.d.ts +317 -0
- package/components/menu/dist/auro-menuoption.d.ts +210 -0
- package/components/menu/dist/iconVersion.d.ts +2 -0
- package/components/menu/dist/index.d.ts +4 -0
- package/components/menu/dist/index.js +2253 -0
- package/components/menu/dist/registered.js +2201 -0
- package/components/menu/dist/styles/default/color-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/default/color-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/default/style-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/default/style-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/default/tokens-css.d.ts +2 -0
- package/components/radio/demo/api.md +675 -0
- package/components/radio/demo/api.min.js +2210 -0
- package/components/radio/demo/index.md +73 -0
- package/components/radio/demo/index.min.js +2167 -0
- package/components/radio/demo/keyboardBehavior.md +0 -0
- package/components/radio/demo/readme.md +141 -0
- package/components/radio/dist/auro-radio-group.d.ts +250 -0
- package/components/radio/dist/auro-radio.d.ts +180 -0
- package/components/radio/dist/index.d.ts +3 -0
- package/components/radio/dist/index.js +2116 -0
- package/components/radio/dist/registered.js +2117 -0
- package/components/radio/dist/styles/auro-radio-group-css.d.ts +2 -0
- package/components/radio/dist/styles/color-css.d.ts +2 -0
- package/components/radio/dist/styles/groupColor-css.d.ts +2 -0
- package/components/radio/dist/styles/style-css.d.ts +2 -0
- package/components/radio/dist/styles/tokens-css.d.ts +2 -0
- package/components/select/demo/api.md +2378 -0
- package/components/select/demo/api.min.js +10542 -0
- package/components/select/demo/index.md +355 -0
- package/components/select/demo/index.min.js +10449 -0
- package/components/select/demo/keyboardBehavior.md +245 -0
- package/components/select/demo/readme.md +148 -0
- package/components/select/dist/auro-select.d.ts +553 -0
- package/components/select/dist/index.d.ts +2 -0
- package/components/select/dist/index.js +8376 -0
- package/components/select/dist/registered.js +8376 -0
- package/components/select/dist/selectKeyboardStrategy.d.ts +11 -0
- package/components/select/dist/styles/emphasized/color-css.d.ts +2 -0
- package/components/select/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/select/dist/styles/style-css.d.ts +2 -0
- package/components/select/dist/styles/tokens-css.d.ts +2 -0
- package/custom-elements.json +18806 -0
- package/package.json +2 -2
|
File without changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The README.md file is a compiled document. No edits should be made directly to this file.
|
|
3
|
+
|
|
4
|
+
README.md is created by running `npm run build:docs`.
|
|
5
|
+
|
|
6
|
+
This file is generated based on a template fetched from
|
|
7
|
+
`../../docs/templates/componentReadmeTemplate.md`
|
|
8
|
+
and copied to `./componentDocs/README.md` each time the docs are compiled.
|
|
9
|
+
|
|
10
|
+
The following sections are editable by making changes to the following files:
|
|
11
|
+
|
|
12
|
+
| SECTION | DESCRIPTION | FILE LOCATION |
|
|
13
|
+
|------------------------|---------------------------------------------------|-------------------------------------|
|
|
14
|
+
| Description | Description of the component | `./docs/partials/description.md` |
|
|
15
|
+
| Use Cases | Examples for when to use this component | `./docs/partials/useCases.md` |
|
|
16
|
+
| Additional Information | For use to add any component specific information | `./docs/partials/readmeAddlInfo.md` |
|
|
17
|
+
| Component Example Code | HTML sample code of the components use | `./apiExamples/basic.html` |
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
# Form
|
|
21
|
+
|
|
22
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/description.md) -->
|
|
23
|
+
<!-- The below content is automatically added from ./docs/partials/description.md -->
|
|
24
|
+
`<auro-form>` is a [HTML custom element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) designed to
|
|
25
|
+
serve as the base logic for all auro-constructed forms.
|
|
26
|
+
|
|
27
|
+
It automatically "scrapes" its inner content for any auro form elements, and surfaces
|
|
28
|
+
them (along with events) to the parent form element as a JSON object.
|
|
29
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
30
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/readmeAddlInfo.md) -->
|
|
31
|
+
<!-- The below content is automatically added from ./docs/partials/readmeAddlInfo.md -->
|
|
32
|
+
<!-- AURO-GENERATED-CONTENT This file is to be used for any additional content that should be included in the README.md which is specific to this component. -->
|
|
33
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
34
|
+
|
|
35
|
+
## Form Use Cases
|
|
36
|
+
|
|
37
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
|
|
38
|
+
<!-- The below content is automatically added from ./docs/partials/useCases.md -->
|
|
39
|
+
The `<auro-form>` element should be used in situations where users want to build HTML forms.
|
|
40
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
41
|
+
|
|
42
|
+
## Getting Started
|
|
43
|
+
|
|
44
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../../docs/templates/componentInstall.md) -->
|
|
45
|
+
<!-- The below content is automatically added from ../../docs/templates/componentInstall.md -->
|
|
46
|
+
|
|
47
|
+
#### NPM Installation
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
$ npm i @aurodesignsystem/auro-formkit
|
|
51
|
+
```
|
|
52
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
53
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../../docs/templates/gettingStarted.md) -->
|
|
54
|
+
<!-- The below content is automatically added from ../../docs/templates/gettingStarted.md -->
|
|
55
|
+
|
|
56
|
+
### TypeScript Module Resolution
|
|
57
|
+
|
|
58
|
+
When using TypeScript set `moduleResolution` to `bundler`, add the following to your `tsconfig.json`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"compilerOptions": {
|
|
63
|
+
"moduleResolution": "bundler"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This configuration enables proper module resolution for the component's TypeScript files.
|
|
69
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
70
|
+
|
|
71
|
+
## Install from CDN
|
|
72
|
+
|
|
73
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../../docs/templates/bundleInstallDescription.md) -->
|
|
74
|
+
<!-- The below content is automatically added from ../../docs/templates/bundleInstallDescription.md -->
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@latest/auro-form/+esm"></script>
|
|
79
|
+
```
|
|
80
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
81
|
+
|
|
82
|
+
## Formkit Development
|
|
83
|
+
|
|
84
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../../docs/partials/developmentDescription.md) -->
|
|
85
|
+
<!-- The below content is automatically added from ../../docs/partials/developmentDescription.md -->
|
|
86
|
+
|
|
87
|
+
### Filtering
|
|
88
|
+
|
|
89
|
+
Running the `dev` command will open a `localhost` development server for all components in the monorepo at once.
|
|
90
|
+
|
|
91
|
+
To only develop a single component, use the `--filter` flag:
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
npx turbo dev --filter=@aurodesignsystem/auro-input
|
|
95
|
+
```
|
|
96
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
97
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/customRegistration.md) -->
|
|
98
|
+
<!-- The below content is automatically added from ./docs/partials/customRegistration.md -->
|
|
99
|
+
|
|
100
|
+
## Custom Component Registration for Version Management
|
|
101
|
+
|
|
102
|
+
There are two key parts to every Auro component: the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> 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.
|
|
103
|
+
|
|
104
|
+
When you install the component as described on the `Install` page, the class is imported automatically, and the component is registered globally for you.
|
|
105
|
+
|
|
106
|
+
However, if you need to load multiple versions of the same component on a single page (for example, when two projects depend on different versions), you can manually register the class under a custom element name to avoid conflicts.
|
|
107
|
+
|
|
108
|
+
You can do this by importing only the component class and using the `register(name)` method with a unique name:
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
// Import the class only
|
|
112
|
+
import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
|
|
113
|
+
|
|
114
|
+
// Register with a custom name if desired
|
|
115
|
+
AuroForm.register('custom-form');
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
### Using Custom-Named Child Form Elements
|
|
121
|
+
|
|
122
|
+
When consuming custom-named Auro form elements (like `auro-input` registered as `my-custom-input`),
|
|
123
|
+
these elements _must_ be registered BEFORE auro-form due to rendering order limitations.
|
|
124
|
+
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.
|
|
125
|
+
|
|
126
|
+
For example, the following is correct:
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
import { AuroInput } from '@aurodesignsystem/auro-formkit/auro-input/class';
|
|
130
|
+
import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
|
|
131
|
+
|
|
132
|
+
AuroInput.register('my-custom-input'); // adds an internal identifier auro-form uses to recognize the custom element
|
|
133
|
+
AuroForm.register(); // render looks for said identifier
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The following is NOT correct and will result in forms not working as expected:
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
import { AuroInput } from '@aurodesignsystem/auro-formkit/auro-input/class';
|
|
140
|
+
import { AuroForm } from '@aurodesignsystem/auro-formkit/auro-form/class';
|
|
141
|
+
|
|
142
|
+
AuroForm.register(); // forms start rendering, looking for auro inputs, or custom-named inputs
|
|
143
|
+
AuroInput.register('my-custom-input'); // too late, form has already rendered and did not find the custom element
|
|
144
|
+
```
|
|
145
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} FormStateMember - The form state member.
|
|
3
|
+
* @property {string | number | boolean | string[] | null} value - The value of the form element.
|
|
4
|
+
* @property {ValidityState} validity - The validity state of the form element, stored when fired from the form element.
|
|
5
|
+
* @property {boolean} required - Whether the form element is required or not.
|
|
6
|
+
* @property {HTMLElement} element - Whether the form element is required or not.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object.<string, FormStateMember>} FormState - The form state.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The `auro-form` element provides users a way to create and manage forms in a consistent manner.
|
|
13
|
+
* @customElement auro-form
|
|
14
|
+
*
|
|
15
|
+
* @slot default - The default slot for form elements.
|
|
16
|
+
*
|
|
17
|
+
* @event input - Fires when a child form element receives user input.
|
|
18
|
+
* @event change - Fires when a child form element's value changes or the form is initialized.
|
|
19
|
+
* @event reset - Fires when the form is reset. The event detail contains the previous value of the form before reset.
|
|
20
|
+
* @event submit - Fires when the form is submitted. The event detail contains the current value of the form.
|
|
21
|
+
*/
|
|
22
|
+
export class AuroForm extends LitElement {
|
|
23
|
+
static get properties(): {
|
|
24
|
+
/** @private */
|
|
25
|
+
formState: {
|
|
26
|
+
type: ObjectConstructor;
|
|
27
|
+
attribute: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** @private */
|
|
30
|
+
_validity: {
|
|
31
|
+
type: ObjectConstructor;
|
|
32
|
+
attribute: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** @private */
|
|
35
|
+
_isInitialState: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
attribute: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** @private */
|
|
40
|
+
_elements: {
|
|
41
|
+
type: ArrayConstructor;
|
|
42
|
+
attribute: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** @private */
|
|
45
|
+
_submitElements: {
|
|
46
|
+
type: ArrayConstructor;
|
|
47
|
+
attribute: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** @private */
|
|
50
|
+
_resetElements: {
|
|
51
|
+
type: ArrayConstructor;
|
|
52
|
+
attribute: boolean;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
static get formElementTags(): string[];
|
|
56
|
+
static get buttonElementTags(): string[];
|
|
57
|
+
static get styles(): import("lit").CSSResult[];
|
|
58
|
+
/**
|
|
59
|
+
* Registers the `auro-form` custom element with the browser under a given tag name.
|
|
60
|
+
* @param {string} [name="auro-form"] - The custom element tag name to register.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* AuroForm.register("custom-form") // registers as <custom-form>
|
|
64
|
+
*/
|
|
65
|
+
static register(name?: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* @type {FormState}
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
private formState;
|
|
71
|
+
/**
|
|
72
|
+
* @type {"valid" | "invalid" | null}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private _validity;
|
|
76
|
+
/** @private */
|
|
77
|
+
private _isInitialState;
|
|
78
|
+
/**
|
|
79
|
+
* @type {(HTMLElement & {reset: () => void})[]}
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
private _elements;
|
|
83
|
+
/**
|
|
84
|
+
* @type {HTMLButtonElement[]}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private _submitElements;
|
|
88
|
+
/**
|
|
89
|
+
* @type {HTMLButtonElement[]}
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
private _resetElements;
|
|
93
|
+
/**
|
|
94
|
+
* @private
|
|
95
|
+
* @type {MutationObserver[]}
|
|
96
|
+
*/
|
|
97
|
+
private mutationObservers;
|
|
98
|
+
/**
|
|
99
|
+
* Resets all form elements to their initial state and fires a `reset` event. The event's `detail.previousValue` contains the form values captured immediately before the reset.
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
102
|
+
reset(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Validates all form elements. If all are valid, fires a `submit` event with `detail.value` containing the current form values. If any element is invalid, its error state is surfaced and the `submit` event is not fired.
|
|
105
|
+
* @returns {Promise<void>}
|
|
106
|
+
*/
|
|
107
|
+
submit(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Shared input listener for all form elements.
|
|
110
|
+
* @param {Event} event - The event that is fired from the form element.
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
private sharedInputListener;
|
|
114
|
+
/**
|
|
115
|
+
* Shared validation listener for all form elements.
|
|
116
|
+
* @param {Event} event - The event that is fired from the form element.
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
private sharedValidationListener;
|
|
120
|
+
/**
|
|
121
|
+
* Mutation observer for form elements. Slot change does not trigger unless
|
|
122
|
+
* root-level elements are added/removed. This is a workaround to ensure
|
|
123
|
+
* nested form elements are also observed.
|
|
124
|
+
*
|
|
125
|
+
* @returns {void}
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
private mutationEventListener;
|
|
129
|
+
/**
|
|
130
|
+
* Handle Enter key press on form elements.
|
|
131
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
private handleKeyDown;
|
|
135
|
+
/**
|
|
136
|
+
* Compare tag name with element to identify it (for API purposes).
|
|
137
|
+
* @param {string} elementTag - The HTML tag name like `auro-datepicker`.
|
|
138
|
+
* @param {HTMLElement} element - The actual HTML element to compare.
|
|
139
|
+
* @returns {boolean}
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
private _isElementTag;
|
|
143
|
+
/**
|
|
144
|
+
* Shared code for determining if an element is something we care about (submit, form element, etc.).
|
|
145
|
+
* @param {string[]} collection - The array to use for tag name search.
|
|
146
|
+
* @param {HTMLElement} element - The element to compare against the master list.
|
|
147
|
+
* @returns {boolean}
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
private _isInElementCollection;
|
|
151
|
+
/**
|
|
152
|
+
* Check if the tag name is a form element.
|
|
153
|
+
* @param {HTMLElement} element - The element to check (attr or tag name).
|
|
154
|
+
* @returns {boolean}
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
private isFormElement;
|
|
158
|
+
/**
|
|
159
|
+
* Validates if an event is from a valid form element with a name.
|
|
160
|
+
* @param {Event} event - The event to validate.
|
|
161
|
+
* @returns {boolean} - True if event is valid for processing.
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
private _eventIsValidFormEvent;
|
|
165
|
+
/**
|
|
166
|
+
* Check if the tag name is a button element.
|
|
167
|
+
* @param {HTMLElement} element - The element to check.
|
|
168
|
+
* @returns {boolean}
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
private isButtonElement;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the current values of all named form elements as a key-value object, keyed by each element's `name` attribute.
|
|
174
|
+
* @returns {Record<string, string | number | boolean | string[] | null>} The current form values.
|
|
175
|
+
*/
|
|
176
|
+
get value(): Record<string, string | number | boolean | string[] | null>;
|
|
177
|
+
/**
|
|
178
|
+
* Getter for internal _submitElements.
|
|
179
|
+
* @returns {HTMLButtonElement[]}
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
private get submitElements();
|
|
183
|
+
/**
|
|
184
|
+
* Returns a collection of elements that will reset the form.
|
|
185
|
+
* @returns {HTMLButtonElement[]}
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
188
|
+
private get resetElements();
|
|
189
|
+
/**
|
|
190
|
+
* Infer validity status based on current formState.
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
193
|
+
private _calculateValidity;
|
|
194
|
+
/**
|
|
195
|
+
* Returns `'valid'` if all required and interacted-with form elements are valid, `'invalid'` if any are not, or `null` if the form has not been interacted with yet.
|
|
196
|
+
* @returns {"valid" | "invalid" | null}
|
|
197
|
+
*/
|
|
198
|
+
get validity(): "valid" | "invalid" | null;
|
|
199
|
+
/**
|
|
200
|
+
* Determines whether the form is in its initial (untouched) state and updates `_isInitialState` accordingly.
|
|
201
|
+
* @returns {void}
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
private _setInitialState;
|
|
205
|
+
/**
|
|
206
|
+
* Returns `true` if no form element has been interacted with or had its value changed since the form was initialized or last reset.
|
|
207
|
+
* @returns {boolean}
|
|
208
|
+
*/
|
|
209
|
+
get isInitialState(): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Enables or disables submit and reset buttons based on the current form state and validity.
|
|
212
|
+
* @returns {void}
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
private setDisabledStateOnButtons;
|
|
216
|
+
/**
|
|
217
|
+
* Construct the query strings from elements, append them together, execute, and return the NodeList.
|
|
218
|
+
* @returns {NodeList}
|
|
219
|
+
* @private
|
|
220
|
+
*/
|
|
221
|
+
private queryAuroElements;
|
|
222
|
+
/**
|
|
223
|
+
* Store an element in state and on the _elements array.
|
|
224
|
+
* @param {HTMLElement} element - The element to add to our state.
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
private _addElementToState;
|
|
228
|
+
/**
|
|
229
|
+
* Initialize (or reinitialize) the form state.
|
|
230
|
+
* @returns {void}
|
|
231
|
+
* @private
|
|
232
|
+
*/
|
|
233
|
+
private initializeState;
|
|
234
|
+
/**
|
|
235
|
+
* Attaches input, validation, and keydown listeners to all tracked form and button elements.
|
|
236
|
+
* Removes existing listeners first to avoid duplicates on re-initialization.
|
|
237
|
+
* @returns {void}
|
|
238
|
+
* @private
|
|
239
|
+
*/
|
|
240
|
+
private _attachEventListeners;
|
|
241
|
+
/**
|
|
242
|
+
* Slot change event listener. This is the main entry point for the form element.
|
|
243
|
+
* @param {Event} event - The slot change event.
|
|
244
|
+
* @returns {void}
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
private onSlotChange;
|
|
248
|
+
/**
|
|
249
|
+
* @returns {import('lit').TemplateResult}
|
|
250
|
+
*/
|
|
251
|
+
render(): import("lit").TemplateResult;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* - The form state member.
|
|
255
|
+
*/
|
|
256
|
+
export type FormStateMember = {
|
|
257
|
+
/**
|
|
258
|
+
* - The value of the form element.
|
|
259
|
+
*/
|
|
260
|
+
value: string | number | boolean | string[] | null;
|
|
261
|
+
/**
|
|
262
|
+
* - The validity state of the form element, stored when fired from the form element.
|
|
263
|
+
*/
|
|
264
|
+
validity: ValidityState;
|
|
265
|
+
/**
|
|
266
|
+
* - Whether the form element is required or not.
|
|
267
|
+
*/
|
|
268
|
+
required: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* - Whether the form element is required or not.
|
|
271
|
+
*/
|
|
272
|
+
element: HTMLElement;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* - The form state.
|
|
276
|
+
*/
|
|
277
|
+
export type FormState = {
|
|
278
|
+
[x: string]: FormStateMember;
|
|
279
|
+
};
|
|
280
|
+
import { LitElement } from "lit";
|