@gov-design-system-ce/components 0.0.7 → 0.0.8
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/gov-app.cjs.entry.js +15 -6
- 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 +23 -7
- package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-file.cjs.entry.js +7 -1
- package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-input.cjs.entry.js +6 -0
- package/dist/cjs/gov-form-input.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 +17 -1
- 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-switch.cjs.entry.js +23 -7
- 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.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 +7 -1
- package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
- package/dist/collection/components/gov-form/input/gov-form-input.js +6 -0
- package/dist/collection/components/gov-form/input/gov-form-input.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.js +35 -1
- 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/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/pages/Forms.js +15 -6
- 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/gov-accordion-item.js +0 -1
- package/dist/components/gov-accordion-item.js.map +1 -1
- package/dist/components/gov-accordion.js +0 -1
- package/dist/components/gov-accordion.js.map +1 -1
- package/dist/components/gov-alert.js +0 -1
- package/dist/components/gov-alert.js.map +1 -1
- package/dist/components/gov-app.js +15 -7
- package/dist/components/gov-app.js.map +1 -1
- package/dist/components/gov-attachments-item2.js +0 -1
- package/dist/components/gov-attachments-item2.js.map +1 -1
- package/dist/components/gov-attachments2.js +0 -1
- package/dist/components/gov-attachments2.js.map +1 -1
- package/dist/components/gov-backdrop2.js +0 -1
- package/dist/components/gov-backdrop2.js.map +1 -1
- package/dist/components/gov-badge2.js +0 -1
- package/dist/components/gov-badge2.js.map +1 -1
- package/dist/components/gov-breadcrumbs.js +0 -1
- package/dist/components/gov-breadcrumbs.js.map +1 -1
- package/dist/components/gov-button2.js +12 -2
- package/dist/components/gov-button2.js.map +1 -1
- package/dist/components/gov-card.js +0 -1
- package/dist/components/gov-card.js.map +1 -1
- package/dist/components/gov-container.js +0 -1
- package/dist/components/gov-container.js.map +1 -1
- package/dist/components/gov-cookiebar.js +0 -1
- package/dist/components/gov-cookiebar.js.map +1 -1
- package/dist/components/gov-empty.js +0 -1
- package/dist/components/gov-empty.js.map +1 -1
- package/dist/components/gov-error-code.js +0 -1
- package/dist/components/gov-error-code.js.map +1 -1
- package/dist/components/gov-form-autocomplete2.js +4 -1
- package/dist/components/gov-form-autocomplete2.js.map +1 -1
- package/dist/components/gov-form-checkbox.js +24 -8
- package/dist/components/gov-form-checkbox.js.map +1 -1
- package/dist/components/gov-form-control.js +0 -1
- package/dist/components/gov-form-control.js.map +1 -1
- package/dist/components/gov-form-file.js +7 -2
- package/dist/components/gov-form-file.js.map +1 -1
- package/dist/components/gov-form-group.js +0 -1
- package/dist/components/gov-form-group.js.map +1 -1
- package/dist/components/gov-form-input2.js +6 -1
- package/dist/components/gov-form-input2.js.map +1 -1
- package/dist/components/gov-form-label.js +0 -1
- package/dist/components/gov-form-label.js.map +1 -1
- package/dist/components/gov-form-message2.js +0 -1
- package/dist/components/gov-form-message2.js.map +1 -1
- package/dist/components/gov-form-multi-select.js +8 -1
- package/dist/components/gov-form-multi-select.js.map +1 -1
- package/dist/components/gov-form-password-power.js +0 -1
- package/dist/components/gov-form-password-power.js.map +1 -1
- package/dist/components/gov-form-radio.js +18 -2
- package/dist/components/gov-form-radio.js.map +1 -1
- package/dist/components/gov-form-search.js +1 -2
- package/dist/components/gov-form-search.js.map +1 -1
- package/dist/components/gov-form-select2.js +0 -1
- package/dist/components/gov-form-select2.js.map +1 -1
- package/dist/components/gov-form-switch.js +24 -8
- package/dist/components/gov-form-switch.js.map +1 -1
- package/dist/components/gov-grid-item.js +0 -1
- package/dist/components/gov-grid-item.js.map +1 -1
- package/dist/components/gov-grid.js +0 -1
- package/dist/components/gov-grid.js.map +1 -1
- package/dist/components/gov-icon2.js +1 -2
- package/dist/components/gov-icon2.js.map +1 -1
- package/dist/components/gov-layout-column.js +0 -1
- package/dist/components/gov-layout-column.js.map +1 -1
- package/dist/components/gov-layout.js +0 -1
- package/dist/components/gov-layout.js.map +1 -1
- package/dist/components/gov-loading.js +0 -1
- package/dist/components/gov-loading.js.map +1 -1
- package/dist/components/gov-message.js +0 -1
- package/dist/components/gov-message.js.map +1 -1
- package/dist/components/gov-modal.js +0 -1
- package/dist/components/gov-modal.js.map +1 -1
- package/dist/components/gov-nav-item.js +0 -1
- package/dist/components/gov-nav-item.js.map +1 -1
- package/dist/components/gov-nav.js +0 -1
- package/dist/components/gov-nav.js.map +1 -1
- package/dist/components/gov-pagination.js +2 -4
- package/dist/components/gov-pagination.js.map +1 -1
- package/dist/components/gov-prompt.js +0 -1
- package/dist/components/gov-prompt.js.map +1 -1
- package/dist/components/gov-side-nav-item.js +0 -1
- package/dist/components/gov-side-nav-item.js.map +1 -1
- package/dist/components/gov-side-nav.js +0 -1
- package/dist/components/gov-side-nav.js.map +1 -1
- package/dist/components/gov-spacer.js +0 -1
- package/dist/components/gov-spacer.js.map +1 -1
- package/dist/components/gov-statsbar-item.js +0 -1
- package/dist/components/gov-statsbar-item.js.map +1 -1
- package/dist/components/gov-statsbar.js +0 -1
- package/dist/components/gov-statsbar.js.map +1 -1
- package/dist/components/gov-stepper-item.js +0 -1
- package/dist/components/gov-stepper-item.js.map +1 -1
- package/dist/components/gov-stepper.js +0 -1
- package/dist/components/gov-stepper.js.map +1 -1
- package/dist/components/gov-tabs-item.js +0 -1
- package/dist/components/gov-tabs-item.js.map +1 -1
- package/dist/components/gov-tabs.js +0 -1
- package/dist/components/gov-tabs.js.map +1 -1
- package/dist/components/gov-tile.js +3 -3
- package/dist/components/gov-tile.js.map +1 -1
- package/dist/components/gov-tiles.js +0 -1
- package/dist/components/gov-tiles.js.map +1 -1
- package/dist/components/gov-toast.js +0 -1
- package/dist/components/gov-toast.js.map +1 -1
- package/dist/components/gov-tooltip-content.js +0 -1
- package/dist/components/gov-tooltip-content.js.map +1 -1
- package/dist/components/gov-tooltip.js +0 -1
- package/dist/components/gov-tooltip.js.map +1 -1
- package/dist/components/gov-wizzard-item.js +0 -1
- package/dist/components/gov-wizzard-item.js.map +1 -1
- package/dist/components/gov-wizzard.js +0 -1
- package/dist/components/gov-wizzard.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-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-e9c94ef7.entry.js → p-72b9e63a.entry.js} +2 -2
- 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-8dbad4a2.entry.js +2 -0
- package/dist/core/p-8dbad4a2.entry.js.map +1 -0
- package/dist/core/p-902002e9.entry.js +2 -0
- package/dist/core/p-902002e9.entry.js.map +1 -0
- package/dist/core/{p-a0c491a6.entry.js → p-95f21fbf.entry.js} +2 -2
- package/dist/core/{p-a0c491a6.entry.js.map → p-95f21fbf.entry.js.map} +1 -1
- 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-692eb701.entry.js → p-a36234bb.entry.js} +2 -2
- package/dist/core/p-a36234bb.entry.js.map +1 -0
- package/dist/core/p-ac33c5ef.entry.js +2 -0
- package/dist/core/p-ac33c5ef.entry.js.map +1 -0
- package/dist/core/{p-da2b921e.entry.js → p-c0430e75.entry.js} +2 -2
- package/dist/core/p-c0430e75.entry.js.map +1 -0
- package/dist/core/p-ecdfb046.entry.js +2 -0
- package/dist/core/p-ecdfb046.entry.js.map +1 -0
- package/dist/custom-elements/index.js +1 -1
- package/dist/custom-elements/index.js.map +1 -1
- package/dist/esm/Fragment-8d8d54fb.js +5 -0
- package/dist/esm/Fragment-8d8d54fb.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/gov-app.entry.js +15 -6
- 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 +23 -7
- package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
- package/dist/esm/gov-form-file.entry.js +7 -1
- package/dist/esm/gov-form-file.entry.js.map +1 -1
- package/dist/esm/gov-form-input.entry.js +6 -0
- package/dist/esm/gov-form-input.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 +17 -1
- 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-switch.entry.js +23 -7
- 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 +121 -29
- package/dist/types/components/gov-button/gov-button.d.ts +2 -0
- package/dist/types/components/gov-form/checkbox/gov-form-checkbox.d.ts +8 -3
- package/dist/types/components/gov-form/file/gov-form-file.d.ts +1 -0
- package/dist/types/components/gov-form/radio/gov-form-radio.d.ts +5 -0
- package/dist/types/components/gov-form/switch/gov-form-switch.d.ts +8 -3
- 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 +26 -4
- package/package.json +1 -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.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-ae3e2d60.entry.js.map +0 -1
- package/dist/core/p-da2b921e.entry.js.map +0 -1
- /package/dist/core/{p-e9c94ef7.entry.js.map → p-72b9e63a.entry.js.map} +0 -0
|
@@ -560,6 +560,10 @@ export namespace Components {
|
|
|
560
560
|
* Name of the checkbox.
|
|
561
561
|
*/
|
|
562
562
|
"name": string;
|
|
563
|
+
/**
|
|
564
|
+
* When you can't use the form label.
|
|
565
|
+
*/
|
|
566
|
+
"noLabel": boolean;
|
|
563
567
|
/**
|
|
564
568
|
* 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
569
|
*/
|
|
@@ -925,6 +929,10 @@ export namespace Components {
|
|
|
925
929
|
* Name of the radio.
|
|
926
930
|
*/
|
|
927
931
|
"name": string;
|
|
932
|
+
/**
|
|
933
|
+
* When you can't use the form label.
|
|
934
|
+
*/
|
|
935
|
+
"noLabel": boolean;
|
|
928
936
|
/**
|
|
929
937
|
* 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
938
|
*/
|
|
@@ -1043,6 +1051,10 @@ export namespace Components {
|
|
|
1043
1051
|
* Name of the switch.
|
|
1044
1052
|
*/
|
|
1045
1053
|
"name": string;
|
|
1054
|
+
/**
|
|
1055
|
+
* When you can't use the form label.
|
|
1056
|
+
*/
|
|
1057
|
+
"noLabel": boolean;
|
|
1046
1058
|
/**
|
|
1047
1059
|
* 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
1060
|
*/
|
|
@@ -1518,8 +1530,7 @@ export namespace Components {
|
|
|
1518
1530
|
}
|
|
1519
1531
|
interface GovTile {
|
|
1520
1532
|
/**
|
|
1521
|
-
*
|
|
1522
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href
|
|
1533
|
+
* Link on whole tile
|
|
1523
1534
|
*/
|
|
1524
1535
|
"href": string;
|
|
1525
1536
|
/**
|
|
@@ -2694,6 +2705,10 @@ declare namespace LocalJSX {
|
|
|
2694
2705
|
* Name of the checkbox.
|
|
2695
2706
|
*/
|
|
2696
2707
|
"name"?: string;
|
|
2708
|
+
/**
|
|
2709
|
+
* When you can't use the form label.
|
|
2710
|
+
*/
|
|
2711
|
+
"noLabel"?: boolean;
|
|
2697
2712
|
/**
|
|
2698
2713
|
* Emitted when the checkbox loses focus.
|
|
2699
2714
|
*/
|
|
@@ -3075,6 +3090,10 @@ declare namespace LocalJSX {
|
|
|
3075
3090
|
* Name of the radio.
|
|
3076
3091
|
*/
|
|
3077
3092
|
"name"?: string;
|
|
3093
|
+
/**
|
|
3094
|
+
* When you can't use the form label.
|
|
3095
|
+
*/
|
|
3096
|
+
"noLabel"?: boolean;
|
|
3078
3097
|
/**
|
|
3079
3098
|
* Emitted when the radio loses focus.
|
|
3080
3099
|
*/
|
|
@@ -3197,6 +3216,10 @@ declare namespace LocalJSX {
|
|
|
3197
3216
|
* Name of the switch.
|
|
3198
3217
|
*/
|
|
3199
3218
|
"name"?: string;
|
|
3219
|
+
/**
|
|
3220
|
+
* When you can't use the form label.
|
|
3221
|
+
*/
|
|
3222
|
+
"noLabel"?: boolean;
|
|
3200
3223
|
/**
|
|
3201
3224
|
* Emitted when the switch loses focus.
|
|
3202
3225
|
*/
|
|
@@ -3628,8 +3651,7 @@ declare namespace LocalJSX {
|
|
|
3628
3651
|
}
|
|
3629
3652
|
interface GovTile {
|
|
3630
3653
|
/**
|
|
3631
|
-
*
|
|
3632
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href
|
|
3654
|
+
* Link on whole tile
|
|
3633
3655
|
*/
|
|
3634
3656
|
"href"?: string;
|
|
3635
3657
|
/**
|
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.8",
|
|
6
6
|
"license" : "EUPL v1.2 Licensed",
|
|
7
7
|
"main" : "./dist/index.cjs.js",
|
|
8
8
|
"module" : "./dist/index.js",
|
|
@@ -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,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YAAcjE,KAAKC,SAAUD,KAAKyE,eAAgBlE,EAAqBC","sourcesContent":["/*\n * Multiselect\n */\n\n@import \"../select/gov-form-select-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,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,QAOhB5F,qBACC,GAAIE,KAAK4D,UAAW,CACnB+B,EAAgB3F,KAAK8D,qBAAsB,wBAAyBvD,EAAYC,MAChFmF,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,EA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qB3D,KAAKqB,YAAcrB,KAAKC,QAASD,KAAKkD,eAAgBlC,EAAeC","sourcesContent":["/*\n * Radio\n */\n\n@import \"../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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/input/gov-form-input.scss?tag=gov-form-input","../../../packages/core/src/components/gov-form/input/gov-form-input.tsx"],"names":["govFormInputCss","Tags","GovFormInput","[object Object]","hostRef","this","h","govHost","host","inputId","createID","f","govForm","newValue","validateProp","FormInputVariants","FormInputClass","root","FormInputSizes","validateVariant","variant","validateSize","size","passAttrToControl","multiline","TEXTAREA","INPUT","canValidateWcagOnRender","delay","validateWcag","Tag","Host","class","type","hasSlot","name","success","invalid","slot","inputType","disabled","id","identifier","onFocus","onFocusHandler","bind","onInput","onInputHandler","onBlur","onBlurHandler","onKeyUp","onKeyUpHandler","ref","el","inputRef","placeholder","value","readonly","toBoolAttrIfDefined","autocomplete","toOnOffAttrIfDefined","autocorrect","minlength","maxlength","required","rows","cols","role","aria-required","aria-invalid","aria-disabled","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-owns","wcagOwns","aria-expanded","wcagExpanded","aria-autocomplete","wcagAutocomplete","e","focused","govFocus","emit","govBlur","stopPropagation","govKeyUp","target","govInput","options","focus","validateWcagRef","validateWcagLabelFor"],"mappings":"ifAAA,MAAMA,EAAkB,mxTCaxB,IA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9E,eAAeuF,GACd,OAAOrF,KAAKiD,SAASqC,MAAMD,GAO5BvF,eAAeqD,GACdnD,KAAKmD,MAAQA,EAOdrD,mBACCE,KAAKmD,MAAQ,GACbnD,KAAKiD,SAASE,MAAQ,GAOvBrD,oBACC,OAAOE,KAAKiD,SAObnD,qBACCyF,EAAgBvF,KAAKmE,gBAAiB,oBAAqBxD,EAAeC,MAC1E2E,EAAgBvF,KAAKqE,eAAgB,mBAAoB1D,EAAeC,MACxE2E,EAAgBvF,KAAKuE,SAAU,YAAa5D,EAAeC,MAC3D4E,EAAqBxF,KAAKqC,YAAcrC,KAAKI,QAASJ,KAAKqE,eAAgB1D,EAAeC","sourcesContent":["/*\n * Input\n */\n\n@import \"../input/gov-form-input-core.scss\";\n$class: \".gov-form-input\";\n\n#{$class} {\n\t@extend %form-input-core;\n\n\t// STATES\n\t@include parameter(\"invalid\") {\n\t\t*[slot=\"right-icon\"]:not(.icon-validation):not(.icon-arrow) {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t&[type=\"reset\"] {\n\t\tinput {\n\t\t\tborder-width: 0;\n\t\t\t&:focus {\n\t\t\t\toutline: none;\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch, Event, EventEmitter, State, Method } from '@stencil/core'\nimport { GovHost } from '../../../helpers/Dom/template.types'\nimport { FormInputSizes, FormInputSizesType, InputType, Type } from './constants'\nimport { createID } from '../../../utils/string.utils'\nimport { govHost, toBoolAttrIfDefined, toOnOffAttrIfDefined } from '../../../helpers/Dom/template'\nimport { FormInputClass, FormInputVariants, FormInputVariantType } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { canValidateWcagOnRender } from '../../../helpers/Dom/win'\nimport { delay } from '../../../utils/utils'\nimport { validateWcagLabelFor, validateWcagRef } from '../../../helpers/Validate/wcag'\nimport { GovForm } from '../../../helpers/Dom/form.types'\nimport { govForm } from '../../../helpers/Dom/form'\n\nenum Tags {\n\tINPUT = 'input',\n\tTEXTAREA = 'textarea',\n}\n\n@Component({\n\ttag: 'gov-form-input',\n\tstyleUrl: 'gov-form-input.scss',\n})\nexport class GovFormInput {\n\tprivate f: GovForm\n\tprivate h: GovHost\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly inputId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.inputId = createID('GovInput')\n\t\tthis.f = govForm(govHost(this.host))\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value: string\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: FormInputVariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: FormInputSizesType = 'm'\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Generates a texarea for the possibility of multiple lines\n\t */\n\t@Prop() readonly multiline: boolean\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n\t */\n\t@Prop() readonly rows: number\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-cols\n\t */\n\t@Prop() readonly cols: number\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 input 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 * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-autocomplete\n\t */\n\t@Prop() readonly autocomplete: boolean\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-autocorrect\n\t */\n\t@Prop() readonly autocorrect: boolean\n\t/**\n\t * Defineds the visual style of input\n\t */\n\t@Prop() readonly type?: Type\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types\n\t */\n\t@Prop() readonly inputType: InputType = 'text'\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/input_role\n\t */\n\t@Prop() readonly role: 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 * 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 * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value.\n\t */\n\t@Prop({ attribute: 'wcag-autocomplete' }) readonly wcagAutocomplete: string\n\t/**\n\t * Attribute is set on an element to indicate if a control is expanded or collapsed\n\t */\n\t@Prop({ attribute: 'wcag-expanded' }) readonly wcagExpanded: boolean\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-input' }) govInput: EventEmitter<InputEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-keyup' }) govKeyUp: EventEmitter<KeyboardEvent>\n\t@State() focused: boolean\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormInputVariants, newValue, FormInputClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormInputSizes, newValue, FormInputClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\n\t\tthis.f.passAttrToControl('type', this.multiline ? Tags.TEXTAREA : Tags.INPUT)\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 Tag = this.multiline ? Tags.TEXTAREA : Tags.INPUT\n\n\t\treturn (\n\t\t\t<Host class={FormInputClass.root} size={this.size} variant={this.variant} type={this.type}>\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{this.h.hasSlot('left-icon') && <slot name=\"left-icon\" />}\n\n\t\t\t\t\t{this.h.hasSlot('right-icon') && !(this.success || this.invalid) && <slot name=\"right-icon\" />}\n\n\t\t\t\t\t{this.success && !this.multiline && <gov-icon slot=\"right-icon\" class=\"icon-validation\" name=\"check-lg\"></gov-icon>}\n\t\t\t\t\t{this.invalid && !this.multiline && <gov-icon slot=\"right-icon\" class=\"icon-validation\" name=\"exclamation-lg\"></gov-icon>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\ttype={this.inputType}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\tid={this.identifier || this.inputId}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonInput={this.onInputHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\tonKeyUp={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\treadonly={toBoolAttrIfDefined(this.readonly)}\n\t\t\t\t\t\tautocomplete={toOnOffAttrIfDefined(this.autocomplete)}\n\t\t\t\t\t\tautocorrect={toOnOffAttrIfDefined(this.autocorrect)}\n\t\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\trows={this.rows}\n\t\t\t\t\t\tcols={this.cols}\n\t\t\t\t\t\trole={this.role}\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-disabled={toBoolAttrIfDefined(this.disabled)}\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\taria-expanded={toBoolAttrIfDefined(this.wcagExpanded)}\n\t\t\t\t\t\taria-autocomplete={this.wcagAutocomplete}\n\t\t\t\t\t/>\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 onKeyUpHandler(e: KeyboardEvent) {\n\t\te.stopPropagation()\n\t\tthis.govKeyUp.emit(e)\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit(e)\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.inputRef.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 * Clears input value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\t}\n\n\t/**\n\t * Returns an instance of the native html input element\n\t */\n\t@Method()\n\tasync getInstance(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, 'wcag-described-by', FormInputClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormInputClass.root)\n\t\tvalidateWcagRef(this.wcagOwns, 'wcag-owns', FormInputClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.inputId, this.wcagLabelledBy, FormInputClass.root)\n\t}\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,c as r,h as t,H as e,g as n}from"./p-682c7cc6.js";import{v as a}from"./p-26acf964.js";import{S as i}from"./p-55500e5a.js";import{V as s}from"./p-ff7365ae.js";import{p as g,d as c}from"./p-03990da5.js";import{g as v,p as l,t as u}from"./p-3f37ddb6.js";import{c as h,v as p}from"./p-364b4792.js";import{c as d}from"./p-c20102ff.js";import{c as b}from"./p-24636c53.js";import"./p-561fa17b.js";const m=(o,r)=>[...r];const _=g(i,["_S","_M"]);const y=g(s,["PRIMARY","SECONDARY"]);var f;(function(o){o["BUTTON"]="button";o["SELECT"]="select"})(f||(f={}));const w={root:"gov-pagination",list:"gov-pagination__list",item:"gov-pagination__item",itemArrow:"gov-pagination__item--arrow",itemMore:"gov-pagination__item--more",itemSelect:"gov-pagination__item--select",inner:"gov-pagination__inner",arrow:"gov-pagination__arrow"};function k(o,r=1,t=10,e=10){const n=Math.ceil(o/t);if(r<1){r=1}else if(r>n){r=n}let a,i;if(n<=e){a=1;i=n}else{const o=Math.floor(e/2);const t=Math.ceil(e/2)-1;if(r<=o){a=1;i=e}else if(r+t>=n){a=n-e+1;i=n}else{a=r-o;i=r+t}}const s=(r-1)*t;const g=Math.min(s+t-1,o-1);const c=Array.from(Array(i+1-a).keys()).map((o=>a+o));return{totalItems:o,currentPage:r,pageSize:t,totalPages:n,startPage:a,endPage:i,startIndex:s,endIndex:g,pages:c}}const x=(o,r)=>[...Array(r+1).keys()].slice(o);const z=".gov-pagination__list{margin:0;padding:0}.gov-pagination__list .gov-pagination__item{margin:0;padding:0;background:none}.gov-pagination__list .gov-pagination__item::before{display:none}.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-pagination{position:relative;display:block;width:100%}.gov-pagination__list{display:flex;align-items:center;flex-wrap:wrap;font-weight:bold;text-align:center}.gov-pagination__list .gov-pagination__item{display:flex;justify-content:center;align-items:center;margin:0;border-radius:var(--gov-border-radius, 0.1875rem);overflow:hidden}.gov-pagination__list .gov-pagination__item--arrow{display:flex}.gov-pagination__list .gov-pagination__item--select{z-index:1;display:flex;overflow:visible;padding:0rem 1rem}.gov-pagination__arrow{margin:0}.gov-pagination__item--more .gov-form-select select{border:none;padding-right:0.75rem !important}.gov-pagination__item--more .gov-form-select .gov-icon{display:none}.gov-pagination__inner{display:flex;justify-content:center;align-items:center;align-self:stretch;width:100%;text-decoration:none}.gov-pagination__inner[wcag-current=true][type=solid][variant=primary] .element{background-color:var(--gov-button-primary-solid-hover-bg, var(--gov-color-primary-700));color:var(--gov-button-primary-solid-hover-color, var(--gov-color-neutral-white))}.gov-pagination__inner[wcag-current=true][type=outlined][variant=primary] .element{background-color:var(--gov-button-primary-outlined-hover-bg, var(--gov-color-primary-100));color:var(--gov-button-primary-outlined-hover-color, var(--gov-color-primary))}.gov-pagination__inner[wcag-current=true][type=base][variant=primary] .element{background-color:var(--gov-button-primary-base-hover-bg, var(--gov-color-primary-100));color:var(--gov-button-primary-base-hover-color, var(--gov-color-primary))}.gov-pagination__inner[wcag-current=true][type=link][variant=primary] .element{background-color:var(--gov-button-primary-link-hover-bg, transparent);color:var(--gov-button-primary-link-hover-color, var(--gov-color-primary))}.gov-pagination__inner[wcag-current=true][type=solid][variant=secondary] .element{background-color:var(--gov-button-secondary-solid-hover-bg, var(--gov-color-secondary-900));color:var(--gov-button-secondary-solid-hover-color, var(--gov-color-neutral-white))}.gov-pagination__inner[wcag-current=true][type=outlined][variant=secondary] .element{background-color:var(--gov-button-secondary-outlined-hover-bg, var(--gov-color-secondary-300));color:var(--gov-button-secondary-outlined-hover-color, var(--gov-color-secondary))}.gov-pagination__inner[wcag-current=true][type=base][variant=secondary] .element{background-color:var(--gov-button-secondary-base-hover-bg, var(--gov-color-secondary-300));color:var(--gov-button-secondary-base-hover-color, var(--gov-color-secondary))}.gov-pagination__inner[wcag-current=true][type=link][variant=secondary] .element{background-color:var(--gov-button-secondary-link-hover-bg, transparent);color:var(--gov-button-secondary-link-hover-color, var(--gov-color-secondary))}.gov-pagination__inner[wcag-current=true][type=solid][variant=error] .element{background-color:var(--gov-button-error-solid-hover-bg, var(--gov-color-error-500));color:var(--gov-button-error-solid-hover-color, var(--gov-color-neutral-white))}.gov-pagination__inner[wcag-current=true][type=outlined][variant=error] .element{background-color:var(--gov-button-error-outlined-hover-bg, var(--gov-color-error-100));color:var(--gov-button-error-outlined-hover-color, var(--gov-color-error))}.gov-pagination__inner[wcag-current=true][type=base][variant=error] .element{background-color:var(--gov-button-error-base-hover-bg, var(--gov-color-error-100));color:var(--gov-button-error-base-hover-color, var(--gov-color-error))}.gov-pagination__inner[wcag-current=true][type=link][variant=error] .element{background-color:var(--gov-button-error-link-hover-bg, transparent);color:var(--gov-button-error-link-hover-color, var(--gov-color-error))}.gov-pagination__inner[wcag-current=true][type=solid][variant=success] .element{background-color:var(--gov-button-success-solid-hover-bg, var(--gov-color-success-600));color:var(--gov-button-success-solid-hover-color, var(--gov-color-neutral-white))}.gov-pagination__inner[wcag-current=true][type=outlined][variant=success] .element{background-color:var(--gov-button-success-outlined-hover-bg, var(--gov-color-success-100));color:var(--gov-button-success-outlined-hover-color, var(--gov-color-success-500))}.gov-pagination__inner[wcag-current=true][type=base][variant=success] .element{background-color:var(--gov-button-success-base-hover-bg, var(--gov-color-success-100));color:var(--gov-button-success-base-hover-color, var(--gov-color-success-500))}.gov-pagination__inner[wcag-current=true][type=link][variant=success] .element{background-color:var(--gov-button-success-link-hover-bg, transparent);color:var(--gov-button-success-link-hover-color, var(--gov-color-success-500))}.gov-pagination__inner[wcag-current=true][type=solid][variant=warning] .element{background-color:var(--gov-button-warning-solid-hover-bg, var(--gov-color-warning-600));color:var(--gov-button-warning-solid-hover-color, var(--gov-color-neutral-white))}.gov-pagination__inner[wcag-current=true][type=outlined][variant=warning] .element{background-color:var(--gov-button-warning-outlined-hover-bg, var(--gov-color-warning-200));color:var(--gov-button-warning-outlined-hover-color, var(--gov-color-warning-500))}.gov-pagination__inner[wcag-current=true][type=base][variant=warning] .element{background-color:var(--gov-button-warning-base-hover-bg, var(--gov-color-warning-200));color:var(--gov-button-warning-base-hover-color, var(--gov-color-warning-500))}.gov-pagination__inner[wcag-current=true][type=link][variant=warning] .element{background-color:var(--gov-button-warning-link-hover-bg, transparent);color:var(--gov-button-warning-link-hover-color, var(--gov-color-warning-500))}.gov-pagination[size=s] .gov-pagination__inner{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);font-weight:inherit}.gov-pagination[size=s] .gov-pagination__inner .element{min-width:var(--gov-pagination-s-button-size, 2rem)}.gov-pagination[size=m] .gov-pagination__inner{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);font-weight:inherit}.gov-pagination[size=m] .gov-pagination__inner .element{min-width:var(--gov-pagination-m-button-size, 2.5rem)}";const j=class{constructor(t){o(this,t);this.govPage=r(this,"gov-page",7);this.type="button";this.current=1;this.total=undefined;this.inverse=undefined;this.size="m";this.variant="primary";this.pageSize=10;this.maxPages=5;this.link=undefined;this.wcagLabel=undefined;this.wcagLabelledBy=undefined;this.wcagSelectLabel="Vybrat stranu";this.wcagPageLabel="Strana";this.pagination=undefined;this.h=v(this.host);this.pageSelectId=b("GovPageSelect")}validateType(o){a(f,o,w.root)}validateSize(o){a(_,o,w.root)}validateVariant(o){a(y,o,w.root)}componentWillLoad(){this.recalculatePagination(this.current);this.validateSize(this.size);this.validateVariant(this.variant)}async componentDidRender(){if(d()){await c(500);await this.validateWcag()}}recalculatePagination(o){this.pagination=k(this.total,o,this.pageSize,this.maxPages)}isActivePageClass(o,r){if(this.pagination.currentPage===r){return o+" is-active"}else{return o}}prepareLinkUrl(o){if(this.link){return String(this.link).replace("{PAGE}",String(o))}return undefined}resetSelectValue(){if(this.spreadSelectRef){this.spreadSelectRef.getInstance().then((o=>{o.value="..."}))}}render(){const o=(o,r)=>{const e=o===-1;const n=u(this.pagination.currentPage===o?true:undefined);return t("gov-button",{href:this.prepareLinkUrl(o),variant:this.variant,size:this.size,type:"base",disabled:e,"on-gov-click":r=>this.onClickHandler(r,o),"wcag-label":o>-1?this.wcagPageLabel+" "+o:undefined,"wcag-current":n,class:w.inner},r)};return t(e,{class:this.h.classes(w.root),type:this.type,variant:this.variant,size:this.size},t("nav",{"aria-label":this.wcagLabel,"aria-labelledby":this.wcagLabelledBy},t("ul",{class:w.list},t("li",{class:l([w.item,w.itemArrow])},o(this.pagination.currentPage>1?1:-1,t("gov-icon",{class:w.arrow,name:"chevron-double-left"}))),t("li",{class:l([w.item,w.itemArrow])},o(this.pagination.startPage<this.pagination.currentPage?this.pagination.currentPage-1:-1,t("gov-icon",{class:w.arrow,name:"chevron-left"}))),this.type=="select"?t("li",{class:l([w.item,w.itemSelect])},t("span",{class:w.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m","wcag-labelled-by":this.pageSelectId,"on-gov-change":this.onSelectHandler.bind(this)},x(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:this.pagination.currentPage===o},o)))))):t(m,null,this.pagination.pages.map((r=>t("li",{class:this.isActivePageClass(w.item,r)},o(r,r)))),t("li",{class:l([w.item,w.itemMore])},t("span",{class:w.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m","wcag-labelled-by":this.pageSelectId,ref:o=>this.spreadSelectRef=o,"on-gov-change":this.onSelectHandler.bind(this)},t("option",{selected:true,hidden:true},"..."),x(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:false},o))))))),t("li",{class:l([w.item,w.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.currentPage+1:-1,t("gov-icon",{class:w.arrow,name:"chevron-right"}))),t("li",{class:l([w.item,w.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.totalPages:-1,t("gov-icon",{class:w.arrow,name:"chevron-double-right"}))))))}onClickHandler(o,r){o.stopPropagation();o.preventDefault();this.recalculatePagination(r);this.govPage.emit(Object.assign({},this.pagination))}onSelectHandler(o){o.stopPropagation();o.preventDefault();const r=o.target;const t=parseInt(r.value);this.resetSelectValue();if(isNaN(t)===false){this.recalculatePagination(t);if(this.link){window.location.href=this.prepareLinkUrl(t)}else{this.govPage.emit(Object.assign({},this.pagination))}}}async validateWcag(){h(this.wcagPageLabel,"wcag-page-label",w.root);p(this.wcagLabel,this.wcagLabelledBy,w.root);if(this.type==="select"){h(this.wcagSelectLabel,"wcag-select-label",w.root)}}get host(){return n(this)}static get watchers(){return{type:["validateType"],size:["validateSize"],variant:["validateVariant"]}}};j.style=z;export{j as gov_pagination};
|
|
2
|
-
//# sourceMappingURL=p-86a3c0d5.entry.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,c as i,h as r,H as t,g as e}from"./p-682c7cc6.js";import{c as s}from"./p-24636c53.js";import{v as a}from"./p-26acf964.js";import{g as c,e as h,f as g}from"./p-76542f4f.js";import{g as v,t as m}from"./p-3f37ddb6.js";import{a as f,b as l}from"./p-364b4792.js";import{c as n}from"./p-c20102ff.js";import{d}from"./p-03990da5.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 w='.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-switch{position:relative;display:flex}.gov-form-switch__holder{display:inline-flex}.gov-form-switch__input{position:absolute;top:0;left:0;z-index:1;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gov-form-switch .gov-form-label__label{position:relative;z-index:1;margin-bottom:0;color:var(--gov-form-switch-color, var(--gov-color-secondary-800))}.gov-form-switch__indicator{position:relative;flex:0 0 auto;border:var(--gov-form-switch-indicator-border, 0.0625rem solid var(--gov-color-secondary-500));background-color:var(--gov-form-switch-indicator-bg, var(--gov-color-secondary-300));transition:150ms linear background-color}.gov-form-switch__indicator::before{content:"";position:absolute;display:block;border-radius:50%;background-color:var(--gov-form-switch-indicator-circle-bg, var(--gov-color-neutral-white));transition:150ms linear left;box-shadow:var(--gov-form-switch-indicator-circle-box-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.35))}.gov-form-switch__input:focus-visible~.gov-form-switch__indicator{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}.gov-form-switch__input:checked+.gov-form-switch__indicator{border-color:var(--gov-form-switch-indicator-bg-checked, var(--gov-color-primary));background-color:var(--gov-form-switch-indicator-bg-checked, var(--gov-color-primary))}.gov-form-switch[disabled=""],.gov-form-switch[disabled=true i],.gov-form-switch[disabled="1"]{pointer-events:none}.gov-form-switch[disabled=""] .gov-form-label__label,.gov-form-switch[disabled=true i] .gov-form-label__label,.gov-form-switch[disabled="1"] .gov-form-label__label{color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}.gov-form-switch[disabled=""] .gov-form-switch__indicator::before,.gov-form-switch[disabled=true i] .gov-form-switch__indicator::before,.gov-form-switch[disabled="1"] .gov-form-switch__indicator::before{background:var(--gov-form-input-disabled-bg, var(--gov-color-secondary-300))}.gov-form-switch[disabled=""] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[disabled=true i] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[disabled="1"] .gov-form-switch__input:checked+.gov-form-switch__indicator{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-switch[invalid=""] .gov-form-label__label,.gov-form-switch[invalid=true i] .gov-form-label__label,.gov-form-switch[invalid="1"] .gov-form-label__label{color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[invalid=""] .gov-form-switch__indicator,.gov-form-switch[invalid=true i] .gov-form-switch__indicator,.gov-form-switch[invalid="1"] .gov-form-switch__indicator{border-color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[invalid=""] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[invalid=true i] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[invalid="1"] .gov-form-switch__input:checked+.gov-form-switch__indicator{background-color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[size=xs] .gov-form-label__label{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);margin-bottom:0;margin-left:calc((var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 + var(--gov-form-switch-xs-gap, 0.75rem)) * -1);padding-top:calc((var(--gov-form-switch-xs-indicator-height, 1.25rem) - var(--gov-text-xs-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 + var(--gov-form-switch-xs-gap, 0.75rem))}.gov-form-switch[size=xs] .gov-form-switch__holder{gap:var(--gov-form-switch-xs-gap, 0.75rem)}.gov-form-switch[size=xs] .gov-form-switch__indicator{width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667);height:var(--gov-form-switch-xs-indicator-height, 1.25rem);border-radius:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 0.5)}.gov-form-switch[size=xs] .gov-form-switch__indicator::before{top:calc(var(--gov-form-switch-xs-toggle-offset, 0.051875rem) - 0.0625rem);left:calc(var(--gov-form-switch-xs-toggle-offset, 0.051875rem) - 0.0625rem);width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) - 2 * var(--gov-form-switch-xs-toggle-offset, 0.051875rem));height:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) - 2 * var(--gov-form-switch-xs-toggle-offset, 0.051875rem))}.gov-form-switch[size=xs] .gov-form-switch__input[aria-checked]+.gov-form-switch__indicator::before{left:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 - var(--gov-form-switch-xs-indicator-height, 1.25rem) + var(--gov-form-switch-xs-toggle-offset, 0.051875rem) - 0.0625rem)}.gov-form-switch[size=s] .gov-form-label__label{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);margin-bottom:0;margin-left:calc((var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 + var(--gov-form-switch-s-gap, 0.75rem)) * -1);padding-top:calc((var(--gov-form-switch-s-indicator-height, 1.375rem) - var(--gov-text-s-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 + var(--gov-form-switch-s-gap, 0.75rem))}.gov-form-switch[size=s] .gov-form-switch__holder{gap:var(--gov-form-switch-s-gap, 0.75rem)}.gov-form-switch[size=s] .gov-form-switch__indicator{width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667);height:var(--gov-form-switch-s-indicator-height, 1.375rem);border-radius:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 0.5)}.gov-form-switch[size=s] .gov-form-switch__indicator::before{top:calc(var(--gov-form-switch-s-toggle-offset, 0.0575rem) - 0.0625rem);left:calc(var(--gov-form-switch-s-toggle-offset, 0.0575rem) - 0.0625rem);width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) - 2 * var(--gov-form-switch-s-toggle-offset, 0.0575rem));height:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) - 2 * var(--gov-form-switch-s-toggle-offset, 0.0575rem))}.gov-form-switch[size=s] .gov-form-switch__input[aria-checked]+.gov-form-switch__indicator::before{left:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 - var(--gov-form-switch-s-indicator-height, 1.375rem) + var(--gov-form-switch-s-toggle-offset, 0.0575rem) - 0.0625rem)}.gov-form-switch[size=m] .gov-form-label__label{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);margin-bottom:0;margin-left:calc((var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 + var(--gov-form-switch-m-gap, 1rem)) * -1);padding-top:calc((var(--gov-form-switch-m-indicator-height, 1.5rem) - var(--gov-text-m-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 + var(--gov-form-switch-m-gap, 1rem))}.gov-form-switch[size=m] .gov-form-switch__holder{gap:var(--gov-form-switch-m-gap, 1rem)}.gov-form-switch[size=m] .gov-form-switch__indicator{width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667);height:var(--gov-form-switch-m-indicator-height, 1.5rem);border-radius:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 0.5)}.gov-form-switch[size=m] .gov-form-switch__indicator::before{top:calc(var(--gov-form-switch-m-toggle-offset, 0.0625rem) - 0.0625rem);left:calc(var(--gov-form-switch-m-toggle-offset, 0.0625rem) - 0.0625rem);width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) - 2 * var(--gov-form-switch-m-toggle-offset, 0.0625rem));height:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) - 2 * var(--gov-form-switch-m-toggle-offset, 0.0625rem))}.gov-form-switch[size=m] .gov-form-switch__input[aria-checked]+.gov-form-switch__indicator::before{left:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 - var(--gov-form-switch-m-indicator-height, 1.5rem) + var(--gov-form-switch-m-toggle-offset, 0.0625rem) - 0.0625rem)}.gov-form-switch[size=l] .gov-form-label__label{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);margin-bottom:0;margin-left:calc((var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 + var(--gov-form-switch-l-gap, 1rem)) * -1);padding-top:calc((var(--gov-form-switch-l-indicator-height, 2rem) - var(--gov-text-l-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 + var(--gov-form-switch-l-gap, 1rem))}.gov-form-switch[size=l] .gov-form-switch__holder{gap:var(--gov-form-switch-l-gap, 1rem)}.gov-form-switch[size=l] .gov-form-switch__indicator{width:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667);height:var(--gov-form-switch-l-indicator-height, 2rem);border-radius:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 0.5)}.gov-form-switch[size=l] .gov-form-switch__indicator::before{top:calc(var(--gov-form-switch-l-toggle-offset, 0.083125rem) - 0.0625rem);left:calc(var(--gov-form-switch-l-toggle-offset, 0.083125rem) - 0.0625rem);width:calc(var(--gov-form-switch-l-indicator-height, 2rem) - 2 * var(--gov-form-switch-l-toggle-offset, 0.083125rem));height:calc(var(--gov-form-switch-l-indicator-height, 2rem) - 2 * var(--gov-form-switch-l-toggle-offset, 0.083125rem))}.gov-form-switch[size=l] .gov-form-switch__input[aria-checked]+.gov-form-switch__indicator::before{left:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 - var(--gov-form-switch-l-indicator-height, 2rem) + var(--gov-form-switch-l-toggle-offset, 0.083125rem) - 0.0625rem)}';const p=class{constructor(r){o(this,r);this.govFocus=i(this,"gov-focus",7);this.govBlur=i(this,"gov-blur",7);this.govChange=i(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=s("GovCheckbox");this.h=v(this.host);this.f=c(this.h)}updateCheckedState(o){this.isChecked=o;this.govChange.emit({checked:this.isChecked,value:this.value})}validateSize(o){a(g,o,h.root)}componentWillLoad(){this.isChecked=this.checked;this.f.passAttrToControl("type","switch");this.h.passChildAttr(h.root,"identifier",this.identifier||this.checkboxId)}async componentDidRender(){if(n()){await d(500);await this.validateWcag()}}render(){const{isChecked:o}=this;return r(t,{class:h.root,"is-checked":o,size:this.size,invalid:m(this.invalid)},r("div",{class:h.holder},r("input",{class:h.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":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)}),r("span",{class:h.indicator}),r("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(){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 e(this)}static get watchers(){return{checked:["updateCheckedState"],size:["validateSize"]}}};p.style=w;export{p as gov_form_switch};
|
|
2
|
-
//# sourceMappingURL=p-8965f84a.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/switch/gov-form-switch.scss?tag=gov-form-switch","../../../packages/core/src/components/gov-form/switch/gov-form-switch.tsx"],"names":["govFormSwitchCss","GovFormSwitch","[object Object]","hostRef","this","checkboxId","createID","h","govHost","host","f","govForm","newValue","isChecked","govChange","emit","checked","value","validateProp","FormSwitchSizes","FormSwitchClass","root","passAttrToControl","passChildAttr","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","indicator","e","govFocus","govBlur","target","stopPropagation","validateWcagRef","validateWcagLabelFor"],"mappings":"meAAA,MAAMA,EAAmB,y+TCkBZC,EAAa,MAMzBC,YAAAC,2JAeqD,oBAKh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YAC7BjD,EAAA,OAAA,CAAM+B,KAAK,YAMPpC,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,EAAgBC,MAC3EyC,EAAgB1D,KAAKiD,eAAgB,mBAAoBjC,EAAgBC,MACzE0C,EAAqB3D,KAAKoB,YAAcpB,KAAKC,WAAYD,KAAKiD,eAAgBjC,EAAgBC","sourcesContent":["/*\n * Switch\n */\n\n$class: \".gov-form-switch\";\n$indicator-ratio: calc(5 / 3);\n\n#{$class} {\n\tposition: relative;\n\tdisplay: flex;\n\t&__holder {\n\t\tdisplay: inline-flex;\n\t}\n\t&__input {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tz-index: 1;\n\t\tmargin: 0;\n\t\tappearance: none;\n\t}\n\t.gov-form-label__label {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tmargin-bottom: 0;\n\t\tcolor: $form-switch-color;\n\t}\n\t&__indicator {\n\t\tposition: relative;\n\t\tflex: 0 0 auto;\n\t\tborder: $form-switch-indicator-border;\n\t\tbackground-color: $form-switch-indicator-bg;\n\t\ttransition: $t linear background-color;\n\t\t&::before {\n\t\t\t@include pseudo();\n\t\t\tborder-radius: 50%;\n\t\t\tbackground-color: $form-switch-indicator-circle-bg;\n\t\t\ttransition: $t linear left;\n\t\t\tbox-shadow: $form-switch-indicator-circle-box-shadow;\n\t\t}\n\t}\n\n\t// STATES\n\t// focus\n\t&__input:focus-visible ~ &__indicator {\n\t\toutline: $outline;\n\t}\n\t// checked\n\t&__input:checked + &__indicator {\n\t\tborder-color: $form-switch-indicator-bg-checked;\n\t\tbackground-color: $form-switch-indicator-bg-checked;\n\t}\n\n\t// disabled\n\t@include parameter(\"disabled\") {\n\t\tpointer-events: none;\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-disabled;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\t&::before {\n\t\t\t\t\tbackground: $form-state-bg-input-disabled;\n\t\t\t\t}\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t\t}\n\t\t}\n\t}\n\n\t// invalid\n\t@include parameter(\"invalid\") {\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-error;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\tborder-color: $form-state-color-error;\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tbackground-color: $form-state-color-error;\n\t\t\t}\n\t\t}\n\t}\n\n\t// sizes\n\t@each $size, $definitions in $form-switch-sizes {\n\t\t$indicator-width: calc(get(\"indicator-height\", $definitions) * $indicator-ratio);\n\t\t$indicator-height: get(\"indicator-height\", $definitions);\n\t\t$border-offset: calc(get(\"toggle-offset\", $definitions) - rem-calc(1));\n\n\t\t&[size=\"#{$size}\"] {\n\t\t\t.gov-form-label__label {\n\t\t\t\t@include typography($size);\n\t\t\t\tmargin-bottom: 0;\n\t\t\t\tmargin-left: calc(($indicator-width + get(\"gap\", $definitions)) * -1);\n\t\t\t\tpadding-top: calc(($indicator-height - (var(--gov-text-#{$size}-font-size) * 1.5)) / 2);\n\t\t\t\tpadding-left: calc($indicator-width + get(\"gap\", $definitions));\n\t\t\t}\n\t\t\t#{$class} {\n\t\t\t\t&__holder {\n\t\t\t\t\tgap: get(\"gap\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__indicator {\n\t\t\t\t\twidth: $indicator-width;\n\t\t\t\t\theight: $indicator-height;\n\t\t\t\t\tborder-radius: calc($indicator-height * 0.5);\n\t\t\t\t\t&::before {\n\t\t\t\t\t\ttop: $border-offset;\n\t\t\t\t\t\tleft: $border-offset;\n\t\t\t\t\t\twidth: calc($indicator-height - (2 * get(\"toggle-offset\", $definitions)));\n\t\t\t\t\t\theight: calc($indicator-height - (2 * get(\"toggle-offset\", $definitions)));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// STATES\n\t\t\t\t&__input[aria-checked] + #{$class}__indicator {\n\t\t\t\t\t&::before {\n\t\t\t\t\t\tleft: calc($indicator-width - $indicator-height + $border-offset);\n\t\t\t\t\t}\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 { FormSwitchClass, FormSwitchSizes, FormSwitchSizesType } 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 { GovFormSwitchChangeEvent } from './interfaces'\n\n@Component({\n\ttag: 'gov-form-switch',\n\tstyleUrl: 'gov-form-switch.scss',\n})\nexport class GovFormSwitch {\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: HTMLGovFormSwitchElement\n\t/**\n\t * Value of switch\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Switch 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 switch component disabled.\n\t * This prevents users from being able to interact with the switch, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the switch.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Switch's size.\n\t */\n\t@Prop() readonly size?: FormSwitchSizesType = 'm'\n\t/**\n\t * Custom switch 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 switch has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the switch loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the switch change value.\n\t */\n\t@Event({ eventName: 'gov-change' }) govChange: EventEmitter<GovFormSwitchChangeEvent>\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(FormSwitchSizes, newValue, FormSwitchClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.isChecked = this.checked\n\n\t\tthis.f.passAttrToControl('type', 'switch')\n\t\tthis.h.passChildAttr(FormSwitchClass.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={FormSwitchClass.root} is-checked={isChecked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormSwitchClass.holder}>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormSwitchClass.input}\n\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\ttype=\"checkbox\"\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 class={FormSwitchClass.indicator}></span>\n\t\t\t\t\t<slot name=\"label\"></slot>\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', FormSwitchClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormSwitchClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormSwitchClass.root)\n\t}\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as o,h as t,H as i,g as e}from"./p-682c7cc6.js";import{a as r}from"./p-561fa17b.js";import{g as n}from"./p-3f37ddb6.js";const l={root:"gov-tile",icon:"gov-tile__icon",arrow:"gov-tile__arrow",title:"gov-tile__title",link:"gov-tile__link",content:"gov-tile__content"};const a='.gov-tile__link::before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;z-index:1}.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-tile{position:relative;display:block;width:100%;padding:0.75rem;transition:background-color 150ms}.gov-tile__icon{display:flex;margin:0rem 0rem 0.75rem;color:var(--gov-tile-main-color, var(--gov-color-primary))}.gov-tile__icon .gov-icon{width:2.5rem;height:2.5rem}.gov-tile__title{font-weight:var(--gov-text-xl-font-weight);font-size:var(--gov-text-xl-font-size);line-height:var(--gov-text-xl-line-height);letter-spacing:var(--gov-text-xl-letter-spacing);margin:0 0 0.5rem}.gov-tile__link{display:flex;gap:0.5rem;justify-content:space-between;color:var(--gov-tile-main-color, var(--gov-color-primary));text-decoration:none}.gov-tile__arrow{flex:0 0 auto;width:0.75rem;height:2rem;margin:0.5rem;color:inherit}.gov-tile__content{color:var(--gov-tile-text-color, var(--gov-color-secondary-700))}.gov-tile__content>*:last-child{margin-bottom:0}.gov-tile__content a{position:relative;z-index:1}@media not all and (pointer: coarse){.gov-tile[href]:hover{background:var(--gov-tile-hover-bg, var(--gov-color-primary-200))}.gov-tile[href]:hover .gov-tile__link{color:var(--gov-tile-main-color, var(--gov-color-primary))}}@media (min-width: 30em){.gov-tile[promotion=""],.gov-tile[promotion=true i],.gov-tile[promotion="1"]{display:grid;grid-template-columns:auto 1fr;gap:0 0.875rem}.gov-tile[promotion=""] .gov-tile__icon,.gov-tile[promotion=true i] .gov-tile__icon,.gov-tile[promotion="1"] .gov-tile__icon{grid-area:1/1/3/1;margin:0}.gov-tile[promotion=""] .gov-tile__title,.gov-tile[promotion=true i] .gov-tile__title,.gov-tile[promotion="1"] .gov-tile__title{grid-area:1/2/1/2}.gov-tile[promotion=""] .gov-tile__content,.gov-tile[promotion=true i] .gov-tile__content,.gov-tile[promotion="1"] .gov-tile__content{grid-area:2/2/2/2}}@media (min-width: 48em){.gov-tile{padding:1.5rem}.gov-tile__icon{margin:0rem 0rem 1.5rem}.gov-tile__icon .gov-icon{width:3rem;height:3rem}}@media (min-width: 64em){.gov-tile[promotion=""],.gov-tile[promotion=true i],.gov-tile[promotion="1"]{gap:0 1.625rem}}';const g=class{constructor(t){o(this,t);this.promotion=false;this.href=undefined;this.name=undefined;this.h=n(this.host)}validateName(o){if(!o){r(`[${l.root}]: Parameter title is required.`)}}componentWillLoad(){this.validateName(this.name)}render(){return t(i,{class:this.h.classes(l.root),promotion:this.promotion},this.h.hasSlot("icon")&&t("div",{class:l.icon},t("slot",{name:"icon"})),t("h3",{class:l.title},this.href?t("a",{href:this.href,class:l.link},this.name,t("gov-icon",{class:l.arrow,name:"chevron-right"})):t("span",null,this.name)),t("div",{class:l.content},t("slot",null)))}get host(){return e(this)}static get watchers(){return{name:["validateName"]}}};g.style=a;export{g as gov_tile};
|
|
2
|
-
//# sourceMappingURL=p-a0dd0a95.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-tile/constants.ts","../../../packages/core/src/components/gov-tile/gov-tile.scss?tag=gov-tile","../../../packages/core/src/components/gov-tile/gov-tile.tsx"],"names":["TileClass","root","icon","arrow","title","link","content","govTileCss","GovTile","[object Object]","hostRef","this","h","govHost","host","newValue","govErrorLog","validateName","name","Host","class","classes","promotion","hasSlot","href"],"mappings":"iIAAO,MAAMA,EAAY,CACxBC,KAAM,WACNC,KAAM,iBACNC,MAAO,kBACPC,MAAO,kBACPC,KAAM,iBACNC,QAAS,qBCNV,MAAMC,EAAa,8tECUNC,EAAO,MAGnBC,YAAAC,4BAQsC,8CAPrCC,KAAKC,EAAIC,EAAQF,KAAKG,MAmBvBL,aAAaM,GACZ,IAAKA,EAAU,CACdC,EAAY,IAAIhB,EAAUC,wCAI5BQ,oBACCE,KAAKM,aAAaN,KAAKO,MAGxBT,SAEC,OACCG,EAACO,EAAI,CAACC,MAAOT,KAAKC,EAAES,QAAQrB,EAAUC,MAAOqB,UAAWX,KAAKW,WAC3DX,KAAKC,EAAEW,QAAQ,SACfX,EAAA,MAAA,CAAKQ,MAAOpB,EAAUE,MACrBU,EAAA,OAAA,CAAMM,KAAK,UAGbN,EAAA,KAAA,CAAIQ,MAAOpB,EAAUI,OACnBO,KAAKa,KACLZ,EAAA,IAAA,CAAGY,KAAMb,KAAKa,KAAMJ,MAAOpB,EAAUK,MACnCM,KAAKO,KACNN,EAAA,WAAA,CAAUQ,MAAOpB,EAAUG,MAAOe,KAAK,mBAGxCN,EAAA,OAAA,KAAOD,KAAKO,OAGdN,EAAA,MAAA,CAAKQ,MAAOpB,EAAUM,SACrBM,EAAA,OAAA","sourcesContent":["export const TileClass = {\n\troot: 'gov-tile',\n\ticon: 'gov-tile__icon',\n\tarrow: 'gov-tile__arrow',\n\ttitle: 'gov-tile__title',\n\tlink: 'gov-tile__link',\n\tcontent: 'gov-tile__content',\n}\n","/*\n * Tile\n */\n\n$class: \".gov-tile\";\n\n#{$class} {\n\t@include base();\n\tpadding: rem-calc(12);\n\ttransition: background-color $t;\n\t&__icon {\n\t\tdisplay: flex;\n\t\tmargin: rem-calc(0 0 12);\n\t\tcolor: $tile-main-color;\n\t\t.gov-icon {\n\t\t\twidth: rem-calc(40);\n\t\t\theight: rem-calc(40);\n\t\t}\n\t}\n\t&__title {\n\t\t@include typography($font-size-xl);\n\t\tmargin: 0 0 rem-calc(8);\n\t}\n\t&__link {\n\t\t@extend %link-mask;\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8);\n\t\tjustify-content: space-between;\n\t\tcolor: $tile-main-color;\n\t\ttext-decoration: none;\n\t}\n\t&__arrow {\n\t\tflex: 0 0 auto;\n\t\twidth: rem-calc(12);\n\t\theight: rem-calc(32);\n\t\tmargin: rem-calc(8);\n\t\tcolor: inherit;\n\t}\n\t&__content {\n\t\t@include reset-last-margin();\n\t\tcolor: $tile-text-color;\n\t\ta {\n\t\t\tposition: relative;\n\t\t\tz-index: 1;\n\t\t}\n\t}\n\n\t// HOVERS\n\t&[href] {\n\t\t@include hover() {\n\t\t\tbackground: $tile-hover-bg;\n\t\t\t#{$class} {\n\t\t\t\t&__link {\n\t\t\t\t\tcolor: $tile-main-color;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// MQ\n\t@include mq($from: sm) {\n\t\t// VARIANTS\n\t\t@include parameter(\"promotion\") {\n\t\t\tdisplay: grid;\n\t\t\tgrid-template-columns: auto 1fr;\n\t\t\tgap: 0 rem-calc(14);\n\t\t\t#{$class} {\n\t\t\t\t&__icon {\n\t\t\t\t\tgrid-area: 1/1/3/1;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t\t&__title {\n\t\t\t\t\tgrid-area: 1/2/1/2;\n\t\t\t\t}\n\t\t\t\t&__content {\n\t\t\t\t\tgrid-area: 2/2/2/2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t@include mq($from: md) {\n\t\tpadding: rem-calc(24);\n\t\t&__icon {\n\t\t\tmargin: rem-calc(0 0 24);\n\t\t\t.gov-icon {\n\t\t\t\twidth: rem-calc(48);\n\t\t\t\theight: rem-calc(48);\n\t\t\t}\n\t\t}\n\t}\n\t@include mq($from: lg) {\n\t\t// VARIANTS\n\t\t@include parameter(\"promotion\") {\n\t\t\tgap: 0 rem-calc(26);\n\t\t}\n\t}\n}\n","import { Component, Element, h, Host, Prop, Watch } from '@stencil/core'\nimport { govErrorLog } from '../../helpers/Log/gov.log'\nimport { TileClass } from './constants'\nimport { govHost } from '../../helpers/Dom/template'\nimport { GovHost } from '../../helpers/Dom/template.types'\n\n@Component({\n\ttag: 'gov-tile',\n\tstyleUrl: 'gov-tile.scss',\n})\nexport class GovTile {\n\tprivate h: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovTileElement\n\t/**\n\t * Style variation of the card.\n\t */\n\t@Prop() readonly promotion: boolean = false\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 * Item name\n\t */\n\t@Prop() readonly name: string\n\n\t@Watch('name')\n\tvalidateName(newValue: string): void {\n\t\tif (!newValue) {\n\t\t\tgovErrorLog(`[${TileClass.root}]: Parameter title is required.`)\n\t\t}\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateName(this.name)\n\t}\n\n\trender() {\n\t\t// tag type\n\t\treturn (\n\t\t\t<Host class={this.h.classes(TileClass.root)} promotion={this.promotion}>\n\t\t\t\t{this.h.hasSlot('icon') && (\n\t\t\t\t\t<div class={TileClass.icon}>\n\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<h3 class={TileClass.title}>\n\t\t\t\t\t{this.href ? (\n\t\t\t\t\t\t<a href={this.href} class={TileClass.link}>\n\t\t\t\t\t\t\t{this.name}\n\t\t\t\t\t\t\t<gov-icon class={TileClass.arrow} name=\"chevron-right\"></gov-icon>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<span>{this.name}</span>\n\t\t\t\t\t)}\n\t\t\t\t</h3>\n\t\t\t\t<div class={TileClass.content}>\n\t\t\t\t\t<slot />\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.scss?tag=gov-form-autocomplete","../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.tsx"],"names":["govFormAutocompleteCss","GovFormAutocomplete","[object Object]","hostRef","this","templateResolver","item","nameKey","listBoxId","createID","newValue","validateProp","FormAutocompleteVariants","FormAutocompleteClass","root","FormAutocompleteSizes","arrowCounter","list","length","Number","isInteger","minlength","String","value","processing","searchCallback","then","response","catch","finally","validateVariant","variant","validateSize","size","h","Host","class","placeholder","name","disabled","readonly","autocomplete","required","invalid","role","maxlength","on-gov-input","throttle","onInputHandler","bind","on-gov-keyup","onKeyUpHandler","on-gov-focus","onFocusHandler","on-gov-blur","onBlurHandler","wcagAutocomplete","wcagDescribedBy","wcagLabelledBy","wcagOwns","join","wcagExpanded","focused","ref","el","inputRef","slot","id","map","index","isSelected","innerHTML","aria-posinset","tabindex","aria-setsize","onClick","onSelectHandler","aria-selected","toBoolAttr","e","doSearch","stopPropagation","govFocus","emit","setTimeout","govBlur","target","govInput","selected","has","govSelect","event","detail","keyCode","onArrowUp","onArrowDown","options","focus","clearValue","callback"],"mappings":"iVAAA,MAAMA,EAAyB,khDCclBC,EAAmB,MAM/BC,YAAAC,6JAFQC,KAAAC,iBAAiFC,GAAQA,EAAKF,KAAKG,oBAU3D,qFAgBZ,iBAID,yCASE,uHAqBA,uJAmCf,yBACG,YACkB,GA9F1CH,KAAKI,UAAYC,EAAS,cAiG3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AKJ,GACnB3E,KAAK4E,WAGE9E,gBAAgBmE,GAAS,GAChC,IAAImB,EAA8C,KAClD,GAAInB,GAAS,EAAG,CACfmB,EAAWpF,KAAKa,KAAKoD,QACf,GAAIoB,EAAIrF,KAAKY,aAAcZ,KAAKa,MAAO,CAC7CuE,EAAWpF,KAAKa,KAAKb,KAAKY,cAE3B,GAAIwE,EAAU,CACbpF,KAAKsF,UAAUP,KAAKK,GACpBpF,KAAKa,KAAO,GACZ,GAAIwE,EAAIrF,KAAKG,QAASiF,WAAoBA,EAASpF,KAAKG,WAAa,SAAU,CAC9EH,KAAKmB,MAAQiE,EAASpF,KAAKG,WAKtBL,eAAe6E,GACtB,MAAMY,EAAQZ,EAAEa,OAChBb,EAAEE,kBACF,GAAIU,EAAME,UAAY,GAAIzF,KAAK0F,iBAC1B,GAAIH,EAAME,UAAY,GAAIzF,KAAK2F,mBAC/B,GAAIJ,EAAME,UAAY,GAAIzF,KAAKwE,kBAOrC1E,eAAe8F,GACd,OAAO5F,KAAK6D,SAASgC,MAAMD,GAO5B9F,mBACCE,KAAKmB,MAAQ,GACbnB,KAAK6D,SAAS1C,MAAQ,SAEhBnB,KAAK6D,SAASiC,aAOrBhG,wBAAwBiG,GACvB/F,KAAKqB,eAAiB0E,EAQvBjG,0BAA0BiG,GACzB/F,KAAKC,iBAAmB8F","sourcesContent":["$class: \".gov-form-autocomplete\";\n\n#{$class} {\n\t@include base();\n\t&__list {\n\t\t@include typography($font-size-s);\n\t\t@extend %reset-ul;\n\t\tposition: absolute;\n\t\ttop: 100%;\n\t\tright: 0;\n\t\tleft: 0;\n\t\tz-index: 5;\n\t\tmax-height: rem-calc(225);\n\t\tmargin-top: rem-calc(8);\n\t\tborder: $form-autocomplete-border;\n\t\tborder-radius: $border-radius;\n\t\tbackground: $form-autocomplete-bg;\n\t\toverflow-x: hidden;\n\t\toverflow-y: auto;\n\t\toverscroll-behavior: none;\n\t}\n\t&__list > &__item {\n\t\t@extend %reset-ul-li;\n\t\tpadding: rem-calc(12 8);\n\t\tcursor: pointer;\n\t}\n\n\t// STATES\n\t&__list:empty {\n\t\tdisplay: none;\n\t}\n\n\t// HOVERS\n\t&__item {\n\t\t@include parameter(\"aria-selected\") {\n\t\t\tbackground: $form-autocomplete-item-select-bg;\n\t\t}\n\t\t@include hover() {\n\t\t\tbackground: $form-autocomplete-item-hover-bg;\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch, Event, EventEmitter, State, Method } from '@stencil/core'\nimport { SizesType } from './constants'\nimport { createID } from '../../../utils/string.utils'\nimport { FormAutocompleteClass, FormAutocompleteVariants, VariantType, FormAutocompleteSizes } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { has, throttle } from '../../../utils/utils'\nimport { GovFormAutocompleteItem } from './gov-form-autocomplete.types'\nimport { toBoolAttr } from '../../../helpers/Dom/template'\nimport { Nullable } from '../../../types/interfaces'\n\n@Component({\n\ttag: 'gov-form-autocomplete',\n\tstyleUrl: 'gov-form-autocomplete.scss',\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\n\tconstructor() {\n\t\tthis.listBoxId = createID('GovListBox')\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value = ''\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: VariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = 'm'\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop() readonly nameKey: string = 'name'\n\t/**\n\t * Name of the input.\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 input 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 * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: 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 * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 2\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\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 * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-owns\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-input' }) govInput: EventEmitter<InputEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-select' }) govSelect: EventEmitter<GovFormAutocompleteItem>\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteVariants, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && String(this.value).length <= this.minlength && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\trole={'searchbox'}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), 200)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\twcagAutocomplete={'list'}\n\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\twcagOwns={[this.listBoxId, this.wcagOwns].join(' ')}\n\t\t\t\t\twcagExpanded={this.list.length && this.focused}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot slot=\"right-icon\" name=\"right-icon\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list} role={'listbox'} id={this.listBoxId}>\n\t\t\t\t\t{this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={'option'}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonClick={() => this.onSelectHandler(index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t/>\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.arrowCounter = -1\n\t\tif ((this.value || this.minlength === 0) && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tsetTimeout(() => (this.list = []), 200)\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit(e)\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit(selected)\n\t\t\tthis.list = []\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === 'string') {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = e.detail as KeyboardEvent\n\t\te.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) this.onSelectHandler()\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.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.scss?tag=gov-form-file","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"names":["FormFileClass","root","area","label","input","list","item","attachments","formatBytes","bytes","units","l","n","parseInt","toFixed","fileAcceptValidation","file","accept","length","replace","split","filter","RegExp","test","type","fileSizeValidation","maxSize","fileSize","Math","round","size","govFormFileCss","GovFormFile","[object Object]","hostRef","this","fileId","createID","h","govHost","host","f","govForm","highlight","areaRef","classList","add","unhighlight","remove","inputRef","addEventListener","e","preventDefault","stopPropagation","files","target","validateFiles","expanded","events","inEvents","outEvents","map","eventName","preventDefaults","bind","forEach","handleDrop","dataTransfer","Array","from","isFile","find","name","isSizeValid","maxFileSize","isAcceptValid","newFile","id","acceptValid","sizeValid","govAddFile","emit","govFiles","passAttrToControl","canValidateWcagOnRender","delay","validateWcag","registerListeners","Host","class","classes","invalid","toBoolAttrIfDefined","ref","el","identifier","onFocus","onFocusHandler","onBlur","onBlurHandler","required","disabled","aria-required","aria-invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-disabled","hasSlot","displayAttachments","wcagAttachmentsLabel","wcag-label","wcag-remove-labelled-by","on-gov-remove","onRemoveFileHandler","wcagRemoveLabel","slot","variant","errorAccept","errorSize","index","findIndex","removeFile","splice","govRemovFile","govFocus","govBlur","validateWcagRef","validateWcagLabelFor"],"mappings":"sbAAO,MAAMA,EAAgB,CAC5BC,KAAM,gBACNC,KAAM,sBACNC,MAAO,uBACPC,MAAO,uB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,KAAK,UAAUC,QAAQ,SACxChF,EAAA,WAAA,CAAU+E,KAAK,OAAO7C,KAAK,8BAC1BlE,EAAKwE,cAAgB,MAAQ3C,KAAKoF,YAAc,MAE/C,KACHjH,EAAKyE,YAAc,MACnBzC,EAAA,mBAAA,CAAkB+E,KAAK,UAAUC,QAAQ,SACxChF,EAAA,WAAA,CAAU+E,KAAK,OAAO7C,KAAK,8BAC1BrC,KAAKqF,UAAUrG,QAAQ,cAAeX,EAAY2B,KAAKuC,YAAc,QAEpE,KACJpC,EAAA,OAAA,CAAM+E,KAAK,QAAM,IAAG7G,EAAYF,EAAKU,KAAKc,MAAK,UAKhD,MAKCG,oBAAoBjB,GAC3B,MAAMyG,EAAQtF,KAAKmB,MAAMoE,WAAUpH,GAAQA,EAAKuE,KAAO7D,EAAK6D,KAC5D,GAAI4C,KAAW,EAAG,CACjB,MAAMnE,EAAQnB,KAAKmB,MACnB,MAAMqE,EAAaxF,KAAKmB,MAAMmE,GAC9BnE,EAAMsE,OAAOH,EAAO,GACpBtF,KAAKmB,MAAQ,IAAIA,GACjBnB,KAAK0F,aAAa5C,KAAK0C,GACvBxF,KAAK+C,SAASD,KAAK9C,KAAKmB,QAIlBrB,eAAekB,GACtBA,EAAEC,iBACFjB,KAAK2F,SAAS7C,KAAK9B,GAGZlB,cAAckB,GACrBA,EAAEC,iBACFjB,KAAK4F,QAAQ9C,KAAK9B,GAOnBlB,qBACC+F,EAAgB7F,KAAKsE,gBAAiB,oBAAqBzG,EAAcC,MACzE+H,EAAgB7F,KAAKwE,eAAgB,mBAAoB3G,EAAcC,MACvEgI,EAAqB9F,KAAK4D,YAAc5D,KAAKC,OAAQD,KAAKwE,eAAgB3G,EAAcC","sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tlabel: 'gov-form-file__label',\n\tinput: 'gov-form-file__input',\n\tlist: 'gov-form-file__list',\n\titem: 'gov-form-file__item',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept === 'string' && accept.length) {\n\t\treturn (\n\t\t\taccept\n\t\t\t\t.replace(/\\s/g, '')\n\t\t\t\t.split(',')\n\t\t\t\t.filter(accept => {\n\t\t\t\t\treturn new RegExp(accept.replace('*', '.*')).test(file.type)\n\t\t\t\t}).length > 0\n\t\t)\n\t} else {\n\t\treturn true\n\t}\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size / 1024)\n\treturn fileSize <= maxSize\n}\n","/*\n * File\n */\n\n$class: \".gov-form-file\";\n\n#{$class} {\n\t@include base();\n\t&__label .gov-form-label__label {\n\t\t@include reset-last-margin();\n\t}\n\t&__input {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\topacity: 0.0001;\n\t\tcursor: pointer;\n\t}\n\t&__attachments {\n\t\tmargin-top: rem-calc(16 0 0);\n\t}\n\t&__item {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(16);\n\t\talign-items: center;\n\t}\n\n\t// STATES\n\t@include parameter(\"disabled\") {\n\t\t#{$class} {\n\t\t\t&__label .gov-form-label__label {\n\t\t\t\tpointer-events: none;\n\t\t\t\t* {\n\t\t\t\t\tcolor: $form-file-disabled-color;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@include parameter(\"expanded\") {\n\t\t#{$class} {\n\t\t\t&__area {\n\t\t\t\tposition: relative;\n\t\t\t\twidth: 100%;\n\t\t\t\tpadding: rem-calc(32) rem-calc(22) rem-calc(22);\n\t\t\t\tborder: $form-file-border;\n\t\t\t\ttext-align: center;\n\t\t\t\ttransition: background-color $t ease-in-out;\n\t\t\t\twill-change: background-color;\n\t\t\t\t&.highlight {\n\t\t\t\t\tbackground-color: color(\"primary.200\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t&__label .gov-form-label__label {\n\t\t\t\twidth: 100%;\n\t\t\t\tpadding: rem-calc(22);\n\t\t\t\tborder: $form-file-border;\n\t\t\t\ttext-align: center;\n\t\t\t}\n\t\t\t&__attachments {\n\t\t\t\tmargin: rem-calc(24 0 0);\n\t\t\t}\n\t\t}\n\n\t\t// STATES\n\t\t@include parameter(\"invalid\") {\n\t\t\t#{$class} {\n\t\t\t\t&__label .gov-form-label__label {\n\t\t\t\t\tborder-color: $form-state-color-error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// MQ\n\t@include mq($from: sm) {\n\t\t@include parameter(\"expanded\") {\n\t\t\t#{$class} {\n\t\t\t\t&__label .gov-form-label__label {\n\t\t\t\t\tpadding: rem-calc(32);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Host, h, Prop, Event, EventEmitter, Element, Method, State } from '@stencil/core'\nimport { createID } from '../../../utils/string.utils'\nimport { FormFileClass } from './constants'\nimport { toBoolAttrIfDefined } from '../../../helpers/Dom/template'\nimport { validateWcagLabelFor, validateWcagRef } from '../../../helpers/Validate/wcag'\nimport { canValidateWcagOnRender } from '../../../helpers/Dom/win'\nimport { fileAcceptValidation, fileSizeValidation, formatBytes } from '../../../utils/file.utils'\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 { GovFormFileItem } from './gov-form-file.types'\n\n@Component({\n\ttag: 'gov-form-file',\n\tstyleUrl: 'gov-form-file.scss',\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\n\tconstructor() {\n\t\tthis.fileId = createID('GovInputFile')\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: 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 File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({ attribute: 'display-attachments' }) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({ attribute: 'max-file-size' }) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File 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 * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({ attribute: 'error-size' }) readonly errorSize: string = 'Soubor je větší než povolená velikost {FILE_SIZE}'\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({ attribute: 'error-accept' }) readonly errorAccept: string = 'Soubor tohoto typu není povolen'\n\t/**\n\t * Description of the list of attachments\n\t */\n\t@Prop({ attribute: 'attachments-label' }) readonly attachmentsLabel: string = 'Přílohy'\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 * Adds accessible label for the remove button that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: 'wcag-remove-label' }) readonly wcagRemoveLabel: string = 'Odebrat soubor {FILE_NAME}'\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({ attribute: 'wcag-attachments-label' }) readonly wcagAttachmentsLabel: string = 'Přílohy'\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({ eventName: 'gov-files' }) govFiles: EventEmitter<GovFormFileItem[]>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({ eventName: 'gov-add-file' }) govAddFile: EventEmitter<GovFormFileItem>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({ eventName: 'gov-remove-file' }) govRemovFile: EventEmitter<GovFormFileItem>\n\n\t@State() files: GovFormFileItem[] = []\n\n\tprivate registerListeners() {\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add('highlight')\n\t\t}\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove('highlight')\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t'change',\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tthis.validateFiles(files)\n\t\t\t},\n\t\t\tfalse\n\t\t)\n\t\t//this.inputRef.addEventListener('focus')\n\n\t\tif (this.expanded) {\n\t\t\tconst events = ['dragover', 'dragleave']\n\t\t\tconst inEvents = ['dragenter', 'dragover', 'mouseenter']\n\t\t\tconst outEvents = ['dragleave', 'drop', 'mouseleave']\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\n\t\t\tthis.areaRef.addEventListener('drop', this.handleDrop.bind(this), false)\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tArray.from(files).map(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === 'number' && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID('GovFormFile'),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\tthis.govAddFile.emit(newFile)\n\t\t\t}\n\t\t})\n\n\t\tthis.govFiles.emit(this.files)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToControl('type', 'File')\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\n\t\tthis.registerListeners()\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])} invalid={toBoolAttrIfDefined(this.invalid)} expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot />\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\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\tdisabled={this.disabled}\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</div>\n\n\t\t\t\t{this.h.hasSlot('attachments') ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={'attachments'} />\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.wcagAttachmentsLabel} wcag-label={this.wcagAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item wcag-remove-labelled-by={item.id} on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t<span class={'sr-only'} id={item.id}>\n\t\t\t\t\t\t\t\t\t\t{this.wcagRemoveLabel.replace('{FILE_NAME}', item.file.name)}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" variant=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" variant=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace('{FILE_SIZE}', formatBytes(this.maxFileSize * 1024))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.govRemovFile.emit(removeFile)\n\t\t\tthis.govFiles.emit(this.files)\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.preventDefault()\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.preventDefault()\n\t\tthis.govBlur.emit(e)\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', FormFileClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormFileClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.fileId, this.wcagLabelledBy, FormFileClass.root)\n\t}\n}\n"]}
|
|
File without changes
|