@gov-design-system-ce/components 0.0.16 → 0.0.18
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/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/gov-accordion-item.cjs.entry.js +5 -1
- package/dist/cjs/gov-accordion-item.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-accordion.cjs.entry.js +5 -1
- package/dist/cjs/gov-accordion.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-app.cjs.entry.js +11 -8
- package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-backdrop.cjs.entry.js +0 -4
- package/dist/cjs/gov-backdrop.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-button.cjs.entry.js +28 -14
- package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js +33 -14
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-checkbox.cjs.entry.js +25 -18
- package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-file.cjs.entry.js +57 -27
- package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-input.cjs.entry.js +21 -5
- package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-multi-select.cjs.entry.js +30 -19
- package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-radio.cjs.entry.js +23 -16
- package/dist/cjs/gov-form-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-select.cjs.entry.js +27 -15
- package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-switch.cjs.entry.js +23 -16
- package/dist/cjs/gov-form-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-icon.cjs.entry.js +1 -1
- package/dist/cjs/gov-loading.cjs.entry.js +1 -1
- package/dist/cjs/gov-loading.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-modal.cjs.entry.js +1 -1
- package/dist/cjs/gov-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-pagination.cjs.entry.js +18 -10
- package/dist/cjs/gov-pagination.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-prompt.cjs.entry.js +8 -8
- package/dist/cjs/gov-prompt.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-tile.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/gov-accordion/gov-accordion-item.js +9 -5
- package/dist/collection/components/gov-accordion/gov-accordion-item.js.map +1 -1
- package/dist/collection/components/gov-accordion/gov-accordion.js +9 -5
- package/dist/collection/components/gov-accordion/gov-accordion.js.map +1 -1
- package/dist/collection/components/gov-accordion/gov-accordion.types.js +2 -0
- package/dist/collection/components/gov-accordion/gov-accordion.types.js.map +1 -0
- package/dist/collection/components/gov-backdrop/gov-backdrop.js +0 -22
- package/dist/collection/components/gov-backdrop/gov-backdrop.js.map +1 -1
- package/dist/collection/components/gov-button/gov-button.css +2 -2
- package/dist/collection/components/gov-button/gov-button.js +54 -37
- package/dist/collection/components/gov-button/gov-button.js.map +1 -1
- package/dist/collection/components/gov-button/gov-button.types.js +2 -0
- package/dist/collection/components/gov-button/gov-button.types.js.map +1 -0
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +60 -38
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.types.js.map +1 -1
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js +60 -39
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js.map +1 -1
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.types.js +2 -0
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.types.js.map +1 -0
- package/dist/collection/components/gov-form/file/gov-form-file.js +129 -59
- package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
- package/dist/collection/components/gov-form/file/gov-form-file.types.js.map +1 -1
- package/dist/collection/components/gov-form/input/gov-form-input.js +42 -22
- package/dist/collection/components/gov-form/input/gov-form-input.js.map +1 -1
- package/dist/collection/components/gov-form/input/gov-form-input.types.js +2 -0
- package/dist/collection/components/gov-form/input/gov-form-input.types.js.map +1 -0
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +53 -40
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.types.js +2 -0
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.types.js.map +1 -0
- package/dist/collection/components/gov-form/radio/gov-form-radio.js +57 -36
- package/dist/collection/components/gov-form/radio/gov-form-radio.js.map +1 -1
- package/dist/collection/components/gov-form/radio/gov-form-radio.types.js +2 -0
- package/dist/collection/components/gov-form/radio/gov-form-radio.types.js.map +1 -0
- package/dist/collection/components/gov-form/select/gov-form-select.js +56 -37
- package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
- package/dist/collection/components/gov-form/select/gov-form-select.types.js +2 -0
- package/dist/collection/components/gov-form/select/gov-form-select.types.js.map +1 -0
- package/dist/collection/components/gov-form/switch/gov-form-switch.js +57 -36
- package/dist/collection/components/gov-form/switch/gov-form-switch.js.map +1 -1
- package/dist/collection/components/gov-form/switch/gov-form-switch.types.js +2 -0
- package/dist/collection/components/gov-form/switch/gov-form-switch.types.js.map +1 -0
- package/dist/collection/components/gov-loading/loading/gov-loading.js +1 -1
- package/dist/collection/components/gov-loading/loading/gov-loading.js.map +1 -1
- package/dist/collection/components/gov-modal/gov-modal.js +1 -1
- package/dist/collection/components/gov-modal/gov-modal.js.map +1 -1
- package/dist/collection/components/gov-pagination/gov-pagination.js +16 -13
- package/dist/collection/components/gov-pagination/gov-pagination.js.map +1 -1
- package/dist/collection/components/gov-pagination/gov-pagination.types.js +2 -0
- package/dist/collection/components/gov-pagination/gov-pagination.types.js.map +1 -0
- package/dist/collection/components/gov-promp/gov-prompt.js +18 -18
- package/dist/collection/components/gov-promp/gov-prompt.js.map +1 -1
- package/dist/collection/components/gov-tile/gov-tile.js.map +1 -1
- package/dist/collection/pages/Forms.js +3 -0
- package/dist/collection/pages/Forms.js.map +1 -1
- package/dist/collection/pages/Pagination.js +8 -8
- package/dist/collection/pages/Pagination.js.map +1 -1
- package/dist/collection/types/event.types.js +2 -0
- package/dist/collection/types/event.types.js.map +1 -0
- package/dist/collection/utils/array.utils.js +6 -1
- package/dist/collection/utils/array.utils.js.map +1 -1
- package/dist/components/gov-accordion-item.js +5 -1
- package/dist/components/gov-accordion-item.js.map +1 -1
- package/dist/components/gov-accordion.js +5 -1
- package/dist/components/gov-accordion.js.map +1 -1
- package/dist/components/gov-app.js +11 -8
- package/dist/components/gov-app.js.map +1 -1
- package/dist/components/gov-backdrop2.js +0 -5
- package/dist/components/gov-backdrop2.js.map +1 -1
- package/dist/components/gov-button2.js +28 -14
- package/dist/components/gov-button2.js.map +1 -1
- package/dist/components/gov-form-autocomplete2.js +33 -14
- package/dist/components/gov-form-autocomplete2.js.map +1 -1
- package/dist/components/gov-form-checkbox.js +27 -20
- package/dist/components/gov-form-checkbox.js.map +1 -1
- package/dist/components/gov-form-file.js +59 -27
- package/dist/components/gov-form-file.js.map +1 -1
- package/dist/components/gov-form-input2.js +22 -6
- package/dist/components/gov-form-input2.js.map +1 -1
- package/dist/components/gov-form-multi-select.js +30 -19
- package/dist/components/gov-form-multi-select.js.map +1 -1
- package/dist/components/gov-form-radio.js +25 -18
- package/dist/components/gov-form-radio.js.map +1 -1
- package/dist/components/gov-form-select2.js +28 -16
- package/dist/components/gov-form-select2.js.map +1 -1
- package/dist/components/gov-form-switch.js +25 -18
- package/dist/components/gov-form-switch.js.map +1 -1
- package/dist/components/gov-icon2.js +1 -1
- package/dist/components/gov-loading.js +1 -1
- package/dist/components/gov-loading.js.map +1 -1
- package/dist/components/gov-modal.js +1 -1
- package/dist/components/gov-modal.js.map +1 -1
- package/dist/components/gov-pagination.js +18 -10
- package/dist/components/gov-pagination.js.map +1 -1
- package/dist/components/gov-prompt.js +8 -8
- package/dist/components/gov-prompt.js.map +1 -1
- package/dist/components/gov-tile.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/p-26260897.entry.js +2 -0
- package/dist/core/p-26260897.entry.js.map +1 -0
- package/dist/core/{p-30b162df.entry.js → p-354c6a6d.entry.js} +2 -2
- package/dist/core/p-354c6a6d.entry.js.map +1 -0
- package/dist/core/{p-e6b8c610.entry.js → p-3a50ac4c.entry.js} +2 -2
- package/dist/core/p-3a50ac4c.entry.js.map +1 -0
- package/dist/core/p-52f2f67c.entry.js +2 -0
- package/dist/core/p-52f2f67c.entry.js.map +1 -0
- package/dist/core/{p-e3141382.entry.js → p-5e5e925d.entry.js} +2 -2
- package/dist/core/p-5e5e925d.entry.js.map +1 -0
- package/dist/core/p-67006730.entry.js.map +1 -1
- package/dist/core/p-724921e7.entry.js +2 -0
- package/dist/core/p-724921e7.entry.js.map +1 -0
- package/dist/core/{p-d2f6053f.entry.js → p-8b2a6f87.entry.js} +2 -2
- package/dist/core/p-8b2a6f87.entry.js.map +1 -0
- package/dist/core/{p-9bdce72b.entry.js → p-8feb8960.entry.js} +2 -2
- package/dist/core/p-8feb8960.entry.js.map +1 -0
- package/dist/core/{p-f027a1a1.entry.js → p-a37ef1b2.entry.js} +2 -2
- package/dist/core/{p-bce96aac.entry.js → p-b2d1dd2a.entry.js} +2 -2
- package/dist/core/p-b2d1dd2a.entry.js.map +1 -0
- package/dist/core/{p-131c50d1.entry.js → p-b9b80796.entry.js} +2 -2
- package/dist/core/p-b9b80796.entry.js.map +1 -0
- package/dist/core/{p-b7587525.entry.js → p-bb3afae6.entry.js} +2 -2
- package/dist/core/p-bb3afae6.entry.js.map +1 -0
- package/dist/core/{p-c91928ed.entry.js → p-be799dfa.entry.js} +2 -2
- package/dist/core/p-be799dfa.entry.js.map +1 -0
- package/dist/core/{p-2426fa82.entry.js → p-c970a479.entry.js} +2 -2
- package/dist/core/p-c970a479.entry.js.map +1 -0
- package/dist/core/{p-471c0863.entry.js → p-cba27477.entry.js} +2 -2
- package/dist/core/p-cba27477.entry.js.map +1 -0
- package/dist/core/{p-93edcce2.entry.js → p-d79d0f7a.entry.js} +2 -2
- package/dist/core/p-d79d0f7a.entry.js.map +1 -0
- package/dist/core/{p-c836f7cd.entry.js → p-e51baf04.entry.js} +2 -2
- package/dist/core/p-e51baf04.entry.js.map +1 -0
- package/dist/core/{p-0272ffa0.entry.js → p-f73d482b.entry.js} +2 -2
- package/dist/core/p-f73d482b.entry.js.map +1 -0
- package/dist/custom-elements/index.js +1 -1
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/core.js +1 -1
- package/dist/esm/gov-accordion-item.entry.js +5 -1
- package/dist/esm/gov-accordion-item.entry.js.map +1 -1
- package/dist/esm/gov-accordion.entry.js +5 -1
- package/dist/esm/gov-accordion.entry.js.map +1 -1
- package/dist/esm/gov-app.entry.js +11 -8
- package/dist/esm/gov-app.entry.js.map +1 -1
- package/dist/esm/gov-backdrop.entry.js +0 -4
- package/dist/esm/gov-backdrop.entry.js.map +1 -1
- package/dist/esm/gov-button.entry.js +28 -14
- package/dist/esm/gov-button.entry.js.map +1 -1
- package/dist/esm/gov-form-autocomplete.entry.js +33 -14
- package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
- package/dist/esm/gov-form-checkbox.entry.js +25 -18
- package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
- package/dist/esm/gov-form-file.entry.js +57 -27
- package/dist/esm/gov-form-file.entry.js.map +1 -1
- package/dist/esm/gov-form-input.entry.js +21 -5
- package/dist/esm/gov-form-input.entry.js.map +1 -1
- package/dist/esm/gov-form-multi-select.entry.js +30 -19
- package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
- package/dist/esm/gov-form-radio.entry.js +23 -16
- package/dist/esm/gov-form-radio.entry.js.map +1 -1
- package/dist/esm/gov-form-select.entry.js +27 -15
- package/dist/esm/gov-form-select.entry.js.map +1 -1
- package/dist/esm/gov-form-switch.entry.js +23 -16
- package/dist/esm/gov-form-switch.entry.js.map +1 -1
- package/dist/esm/gov-icon.entry.js +1 -1
- package/dist/esm/gov-loading.entry.js +1 -1
- package/dist/esm/gov-loading.entry.js.map +1 -1
- package/dist/esm/gov-modal.entry.js +1 -1
- package/dist/esm/gov-modal.entry.js.map +1 -1
- package/dist/esm/gov-pagination.entry.js +18 -10
- package/dist/esm/gov-pagination.entry.js.map +1 -1
- package/dist/esm/gov-prompt.entry.js +8 -8
- package/dist/esm/gov-prompt.entry.js.map +1 -1
- package/dist/esm/gov-tile.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/hydrate/index.js +326 -187
- package/dist/stencil.config.js +1 -1
- package/dist/stencil.config.js.map +1 -1
- package/dist/types/components/gov-accordion/gov-accordion-item.d.ts +2 -2
- package/dist/types/components/gov-accordion/gov-accordion.d.ts +2 -2
- package/dist/types/components/gov-accordion/gov-accordion.types.d.ts +9 -0
- package/dist/types/components/gov-backdrop/gov-backdrop.d.ts +0 -4
- package/dist/types/components/gov-button/gov-button.d.ts +6 -5
- package/dist/types/components/gov-button/gov-button.types.d.ts +4 -0
- package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.d.ts +8 -8
- package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.types.d.ts +6 -0
- package/dist/types/components/gov-form/checkbox/gov-form-checkbox.d.ts +11 -8
- package/dist/types/components/gov-form/checkbox/gov-form-checkbox.types.d.ts +5 -0
- package/dist/types/components/gov-form/file/gov-form-file.d.ts +16 -8
- package/dist/types/components/gov-form/file/gov-form-file.types.d.ts +5 -0
- package/dist/types/components/gov-form/input/gov-form-input.d.ts +6 -5
- package/dist/types/components/gov-form/input/gov-form-input.types.d.ts +4 -0
- package/dist/types/components/gov-form/multiselect/gov-form-multi-select.d.ts +6 -6
- package/dist/types/components/gov-form/multiselect/gov-form-multi-select.types.d.ts +8 -0
- package/dist/types/components/gov-form/radio/gov-form-radio.d.ts +10 -7
- package/dist/types/components/gov-form/radio/gov-form-radio.types.d.ts +5 -0
- package/dist/types/components/gov-form/select/gov-form-select.d.ts +7 -6
- package/dist/types/components/gov-form/select/gov-form-select.types.d.ts +4 -0
- package/dist/types/components/gov-form/switch/gov-form-switch.d.ts +10 -7
- package/dist/types/components/gov-form/switch/gov-form-switch.types.d.ts +5 -0
- package/dist/types/components/gov-pagination/gov-pagination.d.ts +2 -1
- package/dist/types/components/gov-pagination/gov-pagination.types.d.ts +5 -0
- package/dist/types/components.d.ts +69 -54
- package/dist/types/types/event.types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/collection/components/gov-accordion/gov-accordion-item.d.js +0 -2
- package/dist/collection/components/gov-accordion/gov-accordion-item.d.js.map +0 -1
- package/dist/collection/components/gov-form/checkbox/interfaces.js +0 -2
- package/dist/collection/components/gov-form/checkbox/interfaces.js.map +0 -1
- package/dist/collection/components/gov-form/multiselect/interfaces.js +0 -2
- package/dist/collection/components/gov-form/multiselect/interfaces.js.map +0 -1
- package/dist/collection/components/gov-form/radio/interfaces.js +0 -2
- package/dist/collection/components/gov-form/radio/interfaces.js.map +0 -1
- package/dist/collection/components/gov-form/switch/interfaces.js +0 -2
- package/dist/collection/components/gov-form/switch/interfaces.js.map +0 -1
- package/dist/core/p-0272ffa0.entry.js.map +0 -1
- package/dist/core/p-131c50d1.entry.js.map +0 -1
- package/dist/core/p-2426fa82.entry.js.map +0 -1
- package/dist/core/p-30b162df.entry.js.map +0 -1
- package/dist/core/p-337fb136.entry.js +0 -2
- package/dist/core/p-337fb136.entry.js.map +0 -1
- package/dist/core/p-402c2751.entry.js +0 -2
- package/dist/core/p-402c2751.entry.js.map +0 -1
- package/dist/core/p-405fc50f.entry.js +0 -2
- package/dist/core/p-405fc50f.entry.js.map +0 -1
- package/dist/core/p-471c0863.entry.js.map +0 -1
- package/dist/core/p-93edcce2.entry.js.map +0 -1
- package/dist/core/p-9bdce72b.entry.js.map +0 -1
- package/dist/core/p-b7587525.entry.js.map +0 -1
- package/dist/core/p-bce96aac.entry.js.map +0 -1
- package/dist/core/p-c836f7cd.entry.js.map +0 -1
- package/dist/core/p-c91928ed.entry.js.map +0 -1
- package/dist/core/p-d2f6053f.entry.js.map +0 -1
- package/dist/core/p-e3141382.entry.js.map +0 -1
- package/dist/core/p-e6b8c610.entry.js.map +0 -1
- package/dist/types/components/gov-accordion/gov-accordion-item.d.d.ts +0 -4
- package/dist/types/components/gov-form/checkbox/interfaces.d.ts +0 -4
- package/dist/types/components/gov-form/multiselect/interfaces.d.ts +0 -4
- package/dist/types/components/gov-form/radio/interfaces.d.ts +0 -4
- package/dist/types/components/gov-form/switch/interfaces.d.ts +0 -4
- /package/dist/core/{p-f027a1a1.entry.js.map → p-a37ef1b2.entry.js.map} +0 -0
|
@@ -22,62 +22,70 @@ export class GovFormCheckbox {
|
|
|
22
22
|
this.invalid = undefined;
|
|
23
23
|
this.wcagDescribedBy = undefined;
|
|
24
24
|
this.wcagLabelledBy = undefined;
|
|
25
|
-
this.isChecked = undefined;
|
|
26
25
|
this.checkboxId = createID("GovCheckbox");
|
|
27
26
|
this.h = govHost(this.host);
|
|
28
27
|
this.f = govForm(this.h);
|
|
29
28
|
}
|
|
30
|
-
updateCheckedState(newValue) {
|
|
31
|
-
this.isChecked = newValue;
|
|
32
|
-
this.govChange.emit({
|
|
33
|
-
checked: this.isChecked,
|
|
34
|
-
value: this.value,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
29
|
validateSize(newValue) {
|
|
38
30
|
validateProp(FormCheckboxSizes, newValue, FormCheckboxClass.root);
|
|
39
31
|
}
|
|
40
32
|
componentWillLoad() {
|
|
41
|
-
this.isChecked = this.checked;
|
|
42
33
|
this.f.passAttrToControl("type", "checkbox");
|
|
43
34
|
}
|
|
44
35
|
async componentDidRender() {
|
|
45
|
-
this.f.passAttrToLabel(
|
|
46
|
-
this.f.passAttrToLabel(
|
|
36
|
+
this.f.passAttrToLabel("identifier", this.identifier || this.checkboxId);
|
|
37
|
+
this.f.passAttrToLabel("required", String(this.required));
|
|
47
38
|
if (canValidateWcagOnRender()) {
|
|
48
39
|
await delay(500);
|
|
49
40
|
await this.validateWcag();
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
43
|
render() {
|
|
53
|
-
const { isChecked } = this;
|
|
54
44
|
const wrapCheckbox = (children) => {
|
|
55
45
|
if (this.noLabel) {
|
|
56
46
|
return (h("label", null, children));
|
|
57
47
|
}
|
|
58
48
|
return children;
|
|
59
49
|
};
|
|
60
|
-
return (h(Host, { class: FormCheckboxClass.root,
|
|
50
|
+
return (h(Host, { class: FormCheckboxClass.root, checked: this.checked, size: this.size, invalid: toBoolAttrIfDefined(this.invalid) }, wrapCheckbox(h(Fragment, null, h("input", { id: this.identifier || this.checkboxId, type: "checkbox", value: this.value, name: this.name, checked: this.checked, onClick: this.onClickHandler.bind(this), onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, ref: el => (this.inputRef = el), "aria-checked": toBoolAttr(this.checked), "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": toBoolAttrIfDefined(this.disabled) }), h("span", null, h("slot", { name: "label" }), h("gov-icon", { class: FormCheckboxClass.check, name: "check-lg" }))))));
|
|
61
51
|
}
|
|
62
52
|
onFocusHandler(e) {
|
|
63
53
|
e.stopPropagation();
|
|
64
|
-
this.govFocus.emit(
|
|
54
|
+
this.govFocus.emit({
|
|
55
|
+
component: FormCheckboxClass.root,
|
|
56
|
+
value: this.value,
|
|
57
|
+
checked: this.checked,
|
|
58
|
+
originalEvent: e,
|
|
59
|
+
});
|
|
65
60
|
}
|
|
66
61
|
onBlurHandler(e) {
|
|
67
62
|
e.stopPropagation();
|
|
68
|
-
this.govBlur.emit(
|
|
63
|
+
this.govBlur.emit({
|
|
64
|
+
component: FormCheckboxClass.root,
|
|
65
|
+
value: this.value,
|
|
66
|
+
checked: this.checked,
|
|
67
|
+
originalEvent: e,
|
|
68
|
+
});
|
|
69
69
|
}
|
|
70
70
|
onClickHandler(e) {
|
|
71
71
|
e.stopPropagation();
|
|
72
72
|
}
|
|
73
73
|
onChangeHandler(e) {
|
|
74
|
-
this.
|
|
74
|
+
this.checked = e.target.checked;
|
|
75
75
|
e.stopPropagation();
|
|
76
76
|
this.govChange.emit({
|
|
77
|
-
|
|
77
|
+
component: FormCheckboxClass.root,
|
|
78
78
|
value: this.value,
|
|
79
|
+
checked: this.checked,
|
|
80
|
+
originalEvent: e,
|
|
79
81
|
});
|
|
80
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the reference of the native element
|
|
85
|
+
*/
|
|
86
|
+
async getRef() {
|
|
87
|
+
return this.inputRef;
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Validate the WCAG attributes of the component
|
|
83
91
|
*/
|
|
@@ -118,7 +126,7 @@ export class GovFormCheckbox {
|
|
|
118
126
|
},
|
|
119
127
|
"checked": {
|
|
120
128
|
"type": "boolean",
|
|
121
|
-
"mutable":
|
|
129
|
+
"mutable": true,
|
|
122
130
|
"complexType": {
|
|
123
131
|
"original": "boolean",
|
|
124
132
|
"resolved": "boolean",
|
|
@@ -203,7 +211,7 @@ export class GovFormCheckbox {
|
|
|
203
211
|
"optional": true,
|
|
204
212
|
"docs": {
|
|
205
213
|
"tags": [],
|
|
206
|
-
"text": "
|
|
214
|
+
"text": "Checkboxes size."
|
|
207
215
|
},
|
|
208
216
|
"attribute": "size",
|
|
209
217
|
"reflect": false,
|
|
@@ -297,11 +305,6 @@ export class GovFormCheckbox {
|
|
|
297
305
|
}
|
|
298
306
|
};
|
|
299
307
|
}
|
|
300
|
-
static get states() {
|
|
301
|
-
return {
|
|
302
|
-
"isChecked": {}
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
308
|
static get events() {
|
|
306
309
|
return [{
|
|
307
310
|
"method": "govFocus",
|
|
@@ -314,11 +317,12 @@ export class GovFormCheckbox {
|
|
|
314
317
|
"text": "Emitted when the checkbox has focus."
|
|
315
318
|
},
|
|
316
319
|
"complexType": {
|
|
317
|
-
"original": "
|
|
318
|
-
"resolved": "
|
|
320
|
+
"original": "FormCheckboxEvent",
|
|
321
|
+
"resolved": "FormCheckboxEvent",
|
|
319
322
|
"references": {
|
|
320
|
-
"
|
|
321
|
-
"location": "
|
|
323
|
+
"FormCheckboxEvent": {
|
|
324
|
+
"location": "import",
|
|
325
|
+
"path": "./gov-form-checkbox.types"
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
}
|
|
@@ -333,11 +337,12 @@ export class GovFormCheckbox {
|
|
|
333
337
|
"text": "Emitted when the checkbox loses focus."
|
|
334
338
|
},
|
|
335
339
|
"complexType": {
|
|
336
|
-
"original": "
|
|
337
|
-
"resolved": "
|
|
340
|
+
"original": "FormCheckboxEvent",
|
|
341
|
+
"resolved": "FormCheckboxEvent",
|
|
338
342
|
"references": {
|
|
339
|
-
"
|
|
340
|
-
"location": "
|
|
343
|
+
"FormCheckboxEvent": {
|
|
344
|
+
"location": "import",
|
|
345
|
+
"path": "./gov-form-checkbox.types"
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
348
|
}
|
|
@@ -352,12 +357,12 @@ export class GovFormCheckbox {
|
|
|
352
357
|
"text": "Emitted when the checkbox change value."
|
|
353
358
|
},
|
|
354
359
|
"complexType": {
|
|
355
|
-
"original": "
|
|
356
|
-
"resolved": "
|
|
360
|
+
"original": "FormCheckboxEvent",
|
|
361
|
+
"resolved": "FormCheckboxEvent",
|
|
357
362
|
"references": {
|
|
358
|
-
"
|
|
363
|
+
"FormCheckboxEvent": {
|
|
359
364
|
"location": "import",
|
|
360
|
-
"path": "./
|
|
365
|
+
"path": "./gov-form-checkbox.types"
|
|
361
366
|
}
|
|
362
367
|
}
|
|
363
368
|
}
|
|
@@ -365,6 +370,25 @@ export class GovFormCheckbox {
|
|
|
365
370
|
}
|
|
366
371
|
static get methods() {
|
|
367
372
|
return {
|
|
373
|
+
"getRef": {
|
|
374
|
+
"complexType": {
|
|
375
|
+
"signature": "() => Promise<HTMLInputElement>",
|
|
376
|
+
"parameters": [],
|
|
377
|
+
"references": {
|
|
378
|
+
"Promise": {
|
|
379
|
+
"location": "global"
|
|
380
|
+
},
|
|
381
|
+
"HTMLInputElement": {
|
|
382
|
+
"location": "global"
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
"return": "Promise<HTMLInputElement>"
|
|
386
|
+
},
|
|
387
|
+
"docs": {
|
|
388
|
+
"text": "Returns the reference of the native element",
|
|
389
|
+
"tags": []
|
|
390
|
+
}
|
|
391
|
+
},
|
|
368
392
|
"validateWcag": {
|
|
369
393
|
"complexType": {
|
|
370
394
|
"signature": "() => Promise<void>",
|
|
@@ -386,9 +410,6 @@ export class GovFormCheckbox {
|
|
|
386
410
|
static get elementRef() { return "host"; }
|
|
387
411
|
static get watchers() {
|
|
388
412
|
return [{
|
|
389
|
-
"propName": "checked",
|
|
390
|
-
"methodName": "updateCheckedState"
|
|
391
|
-
}, {
|
|
392
413
|
"propName": "size",
|
|
393
414
|
"methodName": "validateSize"
|
|
394
415
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gov-form-checkbox.js","sourceRoot":"","sources":["../../../../../../../src/components/gov-form/checkbox/gov-form-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE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AiB,CAAC,IAAI,CAAC,CAAA;IAClF,eAAe,CAAC,IAAI,CAAC,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAChF,oBAAoB,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAA;EACtG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import { Component, Host, h, Prop, State, Event, EventEmitter, Element, Watch, Method } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormCheckboxClass, FormCheckboxSizes, FormCheckboxSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost, toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport { GovFormCheckboxChangeEvent } from \"./interfaces\"\nimport Fragment from \"../../../helpers/Fragment\"\n\n@Component({\n\ttag: \"gov-form-checkbox\",\n\tstyleUrl: \"gov-form-checkbox.scss\",\n})\nexport class GovFormCheckbox {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\n\tprivate readonly checkboxId: string\n\n\tconstructor() {\n\t\tthis.checkboxId = createID(\"GovCheckbox\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormCheckboxElement\n\t/**\n\t * Value of checkbox\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Checkbox default state\n\t */\n\t@Prop({ reflect: true }) readonly checked: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the checkbox component disabled.\n\t * This prevents users from being able to interact with the checkbox, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the checkbox.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Checkbox's size.\n\t */\n\t@Prop() readonly size?: FormCheckboxSizesType = \"m\"\n\t/**\n\t * Custom checkbox identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Emitted when the checkbox has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the checkbox loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the checkbox change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<GovFormCheckboxChangeEvent>\n\n\t@State() isChecked: boolean\n\n\t@Watch(\"checked\")\n\tupdateCheckedState(newValue: boolean): void {\n\t\tthis.isChecked = newValue\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormCheckboxSizes, newValue, FormCheckboxClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.isChecked = this.checked\n\n\t\tthis.f.passAttrToControl(\"type\", \"checkbox\")\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel('identifier', this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel('required', String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst { isChecked } = this\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={FormCheckboxClass.root} is-checked={isChecked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tchecked={this.isChecked}\n\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\taria-checked={toBoolAttr(this.isChecked)}\n\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t<gov-icon class={FormCheckboxClass.check} name=\"check-lg\"></gov-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Fragment>\n\t\t\t\t)}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.isChecked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormCheckboxClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormCheckboxClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormCheckboxClass.root)\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gov-form-checkbox.js","sourceRoot":"","sources":["../../../../../../../src/components/gov-form/checkbox/gov-form-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAgB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAyB,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAOhD,MAAM,OAAO,eAAe;EAO3B;;mBAekD,KAAK;oBAKlB,KAAK;;;gBAaM,GAAG;;mBAQU,KAAK;;;;IAxCjE,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;IAEzC,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;GACxB;EA+DD,YAAY,CAAC,QAAgB;IAC5B,YAAY,CAAC,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,CAAC,IAAI,CAAC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@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormCheckboxClass, FormCheckboxSizes, FormCheckboxSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost, toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormCheckboxEvent } from \"./gov-form-checkbox.types\"\n\n@Component({\n\ttag: \"gov-form-checkbox\",\n\tstyleUrl: \"gov-form-checkbox.scss\",\n})\nexport class GovFormCheckbox {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\n\n\tprivate readonly checkboxId: string\n\n\tconstructor() {\n\t\tthis.checkboxId = createID(\"GovCheckbox\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormCheckboxElement\n\t/**\n\t * Value of checkbox\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Checkbox default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the checkbox component disabled.\n\t * This prevents users from being able to interact with the checkbox, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the checkbox.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Checkboxes size.\n\t */\n\t@Prop() readonly size?: FormCheckboxSizesType = \"m\"\n\t/**\n\t * Custom checkbox identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Emitted when the checkbox has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FormCheckboxEvent>\n\t/**\n\t * Emitted when the checkbox loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormCheckboxEvent>\n\t/**\n\t * Emitted when the checkbox change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormCheckboxEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormCheckboxSizes, newValue, FormCheckboxClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToControl(\"type\", \"checkbox\")\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={FormCheckboxClass.root} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\taria-checked={toBoolAttr(this.checked)}\n\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t<gov-icon class={FormCheckboxClass.check} name=\"check-lg\"></gov-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Fragment>,\n\t\t\t\t)}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormCheckboxClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormCheckboxClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormCheckboxClass.root)\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gov-form-checkbox.types.js","sourceRoot":"","sources":["../../../../../../../src/components/gov-form/checkbox/gov-form-checkbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import { GovBaseEvent } from \"../../../types/event.types\"\n\nexport interface FormCheckboxEvent extends GovBaseEvent {\n\tchecked: boolean,\n\tvalue: string\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Host, h } from
|
|
2
|
-
import { createID } from
|
|
3
|
-
import { FormFileClass } from
|
|
4
|
-
import { toBoolAttrIfDefined } from
|
|
5
|
-
import { validateWcagLabelFor, validateWcagRef } from
|
|
6
|
-
import { canValidateWcagOnRender } from
|
|
7
|
-
import { fileAcceptValidation, fileSizeValidation, formatBytes } from
|
|
8
|
-
import { delay } from
|
|
9
|
-
import { govHost } from
|
|
10
|
-
import { govForm } from
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { createID } from "../../../utils/string.utils";
|
|
3
|
+
import { FormFileClass } from "./constants";
|
|
4
|
+
import { toBoolAttrIfDefined } from "../../../helpers/Dom/template";
|
|
5
|
+
import { validateWcagLabelFor, validateWcagRef } from "../../../helpers/Validate/wcag";
|
|
6
|
+
import { canValidateWcagOnRender } from "../../../helpers/Dom/win";
|
|
7
|
+
import { fileAcceptValidation, fileSizeValidation, formatBytes } from "../../../utils/file.utils";
|
|
8
|
+
import { delay } from "../../../utils/utils";
|
|
9
|
+
import { govHost } from "../../../helpers/Dom/template";
|
|
10
|
+
import { govForm } from "../../../helpers/Dom/form";
|
|
11
11
|
export class GovFormFile {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.expanded = false;
|
|
@@ -19,26 +19,26 @@ export class GovFormFile {
|
|
|
19
19
|
this.maxFileSize = -1;
|
|
20
20
|
this.identifier = undefined;
|
|
21
21
|
this.invalid = undefined;
|
|
22
|
-
this.errorSize =
|
|
23
|
-
this.errorAccept =
|
|
24
|
-
this.attachmentsLabel =
|
|
22
|
+
this.errorSize = "Soubor je větší než povolená velikost {FILE_SIZE}";
|
|
23
|
+
this.errorAccept = "Soubor tohoto typu není povolen";
|
|
24
|
+
this.attachmentsLabel = "Přílohy";
|
|
25
25
|
this.wcagDescribedBy = undefined;
|
|
26
26
|
this.wcagLabelledBy = undefined;
|
|
27
|
-
this.wcagRemoveLabel =
|
|
28
|
-
this.wcagAttachmentsLabel =
|
|
27
|
+
this.wcagRemoveLabel = "Odebrat soubor {FILE_NAME}";
|
|
28
|
+
this.wcagAttachmentsLabel = "Přílohy";
|
|
29
29
|
this.files = [];
|
|
30
|
-
this.fileId = createID(
|
|
30
|
+
this.fileId = createID("GovInputFile");
|
|
31
31
|
this.h = govHost(this.host);
|
|
32
32
|
this.f = govForm(this.h);
|
|
33
33
|
}
|
|
34
34
|
registerListeners() {
|
|
35
35
|
function highlight() {
|
|
36
|
-
this.areaRef.classList.add(
|
|
36
|
+
this.areaRef.classList.add("highlight");
|
|
37
37
|
}
|
|
38
38
|
function unhighlight() {
|
|
39
|
-
this.areaRef.classList.remove(
|
|
39
|
+
this.areaRef.classList.remove("highlight");
|
|
40
40
|
}
|
|
41
|
-
this.inputRef.addEventListener(
|
|
41
|
+
this.inputRef.addEventListener("change", e => {
|
|
42
42
|
e.preventDefault();
|
|
43
43
|
e.stopPropagation();
|
|
44
44
|
const files = e.target.files;
|
|
@@ -46,13 +46,13 @@ export class GovFormFile {
|
|
|
46
46
|
}, false);
|
|
47
47
|
//this.inputRef.addEventListener('focus')
|
|
48
48
|
if (this.expanded) {
|
|
49
|
-
const events = [
|
|
50
|
-
const inEvents = [
|
|
51
|
-
const outEvents = [
|
|
49
|
+
const events = ["dragover", "dragleave"];
|
|
50
|
+
const inEvents = ["dragenter", "dragover", "mouseenter"];
|
|
51
|
+
const outEvents = ["dragleave", "drop", "mouseleave"];
|
|
52
52
|
events.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false));
|
|
53
53
|
inEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false));
|
|
54
54
|
outEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false));
|
|
55
|
-
this.areaRef.addEventListener(
|
|
55
|
+
this.areaRef.addEventListener("drop", this.handleDrop.bind(this), false);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
preventDefaults(e) {
|
|
@@ -67,23 +67,29 @@ export class GovFormFile {
|
|
|
67
67
|
Array.from(files).map(file => {
|
|
68
68
|
const isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null;
|
|
69
69
|
if (isFile === null) {
|
|
70
|
-
const isSizeValid = typeof this.maxFileSize ===
|
|
70
|
+
const isSizeValid = typeof this.maxFileSize === "number" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true;
|
|
71
71
|
const isAcceptValid = fileAcceptValidation(file, this.accept);
|
|
72
72
|
const newFile = {
|
|
73
|
-
id: createID(
|
|
73
|
+
id: createID("GovFormFile"),
|
|
74
74
|
file,
|
|
75
75
|
acceptValid: isAcceptValid,
|
|
76
76
|
sizeValid: isSizeValid,
|
|
77
77
|
};
|
|
78
78
|
this.files = [...this.files, newFile];
|
|
79
|
-
this.govAddFile.emit(
|
|
79
|
+
this.govAddFile.emit({
|
|
80
|
+
component: FormFileClass.root,
|
|
81
|
+
file: newFile,
|
|
82
|
+
});
|
|
80
83
|
}
|
|
81
84
|
});
|
|
82
|
-
this.govFiles.emit(
|
|
85
|
+
this.govFiles.emit({
|
|
86
|
+
component: FormFileClass.root,
|
|
87
|
+
files: this.files,
|
|
88
|
+
});
|
|
83
89
|
}
|
|
84
90
|
componentWillLoad() {
|
|
85
|
-
this.f.passAttrToControl(
|
|
86
|
-
this.f.passAttrToLabel(
|
|
91
|
+
this.f.passAttrToControl("type", "File");
|
|
92
|
+
this.f.passAttrToLabel("required", String(this.required));
|
|
87
93
|
}
|
|
88
94
|
async componentDidRender() {
|
|
89
95
|
if (canValidateWcagOnRender()) {
|
|
@@ -93,7 +99,7 @@ export class GovFormFile {
|
|
|
93
99
|
this.registerListeners();
|
|
94
100
|
}
|
|
95
101
|
render() {
|
|
96
|
-
return (h(Host, { class: this.h.classes([FormFileClass.root]), invalid: toBoolAttrIfDefined(this.invalid), expanded: toBoolAttrIfDefined(this.expanded) }, h("div", { class: FormFileClass.area, ref: el => (this.areaRef = el) }, h("slot", null), h("input", { class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled, "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": toBoolAttrIfDefined(this.disabled) })), this.h.hasSlot(
|
|
102
|
+
return (h(Host, { class: this.h.classes([FormFileClass.root]), invalid: toBoolAttrIfDefined(this.invalid), expanded: toBoolAttrIfDefined(this.expanded) }, h("div", { class: FormFileClass.area, ref: el => (this.areaRef = el) }, h("slot", null), h("input", { class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled, "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": toBoolAttrIfDefined(this.disabled) })), this.h.hasSlot("attachments") ? (h("div", { class: FormFileClass.attachments }, h("slot", { name: "attachments" }))) : null, this.files.length && this.displayAttachments ? (h("div", { class: FormFileClass.attachments }, h("gov-attachments", { label: this.wcagAttachmentsLabel, "wcag-label": this.wcagAttachmentsLabel }, this.files.map(item => (h("gov-attachments-item", { "wcag-remove-labelled-by": item.id, "on-gov-remove": () => this.onRemoveFileHandler(item) }, h("span", { class: "sr-only", id: item.id }, this.wcagRemoveLabel.replace("{FILE_NAME}", item.file.name)), item.file.name, item.acceptValid === false ? (h("gov-form-message", { slot: "message", variant: "error" }, h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), item.acceptValid === false ? this.errorAccept : null)) : null, item.sizeValid === false ? (h("gov-form-message", { slot: "message", variant: "error" }, h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), this.errorSize.replace("{FILE_SIZE}", formatBytes(this.maxFileSize * 1024)))) : null, h("span", { slot: "info" }, "(", formatBytes(item.file.size), ")"))))))) : null));
|
|
97
103
|
}
|
|
98
104
|
onRemoveFileHandler(file) {
|
|
99
105
|
const index = this.files.findIndex(item => item.id === file.id);
|
|
@@ -102,27 +108,51 @@ export class GovFormFile {
|
|
|
102
108
|
const removeFile = this.files[index];
|
|
103
109
|
files.splice(index, 1);
|
|
104
110
|
this.files = [...files];
|
|
105
|
-
this.
|
|
106
|
-
|
|
111
|
+
this.govRemoveFile.emit({
|
|
112
|
+
component: FormFileClass.root,
|
|
113
|
+
file: removeFile,
|
|
114
|
+
});
|
|
115
|
+
this.govFiles.emit({
|
|
116
|
+
component: FormFileClass.root,
|
|
117
|
+
files,
|
|
118
|
+
});
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
121
|
onFocusHandler(e) {
|
|
110
122
|
e.stopPropagation();
|
|
111
|
-
this.govFocus.emit(
|
|
123
|
+
this.govFocus.emit({
|
|
124
|
+
component: FormFileClass.root,
|
|
125
|
+
originalEvent: e,
|
|
126
|
+
});
|
|
112
127
|
}
|
|
113
128
|
onBlurHandler(e) {
|
|
114
129
|
e.stopPropagation();
|
|
115
|
-
this.govBlur.emit(
|
|
130
|
+
this.govBlur.emit({
|
|
131
|
+
component: FormFileClass.root,
|
|
132
|
+
originalEvent: e,
|
|
133
|
+
});
|
|
116
134
|
}
|
|
117
135
|
onChangeHandler(e) {
|
|
118
136
|
e.stopPropagation();
|
|
119
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns the reference of the native element
|
|
140
|
+
*/
|
|
141
|
+
async getRef() {
|
|
142
|
+
return this.inputRef;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the reference of the native area element
|
|
146
|
+
*/
|
|
147
|
+
async getAreaRef() {
|
|
148
|
+
return this.areaRef;
|
|
149
|
+
}
|
|
120
150
|
/**
|
|
121
151
|
* Validate the WCAG attributes of the component
|
|
122
152
|
*/
|
|
123
153
|
async validateWcag() {
|
|
124
|
-
validateWcagRef(this.wcagDescribedBy,
|
|
125
|
-
validateWcagRef(this.wcagLabelledBy,
|
|
154
|
+
validateWcagRef(this.wcagDescribedBy, "wcag-described-by", FormFileClass.root);
|
|
155
|
+
validateWcagRef(this.wcagLabelledBy, "wcag-labelled-by", FormFileClass.root);
|
|
126
156
|
validateWcagLabelFor(this.identifier || this.fileId, this.wcagLabelledBy, FormFileClass.root);
|
|
127
157
|
}
|
|
128
158
|
static get is() { return "gov-form-file"; }
|
|
@@ -314,7 +344,7 @@ export class GovFormFile {
|
|
|
314
344
|
},
|
|
315
345
|
"attribute": "error-size",
|
|
316
346
|
"reflect": false,
|
|
317
|
-
"defaultValue": "
|
|
347
|
+
"defaultValue": "\"Soubor je v\u011Bt\u0161\u00ED ne\u017E povolen\u00E1 velikost {FILE_SIZE}\""
|
|
318
348
|
},
|
|
319
349
|
"errorAccept": {
|
|
320
350
|
"type": "string",
|
|
@@ -332,7 +362,7 @@ export class GovFormFile {
|
|
|
332
362
|
},
|
|
333
363
|
"attribute": "error-accept",
|
|
334
364
|
"reflect": false,
|
|
335
|
-
"defaultValue": "
|
|
365
|
+
"defaultValue": "\"Soubor tohoto typu nen\u00ED povolen\""
|
|
336
366
|
},
|
|
337
367
|
"attachmentsLabel": {
|
|
338
368
|
"type": "string",
|
|
@@ -350,7 +380,7 @@ export class GovFormFile {
|
|
|
350
380
|
},
|
|
351
381
|
"attribute": "attachments-label",
|
|
352
382
|
"reflect": false,
|
|
353
|
-
"defaultValue": "
|
|
383
|
+
"defaultValue": "\"P\u0159\u00EDlohy\""
|
|
354
384
|
},
|
|
355
385
|
"wcagDescribedBy": {
|
|
356
386
|
"type": "string",
|
|
@@ -402,7 +432,7 @@ export class GovFormFile {
|
|
|
402
432
|
},
|
|
403
433
|
"attribute": "wcag-remove-label",
|
|
404
434
|
"reflect": false,
|
|
405
|
-
"defaultValue": "
|
|
435
|
+
"defaultValue": "\"Odebrat soubor {FILE_NAME}\""
|
|
406
436
|
},
|
|
407
437
|
"wcagAttachmentsLabel": {
|
|
408
438
|
"type": "string",
|
|
@@ -420,7 +450,7 @@ export class GovFormFile {
|
|
|
420
450
|
},
|
|
421
451
|
"attribute": "wcag-attachments-label",
|
|
422
452
|
"reflect": false,
|
|
423
|
-
"defaultValue": "
|
|
453
|
+
"defaultValue": "\"P\u0159\u00EDlohy\""
|
|
424
454
|
}
|
|
425
455
|
};
|
|
426
456
|
}
|
|
@@ -441,11 +471,12 @@ export class GovFormFile {
|
|
|
441
471
|
"text": "Emitted when the File has focus."
|
|
442
472
|
},
|
|
443
473
|
"complexType": {
|
|
444
|
-
"original": "
|
|
445
|
-
"resolved": "
|
|
474
|
+
"original": "GovFormFileEvent",
|
|
475
|
+
"resolved": "GovFormFileEvent",
|
|
446
476
|
"references": {
|
|
447
|
-
"
|
|
448
|
-
"location": "
|
|
477
|
+
"GovFormFileEvent": {
|
|
478
|
+
"location": "import",
|
|
479
|
+
"path": "./gov-form-file.types"
|
|
449
480
|
}
|
|
450
481
|
}
|
|
451
482
|
}
|
|
@@ -460,11 +491,12 @@ export class GovFormFile {
|
|
|
460
491
|
"text": "Emitted when the File loses focus."
|
|
461
492
|
},
|
|
462
493
|
"complexType": {
|
|
463
|
-
"original": "
|
|
464
|
-
"resolved": "
|
|
494
|
+
"original": "GovFormFileEvent",
|
|
495
|
+
"resolved": "GovFormFileEvent",
|
|
465
496
|
"references": {
|
|
466
|
-
"
|
|
467
|
-
"location": "
|
|
497
|
+
"GovFormFileEvent": {
|
|
498
|
+
"location": "import",
|
|
499
|
+
"path": "./gov-form-file.types"
|
|
468
500
|
}
|
|
469
501
|
}
|
|
470
502
|
}
|
|
@@ -479,10 +511,10 @@ export class GovFormFile {
|
|
|
479
511
|
"text": "Called when the list of inserted files is changed"
|
|
480
512
|
},
|
|
481
513
|
"complexType": {
|
|
482
|
-
"original": "
|
|
483
|
-
"resolved": "
|
|
514
|
+
"original": "GovFormFileEvent",
|
|
515
|
+
"resolved": "GovFormFileEvent",
|
|
484
516
|
"references": {
|
|
485
|
-
"
|
|
517
|
+
"GovFormFileEvent": {
|
|
486
518
|
"location": "import",
|
|
487
519
|
"path": "./gov-form-file.types"
|
|
488
520
|
}
|
|
@@ -499,17 +531,17 @@ export class GovFormFile {
|
|
|
499
531
|
"text": "Called when a new file is added"
|
|
500
532
|
},
|
|
501
533
|
"complexType": {
|
|
502
|
-
"original": "
|
|
503
|
-
"resolved": "
|
|
534
|
+
"original": "GovFormFileEvent",
|
|
535
|
+
"resolved": "GovFormFileEvent",
|
|
504
536
|
"references": {
|
|
505
|
-
"
|
|
537
|
+
"GovFormFileEvent": {
|
|
506
538
|
"location": "import",
|
|
507
539
|
"path": "./gov-form-file.types"
|
|
508
540
|
}
|
|
509
541
|
}
|
|
510
542
|
}
|
|
511
543
|
}, {
|
|
512
|
-
"method": "
|
|
544
|
+
"method": "govRemoveFile",
|
|
513
545
|
"name": "gov-remove-file",
|
|
514
546
|
"bubbles": true,
|
|
515
547
|
"cancelable": true,
|
|
@@ -519,10 +551,10 @@ export class GovFormFile {
|
|
|
519
551
|
"text": "Called when a file is removed from the list"
|
|
520
552
|
},
|
|
521
553
|
"complexType": {
|
|
522
|
-
"original": "
|
|
523
|
-
"resolved": "
|
|
554
|
+
"original": "GovFormFileEvent",
|
|
555
|
+
"resolved": "GovFormFileEvent",
|
|
524
556
|
"references": {
|
|
525
|
-
"
|
|
557
|
+
"GovFormFileEvent": {
|
|
526
558
|
"location": "import",
|
|
527
559
|
"path": "./gov-form-file.types"
|
|
528
560
|
}
|
|
@@ -532,6 +564,44 @@ export class GovFormFile {
|
|
|
532
564
|
}
|
|
533
565
|
static get methods() {
|
|
534
566
|
return {
|
|
567
|
+
"getRef": {
|
|
568
|
+
"complexType": {
|
|
569
|
+
"signature": "() => Promise<HTMLInputElement>",
|
|
570
|
+
"parameters": [],
|
|
571
|
+
"references": {
|
|
572
|
+
"Promise": {
|
|
573
|
+
"location": "global"
|
|
574
|
+
},
|
|
575
|
+
"HTMLInputElement": {
|
|
576
|
+
"location": "global"
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
"return": "Promise<HTMLInputElement>"
|
|
580
|
+
},
|
|
581
|
+
"docs": {
|
|
582
|
+
"text": "Returns the reference of the native element",
|
|
583
|
+
"tags": []
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
"getAreaRef": {
|
|
587
|
+
"complexType": {
|
|
588
|
+
"signature": "() => Promise<HTMLDivElement>",
|
|
589
|
+
"parameters": [],
|
|
590
|
+
"references": {
|
|
591
|
+
"Promise": {
|
|
592
|
+
"location": "global"
|
|
593
|
+
},
|
|
594
|
+
"HTMLDivElement": {
|
|
595
|
+
"location": "global"
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
"return": "Promise<HTMLDivElement>"
|
|
599
|
+
},
|
|
600
|
+
"docs": {
|
|
601
|
+
"text": "Returns the reference of the native area element",
|
|
602
|
+
"tags": []
|
|
603
|
+
}
|
|
604
|
+
},
|
|
535
605
|
"validateWcag": {
|
|
536
606
|
"complexType": {
|
|
537
607
|
"signature": "() => Promise<void>",
|