@gov-design-system-ce/components 0.0.7 → 0.0.9
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/Fragment-52846f79.js +7 -0
- package/dist/cjs/Fragment-52846f79.js.map +1 -0
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/{form-49298257.js → form-02872a5e.js} +19 -7
- package/dist/cjs/form-02872a5e.js.map +1 -0
- package/dist/cjs/gov-app.cjs.entry.js +16 -21
- package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-button.cjs.entry.js +12 -1
- package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js +4 -0
- package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-checkbox.cjs.entry.js +27 -10
- package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-control.cjs.entry.js +2 -1
- package/dist/cjs/gov-form-control.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-file.cjs.entry.js +10 -2
- package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-group.cjs.entry.js +19 -1
- package/dist/cjs/gov-form-group.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-input.cjs.entry.js +9 -1
- package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-label.cjs.entry.js +2 -1
- package/dist/cjs/gov-form-label.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-multi-select.cjs.entry.js +8 -0
- package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-radio.cjs.entry.js +22 -5
- package/dist/cjs/gov-form-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-search.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-search.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-select.cjs.entry.js +3 -1
- package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-switch.cjs.entry.js +26 -9
- 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-pagination.cjs.entry.js +3 -4
- package/dist/cjs/gov-pagination.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-tile.cjs.entry.js +3 -2
- package/dist/cjs/gov-tile.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/gov-button/gov-button.js +12 -1
- package/dist/collection/components/gov-button/gov-button.js.map +1 -1
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +4 -0
- package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.css +4 -0
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js +53 -19
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js.map +1 -1
- package/dist/collection/components/gov-form/file/gov-form-file.js +8 -1
- package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
- package/dist/collection/components/gov-form/group/constants.js +3 -0
- package/dist/collection/components/gov-form/group/constants.js.map +1 -1
- package/dist/collection/components/gov-form/group/gov-form-group.js +49 -3
- package/dist/collection/components/gov-form/group/gov-form-group.js.map +1 -1
- package/dist/collection/components/gov-form/input/gov-form-input.js +7 -0
- package/dist/collection/components/gov-form/input/gov-form-input.js.map +1 -1
- package/dist/collection/components/gov-form/label/gov-form-label.js +20 -1
- package/dist/collection/components/gov-form/label/gov-form-label.js.map +1 -1
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +8 -0
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
- package/dist/collection/components/gov-form/radio/gov-form-radio.css +4 -0
- package/dist/collection/components/gov-form/radio/gov-form-radio.js +37 -3
- package/dist/collection/components/gov-form/radio/gov-form-radio.js.map +1 -1
- package/dist/collection/components/gov-form/search/gov-form-search.css +4 -0
- package/dist/collection/components/gov-form/select/gov-form-select.js +1 -0
- package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
- package/dist/collection/components/gov-form/switch/gov-form-switch.css +4 -0
- package/dist/collection/components/gov-form/switch/gov-form-switch.js +52 -18
- package/dist/collection/components/gov-form/switch/gov-form-switch.js.map +1 -1
- package/dist/collection/components/gov-pagination/gov-pagination.css +1 -0
- package/dist/collection/components/gov-tile/constants.js +1 -0
- package/dist/collection/components/gov-tile/constants.js.map +1 -1
- package/dist/collection/components/gov-tile/gov-tile.css +7 -3
- package/dist/collection/components/gov-tile/gov-tile.js +3 -6
- package/dist/collection/components/gov-tile/gov-tile.js.map +1 -1
- package/dist/collection/helpers/Dom/form.js +12 -0
- package/dist/collection/helpers/Dom/form.js.map +1 -1
- package/dist/collection/helpers/Dom/form.types.js.map +1 -1
- package/dist/collection/pages/Forms.js +16 -21
- package/dist/collection/pages/Forms.js.map +1 -1
- package/dist/components/Fragment.js +5 -0
- package/dist/components/Fragment.js.map +1 -0
- package/dist/components/form.js +12 -0
- package/dist/components/form.js.map +1 -1
- package/dist/components/gov-app.js +16 -21
- package/dist/components/gov-app.js.map +1 -1
- package/dist/components/gov-button2.js +12 -1
- package/dist/components/gov-button2.js.map +1 -1
- package/dist/components/gov-form-autocomplete2.js +4 -0
- package/dist/components/gov-form-autocomplete2.js.map +1 -1
- package/dist/components/gov-form-checkbox.js +26 -9
- package/dist/components/gov-form-checkbox.js.map +1 -1
- package/dist/components/gov-form-file.js +8 -1
- package/dist/components/gov-form-file.js.map +1 -1
- package/dist/components/gov-form-group.js +21 -2
- package/dist/components/gov-form-group.js.map +1 -1
- package/dist/components/gov-form-input2.js +7 -0
- package/dist/components/gov-form-input2.js.map +1 -1
- package/dist/components/gov-form-label.js +3 -1
- package/dist/components/gov-form-label.js.map +1 -1
- package/dist/components/gov-form-multi-select.js +8 -0
- package/dist/components/gov-form-multi-select.js.map +1 -1
- package/dist/components/gov-form-radio.js +21 -4
- package/dist/components/gov-form-radio.js.map +1 -1
- package/dist/components/gov-form-search.js +1 -1
- package/dist/components/gov-form-search.js.map +1 -1
- package/dist/components/gov-form-select2.js +1 -0
- package/dist/components/gov-form-select2.js.map +1 -1
- package/dist/components/gov-form-switch.js +25 -8
- package/dist/components/gov-form-switch.js.map +1 -1
- package/dist/components/gov-icon2.js +1 -1
- package/dist/components/gov-pagination.js +2 -3
- package/dist/components/gov-pagination.js.map +1 -1
- package/dist/components/gov-tile.js +3 -2
- package/dist/components/gov-tile.js.map +1 -1
- package/dist/core/core.css +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-ae3e2d60.entry.js → p-04fc18ab.entry.js} +2 -2
- package/dist/core/p-04fc18ab.entry.js.map +1 -0
- package/dist/core/{p-a2d0ff57.entry.js → p-159c9835.entry.js} +2 -2
- package/dist/core/p-159c9835.entry.js.map +1 -0
- package/dist/core/{p-1cc7b8d3.entry.js → p-1c06fb0b.entry.js} +2 -2
- package/dist/core/p-1c06fb0b.entry.js.map +1 -0
- package/dist/core/p-1c1d0bbe.js +2 -0
- package/dist/core/p-1c1d0bbe.js.map +1 -0
- package/dist/core/p-1db2ac17.entry.js +2 -0
- package/dist/core/p-1db2ac17.entry.js.map +1 -0
- package/dist/core/{p-e9c94ef7.entry.js → p-347b9f10.entry.js} +2 -2
- package/dist/core/{p-a0c491a6.entry.js → p-35c42aea.entry.js} +2 -2
- package/dist/core/{p-a0c491a6.entry.js.map → p-35c42aea.entry.js.map} +1 -1
- package/dist/core/p-44dc2ef4.entry.js +2 -0
- package/dist/core/p-44dc2ef4.entry.js.map +1 -0
- package/dist/core/p-6b69dbd3.entry.js +2 -0
- package/dist/core/p-6b69dbd3.entry.js.map +1 -0
- package/dist/core/p-6b928a53.entry.js +2 -0
- package/dist/core/p-6b928a53.entry.js.map +1 -0
- package/dist/core/p-71e57780.entry.js +2 -0
- package/dist/core/p-71e57780.entry.js.map +1 -0
- package/dist/core/{p-165fe5f4.entry.js → p-851939ff.entry.js} +2 -2
- package/dist/core/p-851939ff.entry.js.map +1 -0
- package/dist/core/p-9ceeba49.entry.js +2 -0
- package/dist/core/{p-86a3c0d5.entry.js.map → p-9ceeba49.entry.js.map} +1 -1
- package/dist/core/{p-ec617f18.entry.js → p-9d30e79e.entry.js} +2 -2
- package/dist/core/{p-ec617f18.entry.js.map → p-9d30e79e.entry.js.map} +1 -1
- package/dist/core/p-ac33c5ef.entry.js +2 -0
- package/dist/core/p-ac33c5ef.entry.js.map +1 -0
- package/dist/core/p-af40ceef.js +2 -0
- package/dist/core/p-af40ceef.js.map +1 -0
- package/dist/core/p-bba09987.entry.js +2 -0
- package/dist/core/p-bba09987.entry.js.map +1 -0
- package/dist/core/p-cc37a226.entry.js +2 -0
- package/dist/core/p-cc37a226.entry.js.map +1 -0
- package/dist/core/p-e582a589.entry.js +2 -0
- package/dist/core/{p-eb1214ab.entry.js.map → p-e582a589.entry.js.map} +1 -1
- package/dist/custom-elements/index.js +1 -1
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/Fragment-8d8d54fb.js +5 -0
- package/dist/esm/Fragment-8d8d54fb.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/{form-95b9a91b.js → form-e2e12619.js} +13 -1
- package/dist/esm/form-e2e12619.js.map +1 -0
- package/dist/esm/gov-app.entry.js +16 -21
- package/dist/esm/gov-app.entry.js.map +1 -1
- package/dist/esm/gov-button.entry.js +12 -1
- package/dist/esm/gov-button.entry.js.map +1 -1
- package/dist/esm/gov-form-autocomplete.entry.js +4 -0
- package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
- package/dist/esm/gov-form-checkbox.entry.js +27 -10
- package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
- package/dist/esm/gov-form-control.entry.js +2 -1
- package/dist/esm/gov-form-control.entry.js.map +1 -1
- package/dist/esm/gov-form-file.entry.js +10 -2
- package/dist/esm/gov-form-file.entry.js.map +1 -1
- package/dist/esm/gov-form-group.entry.js +20 -2
- package/dist/esm/gov-form-group.entry.js.map +1 -1
- package/dist/esm/gov-form-input.entry.js +9 -1
- package/dist/esm/gov-form-input.entry.js.map +1 -1
- package/dist/esm/gov-form-label.entry.js +2 -1
- package/dist/esm/gov-form-label.entry.js.map +1 -1
- package/dist/esm/gov-form-multi-select.entry.js +8 -0
- package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
- package/dist/esm/gov-form-radio.entry.js +22 -5
- package/dist/esm/gov-form-radio.entry.js.map +1 -1
- package/dist/esm/gov-form-search.entry.js +1 -1
- package/dist/esm/gov-form-search.entry.js.map +1 -1
- package/dist/esm/gov-form-select.entry.js +3 -1
- package/dist/esm/gov-form-select.entry.js.map +1 -1
- package/dist/esm/gov-form-switch.entry.js +26 -9
- package/dist/esm/gov-form-switch.entry.js.map +1 -1
- package/dist/esm/gov-icon.entry.js +1 -1
- package/dist/esm/gov-pagination.entry.js +2 -3
- package/dist/esm/gov-pagination.entry.js.map +1 -1
- package/dist/esm/gov-tile.entry.js +3 -2
- package/dist/esm/gov-tile.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/hydrate/index.js +167 -55
- package/dist/types/components/gov-button/gov-button.d.ts +2 -0
- package/dist/types/components/gov-form/checkbox/gov-form-checkbox.d.ts +9 -4
- package/dist/types/components/gov-form/file/gov-form-file.d.ts +1 -0
- package/dist/types/components/gov-form/group/constants.d.ts +4 -0
- package/dist/types/components/gov-form/group/gov-form-group.d.ts +10 -0
- package/dist/types/components/gov-form/label/gov-form-label.d.ts +4 -0
- package/dist/types/components/gov-form/radio/gov-form-radio.d.ts +6 -1
- package/dist/types/components/gov-form/switch/gov-form-switch.d.ts +9 -4
- package/dist/types/components/gov-tile/constants.d.ts +1 -0
- package/dist/types/components/gov-tile/gov-tile.d.ts +1 -2
- package/dist/types/components.d.ts +43 -4
- package/dist/types/helpers/Dom/form.types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/form-49298257.js.map +0 -1
- package/dist/core/p-0950ba85.entry.js +0 -2
- package/dist/core/p-0950ba85.entry.js.map +0 -1
- package/dist/core/p-165fe5f4.entry.js.map +0 -1
- package/dist/core/p-1cc7b8d3.entry.js.map +0 -1
- package/dist/core/p-22722ff3.entry.js +0 -2
- package/dist/core/p-22722ff3.entry.js.map +0 -1
- package/dist/core/p-54f367db.entry.js +0 -2
- package/dist/core/p-54f367db.entry.js.map +0 -1
- package/dist/core/p-692eb701.entry.js +0 -2
- package/dist/core/p-692eb701.entry.js.map +0 -1
- package/dist/core/p-76542f4f.js +0 -2
- package/dist/core/p-76542f4f.js.map +0 -1
- package/dist/core/p-86a3c0d5.entry.js +0 -2
- package/dist/core/p-8965f84a.entry.js +0 -2
- package/dist/core/p-8965f84a.entry.js.map +0 -1
- package/dist/core/p-a0dd0a95.entry.js +0 -2
- package/dist/core/p-a0dd0a95.entry.js.map +0 -1
- package/dist/core/p-a2d0ff57.entry.js.map +0 -1
- package/dist/core/p-ae3e2d60.entry.js.map +0 -1
- package/dist/core/p-ce78b591.entry.js +0 -2
- package/dist/core/p-ce78b591.entry.js.map +0 -1
- package/dist/core/p-da2b921e.entry.js +0 -2
- package/dist/core/p-da2b921e.entry.js.map +0 -1
- package/dist/core/p-eb1214ab.entry.js +0 -2
- package/dist/esm/form-95b9a91b.js.map +0 -1
- /package/dist/core/{p-e9c94ef7.entry.js.map → p-347b9f10.entry.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import { FormCheckboxSizesType } from
|
|
3
|
-
import { GovFormCheckboxChangeEvent } from
|
|
1
|
+
import { EventEmitter } from "../../../stencil-public-runtime";
|
|
2
|
+
import { FormCheckboxSizesType } from "./constants";
|
|
3
|
+
import { GovFormCheckboxChangeEvent } from "./interfaces";
|
|
4
4
|
export declare class GovFormCheckbox {
|
|
5
|
-
private h;
|
|
5
|
+
private readonly h;
|
|
6
6
|
private f;
|
|
7
7
|
private readonly checkboxId;
|
|
8
8
|
constructor();
|
|
@@ -37,6 +37,10 @@ export declare class GovFormCheckbox {
|
|
|
37
37
|
* Custom checkbox identifier.
|
|
38
38
|
*/
|
|
39
39
|
readonly identifier: string;
|
|
40
|
+
/**
|
|
41
|
+
* When you can't use the form label.
|
|
42
|
+
*/
|
|
43
|
+
readonly noLabel: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Indicates the entered value does not conform to the format expected by the application.
|
|
42
46
|
*/
|
|
@@ -69,6 +73,7 @@ export declare class GovFormCheckbox {
|
|
|
69
73
|
render(): any;
|
|
70
74
|
private onFocusHandler;
|
|
71
75
|
private onBlurHandler;
|
|
76
|
+
private onClickHandler;
|
|
72
77
|
private onChangeHandler;
|
|
73
78
|
/**
|
|
74
79
|
* Validate the WCAG attributes of the component
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { Sizes } from "../../../core/constants/sizes";
|
|
2
|
+
import { ValueOf } from "../../../types/interfaces";
|
|
3
|
+
export declare const FormGroupSizes: Pick<typeof Sizes, "_S" | "_M" | "_L" | "_2XS" | "_XS">;
|
|
4
|
+
export declare type FormGroupSizesType = `${ValueOf<typeof FormGroupSizes>}`;
|
|
1
5
|
export declare const FormGroupClass: {
|
|
2
6
|
root: string;
|
|
3
7
|
};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { FormGroupSizesType } from "./constants";
|
|
1
2
|
export declare class GovFormGroup {
|
|
3
|
+
private readonly h;
|
|
4
|
+
constructor();
|
|
5
|
+
host: HTMLGovFormGroupElement;
|
|
6
|
+
/**
|
|
7
|
+
* Gap's size.
|
|
8
|
+
*/
|
|
9
|
+
readonly gap?: FormGroupSizesType;
|
|
10
|
+
validateGap(newValue: string): void;
|
|
11
|
+
componentWillLoad(): void;
|
|
2
12
|
render(): any;
|
|
3
13
|
}
|
|
@@ -4,6 +4,10 @@ export declare class GovFormLabel {
|
|
|
4
4
|
* Identifier for label.
|
|
5
5
|
*/
|
|
6
6
|
readonly identifier: string;
|
|
7
|
+
/**
|
|
8
|
+
* Set whether the input is required or not.
|
|
9
|
+
*/
|
|
10
|
+
readonly required: boolean;
|
|
7
11
|
/**
|
|
8
12
|
* Use label as a legend for better accessibility.
|
|
9
13
|
* Note: Don't forget to set the fieldset attribute of the gov-form-control component
|
|
@@ -2,7 +2,7 @@ import { EventEmitter } from '../../../stencil-public-runtime';
|
|
|
2
2
|
import { FormRadioSizesType } from './constants';
|
|
3
3
|
import { GovFormRadioChangeEvent } from './interfaces';
|
|
4
4
|
export declare class GovFormRadio {
|
|
5
|
-
private h;
|
|
5
|
+
private readonly h;
|
|
6
6
|
private f;
|
|
7
7
|
private readonly radioId;
|
|
8
8
|
constructor();
|
|
@@ -11,6 +11,10 @@ export declare class GovFormRadio {
|
|
|
11
11
|
* Value of radio
|
|
12
12
|
*/
|
|
13
13
|
readonly value: string;
|
|
14
|
+
/**
|
|
15
|
+
* When you can't use the form label.
|
|
16
|
+
*/
|
|
17
|
+
readonly noLabel: boolean;
|
|
14
18
|
/**
|
|
15
19
|
* Radio default state
|
|
16
20
|
*/
|
|
@@ -67,6 +71,7 @@ export declare class GovFormRadio {
|
|
|
67
71
|
componentWillLoad(): void;
|
|
68
72
|
componentDidRender(): Promise<void>;
|
|
69
73
|
render(): any;
|
|
74
|
+
private onClickHandler;
|
|
70
75
|
private onFocusHandler;
|
|
71
76
|
private onBlurHandler;
|
|
72
77
|
private onChangeHandler;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import { FormSwitchSizesType } from
|
|
3
|
-
import { GovFormSwitchChangeEvent } from
|
|
1
|
+
import { EventEmitter } from "../../../stencil-public-runtime";
|
|
2
|
+
import { FormSwitchSizesType } from "./constants";
|
|
3
|
+
import { GovFormSwitchChangeEvent } from "./interfaces";
|
|
4
4
|
export declare class GovFormSwitch {
|
|
5
|
-
private h;
|
|
5
|
+
private readonly h;
|
|
6
6
|
private f;
|
|
7
7
|
private readonly checkboxId;
|
|
8
8
|
constructor();
|
|
@@ -11,6 +11,10 @@ export declare class GovFormSwitch {
|
|
|
11
11
|
* Value of switch
|
|
12
12
|
*/
|
|
13
13
|
readonly value: string;
|
|
14
|
+
/**
|
|
15
|
+
* When you can't use the form label.
|
|
16
|
+
*/
|
|
17
|
+
readonly noLabel: boolean;
|
|
14
18
|
/**
|
|
15
19
|
* Switch default state
|
|
16
20
|
*/
|
|
@@ -67,6 +71,7 @@ export declare class GovFormSwitch {
|
|
|
67
71
|
componentWillLoad(): void;
|
|
68
72
|
componentDidRender(): Promise<void>;
|
|
69
73
|
render(): any;
|
|
74
|
+
private onClickHandler;
|
|
70
75
|
private onFocusHandler;
|
|
71
76
|
private onBlurHandler;
|
|
72
77
|
private onChangeHandler;
|
|
@@ -18,6 +18,7 @@ import { FormCheckboxSizesType } from "./components/gov-form/checkbox/constants"
|
|
|
18
18
|
import { GovFormCheckboxChangeEvent } from "./components/gov-form/checkbox/interfaces";
|
|
19
19
|
import { FormControlSizesType } from "./components/gov-form/control/constants";
|
|
20
20
|
import { GovFormFileItem } from "./components/gov-form/file/gov-form-file.types";
|
|
21
|
+
import { FormGroupSizesType } from "./components/gov-form/group/constants";
|
|
21
22
|
import { FormInputSizesType, FormInputVariantType, InputType, Type } from "./components/gov-form/input/constants";
|
|
22
23
|
import { FormMessageVariantType } from "./components/gov-form/message/constants";
|
|
23
24
|
import { FormMultiselectSizesType, FormMultiselectVariantType } from "./components/gov-form/multiselect/constants";
|
|
@@ -560,6 +561,10 @@ export namespace Components {
|
|
|
560
561
|
* Name of the checkbox.
|
|
561
562
|
*/
|
|
562
563
|
"name": string;
|
|
564
|
+
/**
|
|
565
|
+
* When you can't use the form label.
|
|
566
|
+
*/
|
|
567
|
+
"noLabel": boolean;
|
|
563
568
|
/**
|
|
564
569
|
* 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. When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.
|
|
565
570
|
*/
|
|
@@ -687,6 +692,10 @@ export namespace Components {
|
|
|
687
692
|
"wcagRemoveLabel": string;
|
|
688
693
|
}
|
|
689
694
|
interface GovFormGroup {
|
|
695
|
+
/**
|
|
696
|
+
* Gap's size.
|
|
697
|
+
*/
|
|
698
|
+
"gap"?: FormGroupSizesType;
|
|
690
699
|
}
|
|
691
700
|
interface GovFormInput {
|
|
692
701
|
/**
|
|
@@ -825,6 +834,10 @@ export namespace Components {
|
|
|
825
834
|
* Use label as a legend for better accessibility. Note: Don't forget to set the fieldset attribute of the gov-form-control component
|
|
826
835
|
*/
|
|
827
836
|
"legend": boolean;
|
|
837
|
+
/**
|
|
838
|
+
* Set whether the input is required or not.
|
|
839
|
+
*/
|
|
840
|
+
"required": boolean;
|
|
828
841
|
}
|
|
829
842
|
interface GovFormMessage {
|
|
830
843
|
/**
|
|
@@ -925,6 +938,10 @@ export namespace Components {
|
|
|
925
938
|
* Name of the radio.
|
|
926
939
|
*/
|
|
927
940
|
"name": string;
|
|
941
|
+
/**
|
|
942
|
+
* When you can't use the form label.
|
|
943
|
+
*/
|
|
944
|
+
"noLabel": boolean;
|
|
928
945
|
/**
|
|
929
946
|
* 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. When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.
|
|
930
947
|
*/
|
|
@@ -1043,6 +1060,10 @@ export namespace Components {
|
|
|
1043
1060
|
* Name of the switch.
|
|
1044
1061
|
*/
|
|
1045
1062
|
"name": string;
|
|
1063
|
+
/**
|
|
1064
|
+
* When you can't use the form label.
|
|
1065
|
+
*/
|
|
1066
|
+
"noLabel": boolean;
|
|
1046
1067
|
/**
|
|
1047
1068
|
* 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. When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.
|
|
1048
1069
|
*/
|
|
@@ -1518,8 +1539,7 @@ export namespace Components {
|
|
|
1518
1539
|
}
|
|
1519
1540
|
interface GovTile {
|
|
1520
1541
|
/**
|
|
1521
|
-
*
|
|
1522
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href
|
|
1542
|
+
* Link on whole tile
|
|
1523
1543
|
*/
|
|
1524
1544
|
"href": string;
|
|
1525
1545
|
/**
|
|
@@ -2694,6 +2714,10 @@ declare namespace LocalJSX {
|
|
|
2694
2714
|
* Name of the checkbox.
|
|
2695
2715
|
*/
|
|
2696
2716
|
"name"?: string;
|
|
2717
|
+
/**
|
|
2718
|
+
* When you can't use the form label.
|
|
2719
|
+
*/
|
|
2720
|
+
"noLabel"?: boolean;
|
|
2697
2721
|
/**
|
|
2698
2722
|
* Emitted when the checkbox loses focus.
|
|
2699
2723
|
*/
|
|
@@ -2845,6 +2869,10 @@ declare namespace LocalJSX {
|
|
|
2845
2869
|
"wcagRemoveLabel"?: string;
|
|
2846
2870
|
}
|
|
2847
2871
|
interface GovFormGroup {
|
|
2872
|
+
/**
|
|
2873
|
+
* Gap's size.
|
|
2874
|
+
*/
|
|
2875
|
+
"gap"?: FormGroupSizesType;
|
|
2848
2876
|
}
|
|
2849
2877
|
interface GovFormInput {
|
|
2850
2878
|
/**
|
|
@@ -2983,6 +3011,10 @@ declare namespace LocalJSX {
|
|
|
2983
3011
|
* Emitted when the label click.
|
|
2984
3012
|
*/
|
|
2985
3013
|
"onGov-click"?: (event: GovFormLabelCustomEvent<PointerEvent>) => void;
|
|
3014
|
+
/**
|
|
3015
|
+
* Set whether the input is required or not.
|
|
3016
|
+
*/
|
|
3017
|
+
"required"?: boolean;
|
|
2986
3018
|
}
|
|
2987
3019
|
interface GovFormMessage {
|
|
2988
3020
|
/**
|
|
@@ -3075,6 +3107,10 @@ declare namespace LocalJSX {
|
|
|
3075
3107
|
* Name of the radio.
|
|
3076
3108
|
*/
|
|
3077
3109
|
"name"?: string;
|
|
3110
|
+
/**
|
|
3111
|
+
* When you can't use the form label.
|
|
3112
|
+
*/
|
|
3113
|
+
"noLabel"?: boolean;
|
|
3078
3114
|
/**
|
|
3079
3115
|
* Emitted when the radio loses focus.
|
|
3080
3116
|
*/
|
|
@@ -3197,6 +3233,10 @@ declare namespace LocalJSX {
|
|
|
3197
3233
|
* Name of the switch.
|
|
3198
3234
|
*/
|
|
3199
3235
|
"name"?: string;
|
|
3236
|
+
/**
|
|
3237
|
+
* When you can't use the form label.
|
|
3238
|
+
*/
|
|
3239
|
+
"noLabel"?: boolean;
|
|
3200
3240
|
/**
|
|
3201
3241
|
* Emitted when the switch loses focus.
|
|
3202
3242
|
*/
|
|
@@ -3628,8 +3668,7 @@ declare namespace LocalJSX {
|
|
|
3628
3668
|
}
|
|
3629
3669
|
interface GovTile {
|
|
3630
3670
|
/**
|
|
3631
|
-
*
|
|
3632
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href
|
|
3671
|
+
* Link on whole tile
|
|
3633
3672
|
*/
|
|
3634
3673
|
"href"?: string;
|
|
3635
3674
|
/**
|
|
@@ -2,7 +2,9 @@ import { GovHost } from './template.types';
|
|
|
2
2
|
export interface GovForm {
|
|
3
3
|
govHost: GovHost;
|
|
4
4
|
control: HTMLGovFormControlElement | null;
|
|
5
|
+
label: HTMLGovFormLabelElement | null;
|
|
5
6
|
passAttrToControl: (name: string, value: string) => void;
|
|
7
|
+
passAttrToLabel: (name: string, value: string) => void;
|
|
6
8
|
hasGroupChildren: boolean;
|
|
7
9
|
mainElementsInControl: Element[];
|
|
8
10
|
messageElements: HTMLGovFormMessageElement[];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name" : "@gov-design-system-ce/components",
|
|
3
3
|
"description" : "This package includes Gov Design System Web Components and related utilities.",
|
|
4
4
|
"author": "Zdeněk Vítek",
|
|
5
|
-
"version" : "0.0.
|
|
5
|
+
"version" : "0.0.9",
|
|
6
6
|
"license"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;MACD,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;KACpD;IACD,IAAI,qBAAqB;MACxB,MAAM,YAAY,GAAG;QACpB,eAAe,CAAC,IAAI;QACpB,cAAc,CAAC,IAAI;QACnB,eAAe,CAAC,IAAI;QACpB,iBAAiB,CAAC,IAAI;QACtB,cAAc,CAAC,IAAI;QACnBE,gCAAoB,CAAC,IAAI;QACzBC,iCAAqB,CAAC,IAAI;OAC1B,CAAA;MACD,IAAI,IAAI,CAAC,OAAO,EAAE;QACjB,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAA;OAC1D;MACD,OAAO,EAAE,CAAA;KACT;IACD,IAAI,eAAe;MAClB,IAAI,IAAI,CAAC,OAAO,EAAE;QACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAACC,0BAAgB,CAAC,IAAI,CAAC,CAAC,CAAA;OACvE;MACD,OAAO,EAAE,CAAA;KACT;GACD,CAAA;AACF;;;;;;;;;;;;;;;;;","names":["pick","Sizes","Variants","FormMultiSelectClass","FormAutocompleteClass","FormMessageClass"],"sources":["../../../packages/core/src/components/gov-form/checkbox/constants.ts","../../../packages/core/src/components/gov-form/control/constants.ts","../../../packages/core/src/components/gov-form/input/constants.ts","../../../packages/core/src/components/gov-form/select/constants.ts","../../../packages/core/src/components/gov-form/switch/constants.ts","../../../packages/core/src/components/gov-form/radio/constants.ts","../../../packages/core/src/helpers/Dom/form.ts"],"sourcesContent":["import { Sizes } from '../../../core/constants/sizes'\nimport { pick } from '../../../utils/utils'\nimport { ValueOf } from '../../../types/interfaces'\n\nexport const FormCheckboxSizes = pick(Sizes, ['_XS', '_S', '_M', '_L'])\nexport type FormCheckboxSizesType = `${ValueOf<typeof FormCheckboxSizes>}`\n\nexport const FormCheckboxClass = {\n\troot: 'gov-form-checkbox',\n\tcheck: 'gov-form-checkbox__check',\n}\n","import { Sizes } from '../../../core/constants/sizes'\nimport { pick } from '../../../utils/utils'\nimport { ValueOf } from '../../../types/interfaces'\n\nexport const FormControlSizes = pick(Sizes, ['_M', '_L', '_XL'])\nexport type FormControlSizesType = `${ValueOf<typeof FormControlSizes>}`\n\nexport const FormControlClass = {\n\troot: 'gov-form-control',\n\tholder: 'gov-form-control__holder',\n\tbottom: 'gov-form-control__bottom',\n}\n","import { Sizes } from '../../../core/constants/sizes'\nimport { Variants } from '../../../core/constants/variants'\nimport { pick } from '../../../utils/utils'\nimport { ValueOf } from '../../../types/interfaces'\n\nexport const FormInputSizes = pick(Sizes, ['_M', '_L', '_XL'])\nexport type FormInputSizesType = `${ValueOf<typeof FormInputSizes>}`\n\nexport const FormInputVariants = pick(Variants, ['PRIMARY', 'SECONDARY'])\nexport type FormInputVariantType = `${ValueOf<typeof FormInputVariants>}`\n\nexport enum InputTypes {\n\tCOLOR = 'color',\n\tDATE = 'date',\n\tDATETIME_LOCAL = 'datetime-local',\n\tEMAIL = 'email',\n\tMONTH = 'month',\n\tNUMBER = 'number',\n\tPASSWORD = 'password',\n\tSEARCH = 'search',\n\tTEL = 'tel',\n\tTEXT = 'text',\n\tTIME = 'time',\n\tURL = 'url',\n\tWEEK = 'week',\n}\n\nexport type InputType = `${ValueOf<typeof InputTypes>}`\n\nexport enum Type {\n\tRESET = 'reset',\n}\n\nexport type TypesType = `${ValueOf<typeof Type>}`\n\nexport const FormInputClass = {\n\troot: 'gov-form-input',\n}\n","import { Sizes } from '../../../core/constants/sizes'\nimport { Variants } from '../../../core/constants/variants'\nimport { pick } from '../../../utils/utils'\nimport { ValueOf } from '../../../types/interfaces'\n\nexport const FormSelectSizes = pick(Sizes, ['_M', '_L', '_XL'])\nexport type FormSelectSizesType = `${ValueOf<typeof FormSelectSizes>}`\n\nexport const FormSelectVariants = pick(Variants, ['PRIMARY', 'SECONDARY'])\nexport type FormSelectVariantType = `${ValueOf<typeof FormSelectVariants>}`\n\nexport const FormSelectClass = {\n\troot: 'gov-form-select',\n\ticon: 'gov-form-select__icon',\n}\n","import { Sizes } from '../../../core/constants/sizes'\nimport { ValueOf } from '../../../types/interfaces'\nimport { pick } from '../../../utils/utils'\n\nexport const FormSwitchSizes = pick(Sizes, ['_XS', '_S', '_M', '_L'])\nexport type FormSwitchSizesType = `${ValueOf<typeof FormSwitchSizes>}`\n\nexport const FormSwitchClass = {\n\troot: 'gov-form-switch',\n\tholder: 'gov-form-switch__holder',\n\tinput: 'gov-form-switch__input',\n\tindicator: 'gov-form-switch__indicator',\n}\n","import { Sizes } from '../../../core/constants/sizes'\nimport { pick } from '../../../utils/utils'\nimport { ValueOf } from '../../../types/interfaces'\n\nexport const FormRadioSizes = pick(Sizes, ['_XS', '_S', '_M', '_L'])\nexport type FormRadioSizesType = `${ValueOf<typeof FormRadioSizes>}`\n\nexport const FormRadioClass = {\n\troot: 'gov-form-radio',\n\tholder: 'gov-form-radio__holder',\n\tinput: 'gov-form-radio__input',\n\tindicator: 'gov-form-radio__indicator',\n}\n","import { GovHost } from './template.types'\nimport { GovForm } from './form.types'\nimport { FormControlClass } from '../../components/gov-form/control/constants'\nimport { FormInputClass } from '../../components/gov-form/input/constants'\nimport { FormSelectClass } from '../../components/gov-form/select/constants'\nimport { FormMultiSelectClass } from '../../components/gov-form/multiselect/constants'\nimport { FormSwitchClass } from '../../components/gov-form/switch/constants'\nimport { FormCheckboxClass } from '../../components/gov-form/checkbox/constants'\nimport { FormRadioClass } from '../../components/gov-form/radio/constants'\nimport { FormMessageClass } from '../../components/gov-form/message/constants'\nimport { FormAutocompleteClass } from '../../components/gov-form/autocomplete/constants'\nimport { Nullable } from '../../types/interfaces'\n\nexport const govForm = (govHost: GovHost): GovForm => {\n\treturn {\n\t\tget govHost(): GovHost {\n\t\t\treturn govHost\n\t\t},\n\t\tpassAttrToControl(name: string, value: string): void {\n\t\t\tif (this.control) {\n\t\t\t\tthis.control.setAttribute(name, value)\n\t\t\t}\n\t\t},\n\t\tget hasGroupChildren(): boolean {\n\t\t\tif (this.control) {\n\t\t\t\treturn this.control.querySelectorAll('gov-form-group > *').length > 1\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\t\tget control(): Nullable<HTMLGovFormControlElement> {\n\t\t\tif (this.govHost.name === FormControlClass.root) {\n\t\t\t\treturn this.govHost.hostElement\n\t\t\t}\n\t\t\treturn this.govHost.getParent(FormControlClass.root)\n\t\t},\n\t\tget mainElementsInControl(): Element[] {\n\t\t\tconst formElements = [\n\t\t\t\tFormSelectClass.root,\n\t\t\t\tFormInputClass.root,\n\t\t\t\tFormSwitchClass.root,\n\t\t\t\tFormCheckboxClass.root,\n\t\t\t\tFormRadioClass.root,\n\t\t\t\tFormMultiSelectClass.root,\n\t\t\t\tFormAutocompleteClass.root,\n\t\t\t]\n\t\t\tif (this.control) {\n\t\t\t\tconst elements = formElements.map(el => `${el}:first-of-type`).join(', ')\n\t\t\t\treturn Array.from(this.control.querySelectorAll(elements))\n\t\t\t}\n\t\t\treturn []\n\t\t},\n\t\tget messageElements(): HTMLGovFormMessageElement[] {\n\t\t\tif (this.control) {\n\t\t\t\treturn Array.from(this.control.querySelectorAll(FormMessageClass.root))\n\t\t\t}\n\t\t\treturn []\n\t\t},\n\t}\n}\n"],"version":3}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e,c as o,h as t,H as r,g as i}from"./p-682c7cc6.js";import{g as s,t as l}from"./p-3f37ddb6.js";import{g as c,k as a,l as n,m as v}from"./p-76542f4f.js";import{v as g}from"./p-26acf964.js";import{a as m,b as f}from"./p-364b4792.js";import{c as d}from"./p-c20102ff.js";import{c as h}from"./p-24636c53.js";import{d as p}from"./p-03990da5.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-ef79904e.js";import"./p-6278531b.js";import"./p-f687452c.js";import"./p-561fa17b.js";const u='.gov-spin-animation,.gov-pseudo-spin-animation::before{animation:spin 4s linear infinite}@keyframes spin{100%{transform:rotate(360deg)}}@keyframes countdown{to{transform:scaleX(0)}}.gov-form-select{position:relative;display:flex;width:100%;align-items:center}.gov-form-select .element{position:relative;flex:1 1 auto}.gov-form-select input,.gov-form-select select,.gov-form-select textarea{width:100%;border:var(--gov-form-input-border-width, 0.0625rem solid var(--gov-color-secondary-700));border-radius:var(--gov-border-radius, 0.1875rem);background-color:var(--gov-form-bg-color, var(--gov-color-neutral-white));color:var(--gov-form-input-color, var(--gov-color-secondary-700));font-family:var(--gov-font-family, "Roboto", sans-serif)}.gov-form-select input:focus,.gov-form-select select:focus,.gov-form-select textarea:focus{outline:none}.gov-form-select input:focus-visible,.gov-form-select select:focus-visible,.gov-form-select textarea:focus-visible{border-radius:var(--gov-border-radius, 0.1875rem);outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base);outline-offset:0}.gov-form-select input::-moz-placeholder,.gov-form-select select::-moz-placeholder,.gov-form-select textarea::-moz-placeholder{color:var(--gov-form-placeholder-color, var(--gov-color-secondary-600))}.gov-form-select input::placeholder,.gov-form-select select::placeholder,.gov-form-select textarea::placeholder{color:var(--gov-form-placeholder-color, var(--gov-color-secondary-600))}.gov-form-select textarea{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);padding:0.5rem 0.75rem;resize:none}.gov-form-select *[slot=left-icon],.gov-form-select *[slot=right-icon]{position:absolute;top:50%;display:flex;justify-content:center;color:var(--gov-form-input-icon-color, var(--gov-color-primary));transform:translateY(-50%);pointer-events:none}.gov-form-select *[slot=left-icon]{left:0}.gov-form-select *[slot=right-icon]{right:0}[disabled=""].gov-form-select,[disabled=true i].gov-form-select,[disabled="1"].gov-form-select{pointer-events:none}[disabled=""].gov-form-select input,[disabled=""].gov-form-select select,[disabled=""].gov-form-select textarea,[disabled=true i].gov-form-select input,[disabled=true i].gov-form-select select,[disabled=true i].gov-form-select textarea,[disabled="1"].gov-form-select input,[disabled="1"].gov-form-select select,[disabled="1"].gov-form-select textarea{border-color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600));background:var(--gov-form-input-disabled-bg, var(--gov-color-secondary-300));color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}[disabled=""].gov-form-select *[slot=left-icon],[disabled=""].gov-form-select *[slot=right-icon],[disabled=true i].gov-form-select *[slot=left-icon],[disabled=true i].gov-form-select *[slot=right-icon],[disabled="1"].gov-form-select *[slot=left-icon],[disabled="1"].gov-form-select *[slot=right-icon]{color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}[invalid=""].gov-form-select input,[invalid=""].gov-form-select select,[invalid=""].gov-form-select textarea,[invalid=true i].gov-form-select input,[invalid=true i].gov-form-select select,[invalid=true i].gov-form-select textarea,[invalid="1"].gov-form-select input,[invalid="1"].gov-form-select select,[invalid="1"].gov-form-select textarea{border-color:var(--gov-form-state-color-error, var(--gov-color-error));color:var(--gov-form-state-color-error, var(--gov-color-error))}[invalid=""].gov-form-select input::-moz-placeholder,[invalid=""].gov-form-select select::-moz-placeholder,[invalid=""].gov-form-select textarea::-moz-placeholder,[invalid=true i].gov-form-select input::-moz-placeholder,[invalid=true i].gov-form-select select::-moz-placeholder,[invalid=true i].gov-form-select textarea::-moz-placeholder,[invalid="1"].gov-form-select input::-moz-placeholder,[invalid="1"].gov-form-select select::-moz-placeholder,[invalid="1"].gov-form-select textarea::-moz-placeholder{color:var(--gov-form-state-color-error, var(--gov-color-error-300))}[invalid=""].gov-form-select input::placeholder,[invalid=""].gov-form-select select::placeholder,[invalid=""].gov-form-select textarea::placeholder,[invalid=true i].gov-form-select input::placeholder,[invalid=true i].gov-form-select select::placeholder,[invalid=true i].gov-form-select textarea::placeholder,[invalid="1"].gov-form-select input::placeholder,[invalid="1"].gov-form-select select::placeholder,[invalid="1"].gov-form-select textarea::placeholder{color:var(--gov-form-state-color-error, var(--gov-color-error-300))}[invalid=""].gov-form-select *[slot=left-icon],[invalid=""].gov-form-select *[slot=right-icon],[invalid=true i].gov-form-select *[slot=left-icon],[invalid=true i].gov-form-select *[slot=right-icon],[invalid="1"].gov-form-select *[slot=left-icon],[invalid="1"].gov-form-select *[slot=right-icon]{color:var(--gov-form-state-color-error, var(--gov-color-error))}[success=""].gov-form-select *[slot=right-icon],[success=true i].gov-form-select *[slot=right-icon],[success="1"].gov-form-select *[slot=right-icon]{color:var(--gov-form-state-color-success, var(--gov-color-success))}[success=""].gov-form-select *[slot=right-icon]:not(.icon-validation):not(.icon-arrow),[success=true i].gov-form-select *[slot=right-icon]:not(.icon-validation):not(.icon-arrow),[success="1"].gov-form-select *[slot=right-icon]:not(.icon-validation):not(.icon-arrow){display:none}[size=m].gov-form-select{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);gap:0.5rem var(--gov-form-input-core-m-icon-size, 1rem)}[size=m].gov-form-select input,[size=m].gov-form-select select{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);height:var(--gov-form-input-core-m-height, 2.5rem);padding:var(--gov-form-input-core-m-padding, 0.4375rem 0.75rem)}[size=m].gov-form-select *[slot=left-icon],[size=m].gov-form-select *[slot=right-icon]{width:var(--gov-form-input-core-m-icon-size, 1rem);height:var(--gov-form-input-core-m-icon-size, 1rem)}[size=m].gov-form-select *[slot=left-icon]{left:calc((var(--gov-form-input-core-m-icon-padding, 2.5rem) - var(--gov-form-input-core-m-icon-size, 1rem)) / 2)}[size=m].gov-form-select *[slot=left-icon]~input{padding-left:var(--gov-form-input-core-m-icon-padding, 2.5rem)}[size=m].gov-form-select *[slot=right-icon]{right:calc((var(--gov-form-input-core-m-icon-padding, 2.5rem) - var(--gov-form-input-core-m-icon-size, 1rem)) / 2)}[size=m].gov-form-select *[slot=right-icon]~input,[size=m].gov-form-select *[slot=right-icon]~select{padding-right:var(--gov-form-input-core-m-icon-padding, 2.5rem)}[size=l].gov-form-select{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);gap:0.5rem var(--gov-form-input-core-l-icon-size, 1rem)}[size=l].gov-form-select input,[size=l].gov-form-select select{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);height:var(--gov-form-input-core-l-height, 3rem);padding:var(--gov-form-input-core-l-padding, 0.6875rem 0.75rem)}[size=l].gov-form-select *[slot=left-icon],[size=l].gov-form-select *[slot=right-icon]{width:var(--gov-form-input-core-l-icon-size, 1rem);height:var(--gov-form-input-core-l-icon-size, 1rem)}[size=l].gov-form-select *[slot=left-icon]{left:calc((var(--gov-form-input-core-l-icon-padding, 2.5rem) - var(--gov-form-input-core-l-icon-size, 1rem)) / 2)}[size=l].gov-form-select *[slot=left-icon]~input{padding-left:var(--gov-form-input-core-l-icon-padding, 2.5rem)}[size=l].gov-form-select *[slot=right-icon]{right:calc((var(--gov-form-input-core-l-icon-padding, 2.5rem) - var(--gov-form-input-core-l-icon-size, 1rem)) / 2)}[size=l].gov-form-select *[slot=right-icon]~input,[size=l].gov-form-select *[slot=right-icon]~select{padding-right:var(--gov-form-input-core-l-icon-padding, 2.5rem)}[size=xl].gov-form-select{font-weight:var(--gov-text-l-font-weight);font-size:var(--gov-text-l-font-size);line-height:var(--gov-text-l-line-height);letter-spacing:var(--gov-text-l-letter-spacing);gap:0.5rem var(--gov-form-input-core-xl-icon-size, 1.25rem)}[size=xl].gov-form-select input,[size=xl].gov-form-select select{font-weight:var(--gov-text-l-font-weight);font-size:var(--gov-text-l-font-size);line-height:var(--gov-text-l-line-height);letter-spacing:var(--gov-text-l-letter-spacing);height:var(--gov-form-input-core-xl-height, 3.5rem);padding:var(--gov-form-input-core-xl-padding, 0.9375rem 1rem 0.875rem)}[size=xl].gov-form-select *[slot=left-icon],[size=xl].gov-form-select *[slot=right-icon]{width:var(--gov-form-input-core-xl-icon-size, 1.25rem);height:var(--gov-form-input-core-xl-icon-size, 1.25rem)}[size=xl].gov-form-select *[slot=left-icon]{left:calc((var(--gov-form-input-core-xl-icon-padding, 3rem) - var(--gov-form-input-core-xl-icon-size, 1.25rem)) / 2)}[size=xl].gov-form-select *[slot=left-icon]~input{padding-left:var(--gov-form-input-core-xl-icon-padding, 3rem)}[size=xl].gov-form-select *[slot=right-icon]{right:calc((var(--gov-form-input-core-xl-icon-padding, 3rem) - var(--gov-form-input-core-xl-icon-size, 1.25rem)) / 2)}[size=xl].gov-form-select *[slot=right-icon]~input,[size=xl].gov-form-select *[slot=right-icon]~select{padding-right:var(--gov-form-input-core-xl-icon-padding, 3rem)}.gov-form-select{background:none}.gov-form-select select{-webkit-appearance:none;-moz-appearance:none}.gov-form-select select::-ms-expand{display:none}[size=m].gov-form-select *[slot=right-icon]{right:var(--gov-form-select-m-arrow-right-position, 1rem);width:var(--gov-form-select-m-arrow-size, 0.5rem);height:var(--gov-form-select-m-arrow-size, 0.5rem)}[size=l].gov-form-select *[slot=right-icon]{right:var(--gov-form-select-l-arrow-right-position, 1rem);width:var(--gov-form-select-l-arrow-size, 0.5rem);height:var(--gov-form-select-l-arrow-size, 0.5rem)}[size=xl].gov-form-select *[slot=right-icon]{right:var(--gov-form-select-xl-arrow-right-position, 1.3125rem);width:var(--gov-form-select-xl-arrow-size, 0.625rem);height:var(--gov-form-select-xl-arrow-size, 0.625rem)}';const z=class{constructor(t){e(this,t);this.govFocus=o(this,"gov-focus",7);this.govBlur=o(this,"gov-blur",7);this.govChange=o(this,"gov-change",7);this.value=undefined;this.identifier=undefined;this.variant=undefined;this.size="m";this.name=undefined;this.required=false;this.disabled=undefined;this.invalid=undefined;this.wcagActiveDescendant=undefined;this.wcagControls=undefined;this.wcagDescribedBy=undefined;this.wcagLabelledBy=undefined;this.wcagOwns=undefined;this.focused=undefined;this.h=s(this.host);this.selectId=h("GovSelect");this.f=c(s(this.host))}validateVariant(e){g(n,e,a.root)}validateSize(e){g(v,e,a.root)}componentWillLoad(){this.validateVariant(this.variant);this.validateSize(this.size);this.host.querySelectorAll("option").forEach((e=>{if(e.value===this.value){e.setAttribute("selected","true")}}));this.f.passAttrToControl("type","select")}async componentDidRender(){if(d()){await p(500);await this.validateWcag()}}render(){return t(r,{class:a.root,size:this.size,variant:this.variant},this.h.hasSlot("prefix")&&t("slot",{name:"prefix"}),t("span",{class:"element"},t("gov-icon",{slot:"right-icon",name:"chevron-down"}),t("select",{id:this.identifier||this.selectId,onFocus:this.onFocusHandler.bind(this),onChange:this.onChangeHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,name:this.name,disabled:this.disabled,ref:e=>this.selectRef=e,"aria-disabled":l(this.disabled),"aria-activedescendant":this.wcagActiveDescendant,"aria-controls":this.wcagControls,"aria-required":l(this.required),"aria-invalid":l(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-owns":this.wcagOwns},t("slot",null))),this.h.hasSlot("sufix")&&t("slot",{name:"sufix"}))}onFocusHandler(e){this.focused=true;this.govFocus.emit(e)}onBlurHandler(e){this.focused=false;this.govBlur.emit(e)}onChangeHandler(e){this.value=e.target.value;e.stopPropagation();this.govChange.emit(e.target)}async setFocus(e){return this.selectRef.focus(e)}async setValue(e){this.value=e}async getInstance(){return this.selectRef}async validateWcag(){m(this.wcagActiveDescendant,"wcag-active-descendant",a.root);m(this.wcagControls,"wcag-controls",a.root);m(this.wcagDescribedBy,"wcag-described-by",a.root);m(this.wcagOwns,"wcag-owns",a.root);f(this.identifier||this.selectId,this.wcagLabelledBy,a.root)}get host(){return i(this)}static get watchers(){return{variant:["validateVariant"],size:["validateSize"]}}};z.style=u;export{z as gov_form_select};
|
|
2
|
-
//# sourceMappingURL=p-0950ba85.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/select/gov-form-select.scss?tag=gov-form-select","../../../packages/core/src/components/gov-form/select/gov-form-select.tsx"],"names":["govFormSelectCss","GovFormSelect","[object Object]","hostRef","this","h","govHost","host","selectId","createID","f","govForm","newValue","validateProp","FormSelectVariants","FormSelectClass","root","FormSelectSizes","validateVariant","variant","validateSize","size","querySelectorAll","forEach","option","value","setAttribute","passAttrToControl","canValidateWcagOnRender","delay","validateWcag","Host","class","hasSlot","name","slot","id","identifier","onFocus","onFocusHandler","bind","onChange","onChangeHandler","onBlur","onBlurHandler","required","disabled","ref","el","selectRef","aria-disabled","toBoolAttrIfDefined","aria-activedescendant","wcagActiveDescendant","aria-controls","wcagControls","aria-required","aria-invalid","invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-owns","wcagOwns","e","focused","govFocus","emit","govBlur","target","stopPropagation","govChange","options","focus","validateWcagRef","validateWcagLabelFor"],"mappings":"+eAAA,MAAMA,EAAmB,ixUCgBZC,EAAa,MAOzBC,YAAAC,yMAsB8C,sCAST,iOA9BpCC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,SAAWC,EAAS,aACzBL,KAAKM,EAAIC,EAAQL,EAAQF,KAAKG,OAyE/BL,gBAAgBU,GACfC,EAAaC,EAAoBF,EAAUG,EAAgBC,MAI5Dd,aAAaU,GACZC,EAAaI,EAAiBL,EAAUG,EAAgBC,MAGzDd,oBACCE,KAAKc,gBAAgBd,KAAKe,SAC1Bf,KAAKgB,aAAahB,KAAKiB,MAEvBjB,KAAKG,KAAKe,iBAAiB,UAAUC,SAASC,IAC7C,GAAIA,EAAOC,QAAUrB,KAAKqB,MAAO,CAChCD,EAAOE,aAAa,WAAY,YAIlCtB,KAAKM,EAAEiB,kBAAkB,OA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AMD,GAO7BvE,eAAeuB,GACdrB,KAAKqB,MAAQA,EAOdvB,oBACC,OAAOE,KAAK6C,UAOb/C,qBACCyE,EAAgBvE,KAAKiD,qBAAsB,yBAA0BtC,EAAgBC,MACrF2D,EAAgBvE,KAAKmD,aAAc,gBAAiBxC,EAAgBC,MACpE2D,EAAgBvE,KAAKwD,gBAAiB,oBAAqB7C,EAAgBC,MAC3E2D,EAAgBvE,KAAK4D,SAAU,YAAajD,EAAgBC,MAC5D4D,EAAqBxE,KAAKiC,YAAcjC,KAAKI,SAAUJ,KAAK0D,eAAgB/C,EAAgBC","sourcesContent":["/*\n * Select\n */\n\n@import \"../select/gov-form-select-core.scss\";\n\n$class: \".gov-form-select\";\n\n#{$class} {\n\t@extend %form-select-core;\n}\n","import { Component, Element, h, State, Prop, Event, EventEmitter, Watch, Host, Method } from '@stencil/core'\nimport { GovHost } from '../../../helpers/Dom/template.types'\nimport { toBoolAttrIfDefined, govHost } from '../../../helpers/Dom/template'\nimport { FormSelectSizesType, FormSelectVariants, FormSelectVariantType, FormSelectClass, FormSelectSizes } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { validateWcagLabelFor, validateWcagRef } from '../../../helpers/Validate/wcag'\nimport { canValidateWcagOnRender } from '../../../helpers/Dom/win'\nimport { createID } from '../../../utils/string.utils'\nimport { delay } from '../../../utils/utils'\nimport { GovForm } from '../../../helpers/Dom/form.types'\nimport { govForm } from '../../../helpers/Dom/form'\n\n@Component({\n\ttag: 'gov-form-select',\n\tstyleUrl: 'gov-form-select.scss',\n})\nexport class GovFormSelect {\n\tprivate f: GovForm\n\tprivate h: GovHost\n\tprivate selectRef?: HTMLSelectElement\n\n\tprivate readonly selectId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.selectId = createID('GovSelect')\n\t\tthis.f = govForm(govHost(this.host))\n\t}\n\n\t@Element() host: HTMLGovFormSelectElement\n\t/**\n\t * Value of select\n\t */\n\t@Prop({ reflect: true, mutable: true }) value: string\n\t/**\n\t * Custom select identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Style variation of the form select.\n\t */\n\t@Prop() readonly variant?: FormSelectVariantType\n\t/**\n\t * Select’s size.\n\t */\n\t@Prop() readonly size?: FormSelectSizesType = 'm'\n\t/**\n\t * Name of the select.\n\t */\n\t@Prop() readonly name: string\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 select component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\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 related component’s visually focused element.\n\t */\n\t@Prop({ attribute: 'wcag-active-descendant' }) readonly wcagActiveDescendant: string\n\t/**\n\t * Use this prop to add an aria-controls attribute. Use the attribute to indicate the id of a component controlled by this component.\n\t */\n\t@Prop({ attribute: 'wcag-controls' }) readonly wcagControls: string\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 * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the select has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the select loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the select change value.\n\t */\n\t@Event({ eventName: 'gov-change' }) govChange: EventEmitter\n\t@State() focused: boolean\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormSelectVariants, newValue, FormSelectClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSelectSizes, newValue, FormSelectClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\n\t\tthis.host.querySelectorAll('option').forEach((option: HTMLOptionElement) => {\n\t\t\tif (option.value === this.value) {\n\t\t\t\toption.setAttribute('selected', 'true')\n\t\t\t}\n\t\t})\n\n\t\tthis.f.passAttrToControl('type', 'select')\n\t}\n\n\tasync componentDidRender() {\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\treturn (\n\t\t\t<Host class={FormSelectClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t{this.h.hasSlot('prefix') && <slot name=\"prefix\"></slot>}\n\t\t\t\t<span class=\"element\">\n\t\t\t\t\t<gov-icon slot=\"right-icon\" name=\"chevron-down\"></gov-icon>\n\t\t\t\t\t<select\n\t\t\t\t\t\tid={this.identifier || this.selectId}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\tref={el => (this.selectRef = el as HTMLSelectElement)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\taria-activedescendant={this.wcagActiveDescendant}\n\t\t\t\t\t\taria-controls={this.wcagControls}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\taria-owns={this.wcagOwns}\n\t\t\t\t\t>\n\t\t\t\t\t\t<slot></slot>\n\t\t\t\t\t</select>\n\t\t\t\t</span>\n\t\t\t\t{this.h.hasSlot('sufix') && <slot name=\"sufix\"></slot>}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.value = (e.target as HTMLSelectElement).value\n\t\te.stopPropagation()\n\t\tthis.govChange.emit(e.target)\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.selectRef.focus(options)\n\t}\n\n\t/**\n\t * Sets the ordered value of the element\n\t */\n\t@Method()\n\tasync setValue(value: string): Promise<void> {\n\t\tthis.value = value\n\t}\n\n\t/**\n\t * Returns an instance of the native html select element\n\t */\n\t@Method()\n\tasync getInstance(): Promise<HTMLSelectElement> {\n\t\treturn this.selectRef\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.wcagActiveDescendant, 'wcag-active-descendant', FormSelectClass.root)\n\t\tvalidateWcagRef(this.wcagControls, 'wcag-controls', FormSelectClass.root)\n\t\tvalidateWcagRef(this.wcagDescribedBy, 'wcag-described-by', FormSelectClass.root)\n\t\tvalidateWcagRef(this.wcagOwns, 'wcag-owns', FormSelectClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.selectId, this.wcagLabelledBy, FormSelectClass.root)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.scss?tag=gov-form-multi-select","../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.tsx"],"names":["govFormMultiSelectCss","GovFormMultiSelect","[object Object]","hostRef","this","selectId","createID","listId","newValue","validateProp","FormMultiselectVariants","FormMultiSelectClass","root","FormMultiselectSizes","govChange","emit","validateVariant","variant","validateSize","size","Array","from","selectRef","querySelectorAll","filter","option","disabled","selected","map","name","textContent","value","autocompleteRef","addEventListener","onSelectHandler","bind","onInputHandler","onFocusHandler","onBlurHandler","setSearchCallback","Promise","resolve","data","getAvailableOptions","String","length","removeDiacritics","toLowerCase","indexOf","then","selectedOptions","findIndex","querySelector","newOption","index","getOptionIndex","getOptionElement","removeOption","splice","initAutocomplete","delay","forEach","selectOption","canValidateWcagOnRender","validateWcag","h","Host","class","wrap","identifier","required","invalid","placeholder","ref","el","minlength","wcagDescribedBy","wcagLabelledBy","wcagOwns","slot","hidden","aria-hidden","multiple","aria-disabled","toBoolAttrIfDefined","aria-required","aria-invalid","aria-describedby","aria-labelledby","aria-owns","role","id","list","item","wcagLabel","type","on-gov-click","onTagRemove","e","focused","govFocus","govBlur","target","stopPropagation","detail","clearValue","focus","options","validateWcagRef","validateWcagLabelFor"],"mappings":"sZAAA,MAAMA,EAAwB,gwXCejBC,EAAkB,MAO9BC,YAAAC,+MAqBmD,sCASd,2MAoCgB,GAjEpDC,KAAKC,SAAWC,EAAS,aACzBF,KAAKG,OAASD,EAAS,gBAmExBJ,gBAAgBM,GACfC,EAAaC,EAAyBF,EAAUG,EAAqBC,MAItEV,aAAaM,GACZC,EAAaI,EAAsBL,EAAUG,EAAqBC,MAInEV,WAAWM,GACVJ,KAAKU,UAAUC,KAAKP,GAGrBN,oBACCE,KAAKY,gBAAgBZ,KAAKa,SAC1Bb,KAAKc,aAAad,KAAKe,MAGhBjB,sBACP,OAAOkB,MAAMC,KAAKjB,KAAKkB,UAAUC,iB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-core.scss\";\n$class: \".gov-form-multi-select\";\n\n#{$class} {\n\t@extend %form-select-core;\n\tflex-wrap: wrap;\n\t&__wrap {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8);\n\t\twidth: 100%;\n\t}\n\t&__list {\n\t\t@extend %reset-ul;\n\t\t@include typography($font-size-xs);\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8);\n\t\tflex-wrap: wrap;\n\t}\n\t&__list > &__item {\n\t\t@extend %reset-ul-li;\n\t\tposition: relative;\n\t\tdisplay: flex;\n\t\tflex: 0 0 auto;\n\t\talign-items: center;\n\t\tpadding: rem-calc(0 0 0 8);\n\t\tbackground: $form-multiselect-bg;\n\t\ttransition: $t linear background-color;\n\t}\n}\n","import { Component, Element, h, State, Prop, Event, EventEmitter, Watch, Host, Method } from '@stencil/core'\nimport { toBoolAttrIfDefined } from '../../../helpers/Dom/template'\nimport { FormMultiselectSizesType, FormMultiselectVariants, FormMultiselectVariantType, FormMultiSelectClass, FormMultiselectSizes } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { validateWcagLabelFor, validateWcagRef } from '../../../helpers/Validate/wcag'\nimport { canValidateWcagOnRender } from '../../../helpers/Dom/win'\nimport { createID, removeDiacritics } from '../../../utils/string.utils'\nimport { delay } from '../../../utils/utils'\nimport { Nullable } from '../../../types/interfaces'\nimport { GovFormMultiSelectItem } from './interfaces'\n\n@Component({\n\ttag: 'gov-form-multi-select',\n\tstyleUrl: 'gov-form-multi-select.scss',\n})\nexport class GovFormMultiSelect {\n\tprivate selectRef?: HTMLSelectElement\n\tprivate autocompleteRef?: HTMLGovFormAutocompleteElement\n\n\tprivate readonly selectId: string\n\tprivate readonly listId: string\n\n\tconstructor() {\n\t\tthis.selectId = createID('GovSelect')\n\t\tthis.listId = createID('GovMultiList')\n\t}\n\n\t@Element() host: HTMLGovFormSelectElement\n\t/**\n\t * Custom select identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Custom select placeholder.\n\t */\n\t@Prop({ attribute: 'placeholder' }) readonly placeholder: string\n\t/**\n\t * Style variation of the form select.\n\t */\n\t@Prop() readonly variant?: FormMultiselectVariantType\n\t/**\n\t * Select’s size.\n\t */\n\t@Prop() readonly size?: FormMultiselectSizesType = 'm'\n\t/**\n\t * Name of the select.\n\t */\n\t@Prop() readonly name: string\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 select component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\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 * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the select has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the select loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the select change value.\n\t */\n\t@Event({ eventName: 'gov-change' }) govChange: EventEmitter<GovFormMultiSelectItem[]>\n\t@State() focused: boolean\n\t@State() value: string\n\t@State() selectedOptions: GovFormMultiSelectItem[] = []\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormMultiselectVariants, newValue, FormMultiSelectClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormMultiselectSizes, newValue, FormMultiSelectClass.root)\n\t}\n\n\t@Watch('selectedOptions')\n\temitChange(newValue: GovFormMultiSelectItem[]) {\n\t\tthis.govChange.emit(newValue)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\tprivate getAvailableOptions(): GovFormMultiSelectItem[] {\n\t\treturn Array.from(this.selectRef.querySelectorAll('option'))\n\t\t\t.filter((option: HTMLOptionElement) => !(option.disabled || option.selected))\n\t\t\t.map((option: HTMLOptionElement) => ({ name: option.textContent, value: option.value }))\n\t}\n\n\tprivate initAutocomplete() {\n\t\tthis.autocompleteRef.addEventListener('gov-select', this.onSelectHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener('gov-input', this.onInputHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener('gov-focus', this.onFocusHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener('gov-blur', this.onBlurHandler.bind(this))\n\t\tthis.autocompleteRef\n\t\t\t.setSearchCallback(value => {\n\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\tconst data = this.getAvailableOptions()\n\t\t\t\t\tif (String(value).length === 0) {\n\t\t\t\t\t\treturn resolve(data)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(\n\t\t\t\t\t\tdata.filter(({ name }) => {\n\t\t\t\t\t\t\tif (!name) return false\n\t\t\t\t\t\t\treturn removeDiacritics(name).toLowerCase().indexOf(removeDiacritics(value).toLowerCase()) > -1\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t})\n\t\t\t.then()\n\t}\n\n\tprivate getOptionIndex(value: GovFormMultiSelectItem): number {\n\t\treturn this.selectedOptions.findIndex(option => option.value === value.value && option.name === value.name)\n\t}\n\n\tprivate getOptionElement(value: GovFormMultiSelectItem): Nullable<HTMLOptionElement> {\n\t\treturn this.selectRef.querySelector('option[value=\"' + value.value + '\"]') as HTMLOptionElement\n\t}\n\n\tprivate selectOption(newOption: GovFormMultiSelectItem) {\n\t\tconst index = this.getOptionIndex(newOption)\n\t\tif (index === -1) {\n\t\t\tthis.selectedOptions = [...this.selectedOptions, newOption]\n\t\t\tconst option = this.getOptionElement(newOption)\n\t\t\tif (option) {\n\t\t\t\toption.selected = true\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeOption(removeOption: GovFormMultiSelectItem) {\n\t\tconst index = this.getOptionIndex(removeOption)\n\t\tif (index !== -1) {\n\t\t\tthis.selectedOptions.splice(index, 1)\n\t\t\tthis.selectedOptions = [...this.selectedOptions]\n\t\t\tconst option = this.getOptionElement(removeOption)\n\t\t\tif (option) {\n\t\t\t\toption.selected = false\n\t\t\t}\n\t\t}\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.initAutocomplete()\n\t\tawait delay(0)\n\t\tthis.selectRef.querySelectorAll('option').forEach((option: HTMLOptionElement) => {\n\t\t\tif (option.selected) {\n\t\t\t\tthis.selectOption({\n\t\t\t\t\tname: option.textContent,\n\t\t\t\t\tvalue: option.value,\n\t\t\t\t})\n\t\t\t}\n\t\t})\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\treturn (\n\t\t\t<Host class={FormMultiSelectClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<div class={FormMultiSelectClass.wrap}>\n\t\t\t\t\t<div class=\"element\">\n\t\t\t\t\t\t<gov-form-autocomplete\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\tidentifier={this.identifier || this.selectId}\n\t\t\t\t\t\t\trequired={false}\n\t\t\t\t\t\t\tsize={this.size}\n\t\t\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\t\t\tref={el => (this.autocompleteRef = el as HTMLGovFormAutocompleteElement)}\n\t\t\t\t\t\t\tminlength={0}\n\t\t\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\t\t\twcagOwns={this.listId}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<gov-icon slot=\"right-icon\" class=\"icon-arrow\" name=\"chevron-down\"></gov-icon>\n\t\t\t\t\t\t<select\n\t\t\t\t\t\t\thidden\n\t\t\t\t\t\t\taria-hidden={true}\n\t\t\t\t\t\t\tmultiple\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\tref={el => (this.selectRef = el as HTMLSelectElement)}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\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-owns={this.wcagOwns}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<slot></slot>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<ul role=\"listbox\" id={this.listId} class={FormMultiSelectClass.list}>\n\t\t\t\t\t{this.selectedOptions.map(option => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li class={FormMultiSelectClass.item} role=\"option\">\n\t\t\t\t\t\t\t\t{option.name}\n\t\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\t\twcagLabel={'Odebrat vybranou položku ' + option.name}\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\t\tsize=\"s\"\n\t\t\t\t\t\t\t\t\ton-gov-click={() => this.onTagRemove(option)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\"></gov-icon>\n\t\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onInputHandler(e: Event) {\n\t\tthis.value = (e.target as HTMLSelectElement).value\n\t\te.stopPropagation()\n\t}\n\n\tprivate onSelectHandler(e: CustomEvent) {\n\t\tconst value = e.detail as GovFormMultiSelectItem\n\t\tthis.selectOption(value)\n\t\tthis.value = ''\n\t\tthis.autocompleteRef.clearValue()\n\t\tthis.autocompleteRef.focus()\n\t}\n\n\tprivate onTagRemove(removeOption: GovFormMultiSelectItem) {\n\t\tthis.removeOption(removeOption)\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.selectRef.focus(options)\n\t}\n\n\t/**\n\t * Sets the ordered value of the element\n\t */\n\t@Method()\n\tasync setValue(value: string): Promise<void> {\n\t\tthis.value = value\n\t}\n\n\t/**\n\t * Returns an instance of the native html select element\n\t */\n\t@Method()\n\tasync getInstance(): Promise<HTMLSelectElement> {\n\t\treturn this.selectRef\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', FormMultiSelectClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormMultiSelectClass.root)\n\t\tvalidateWcagRef(this.wcagOwns, 'wcag-owns', FormMultiSelectClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.selectId, this.wcagLabelledBy, FormMultiSelectClass.root)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/utils/bool.utils.ts","../../../packages/core/src/components/gov-button/gov-button.scss?tag=gov-button","../../../packages/core/src/components/gov-button/gov-button.tsx"],"names":["toBool","value","indexOf","govButtonCss","Tags","GovButton","[object Object]","hostRef","this","h","govHost","host","newValue","validateProp","ButtonVariants","ButtonClass","root","Type","Sizes","NativeType","validateVariant","variant","validateType","type","validateSize","size","validateNativeType","nativeType","canValidateWcagOnRender","delay","validateWcag","classNames","prepareClasses","hasSlot","rootWithIcon","Tag","href","A","BUTTON","undefined","Host","hoverable","class","classes","inverse","ref","el","buttonRef","onClick","onClickHandler","bind","onFocus","govFocus","emit","onBlur","govBlur","onMouseDown","isPressed","onMouseUp","disabled","id","identifier","target","download","hreflang","rel","name","tabindex","focusable","aria-activedescendant","wcagActiveDescendant","aria-describedby","aria-description","wcagDescription","aria-controls","wcagControls","aria-details","wcagDetails","aria-expanded","toBoolAttrIfDefined","wcagExpanded","aria-label","wcagLabel","aria-labelledby","wcagLabelledBy","aria-owns","wcagOwns","aria-haspopup","wcagHasPopup","aria-pressed","toBoolAttr","aria-disabled","aria-current","wcagCurrent","loading","e","stopPropagation","govClick","focus","validateWcagRef","validateWcagLabel"],"mappings":"8bAAgBA,EAAOC,GACtB,UAAWA,IAAU,SAAU,CAC9B,MAAO,CAAC,OAAQ,OAAQ,OAAQ,KAAKC,QAAQD,MAAY,OACnD,UAAWA,IAAU,SAAU,CACrC,OAAOA,EAAQ,OACT,UAAWA,IAAU,UAAW,CACtC,OAAOA,MACD,CACN,OAAOA,EAAQ,KAAO,OCRxB,MAAME,EAAe,68wECWrB,IAAKC,GAAL,SAAKA,GACJA,EAAA,KAAA,IACAA,EAAA,UAAA,UAFD,CAAKA,IAAA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FmF,EAAgB3F,KAAKmE,aAAc,gBAAiB5D,EAAYC,MAChEmF,EAAgB3F,KAAKqE,YAAa,eAAgB9D,EAAYC,MAC9DmF,EAAgB3F,KAAK8E,SAAU,YAAavE,EAAYC,MACxDmF,EAAgB3F,KAAKgF,aAAc,gBAAiBzE,EAAYC,MAChEoF,EAAkB5F,KAAK0E,UAAW1E,KAAK4E,eAAgBrE,EAAYC","sourcesContent":["export function toBool(value: any): boolean {\n\tif (typeof value === 'string') {\n\t\treturn ['true', 'True', 'TRUE', '1'].indexOf(value) !== -1\n\t} else if (typeof value === 'number') {\n\t\treturn value > 0\n\t} else if (typeof value === 'boolean') {\n\t\treturn value\n\t} else {\n\t\treturn value ? true : false\n\t}\n}\n","/*\n * Button\n */\n\n// Shared definitions - BUTTON & badge\n@import \"./gov-button-core.scss\";\n\n.gov-button {\n\t@extend %button-core;\n\tdisplay: inline-block;\n\t.element {\n\t\tborder-radius: #{$border-radius};\n\t}\n\n\t&[type=\"link\"] {\n\t\t.element {\n\t\t\tpadding: 0;\n\t\t\ttext-decoration: underline;\n\t\t\tline-height: inherit;\n\t\t\tmin-height: inherit;\n\t\t\t@include hover() {\n\t\t\t\ttext-decoration: none;\n\t\t\t}\n\t\t}\n\t}\n\n\t// STATES\n\t&[loading=\"true\"],\n\t&[loading=\"1\"] {\n\t\t.element {\n\t\t\t> .gov-icon:not(.gov-spin-animation),\n\t\t\t> gov-icon:not(.gov-spin-animation) {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $button-sizes {\n\t\t// Loading state\n\t\t&:not(&--w-icon)[loading=\"0\"][size=\"#{$size}\"],\n\t\t&:not(&--w-icon)[loading=\"false\"][size=\"#{$size}\"],\n\t\t&:not(&--w-icon)[loading=\"\"][size=\"#{$size}\"]\n\t\t&:not[type=\"link\"] {\n\t\t\t.element {\n\t\t\t\tpadding: get(\"padding-y\", $definitions)\n\t\t\t\t\tcalc(get(\"padding-x\", $definitions) + (get(\"padding-x\", $definitions) / 2) + (get(\"icon-size\", $definitions) / 2));\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core'\nimport { validateProp } from '../../helpers/Validate/props'\nimport { ButtonSizesType, NativeTypesType, TypesType, ButtonVariants, ButtonVariantType, ButtonClass, Type, NativeType, ButtonTargetType } from './constants'\nimport { govHost, toBoolAttr, toBoolAttrIfDefined, prepareClasses } from '../../helpers/Dom/template'\nimport { GovHost } from '../../helpers/Dom/template.types'\nimport { toBool } from '../../utils/bool.utils'\nimport { Sizes } from '../../core/constants/sizes'\nimport { validateWcagLabel, validateWcagRef } from '../../helpers/Validate/wcag'\nimport { canValidateWcagOnRender } from '../../helpers/Dom/win'\nimport { delay } from '../../utils/utils'\n\nenum Tags {\n\tA = 'a',\n\tBUTTON = 'button',\n}\n\n@Component({\n\ttag: 'gov-button',\n\tstyleUrl: 'gov-button.scss',\n})\nexport class GovButton {\n\tprivate h: GovHost\n\tprivate buttonRef?: HTMLButtonElement\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovButtonElement\n\n\t/**\n\t * Style variation of the button\n\t */\n\t@Prop({reflect: true}) readonly variant?: ButtonVariantType\n\t/**\n\t * Button’s size\n\t */\n\t@Prop({reflect: true}) readonly size?: ButtonSizesType = 'm'\n\t/**\n\t * Button's type\n\t */\n\t@Prop({reflect: true}) readonly type?: TypesType = 'solid'\n\t/**\n\t * Expands the button to fill 100% of the container width\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Determine if component should have inversed colors to be used on dark background\n\t */\n\t@Prop() readonly inverse: boolean = false\n\t/**\n\t * The name of the button, which gets paired with the button's value when submitted as part of a form. Corresponds with the native HTML name attribute\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Makes the button component disabled.\n\t * This prevents users from being able to interact with the button, and conveys its inactive state to assistive technologies\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type\n\t */\n\t@Prop() readonly nativeType?: NativeTypesType = 'button'\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href\n\t */\n\t@Prop() readonly href: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target\n\t */\n\t@Prop() readonly target?: ButtonTargetType\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download\n\t */\n\t@Prop() readonly download: boolean\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-hreflang\n\t */\n\t@Prop() readonly hreflang: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-referrerpolicy\n\t */\n\t@Prop() readonly referrerpolicy: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-rel\n\t */\n\t@Prop() readonly rel: string\n\t/**\n\t * Indicates whether an asynchronous process is running\n\t */\n\t@Prop() readonly loading: string\n\t/**\n\t * Same as original parametr\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/focusable\n\t */\n\t@Prop() readonly focusable: boolean = true\n\t/**\n\t * Custom button identifier\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Indicates the id of a related component’s visually focused element\n\t */\n\t@Prop({ attribute: 'wcag-active-descendant' }) readonly wcagActiveDescendant: string\n\t/**\n\t * Use this property to add an aria-controls attribute to the button. Use the attribute to point to the unique id of the content that the button manages\n\t */\n\t@Prop({ attribute: 'wcag-controls' }) readonly wcagControls: string\n\t/**\n\t * Indicates the id of a component that describes the button\n\t */\n\t@Prop({ attribute: 'wcag-described-by' }) readonly wcagDescribedBy: string\n\t/**\n\t * Aria description the button\n\t */\n\t@Prop({ attribute: 'wcag-description' }) readonly wcagDescription: string\n\t/**\n\t * Details of the component\n\t */\n\t@Prop({ attribute: 'wcag-details' }) readonly wcagDetails: string\n\t/**\n\t * If a button expands or collapses adjacent content, then use the ariaExpanded prop to add the aria-expanded attribute to the button\n\t * Set the value to convey the current expanded (true) or collapsed (false) state of the content\n\t */\n\t@Prop({ attribute: 'wcag-expanded' }) readonly wcagExpanded: boolean\n\t/**\n\t * Adds accessible label for the button that is only shown for screen readers\n\t * Typically, this label text replaces the visible text on the button for users who use assistive technology\n\t */\n\t@Prop({ attribute: 'wcag-label' }) readonly wcagLabel: string\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: 'wcag-labelled-by' }) readonly wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component owned by the button\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * \tUse this property to add an aria-haspopup attribute to a button, if you are using it as a menu button\n\t */\n\t@Prop({ attribute: 'wcag-has-popup' }) readonly wcagHasPopup: string\n\t/**\n\t * Tells screen reader the element is pressed\n\t */\n\t@Prop({ attribute: 'wcag-pressed' }) readonly wcagPressed: string\n\t/**\n\t * Indicates the current item within a container or set of related elements\n\t */\n\t@Prop({ attribute: 'wcag-current' }) readonly wcagCurrent: string\n\t/**\n\t * Emitted when the button click\n\t */\n\t@Event({ eventName: 'gov-click' }) govClick: EventEmitter<PointerEvent>\n\t/**\n\t * Emitted when the button has focus\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the button loses focus\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(ButtonVariants, newValue, ButtonClass.root)\n\t}\n\n\t@Watch('type')\n\tvalidateType(newValue: string): void {\n\t\tvalidateProp(Type, newValue, ButtonClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(Sizes, newValue, ButtonClass.root)\n\t}\n\n\t@Watch('nativeType')\n\tvalidateNativeType(newValue: string): void {\n\t\tvalidateProp(NativeType, newValue, ButtonClass.root)\n\t}\n\n\t@State() isPressed = false\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateType(this.type)\n\t\tthis.validateSize(this.size)\n\t\tthis.validateNativeType(this.nativeType)\n\t}\n\n\tasync componentDidRender() {\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\tget classNames(): string {\n\t\tconst { h } = this\n\n\t\treturn prepareClasses([ButtonClass.root, h.hasSlot('left-icon') && ButtonClass.rootWithIcon, h.hasSlot('right-icon') && ButtonClass.rootWithIcon])\n\t}\n\n\trender() {\n\t\tconst Tag = this.href ? Tags.A : Tags.BUTTON\n\t\tconst nativeType = Tag === Tags.A ? undefined : this.nativeType\n\n\t\treturn (\n\t\t\t<Host hoverable={true} size={this.size} variant={this.variant} class={this.h.classes(this.classNames)} type={this.type} inverse={this.inverse}>\n\t\t\t\t<Tag\n\t\t\t\t\tclass=\"element\"\n\t\t\t\t\tref={el => (this.buttonRef = el as HTMLButtonElement)}\n\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\tonFocus={() => this.govFocus.emit()}\n\t\t\t\t\tonBlur={() => this.govBlur.emit()}\n\t\t\t\t\tonMouseDown={() => (this.isPressed = true)}\n\t\t\t\t\tonMouseUp={() => (this.isPressed = false)}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\tid={this.identifier}\n\t\t\t\t\thref={this.href}\n\t\t\t\t\ttarget={this.target}\n\t\t\t\t\tdownload={this.download}\n\t\t\t\t\threflang={this.hreflang}\n\t\t\t\t\trel={this.rel}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\ttype={nativeType}\n\t\t\t\t\ttabindex={this.focusable ? '0' : '-1'}\n\t\t\t\t\taria-activedescendant={this.wcagActiveDescendant}\n\t\t\t\t\taria-describedby={this.wcagActiveDescendant}\n\t\t\t\t\taria-description={this.wcagDescription}\n\t\t\t\t\taria-controls={this.wcagControls}\n\t\t\t\t\taria-details={this.wcagDetails}\n\t\t\t\t\taria-expanded={toBoolAttrIfDefined(this.wcagExpanded)}\n\t\t\t\t\taria-label={this.wcagLabel}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\taria-owns={this.wcagOwns}\n\t\t\t\t\taria-haspopup={toBoolAttrIfDefined(this.wcagHasPopup)}\n\t\t\t\t\taria-pressed={toBoolAttr(this.isPressed)}\n\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\taria-current={this.wcagCurrent}\n\t\t\t\t>\n\t\t\t\t\t{toBool(this.loading) && !this.h.hasSlot('right-icon') && <gov-icon name=\"loader\" class=\"gov-spin-animation\"></gov-icon>}\n\t\t\t\t\t{this.h.hasSlot('left-icon') && <slot name=\"left-icon\"></slot>}\n\t\t\t\t\t<slot />\n\t\t\t\t\t{this.h.hasSlot('right-icon') && <slot name=\"right-icon\"></slot>}\n\t\t\t\t\t{toBool(this.loading) && this.h.hasSlot('right-icon') && <gov-icon name=\"loader\" class=\"gov-spin-animation\"></gov-icon>}\n\t\t\t\t</Tag>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent): void {\n\t\te.stopPropagation()\n\t\tif (this.disabled === false) {\n\t\t\tthis.govClick.emit(e)\n\t\t}\n\t}\n\n\t/**\n\t * Focus button element\n\t */\n\t@Method()\n\tasync setFocus(): Promise<void> {\n\t\tthis.buttonRef.focus()\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\tif (this.focusable) {\n\t\t\tvalidateWcagRef(this.wcagActiveDescendant, 'aria-activedescendant', ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagControls, 'aria-controls', ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagDetails, 'aria-details', ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagOwns, 'aria-owns', ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagHasPopup, 'aria-haspopup', ButtonClass.root)\n\t\t\tvalidateWcagLabel(this.wcagLabel, this.wcagLabelledBy, ButtonClass.root)\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,c as r,h as e,H as i,g as a}from"./p-682c7cc6.js";import{c as t}from"./p-24636c53.js";import{v as s}from"./p-26acf964.js";import{g as c,c as v,d as n}from"./p-76542f4f.js";import{g as d,t as m}from"./p-3f37ddb6.js";import{a as g,b as f}from"./p-364b4792.js";import{c as l}from"./p-c20102ff.js";import{d as h}from"./p-03990da5.js";import{F as p}from"./p-27977727.js";import"./p-561fa17b.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-ef79904e.js";import"./p-6278531b.js";import"./p-f687452c.js";const b='.gov-spin-animation,.gov-pseudo-spin-animation::before{animation:spin 4s linear infinite}@keyframes spin{100%{transform:rotate(360deg)}}@keyframes countdown{to{transform:scaleX(0)}}.gov-form-radio{cursor:pointer}.gov-form-radio input{position:absolute;top:0;left:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gov-form-radio input+span{position:relative;display:block}.gov-form-radio input+span::before{content:"";position:absolute;display:block;top:0;left:0;border:var(--gov-form-checkbox-border-size, 0.125rem solid var(--gov-color-primary));transition:150ms linear border-color, 150ms linear background-color, 150ms linear outline-color}.gov-form-radio .gov-form-label__label{position:relative;z-index:1;width:100%}.gov-form-radio input:focus-visible+span::before{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}[invalid=""].gov-form-radio .gov-form-label__label,[invalid=true i].gov-form-radio .gov-form-label__label,[invalid="1"].gov-form-radio .gov-form-label__label{color:var(--gov-form-state-color-error, var(--gov-color-error))}[invalid=""].gov-form-radio input+span::before,[invalid=true i].gov-form-radio input+span::before,[invalid="1"].gov-form-radio input+span::before{border-color:var(--gov-form-state-color-error, var(--gov-color-error))}[disabled=""].gov-form-radio,[disabled=true i].gov-form-radio,[disabled="1"].gov-form-radio{pointer-events:none}[disabled=""].gov-form-radio .gov-form-label__label,[disabled=true i].gov-form-radio .gov-form-label__label,[disabled="1"].gov-form-radio .gov-form-label__label{color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}[disabled=""].gov-form-radio input+span::before,[disabled=true i].gov-form-radio input+span::before,[disabled="1"].gov-form-radio input+span::before{border-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400))}[size=xs].gov-form-radio{font-weight:var(--gov-text-xs-font-weight);font-size:var(--gov-text-xs-font-size);line-height:var(--gov-text-xs-line-height);letter-spacing:var(--gov-text-xs-letter-spacing);min-width:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem);min-height:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem)}[size=xs].gov-form-radio .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-text-xs-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) + var(--gov-form-checkbox-core-xs-gap, 0.75rem))}[size=xs].gov-form-radio input+span::before{width:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem);height:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem)}[size=s].gov-form-radio{font-weight:var(--gov-text-s-font-weight);font-size:var(--gov-text-s-font-size);line-height:var(--gov-text-s-line-height);letter-spacing:var(--gov-text-s-letter-spacing);min-width:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem);min-height:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem)}[size=s].gov-form-radio .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-text-s-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) + var(--gov-form-checkbox-core-s-gap, 0.75rem))}[size=s].gov-form-radio input+span::before{width:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem);height:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem)}[size=m].gov-form-radio{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);min-width:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem);min-height:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem)}[size=m].gov-form-radio .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-text-m-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) + var(--gov-form-checkbox-core-m-gap, 1rem))}[size=m].gov-form-radio input+span::before{width:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem);height:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem)}[size=l].gov-form-radio{font-weight:var(--gov-text-l-font-weight);font-size:var(--gov-text-l-font-size);line-height:var(--gov-text-l-line-height);letter-spacing:var(--gov-text-l-letter-spacing);min-width:var(--gov-form-checkbox-core-l-indicator-size, 2rem);min-height:var(--gov-form-checkbox-core-l-indicator-size, 2rem)}[size=l].gov-form-radio .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-text-l-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-l-indicator-size, 2rem) + var(--gov-form-checkbox-core-l-gap, 1rem))}[size=l].gov-form-radio input+span::before{width:var(--gov-form-checkbox-core-l-indicator-size, 2rem);height:var(--gov-form-checkbox-core-l-indicator-size, 2rem)}.gov-form-radio input+span::before{border-radius:50%}.gov-form-radio input+span::after{content:"";position:absolute;display:block;border-radius:50%;background:var(--gov-form-radio-indicator-bg, var(--gov-color-primary));opacity:0;transition:150ms linear opacity}.gov-form-radio input:checked+span::after{opacity:1}.gov-form-radio[invalid=""] input+span::after,.gov-form-radio[invalid=true i] input+span::after,.gov-form-radio[invalid="1"] input+span::after{background:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-radio[disabled=""] input:checked+span::after,.gov-form-radio[disabled=true i] input:checked+span::after,.gov-form-radio[disabled="1"] input:checked+span::after{background-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400))}.gov-form-radio[size=xs] input+span::after{top:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-form-checkbox-core-xs-dot-size, 0.625rem)) / 2);left:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-form-checkbox-core-xs-dot-size, 0.625rem)) / 2);width:var(--gov-form-checkbox-core-xs-dot-size, 0.625rem);height:var(--gov-form-checkbox-core-xs-dot-size, 0.625rem)}.gov-form-radio[size=s] input+span::after{top:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-form-checkbox-core-s-dot-size, 0.6875rem)) / 2);left:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-form-checkbox-core-s-dot-size, 0.6875rem)) / 2);width:var(--gov-form-checkbox-core-s-dot-size, 0.6875rem);height:var(--gov-form-checkbox-core-s-dot-size, 0.6875rem)}.gov-form-radio[size=m] input+span::after{top:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-form-checkbox-core-m-dot-size, 0.75rem)) / 2);left:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-form-checkbox-core-m-dot-size, 0.75rem)) / 2);width:var(--gov-form-checkbox-core-m-dot-size, 0.75rem);height:var(--gov-form-checkbox-core-m-dot-size, 0.75rem)}.gov-form-radio[size=l] input+span::after{top:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-form-checkbox-core-l-dot-size, 1rem)) / 2);left:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-form-checkbox-core-l-dot-size, 1rem)) / 2);width:var(--gov-form-checkbox-core-l-dot-size, 1rem);height:var(--gov-form-checkbox-core-l-dot-size, 1rem)}';const x=class{constructor(e){o(this,e);this.govFocus=r(this,"gov-focus",7);this.govBlur=r(this,"gov-blur",7);this.govChange=r(this,"gov-change",7);this.value=undefined;this.checked=false;this.required=false;this.disabled=undefined;this.name=undefined;this.size="m";this.identifier=undefined;this.invalid=undefined;this.wcagDescribedBy=undefined;this.wcagLabelledBy=undefined;this.isChecked=undefined;this.radioId=t("GovRadio");this.h=d(this.host);this.f=c(this.h)}updateCheckedState(o){this.isChecked=o;this.govChange.emit({checked:this.isChecked,value:this.value})}validateSize(o){s(n,o,v.root)}componentWillLoad(){this.isChecked=this.checked;this.f.passAttrToControl("type","radio");this.h.passChildAttr(p.root,"identifier",this.identifier||this.radioId)}async componentDidRender(){if(l()){await h(500);await this.validateWcag()}}render(){const{isChecked:o}=this;return e(i,{class:v.root,"is-checked":o,size:this.size,invalid:m(this.invalid)},e("div",{class:v.holder},e("input",{class:v.input,id:this.identifier||this.radioId,type:"radio",value:this.value,name:this.name,checked:this.isChecked,onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,"aria-checked":this.isChecked,"aria-required":m(this.required),"aria-invalid":m(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":m(this.disabled)}),e("span",null,e("slot",{name:"label"}))))}onFocusHandler(o){this.govFocus.emit(o)}onBlurHandler(o){this.govBlur.emit(o)}onChangeHandler(o){this.isChecked=o.target.checked;o.stopPropagation();this.govChange.emit({checked:this.isChecked,value:this.value})}async validateWcag(){g(this.wcagDescribedBy,"wcag-described-by",v.root);g(this.wcagLabelledBy,"wcag-labelled-by",v.root);f(this.identifier||this.radioId,this.wcagLabelledBy,v.root)}get host(){return a(this)}static get watchers(){return{checked:["updateCheckedState"],size:["validateSize"]}}};x.style=b;export{x as gov_form_radio};
|
|
2
|
-
//# sourceMappingURL=p-22722ff3.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/radio/gov-form-radio.scss?tag=gov-form-radio","../../../packages/core/src/components/gov-form/radio/gov-form-radio.tsx"],"names":["govFormRadioCss","GovFormRadio","[object Object]","hostRef","this","radioId","createID","h","govHost","host","f","govForm","newValue","isChecked","govChange","emit","checked","value","validateProp","FormRadioSizes","FormRadioClass","root","passAttrToControl","passChildAttr","FormLabelClass","identifier","canValidateWcagOnRender","delay","validateWcag","Host","class","is-checked","size","invalid","toBoolAttrIfDefined","holder","input","id","type","name","onChange","onChangeHandler","bind","onFocus","onFocusHandler","onBlur","onBlurHandler","required","aria-checked","aria-required","aria-invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-disabled","disabled","e","govFocus","govBlur","target","stopPropagation","validateWcagRef","validateWcagLabelFor"],"mappings":"4gBAAA,MAAMA,EAAkB,4tOCmBXC,EAAY,MAMxBC,YAAAC,2JAeqD,oBAKhB,4DAaQ,2IAhC5CC,KAAKC,QAAUC,EAAS,YAExBF,KAAKG,EAAIC,EAAQJ,KAAKK,MACtBL,KAAKM,EAAIC,EAAQP,KAAKG,GA8DvBL,mBAAmBU,GAClBR,KAAKS,UAAYD,EACjBR,KAAKU,UAAUC,KAAK,CACnBC,QAASZ,KAAKS,UACdI,MAAOb,KAAKa,QAKdf,aAAaU,GACZM,EAAaC,EAAgBP,EAAUQ,EAAeC,MAGvDnB,oBACCE,KAAKS,UAAYT,KAAKY,QAEtBZ,KAAKM,EAAEY,kBAAkB,OAAQ,SACjClB,KAAKG,EAAEgB,cAAcC,EAAeH,KAAM,aAAcjB,KAAKqB,YAAcrB,KAAKC,SAGjFH,2BACC,GAAIwB,IAA2B,OACxBC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checkbox/gov-form-checkbox-core.scss\";\n$class: \".gov-form-radio\";\n\n#{$class} {\n\t@extend %form-checkbox-core;\n\tinput + span {\n\t\t&::before {\n\t\t\tborder-radius: 50%;\n\t\t}\n\t\t&::after {\n\t\t\t@include pseudo();\n\t\t\tborder-radius: 50%;\n\t\t\tbackground: $form-radio-indicator-bg;\n\t\t\topacity: 0;\n\t\t\ttransition: $t linear opacity;\n\t\t}\n\t}\n\n\t// STATES\n\tinput:checked + span::after {\n\t\topacity: 1;\n\t}\n\t@include parameter(\"invalid\") {\n\t\tinput + span::after {\n\t\t\tbackground: $form-state-color-error;\n\t\t}\n\t}\n\t@include parameter(\"disabled\") {\n\t\tinput:checked + span::after {\n\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $form-checkbox-core-sizes {\n\t\t&[size=\"#{$size}\"] {\n\t\t\tinput + span::after {\n\t\t\t\ttop: calc((get(\"indicator-size\", $definitions) - get(\"dot-size\", $definitions)) / 2);\n\t\t\t\tleft: calc((get(\"indicator-size\", $definitions) - get(\"dot-size\", $definitions)) / 2);\n\t\t\t\twidth: get(\"dot-size\", $definitions);\n\t\t\t\theight: get(\"dot-size\", $definitions);\n\t\t\t}\n\t\t}\n\t}\n}\n","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 { FormRadioClass, FormRadioSizes, FormRadioSizesType } 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 } from '../../../helpers/Dom/template'\nimport { GovHost } from '../../../helpers/Dom/template.types'\nimport { govForm } from '../../../helpers/Dom/form'\nimport { FormLabelClass } from '../label/constants'\nimport { GovFormRadioChangeEvent } from './interfaces'\n\n@Component({\n\ttag: 'gov-form-radio',\n\tstyleUrl: 'gov-form-radio.scss',\n})\nexport class GovFormRadio {\n\tprivate h: GovHost\n\tprivate f: GovForm\n\n\tprivate readonly radioId: string\n\n\tconstructor() {\n\t\tthis.radioId = createID('GovRadio')\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormRadioElement\n\t/**\n\t * Value of radio\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Radio 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 radio component disabled.\n\t * This prevents users from being able to interact with the radio, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the radio.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Radio's size.\n\t */\n\t@Prop() readonly size?: FormRadioSizesType = 'm'\n\t/**\n\t * Custom radio identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\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 radio has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the radio loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the radio change value.\n\t */\n\t@Event({ eventName: 'gov-change' }) govChange: EventEmitter<GovFormRadioChangeEvent>\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(FormRadioSizes, newValue, FormRadioClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.isChecked = this.checked\n\n\t\tthis.f.passAttrToControl('type', 'radio')\n\t\tthis.h.passChildAttr(FormLabelClass.root, 'identifier', this.identifier || this.radioId)\n\t}\n\n\tasync componentDidRender() {\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\n\t\treturn (\n\t\t\t<Host class={FormRadioClass.root} is-checked={isChecked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormRadioClass.holder}>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormRadioClass.input}\n\t\t\t\t\t\tid={this.identifier || this.radioId}\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tchecked={this.isChecked}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\taria-checked={this.isChecked}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.govBlur.emit(e)\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', FormRadioClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormRadioClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.radioId, this.wcagLabelledBy, FormRadioClass.root)\n\t}\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,c as e,h as r,H as c,g as i}from"./p-682c7cc6.js";import{c as a}from"./p-24636c53.js";import{v as t}from"./p-26acf964.js";import{g as s,F as h,a as v}from"./p-76542f4f.js";import{g as m,a as n,t as g}from"./p-3f37ddb6.js";import{a as f,b as l}from"./p-364b4792.js";import{c as b}from"./p-c20102ff.js";import{d}from"./p-03990da5.js";import{F as k}from"./p-27977727.js";import"./p-561fa17b.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-ef79904e.js";import"./p-6278531b.js";import"./p-f687452c.js";const x='.gov-spin-animation,.gov-pseudo-spin-animation::before{animation:spin 4s linear infinite}@keyframes spin{100%{transform:rotate(360deg)}}@keyframes countdown{to{transform:scaleX(0)}}.gov-form-checkbox{cursor:pointer}.gov-form-checkbox input{position:absolute;top:0;left:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gov-form-checkbox input+span{position:relative;display:block}.gov-form-checkbox input+span::before{content:"";position:absolute;display:block;top:0;left:0;border:var(--gov-form-checkbox-border-size, 0.125rem solid var(--gov-color-primary));transition:150ms linear border-color, 150ms linear background-color, 150ms linear outline-color}.gov-form-checkbox .gov-form-label__label{position:relative;z-index:1;width:100%}.gov-form-checkbox input:focus-visible+span::before{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}[invalid=""].gov-form-checkbox .gov-form-label__label,[invalid=true i].gov-form-checkbox .gov-form-label__label,[invalid="1"].gov-form-checkbox .gov-form-label__label{color:var(--gov-form-state-color-error, var(--gov-color-error))}[invalid=""].gov-form-checkbox input+span::before,[invalid=true i].gov-form-checkbox input+span::before,[invalid="1"].gov-form-checkbox input+span::before{border-color:var(--gov-form-state-color-error, var(--gov-color-error))}[disabled=""].gov-form-checkbox,[disabled=true i].gov-form-checkbox,[disabled="1"].gov-form-checkbox{pointer-events:none}[disabled=""].gov-form-checkbox .gov-form-label__label,[disabled=true i].gov-form-checkbox .gov-form-label__label,[disabled="1"].gov-form-checkbox .gov-form-label__label{color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}[disabled=""].gov-form-checkbox input+span::before,[disabled=true i].gov-form-checkbox input+span::before,[disabled="1"].gov-form-checkbox input+span::before{border-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400))}[size=xs].gov-form-checkbox{font-weight:var(--gov-text-xs-font-weight);font-size:var(--gov-text-xs-font-size);line-height:var(--gov-text-xs-line-height);letter-spacing:var(--gov-text-xs-letter-spacing);min-width:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem);min-height:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem)}[size=xs].gov-form-checkbox .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-text-xs-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) + var(--gov-form-checkbox-core-xs-gap, 0.75rem))}[size=xs].gov-form-checkbox input+span::before{width:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem);height:var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem)}[size=s].gov-form-checkbox{font-weight:var(--gov-text-s-font-weight);font-size:var(--gov-text-s-font-size);line-height:var(--gov-text-s-line-height);letter-spacing:var(--gov-text-s-letter-spacing);min-width:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem);min-height:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem)}[size=s].gov-form-checkbox .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-text-s-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) + var(--gov-form-checkbox-core-s-gap, 0.75rem))}[size=s].gov-form-checkbox input+span::before{width:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem);height:var(--gov-form-checkbox-core-s-indicator-size, 1.375rem)}[size=m].gov-form-checkbox{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);min-width:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem);min-height:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem)}[size=m].gov-form-checkbox .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-text-m-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) + var(--gov-form-checkbox-core-m-gap, 1rem))}[size=m].gov-form-checkbox input+span::before{width:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem);height:var(--gov-form-checkbox-core-m-indicator-size, 1.5rem)}[size=l].gov-form-checkbox{font-weight:var(--gov-text-l-font-weight);font-size:var(--gov-text-l-font-size);line-height:var(--gov-text-l-line-height);letter-spacing:var(--gov-text-l-letter-spacing);min-width:var(--gov-form-checkbox-core-l-indicator-size, 2rem);min-height:var(--gov-form-checkbox-core-l-indicator-size, 2rem)}[size=l].gov-form-checkbox .gov-form-label__label{padding-top:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-text-l-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-checkbox-core-l-indicator-size, 2rem) + var(--gov-form-checkbox-core-l-gap, 1rem))}[size=l].gov-form-checkbox input+span::before{width:var(--gov-form-checkbox-core-l-indicator-size, 2rem);height:var(--gov-form-checkbox-core-l-indicator-size, 2rem)}.gov-form-checkbox input+span::before{border-radius:var(--gov-border-radius, 0.1875rem)}.gov-form-checkbox__check{position:absolute;color:var(--gov-form-checkbox-check-color, var(--gov-color-neutral-white));opacity:0;transition:150ms linear opacity}.gov-form-checkbox input:checked+span::before{background:var(--gov-form-checkbox-indicator-bg, var(--gov-color-primary))}input:checked+span .gov-form-checkbox__check{opacity:1}.gov-form-checkbox[invalid=""] input:checked+span::before,.gov-form-checkbox[invalid=true i] input:checked+span::before,.gov-form-checkbox[invalid="1"] input:checked+span::before{background:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-checkbox[disabled=""] input:checked+span::before,.gov-form-checkbox[disabled=true i] input:checked+span::before,.gov-form-checkbox[disabled="1"] input:checked+span::before{border-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400));background-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400))}.gov-form-checkbox[size=xs] .gov-form-checkbox__check{top:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-form-checkbox-core-xs-check-size, 0.75rem)) / 2);left:calc((var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) - var(--gov-form-checkbox-core-xs-check-size, 0.75rem)) / 2);width:var(--gov-form-checkbox-core-xs-check-size, 0.75rem);height:var(--gov-form-checkbox-core-xs-check-size, 0.75rem)}.gov-form-checkbox[size=s] .gov-form-checkbox__check{top:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-form-checkbox-core-s-check-size, 0.825rem)) / 2);left:calc((var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) - var(--gov-form-checkbox-core-s-check-size, 0.825rem)) / 2);width:var(--gov-form-checkbox-core-s-check-size, 0.825rem);height:var(--gov-form-checkbox-core-s-check-size, 0.825rem)}.gov-form-checkbox[size=m] .gov-form-checkbox__check{top:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-form-checkbox-core-m-check-size, 0.9rem)) / 2);left:calc((var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) - var(--gov-form-checkbox-core-m-check-size, 0.9rem)) / 2);width:var(--gov-form-checkbox-core-m-check-size, 0.9rem);height:var(--gov-form-checkbox-core-m-check-size, 0.9rem)}.gov-form-checkbox[size=l] .gov-form-checkbox__check{top:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-form-checkbox-core-l-check-size, 1.2rem)) / 2);left:calc((var(--gov-form-checkbox-core-l-indicator-size, 2rem) - var(--gov-form-checkbox-core-l-check-size, 1.2rem)) / 2);width:var(--gov-form-checkbox-core-l-check-size, 1.2rem);height:var(--gov-form-checkbox-core-l-check-size, 1.2rem)}';const p=class{constructor(r){o(this,r);this.govFocus=e(this,"gov-focus",7);this.govBlur=e(this,"gov-blur",7);this.govChange=e(this,"gov-change",7);this.value=undefined;this.checked=false;this.required=false;this.disabled=undefined;this.name=undefined;this.size="m";this.identifier=undefined;this.invalid=undefined;this.wcagDescribedBy=undefined;this.wcagLabelledBy=undefined;this.isChecked=undefined;this.checkboxId=a("GovCheckbox");this.h=m(this.host);this.f=s(this.h)}updateCheckedState(o){this.isChecked=o;this.govChange.emit({checked:this.isChecked,value:this.value})}validateSize(o){t(v,o,h.root)}componentWillLoad(){this.isChecked=this.checked;this.f.passAttrToControl("type","checkbox");this.h.passChildAttr(k.root,"identifier",this.identifier||this.checkboxId)}async componentDidRender(){if(b()){await d(500);await this.validateWcag()}}render(){const{isChecked:o}=this;return r(c,{class:h.root,"is-checked":o,size:this.size,invalid:g(this.invalid)},r("input",{id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.isChecked,onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,"aria-checked":n(this.isChecked),"aria-required":g(this.required),"aria-invalid":g(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":g(this.disabled)}),r("span",null,r("slot",{name:"label"}),r("gov-icon",{class:h.check,name:"check-lg"})))}onFocusHandler(o){this.govFocus.emit(o)}onBlurHandler(o){this.govBlur.emit(o)}onChangeHandler(o){this.isChecked=o.target.checked;o.stopPropagation();this.govChange.emit({checked:this.isChecked,value:this.value})}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",h.root);f(this.wcagLabelledBy,"wcag-labelled-by",h.root);l(this.identifier||this.checkboxId,this.wcagLabelledBy,h.root)}get host(){return i(this)}static get watchers(){return{checked:["updateCheckedState"],size:["validateSize"]}}};p.style=x;export{p as gov_form_checkbox};
|
|
2
|
-
//# sourceMappingURL=p-54f367db.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.scss?tag=gov-form-checkbox","../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.tsx"],"names":["govFormCheckboxCss","GovFormCheckbox","[object Object]","hostRef","this","checkboxId","createID","h","govHost","host","f","govForm","newValue","isChecked","govChange","emit","checked","value","validateProp","FormCheckboxSizes","FormCheckboxClass","root","passAttrToControl","passChildAttr","FormLabelClass","identifier","canValidateWcagOnRender","delay","validateWcag","Host","class","is-checked","size","invalid","toBoolAttrIfDefined","id","type","name","onChange","onChangeHandler","bind","onFocus","onFocusHandler","onBlur","onBlurHandler","required","aria-checked","toBoolAttr","aria-required","aria-invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-disabled","disabled","check","e","govFocus","govBlur","target","stopPropagation","validateWcagRef","validateWcagLabelFor"],"mappings":"8gBAAA,MAAMA,EAAqB,mnPCmBdC,EAAe,MAM3BC,YAAAC,2JAeqD,oBAKhB,4DAaW,2IAhC/CC,KAAKC,WAAaC,EAAS,eAE3BF,KAAKG,EAAIC,EAAQJ,KAAKK,MACtBL,KAAKM,EAAIC,EAAQP,KAAKG,GA8DvBL,mBAAmBU,GAClBR,KAAKS,UAAYD,EACjBR,KAAKU,UAAUC,KAAK,CACnBC,QAASZ,KAAKS,UACdI,MAAOb,KAAKa,QAKdf,aAAaU,GACZM,EAAaC,EAAmBP,EAAUQ,EAAkBC,MAG7DnB,oBACCE,KAAKS,UAAYT,KAAKY,QAEtBZ,KAAKM,EAAEY,kBAAkB,OAAQ,YACjClB,KAAKG,EAAEgB,cAAcC,EAAeH,KAAM,aAAcjB,KAAKqB,YAAcrB,KAAKC,YAGjFH,2BACC,GAAIwB,IAA2B,OACxBC,EAAM,WACNvB,KAAKwB,gBAIb1B,SACC,MAAMW,UAAEA,GAAcT,KAEtB,OACCG,EAACsB,EAAI,CAACC,MAAOV,EAAkBC,KAAIU,aAAclB,EAAWmB,KAAM5B,KAAK4B,KAAMC,QAASC,EAAoB9B,KAAK6B,UAC9G1B,EAAA,QAAA,CACC4B,GAAI/B,KAAKqB,YAAcrB,KAAKC,WAC5B+B,KAAK,WACLnB,MAAOb,KAAKa,MACZoB,KAAMjC,KAAKiC,KACXrB,QAASZ,KAAKS,UACdyB,SAAUlC,KAAKmC,gBAAgBC,KAAKpC,MACpCqC,QAASrC,KAAKsC,eAAeF,KAAKpC,MAClCuC,OAAQvC,KAAKwC,cAAcJ,KAAKpC,MAChCyC,SAAUzC,KAAKyC,SAAQC,eACTC,EAAW3C,KAAKS,WAAUmC,gBACzBd,EAAoB9B,KAAKyC,UAASI,eACnCf,EAAoB9B,KAAK6B,SAAQiB,mBAC7B9C,KAAK+C,gBAAeC,kBACrBhD,KAAKiD,eAAcC,gBACrBpB,EAAoB9B,KAAKmD,YAEzChD,EAAA,OAAA,KACCA,EAAA,OAAA,CAAM8B,KAAK,UACX9B,EAAA,WAAA,CAAUuB,MAAOV,EAAkBoC,MAAOnB,KAAK,eAM3CnC,eAAeuD,GACtBrD,KAAKsD,SAAS3C,KAAK0C,GAGZvD,cAAcuD,GACrBrD,KAAKuD,QAAQ5C,KAAK0C,GAGXvD,gBAAgBuD,GACvBrD,KAAKS,UAAa4C,EAAEG,OAA4B5C,QAChDyC,EAAEI,kBACFzD,KAAKU,UAAUC,KAAK,CACnBC,QAASZ,KAAKS,UACdI,MAAOb,KAAKa,QAQdf,qBACC4D,EAAgB1D,KAAK+C,gBAAiB,oBAAqB/B,EAAkBC,MAC7EyC,EAAgB1D,KAAKiD,eAAgB,mBAAoBjC,EAAkBC,MAC3E0C,EAAqB3D,KAAKqB,YAAcrB,KAAKC,WAAYD,KAAKiD,eAAgBjC,EAAkBC","sourcesContent":["/*\n * Checkbox\n */\n\n@import \"../checkbox/gov-form-checkbox-core.scss\";\n$class: \".gov-form-checkbox\";\n\n#{$class} {\n\t@extend %form-checkbox-core;\n\tinput + span {\n\t\t&::before {\n\t\t\tborder-radius: $border-radius;\n\t\t}\n\t}\n\t&__check {\n\t\tposition: absolute;\n\t\tcolor: $form-checkbox-check-color;\n\t\topacity: 0;\n\t\ttransition: $t linear opacity;\n\t}\n\n\t// STATES\n\tinput:checked + span::before {\n\t\tbackground: $form-checkbox-indicator-bg;\n\t}\n\tinput:checked + span &__check {\n\t\topacity: 1;\n\t}\n\t@include parameter(\"invalid\") {\n\t\tinput:checked + span::before {\n\t\t\tbackground: $form-state-color-error;\n\t\t}\n\t}\n\t@include parameter(\"disabled\") {\n\t\tinput:checked + span::before {\n\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $form-checkbox-core-sizes {\n\t\t&[size=\"#{$size}\"] {\n\t\t\t#{$class} {\n\t\t\t\t&__check {\n\t\t\t\t\ttop: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\tleft: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\twidth: get(\"check-size\", $definitions);\n\t\t\t\t\theight: get(\"check-size\", $definitions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","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 { FormLabelClass } from '../label/constants'\nimport { GovFormCheckboxChangeEvent } from './interfaces'\n\n@Component({\n\ttag: 'gov-form-checkbox',\n\tstyleUrl: 'gov-form-checkbox.scss',\n})\nexport class GovFormCheckbox {\n\tprivate 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 * 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\tthis.h.passChildAttr(FormLabelClass.root, 'identifier', this.identifier || this.checkboxId)\n\t}\n\n\tasync componentDidRender() {\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\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<input\n\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tchecked={this.isChecked}\n\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\taria-checked={toBoolAttr(this.isChecked)}\n\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t/>\n\t\t\t\t<span>\n\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t<gov-icon class={FormCheckboxClass.check} name=\"check-lg\"></gov-icon>\n\t\t\t\t</span>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.govBlur.emit(e)\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"]}
|