@gov-design-system-ce/components 0.0.56 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/gov-accordion-item.cjs.entry.js +1 -1
- package/dist/cjs/gov-accordion-item.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-app.cjs.entry.js +71 -6
- package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-badge.cjs.entry.js +1 -1
- package/dist/cjs/gov-badge.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-button.cjs.entry.js +1 -1
- package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-input.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-radio.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-select.cjs.entry.js +2 -2
- package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-switch.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-icon.cjs.entry.js +2 -2
- package/dist/cjs/gov-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-loading.cjs.entry.js +2 -3
- package/dist/cjs/gov-loading.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-modal.cjs.entry.js +1 -1
- package/dist/cjs/gov-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-prompt.cjs.entry.js +1 -1
- package/dist/cjs/gov-prompt.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-stepper-item.cjs.entry.js +1 -1
- package/dist/cjs/gov-stepper-item.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-toast.cjs.entry.js +9 -15
- package/dist/cjs/gov-toast.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-wizard-item.cjs.entry.js +1 -1
- package/dist/cjs/gov-wizard-item.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/gov-accordion/gov-accordion-item.css +1 -0
- package/dist/collection/components/gov-badge/gov-badge.css +12 -12
- package/dist/collection/components/gov-button/default/gov-button.css +12 -12
- package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.css +1 -0
- package/dist/collection/components/gov-form/input/gov-form-input.css +17 -7
- package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.css +32 -11
- package/dist/collection/components/gov-form/radio/gov-form-radio.css +1 -0
- package/dist/collection/components/gov-form/select/gov-form-select.css +29 -11
- package/dist/collection/components/gov-form/select/gov-form-select.js +1 -1
- package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
- package/dist/collection/components/gov-form/switch/gov-form-switch.css +4 -8
- package/dist/collection/components/gov-icon/gov-icon.css +6 -2
- package/dist/collection/components/gov-icon/list.js +10 -0
- package/dist/collection/components/gov-icon/list.js.map +1 -1
- package/dist/collection/components/gov-loading/loading/gov-loading.css +4 -3
- package/dist/collection/components/gov-loading/loading/gov-loading.js +1 -24
- package/dist/collection/components/gov-loading/loading/gov-loading.js.map +1 -1
- package/dist/collection/components/gov-modal/gov-modal.css +0 -4
- package/dist/collection/components/gov-promp/gov-prompt.css +0 -4
- package/dist/collection/components/gov-stepper/gov-stepper-item.css +0 -1
- package/dist/collection/components/gov-toast/gov-toast.js +15 -21
- package/dist/collection/components/gov-toast/gov-toast.js.map +1 -1
- package/dist/collection/components/gov-wizard/gov-wizard-item.css +3 -1
- package/dist/collection/pages/Accordion.js +2 -2
- package/dist/collection/pages/Accordion.js.map +1 -1
- package/dist/collection/pages/Forms.js +69 -4
- package/dist/collection/pages/Forms.js.map +1 -1
- package/dist/components/gov-accordion-item.js +1 -1
- package/dist/components/gov-accordion-item.js.map +1 -1
- package/dist/components/gov-alert.js +1 -1
- package/dist/components/gov-app.js +1 -1
- package/dist/components/gov-app.js.map +1 -1
- package/dist/components/gov-attachments-item.js +1 -1
- package/dist/components/gov-badge.js +1 -1
- package/dist/components/gov-button.js +1 -1
- package/dist/components/gov-card.js +1 -1
- package/dist/components/gov-form-autocomplete.js +1 -1
- package/dist/components/gov-form-checkbox.js +1 -1
- package/dist/components/gov-form-checkbox.js.map +1 -1
- package/dist/components/gov-form-file.js +1 -1
- package/dist/components/gov-form-input.js +1 -1
- package/dist/components/gov-form-multi-select.js +1 -1
- package/dist/components/gov-form-multi-select.js.map +1 -1
- package/dist/components/gov-form-radio.js +1 -1
- package/dist/components/gov-form-radio.js.map +1 -1
- package/dist/components/gov-form-select.js +1 -1
- package/dist/components/gov-form-switch.js +1 -1
- package/dist/components/gov-form-switch.js.map +1 -1
- package/dist/components/gov-icon.js +1 -1
- package/dist/components/gov-loading.js +1 -1
- package/dist/components/gov-loading.js.map +1 -1
- package/dist/components/gov-modal.js +1 -1
- package/dist/components/gov-modal.js.map +1 -1
- package/dist/components/gov-pagination.js +1 -1
- package/dist/components/gov-prompt.js +1 -1
- package/dist/components/gov-prompt.js.map +1 -1
- package/dist/components/gov-side-nav-item.js +1 -1
- package/dist/components/gov-stepper-item.js +1 -1
- package/dist/components/gov-stepper-item.js.map +1 -1
- package/dist/components/gov-tabs.js +1 -1
- package/dist/components/gov-tile.js +1 -1
- package/dist/components/gov-toast.js +1 -1
- package/dist/components/gov-toast.js.map +1 -1
- package/dist/components/gov-wizard-item.js +1 -1
- package/dist/components/gov-wizard-item.js.map +1 -1
- package/dist/components/{p-a2e601c5.js → p-0378da4d.js} +2 -2
- package/dist/components/{p-a2e601c5.js.map → p-0378da4d.js.map} +1 -1
- package/dist/components/p-35f6490a.js +2 -0
- package/dist/components/{p-04bfe959.js.map → p-35f6490a.js.map} +1 -1
- package/dist/components/{p-6ca0c464.js → p-70d9d879.js} +2 -2
- package/dist/components/{p-6ca0c464.js.map → p-70d9d879.js.map} +1 -1
- package/dist/components/{p-f516d8f6.js → p-9cba3cd3.js} +2 -2
- package/dist/components/p-a6915747.js +2 -0
- package/dist/components/p-a6915747.js.map +1 -0
- package/dist/components/p-da3b225f.js +2 -0
- package/dist/components/{p-2753b6e4.js.map → p-da3b225f.js.map} +1 -1
- package/dist/components/{p-594ba760.js → p-ee60cdd1.js} +2 -2
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/p-2944bf77.entry.js +2 -0
- package/dist/core/{p-64f7e661.entry.js.map → p-2944bf77.entry.js.map} +1 -1
- package/dist/core/p-2bb9f781.entry.js +2 -0
- package/dist/core/p-2bb9f781.entry.js.map +1 -0
- package/dist/core/p-4c79a97a.entry.js +2 -0
- package/dist/core/p-4c79a97a.entry.js.map +1 -0
- package/dist/core/p-667dc3de.entry.js +2 -0
- package/dist/core/p-667dc3de.entry.js.map +1 -0
- package/dist/core/p-69f944d1.entry.js +2 -0
- package/dist/core/p-69f944d1.entry.js.map +1 -0
- package/dist/core/{p-bfb4d904.entry.js → p-6a65af35.entry.js} +2 -2
- package/dist/core/{p-bfb4d904.entry.js.map → p-6a65af35.entry.js.map} +1 -1
- package/dist/core/p-85258200.entry.js +2 -0
- package/dist/core/{p-f0a5847a.entry.js.map → p-85258200.entry.js.map} +1 -1
- package/dist/core/p-8fce08d1.entry.js +2 -0
- package/dist/core/p-8fce08d1.entry.js.map +1 -0
- package/dist/core/p-9bfab069.entry.js +2 -0
- package/dist/core/{p-fc853777.entry.js.map → p-9bfab069.entry.js.map} +1 -1
- package/dist/core/p-a85f4a62.entry.js +2 -0
- package/dist/core/p-a85f4a62.entry.js.map +1 -0
- package/dist/core/{p-accf8575.entry.js → p-af646ce2.entry.js} +2 -2
- package/dist/core/{p-accf8575.entry.js.map → p-af646ce2.entry.js.map} +1 -1
- package/dist/core/p-cacd0fed.entry.js +2 -0
- package/dist/core/{p-22a86871.entry.js.map → p-cacd0fed.entry.js.map} +1 -1
- package/dist/core/p-d4cfa93a.entry.js +2 -0
- package/dist/core/{p-81643870.entry.js.map → p-d4cfa93a.entry.js.map} +1 -1
- package/dist/core/{p-3858e2c8.entry.js → p-dd39ede4.entry.js} +2 -2
- package/dist/core/p-dd39ede4.entry.js.map +1 -0
- package/dist/core/p-de5c9181.entry.js +2 -0
- package/dist/core/p-de5c9181.entry.js.map +1 -0
- package/dist/core/p-f8252fea.entry.js +2 -0
- package/dist/core/{p-ea4459ae.entry.js.map → p-f8252fea.entry.js.map} +1 -1
- package/dist/core/p-fb99f144.entry.js +2 -0
- package/dist/core/p-fb99f144.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/gov-accordion-item.entry.js +1 -1
- package/dist/esm/gov-accordion-item.entry.js.map +1 -1
- package/dist/esm/gov-app.entry.js +71 -6
- package/dist/esm/gov-app.entry.js.map +1 -1
- package/dist/esm/gov-badge.entry.js +1 -1
- package/dist/esm/gov-badge.entry.js.map +1 -1
- package/dist/esm/gov-button.entry.js +1 -1
- package/dist/esm/gov-button.entry.js.map +1 -1
- package/dist/esm/gov-form-checkbox.entry.js +1 -1
- package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
- package/dist/esm/gov-form-input.entry.js +1 -1
- package/dist/esm/gov-form-input.entry.js.map +1 -1
- package/dist/esm/gov-form-multi-select.entry.js +1 -1
- package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
- package/dist/esm/gov-form-radio.entry.js +1 -1
- package/dist/esm/gov-form-radio.entry.js.map +1 -1
- package/dist/esm/gov-form-select.entry.js +2 -2
- package/dist/esm/gov-form-select.entry.js.map +1 -1
- package/dist/esm/gov-form-switch.entry.js +1 -1
- package/dist/esm/gov-form-switch.entry.js.map +1 -1
- package/dist/esm/gov-icon.entry.js +2 -2
- package/dist/esm/gov-icon.entry.js.map +1 -1
- package/dist/esm/gov-loading.entry.js +2 -3
- package/dist/esm/gov-loading.entry.js.map +1 -1
- package/dist/esm/gov-modal.entry.js +1 -1
- package/dist/esm/gov-modal.entry.js.map +1 -1
- package/dist/esm/gov-prompt.entry.js +1 -1
- package/dist/esm/gov-prompt.entry.js.map +1 -1
- package/dist/esm/gov-stepper-item.entry.js +1 -1
- package/dist/esm/gov-stepper-item.entry.js.map +1 -1
- package/dist/esm/gov-toast.entry.js +9 -15
- package/dist/esm/gov-toast.entry.js.map +1 -1
- package/dist/esm/gov-wizard-item.entry.js +1 -1
- package/dist/esm/gov-wizard-item.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/hydrate/index.js +98 -42
- package/dist/types/components/gov-loading/loading/gov-loading.d.ts +0 -4
- package/dist/types/components/gov-toast/gov-toast.d.ts +4 -6
- package/dist/types/components.d.ts +4 -12
- package/package.json +3 -3
- package/dist/components/p-04bfe959.js +0 -2
- package/dist/components/p-2753b6e4.js +0 -2
- package/dist/components/p-baf87688.js +0 -2
- package/dist/components/p-baf87688.js.map +0 -1
- package/dist/core/p-22a86871.entry.js +0 -2
- package/dist/core/p-23385300.entry.js +0 -2
- package/dist/core/p-23385300.entry.js.map +0 -1
- package/dist/core/p-3858e2c8.entry.js.map +0 -1
- package/dist/core/p-48cfc1c6.entry.js +0 -2
- package/dist/core/p-48cfc1c6.entry.js.map +0 -1
- package/dist/core/p-4df62a13.entry.js +0 -2
- package/dist/core/p-4df62a13.entry.js.map +0 -1
- package/dist/core/p-64f7e661.entry.js +0 -2
- package/dist/core/p-74f0be51.entry.js +0 -2
- package/dist/core/p-74f0be51.entry.js.map +0 -1
- package/dist/core/p-801f1147.entry.js +0 -2
- package/dist/core/p-801f1147.entry.js.map +0 -1
- package/dist/core/p-81643870.entry.js +0 -2
- package/dist/core/p-82f64673.entry.js +0 -2
- package/dist/core/p-82f64673.entry.js.map +0 -1
- package/dist/core/p-aa4e716e.entry.js +0 -2
- package/dist/core/p-aa4e716e.entry.js.map +0 -1
- package/dist/core/p-e769f3ee.entry.js +0 -2
- package/dist/core/p-e769f3ee.entry.js.map +0 -1
- package/dist/core/p-ea4459ae.entry.js +0 -2
- package/dist/core/p-f0a5847a.entry.js +0 -2
- package/dist/core/p-fc853777.entry.js +0 -2
- package/dist/globals.d.ts +0 -2
- package/dist/types/types/typings.d.ts +0 -6
- /package/dist/components/{p-f516d8f6.js.map → p-9cba3cd3.js.map} +0 -0
- /package/dist/components/{p-594ba760.js.map → p-ee60cdd1.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["govFormRadioCss","GovFormRadio","proxyCustomElement","H","constructor","this","radioId","createID","h","govHost","host","f","govForm","validateSize","newValue","validateProp","FormRadioSizes","FormRadioClass","root","watchDisabled","passControlAttrs","passAttrToControl","size","toBoolAttr","disabled","invalid","componentWillLoad","componentDidRender","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","render","wrapCheckbox","children","noLabel","Host","class","checked","toBoolAttrIfDefined","holder","Fragment","input","id","type","value","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","ref","el","inputRef","wcagDescribedBy","wcagLabelledBy","e","stopPropagation","govFocus","emit","component","originalEvent","govBlur","target","govChange","getRef","validateWcagRef","validateWcagLabelFor"],"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"],"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, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormRadioClass, FormRadioSizes, FormRadioSizesType } from \"./constants\"\nimport { govHost, toBoolAttr, 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.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormRadioEvent } from \"./gov-form-radio.types\"\n\n@Component({\n\ttag: \"gov-form-radio\",\n\tstyleUrl: \"gov-form-radio.scss\",\n})\nexport class GovFormRadio {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\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 * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Radio default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the 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<FormRadioEvent>\n\t/**\n\t * Emitted when the radio loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormRadioEvent>\n\t/**\n\t * Emitted when the radio change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormRadioEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormRadioSizes, newValue, FormRadioClass.root)\n\t}\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\t@Watch(\"size\")\n\twatchDisabled(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"size\", this.size)\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"type\", \"radio\")\n\t}\n\n\n\tcomponentWillLoad() {\n\t\tthis.passControlAttrs()\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.radioId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = children => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn <label>{children}</label>\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={FormRadioClass.root} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormRadioClass.holder}>\n\t\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tclass={FormRadioClass.input}\n\t\t\t\t\t\t\t\tid={this.identifier || this.radioId}\n\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\t\taria-checked={this.checked}\n\t\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Fragment>,\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", 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"],"mappings":"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"}
|
|
1
|
+
{"version":3,"names":["govFormRadioCss","GovFormRadio","proxyCustomElement","H","constructor","this","radioId","createID","h","govHost","host","f","govForm","validateSize","newValue","validateProp","FormRadioSizes","FormRadioClass","root","watchDisabled","passControlAttrs","passAttrToControl","size","toBoolAttr","disabled","invalid","componentWillLoad","componentDidRender","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","render","wrapCheckbox","children","noLabel","Host","class","checked","toBoolAttrIfDefined","holder","Fragment","input","id","type","value","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","ref","el","inputRef","wcagDescribedBy","wcagLabelledBy","e","stopPropagation","govFocus","emit","component","originalEvent","govBlur","target","govChange","getRef","validateWcagRef","validateWcagLabelFor"],"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"],"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, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormRadioClass, FormRadioSizes, FormRadioSizesType } from \"./constants\"\nimport { govHost, toBoolAttr, 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.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormRadioEvent } from \"./gov-form-radio.types\"\n\n@Component({\n\ttag: \"gov-form-radio\",\n\tstyleUrl: \"gov-form-radio.scss\",\n})\nexport class GovFormRadio {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\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 * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Radio default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the 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<FormRadioEvent>\n\t/**\n\t * Emitted when the radio loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormRadioEvent>\n\t/**\n\t * Emitted when the radio change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormRadioEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormRadioSizes, newValue, FormRadioClass.root)\n\t}\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\t@Watch(\"size\")\n\twatchDisabled(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"size\", this.size)\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"type\", \"radio\")\n\t}\n\n\n\tcomponentWillLoad() {\n\t\tthis.passControlAttrs()\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.radioId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = children => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn <label>{children}</label>\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={FormRadioClass.root} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormRadioClass.holder}>\n\t\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tclass={FormRadioClass.input}\n\t\t\t\t\t\t\t\tid={this.identifier || this.radioId}\n\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\t\taria-checked={this.checked}\n\t\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Fragment>,\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormRadioClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", 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"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{G as o,d as s}from"./p-
|
|
1
|
+
import{G as o,d as s}from"./p-da3b225f.js";const t=o;const a=s;export{t as GovFormSelect,a as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-form-select.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,H as i,c as t,h as r,d as e}from"./p-80c0109d.js";import{c as s}from"./p-24636c53.js";import{v as c}from"./p-26acf964.js";import{g as a,r as h,s as g}from"./p-17c1ffc1.js";import{g as v,a as m,t as l}from"./p-3f37ddb6.js";import{b as f,c as n}from"./p-ae894a40.js";import{c as d}from"./p-cac3881f.js";import{d as w}from"./p-03990da5.js";import{F as b}from"./p-1c1d0bbe.js";const _='.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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-form-switch{position:relative;display:flex}.gov-form-switch__holder{display:inline-flex}.gov-form-switch__input{position:relative;z-index:1;-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:absolute;top:0;left:0;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;padding-top:calc((var(--gov-form-switch-xs-indicator-height, 1.25rem) - var(--gov-text-xs-font-size) * 1.5) / 2)}.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__input{width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 2.5);height:var(--gov-form-switch-xs-indicator-height, 1.25rem)}.gov-form-switch[size=xs] .gov-form-switch__indicator{display:block;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=xs] label{display:inline-flex}.gov-form-switch[size=xs] label .gov-form-switch__input{width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667)}.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;padding-top:calc((var(--gov-form-switch-s-indicator-height, 1.375rem) - var(--gov-text-s-font-size) * 1.5) / 2)}.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__input{width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 2.5);height:var(--gov-form-switch-s-indicator-height, 1.375rem)}.gov-form-switch[size=s] .gov-form-switch__indicator{display:block;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=s] label{display:inline-flex}.gov-form-switch[size=s] label .gov-form-switch__input{width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667)}.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;padding-top:calc((var(--gov-form-switch-m-indicator-height, 1.5rem) - var(--gov-text-m-font-size) * 1.5) / 2)}.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__input{width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 2.5);height:var(--gov-form-switch-m-indicator-height, 1.5rem)}.gov-form-switch[size=m] .gov-form-switch__indicator{display:block;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=m] label{display:inline-flex}.gov-form-switch[size=m] label .gov-form-switch__input{width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667)}.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;padding-top:calc((var(--gov-form-switch-l-indicator-height, 2rem) - var(--gov-text-l-font-size) * 1.5) / 2)}.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__input{width:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 2.5);height:var(--gov-form-switch-l-indicator-height, 2rem)}.gov-form-switch[size=l] .gov-form-switch__indicator{display:block;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)}.gov-form-switch[size=l] label{display:inline-flex}.gov-form-switch[size=l] label .gov-form-switch__input{width:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667)}';const p=o(class o extends i{constructor(){super();this.__registerHost();this.govFocus=t(this,"gov-focus",7);this.govBlur=t(this,"gov-blur",7);this.govChange=t(this,"gov-change",7);this.value=undefined;this.noLabel=false;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.checkboxId=s("GovCheckbox");this.h=v(this.host);this.f=a(this.h)}validateSize(o){c(g,o,h.root)}watchDisabled(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("disabled",m(this.disabled));this.f.passAttrToControl("invalid",m(this.invalid));this.f.passAttrToControl("type","switch")}componentWillLoad(){this.passControlAttrs()}async componentDidRender(){this.f.passAttrToLabel("identifier",this.identifier||this.checkboxId);this.f.passAttrToLabel("required",String(this.required));if(d()){await w(500);await this.validateWcag()}}render(){const o=o=>{if(this.noLabel){return r("label",null,o)}return o};return r(e,{class:this.h.classes(h.root),checked:this.checked,size:this.size,invalid:l(this.invalid)},r("div",{class:h.holder},o(r(b,null,r("input",{class:h.input,id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.checked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),ref:o=>this.inputRef=o,required:this.required,"aria-checked":this.checked,"aria-required":l(this.required),"aria-invalid":l(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":l(this.disabled)}),r("span",{class:h.indicator}),r("slot",{name:"label"})))))}onClickHandler(o){o.stopPropagation()}onFocusHandler(o){o.stopPropagation();this.govFocus.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}onBlurHandler(o){o.stopPropagation();this.govBlur.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}onChangeHandler(o){this.checked=o.target.checked;o.stopPropagation();this.govChange.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}async getRef(){return this.inputRef}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",h.root);f(this.wcagLabelledBy,"wcag-labelled-by",h.root);n(this.identifier||this.checkboxId,this.wcagLabelledBy,h.root)}get host(){return this}static get watchers(){return{size:["validateSize","watchDisabled"],disabled:["watchDisabled"],invalid:["watchDisabled"]}}static get style(){return _}},[4,"gov-form-switch",{value:[1],noLabel:[4,"no-label"],checked:[1540],required:[4],disabled:[4],name:[1],size:[1],identifier:[1],invalid:[4],wcagDescribedBy:[1,"wcag-described-by"],wcagLabelledBy:[1,"wcag-labelled-by"],getRef:[64],validateWcag:[64]}]);function u(){if(typeof customElements==="undefined"){return}const o=["gov-form-switch"];o.forEach((o=>{switch(o){case"gov-form-switch":if(!customElements.get(o)){customElements.define(o,p)}break}}))}u();const x=p;const z=u;export{x as GovFormSwitch,z as defineCustomElement};
|
|
1
|
+
import{p as o,H as i,c as r,h as t,d as e}from"./p-80c0109d.js";import{c as s}from"./p-24636c53.js";import{v as c}from"./p-26acf964.js";import{g as a,r as h,s as g}from"./p-17c1ffc1.js";import{g as v,a as m,t as l}from"./p-3f37ddb6.js";import{b as f,c as n}from"./p-ae894a40.js";import{c as d}from"./p-cac3881f.js";import{d as w}from"./p-03990da5.js";import{F as b}from"./p-1c1d0bbe.js";const _='.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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-form-switch{position:relative;display:flex}.gov-form-switch__holder{display:inline-flex}.gov-form-switch__input{position:relative;z-index:1;-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:absolute;top:0;left:0;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}.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__input{width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667);height:var(--gov-form-switch-xs-indicator-height, 1.25rem)}.gov-form-switch[size=xs] .gov-form-switch__indicator{display:block;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=xs] label{display:inline-flex}.gov-form-switch[size=xs] label .gov-form-switch__input{width:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667)}.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}.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__input{width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667);height:var(--gov-form-switch-s-indicator-height, 1.375rem)}.gov-form-switch[size=s] .gov-form-switch__indicator{display:block;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=s] label{display:inline-flex}.gov-form-switch[size=s] label .gov-form-switch__input{width:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667)}.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}.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__input{width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667);height:var(--gov-form-switch-m-indicator-height, 1.5rem)}.gov-form-switch[size=m] .gov-form-switch__indicator{display:block;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=m] label{display:inline-flex}.gov-form-switch[size=m] label .gov-form-switch__input{width:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667)}.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}.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__input{width:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667);height:var(--gov-form-switch-l-indicator-height, 2rem)}.gov-form-switch[size=l] .gov-form-switch__indicator{display:block;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)}.gov-form-switch[size=l] label{display:inline-flex}.gov-form-switch[size=l] label .gov-form-switch__input{width:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667)}';const p=o(class o extends i{constructor(){super();this.__registerHost();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.noLabel=false;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.checkboxId=s("GovCheckbox");this.h=v(this.host);this.f=a(this.h)}validateSize(o){c(g,o,h.root)}watchDisabled(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("disabled",m(this.disabled));this.f.passAttrToControl("invalid",m(this.invalid));this.f.passAttrToControl("type","switch")}componentWillLoad(){this.passControlAttrs()}async componentDidRender(){this.f.passAttrToLabel("identifier",this.identifier||this.checkboxId);this.f.passAttrToLabel("required",String(this.required));if(d()){await w(500);await this.validateWcag()}}render(){const o=o=>{if(this.noLabel){return t("label",null,o)}return o};return t(e,{class:this.h.classes(h.root),checked:this.checked,size:this.size,invalid:l(this.invalid)},t("div",{class:h.holder},o(t(b,null,t("input",{class:h.input,id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.checked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),ref:o=>this.inputRef=o,required:this.required,"aria-checked":this.checked,"aria-required":l(this.required),"aria-invalid":l(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":l(this.disabled)}),t("span",{class:h.indicator}),t("slot",{name:"label"})))))}onClickHandler(o){o.stopPropagation()}onFocusHandler(o){o.stopPropagation();this.govFocus.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}onBlurHandler(o){o.stopPropagation();this.govBlur.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}onChangeHandler(o){this.checked=o.target.checked;o.stopPropagation();this.govChange.emit({component:h.root,checked:this.checked,value:this.value,originalEvent:o})}async getRef(){return this.inputRef}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",h.root);f(this.wcagLabelledBy,"wcag-labelled-by",h.root);n(this.identifier||this.checkboxId,this.wcagLabelledBy,h.root)}get host(){return this}static get watchers(){return{size:["validateSize","watchDisabled"],disabled:["watchDisabled"],invalid:["watchDisabled"]}}static get style(){return _}},[4,"gov-form-switch",{value:[1],noLabel:[4,"no-label"],checked:[1540],required:[4],disabled:[4],name:[1],size:[1],identifier:[1],invalid:[4],wcagDescribedBy:[1,"wcag-described-by"],wcagLabelledBy:[1,"wcag-labelled-by"],getRef:[64],validateWcag:[64]}]);function u(){if(typeof customElements==="undefined"){return}const o=["gov-form-switch"];o.forEach((o=>{switch(o){case"gov-form-switch":if(!customElements.get(o)){customElements.define(o,p)}break}}))}u();const x=p;const z=u;export{x as GovFormSwitch,z as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-form-switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["govFormSwitchCss","GovFormSwitch","proxyCustomElement","H","constructor","this","checkboxId","createID","h","govHost","host","f","govForm","validateSize","newValue","validateProp","FormSwitchSizes","FormSwitchClass","root","watchDisabled","passControlAttrs","passAttrToControl","size","toBoolAttr","disabled","invalid","componentWillLoad","componentDidRender","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","render","wrapCheckbox","children","noLabel","Host","class","classes","checked","toBoolAttrIfDefined","holder","Fragment","input","id","type","value","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","ref","el","inputRef","wcagDescribedBy","wcagLabelledBy","indicator","e","stopPropagation","govFocus","emit","component","originalEvent","govBlur","target","govChange","getRef","validateWcagRef","validateWcagLabelFor"],"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"],"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: relative;\n\t\tz-index: 1;\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: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\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\tpadding-top: calc(($indicator-height - (var(--gov-text-#{$size}-font-size) * 1.5)) / 2);\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&__input {\n\t\t\t\t\twidth: calc($indicator-height * (5 / 2));\n\t\t\t\t\theight: $indicator-height;\n\t\t\t\t}\n\t\t\t\t&__indicator {\n\t\t\t\t\tdisplay: block;\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\tlabel {\n\t\t\t\tdisplay: inline-flex;\n\t\t\t\t#{$class}__input {\n\t\t\t\t\twidth: $indicator-width;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormSwitchClass, FormSwitchSizes, FormSwitchSizesType } from \"./constants\"\nimport { govHost, toBoolAttr, 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.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormSwitchEvent } from \"./gov-form-switch.types\"\n\n@Component({\n\ttag: \"gov-form-switch\",\n\tstyleUrl: \"gov-form-switch.scss\",\n})\nexport class GovFormSwitch {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\n\n\tprivate readonly checkboxId: string\n\n\tconstructor() {\n\t\tthis.checkboxId = createID(\"GovCheckbox\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormSwitchElement\n\t/**\n\t * Value of switch\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Switch default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the 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<FormSwitchEvent>\n\t/**\n\t * Emitted when the switch loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormSwitchEvent>\n\t/**\n\t * Emitted when the switch change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormSwitchEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSwitchSizes, newValue, FormSwitchClass.root)\n\t}\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\t@Watch(\"size\")\n\twatchDisabled(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"size\", this.size)\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"type\", \"switch\")\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.passControlAttrs()\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={this.h.classes(FormSwitchClass.root)} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormSwitchClass.holder}>\n\t\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tclass={FormSwitchClass.input}\n\t\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\t\taria-checked={this.checked}\n\t\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span class={FormSwitchClass.indicator}></span>\n\t\t\t\t\t\t\t<slot name=\"label\"></slot>\n\t\t\t\t\t\t</Fragment>,\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", 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"],"mappings":"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"}
|
|
1
|
+
{"version":3,"names":["govFormSwitchCss","GovFormSwitch","proxyCustomElement","H","constructor","this","checkboxId","createID","h","govHost","host","f","govForm","validateSize","newValue","validateProp","FormSwitchSizes","FormSwitchClass","root","watchDisabled","passControlAttrs","passAttrToControl","size","toBoolAttr","disabled","invalid","componentWillLoad","componentDidRender","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","render","wrapCheckbox","children","noLabel","Host","class","classes","checked","toBoolAttrIfDefined","holder","Fragment","input","id","type","value","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","ref","el","inputRef","wcagDescribedBy","wcagLabelledBy","indicator","e","stopPropagation","govFocus","emit","component","originalEvent","govBlur","target","govChange","getRef","validateWcagRef","validateWcagLabelFor"],"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"],"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: relative;\n\t\tz-index: 1;\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: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\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}\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&__input {\n\t\t\t\t\twidth: $indicator-width;\n\t\t\t\t\theight: $indicator-height;\n\t\t\t\t}\n\t\t\t\t&__indicator {\n\t\t\t\t\tdisplay: block;\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\tlabel {\n\t\t\t\tdisplay: inline-flex;\n\t\t\t\t#{$class}__input {\n\t\t\t\t\twidth: $indicator-width;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormSwitchClass, FormSwitchSizes, FormSwitchSizesType } from \"./constants\"\nimport { govHost, toBoolAttr, 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.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormSwitchEvent } from \"./gov-form-switch.types\"\n\n@Component({\n\ttag: \"gov-form-switch\",\n\tstyleUrl: \"gov-form-switch.scss\",\n})\nexport class GovFormSwitch {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\n\n\tprivate readonly checkboxId: string\n\n\tconstructor() {\n\t\tthis.checkboxId = createID(\"GovCheckbox\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormSwitchElement\n\t/**\n\t * Value of switch\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Switch default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the 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<FormSwitchEvent>\n\t/**\n\t * Emitted when the switch loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormSwitchEvent>\n\t/**\n\t * Emitted when the switch change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormSwitchEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSwitchSizes, newValue, FormSwitchClass.root)\n\t}\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\t@Watch(\"size\")\n\twatchDisabled(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"size\", this.size)\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"type\", \"switch\")\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.passControlAttrs()\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={this.h.classes(FormSwitchClass.root)} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormSwitchClass.holder}>\n\t\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tclass={FormSwitchClass.input}\n\t\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\t\taria-checked={this.checked}\n\t\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span class={FormSwitchClass.indicator}></span>\n\t\t\t\t\t\t\t<slot name=\"label\"></slot>\n\t\t\t\t\t\t</Fragment>,\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormSwitchClass.root,\n\t\t\tchecked: this.checked,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", 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"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{G as o,d as s}from"./p-
|
|
1
|
+
import{G as o,d as s}from"./p-35f6490a.js";const t=o;const a=s;export{t as GovIcon,a as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-icon.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,H as n,h as
|
|
1
|
+
import{p as o,H as n,h as e,d as t}from"./p-80c0109d.js";import{g as i,p as s}from"./p-3f37ddb6.js";import{d as a}from"./p-3e8a9e92.js";import{d as r}from"./p-35f6490a.js";const c={root:"gov-loading",content:"gov-loading__content",icon:"gov-loading__icon"};const g=".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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-loading{display:block}.gov-loading__content{z-index:101;position:fixed;top:50%;left:50%;display:flex;gap:1rem;flex-direction:column;align-items:center;min-width:9.6875rem;padding:1.5rem;border-radius:0.5rem;background:var(--gov-loading-bg, rgba(var(--gov-color-secondary-400-rgb), 0.8));color:var(--gov-loading-color, var(--gov-color-primary));text-align:center;transform:translate(-50%, -50%)}.gov-loading__icon{width:4rem;height:4rem;line-height:1}.gov-loading__icon svg{width:100%;height:100%}";const d=o(class o extends n{constructor(){super();this.__registerHost();this.h=i(this.host)}render(){return e(t,{class:this.h.classes(c.root)},e("div",{class:c.content},e("gov-icon",{class:s([c.icon,"gov-spin-animation"]),name:"loader"}),e("slot",null)),e("gov-backdrop",{inverse:true}))}get host(){return this}static get style(){return g}},[4,"gov-loading"]);function l(){if(typeof customElements==="undefined"){return}const o=["gov-loading","gov-backdrop","gov-icon"];o.forEach((o=>{switch(o){case"gov-loading":if(!customElements.get(o)){customElements.define(o,d)}break;case"gov-backdrop":if(!customElements.get(o)){a()}break;case"gov-icon":if(!customElements.get(o)){r()}break}}))}l();const m=d;const p=l;export{m as GovLoading,p as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-loading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LoadingClass","root","content","icon","govLoadingCss","GovLoading","proxyCustomElement","H","constructor","this","h","govHost","host","render","Host","class","classes","
|
|
1
|
+
{"version":3,"names":["LoadingClass","root","content","icon","govLoadingCss","GovLoading","proxyCustomElement","H","constructor","this","h","govHost","host","render","Host","class","classes","prepareClasses","name","inverse"],"sources":["../../../packages/core/src/components/gov-loading/loading/constants.ts","../../../packages/core/src/components/gov-loading/loading/gov-loading.scss?tag=gov-loading","../../../packages/core/src/components/gov-loading/loading/gov-loading.tsx"],"sourcesContent":["export const LoadingClass = {\n\troot: 'gov-loading',\n\tcontent: 'gov-loading__content',\n\ticon: 'gov-loading__icon',\n}\n","/*\n * Loading\n */\n\n$class: \".gov-loading\";\n\n#{$class} {\n\tdisplay: block;\n\t&__content {\n\t\t@include z-index(\"modal\", 1);\n\t\tposition: fixed;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\tdisplay: flex;\n\t\tgap: rem-calc(16);\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tmin-width: rem-calc(155);\n\t\tpadding: rem-calc(24);\n\t\tborder-radius: rem-calc(8);\n\t\tbackground: $loading-bg;\n\t\tcolor: $loading-color;\n\t\ttext-align: center;\n\t\ttransform: translate(-50%, -50%);\n\t}\n\t&__icon {\n\t\twidth: rem-calc(64);\n\t\theight: rem-calc(64);\n\t\tline-height: 1;\n\n\t\tsvg {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t}\n}\n","import { Component, Element, h, Host } from \"@stencil/core\"\nimport { LoadingClass } from \"./constants\"\nimport { govHost, prepareClasses } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\n\n@Component({\n\ttag: \"gov-loading\",\n\tstyleUrl: \"gov-loading.scss\",\n})\nexport class GovLoading {\n\tprivate h: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovLoadingElement\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes(LoadingClass.root)}>\n\t\t\t\t<div class={LoadingClass.content}>\n\t\t\t\t\t<gov-icon class={prepareClasses([LoadingClass.icon, \"gov-spin-animation\"])} name=\"loader\"></gov-icon>\n\t\t\t\t\t<slot />\n\t\t\t\t</div>\n\t\t\t\t<gov-backdrop inverse={true} />\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"],"mappings":"4KAAO,MAAMA,EAAe,CAC3BC,KAAM,cACNC,QAAS,uBACTC,KAAM,qBCHP,MAAMC,EAAgB,80B,MCSTC,EAAUC,EAAA,MAAAD,UAAAE,EAGtB,WAAAC,G,8BACCC,KAAKC,EAAIC,EAAQF,KAAKG,K,CAKvB,MAAAC,GACC,OACCH,EAACI,EAAI,CAACC,MAAON,KAAKC,EAAEM,QAAQhB,EAAaC,OACxCS,EAAA,OAAKK,MAAOf,EAAaE,SACxBQ,EAAA,YAAUK,MAAOE,EAAe,CAACjB,EAAaG,KAAM,uBAAwBe,KAAK,WACjFR,EAAA,cAEDA,EAAA,gBAAcS,QAAS,O"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,H as a,c as e,h as t,d as i}from"./p-80c0109d.js";import{g as s,a as r}from"./p-3f37ddb6.js";import{c as l}from"./p-cac3881f.js";import{a as d}from"./p-561fa17b.js";import{b as n}from"./p-ae894a40.js";import{c as m}from"./p-24636c53.js";import{d as
|
|
1
|
+
import{p as o,H as a,c as e,h as t,d as i}from"./p-80c0109d.js";import{g as s,a as r}from"./p-3f37ddb6.js";import{c as l}from"./p-cac3881f.js";import{a as d}from"./p-561fa17b.js";import{b as n}from"./p-ae894a40.js";import{c as m}from"./p-24636c53.js";import{d as g}from"./p-03990da5.js";import{M as c}from"./p-be4aab0e.js";import{d as v}from"./p-3e8a9e92.js";import{d as h}from"./p-70d9d879.js";import{d as p}from"./p-35f6490a.js";const f='.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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-modal{display:none}.gov-modal__dialog{z-index:101;position:fixed;top:50%;left:50%;display:flex;justify-content:center;align-items:center;width:100%;max-width:var(--gov-modal-max-width, 52.5rem);height:100%;padding:0.5rem;border:none;background:transparent;transform:translate(-50%, -50%);pointer-events:none}.gov-modal__inner{position:relative;display:flex;flex-direction:column;width:100%;max-height:100%;border-radius:var(--gov-border-radius, 0.1875rem);background:var(--gov-modal-bg, var(--gov-color-neutral-white));overflow:hidden;pointer-events:auto;box-shadow:0 0 1.5rem rgba(var(--gov-color-secondary-800-rgb), 0.24)}.gov-modal__header{display:flex;gap:1rem;align-items:flex-start;padding:1.5rem 1rem;border-bottom:var(--gov-modal-border-color, 0.0625rem solid var(--gov-color-secondary-500))}.gov-modal__icon{flex:0 0 auto;padding-top:calc((var(--gov-text-3xl-font-size) * 1.5 - 1.5rem) / 2)}.gov-modal__icon>*{width:1.5rem;height:1.5rem}.gov-modal__title{font-weight:var(--gov-text-3xl-font-weight);font-size:var(--gov-text-3xl-font-size);line-height:var(--gov-text-3xl-line-height);letter-spacing:var(--gov-text-3xl-letter-spacing);margin:0}.gov-modal__close{flex:0 0 auto;margin-left:auto}.gov-modal__content{height:100%;padding:1.5rem 1rem;color:var(--gov-modal-text-color, var(--gov-color-secondary-700));overflow:auto}.gov-modal__content>*:last-child{margin-bottom:0}.gov-modal__footer,.gov-modal__actions{padding:1.5rem 1rem;border-top:var(--gov-modal-border-color, 0.0625rem solid var(--gov-color-secondary-500))}.gov-modal__actions{display:flex;gap:0.5rem 1rem;flex-wrap:wrap;justify-content:flex-end}.gov-modal__dialog:focus .gov-modal__inner{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}.gov-modal[open=""],.gov-modal[open=true i],.gov-modal[open="1"]{display:block}@media (min-width: 30em){.gov-modal__dialog{max-width:calc(var(--gov-modal-max-width, 52.5rem) + 3rem);padding:1.5rem}.gov-modal__dialog:focus{outline-offset:-1.5rem}.gov-modal__inner{box-shadow:0 0 2rem rgba(var(--gov-color-secondary-800-rgb), 0.32)}.gov-modal--prompt .gov-modal__dialog{max-width:calc(var(--gov-modal-prompt-max-width, 33.125rem) + 3rem)}}@media (min-width: 48em){.gov-modal__header{gap:1.25rem;padding:2rem 2.5rem 2rem 3rem}.gov-modal__content{padding:2rem 3rem}.gov-modal__footer{padding:1rem 3rem}.gov-modal--prompt .gov-modal__header,.gov-modal--prompt .gov-modal__content,.gov-modal--prompt .gov-modal__footer,.gov-modal--prompt .gov-modal__actions{padding:1.5rem}}';const b=o(class o extends a{constructor(){super();this.__registerHost();this.govClose=e(this,"gov-close",7);this.open=false;this.label=undefined;this.role="dialog";this.labelTag="h2";this.wcagLabelledBy=undefined;this.wcagDescribedBy=undefined;this.wcagCloseLabel=undefined;this.wcagCloseLabelledBy=undefined;this.h=s(this.host);this.labelId=m("GovModalLabel");this.contentId=m("GovModalContent")}validateLabelTag(o){const a=["h1","h2","h3","h4","h5","h6"];if(o){if(!a.includes(o)){d(`[${c.root}]: Tag ${o} is not allowed.`)}}}watchOpen(o){this.open=o}showModal(){this.open=true;document.body.classList.add(c.bodyFix)}hideModal(){this.open=false;document.body.classList.remove(c.bodyFix)}async componentWillRender(){if(this.open){this.showModal()}else{this.hideModal()}}async componentDidRender(){if(l()){await g(500);await this.validateWcag()}}render(){const o=this.labelTag;return t(i,{class:this.h.classes(c.root),open:this.open},t("dialog",{class:c.dialog,hidden:!this.open,tabindex:"-1",open:this.open,"aria-modal":"true","aria-hidden":r(!this.open),"aria-labelledby":this.wcagLabelledBy||this.labelId,"aria-describedby":this.wcagDescribedBy||this.contentId,role:this.role},t("div",{class:c.inner},t("div",{class:c.header},this.h.hasSlot("icon")&&t("div",{class:c.icon},t("slot",{name:"icon"})),this.label&&t(o,{class:c.title,id:this.labelId},this.label),t("gov-button",{class:c.close,variant:"primary",wcagLabel:this.wcagCloseLabel,wcagLabelledBy:this.wcagCloseLabelledBy,type:"base","on-gov-click":this.onCloseHandler.bind(this)},t("gov-icon",{name:"x-lg"}))),t("div",{class:c.content,id:this.contentId},t("slot",null)),this.h.hasSlot("footer")&&t("div",{class:c.footer},t("slot",{name:"footer"})))),this.open?t("gov-backdrop",{"wcag-label":this.wcagCloseLabel,"wcag-labelled-by":this.wcagCloseLabelledBy,"on-gov-click":this.onCloseHandler.bind(this)}):null)}onCloseHandler(o){o.stopPropagation();this.hideModal();this.govClose.emit(o)}async show(){this.showModal()}async hide(){this.hideModal()}async validateWcag(){n(this.wcagLabelledBy,"wcag-labelled-by",c.root);n(this.wcagDescribedBy,"wcag-described-by",c.root)}get host(){return this}static get watchers(){return{labelTag:["validateLabelTag"],open:["watchOpen"]}}static get style(){return f}},[4,"gov-modal",{open:[1028],label:[1],role:[1],labelTag:[1,"label-tag"],wcagLabelledBy:[1,"wcag-labelled-by"],wcagDescribedBy:[1,"wcag-described-by"],wcagCloseLabel:[1,"wcag-close-label"],wcagCloseLabelledBy:[1,"wcag-close-labelled-by"],show:[64],hide:[64],validateWcag:[64]}]);function u(){if(typeof customElements==="undefined"){return}const o=["gov-modal","gov-backdrop","gov-button","gov-icon"];o.forEach((o=>{switch(o){case"gov-modal":if(!customElements.get(o)){customElements.define(o,b)}break;case"gov-backdrop":if(!customElements.get(o)){v()}break;case"gov-button":if(!customElements.get(o)){h()}break;case"gov-icon":if(!customElements.get(o)){p()}break}}))}u();const _=b;const w=u;export{_ as GovModal,w as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["govModalCss","GovModal","proxyCustomElement","H","constructor","this","h","govHost","host","labelId","createID","contentId","validateLabelTag","newValue","validTags","includes","govErrorLog","ModalClass","root","watchOpen","open","showModal","document","body","classList","add","bodyFix","hideModal","remove","componentWillRender","componentDidRender","canValidateWcagOnRender","delay","validateWcag","render","LabelTag","labelTag","Host","class","classes","dialog","hidden","tabindex","toBoolAttr","wcagLabelledBy","wcagDescribedBy","role","inner","header","hasSlot","icon","name","label","title","id","close","variant","wcagLabel","wcagCloseLabel","wcagCloseLabelledBy","type","onCloseHandler","bind","content","footer","e","stopPropagation","govClose","emit","show","hide","validateWcagRef"],"sources":["../../../packages/core/src/components/gov-modal/gov-modal.scss?tag=gov-modal","../../../packages/core/src/components/gov-modal/gov-modal.tsx"],"sourcesContent":["/*\n * Modal\n */\n\n$class: \".gov-modal\";\n\n#{$class} {\n\tdisplay: none;\n\n\t&__dialog {\n\t\t@include z-index(\"modal\", 1);\n\t\tposition: fixed;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\twidth: 100%;\n\t\tmax-width: $modal-max-width;\n\t\theight: 100%;\n\t\tpadding: rem-calc(8);\n\t\tborder: none;\n\t\tbackground: transparent;\n\t\ttransform: translate(-50%, -50%);\n\t\tpointer-events: none;\n\t}\n\n\t&__inner {\n\t\tposition: relative;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\twidth: 100%;\n\t\tmax-height: 100%;\n\t\tborder-radius: $border-radius;\n\t\tbackground: $modal-bg;\n\t\toverflow: hidden;\n\t\tpointer-events: auto;\n\t\tbox-shadow: get($shadow-l, $shadows);\n\t}\n\n\t&__header {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(16);\n\t\talign-items: flex-start;\n\t\tpadding: rem-calc(24 16);\n\t\tborder-bottom: $modal-border;\n\t}\n\n\t&__icon {\n\t\tflex: 0 0 auto;\n\t\tpadding-top: calc(((var(--gov-text-#{$font-size-3xl}-font-size) * 1.5) - rem-calc(24)) / 2);\n\n\t\t& > * {\n\t\t\twidth: rem-calc(24);\n\t\t\theight: rem-calc(24);\n\t\t}\n\t}\n\n\t&__title {\n\t\t@include typography($font-size-3xl);\n\t\tmargin: 0;\n\t}\n\n\t&__close {\n\t\tflex: 0 0 auto;\n\t\tmargin-left: auto;\n\t\tpadding-top: calc(((var(--gov-text-#{$font-size-3xl}-font-size) * 1.5) - rem-calc(32)) / 2);\n\t}\n\n\t&__content {\n\t\t@include reset-last-margin();\n\t\theight: 100%;\n\t\tpadding: rem-calc(24 16);\n\t\tcolor: $modal-text-color;\n\t\toverflow: auto;\n\t}\n\n\t&__footer,\n\t&__actions {\n\t\tpadding: rem-calc(24 16);\n\t\tborder-top: $modal-border;\n\t}\n\n\t&__actions {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8 16);\n\t\tflex-wrap: wrap;\n\t\tjustify-content: flex-end;\n\t}\n\n\t// STATES\n\t&__dialog:focus &__inner {\n\t\toutline: $outline;\n\t}\n\n\t@include parameter(\"open\") {\n\t\tdisplay: block;\n\t}\n\n\t// MQ\n\t@include mq($from: sm) {\n\t\t&__dialog {\n\t\t\tmax-width: calc($modal-max-width + 2 * rem-calc(24));\n\t\t\tpadding: rem-calc(24);\n\n\t\t\t&:focus {\n\t\t\t\toutline-offset: rem-calc(-24);\n\t\t\t}\n\t\t}\n\t\t&__inner {\n\t\t\tbox-shadow: get($shadow-xl, $shadows);\n\t\t}\n\n\t\t// VARIANTS\n\t\t&--prompt &__dialog {\n\t\t\tmax-width: calc($modal-prompt-max-width + 2 * rem-calc(24));\n\t\t}\n\t}\n\t@include mq($from: md) {\n\t\t&__header {\n\t\t\tgap: rem-calc(20);\n\t\t\tpadding: rem-calc(32 40 32 48);\n\t\t}\n\t\t&__close {\n\t\t\tpadding-top: calc(((var(--gov-text-#{$font-size-3xl}-font-size) * 1.5) - rem-calc(40)) / 2);\n\t\t}\n\t\t&__content {\n\t\t\tpadding: rem-calc(32 48);\n\t\t}\n\t\t&__footer {\n\t\t\tpadding: rem-calc(16 48);\n\t\t}\n\n\t\t// VARIANTS\n\t\t&--prompt {\n\t\t\t#{$class} {\n\t\t\t\t&__header,\n\t\t\t\t&__content,\n\t\t\t\t&__footer,\n\t\t\t\t&__actions {\n\t\t\t\t\tpadding: rem-calc(24);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, Prop, Watch, h } from \"@stencil/core\"\nimport { govHost, toBoolAttr } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { canValidateWcagOnRender } from \"../../helpers/Dom/win\"\nimport { govErrorLog } from \"../../helpers/Log/gov.log\"\nimport { validateWcagRef } from \"../../helpers/Validate/wcag\"\nimport { createID } from \"../../utils/string.utils\"\nimport { delay } from \"../../utils/utils\"\nimport { ModalClass } from \"./constants\"\nimport { Nullable } from \"../../types/interfaces\"\n\n@Component({\n\ttag: \"gov-modal\",\n\tstyleUrl: \"gov-modal.scss\",\n})\nexport class GovModal {\n\tprivate h: GovHost\n\tprivate readonly labelId: string\n\tprivate readonly contentId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.labelId = createID(\"GovModalLabel\")\n\t\tthis.contentId = createID(\"GovModalContent\")\n\t}\n\n\t@Element() host: HTMLGovModalElement\n\n\t/**\n\t * Attribute for modal window display\n\t */\n\t@Prop({mutable: true}) open = false\n\t/**\n\t * Title of modal window\n\t */\n\t@Prop() label: string\n\t/**\n\t * Role of modal\n\t */\n\t@Prop({ attribute: \"role\" }) role: Nullable<string> = \"dialog\"\n\t/**\n\t * Used to change the HTML tag in the modal label for correct semantic structure\n\t */\n\t@Prop({ attribute: \"label-tag\" }) readonly labelTag: string = \"h2\"\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the modal.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) wcagDescribedBy: string\n\t/**\n\t * Adds accessible label for the modal close button that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: \"wcag-close-label\" }) wcagCloseLabel: string\n\t/**\n\t * A string of identifiers that indicate alternative label elements for closing the modal window\n\t */\n\t@Prop({ attribute: \"wcag-close-labelled-by\" }) wcagCloseLabelledBy: string\n\t/**\n\t * Emitted when modal window closes.\n\t */\n\t@Event({ eventName: \"gov-close\" }) govClose: EventEmitter<PointerEvent>\n\n\t@Watch(\"labelTag\")\n\tvalidateLabelTag(newValue: string): void {\n\t\tconst validTags = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]\n\t\tif (newValue) {\n\t\t\tif (!validTags.includes(newValue)) {\n\t\t\t\tgovErrorLog(`[${ModalClass.root}]: Tag ${newValue} is not allowed.`)\n\t\t\t}\n\t\t}\n\t}\n\n\t@Watch(\"open\")\n\twatchOpen(newValue: boolean): void {\n\t\tthis.open = newValue\n\t}\n\n\tprivate showModal() {\n\t\tthis.open = true\n\t\tdocument.body.classList.add(ModalClass.bodyFix)\n\t}\n\n\tprivate hideModal() {\n\t\tthis.open = false\n\t\tdocument.body.classList.remove(ModalClass.bodyFix)\n\t}\n\n\tasync componentWillRender() {\n\t\tif (this.open) {\n\t\t\tthis.showModal()\n\t\t} else {\n\t\t\tthis.hideModal()\n\t\t}\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 LabelTag = this.labelTag\n\t\treturn (\n\t\t\t<Host class={this.h.classes(ModalClass.root)} open={this.open}>\n\t\t\t\t<dialog\n\t\t\t\t\tclass={ModalClass.dialog}\n\t\t\t\t\thidden={!this.open}\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\topen={this.open}\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\taria-hidden={toBoolAttr(!this.open)}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy || this.labelId}\n\t\t\t\t\taria-describedby={this.wcagDescribedBy || this.contentId}\n\t\t\t\t\trole={this.role}\n\t\t\t\t>\n\t\t\t\t\t<div class={ModalClass.inner}>\n\t\t\t\t\t\t<div class={ModalClass.header}>\n\t\t\t\t\t\t\t{this.h.hasSlot(\"icon\") && (\n\t\t\t\t\t\t\t\t<div class={ModalClass.icon}>\n\t\t\t\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{this.label && (\n\t\t\t\t\t\t\t\t<LabelTag class={ModalClass.title} id={this.labelId}>\n\t\t\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t\t\t</LabelTag>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\tclass={ModalClass.close}\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\twcagLabel={this.wcagCloseLabel}\n\t\t\t\t\t\t\t\twcagLabelledBy={this.wcagCloseLabelledBy}\n\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\" />\n\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.content} id={this.contentId}>\n\t\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{this.h.hasSlot(\"footer\") && (\n\t\t\t\t\t\t\t<div class={ModalClass.footer}>\n\t\t\t\t\t\t\t\t<slot name=\"footer\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</dialog>\n\n\t\t\t\t{this.open ? (\n\t\t\t\t\t<gov-backdrop\n\t\t\t\t\t\twcag-label={this.wcagCloseLabel}\n\t\t\t\t\t\twcag-labelled-by={this.wcagCloseLabelledBy}\n\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onCloseHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t\tthis.hideModal()\n\t\tthis.govClose.emit(e)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showModal()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.hideModal()\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.wcagLabelledBy, \"wcag-labelled-by\", ModalClass.root)\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", ModalClass.root)\n\t}\n}\n"],"mappings":"+aAAA,MAAMA,EAAc,k8F,MCePC,EAAQC,EAAA,MAAAD,UAAAE,EAKpB,WAAAC,G,4EAW8B,M,+BAQwB,S,cAIQ,K,8HAtB7DC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,QAAUC,EAAS,iBACxBL,KAAKM,UAAYD,EAAS,kB,CA2C3B,gBAAAE,CAAiBC,GAChB,MAAMC,EAAY,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM,MACjD,GAAID,EAAU,CACb,IAAKC,EAAUC,SAASF,GAAW,CAClCG,EAAY,IAAIC,EAAWC,cAAcL,oB,GAM5C,SAAAM,CAAUN,GACTR,KAAKe,KAAOP,C,CAGL,SAAAQ,GACPhB,KAAKe,KAAO,KACZE,SAASC,KAAKC,UAAUC,IAAIR,EAAWS,Q,CAGhC,SAAAC,GACPtB,KAAKe,KAAO,MACZE,SAASC,KAAKC,UAAUI,OAAOX,EAAWS,Q,CAG3C,yBAAMG,GACL,GAAIxB,KAAKe,KAAM,CACdf,KAAKgB,W,KACC,CACNhB,KAAKsB,W,EAIP,wBAAMG,GACL,GAAIC,IAA2B,OACxBC,EAAM,WACN3B,KAAK4B,c,EAIb,MAAAC,GACC,MAAMC,EAAW9B,KAAK+B,SACtB,OACC9B,EAAC+B,EAAI,CAACC,MAAOjC,KAAKC,EAAEiC,QAAQtB,EAAWC,MAAOE,KAAMf,KAAKe,MACxDd,EAAA,UACCgC,MAAOrB,EAAWuB,OAClBC,QAASpC,KAAKe,KACdsB,SAAS,KACTtB,KAAMf,KAAKe,KAAI,aACJ,OAAM,cACJuB,GAAYtC,KAAKe,MAAK,kBAClBf,KAAKuC,gBAAkBvC,KAAKI,QAAO,mBAClCJ,KAAKwC,iBAAmBxC,KAAKM,UAC/CmC,KAAMzC,KAAKyC,MAEXxC,EAAA,OAAKgC,MAAOrB,EAAW8B,OACtBzC,EAAA,OAAKgC,MAAOrB,EAAW+B,QACrB3C,KAAKC,EAAE2C,QAAQ,SACf3C,EAAA,OAAKgC,MAAOrB,EAAWiC,MACtB5C,EAAA,QAAM6C,KAAK,UAGZ9C,KAAK+C,OACL9C,EAAC6B,EAAQ,CAACG,MAAOrB,EAAWoC,MAAOC,GAAIjD,KAAKI,SAC1CJ,KAAK+C,OAGR9C,EAAA,cACCgC,MAAOrB,EAAWsC,MAClBC,QAAQ,UACRC,UAAWpD,KAAKqD,eAChBd,eAAgBvC,KAAKsD,oBACrBC,KAAK,OAAM,eACGvD,KAAKwD,eAAeC,KAAKzD,OAEvCC,EAAA,YAAU6C,KAAK,WAGjB7C,EAAA,OAAKgC,MAAOrB,EAAW8C,QAAST,GAAIjD,KAAKM,WACxCL,EAAA,cAEAD,KAAKC,EAAE2C,QAAQ,WACf3C,EAAA,OAAKgC,MAAOrB,EAAW+C,QACtB1D,EAAA,QAAM6C,KAAK,cAMd9C,KAAKe,KACLd,EAAA,6BACaD,KAAKqD,eAAc,mBACbrD,KAAKsD,oBAAmB,eAC5BtD,KAAKwD,eAAeC,KAAKzD,QAErC,K,CAKC,cAAAwD,CAAeI,GACtBA,EAAEC,kBACF7D,KAAKsB,YACLtB,KAAK8D,SAASC,KAAKH,E,CAOpB,UAAMI,GACLhE,KAAKgB,W,CAON,UAAMiD,GACLjE,KAAKsB,W,CAON,kBAAMM,GACLsC,EAAgBlE,KAAKuC,eAAgB,mBAAoB3B,EAAWC,MACpEqD,EAAgBlE,KAAKwC,gBAAiB,oBAAqB5B,EAAWC,K"}
|
|
1
|
+
{"version":3,"names":["govModalCss","GovModal","proxyCustomElement","H","constructor","this","h","govHost","host","labelId","createID","contentId","validateLabelTag","newValue","validTags","includes","govErrorLog","ModalClass","root","watchOpen","open","showModal","document","body","classList","add","bodyFix","hideModal","remove","componentWillRender","componentDidRender","canValidateWcagOnRender","delay","validateWcag","render","LabelTag","labelTag","Host","class","classes","dialog","hidden","tabindex","toBoolAttr","wcagLabelledBy","wcagDescribedBy","role","inner","header","hasSlot","icon","name","label","title","id","close","variant","wcagLabel","wcagCloseLabel","wcagCloseLabelledBy","type","onCloseHandler","bind","content","footer","e","stopPropagation","govClose","emit","show","hide","validateWcagRef"],"sources":["../../../packages/core/src/components/gov-modal/gov-modal.scss?tag=gov-modal","../../../packages/core/src/components/gov-modal/gov-modal.tsx"],"sourcesContent":["/*\n * Modal\n */\n\n$class: \".gov-modal\";\n\n#{$class} {\n\tdisplay: none;\n\n\t&__dialog {\n\t\t@include z-index(\"modal\", 1);\n\t\tposition: fixed;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\twidth: 100%;\n\t\tmax-width: $modal-max-width;\n\t\theight: 100%;\n\t\tpadding: rem-calc(8);\n\t\tborder: none;\n\t\tbackground: transparent;\n\t\ttransform: translate(-50%, -50%);\n\t\tpointer-events: none;\n\t}\n\n\t&__inner {\n\t\tposition: relative;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\twidth: 100%;\n\t\tmax-height: 100%;\n\t\tborder-radius: $border-radius;\n\t\tbackground: $modal-bg;\n\t\toverflow: hidden;\n\t\tpointer-events: auto;\n\t\tbox-shadow: get($shadow-l, $shadows);\n\t}\n\n\t&__header {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(16);\n\t\talign-items: flex-start;\n\t\tpadding: rem-calc(24 16);\n\t\tborder-bottom: $modal-border;\n\t}\n\n\t&__icon {\n\t\tflex: 0 0 auto;\n\t\tpadding-top: calc(((var(--gov-text-#{$font-size-3xl}-font-size) * 1.5) - rem-calc(24)) / 2);\n\n\t\t& > * {\n\t\t\twidth: rem-calc(24);\n\t\t\theight: rem-calc(24);\n\t\t}\n\t}\n\n\t&__title {\n\t\t@include typography($font-size-3xl);\n\t\tmargin: 0;\n\t}\n\n\t&__close {\n\t\tflex: 0 0 auto;\n\t\tmargin-left: auto;\n\t}\n\n\t&__content {\n\t\t@include reset-last-margin();\n\t\theight: 100%;\n\t\tpadding: rem-calc(24 16);\n\t\tcolor: $modal-text-color;\n\t\toverflow: auto;\n\t}\n\n\t&__footer,\n\t&__actions {\n\t\tpadding: rem-calc(24 16);\n\t\tborder-top: $modal-border;\n\t}\n\n\t&__actions {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8 16);\n\t\tflex-wrap: wrap;\n\t\tjustify-content: flex-end;\n\t}\n\n\t// STATES\n\t&__dialog:focus &__inner {\n\t\toutline: $outline;\n\t}\n\n\t@include parameter(\"open\") {\n\t\tdisplay: block;\n\t}\n\n\t// MQ\n\t@include mq($from: sm) {\n\t\t&__dialog {\n\t\t\tmax-width: calc($modal-max-width + 2 * rem-calc(24));\n\t\t\tpadding: rem-calc(24);\n\n\t\t\t&:focus {\n\t\t\t\toutline-offset: rem-calc(-24);\n\t\t\t}\n\t\t}\n\t\t&__inner {\n\t\t\tbox-shadow: get($shadow-xl, $shadows);\n\t\t}\n\n\t\t// VARIANTS\n\t\t&--prompt &__dialog {\n\t\t\tmax-width: calc($modal-prompt-max-width + 2 * rem-calc(24));\n\t\t}\n\t}\n\t@include mq($from: md) {\n\t\t&__header {\n\t\t\tgap: rem-calc(20);\n\t\t\tpadding: rem-calc(32 40 32 48);\n\t\t}\n\t\t&__content {\n\t\t\tpadding: rem-calc(32 48);\n\t\t}\n\t\t&__footer {\n\t\t\tpadding: rem-calc(16 48);\n\t\t}\n\n\t\t// VARIANTS\n\t\t&--prompt {\n\t\t\t#{$class} {\n\t\t\t\t&__header,\n\t\t\t\t&__content,\n\t\t\t\t&__footer,\n\t\t\t\t&__actions {\n\t\t\t\t\tpadding: rem-calc(24);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, Prop, Watch, h } from \"@stencil/core\"\nimport { govHost, toBoolAttr } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { canValidateWcagOnRender } from \"../../helpers/Dom/win\"\nimport { govErrorLog } from \"../../helpers/Log/gov.log\"\nimport { validateWcagRef } from \"../../helpers/Validate/wcag\"\nimport { createID } from \"../../utils/string.utils\"\nimport { delay } from \"../../utils/utils\"\nimport { ModalClass } from \"./constants\"\nimport { Nullable } from \"../../types/interfaces\"\n\n@Component({\n\ttag: \"gov-modal\",\n\tstyleUrl: \"gov-modal.scss\",\n})\nexport class GovModal {\n\tprivate h: GovHost\n\tprivate readonly labelId: string\n\tprivate readonly contentId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.labelId = createID(\"GovModalLabel\")\n\t\tthis.contentId = createID(\"GovModalContent\")\n\t}\n\n\t@Element() host: HTMLGovModalElement\n\n\t/**\n\t * Attribute for modal window display\n\t */\n\t@Prop({mutable: true}) open = false\n\t/**\n\t * Title of modal window\n\t */\n\t@Prop() label: string\n\t/**\n\t * Role of modal\n\t */\n\t@Prop({ attribute: \"role\" }) role: Nullable<string> = \"dialog\"\n\t/**\n\t * Used to change the HTML tag in the modal label for correct semantic structure\n\t */\n\t@Prop({ attribute: \"label-tag\" }) readonly labelTag: string = \"h2\"\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the modal.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) wcagDescribedBy: string\n\t/**\n\t * Adds accessible label for the modal close button that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: \"wcag-close-label\" }) wcagCloseLabel: string\n\t/**\n\t * A string of identifiers that indicate alternative label elements for closing the modal window\n\t */\n\t@Prop({ attribute: \"wcag-close-labelled-by\" }) wcagCloseLabelledBy: string\n\t/**\n\t * Emitted when modal window closes.\n\t */\n\t@Event({ eventName: \"gov-close\" }) govClose: EventEmitter<PointerEvent>\n\n\t@Watch(\"labelTag\")\n\tvalidateLabelTag(newValue: string): void {\n\t\tconst validTags = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]\n\t\tif (newValue) {\n\t\t\tif (!validTags.includes(newValue)) {\n\t\t\t\tgovErrorLog(`[${ModalClass.root}]: Tag ${newValue} is not allowed.`)\n\t\t\t}\n\t\t}\n\t}\n\n\t@Watch(\"open\")\n\twatchOpen(newValue: boolean): void {\n\t\tthis.open = newValue\n\t}\n\n\tprivate showModal() {\n\t\tthis.open = true\n\t\tdocument.body.classList.add(ModalClass.bodyFix)\n\t}\n\n\tprivate hideModal() {\n\t\tthis.open = false\n\t\tdocument.body.classList.remove(ModalClass.bodyFix)\n\t}\n\n\tasync componentWillRender() {\n\t\tif (this.open) {\n\t\t\tthis.showModal()\n\t\t} else {\n\t\t\tthis.hideModal()\n\t\t}\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 LabelTag = this.labelTag\n\t\treturn (\n\t\t\t<Host class={this.h.classes(ModalClass.root)} open={this.open}>\n\t\t\t\t<dialog\n\t\t\t\t\tclass={ModalClass.dialog}\n\t\t\t\t\thidden={!this.open}\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\topen={this.open}\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\taria-hidden={toBoolAttr(!this.open)}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy || this.labelId}\n\t\t\t\t\taria-describedby={this.wcagDescribedBy || this.contentId}\n\t\t\t\t\trole={this.role}\n\t\t\t\t>\n\t\t\t\t\t<div class={ModalClass.inner}>\n\t\t\t\t\t\t<div class={ModalClass.header}>\n\t\t\t\t\t\t\t{this.h.hasSlot(\"icon\") && (\n\t\t\t\t\t\t\t\t<div class={ModalClass.icon}>\n\t\t\t\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{this.label && (\n\t\t\t\t\t\t\t\t<LabelTag class={ModalClass.title} id={this.labelId}>\n\t\t\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t\t\t</LabelTag>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\tclass={ModalClass.close}\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\twcagLabel={this.wcagCloseLabel}\n\t\t\t\t\t\t\t\twcagLabelledBy={this.wcagCloseLabelledBy}\n\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\" />\n\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.content} id={this.contentId}>\n\t\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{this.h.hasSlot(\"footer\") && (\n\t\t\t\t\t\t\t<div class={ModalClass.footer}>\n\t\t\t\t\t\t\t\t<slot name=\"footer\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</dialog>\n\n\t\t\t\t{this.open ? (\n\t\t\t\t\t<gov-backdrop\n\t\t\t\t\t\twcag-label={this.wcagCloseLabel}\n\t\t\t\t\t\twcag-labelled-by={this.wcagCloseLabelledBy}\n\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onCloseHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t\tthis.hideModal()\n\t\tthis.govClose.emit(e)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showModal()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.hideModal()\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.wcagLabelledBy, \"wcag-labelled-by\", ModalClass.root)\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", ModalClass.root)\n\t}\n}\n"],"mappings":"+aAAA,MAAMA,EAAc,wyF,MCePC,EAAQC,EAAA,MAAAD,UAAAE,EAKpB,WAAAC,G,4EAW8B,M,+BAQwB,S,cAIQ,K,8HAtB7DC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,QAAUC,EAAS,iBACxBL,KAAKM,UAAYD,EAAS,kB,CA2C3B,gBAAAE,CAAiBC,GAChB,MAAMC,EAAY,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM,MACjD,GAAID,EAAU,CACb,IAAKC,EAAUC,SAASF,GAAW,CAClCG,EAAY,IAAIC,EAAWC,cAAcL,oB,GAM5C,SAAAM,CAAUN,GACTR,KAAKe,KAAOP,C,CAGL,SAAAQ,GACPhB,KAAKe,KAAO,KACZE,SAASC,KAAKC,UAAUC,IAAIR,EAAWS,Q,CAGhC,SAAAC,GACPtB,KAAKe,KAAO,MACZE,SAASC,KAAKC,UAAUI,OAAOX,EAAWS,Q,CAG3C,yBAAMG,GACL,GAAIxB,KAAKe,KAAM,CACdf,KAAKgB,W,KACC,CACNhB,KAAKsB,W,EAIP,wBAAMG,GACL,GAAIC,IAA2B,OACxBC,EAAM,WACN3B,KAAK4B,c,EAIb,MAAAC,GACC,MAAMC,EAAW9B,KAAK+B,SACtB,OACC9B,EAAC+B,EAAI,CAACC,MAAOjC,KAAKC,EAAEiC,QAAQtB,EAAWC,MAAOE,KAAMf,KAAKe,MACxDd,EAAA,UACCgC,MAAOrB,EAAWuB,OAClBC,QAASpC,KAAKe,KACdsB,SAAS,KACTtB,KAAMf,KAAKe,KAAI,aACJ,OAAM,cACJuB,GAAYtC,KAAKe,MAAK,kBAClBf,KAAKuC,gBAAkBvC,KAAKI,QAAO,mBAClCJ,KAAKwC,iBAAmBxC,KAAKM,UAC/CmC,KAAMzC,KAAKyC,MAEXxC,EAAA,OAAKgC,MAAOrB,EAAW8B,OACtBzC,EAAA,OAAKgC,MAAOrB,EAAW+B,QACrB3C,KAAKC,EAAE2C,QAAQ,SACf3C,EAAA,OAAKgC,MAAOrB,EAAWiC,MACtB5C,EAAA,QAAM6C,KAAK,UAGZ9C,KAAK+C,OACL9C,EAAC6B,EAAQ,CAACG,MAAOrB,EAAWoC,MAAOC,GAAIjD,KAAKI,SAC1CJ,KAAK+C,OAGR9C,EAAA,cACCgC,MAAOrB,EAAWsC,MAClBC,QAAQ,UACRC,UAAWpD,KAAKqD,eAChBd,eAAgBvC,KAAKsD,oBACrBC,KAAK,OAAM,eACGvD,KAAKwD,eAAeC,KAAKzD,OAEvCC,EAAA,YAAU6C,KAAK,WAGjB7C,EAAA,OAAKgC,MAAOrB,EAAW8C,QAAST,GAAIjD,KAAKM,WACxCL,EAAA,cAEAD,KAAKC,EAAE2C,QAAQ,WACf3C,EAAA,OAAKgC,MAAOrB,EAAW+C,QACtB1D,EAAA,QAAM6C,KAAK,cAMd9C,KAAKe,KACLd,EAAA,6BACaD,KAAKqD,eAAc,mBACbrD,KAAKsD,oBAAmB,eAC5BtD,KAAKwD,eAAeC,KAAKzD,QAErC,K,CAKC,cAAAwD,CAAeI,GACtBA,EAAEC,kBACF7D,KAAKsB,YACLtB,KAAK8D,SAASC,KAAKH,E,CAOpB,UAAMI,GACLhE,KAAKgB,W,CAON,UAAMiD,GACLjE,KAAKsB,W,CAON,kBAAMM,GACLsC,EAAgBlE,KAAKuC,eAAgB,mBAAoB3B,EAAWC,MACpEqD,EAAgBlE,KAAKwC,gBAAiB,oBAAqB5B,EAAWC,K"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,H as r,c as e,h as t,d as a}from"./p-80c0109d.js";import{F as n}from"./p-1c1d0bbe.js";import{v as i}from"./p-26acf964.js";import{S as s}from"./p-55500e5a.js";import{V as g}from"./p-ff7365ae.js";import{p as c,d as l}from"./p-03990da5.js";import{g as v,p as u,t as p}from"./p-3f37ddb6.js";import{a as h,v as d}from"./p-ae894a40.js";import{c as m}from"./p-cac3881f.js";import{c as b}from"./p-24636c53.js";import{d as _}from"./p-6ca0c464.js";import{d as y}from"./p-2753b6e4.js";import{d as f}from"./p-04bfe959.js";const w=c(s,["_S","_M"]);const k=c(g,["PRIMARY","SECONDARY"]);var x;(function(o){o["BUTTON"]="button";o["SELECT"]="select"})(x||(x={}));const z={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 S(o,r=1,e=10,t=10){const a=Math.ceil(o/e);if(r<1){r=1}else if(r>a){r=a}let n,i;if(a<=t){n=1;i=a}else{const o=Math.floor(t/2);const e=Math.ceil(t/2)-1;if(r<=o){n=1;i=t}else if(r+e>=a){n=a-t+1;i=a}else{n=r-o;i=r+e}}const s=(r-1)*e;const g=Math.min(s+e-1,o-1);const c=Array.from(Array(i+1-n).keys()).map((o=>n+o));return{totalItems:o,currentPage:r,pageSize:e,totalPages:a,startPage:n,endPage:i,startIndex:s,endIndex:g,pages:c}}const j=(o,r)=>{if(Number.isInteger(o)&&Number.isInteger(r)){return[...Array(r+1).keys()].slice(o)}return[]};const P=".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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.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;padding:0.125rem;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 A=o(class o extends r{constructor(){super();this.__registerHost();this.govPage=e(this,"gov-page",7);this.type="button";this.current=1;this.total=0;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){i(x,o,z.root)}validateSize(o){i(w,o,z.root)}validateVariant(o){i(k,o,z.root)}recalculate(){this.recalculatePagination(this.current)}componentWillLoad(){this.recalculatePagination(this.current);this.validateSize(this.size);this.validateVariant(this.variant)}async componentDidRender(){if(m()){await l(500);await this.validateWcag()}}recalculatePagination(o){this.pagination=S(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.getRef().then((o=>{o.value="..."}))}}render(){const o=(o,r)=>{const e=o===-1;const a=p(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":a,class:z.inner},r)};return t(a,{class:this.h.classes(z.root),type:this.type,variant:this.variant,size:this.size},t("nav",{"aria-label":this.wcagLabel,"aria-labelledby":this.wcagLabelledBy},t("ul",{class:z.list},t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.currentPage>1?1:-1,t("gov-icon",{class:z.arrow,name:"chevron-double-left"}))),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.startPage<this.pagination.currentPage?this.pagination.currentPage-1:-1,t("gov-icon",{class:z.arrow,name:"chevron-left"}))),this.type=="select"?t("li",{class:u([z.item,z.itemSelect])},t("span",{class:z.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m",variant:this.variant,"wcag-labelled-by":this.pageSelectId,"on-gov-change":this.onSelectHandler.bind(this)},j(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:this.pagination.currentPage===o},o)))))):t(n,null,this.pagination.pages.map((r=>t("li",{class:this.isActivePageClass(z.item,r)},o(r,r)))),this.pagination.totalPages?t("li",{class:u([z.item,z.itemMore])},t("span",{class:z.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m",variant:this.variant,"wcag-labelled-by":this.pageSelectId,ref:o=>this.spreadSelectRef=o,"on-gov-change":this.onSelectHandler.bind(this)},t("option",{selected:true,hidden:true},"..."),j(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:false},o)))))):null),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.currentPage+1:-1,t("gov-icon",{class:z.arrow,name:"chevron-right"}))),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.totalPages:-1,t("gov-icon",{class:z.arrow,name:"chevron-double-right"}))))))}onClickHandler(o,r){o.stopPropagation();this.recalculatePagination(r);this.govPage.emit({component:z.root,pagination:this.pagination})}onSelectHandler(o){o.stopPropagation();const r=o.detail.value;const e=parseInt(r);this.resetSelectValue();if(isNaN(e)===false){this.recalculatePagination(e);if(this.link){window.location.href=this.prepareLinkUrl(e)}else{this.govPage.emit({component:z.root,pagination:this.pagination})}}}async validateWcag(){h(this.wcagPageLabel,"wcag-page-label",z.root);d(this.wcagLabel,this.wcagLabelledBy,z.root)}get host(){return this}static get watchers(){return{type:["validateType"],size:["validateSize"],variant:["validateVariant"],current:["recalculate"],total:["recalculate"],pageSize:["recalculate"],maxPages:["recalculate"]}}static get style(){return P}},[0,"gov-pagination",{type:[1],current:[2],total:[2],inverse:[4],size:[1],variant:[1],pageSize:[2,"page-size"],maxPages:[2,"max-pages"],link:[1],wcagLabel:[1,"wcag-label"],wcagLabelledBy:[1,"wcag-labelled-by"],wcagSelectLabel:[1,"wcag-select-label"],wcagPageLabel:[1,"wcag-page-label"],pagination:[32],validateWcag:[64]}]);function E(){if(typeof customElements==="undefined"){return}const o=["gov-pagination","gov-button","gov-form-select","gov-icon"];o.forEach((o=>{switch(o){case"gov-pagination":if(!customElements.get(o)){customElements.define(o,A)}break;case"gov-button":if(!customElements.get(o)){_()}break;case"gov-form-select":if(!customElements.get(o)){y()}break;case"gov-icon":if(!customElements.get(o)){f()}break}}))}E();const M=A;const L=E;export{M as GovPagination,L as defineCustomElement};
|
|
1
|
+
import{p as o,H as r,c as e,h as t,d as a}from"./p-80c0109d.js";import{F as n}from"./p-1c1d0bbe.js";import{v as i}from"./p-26acf964.js";import{S as s}from"./p-55500e5a.js";import{V as g}from"./p-ff7365ae.js";import{p as c,d as l}from"./p-03990da5.js";import{g as v,p as u,t as p}from"./p-3f37ddb6.js";import{a as h,v as d}from"./p-ae894a40.js";import{c as m}from"./p-cac3881f.js";import{c as b}from"./p-24636c53.js";import{d as _}from"./p-70d9d879.js";import{d as f}from"./p-da3b225f.js";import{d as y}from"./p-35f6490a.js";const w=c(s,["_S","_M"]);const k=c(g,["PRIMARY","SECONDARY"]);var x;(function(o){o["BUTTON"]="button";o["SELECT"]="select"})(x||(x={}));const z={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 S(o,r=1,e=10,t=10){const a=Math.ceil(o/e);if(r<1){r=1}else if(r>a){r=a}let n,i;if(a<=t){n=1;i=a}else{const o=Math.floor(t/2);const e=Math.ceil(t/2)-1;if(r<=o){n=1;i=t}else if(r+e>=a){n=a-t+1;i=a}else{n=r-o;i=r+e}}const s=(r-1)*e;const g=Math.min(s+e-1,o-1);const c=Array.from(Array(i+1-n).keys()).map((o=>n+o));return{totalItems:o,currentPage:r,pageSize:e,totalPages:a,startPage:n,endPage:i,startIndex:s,endIndex:g,pages:c}}const j=(o,r)=>{if(Number.isInteger(o)&&Number.isInteger(r)){return[...Array(r+1).keys()].slice(o)}return[]};const P=".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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.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;padding:0.125rem;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 A=o(class o extends r{constructor(){super();this.__registerHost();this.govPage=e(this,"gov-page",7);this.type="button";this.current=1;this.total=0;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){i(x,o,z.root)}validateSize(o){i(w,o,z.root)}validateVariant(o){i(k,o,z.root)}recalculate(){this.recalculatePagination(this.current)}componentWillLoad(){this.recalculatePagination(this.current);this.validateSize(this.size);this.validateVariant(this.variant)}async componentDidRender(){if(m()){await l(500);await this.validateWcag()}}recalculatePagination(o){this.pagination=S(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.getRef().then((o=>{o.value="..."}))}}render(){const o=(o,r)=>{const e=o===-1;const a=p(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":a,class:z.inner},r)};return t(a,{class:this.h.classes(z.root),type:this.type,variant:this.variant,size:this.size},t("nav",{"aria-label":this.wcagLabel,"aria-labelledby":this.wcagLabelledBy},t("ul",{class:z.list},t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.currentPage>1?1:-1,t("gov-icon",{class:z.arrow,name:"chevron-double-left"}))),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.startPage<this.pagination.currentPage?this.pagination.currentPage-1:-1,t("gov-icon",{class:z.arrow,name:"chevron-left"}))),this.type=="select"?t("li",{class:u([z.item,z.itemSelect])},t("span",{class:z.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m",variant:this.variant,"wcag-labelled-by":this.pageSelectId,"on-gov-change":this.onSelectHandler.bind(this)},j(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:this.pagination.currentPage===o},o)))))):t(n,null,this.pagination.pages.map((r=>t("li",{class:this.isActivePageClass(z.item,r)},o(r,r)))),this.pagination.totalPages?t("li",{class:u([z.item,z.itemMore])},t("span",{class:z.inner},t("span",{id:this.pageSelectId,hidden:true},this.wcagSelectLabel),t("gov-form-select",{size:"m",variant:this.variant,"wcag-labelled-by":this.pageSelectId,ref:o=>this.spreadSelectRef=o,"on-gov-change":this.onSelectHandler.bind(this)},t("option",{selected:true,hidden:true},"..."),j(1,this.pagination.totalPages).map((o=>t("option",{value:o,selected:false},o)))))):null),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.currentPage+1:-1,t("gov-icon",{class:z.arrow,name:"chevron-right"}))),t("li",{class:u([z.item,z.itemArrow])},o(this.pagination.totalPages>this.pagination.currentPage?this.pagination.totalPages:-1,t("gov-icon",{class:z.arrow,name:"chevron-double-right"}))))))}onClickHandler(o,r){o.stopPropagation();this.recalculatePagination(r);this.govPage.emit({component:z.root,pagination:this.pagination})}onSelectHandler(o){o.stopPropagation();const r=o.detail.value;const e=parseInt(r);this.resetSelectValue();if(isNaN(e)===false){this.recalculatePagination(e);if(this.link){window.location.href=this.prepareLinkUrl(e)}else{this.govPage.emit({component:z.root,pagination:this.pagination})}}}async validateWcag(){h(this.wcagPageLabel,"wcag-page-label",z.root);d(this.wcagLabel,this.wcagLabelledBy,z.root)}get host(){return this}static get watchers(){return{type:["validateType"],size:["validateSize"],variant:["validateVariant"],current:["recalculate"],total:["recalculate"],pageSize:["recalculate"],maxPages:["recalculate"]}}static get style(){return P}},[0,"gov-pagination",{type:[1],current:[2],total:[2],inverse:[4],size:[1],variant:[1],pageSize:[2,"page-size"],maxPages:[2,"max-pages"],link:[1],wcagLabel:[1,"wcag-label"],wcagLabelledBy:[1,"wcag-labelled-by"],wcagSelectLabel:[1,"wcag-select-label"],wcagPageLabel:[1,"wcag-page-label"],pagination:[32],validateWcag:[64]}]);function E(){if(typeof customElements==="undefined"){return}const o=["gov-pagination","gov-button","gov-form-select","gov-icon"];o.forEach((o=>{switch(o){case"gov-pagination":if(!customElements.get(o)){customElements.define(o,A)}break;case"gov-button":if(!customElements.get(o)){_()}break;case"gov-form-select":if(!customElements.get(o)){f()}break;case"gov-icon":if(!customElements.get(o)){y()}break}}))}E();const M=A;const L=E;export{M as GovPagination,L as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-pagination.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,H as
|
|
1
|
+
import{p as o,H as a,c as e,h as t,d as i}from"./p-80c0109d.js";import{c as s}from"./p-24636c53.js";import{b as r}from"./p-ae894a40.js";import{M as l}from"./p-be4aab0e.js";import{c as d}from"./p-cac3881f.js";import{d as n}from"./p-03990da5.js";import{g as m,a as g}from"./p-3f37ddb6.js";import{a as c}from"./p-561fa17b.js";import{d as v}from"./p-3e8a9e92.js";import{d as h}from"./p-70d9d879.js";import{d as p}from"./p-35f6490a.js";const f='.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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-modal{display:none}.gov-modal__dialog{z-index:101;position:fixed;top:50%;left:50%;display:flex;justify-content:center;align-items:center;width:100%;max-width:var(--gov-modal-max-width, 52.5rem);height:100%;padding:0.5rem;border:none;background:transparent;transform:translate(-50%, -50%);pointer-events:none}.gov-modal__inner{position:relative;display:flex;flex-direction:column;width:100%;max-height:100%;border-radius:var(--gov-border-radius, 0.1875rem);background:var(--gov-modal-bg, var(--gov-color-neutral-white));overflow:hidden;pointer-events:auto;box-shadow:0 0 1.5rem rgba(var(--gov-color-secondary-800-rgb), 0.24)}.gov-modal__header{display:flex;gap:1rem;align-items:flex-start;padding:1.5rem 1rem;border-bottom:var(--gov-modal-border-color, 0.0625rem solid var(--gov-color-secondary-500))}.gov-modal__icon{flex:0 0 auto;padding-top:calc((var(--gov-text-3xl-font-size) * 1.5 - 1.5rem) / 2)}.gov-modal__icon>*{width:1.5rem;height:1.5rem}.gov-modal__title{font-weight:var(--gov-text-3xl-font-weight);font-size:var(--gov-text-3xl-font-size);line-height:var(--gov-text-3xl-line-height);letter-spacing:var(--gov-text-3xl-letter-spacing);margin:0}.gov-modal__close{flex:0 0 auto;margin-left:auto}.gov-modal__content{height:100%;padding:1.5rem 1rem;color:var(--gov-modal-text-color, var(--gov-color-secondary-700));overflow:auto}.gov-modal__content>*:last-child{margin-bottom:0}.gov-modal__footer,.gov-modal__actions{padding:1.5rem 1rem;border-top:var(--gov-modal-border-color, 0.0625rem solid var(--gov-color-secondary-500))}.gov-modal__actions{display:flex;gap:0.5rem 1rem;flex-wrap:wrap;justify-content:flex-end}.gov-modal__dialog:focus .gov-modal__inner{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}.gov-modal[open=""],.gov-modal[open=true i],.gov-modal[open="1"]{display:block}@media (min-width: 30em){.gov-modal__dialog{max-width:calc(var(--gov-modal-max-width, 52.5rem) + 3rem);padding:1.5rem}.gov-modal__dialog:focus{outline-offset:-1.5rem}.gov-modal__inner{box-shadow:0 0 2rem rgba(var(--gov-color-secondary-800-rgb), 0.32)}.gov-modal--prompt .gov-modal__dialog{max-width:calc(var(--gov-modal-prompt-max-width, 33.125rem) + 3rem)}}@media (min-width: 48em){.gov-modal__header{gap:1.25rem;padding:2rem 2.5rem 2rem 3rem}.gov-modal__content{padding:2rem 3rem}.gov-modal__footer{padding:1rem 3rem}.gov-modal--prompt .gov-modal__header,.gov-modal--prompt .gov-modal__content,.gov-modal--prompt .gov-modal__footer,.gov-modal--prompt .gov-modal__actions{padding:1.5rem}}';const b=o(class o extends a{constructor(){super();this.__registerHost();this.govClose=e(this,"gov-close",7);this.open=false;this.label=undefined;this.role="dialog";this.labelTag="h2";this.wcagLabelledBy=undefined;this.wcagDescribedBy=undefined;this.wcagCloseLabel=undefined;this.wcagCloseLabelledBy=undefined;this.h=m(this.host);this.labelId=s("GovPromptLabel");this.contentId=s("GovPromptContent")}validateLabelTag(o){const a=["h1","h2","h3","h4","h5","h6"];if(o){if(!a.includes(o)){c(`[${l.root}]: Tag ${o} is not allowed.`)}}}watchOpen(o){this.open=o}showModal(){this.open=true;document.body.classList.add(l.bodyFix)}hideModal(){this.open=false;document.body.classList.remove(l.bodyFix)}async componentWillRender(){if(this.open){this.showModal()}else{this.hideModal()}}async componentDidRender(){if(d()){await n(500);await this.validateWcag()}}render(){const o=this.labelTag;return t(i,{class:this.h.classes(l.rootPrompt),open:this.open},t("dialog",{class:l.dialog,hidden:!this.open,tabindex:"-1",open:this.open,"aria-modal":"true","aria-hidden":g(!this.open),"aria-labelledby":this.wcagLabelledBy||this.labelId,"aria-describedby":this.wcagDescribedBy||this.contentId,role:this.role},t("div",{class:l.inner},t("div",{class:l.header},this.h.hasSlot("icon")&&t("div",{class:l.icon},t("slot",{name:"icon"})),this.label&&t(o,{class:l.title,id:this.labelId},this.label),t("gov-button",{class:l.close,variant:"primary",wcagLabel:this.wcagCloseLabel,wcagLabelledBy:this.wcagCloseLabelledBy,type:"base","on-gov-click":this.onCloseHandler.bind(this)},t("gov-icon",{name:"x-lg"}))),t("div",{class:l.content,id:this.contentId},t("slot",null)),t("div",{class:l.actions},t("slot",{name:"actions"})))),this.open?t("gov-backdrop",{"wcag-label":this.wcagCloseLabel,"wcag-labelled-by":this.wcagCloseLabelledBy,"on-gov-click":this.onCloseHandler.bind(this)}):null)}onCloseHandler(o){o.stopPropagation();this.hideModal();this.govClose.emit(o)}async show(){this.showModal()}async hide(){this.hideModal()}async validateWcag(){r(this.wcagLabelledBy,"wcag-labelled-by",l.root);r(this.wcagDescribedBy,"wcag-described-by",l.root)}get host(){return this}static get watchers(){return{labelTag:["validateLabelTag"],open:["watchOpen"]}}static get style(){return f}},[4,"gov-prompt",{open:[1028],label:[1],role:[1],labelTag:[1,"label-tag"],wcagLabelledBy:[1,"wcag-labelled-by"],wcagDescribedBy:[1,"wcag-described-by"],wcagCloseLabel:[1,"wcag-close-label"],wcagCloseLabelledBy:[1,"wcag-close-labelled-by"],show:[64],hide:[64],validateWcag:[64]}]);function u(){if(typeof customElements==="undefined"){return}const o=["gov-prompt","gov-backdrop","gov-button","gov-icon"];o.forEach((o=>{switch(o){case"gov-prompt":if(!customElements.get(o)){customElements.define(o,b)}break;case"gov-backdrop":if(!customElements.get(o)){v()}break;case"gov-button":if(!customElements.get(o)){h()}break;case"gov-icon":if(!customElements.get(o)){p()}break}}))}u();const _=b;const w=u;export{_ as GovPrompt,w as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["govPromptCss","GovPrompt","proxyCustomElement","H","constructor","this","h","govHost","host","labelId","createID","contentId","validateLabelTag","newValue","validTags","includes","govErrorLog","ModalClass","root","watchOpen","open","showModal","document","body","classList","add","bodyFix","hideModal","remove","componentWillRender","componentDidRender","canValidateWcagOnRender","delay","validateWcag","render","LabelTag","labelTag","Host","class","classes","rootPrompt","dialog","hidden","tabindex","toBoolAttr","wcagLabelledBy","wcagDescribedBy","role","inner","header","hasSlot","icon","name","label","title","id","close","variant","wcagLabel","wcagCloseLabel","wcagCloseLabelledBy","type","onCloseHandler","bind","content","actions","e","stopPropagation","govClose","emit","show","hide","validateWcagRef"],"sources":["../../../packages/core/src/components/gov-promp/gov-prompt.scss?tag=gov-prompt","../../../packages/core/src/components/gov-promp/gov-prompt.tsx"],"sourcesContent":["/*\n * Prompt\n */\n\n// $class: \".gov-prompt\";\n@import \"../gov-modal/gov-modal.scss\";\n\n// #{$class} {\n// \t//\n// }\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../utils/string.utils\"\nimport { validateWcagRef } from \"../../helpers/Validate/wcag\"\nimport { ModalClass } from \"../gov-modal/constants\"\nimport { canValidateWcagOnRender } from \"../../helpers/Dom/win\"\nimport { delay } from \"../../utils/utils\"\nimport { govHost, toBoolAttr } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { govErrorLog } from \"../../helpers/Log/gov.log\"\nimport { Nullable } from \"../../types/interfaces\"\n\n@Component({\n\ttag: \"gov-prompt\",\n\tstyleUrl: \"gov-prompt.scss\",\n})\nexport class GovPrompt {\n\tprivate h: GovHost\n\tprivate readonly labelId: string\n\tprivate readonly contentId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.labelId = createID(\"GovPromptLabel\")\n\t\tthis.contentId = createID(\"GovPromptContent\")\n\t}\n\n\t@Element() host: HTMLGovPromptElement\n\t/**\n\t * Attribute for modal window display\n\t */\n\t@Prop({ mutable: true }) open = false\n\t/**\n\t * Title of modal window\n\t */\n\t@Prop() label: string\n\t/**\n\t * Role of modal\n\t */\n\t@Prop({ attribute: \"role\" }) role: Nullable<string> = \"dialog\"\n\t/**\n\t * Used to change the HTML tag in the modal label for correct semantic structure\n\t */\n\t@Prop({ attribute: \"label-tag\" }) readonly labelTag: string = \"h2\"\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the modal.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) wcagDescribedBy: string\n\t/**\n\t * Adds accessible label for the modal close button that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: \"wcag-close-label\" }) wcagCloseLabel: string\n\t/**\n\t * A string of identifiers that indicate alternative label elements for closing the modal window\n\t */\n\t@Prop({ attribute: \"wcag-close-labelled-by\" }) wcagCloseLabelledBy: string\n\t/**\n\t * Emitted when modal window closes.\n\t */\n\t@Event({ eventName: \"gov-close\" }) govClose: EventEmitter<PointerEvent>\n\n\t@Watch(\"labelTag\")\n\tvalidateLabelTag(newValue: string): void {\n\t\tconst validTags = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]\n\t\tif (newValue) {\n\t\t\tif (!validTags.includes(newValue)) {\n\t\t\t\tgovErrorLog(`[${ModalClass.root}]: Tag ${newValue} is not allowed.`)\n\t\t\t}\n\t\t}\n\t}\n\n\t@Watch(\"open\")\n\twatchOpen(newValue: boolean): void {\n\t\tthis.open = newValue\n\t}\n\n\tprivate showModal() {\n\t\tthis.open = true\n\t\tdocument.body.classList.add(ModalClass.bodyFix)\n\t}\n\n\tprivate hideModal() {\n\t\tthis.open = false\n\t\tdocument.body.classList.remove(ModalClass.bodyFix)\n\t}\n\n\tasync componentWillRender() {\n\t\tif (this.open) {\n\t\t\tthis.showModal()\n\t\t} else {\n\t\t\tthis.hideModal()\n\t\t}\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 LabelTag = this.labelTag\n\t\treturn (\n\t\t\t<Host class={this.h.classes(ModalClass.rootPrompt)} open={this.open}>\n\t\t\t\t<dialog\n\t\t\t\t\tclass={ModalClass.dialog}\n\t\t\t\t\thidden={!this.open}\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\topen={this.open}\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\taria-hidden={toBoolAttr(!this.open)}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy || this.labelId}\n\t\t\t\t\taria-describedby={this.wcagDescribedBy || this.contentId}\n\t\t\t\t\trole={this.role}\n\t\t\t\t>\n\t\t\t\t\t<div class={ModalClass.inner}>\n\t\t\t\t\t\t<div class={ModalClass.header}>\n\t\t\t\t\t\t\t{this.h.hasSlot(\"icon\") && (\n\t\t\t\t\t\t\t\t<div class={ModalClass.icon}>\n\t\t\t\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{this.label && (\n\t\t\t\t\t\t\t\t<LabelTag class={ModalClass.title} id={this.labelId}>\n\t\t\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t\t\t</LabelTag>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\tclass={ModalClass.close}\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\twcagLabel={this.wcagCloseLabel}\n\t\t\t\t\t\t\t\twcagLabelledBy={this.wcagCloseLabelledBy}\n\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\" />\n\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.content} id={this.contentId}>\n\t\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.actions}>\n\t\t\t\t\t\t\t<slot name=\"actions\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</dialog>\n\n\t\t\t\t{this.open ? (\n\t\t\t\t\t<gov-backdrop\n\t\t\t\t\t\twcag-label={this.wcagCloseLabel}\n\t\t\t\t\t\twcag-labelled-by={this.wcagCloseLabelledBy}\n\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onCloseHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t\tthis.hideModal()\n\t\tthis.govClose.emit(e)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showModal()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.hideModal()\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.wcagLabelledBy, \"wcag-labelled-by\", ModalClass.root)\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", ModalClass.root)\n\t}\n}\n"],"mappings":"+aAAA,MAAMA,EAAe,
|
|
1
|
+
{"version":3,"names":["govPromptCss","GovPrompt","proxyCustomElement","H","constructor","this","h","govHost","host","labelId","createID","contentId","validateLabelTag","newValue","validTags","includes","govErrorLog","ModalClass","root","watchOpen","open","showModal","document","body","classList","add","bodyFix","hideModal","remove","componentWillRender","componentDidRender","canValidateWcagOnRender","delay","validateWcag","render","LabelTag","labelTag","Host","class","classes","rootPrompt","dialog","hidden","tabindex","toBoolAttr","wcagLabelledBy","wcagDescribedBy","role","inner","header","hasSlot","icon","name","label","title","id","close","variant","wcagLabel","wcagCloseLabel","wcagCloseLabelledBy","type","onCloseHandler","bind","content","actions","e","stopPropagation","govClose","emit","show","hide","validateWcagRef"],"sources":["../../../packages/core/src/components/gov-promp/gov-prompt.scss?tag=gov-prompt","../../../packages/core/src/components/gov-promp/gov-prompt.tsx"],"sourcesContent":["/*\n * Prompt\n */\n\n// $class: \".gov-prompt\";\n@import \"../gov-modal/gov-modal.scss\";\n\n// #{$class} {\n// \t//\n// }\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport { createID } from \"../../utils/string.utils\"\nimport { validateWcagRef } from \"../../helpers/Validate/wcag\"\nimport { ModalClass } from \"../gov-modal/constants\"\nimport { canValidateWcagOnRender } from \"../../helpers/Dom/win\"\nimport { delay } from \"../../utils/utils\"\nimport { govHost, toBoolAttr } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { govErrorLog } from \"../../helpers/Log/gov.log\"\nimport { Nullable } from \"../../types/interfaces\"\n\n@Component({\n\ttag: \"gov-prompt\",\n\tstyleUrl: \"gov-prompt.scss\",\n})\nexport class GovPrompt {\n\tprivate h: GovHost\n\tprivate readonly labelId: string\n\tprivate readonly contentId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.labelId = createID(\"GovPromptLabel\")\n\t\tthis.contentId = createID(\"GovPromptContent\")\n\t}\n\n\t@Element() host: HTMLGovPromptElement\n\t/**\n\t * Attribute for modal window display\n\t */\n\t@Prop({ mutable: true }) open = false\n\t/**\n\t * Title of modal window\n\t */\n\t@Prop() label: string\n\t/**\n\t * Role of modal\n\t */\n\t@Prop({ attribute: \"role\" }) role: Nullable<string> = \"dialog\"\n\t/**\n\t * Used to change the HTML tag in the modal label for correct semantic structure\n\t */\n\t@Prop({ attribute: \"label-tag\" }) readonly labelTag: string = \"h2\"\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the modal.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) wcagDescribedBy: string\n\t/**\n\t * Adds accessible label for the modal close button that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: \"wcag-close-label\" }) wcagCloseLabel: string\n\t/**\n\t * A string of identifiers that indicate alternative label elements for closing the modal window\n\t */\n\t@Prop({ attribute: \"wcag-close-labelled-by\" }) wcagCloseLabelledBy: string\n\t/**\n\t * Emitted when modal window closes.\n\t */\n\t@Event({ eventName: \"gov-close\" }) govClose: EventEmitter<PointerEvent>\n\n\t@Watch(\"labelTag\")\n\tvalidateLabelTag(newValue: string): void {\n\t\tconst validTags = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]\n\t\tif (newValue) {\n\t\t\tif (!validTags.includes(newValue)) {\n\t\t\t\tgovErrorLog(`[${ModalClass.root}]: Tag ${newValue} is not allowed.`)\n\t\t\t}\n\t\t}\n\t}\n\n\t@Watch(\"open\")\n\twatchOpen(newValue: boolean): void {\n\t\tthis.open = newValue\n\t}\n\n\tprivate showModal() {\n\t\tthis.open = true\n\t\tdocument.body.classList.add(ModalClass.bodyFix)\n\t}\n\n\tprivate hideModal() {\n\t\tthis.open = false\n\t\tdocument.body.classList.remove(ModalClass.bodyFix)\n\t}\n\n\tasync componentWillRender() {\n\t\tif (this.open) {\n\t\t\tthis.showModal()\n\t\t} else {\n\t\t\tthis.hideModal()\n\t\t}\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 LabelTag = this.labelTag\n\t\treturn (\n\t\t\t<Host class={this.h.classes(ModalClass.rootPrompt)} open={this.open}>\n\t\t\t\t<dialog\n\t\t\t\t\tclass={ModalClass.dialog}\n\t\t\t\t\thidden={!this.open}\n\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\topen={this.open}\n\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\taria-hidden={toBoolAttr(!this.open)}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy || this.labelId}\n\t\t\t\t\taria-describedby={this.wcagDescribedBy || this.contentId}\n\t\t\t\t\trole={this.role}\n\t\t\t\t>\n\t\t\t\t\t<div class={ModalClass.inner}>\n\t\t\t\t\t\t<div class={ModalClass.header}>\n\t\t\t\t\t\t\t{this.h.hasSlot(\"icon\") && (\n\t\t\t\t\t\t\t\t<div class={ModalClass.icon}>\n\t\t\t\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{this.label && (\n\t\t\t\t\t\t\t\t<LabelTag class={ModalClass.title} id={this.labelId}>\n\t\t\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t\t\t</LabelTag>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\tclass={ModalClass.close}\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\twcagLabel={this.wcagCloseLabel}\n\t\t\t\t\t\t\t\twcagLabelledBy={this.wcagCloseLabelledBy}\n\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\" />\n\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.content} id={this.contentId}>\n\t\t\t\t\t\t\t<slot />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class={ModalClass.actions}>\n\t\t\t\t\t\t\t<slot name=\"actions\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</dialog>\n\n\t\t\t\t{this.open ? (\n\t\t\t\t\t<gov-backdrop\n\t\t\t\t\t\twcag-label={this.wcagCloseLabel}\n\t\t\t\t\t\twcag-labelled-by={this.wcagCloseLabelledBy}\n\t\t\t\t\t\ton-gov-click={this.onCloseHandler.bind(this)}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onCloseHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t\tthis.hideModal()\n\t\tthis.govClose.emit(e)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showModal()\n\t}\n\n\t/**\n\t * Hiding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.hideModal()\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.wcagLabelledBy, \"wcag-labelled-by\", ModalClass.root)\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", ModalClass.root)\n\t}\n}\n"],"mappings":"+aAAA,MAAMA,EAAe,wyF,MCeRC,EAASC,EAAA,MAAAD,UAAAE,EAKrB,WAAAC,G,4EAUgC,M,+BAQsB,S,cAIQ,K,8HArB7DC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,QAAUC,EAAS,kBACxBL,KAAKM,UAAYD,EAAS,mB,CA0C3B,gBAAAE,CAAiBC,GAChB,MAAMC,EAAY,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM,MACjD,GAAID,EAAU,CACb,IAAKC,EAAUC,SAASF,GAAW,CAClCG,EAAY,IAAIC,EAAWC,cAAcL,oB,GAM5C,SAAAM,CAAUN,GACTR,KAAKe,KAAOP,C,CAGL,SAAAQ,GACPhB,KAAKe,KAAO,KACZE,SAASC,KAAKC,UAAUC,IAAIR,EAAWS,Q,CAGhC,SAAAC,GACPtB,KAAKe,KAAO,MACZE,SAASC,KAAKC,UAAUI,OAAOX,EAAWS,Q,CAG3C,yBAAMG,GACL,GAAIxB,KAAKe,KAAM,CACdf,KAAKgB,W,KACC,CACNhB,KAAKsB,W,EAIP,wBAAMG,GACL,GAAIC,IAA2B,OACxBC,EAAM,WACN3B,KAAK4B,c,EAIb,MAAAC,GACC,MAAMC,EAAW9B,KAAK+B,SACtB,OACC9B,EAAC+B,EAAI,CAACC,MAAOjC,KAAKC,EAAEiC,QAAQtB,EAAWuB,YAAapB,KAAMf,KAAKe,MAC9Dd,EAAA,UACCgC,MAAOrB,EAAWwB,OAClBC,QAASrC,KAAKe,KACduB,SAAS,KACTvB,KAAMf,KAAKe,KAAI,aACJ,OAAM,cACJwB,GAAYvC,KAAKe,MAAK,kBAClBf,KAAKwC,gBAAkBxC,KAAKI,QAAO,mBAClCJ,KAAKyC,iBAAmBzC,KAAKM,UAC/CoC,KAAM1C,KAAK0C,MAEXzC,EAAA,OAAKgC,MAAOrB,EAAW+B,OACtB1C,EAAA,OAAKgC,MAAOrB,EAAWgC,QACrB5C,KAAKC,EAAE4C,QAAQ,SACf5C,EAAA,OAAKgC,MAAOrB,EAAWkC,MACtB7C,EAAA,QAAM8C,KAAK,UAGZ/C,KAAKgD,OACL/C,EAAC6B,EAAQ,CAACG,MAAOrB,EAAWqC,MAAOC,GAAIlD,KAAKI,SAC1CJ,KAAKgD,OAGR/C,EAAA,cACCgC,MAAOrB,EAAWuC,MAClBC,QAAQ,UACRC,UAAWrD,KAAKsD,eAChBd,eAAgBxC,KAAKuD,oBACrBC,KAAK,OAAM,eACGxD,KAAKyD,eAAeC,KAAK1D,OAEvCC,EAAA,YAAU8C,KAAK,WAGjB9C,EAAA,OAAKgC,MAAOrB,EAAW+C,QAAST,GAAIlD,KAAKM,WACxCL,EAAA,cAEDA,EAAA,OAAKgC,MAAOrB,EAAWgD,SACtB3D,EAAA,QAAM8C,KAAK,eAKb/C,KAAKe,KACLd,EAAA,6BACaD,KAAKsD,eAAc,mBACbtD,KAAKuD,oBAAmB,eAC5BvD,KAAKyD,eAAeC,KAAK1D,QAErC,K,CAKC,cAAAyD,CAAeI,GACtBA,EAAEC,kBACF9D,KAAKsB,YACLtB,KAAK+D,SAASC,KAAKH,E,CAOpB,UAAMI,GACLjE,KAAKgB,W,CAON,UAAMkD,GACLlE,KAAKsB,W,CAON,kBAAMM,GACLuC,EAAgBnE,KAAKwC,eAAgB,mBAAoB5B,EAAWC,MACpEsD,EAAgBnE,KAAKyC,gBAAiB,oBAAqB7B,EAAWC,K"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as e,H as i,c as a,h as o,d as t}from"./p-80c0109d.js";import{a as n}from"./p-561fa17b.js";import{S as s}from"./p-36be8f6e.js";import{g as r,p as v,b as d}from"./p-3f37ddb6.js";import{d as g}from"./p-
|
|
1
|
+
import{p as e,H as i,c as a,h as o,d as t}from"./p-80c0109d.js";import{a as n}from"./p-561fa17b.js";import{S as s}from"./p-36be8f6e.js";import{g as r,p as v,b as d}from"./p-3f37ddb6.js";import{d as g}from"./p-0378da4d.js";import{d as m}from"./p-35f6490a.js";const c='.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)}}@keyframes progress{0%{background-position:-200px 0}100%{background-position:calc(200px + 100%) 0}}@keyframes pulse{0%{opacity:1}50%{opacity:0.4}100%{opacity:1}}.gov-side-nav-item{position:relative;display:block;width:100%}.gov-side-nav-item__header{display:flex;align-items:center;border-bottom:var(--gov-side-nav-border, 0.0625rem solid var(--gov-color-secondary-500))}.gov-side-nav-item__name{display:inline-flex;vertical-align:middle;justify-content:center;align-items:center;border:0;background-color:transparent;text-align:center;text-decoration:none;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;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);display:flex;gap:1rem;flex:1 1 auto;justify-content:flex-start;padding:0.75rem 1rem 0.75rem 0.5rem;color:var(--gov-side-nav-color, var(--gov-color-secondary));text-align:left;transition:background-color 150ms}.gov-side-nav-item__name:focus{outline:none}.gov-side-nav-item__name:focus{outline:none}.gov-side-nav-item__name:focus-visible{border-radius:var(--gov-border-radius, 0.1875rem);outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base);outline-offset:0}button.gov-side-nav-item__name{padding-right:0 !important}@media not all and (pointer: coarse){.gov-side-nav-item__name:hover{background:var(--gov-side-nav-hover-bg, var(--gov-color-primary-200))}}.gov-side-nav-item__icon{display:flex;flex:0 0 auto;width:1rem;height:1rem}.gov-side-nav-item__icon .gov-icon{margin:0;color:var(--gov-side-nav-color, var(--gov-color-secondary))}.gov-side-nav-item__label{color:inherit}.gov-side-nav-item__badge{display:flex;flex:0 0 auto}.gov-side-nav-item__arrow{display:inline-flex;vertical-align:middle;justify-content:center;align-items:center;border:0;background-color:transparent;text-align:center;text-decoration:none;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:0 0 auto;align-self:stretch;width:3rem;margin-left:auto;color:var(--gov-side-nav-arrow-color, var(--gov-color-primary));transition:background-color 150ms}.gov-side-nav-item__arrow:focus{outline:none}.gov-side-nav-item__arrow:focus{outline:none}.gov-side-nav-item__arrow:focus-visible{border-radius:var(--gov-border-radius, 0.1875rem);outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base);outline-offset:0}.gov-side-nav-item__arrow .gov-icon{width:0.75rem;height:0.75rem}@media not all and (pointer: coarse){.gov-side-nav-item__arrow:hover{background:var(--gov-side-nav-hover-bg, var(--gov-color-primary-200))}}.gov-side-nav-item__content{display:none}.gov-side-nav-item--w-icon .gov-side-nav-item__label{margin-left:2rem}.gov-side-nav-item--w-icon .gov-side-nav-item__icon+.gov-side-nav-item__label{margin-left:0}.gov-side-nav-item .gov-side-nav-item .gov-side-nav-item__header{border:none !important}.gov-side-nav-item .gov-side-nav-item .gov-side-nav-item__name{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);padding:0.625rem 0.5rem;font-weight:bold}.gov-side-nav-item .gov-side-nav-item[aria-expanded=""],.gov-side-nav-item .gov-side-nav-item[aria-expanded=true i],.gov-side-nav-item .gov-side-nav-item[aria-expanded="1"]{background:var(--gov-side-nav-bg-level-2, var(--gov-color-secondary-300))}.gov-side-nav-item .gov-side-nav-item[aria-expanded=""][inverse=""],.gov-side-nav-item .gov-side-nav-item[aria-expanded=""][inverse=true i],.gov-side-nav-item .gov-side-nav-item[aria-expanded=""][inverse="1"],.gov-side-nav-item .gov-side-nav-item[aria-expanded=true i][inverse=""],.gov-side-nav-item .gov-side-nav-item[aria-expanded=true i][inverse=true i],.gov-side-nav-item .gov-side-nav-item[aria-expanded=true i][inverse="1"],.gov-side-nav-item .gov-side-nav-item[aria-expanded="1"][inverse=""],.gov-side-nav-item .gov-side-nav-item[aria-expanded="1"][inverse=true i],.gov-side-nav-item .gov-side-nav-item[aria-expanded="1"][inverse="1"]{background:var(--gov-side-nav-bg-level-2, var(--gov-color-neutral-white))}.gov-side-nav-item .gov-side-nav-item .gov-side-nav-item .gov-side-nav-item__name{gap:0.75rem;font-weight:inherit}.gov-side-nav-item[compact=""] .gov-side-nav-item__header,.gov-side-nav-item[compact=true i] .gov-side-nav-item__header,.gov-side-nav-item[compact="1"] .gov-side-nav-item__header{border-bottom:none}.gov-side-nav-item[aria-expanded=""]>.gov-side-nav-item__header .gov-side-nav-item__arrow .gov-icon,.gov-side-nav-item[aria-expanded=true i]>.gov-side-nav-item__header .gov-side-nav-item__arrow .gov-icon,.gov-side-nav-item[aria-expanded="1"]>.gov-side-nav-item__header .gov-side-nav-item__arrow .gov-icon{transform:scale(-1)}.gov-side-nav-item[aria-expanded=""]>.gov-side-nav-item__content,.gov-side-nav-item[aria-expanded=true i]>.gov-side-nav-item__content,.gov-side-nav-item[aria-expanded="1"]>.gov-side-nav-item__content{display:block}';const l=e(class e extends i{constructor(){super();this.__registerHost();this.govChange=a(this,"gov-change",7);this.isExpandedState=undefined;this.inverse=false;this.compact=false;this.identifier=undefined;this.count=false;this.label=undefined;this.disabled=false;this.href=undefined;this.isExpanded=false;this.h=r(this.host)}validateLabel(e){if(!e){n(`[${s.root}]: Parameter label is required.`)}}emmitChange(){this.govChange.emit({open:this.isExpandedState,element:this.host})}componentWillLoad(){this.isExpandedState=this.isExpanded;this.validateLabel(this.label)}get classNames(){const{h:e}=this;return v([s.root,e.hasSlot("icon")&&s.rootWithIcon])}render(){const{isExpandedState:e,label:i}=this;const a=this.host.children.length>1;return o(t,{class:this.classNames,role:"listitem",inverse:this.inverse,"aria-expanded":d(e)},this.href?o("div",{class:s.header},o("a",{class:s.name,href:this.href},this.h.hasSlot("icon")&&o("span",{class:s.icon},o("slot",{name:"icon"})),o("span",{class:s.label},i),this.count&&o("span",{class:s.badge},o("gov-badge",{variant:"secondary",size:"s",inverse:this.inverse},"3"))),a&&o("button",{type:"button",class:s.arrow,onClick:()=>this.toggle()},o("gov-icon",{name:"chevron-down"}))):o("div",{class:s.header},o("button",{class:s.name,type:"button",onClick:()=>this.toggle()},this.h.hasSlot("icon")&&o("span",{class:s.icon},o("slot",{name:"icon"})),o("span",{class:s.label},i),a&&o("span",{class:s.arrow},o("gov-icon",{name:"chevron-down"})))),a&&o("div",{class:s.content},o("slot",null)))}async open(){this.isExpandedState=true;this.emmitChange()}async close(){this.isExpandedState=false;this.emmitChange()}async toggle(){this.isExpandedState=!this.isExpandedState;this.emmitChange()}async currentState(){return this.isExpandedState}get host(){return this}static get watchers(){return{label:["validateLabel"]}}static get style(){return c}},[4,"gov-side-nav-item",{inverse:[4],compact:[4],identifier:[1],count:[4],label:[1],disabled:[4],href:[1],isExpanded:[4,"is-expanded"],isExpandedState:[32],open:[64],close:[64],toggle:[64],currentState:[64]}]);function p(){if(typeof customElements==="undefined"){return}const e=["gov-side-nav-item","gov-badge","gov-icon"];e.forEach((e=>{switch(e){case"gov-side-nav-item":if(!customElements.get(e)){customElements.define(e,l)}break;case"gov-badge":if(!customElements.get(e)){g()}break;case"gov-icon":if(!customElements.get(e)){m()}break}}))}p();const h=l;const u=p;export{h as GovSideNavItem,u as defineCustomElement};
|
|
2
2
|
//# sourceMappingURL=gov-side-nav-item.js.map
|