@aurodesignsystem/auro-formkit 2.0.0-beta.14 → 2.0.0-beta.16
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/.turbo/cache/000950e13093845f-meta.json +1 -0
- package/.turbo/cache/{d4b8a79a27266a26.tar.zst → 000950e13093845f.tar.zst} +0 -0
- package/.turbo/cache/02ee016619902665-meta.json +1 -0
- package/.turbo/cache/02ee016619902665.tar.zst +0 -0
- package/.turbo/cache/1b97859030a6d60b-meta.json +1 -0
- package/.turbo/cache/1e855b2163b7c980-meta.json +1 -0
- package/.turbo/cache/1e855b2163b7c980.tar.zst +0 -0
- package/.turbo/cache/1f6653e2ed4c0087-meta.json +1 -0
- package/.turbo/cache/1f6653e2ed4c0087.tar.zst +0 -0
- package/.turbo/cache/2059bc724ac24519-meta.json +1 -0
- package/.turbo/cache/2059bc724ac24519.tar.zst +0 -0
- package/.turbo/cache/23b3a2fea223679d-meta.json +1 -0
- package/.turbo/cache/23b3a2fea223679d.tar.zst +0 -0
- package/.turbo/cache/2c0d681132c153dd-meta.json +1 -1
- package/.turbo/cache/31bd5687f46c7eba-meta.json +1 -0
- package/.turbo/cache/3488cff10dd06acd-meta.json +1 -0
- package/.turbo/cache/{e89dfa7c665c8763.tar.zst → 3488cff10dd06acd.tar.zst} +0 -0
- package/.turbo/cache/3c8718d2ba6d3fe5-meta.json +1 -0
- package/.turbo/cache/3c8718d2ba6d3fe5.tar.zst +0 -0
- package/.turbo/cache/4006a206400d5c7b-meta.json +1 -1
- package/.turbo/cache/43693504bf6e7c4c-meta.json +1 -0
- package/.turbo/cache/45cd32cd38eacbcb-meta.json +1 -0
- package/.turbo/cache/45cd32cd38eacbcb.tar.zst +0 -0
- package/.turbo/cache/492dda333b8d15f1-meta.json +1 -1
- package/.turbo/cache/50cd7dcfc9f820c5-meta.json +1 -1
- package/.turbo/cache/51eaa58d5c167de8-meta.json +1 -1
- package/.turbo/cache/56f2745125fdd552-meta.json +1 -0
- package/.turbo/cache/{5ddbe69f2cb372c5.tar.zst → 56f2745125fdd552.tar.zst} +0 -0
- package/.turbo/cache/5f43911cbacf7df1-meta.json +1 -0
- package/.turbo/cache/{32545b759b9ce644.tar.zst → 5f43911cbacf7df1.tar.zst} +0 -0
- package/.turbo/cache/6081837e8943b62e-meta.json +1 -1
- package/.turbo/cache/60ad74320c682a2b-meta.json +1 -1
- package/.turbo/cache/61e218aba69cff58-meta.json +1 -1
- package/.turbo/cache/6951c2a52e5ab5f7-meta.json +1 -0
- package/.turbo/cache/{35b02758b1702fa7.tar.zst → 6951c2a52e5ab5f7.tar.zst} +0 -0
- package/.turbo/cache/77da375a012de9d0-meta.json +1 -1
- package/.turbo/cache/78418f9089673a21-meta.json +1 -0
- package/.turbo/cache/78418f9089673a21.tar.zst +0 -0
- package/.turbo/cache/7964d1656e9e702a-meta.json +1 -1
- package/.turbo/cache/7bf2b06a479d0b30-meta.json +1 -1
- package/.turbo/cache/7c9ca6163e61285c-meta.json +1 -1
- package/.turbo/cache/80410f4b5990ab83-meta.json +1 -0
- package/.turbo/cache/876b8fa390c8ec81-meta.json +1 -0
- package/.turbo/cache/8bb856bd31b5b479-meta.json +1 -1
- package/.turbo/cache/8f287fd5d33579ae-meta.json +1 -0
- package/.turbo/cache/{4302d0f3b7325335.tar.zst → 8f287fd5d33579ae.tar.zst} +0 -0
- package/.turbo/cache/8f5fef3e04a6fcfa-meta.json +1 -0
- package/.turbo/cache/8fcce3ba8357be57-meta.json +1 -0
- package/.turbo/cache/8fcce3ba8357be57.tar.zst +0 -0
- package/.turbo/cache/9b5868be65819fdf-meta.json +1 -0
- package/.turbo/cache/9b5868be65819fdf.tar.zst +0 -0
- package/.turbo/cache/b5e6dc7fb9ae1a2f-meta.json +1 -1
- package/.turbo/cache/b6a202cc85cb61a0-meta.json +1 -1
- package/.turbo/cache/ba270a0ef147f2e5-meta.json +1 -0
- package/.turbo/cache/be0b95293ea517cc-meta.json +1 -1
- package/.turbo/cache/c03a12ff38ba1e02-meta.json +1 -0
- package/.turbo/cache/c03a12ff38ba1e02.tar.zst +0 -0
- package/.turbo/cache/c1312c6f8c051461-meta.json +1 -0
- package/.turbo/cache/c1312c6f8c051461.tar.zst +0 -0
- package/.turbo/cache/c3b2cc1b044a4135-meta.json +1 -0
- package/.turbo/cache/c3b2cc1b044a4135.tar.zst +0 -0
- package/.turbo/cache/c6c6411199b68170-meta.json +1 -1
- package/.turbo/cache/c6dbc49c3038946d-meta.json +1 -0
- package/.turbo/cache/c6dbc49c3038946d.tar.zst +0 -0
- package/.turbo/cache/cae7586c45bed13e-meta.json +1 -0
- package/.turbo/cache/cae7586c45bed13e.tar.zst +0 -0
- package/.turbo/cache/cf143eb1a55684db-meta.json +1 -0
- package/.turbo/cache/cf143eb1a55684db.tar.zst +0 -0
- package/.turbo/cache/d5b85352bc667f19-meta.json +1 -0
- package/.turbo/cache/d5b85352bc667f19.tar.zst +0 -0
- package/.turbo/cache/d5db503b2eaf239c-meta.json +1 -1
- package/.turbo/cache/d775555355d6b8fc-meta.json +1 -1
- package/.turbo/cache/d7c3007be148d2a1-meta.json +1 -1
- package/.turbo/cache/dad3d78b33edd9e4-meta.json +1 -1
- package/.turbo/cache/db5e65d819bfe66b-meta.json +1 -0
- package/.turbo/cache/{0b22557b4944c6e3.tar.zst → db5e65d819bfe66b.tar.zst} +0 -0
- package/.turbo/cache/dc597b3ea4f61ec8-meta.json +1 -1
- package/.turbo/cache/e392fe0927e4af23-meta.json +1 -0
- package/.turbo/cache/e392fe0927e4af23.tar.zst +0 -0
- package/.turbo/cache/e62cfee068e3ef36-meta.json +1 -1
- package/.turbo/cache/e9e36823f6c98f07-meta.json +1 -1
- package/.turbo/cache/ea8dd91dba19ddee-meta.json +1 -0
- package/.turbo/cache/ea8dd91dba19ddee.tar.zst +0 -0
- package/.turbo/cache/f2913bf19939d840-meta.json +1 -0
- package/.turbo/cache/f2913bf19939d840.tar.zst +0 -0
- package/.turbo/cache/f86b28e5ea2c66fe-meta.json +1 -0
- package/CHANGELOG.md +23 -0
- package/components/checkbox/.turbo/turbo-build.log +3 -3
- package/components/checkbox/.turbo/turbo-bundler.log +3 -3
- package/components/checkbox/README.md +1 -1
- package/components/combobox/.turbo/turbo-build.log +3 -3
- package/components/combobox/README.md +4 -4
- package/components/combobox/demo/api.min.js +2 -4
- package/components/combobox/demo/index.min.js +2 -4
- package/components/combobox/dist/index.js +1 -2
- package/components/counter/.turbo/turbo-build.log +3 -3
- package/components/counter/.turbo/turbo-bundler.log +3 -3
- package/components/counter/README.md +1 -1
- package/components/datepicker/.turbo/turbo-build.log +2 -2
- package/components/datepicker/README.md +4 -4
- package/components/dropdown/.turbo/turbo-build.log +3 -3
- package/components/dropdown/.turbo/turbo-bundler.log +3 -3
- package/components/dropdown/README.md +1 -1
- package/components/form/.turbo/turbo-build.log +3 -3
- package/components/form/.turbo/turbo-bundler.log +3 -3
- package/components/form/README.md +11 -9
- package/components/form/demo/api.min.js +187 -22
- package/components/form/demo/index.min.js +187 -22
- package/components/form/demo/registerDemoDeps.js +5 -0
- package/components/form/demo/working.html +86 -0
- package/components/form/dist/auro-form.d.ts +83 -2
- package/components/form/dist/auro-form.d.ts.map +1 -1
- package/components/form/dist/index.js +187 -22
- package/components/form/package.json +3 -1
- package/components/form/src/auro-form.js +187 -25
- package/components/form/src/styles/style-css.js +1 -1
- package/components/form/src/styles/style.css +8 -0
- package/components/form/src/styles/style.scss +10 -0
- package/components/input/.turbo/turbo-build.log +3 -3
- package/components/input/.turbo/turbo-bundler.log +3 -3
- package/components/input/README.md +1 -1
- package/components/menu/.turbo/turbo-build.log +3 -3
- package/components/menu/.turbo/turbo-bundler.log +3 -3
- package/components/menu/README.md +1 -1
- package/components/menu/demo/api.min.js +1 -2
- package/components/menu/demo/index.min.js +1 -2
- package/components/menu/dist/auro-menu.d.ts.map +1 -1
- package/components/menu/dist/index.js +1 -2
- package/components/menu/src/auro-menu.js +0 -1
- package/components/menu/src/styles/color-menuoption-css.js +1 -1
- package/components/menu/src/styles/color-menuoption.css +3 -0
- package/components/menu/src/styles/color-menuoption.scss +4 -0
- package/components/radio/.turbo/turbo-build.log +3 -3
- package/components/radio/.turbo/turbo-bundler.log +3 -3
- package/components/radio/README.md +1 -1
- package/components/select/.turbo/turbo-build.log +3 -3
- package/components/select/README.md +3 -3
- package/components/select/demo/api.min.js +2 -4
- package/components/select/demo/index.min.js +2 -4
- package/components/select/dist/index.js +1 -2
- package/package.json +1 -1
- package/.turbo/cache/0b22557b4944c6e3-meta.json +0 -1
- package/.turbo/cache/0c8124a987c1cc05-meta.json +0 -1
- package/.turbo/cache/0c8124a987c1cc05.tar.zst +0 -0
- package/.turbo/cache/1502c5fc71126643-meta.json +0 -1
- package/.turbo/cache/1502c5fc71126643.tar.zst +0 -0
- package/.turbo/cache/18129dba20f51b6b-meta.json +0 -1
- package/.turbo/cache/18129dba20f51b6b.tar.zst +0 -0
- package/.turbo/cache/1d461617c524c257-meta.json +0 -1
- package/.turbo/cache/1d461617c524c257.tar.zst +0 -0
- package/.turbo/cache/1f8549ade1f226ed-meta.json +0 -1
- package/.turbo/cache/2787020e69f50af2-meta.json +0 -1
- package/.turbo/cache/2787020e69f50af2.tar.zst +0 -0
- package/.turbo/cache/32545b759b9ce644-meta.json +0 -1
- package/.turbo/cache/34e8aaa18849b071-meta.json +0 -1
- package/.turbo/cache/34e8aaa18849b071.tar.zst +0 -0
- package/.turbo/cache/35b02758b1702fa7-meta.json +0 -1
- package/.turbo/cache/4302d0f3b7325335-meta.json +0 -1
- package/.turbo/cache/4db3f888378e8c97-meta.json +0 -1
- package/.turbo/cache/50993de942ec15a9-meta.json +0 -1
- package/.turbo/cache/50993de942ec15a9.tar.zst +0 -0
- package/.turbo/cache/559969de09c2dc0b-meta.json +0 -1
- package/.turbo/cache/559969de09c2dc0b.tar.zst +0 -0
- package/.turbo/cache/584cc436c8078114-meta.json +0 -1
- package/.turbo/cache/584cc436c8078114.tar.zst +0 -0
- package/.turbo/cache/5c16e68b6c2fe505-meta.json +0 -1
- package/.turbo/cache/5c16e68b6c2fe505.tar.zst +0 -0
- package/.turbo/cache/5ddbe69f2cb372c5-meta.json +0 -1
- package/.turbo/cache/759b0d821dae60c9-meta.json +0 -1
- package/.turbo/cache/76a76201dfec8a47-meta.json +0 -1
- package/.turbo/cache/76a76201dfec8a47.tar.zst +0 -0
- package/.turbo/cache/79b7301ce5cb7388-meta.json +0 -1
- package/.turbo/cache/8a1d75ce1555da17-meta.json +0 -1
- package/.turbo/cache/8a1d75ce1555da17.tar.zst +0 -0
- package/.turbo/cache/8aa9a0ccdac4b3f6-meta.json +0 -1
- package/.turbo/cache/9ae99e8e7bd83d06-meta.json +0 -1
- package/.turbo/cache/9ae99e8e7bd83d06.tar.zst +0 -0
- package/.turbo/cache/a12b45bee8b447ec-meta.json +0 -1
- package/.turbo/cache/a12b45bee8b447ec.tar.zst +0 -0
- package/.turbo/cache/a2c5639ae99f332a-meta.json +0 -1
- package/.turbo/cache/a2c5639ae99f332a.tar.zst +0 -0
- package/.turbo/cache/ab77cb0b089f1928-meta.json +0 -1
- package/.turbo/cache/b30c78f2c15f720d-meta.json +0 -1
- package/.turbo/cache/b30c78f2c15f720d.tar.zst +0 -0
- package/.turbo/cache/ba69fd787d0ded42-meta.json +0 -1
- package/.turbo/cache/c44efc9e4ddd8a0e-meta.json +0 -1
- package/.turbo/cache/c44efc9e4ddd8a0e.tar.zst +0 -0
- package/.turbo/cache/d4b8a79a27266a26-meta.json +0 -1
- package/.turbo/cache/da4d6d64c2b8c14c-meta.json +0 -1
- package/.turbo/cache/da4d6d64c2b8c14c.tar.zst +0 -0
- package/.turbo/cache/e89dfa7c665c8763-meta.json +0 -1
- package/.turbo/cache/e9070f00d98f5229-meta.json +0 -1
- package/.turbo/cache/e9070f00d98f5229.tar.zst +0 -0
- package/.turbo/cache/eaaba23b39cfd96e-meta.json +0 -1
- package/.turbo/cache/eaaba23b39cfd96e.tar.zst +0 -0
- package/.turbo/cache/fb11be9bb5bed06e-meta.json +0 -1
- /package/.turbo/cache/{1f8549ade1f226ed.tar.zst → 1b97859030a6d60b.tar.zst} +0 -0
- /package/.turbo/cache/{ab77cb0b089f1928.tar.zst → 31bd5687f46c7eba.tar.zst} +0 -0
- /package/.turbo/cache/{8aa9a0ccdac4b3f6.tar.zst → 43693504bf6e7c4c.tar.zst} +0 -0
- /package/.turbo/cache/{4db3f888378e8c97.tar.zst → 80410f4b5990ab83.tar.zst} +0 -0
- /package/.turbo/cache/{79b7301ce5cb7388.tar.zst → 876b8fa390c8ec81.tar.zst} +0 -0
- /package/.turbo/cache/{fb11be9bb5bed06e.tar.zst → 8f5fef3e04a6fcfa.tar.zst} +0 -0
- /package/.turbo/cache/{759b0d821dae60c9.tar.zst → ba270a0ef147f2e5.tar.zst} +0 -0
- /package/.turbo/cache/{ba69fd787d0ded42.tar.zst → f86b28e5ea2c66fe.tar.zst} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3
|
+
See LICENSE in the project root for license information.
|
|
4
|
+
|
|
5
|
+
HTML in this document is standardized and NOT to be edited.
|
|
6
|
+
All demo code should be added/edited in ./demo/index.md
|
|
7
|
+
|
|
8
|
+
With the exception of adding custom elements if needed for the demo.
|
|
9
|
+
|
|
10
|
+
----------------------- DO NOT EDIT -----------------------------
|
|
11
|
+
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<!DOCTYPE html>
|
|
15
|
+
<html lang="en">
|
|
16
|
+
<head>
|
|
17
|
+
<meta charset="UTF-8" />
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
19
|
+
<title>Auro Web Component Generator | auro-form custom element</title>
|
|
20
|
+
<link
|
|
21
|
+
rel="stylesheet"
|
|
22
|
+
type="text/css"
|
|
23
|
+
href="https://cdn.jsdelivr.net/npm/prismjs@1.24.1/themes/prism.css"
|
|
24
|
+
/>
|
|
25
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/tokens/CSSCustomProperties.css">
|
|
26
|
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/demoWrapper.css" />
|
|
27
|
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/elementDemoStyles.css" />
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-button@8.2.0/dist/auro-button__bundled.js" type="module"></script>
|
|
29
|
+
</head>
|
|
30
|
+
<body class="auro-markdown">
|
|
31
|
+
<main>
|
|
32
|
+
<style>
|
|
33
|
+
.submitBlock {
|
|
34
|
+
margin-top: 1rem;
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
gap: 1rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.datepickerBlock {
|
|
41
|
+
margin-top: 1rem;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
|
|
45
|
+
<h2>auro-form testing</h2>
|
|
46
|
+
<auro-form>
|
|
47
|
+
<auro-input id="first-name" name="firstName" required>
|
|
48
|
+
<span slot="label">First Name</span>
|
|
49
|
+
</auro-input>
|
|
50
|
+
<div>
|
|
51
|
+
<auro-input id="last-name" name="lastName" required>
|
|
52
|
+
<span slot="label">Last Name</span>
|
|
53
|
+
</auro-input>
|
|
54
|
+
</div>
|
|
55
|
+
<div>
|
|
56
|
+
<div>
|
|
57
|
+
<auro-input id="occupation" name="occupation" required>
|
|
58
|
+
<span slot="label">Occupation</span>
|
|
59
|
+
</auro-input>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="datepickerBlock">
|
|
64
|
+
<h4>Pick a cool date</h4>
|
|
65
|
+
<auro-datepicker id="date-example" name="dateExample" required>
|
|
66
|
+
<span slot="fromLabel">Choose a date</span>
|
|
67
|
+
<span slot="mobileDateLabel">Choose a date</span>
|
|
68
|
+
</auro-datepicker>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div class="submitBlock">
|
|
72
|
+
<auro-button type="reset">Reset</auro-button>
|
|
73
|
+
<auro-button type="submit">Submit</auro-button>
|
|
74
|
+
</div>
|
|
75
|
+
</auro-form>
|
|
76
|
+
</main>
|
|
77
|
+
|
|
78
|
+
<script type="module" data-demo-script="true" src="./index.js"></script>
|
|
79
|
+
<script type="module" data-demo-script="true" src="./registerDemoDeps.js"></script>
|
|
80
|
+
<!--<script type="module" data-demo-script="true" src="~@auro-formkit/auro-input/dist/index.min.js"></script>-->
|
|
81
|
+
|
|
82
|
+
<!-- If additional elements are needed for the demo, add them here. -->
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
|
|
84
|
+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
@@ -1,3 +1,13 @@
|
|
|
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
|
+
*/
|
|
1
11
|
/**
|
|
2
12
|
* The auro-form element provides users a way to ... (it would be great if you fill this out).
|
|
3
13
|
*
|
|
@@ -6,10 +16,12 @@
|
|
|
6
16
|
*/
|
|
7
17
|
export class AuroForm extends LitElement {
|
|
8
18
|
static get properties(): {
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
_formState: {
|
|
20
|
+
attribute: boolean;
|
|
11
21
|
};
|
|
12
22
|
};
|
|
23
|
+
static get formElementTags(): string[];
|
|
24
|
+
static get submitElementTags(): string[];
|
|
13
25
|
static get styles(): import("lit").CSSResult[];
|
|
14
26
|
/**
|
|
15
27
|
* This will register this element with the browser.
|
|
@@ -20,7 +32,76 @@ export class AuroForm extends LitElement {
|
|
|
20
32
|
*
|
|
21
33
|
*/
|
|
22
34
|
static register(name?: string): void;
|
|
35
|
+
/** @type {FormState} */
|
|
36
|
+
_formState: FormState;
|
|
37
|
+
/**
|
|
38
|
+
* Shared code for determining if an element is something we care about (submit, form element, etc.).
|
|
39
|
+
* @param {string[]} collection - The array to use for tag name search.
|
|
40
|
+
* @param {HTMLElement} element - The element to compare against the master list.
|
|
41
|
+
* @returns boolean
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private _isInElementCollection;
|
|
45
|
+
/**
|
|
46
|
+
* Check if the tag name is a form element.
|
|
47
|
+
* @param {HTMLElement} element - The element to check (attr or tag name).
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
isFormElement(element: HTMLElement): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if the tag name is a submit element.
|
|
53
|
+
* @param {HTMLElement} element - The element to check.
|
|
54
|
+
* @returns {boolean}
|
|
55
|
+
*/
|
|
56
|
+
isSubmitElement(element: HTMLElement): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Reduce the form value into a key-value pair.
|
|
59
|
+
*
|
|
60
|
+
* NOTE: form keys use `name` first, and `id` second if `name` is not available.
|
|
61
|
+
* This follows standard HTML5 form behavior - submission uses `name` by default when creating
|
|
62
|
+
* the FormData object.
|
|
63
|
+
*
|
|
64
|
+
* @returns {Record<string, string | number | boolean | string[] | null>} The form value.
|
|
65
|
+
*/
|
|
66
|
+
get value(): Record<string, string | number | boolean | string[] | null>;
|
|
67
|
+
get validity(): "valid" | "invalid";
|
|
68
|
+
get isInitialState(): boolean;
|
|
69
|
+
getSubmitFunction(): (event: any) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Construct the query strings from elements, append them together, execute, and return the NodeList.
|
|
72
|
+
* @returns {NodeList}
|
|
73
|
+
*/
|
|
74
|
+
queryAuroElements(): NodeList;
|
|
75
|
+
firstUpdated(_changedProperties: any): void;
|
|
76
|
+
onSlotChange(): void;
|
|
23
77
|
render(): import("lit-html").TemplateResult<1>;
|
|
24
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* - The form state member.
|
|
81
|
+
*/
|
|
82
|
+
export type FormStateMember = {
|
|
83
|
+
/**
|
|
84
|
+
* - The value of the form element.
|
|
85
|
+
*/
|
|
86
|
+
value: string | number | boolean | string[] | null;
|
|
87
|
+
/**
|
|
88
|
+
* - The validity state of the form element, stored when fired from the form element.
|
|
89
|
+
*/
|
|
90
|
+
validity: ValidityState;
|
|
91
|
+
/**
|
|
92
|
+
* - Whether the form element is required or not.
|
|
93
|
+
*/
|
|
94
|
+
required: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* - Whether the form element is required or not.
|
|
97
|
+
*/
|
|
98
|
+
element: HTMLElement;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* - The form state.
|
|
102
|
+
*/
|
|
103
|
+
export type FormState = {
|
|
104
|
+
[x: string]: FormStateMember;
|
|
105
|
+
};
|
|
25
106
|
import { LitElement } from "lit";
|
|
26
107
|
//# sourceMappingURL=auro-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auro-form.d.ts","sourceRoot":"","sources":["../src/auro-form.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auro-form.d.ts","sourceRoot":"","sources":["../src/auro-form.js"],"names":[],"mappings":"AAcA;;;;;;GAMG;AAEH;;GAEG;AAIH;;;;;GAKG;AAGH;IACE;;;;MAIC;IAWD,uCAOC;IAsBD,yCAKC;IAWD,+CAEC;IAsED;;;;;;;OAOG;IACH,uBANW,MAAM,QAQhB;IArIC,wBAAwB;IACxB,YADW,SAAS,CACA;IActB;;;;;;OAMG;IACH,+BAEC;IAED;;;;OAIG;IACH,uBAHW,WAAW,GACT,OAAO,CAInB;IASD;;;;OAIG;IACH,yBAHW,WAAW,GACT,OAAO,CAInB;IAMD;;;;;;;;OAQG;IACH,aAFa,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,CAOvE;IAED,oCAYC;IAGD,8BAIC;IAED,0CAYC;IAED;;;OAGG;IACH,qBAFa,QAAQ,CAapB;IAcD,4CAqBC;IAED,qBAkBC;IAGD,+CASC;CACF;;;;;;;;WA3Na,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,IAAI;;;;cAC3C,aAAa;;;;cACb,OAAO;;;;aACP,WAAW;;;;;;;;2BAXQ,KAAK"}
|
|
@@ -24,7 +24,7 @@ const t=globalThis,i$1=t.trustedTypes,s=i$1?i$1.createPolicy("lit-html",{createH
|
|
|
24
24
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
25
|
*/class r extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=undefined;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(s,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}}r._$litElement$=true,r["finalized"]=true,globalThis.litElementHydrateSupport?.({LitElement:r});const i=globalThis.litElementPolyfillSupport;i?.({LitElement:r});(globalThis.litElementVersions??=[]).push("4.1.1");
|
|
26
26
|
|
|
27
|
-
var styleCss = i$3`*,*:before,*:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}*:focus-visible{outline:0}*:focus-visible{outline:0}:focus:not(:focus-visible){outline:3px solid transparent}.testClass{display:inline-block;padding:var(--auro-text-body-size-default);border:1px solid var(--auro-color-border-error-on-light);color:var(--auro-color-border-error-on-light)}:focus-visible{background-color:var(--auro-color-border-error-on-light);color:var(--auro-color-base-white)}`;
|
|
27
|
+
var styleCss = i$3`*,*:before,*:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}*:focus-visible{outline:0}*:focus-visible{outline:0}:focus:not(:focus-visible){outline:3px solid transparent}.testClass{display:inline-block;padding:var(--auro-text-body-size-default);border:1px solid var(--auro-color-border-error-on-light);color:var(--auro-color-border-error-on-light)}:focus-visible{background-color:var(--auro-color-border-error-on-light);color:var(--auro-color-base-white)}:host form{display:block;width:100%;padding:1rem;border:1px solid #2a2a2a;border-radius:1rem}`;
|
|
28
28
|
|
|
29
29
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
30
30
|
// See LICENSE in the project root for license information.
|
|
@@ -96,8 +96,20 @@ class AuroLibraryRuntimeUtils {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
/* eslint-disable no-underscore-dangle */
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @typedef {Object} FormStateMember - The form state member.
|
|
104
|
+
* @property {string | number | boolean | string[] | null} value - The value of the form element.
|
|
105
|
+
* @property {ValidityState} validity - The validity state of the form element, stored when fired from the form element.
|
|
106
|
+
* @property {boolean} required - Whether the form element is required or not.
|
|
107
|
+
* @property {HTMLElement} element - Whether the form element is required or not.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @typedef {Object.<string, FormStateMember>} FormState - The form state.
|
|
112
|
+
*/
|
|
101
113
|
|
|
102
114
|
|
|
103
115
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
@@ -110,26 +122,138 @@ class AuroLibraryRuntimeUtils {
|
|
|
110
122
|
|
|
111
123
|
// build the component class
|
|
112
124
|
class AuroForm extends r {
|
|
113
|
-
// constructor() {
|
|
114
|
-
// super();
|
|
115
|
-
// }
|
|
116
|
-
|
|
117
|
-
// This function is to define props used within the scope of this component
|
|
118
|
-
// Be sure to review https://lit.dev/docs/components/properties/
|
|
119
|
-
// to understand how to use reflected attributes with your property settings.
|
|
120
125
|
static get properties() {
|
|
121
126
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// this property is DEMO ONLY! Please delete.
|
|
125
|
-
cssClass: { type: String }
|
|
127
|
+
_formState: { attribute: false },
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
constructor() {
|
|
132
|
+
super();
|
|
133
|
+
|
|
134
|
+
/** @type {FormState} */
|
|
135
|
+
this._formState = {};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Note: button is NOT considered a form element in this context
|
|
139
|
+
// as it does not have a .value property.
|
|
140
|
+
static get formElementTags() {
|
|
141
|
+
return [
|
|
142
|
+
'auro-input',
|
|
143
|
+
'auro-select',
|
|
144
|
+
'auro-datepicker',
|
|
145
|
+
'auro-checkbox-group',
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Shared code for determining if an element is something we care about (submit, form element, etc.).
|
|
151
|
+
* @param {string[]} collection - The array to use for tag name search.
|
|
152
|
+
* @param {HTMLElement} element - The element to compare against the master list.
|
|
153
|
+
* @returns boolean
|
|
154
|
+
* @private
|
|
155
|
+
*/
|
|
156
|
+
_isInElementCollection(collection, element) {
|
|
157
|
+
return collection.some((elementTag) => element.tagName.toLowerCase() === elementTag || element.hasAttribute(elementTag.toLowerCase()));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Check if the tag name is a form element.
|
|
162
|
+
* @param {HTMLElement} element - The element to check (attr or tag name).
|
|
163
|
+
* @returns {boolean}
|
|
164
|
+
*/
|
|
165
|
+
isFormElement(element) {
|
|
166
|
+
return this._isInElementCollection(AuroForm.formElementTags, element);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static get submitElementTags() {
|
|
170
|
+
return [
|
|
171
|
+
'button',
|
|
172
|
+
'auro-button',
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if the tag name is a submit element.
|
|
178
|
+
* @param {HTMLElement} element - The element to check.
|
|
179
|
+
* @returns {boolean}
|
|
180
|
+
*/
|
|
181
|
+
isSubmitElement(element) {
|
|
182
|
+
return this._isInElementCollection(AuroForm.submitElementTags, element);
|
|
183
|
+
}
|
|
184
|
+
|
|
129
185
|
static get styles() {
|
|
130
186
|
return [styleCss];
|
|
131
187
|
}
|
|
132
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Reduce the form value into a key-value pair.
|
|
191
|
+
*
|
|
192
|
+
* NOTE: form keys use `name` first, and `id` second if `name` is not available.
|
|
193
|
+
* This follows standard HTML5 form behavior - submission uses `name` by default when creating
|
|
194
|
+
* the FormData object.
|
|
195
|
+
*
|
|
196
|
+
* @returns {Record<string, string | number | boolean | string[] | null>} The form value.
|
|
197
|
+
*/
|
|
198
|
+
get value() {
|
|
199
|
+
return Object.keys(this._formState).reduce((acc, key) => {
|
|
200
|
+
acc[key] = this._formState[key].value;
|
|
201
|
+
return acc;
|
|
202
|
+
}, {});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
get validity() {
|
|
206
|
+
// go through validity states and return the first invalid state (if any)
|
|
207
|
+
const invalidKey = Object.keys(this._formState).
|
|
208
|
+
find((key) => {
|
|
209
|
+
const formKey = this._formState[key];
|
|
210
|
+
|
|
211
|
+
// these are NOT extra :(
|
|
212
|
+
// eslint-disable-next-line no-extra-parens
|
|
213
|
+
return (formKey.validity !== 'valid' && formKey.required) || (formKey.validity !== 'valid' && formKey.value !== null);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return invalidKey ? 'invalid' : 'valid';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Below is not implemented yet
|
|
220
|
+
get isInitialState() {
|
|
221
|
+
const anyTainted = Object.keys(this._formState).some((key) => this._formState[key].validity !== null);
|
|
222
|
+
|
|
223
|
+
return !anyTainted;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
getSubmitFunction() {
|
|
227
|
+
// We return an arrow function here to ensure that the `this` context points at this same AuroForm context.
|
|
228
|
+
// Otherwise, submission tries to read `this.value` on the button element.
|
|
229
|
+
return (event) => {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
|
|
232
|
+
this.dispatchEvent(new CustomEvent('submit', {
|
|
233
|
+
detail: {
|
|
234
|
+
value: this.value
|
|
235
|
+
}
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Construct the query strings from elements, append them together, execute, and return the NodeList.
|
|
242
|
+
* @returns {NodeList}
|
|
243
|
+
*/
|
|
244
|
+
queryAuroElements() {
|
|
245
|
+
const formElementQuery = AuroForm.formElementTags.map((tag) => `${tag}[name]`).join(',');
|
|
246
|
+
const submitterQuery = AuroForm.submitElementTags.map((tag) => `${tag}[type=submit]`).join(',');
|
|
247
|
+
|
|
248
|
+
// Alternatively, for renamed components...
|
|
249
|
+
const renamedFormElementQuery = AuroForm.formElementTags.map((tag) => `[${tag}][name]`).join(',');
|
|
250
|
+
const renamedSubmitterQuery = AuroForm.formElementTags.map((tag) => `[${tag}][type=submit]`).join(',');
|
|
251
|
+
|
|
252
|
+
const unifiedElementQuery = `${formElementQuery},${submitterQuery},${renamedFormElementQuery},${renamedSubmitterQuery}`;
|
|
253
|
+
|
|
254
|
+
return this.querySelectorAll(unifiedElementQuery);
|
|
255
|
+
}
|
|
256
|
+
|
|
133
257
|
/**
|
|
134
258
|
* This will register this element with the browser.
|
|
135
259
|
* @param {string} [name="auro-form"] - The name of element that you want to register to.
|
|
@@ -142,17 +266,58 @@ class AuroForm extends r {
|
|
|
142
266
|
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroForm);
|
|
143
267
|
}
|
|
144
268
|
|
|
145
|
-
|
|
146
|
-
|
|
269
|
+
firstUpdated(_changedProperties) {
|
|
270
|
+
super.firstUpdated(_changedProperties);
|
|
271
|
+
|
|
272
|
+
const slot = this.shadowRoot.querySelector('slot');
|
|
273
|
+
|
|
274
|
+
// Update the form state when a form element is detected
|
|
275
|
+
slot.addEventListener('input', (event) => {
|
|
276
|
+
|
|
277
|
+
/** @type {HTMLInputElement} */
|
|
278
|
+
const eventTarget = event.target;
|
|
279
|
+
if (this.isFormElement(eventTarget)) {
|
|
280
|
+
this._formState[eventTarget.getAttribute("name")].value = eventTarget.value;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
slot.addEventListener('auroFormElement-validated', (event) => {
|
|
285
|
+
const oldValue = this._formState;
|
|
286
|
+
|
|
287
|
+
this._formState[event.target.getAttribute("name")].validity = event.detail.validity;
|
|
288
|
+
this.requestUpdate('formState', oldValue);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
onSlotChange() {
|
|
293
|
+
this._formState = {};
|
|
147
294
|
|
|
148
|
-
|
|
295
|
+
this.queryAuroElements().forEach((element) => {
|
|
296
|
+
if (this.isFormElement(element)) {
|
|
297
|
+
this._formState[element.getAttribute('name')] = {
|
|
298
|
+
value: element.getAttribute('value'),
|
|
299
|
+
validity: element.getAttribute('validity'),
|
|
300
|
+
required: element.hasAttribute('required'),
|
|
301
|
+
element
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (this.isSubmitElement(element) && element.getAttribute('type') === 'submit') {
|
|
306
|
+
element.removeEventListener('click', this.getSubmitFunction());
|
|
307
|
+
element.addEventListener('click', this.getSubmitFunction());
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
149
313
|
render() {
|
|
150
314
|
return x`
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
315
|
+
<form>
|
|
316
|
+
<p>Value: ${JSON.stringify(this.value)}</p>
|
|
317
|
+
<p>Validity: ${this.validity}</p>
|
|
318
|
+
<h3>Auro form example</h3>
|
|
319
|
+
<slot @slotchange="${this.onSlotChange}"></slot>
|
|
320
|
+
</form>
|
|
156
321
|
`;
|
|
157
322
|
}
|
|
158
323
|
}
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"@auro-formkit/build-tools": "*",
|
|
27
27
|
"@auro-formkit/config": "*",
|
|
28
28
|
"@auro-formkit/typescript": "*",
|
|
29
|
+
"@aurodesignsystem/auro-datepicker": "*",
|
|
30
|
+
"@aurodesignsystem/auro-input": "*",
|
|
29
31
|
"@aurodesignsystem/design-tokens": "^4.12.1",
|
|
30
32
|
"@aurodesignsystem/webcorestylesheets": "^5.1.2",
|
|
31
33
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"bundler": "rollup -c node:@auro-formkit/config/rollup",
|
|
59
61
|
"build:docs": "wca analyze 'scripts/wca/*.js' --outFiles docs/api.md; node ../../packages/build-tools/src/docProcessor.mjs --component form",
|
|
60
62
|
"clean": "rm -rf dist build",
|
|
61
|
-
"dev": "web-dev-server",
|
|
63
|
+
"dev": "web-dev-server --node-resolve",
|
|
62
64
|
"postCss:component": "node ../../node_modules/@aurodesignsystem/auro-library/scripts/build/postCss.mjs",
|
|
63
65
|
"sass:render": "sass-render --load-path=../../node_modules 'src/**/*.css' -t ../../node_modules/@aurodesignsystem/auro-library/scripts/build/staticStyles-template.js",
|
|
64
66
|
"serve": "web-dev-server",
|