@gov-design-system-ce/components 0.0.24 → 0.0.26

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.
Files changed (151) hide show
  1. package/dist/cjs/gov-accordion-item.cjs.entry.js +1 -1
  2. package/dist/cjs/gov-accordion-item.cjs.entry.js.map +1 -1
  3. package/dist/cjs/gov-app.cjs.entry.js +76 -3
  4. package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
  5. package/dist/cjs/gov-badge.cjs.entry.js +1 -1
  6. package/dist/cjs/gov-badge.cjs.entry.js.map +1 -1
  7. package/dist/cjs/gov-button.cjs.entry.js +1 -1
  8. package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
  9. package/dist/cjs/gov-form-autocomplete.cjs.entry.js +27 -7
  10. package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
  11. package/dist/cjs/gov-form-control.cjs.entry.js +1 -1
  12. package/dist/cjs/gov-form-control.cjs.entry.js.map +1 -1
  13. package/dist/cjs/gov-form-group.cjs.entry.js +1 -1
  14. package/dist/cjs/gov-form-group.cjs.entry.js.map +1 -1
  15. package/dist/cjs/gov-form-input.cjs.entry.js +10 -1
  16. package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
  17. package/dist/cjs/gov-form-multi-select.cjs.entry.js +1 -1
  18. package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
  19. package/dist/cjs/gov-form-switch.cjs.entry.js +1 -1
  20. package/dist/cjs/gov-form-switch.cjs.entry.js.map +1 -1
  21. package/dist/cjs/gov-icon.cjs.entry.js +1 -1
  22. package/dist/cjs/gov-skeleton.cjs.entry.js +1 -1
  23. package/dist/cjs/gov-skeleton.cjs.entry.js.map +1 -1
  24. package/dist/cjs/gov-tooltip.cjs.entry.js +1 -1
  25. package/dist/cjs/gov-tooltip.cjs.entry.js.map +1 -1
  26. package/dist/collection/components/gov-accordion/gov-accordion-item.css +24 -24
  27. package/dist/collection/components/gov-badge/gov-badge.css +3 -0
  28. package/dist/collection/components/gov-button/gov-button.css +1 -0
  29. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +29 -9
  30. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
  31. package/dist/collection/components/gov-form/control/gov-form-control.css +6 -6
  32. package/dist/collection/components/gov-form/group/gov-form-group.css +3 -0
  33. package/dist/collection/components/gov-form/input/gov-form-input.js +29 -1
  34. package/dist/collection/components/gov-form/input/gov-form-input.js.map +1 -1
  35. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +1 -1
  36. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
  37. package/dist/collection/components/gov-form/switch/gov-form-switch.css +0 -8
  38. package/dist/collection/components/gov-icon/list.js +1 -0
  39. package/dist/collection/components/gov-icon/list.js.map +1 -1
  40. package/dist/collection/components/gov-loading/skeleton/gov-skeleton.css +3 -2
  41. package/dist/collection/components/gov-loading/skeleton/gov-skeleton.js.map +1 -1
  42. package/dist/collection/components/gov-tooltip/gov-tooltip.css +0 -3
  43. package/dist/collection/pages/Accordion.js +19 -0
  44. package/dist/collection/pages/Accordion.js.map +1 -1
  45. package/dist/collection/pages/Badge.js +57 -3
  46. package/dist/collection/pages/Badge.js.map +1 -1
  47. package/dist/components/gov-accordion-item.js +1 -1
  48. package/dist/components/gov-accordion-item.js.map +1 -1
  49. package/dist/components/gov-app.js +76 -3
  50. package/dist/components/gov-app.js.map +1 -1
  51. package/dist/components/gov-badge2.js +1 -1
  52. package/dist/components/gov-badge2.js.map +1 -1
  53. package/dist/components/gov-button2.js +1 -1
  54. package/dist/components/gov-button2.js.map +1 -1
  55. package/dist/components/gov-form-autocomplete2.js +28 -8
  56. package/dist/components/gov-form-autocomplete2.js.map +1 -1
  57. package/dist/components/gov-form-control.js +1 -1
  58. package/dist/components/gov-form-control.js.map +1 -1
  59. package/dist/components/gov-form-group.js +1 -1
  60. package/dist/components/gov-form-group.js.map +1 -1
  61. package/dist/components/gov-form-input2.js +10 -1
  62. package/dist/components/gov-form-input2.js.map +1 -1
  63. package/dist/components/gov-form-multi-select.js +1 -1
  64. package/dist/components/gov-form-multi-select.js.map +1 -1
  65. package/dist/components/gov-form-switch.js +1 -1
  66. package/dist/components/gov-form-switch.js.map +1 -1
  67. package/dist/components/gov-icon2.js +1 -1
  68. package/dist/components/gov-skeleton.js +1 -1
  69. package/dist/components/gov-skeleton.js.map +1 -1
  70. package/dist/components/gov-tooltip.js +1 -1
  71. package/dist/components/gov-tooltip.js.map +1 -1
  72. package/dist/core/core.css +1 -1
  73. package/dist/core/core.esm.js +1 -1
  74. package/dist/core/critical.css +187 -0
  75. package/dist/core/p-005bfb42.entry.js +2 -0
  76. package/dist/core/p-005bfb42.entry.js.map +1 -0
  77. package/dist/core/p-1065b347.entry.js +2 -0
  78. package/dist/core/p-1065b347.entry.js.map +1 -0
  79. package/dist/core/{p-8925ef42.entry.js → p-1ba7bd9f.entry.js} +2 -2
  80. package/dist/core/p-1ba7bd9f.entry.js.map +1 -0
  81. package/dist/core/{p-0874a5ec.entry.js → p-4d257c38.entry.js} +2 -2
  82. package/dist/core/p-4d257c38.entry.js.map +1 -0
  83. package/dist/core/p-9b380ef6.entry.js +2 -0
  84. package/dist/core/p-9b380ef6.entry.js.map +1 -0
  85. package/dist/core/{p-a8b628ed.entry.js → p-b3d9b255.entry.js} +2 -2
  86. package/dist/core/p-b3d9b255.entry.js.map +1 -0
  87. package/dist/core/{p-5e4cf9a2.entry.js → p-b3f73e1d.entry.js} +2 -2
  88. package/dist/core/p-b3f73e1d.entry.js.map +1 -0
  89. package/dist/core/p-b7681cba.entry.js +2 -0
  90. package/dist/core/p-b7681cba.entry.js.map +1 -0
  91. package/dist/core/p-bec31703.entry.js +2 -0
  92. package/dist/core/p-bec31703.entry.js.map +1 -0
  93. package/dist/core/{p-99f198b9.entry.js → p-c1c5b496.entry.js} +2 -2
  94. package/dist/core/p-c1c5b496.entry.js.map +1 -0
  95. package/dist/core/{p-ccb44728.entry.js → p-c8796c7a.entry.js} +2 -2
  96. package/dist/core/p-ebf79ea8.entry.js +2 -0
  97. package/dist/core/p-ebf79ea8.entry.js.map +1 -0
  98. package/dist/core/p-edcfb1f7.entry.js +2 -0
  99. package/dist/core/p-edcfb1f7.entry.js.map +1 -0
  100. package/dist/custom-elements/index.js +1 -1
  101. package/dist/custom-elements/index.js.map +1 -1
  102. package/dist/esm/gov-accordion-item.entry.js +1 -1
  103. package/dist/esm/gov-accordion-item.entry.js.map +1 -1
  104. package/dist/esm/gov-app.entry.js +76 -3
  105. package/dist/esm/gov-app.entry.js.map +1 -1
  106. package/dist/esm/gov-badge.entry.js +1 -1
  107. package/dist/esm/gov-badge.entry.js.map +1 -1
  108. package/dist/esm/gov-button.entry.js +1 -1
  109. package/dist/esm/gov-button.entry.js.map +1 -1
  110. package/dist/esm/gov-form-autocomplete.entry.js +28 -8
  111. package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
  112. package/dist/esm/gov-form-control.entry.js +1 -1
  113. package/dist/esm/gov-form-control.entry.js.map +1 -1
  114. package/dist/esm/gov-form-group.entry.js +1 -1
  115. package/dist/esm/gov-form-group.entry.js.map +1 -1
  116. package/dist/esm/gov-form-input.entry.js +10 -1
  117. package/dist/esm/gov-form-input.entry.js.map +1 -1
  118. package/dist/esm/gov-form-multi-select.entry.js +1 -1
  119. package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
  120. package/dist/esm/gov-form-switch.entry.js +1 -1
  121. package/dist/esm/gov-form-switch.entry.js.map +1 -1
  122. package/dist/esm/gov-icon.entry.js +1 -1
  123. package/dist/esm/gov-skeleton.entry.js +1 -1
  124. package/dist/esm/gov-skeleton.entry.js.map +1 -1
  125. package/dist/esm/gov-tooltip.entry.js +1 -1
  126. package/dist/esm/gov-tooltip.entry.js.map +1 -1
  127. package/dist/hydrate/index.js +121 -19
  128. package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.d.ts +4 -2
  129. package/dist/types/components/gov-form/input/gov-form-input.d.ts +5 -0
  130. package/dist/types/components.d.ts +4 -0
  131. package/package.json +1 -1
  132. package/dist/core/p-0800095f.entry.js +0 -2
  133. package/dist/core/p-0800095f.entry.js.map +0 -1
  134. package/dist/core/p-0874a5ec.entry.js.map +0 -1
  135. package/dist/core/p-3699c1b3.entry.js +0 -2
  136. package/dist/core/p-3699c1b3.entry.js.map +0 -1
  137. package/dist/core/p-3cd5b6cb.entry.js +0 -2
  138. package/dist/core/p-3cd5b6cb.entry.js.map +0 -1
  139. package/dist/core/p-5176fad8.entry.js +0 -2
  140. package/dist/core/p-5176fad8.entry.js.map +0 -1
  141. package/dist/core/p-5e4cf9a2.entry.js.map +0 -1
  142. package/dist/core/p-8204070b.entry.js +0 -2
  143. package/dist/core/p-8204070b.entry.js.map +0 -1
  144. package/dist/core/p-8925ef42.entry.js.map +0 -1
  145. package/dist/core/p-99f198b9.entry.js.map +0 -1
  146. package/dist/core/p-a8b628ed.entry.js.map +0 -1
  147. package/dist/core/p-bb3afae6.entry.js +0 -2
  148. package/dist/core/p-bb3afae6.entry.js.map +0 -1
  149. package/dist/core/p-d83b4bdc.entry.js +0 -2
  150. package/dist/core/p-d83b4bdc.entry.js.map +0 -1
  151. /package/dist/core/{p-ccb44728.entry.js.map → p-c8796c7a.entry.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/group/constants.ts","../../../packages/core/src/components/gov-form/group/gov-form-group.scss?tag=gov-form-group","../../../packages/core/src/components/gov-form/group/gov-form-group.tsx"],"names":["FormGroupSizes","pick","Sizes","FormGroupClass","root","govFormGroupCss","GovFormGroup","[object Object]","hostRef","undefined","this","h","govHost","host","newValue","validateProp","validateGap","gap","Host","class","classes"],"mappings":"iOAIO,MAAMA,EAAiBC,EAAKC,EAAO,CAAC,OAAQ,MAAO,KAAM,KAAM,OAG/D,MAAMC,EAAiB,CAC7BC,KAAM,kBCRP,MAAMC,EAAkB,snBCUXC,EAAY,MAGxBC,YAAAC,sBAQ4CC,UAP3CC,KAAKC,EAAIC,EAAQF,KAAKG,MAUvBN,YAAYO,GACXC,EAAaf,EAAgBc,EAAUX,EAAeC,MAGvDG,oBACCG,KAAKM,YAAYN,KAAKO,KAGvBV,SACC,OACCI,EAACO,EAAI,CAACD,IAAKP,KAAKO,IAAKE,MAAOT,KAAKC,EAAES,QAAQjB,EAAeC,OACzDO,EAAA,OAAA","sourcesContent":["import { pick } from \"../../../utils/utils\"\nimport { Sizes } from \"../../../core/constants/sizes\"\nimport { ValueOf } from \"../../../types/interfaces\"\n\nexport const FormGroupSizes = pick(Sizes, ['_2XS', '_XS', '_S', '_M', '_L'])\nexport type FormGroupSizesType = `${ValueOf<typeof FormGroupSizes>}`\n\nexport const FormGroupClass = {\n\troot: 'gov-form-group',\n}\n","$class: \".gov-form-group\";\n\n#{$class} {\n\t@include base(flex);\n\tflex-direction: column;\n\talign-items: flex-start;\n\n\t// VARIANTS\n\t@each $gap, $definitions in $form-group-gaps {\n\t\t&[gap=\"#{$gap}\"] {\n\t\t\tgap: get($gap, $sizes);\n\t\t}\n\t}\n}\n// :host([inline]) {\n// \tdisplay: flex;\n\n// \t::slotted(gov-checkbox),\n// \t::slotted(gov-radio) {\n// \t\tdisplay: inline-flex;\n// \t\tmargin-right: rem-calc(30);\n// \t}\n// }\n","import { Component, Element, h, Host, Prop, Watch } from \"@stencil/core\"\nimport { FormGroupClass, FormGroupSizes, FormGroupSizesType } from \"./constants\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govHost } from \"../../../helpers/Dom/template\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\n\n@Component({\n\ttag: \"gov-form-group\",\n\tstyleUrl: \"gov-form-group.scss\",\n})\nexport class GovFormGroup {\n\tprivate readonly h: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovFormGroupElement\n\t/**\n\t * Gap's size.\n\t */\n\t@Prop() readonly gap?: FormGroupSizesType = undefined\n\n\t@Watch(\"gap\")\n\tvalidateGap(newValue: string): void {\n\t\tvalidateProp(FormGroupSizes, newValue, FormGroupClass.root)\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateGap(this.gap)\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host gap={this.gap} class={this.h.classes(FormGroupClass.root)}>\n\t\t\t\t<slot></slot>\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{r as o,h as r,H as e,g as a}from"./p-4af5e4f4.js";import{p as n,d as s}from"./p-03990da5.js";import{V as t}from"./p-ff7365ae.js";import{g as i}from"./p-3f37ddb6.js";import{v as g}from"./p-26acf964.js";import{c as l}from"./p-c20102ff.js";import{v}from"./p-670b4f93.js";import"./p-561fa17b.js";import"./p-24636c53.js";const c=n(t,["PRIMARY","SECONDARY","SUCCESS","ERROR","WARNING"]);var d;(function(o){o["CIRCLE"]="circle";o["REACT"]="rect";o["TEXT"]="text"})(d||(d={}));var k;(function(o){o["PULSE"]="pulse";o["PROGRESS"]="progress";o["FALSE"]="false"})(k||(k={}));const p={root:"gov-skeleton",loader:"gov-skeleton__loader"};const u=".gov-spin-animation,.gov-pseudo-spin-animation::before{animation:spin 4s linear infinite}@keyframes spin{100%{transform:rotate(360deg)}}@keyframes countdown{to{transform:scaleX(0)}}@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-skeleton__loader{position:relative;display:inline-block;width:var(--gov-skeleton-width, 100%);height:var(--gov-skeleton-height, 20px);margin-bottom:var(--gov-skeleton-margin-bottom, 8px);border-radius:var(--gov-skeleton-border-radius, var(--gov-border-radius, 0.1875rem));outline:none;overflow:hidden;box-sizing:border-box;will-change:transform}.gov-skeleton__loader.circle{width:var(--gov-skeleton-circle-size, 60px);height:var(--gov-skeleton-circle-size, 60px);margin-bottom:var(--gov-skeleton-margin-bottom, 8px);border-radius:var(--gov-skeleton-circle-radius, 50%)}.gov-skeleton__loader.rect{border-radius:var(--gov-skeleton-rect-radius, 0)}.gov-skeleton__loader.progress{background-size:200px 100%;animation:progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite}.gov-skeleton__loader.pulse{animation:pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;animation-delay:0.5s}@media (prefers-reduced-motion: reduce){.gov-skeleton__loader.pulse,.gov-skeleton__loader.progress{background-image:none;animation:none}}.gov-skeleton[variant=warning] .gov-skeleton__loader{background-color:var(--gov-skeleton-warning-background, var(--gov-color-warning-100));background-repeat:no-repeat}.gov-skeleton[variant=warning] .gov-skeleton__loader.progress{background-image:linear-gradient(90deg, var(--gov-skeleton-warning-background, var(--gov-color-warning-100)), var(--gov-skeleton-warning-foreground, var(--gov-color-warning-200)), var(--gov-skeleton-warning-background, var(--gov-color-warning-100)))}.gov-skeleton[variant=error] .gov-skeleton__loader{background-color:var(--gov-skeleton-error-background, var(--gov-color-error-100));background-repeat:no-repeat}.gov-skeleton[variant=error] .gov-skeleton__loader.progress{background-image:linear-gradient(90deg, var(--gov-skeleton-error-background, var(--gov-color-error-100)), var(--gov-skeleton-error-foreground, var(--gov-color-error-200)), var(--gov-skeleton-error-background, var(--gov-color-error-100)))}.gov-skeleton[variant=secondary] .gov-skeleton__loader{background-color:var(--gov-skeleton-secondary-background, var(--gov-color-secondary-300));background-repeat:no-repeat}.gov-skeleton[variant=secondary] .gov-skeleton__loader.progress{background-image:linear-gradient(90deg, var(--gov-skeleton-secondary-background, var(--gov-color-secondary-300)), var(--gov-skeleton-secondary-foreground, var(--gov-color-secondary-100)), var(--gov-skeleton-secondary-background, var(--gov-color-secondary-300)))}.gov-skeleton[variant=success] .gov-skeleton__loader{background-color:var(--gov-skeleton-success-background, var(--gov-color-success-100));background-repeat:no-repeat}.gov-skeleton[variant=success] .gov-skeleton__loader.progress{background-image:linear-gradient(90deg, var(--gov-skeleton-success-background, var(--gov-color-success-100)), var(--gov-skeleton-success-foreground, var(--gov-color-success-200)), var(--gov-skeleton-success-background, var(--gov-color-success-100)))}.gov-skeleton[variant=primary] .gov-skeleton__loader{background-color:var(--gov-skeleton-primary-background, var(--gov-color-primary-100));background-repeat:no-repeat}.gov-skeleton[variant=primary] .gov-skeleton__loader.progress{background-image:linear-gradient(90deg, var(--gov-skeleton-primary-background, var(--gov-color-primary-100)), var(--gov-skeleton-primary-foreground, var(--gov-color-primary-200)), var(--gov-skeleton-primary-background, var(--gov-color-primary-100)))}";const m=class{constructor(r){o(this,r);this.items=[];this.variant="secondary";this.count=1;this.shape="text";this.width=null;this.height=null;this.animation="progress";this.wcagLabel=undefined;this.h=i(this.host)}validateVariant(o){g(c,o,p.root)}validateShape(o){g(d,o,p.root)}validateAnimation(o){g(k,o,p.root)}componentWillLoad(){this.validateVariant(this.variant);this.validateShape(this.shape);this.validateAnimation(this.animation);this.init()}componentWillUpdate(){this.init()}async componentDidRender(){if(l()){await s(500);await this.validateWcag()}}init(){this.items.length=this.count;this.items.fill(1)}get style(){const o={width:null,height:null};if(this.width){o.width=this.width}if(this.height){o.height=this.height}return Object.assign({},o)}render(){return r(e,{class:this.h.classes(p.root),variant:this.variant},this.items.map(((o,e)=>r("span",{key:e,class:{circle:this.shape==="circle",rect:this.shape==="rect",progress:this.animation==="progress",pulse:this.animation==="pulse",[p.loader]:true},"aria-busy":"true","aria-valuemin":"0","aria-valuemax":"100","aria-valuetext":this.wcagLabel,role:"progressbar",tabindex:"0",style:this.style}))))}async validateWcag(){v(this.wcagLabel,undefined,p.root)}get host(){return a(this)}static get watchers(){return{variant:["validateVariant"],shape:["validateShape"],animation:["validateAnimation"]}}};m.style=u;export{m as gov_skeleton};
2
- //# sourceMappingURL=p-3699c1b3.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-loading/skeleton/constants.ts","../../../packages/core/src/components/gov-loading/skeleton/gov-skeleton.scss?tag=gov-skeleton","../../../packages/core/src/components/gov-loading/skeleton/gov-skeleton.tsx"],"names":["SkeletonVariants","pick","Variants","SkeletonShapes","SkeletonAnimation","SkeletonClass","root","loader","govSkeletonCss","GovSkeleton","[object Object]","hostRef","this","items","h","govHost","host","newValue","validateProp","validateVariant","variant","validateShape","shape","validateAnimation","animation","init","canValidateWcagOnRender","delay","validateWcag","length","count","fill","style","dimenssionsStyles","width","height","Object","assign","Host","class","classes","map","_","index","key","circle","rect","progress","pulse","aria-busy","aria-valuemin","aria-valuemax","aria-valuetext","wcagLabel","role","tabindex","validateWcagLabel","undefined"],"mappings":"mUAIO,MAAMA,EAAmBC,EAAKC,EAAU,CAAC,UAAW,YAAa,UAAW,QAAS,YAG5F,IAAYC,GAAZ,SAAYA,GACXA,EAAA,UAAA,SACAA,EAAA,SAAA,OACAA,EAAA,QAAA,QAHD,CAAYA,IAAAA,EAAc,KAO1B,IAAYC,GAAZ,SAAYA,GACXA,EAAA,SAAA,QACAA,EAAA,YAAA,WACAA,EAAA,SAAA,SAHD,CAAYA,IAAAA,EAAiB,KAOtB,MAAMC,EAAgB,CAC5BC,KAAM,eACNC,OAAQ,wBCvBT,MAAMC,EAAiB,+qHCmBVC,EAAW,MAGvBC,YAAAC,aAkCAC,KAAAC,MAAkB,gBA1BgC,uBAIlC,aAIqB,kBAIb,iBAIC,oBAImB,oCA3B3CD,KAAKE,EAAIC,EAAQH,KAAKI,MAoCvBN,gBAAgBO,GACfC,EAAalB,EAAkBiB,EAAUZ,EAAcC,MAIxDI,cAAcO,GACbC,EAAaf,EAAgBc,EAAUZ,EAAcC,MAItDI,kBAAkBO,GACjBC,EAAad,EAAmBa,EAAUZ,EAAcC,MAGzDI,oBACCE,KAAKO,gBAAgBP,KAAKQ,SAC1BR,KAAKS,cAAcT,KAAKU,OACxBV,KAAKW,kBAAkBX,KAAKY,WAC5BZ,KAAKa,OAGNf,sBACCE,KAAKa,OAGNf,2BACC,GAAIgB,IAA2B,OACxBC,EAAM,WACNf,KAAKgB,gBAIblB,OACCE,KAAKC,MAAMgB,OAASjB,KAAKkB,MACzBlB,KAAKC,MAAMkB,KAAK,GAGjBC,YACC,MAAMC,EAGF,CACHC,MAAO,KACPC,OAAQ,MAET,GAAIvB,KAAKsB,MAAO,CACfD,EAAkBC,MAAQtB,KAAKsB,MAGhC,GAAItB,KAAKuB,OAAQ,CAChBF,EAAkBE,OAASvB,KAAKuB,OAGjC,OAAAC,OAAAC,OAAA,GAAYJ,GAGbvB,SACC,OACCI,EAACwB,EAAI,CAACC,MAAO3B,KAAKE,EAAE0B,QAAQnC,EAAcC,MAAOc,QAASR,KAAKQ,SAC7DR,KAAKC,MAAM4B,KAAI,CAACC,EAAGC,IAElB7B,EAAA,OAAA,CACC8B,IAAKD,EACLJ,MAAO,CACNM,OAAQjC,KAAKU,QAAU,SACvBwB,KAAMlC,KAAKU,QAAU,OACrByB,SAAUnC,KAAKY,YAAc,WAC7BwB,MAAOpC,KAAKY,YAAc,QAC1Bd,CAACL,EAAcE,QAAS,MACxB0C,YAES,OAAMC,gBACF,IAAGC,gBACH,MAAKC,iBACHxC,KAAKyC,UACrBC,KAAK,cACLC,SAAS,IACTvB,MAAOpB,KAAKoB,WAYlBtB,qBACC8C,EAAkB5C,KAAKyC,UAAWI,UAAWpD,EAAcC","sourcesContent":["import { pick } from \"../../../utils/utils\"\nimport { Variants } from \"../../../core/constants/variants\"\nimport { ValueOf } from \"../../../types/interfaces\"\n\nexport const SkeletonVariants = pick(Variants, [\"PRIMARY\", \"SECONDARY\", \"SUCCESS\", \"ERROR\", \"WARNING\"])\nexport type SkeletonVariantsType = `${ValueOf<typeof SkeletonVariants>}`\n\nexport enum SkeletonShapes {\n\tCIRCLE = 'circle',\n\tREACT = 'rect',\n\tTEXT = 'text'\n}\nexport type SkeletonShapesType = `${ValueOf<typeof SkeletonShapes>}`\n\nexport enum SkeletonAnimation {\n\tPULSE = 'pulse',\n\tPROGRESS = 'progress',\n\tFALSE = 'false'\n}\nexport type SkeletonAnimationType = `${ValueOf<typeof SkeletonAnimation>}`\n\nexport const SkeletonClass = {\n\troot: 'gov-skeleton',\n\tloader: 'gov-skeleton__loader',\n}\n","$class: \".gov-skeleton\";\n\n#{$class} {\n\t&__loader {\n\t\tposition: relative;\n\t\tdisplay: inline-block;\n\t\twidth: $skeleton-width;\n\t\theight: $skeleton-height;\n\t\tmargin-bottom: $skeleton-margin-bottom;\n\t\tborder-radius: $skeleton-border-radius;\n\t\toutline: none;\n\t\toverflow: hidden;\n\t\tbox-sizing: border-box;\n\t\twill-change: transform;\n\n\t\t&.circle {\n\t\t\twidth: $skeleton-circle-size;\n\t\t\theight: $skeleton-circle-size;\n\t\t\tmargin-bottom: $skeleton-margin-bottom;\n\t\t\tborder-radius: $skeleton-circle-radius;\n\t\t}\n\n\t\t&.rect {\n\t\t\tborder-radius: $skeleton-rect-radius;\n\t\t}\n\n\t\t&.progress {\n\t\t\tbackground-size: 200px 100%;\n\t\t\tanimation: progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n\t\t}\n\n\t\t&.pulse {\n\t\t\tanimation: pulse 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n\t\t\tanimation-delay: 0.5s;\n\t\t}\n\n\t\t@media (prefers-reduced-motion: reduce) {\n\t\t\t&.pulse,\n\t\t\t&.progress {\n\t\t\t\tbackground-image: none;\n\t\t\t\tanimation: none;\n\t\t\t}\n\t\t}\n\t}\n\n\t@each $variant, $definitions in $skeleton-variants {\n\t\t&[variant=\"#{$variant}\"] {\n\t\t\t#{$class}__loader {\n\t\t\t\tbackground-color: get(\"background\", $definitions);\n\t\t\t\tbackground-repeat: no-repeat;\n\n\t\t\t\t&.progress {\n\t\t\t\t\tbackground-image: linear-gradient(90deg, get(\"background\", $definitions), get(\"foreground\", $definitions), get(\"background\", $definitions));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, h, Host, Method, Prop, Watch } from \"@stencil/core\"\nimport {\n\tSkeletonAnimation,\n\tSkeletonAnimationType,\n\tSkeletonClass, SkeletonShapes,\n\tSkeletonShapesType, SkeletonVariants,\n\tSkeletonVariantsType,\n} from \"./constants\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govHost } from \"../../../helpers/Dom/template\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { validateWcagLabel } from \"../../../helpers/Validate/wcag\"\n\n@Component({\n\ttag: \"gov-skeleton\",\n\tstyleUrl: \"gov-skeleton.scss\",\n})\nexport class GovSkeleton {\n\th: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovSkeletonElement\n\t/**\n\t * Style variation of the skeleton.\n\t */\n\t@Prop() readonly variant?: SkeletonVariantsType = \"secondary\"\n\t/**\n\t * Number of rows of current skeleton type\n\t */\n\t@Prop() count = 1\n\t/**\n\t * Shape of the skeleton\n\t */\n\t@Prop() shape?: SkeletonShapesType = \"text\"\n\t/**\n\t * Width of the skeleton ex. 100px, 100%, auto etc.\n\t */\n\t@Prop() width: string = null\n\t/**\n\t * Height of the skeleton ex. 100px, 100%, auto etc.\n\t */\n\t@Prop() height: string = null\n\t/**\n\t * Animation type\n\t */\n\t@Prop() animation?: SkeletonAnimationType = \"progress\"\n\t/**\n\t * Adds accessible label for the skeleton that is only shown for screen readers.\n\t */\n\t@Prop({ attribute: 'wcag-label' }) readonly wcagLabel: string\n\n\titems: number[] = []\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(SkeletonVariants, newValue, SkeletonClass.root)\n\t}\n\n\t@Watch('shape')\n\tvalidateShape(newValue: string): void {\n\t\tvalidateProp(SkeletonShapes, newValue, SkeletonClass.root)\n\t}\n\n\t@Watch('animation')\n\tvalidateAnimation(newValue: string): void {\n\t\tvalidateProp(SkeletonAnimation, newValue, SkeletonClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateShape(this.shape)\n\t\tthis.validateAnimation(this.animation)\n\t\tthis.init()\n\t}\n\n\tcomponentWillUpdate() {\n\t\tthis.init()\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\tinit() {\n\t\tthis.items.length = this.count\n\t\tthis.items.fill(1)\n\t}\n\n\tget style() {\n\t\tconst dimenssionsStyles: {\n\t\t\twidth?: string,\n\t\t\theight?: string,\n\t\t} = {\n\t\t\twidth: null,\n\t\t\theight: null,\n\t\t}\n\t\tif (this.width) {\n\t\t\tdimenssionsStyles.width = this.width\n\t\t}\n\n\t\tif (this.height) {\n\t\t\tdimenssionsStyles.height = this.height\n\t\t}\n\n\t\treturn { ...dimenssionsStyles }\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes(SkeletonClass.root)} variant={this.variant}>\n\t\t\t\t{this.items.map((_, index) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t\tclass={{\n\t\t\t\t\t\t\t\tcircle: this.shape === \"circle\",\n\t\t\t\t\t\t\t\trect: this.shape === \"rect\",\n\t\t\t\t\t\t\t\tprogress: this.animation === \"progress\",\n\t\t\t\t\t\t\t\tpulse: this.animation === \"pulse\",\n\t\t\t\t\t\t\t\t[SkeletonClass.loader]: true,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taria-busy=\"true\"\n\t\t\t\t\t\t\taria-valuemin=\"0\"\n\t\t\t\t\t\t\taria-valuemax=\"100\"\n\t\t\t\t\t\t\taria-valuetext={this.wcagLabel}\n\t\t\t\t\t\t\trole=\"progressbar\"\n\t\t\t\t\t\t\ttabindex=\"0\"\n\t\t\t\t\t\t\tstyle={this.style}\n\t\t\t\t\t\t></span>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagLabel(this.wcagLabel, undefined, SkeletonClass.root)\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{r as o,c as i,h as r,H as t,g as e}from"./p-4af5e4f4.js";import{c as s}from"./p-24636c53.js";import{v as a}from"./p-26acf964.js";import{g as c,e as g,f as h}from"./p-9cd80b05.js";import{g as v,t as m}from"./p-3f37ddb6.js";import{b as f,c as l}from"./p-670b4f93.js";import{c as n}from"./p-c20102ff.js";import{d}from"./p-03990da5.js";import{F as w}from"./p-1c1d0bbe.js";import"./p-561fa17b.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-ef79904e.js";import"./p-6278531b.js";import"./p-f687452c.js";import"./p-3464136c.js";const p='.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:absolute;top:0;left:0;z-index:1;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.gov-form-switch .gov-form-label__label{position:relative;z-index:1;margin-bottom:0;color:var(--gov-form-switch-color, var(--gov-color-secondary-800))}.gov-form-switch__indicator{position:relative;flex:0 0 auto;border:var(--gov-form-switch-indicator-border, 0.0625rem solid var(--gov-color-secondary-500));background-color:var(--gov-form-switch-indicator-bg, var(--gov-color-secondary-300));transition:150ms linear background-color}.gov-form-switch__indicator::before{content:"";position:absolute;display:block;border-radius:50%;background-color:var(--gov-form-switch-indicator-circle-bg, var(--gov-color-neutral-white));transition:150ms linear left;box-shadow:var(--gov-form-switch-indicator-circle-box-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.35))}.gov-form-switch__input:focus-visible~.gov-form-switch__indicator{outline:var(--gov-outline-width, 0.125rem) solid var(--gov-color-focus-base)}.gov-form-switch__input:checked+.gov-form-switch__indicator{border-color:var(--gov-form-switch-indicator-bg-checked, var(--gov-color-primary));background-color:var(--gov-form-switch-indicator-bg-checked, var(--gov-color-primary))}.gov-form-switch[disabled=""],.gov-form-switch[disabled=true i],.gov-form-switch[disabled="1"]{pointer-events:none}.gov-form-switch[disabled=""] .gov-form-label__label,.gov-form-switch[disabled=true i] .gov-form-label__label,.gov-form-switch[disabled="1"] .gov-form-label__label{color:var(--gov-form-state-color-disabled, var(--gov-color-secondary-600))}.gov-form-switch[disabled=""] .gov-form-switch__indicator::before,.gov-form-switch[disabled=true i] .gov-form-switch__indicator::before,.gov-form-switch[disabled="1"] .gov-form-switch__indicator::before{background:var(--gov-form-input-disabled-bg, var(--gov-color-secondary-300))}.gov-form-switch[disabled=""] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[disabled=true i] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[disabled="1"] .gov-form-switch__input:checked+.gov-form-switch__indicator{border-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400));background-color:var(--gov-form-input-disabled-bg, var(--gov-color-primary-400))}.gov-form-switch[invalid=""] .gov-form-label__label,.gov-form-switch[invalid=true i] .gov-form-label__label,.gov-form-switch[invalid="1"] .gov-form-label__label{color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[invalid=""] .gov-form-switch__indicator,.gov-form-switch[invalid=true i] .gov-form-switch__indicator,.gov-form-switch[invalid="1"] .gov-form-switch__indicator{border-color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[invalid=""] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[invalid=true i] .gov-form-switch__input:checked+.gov-form-switch__indicator,.gov-form-switch[invalid="1"] .gov-form-switch__input:checked+.gov-form-switch__indicator{background-color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-switch[size=xs] .gov-form-label__label{font-weight:var(--gov-text-xs-font-weight);font-size:var(--gov-text-xs-font-size);line-height:var(--gov-text-xs-line-height);letter-spacing:var(--gov-text-xs-letter-spacing);margin-bottom:0;margin-left:calc((var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 + var(--gov-form-switch-xs-gap, 0.75rem)) * -1);padding-top:calc((var(--gov-form-switch-xs-indicator-height, 1.25rem) - var(--gov-text-xs-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 + var(--gov-form-switch-xs-gap, 0.75rem))}.gov-form-switch[size=xs] .gov-form-switch__holder{gap:var(--gov-form-switch-xs-gap, 0.75rem)}.gov-form-switch[size=xs] .gov-form-switch__indicator{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=s] .gov-form-label__label{font-weight:var(--gov-text-s-font-weight);font-size:var(--gov-text-s-font-size);line-height:var(--gov-text-s-line-height);letter-spacing:var(--gov-text-s-letter-spacing);margin-bottom:0;margin-left:calc((var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 + var(--gov-form-switch-s-gap, 0.75rem)) * -1);padding-top:calc((var(--gov-form-switch-s-indicator-height, 1.375rem) - var(--gov-text-s-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 + var(--gov-form-switch-s-gap, 0.75rem))}.gov-form-switch[size=s] .gov-form-switch__holder{gap:var(--gov-form-switch-s-gap, 0.75rem)}.gov-form-switch[size=s] .gov-form-switch__indicator{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=m] .gov-form-label__label{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);margin-bottom:0;margin-left:calc((var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 + var(--gov-form-switch-m-gap, 1rem)) * -1);padding-top:calc((var(--gov-form-switch-m-indicator-height, 1.5rem) - var(--gov-text-m-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 + var(--gov-form-switch-m-gap, 1rem))}.gov-form-switch[size=m] .gov-form-switch__holder{gap:var(--gov-form-switch-m-gap, 1rem)}.gov-form-switch[size=m] .gov-form-switch__indicator{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=l] .gov-form-label__label{font-weight:var(--gov-text-l-font-weight);font-size:var(--gov-text-l-font-size);line-height:var(--gov-text-l-line-height);letter-spacing:var(--gov-text-l-letter-spacing);margin-bottom:0;margin-left:calc((var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 + var(--gov-form-switch-l-gap, 1rem)) * -1);padding-top:calc((var(--gov-form-switch-l-indicator-height, 2rem) - var(--gov-text-l-font-size) * 1.5) / 2);padding-left:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 + var(--gov-form-switch-l-gap, 1rem))}.gov-form-switch[size=l] .gov-form-switch__holder{gap:var(--gov-form-switch-l-gap, 1rem)}.gov-form-switch[size=l] .gov-form-switch__indicator{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)}';const b=class{constructor(r){o(this,r);this.govFocus=i(this,"gov-focus",7);this.govBlur=i(this,"gov-blur",7);this.govChange=i(this,"gov-change",7);this.value=undefined;this.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=c(this.h)}validateSize(o){a(h,o,g.root)}componentWillLoad(){this.f.passAttrToControl("type","switch")}async componentDidRender(){this.f.passAttrToLabel("identifier",this.identifier||this.checkboxId);this.f.passAttrToLabel("required",String(this.required));if(n()){await d(500);await this.validateWcag()}}render(){const o=o=>{if(this.noLabel){return r("label",null,o)}return o};return r(t,{class:this.h.classes(g.root),checked:this.checked,size:this.size,invalid:m(this.invalid)},r("div",{class:g.holder},o(r(w,null,r("input",{class:g.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":m(this.required),"aria-invalid":m(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":m(this.disabled)}),r("span",{class:g.indicator}),r("slot",{name:"label"})))))}onClickHandler(o){o.stopPropagation()}onFocusHandler(o){o.stopPropagation();this.govFocus.emit({component:g.root,checked:this.checked,value:this.value,originalEvent:o})}onBlurHandler(o){o.stopPropagation();this.govBlur.emit({component:g.root,checked:this.checked,value:this.value,originalEvent:o})}onChangeHandler(o){this.checked=o.target.checked;o.stopPropagation();this.govChange.emit({component:g.root,checked:this.checked,value:this.value,originalEvent:o})}async getRef(){return this.inputRef}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",g.root);f(this.wcagLabelledBy,"wcag-labelled-by",g.root);l(this.identifier||this.checkboxId,this.wcagLabelledBy,g.root)}get host(){return e(this)}static get watchers(){return{size:["validateSize"]}}};b.style=p;export{b as gov_form_switch};
2
- //# sourceMappingURL=p-3cd5b6cb.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/switch/gov-form-switch.scss?tag=gov-form-switch","../../../packages/core/src/components/gov-form/switch/gov-form-switch.tsx"],"names":["govFormSwitchCss","GovFormSwitch","[object Object]","hostRef","this","checkboxId","createID","h","govHost","host","f","govForm","newValue","validateProp","FormSwitchSizes","FormSwitchClass","root","passAttrToControl","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","wrapCheckbox","children","noLabel","Host","class","classes","checked","size","invalid","toBoolAttrIfDefined","holder","Fragment","input","id","type","value","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","ref","el","inputRef","aria-checked","aria-required","aria-invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-disabled","disabled","indicator","e","stopPropagation","govFocus","emit","component","originalEvent","govBlur","target","govChange","validateWcagRef","validateWcagLabelFor"],"mappings":"+hBAAA,MAAMA,EAAmB,ksUCmBZC,EAAa,MAOzBC,YAAAC,2JAe6D,mBAIX,oBAKb,4DAaS,kHApC7CC,KAAKC,WAAaC,EAAS,eAE3BF,KAAKG,EAAIC,EAAQJ,KAAKK,MACtBL,KAAKM,EAAIC,EAAQP,KAAKG,GAgEvBL,aAAaU,GACZC,EAAaC,EAAiBF,EAAUG,EAAgBC,MAGzDd,oBACCE,KAAKM,EAAEO,kBAAkB,OAAQ,UAGlCf,2BACCE,KAAKM,EAAEQ,gBAAgB,aAAcd,KAAKe,YAAcf,KAAKC,YAC7DD,KAAKM,EAAEQ,gBAAgB,WAAYE,OAAOhB,KAAKiB,WAC/C,GAAIC,IAA2B,OACxBC,EAAM,WACNnB,KAAKoB,gBAIbtB,SACC,MAAMuB,EAAgBC,IACrB,GAAItB,KAAKuB,QAAS,CACjB,OACCpB,EAAA,QAAA,KACEmB,GAIJ,OAAOA,GAGR,OACCnB,EAACqB,EAAI,CAACC,MAAOzB,KAAKG,EAAEuB,QAAQf,EAAgBC,MAAOe,QAAS3B,KAAK2B,QAASC,KAAM5B,KAAK4B,KAAMC,QAASC,EAAoB9B,KAAK6B,UAC5H1B,EAAA,MAAA,CAAKsB,MAAOd,EAAgBoB,QAC1BV,EACAlB,EAAC6B,EAAQ,KACR7B,EAAA,QAAA,CACCsB,MAAOd,EAAgBsB,MACvBC,GAAIlC,KAAKe,YAAcf,KAAKC,WAC5BkC,KAAK,WACLC,MAAOpC,KAAKoC,MACZC,KAAMrC,KAAKqC,KACXV,QAAS3B,KAAK2B,QACdW,QAAStC,KAAKuC,eAAeC,KAAKxC,MAClCyC,SAAUzC,KAAK0C,gBAAgBF,KAAKxC,MACpC2C,QAA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tposition: relative;\n\tdisplay: flex;\n\t&__holder {\n\t\tdisplay: inline-flex;\n\t}\n\t&__input {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tz-index: 1;\n\t\tmargin: 0;\n\t\tappearance: none;\n\t}\n\t.gov-form-label__label {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tmargin-bottom: 0;\n\t\tcolor: $form-switch-color;\n\t}\n\t&__indicator {\n\t\tposition: relative;\n\t\tflex: 0 0 auto;\n\t\tborder: $form-switch-indicator-border;\n\t\tbackground-color: $form-switch-indicator-bg;\n\t\ttransition: $t linear background-color;\n\t\t&::before {\n\t\t\t@include pseudo();\n\t\t\tborder-radius: 50%;\n\t\t\tbackground-color: $form-switch-indicator-circle-bg;\n\t\t\ttransition: $t linear left;\n\t\t\tbox-shadow: $form-switch-indicator-circle-box-shadow;\n\t\t}\n\t}\n\n\t// STATES\n\t// focus\n\t&__input:focus-visible ~ &__indicator {\n\t\toutline: $outline;\n\t}\n\t// checked\n\t&__input:checked + &__indicator {\n\t\tborder-color: $form-switch-indicator-bg-checked;\n\t\tbackground-color: $form-switch-indicator-bg-checked;\n\t}\n\n\t// disabled\n\t@include parameter(\"disabled\") {\n\t\tpointer-events: none;\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-disabled;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\t&::before {\n\t\t\t\t\tbackground: $form-state-bg-input-disabled;\n\t\t\t\t}\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t\t}\n\t\t}\n\t}\n\n\t// invalid\n\t@include parameter(\"invalid\") {\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-error;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\tborder-color: $form-state-color-error;\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tbackground-color: $form-state-color-error;\n\t\t\t}\n\t\t}\n\t}\n\n\t// sizes\n\t@each $size, $definitions in $form-switch-sizes {\n\t\t$indicator-width: calc(get(\"indicator-height\", $definitions) * $indicator-ratio);\n\t\t$indicator-height: get(\"indicator-height\", $definitions);\n\t\t$border-offset: calc(get(\"toggle-offset\", $definitions) - rem-calc(1));\n\n\t\t&[size=\"#{$size}\"] {\n\t\t\t.gov-form-label__label {\n\t\t\t\t@include typography($size);\n\t\t\t\tmargin-bottom: 0;\n\t\t\t\tmargin-left: calc(($indicator-width + get(\"gap\", $definitions)) * -1);\n\t\t\t\tpadding-top: calc(($indicator-height - (var(--gov-text-#{$size}-font-size) * 1.5)) / 2);\n\t\t\t\tpadding-left: calc($indicator-width + get(\"gap\", $definitions));\n\t\t\t}\n\t\t\t#{$class} {\n\t\t\t\t&__holder {\n\t\t\t\t\tgap: get(\"gap\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__indicator {\n\t\t\t\t\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}\n\t}\n}\n","import { Component, Host, h, Prop, Event, EventEmitter, Element, Watch, Method } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormSwitchClass, FormSwitchSizes, FormSwitchSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport 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\tcomponentWillLoad() {\n\t\tthis.f.passAttrToControl(\"type\", \"switch\")\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"]}
@@ -1,2 +0,0 @@
1
- import{r as o,c as i,h as e,H as a,g as r}from"./p-4af5e4f4.js";import{a as t}from"./p-561fa17b.js";import{v as n}from"./p-26acf964.js";import{A as c,a as d,b as s,c as g}from"./p-a5d69694.js";import{c as v}from"./p-24636c53.js";import{g as m,b as l,t as h}from"./p-3f37ddb6.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-03990da5.js";const p='.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-accordion-item{position:relative;display:block;width:100%}.gov-accordion-item__header{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;position:relative;display:flex;justify-content:space-between;align-items:center;width:100%;border-radius:0;text-align:left;text-transform:none;transition:background-color 150ms ease-in-out}.gov-accordion-item__header:focus{outline:none}.gov-accordion-item__header:focus{outline:none}.gov-accordion-item__header: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-accordion-item__header::before{content:"";position:absolute;display:block;right:0;bottom:-1px;left:0;height:1px}.gov-accordion-item__header:focus-visible::before{display:none}.gov-accordion-item__header[aria-expanded=""] .gov-accordion-item__arrow,.gov-accordion-item__header[aria-expanded=true i] .gov-accordion-item__arrow,.gov-accordion-item__header[aria-expanded="1"] .gov-accordion-item__arrow{transform:scale(-1)}.gov-accordion-item__arrow{flex:0 0 auto;align-self:center}.gov-accordion-item__icon{display:inline-flex;vertical-align:middle;flex:0 0 auto}.gov-accordion-item__suffix{display:inline-flex;vertical-align:middle;flex:0 0 auto;align-self:start;margin-left:auto;line-height:initial}.gov-accordion-item__title{margin:0;padding:0;font-family:var(--gov-font-family, "Roboto", sans-serif);font-weight:400;box-sizing:border-box;display:flex;flex:1 1 auto;align-items:flex-start}.gov-accordion-item__name{display:flex;flex-direction:column}.gov-accordion-item__annot{color:var(--gov-color-secondary)}.gov-accordion-item__content>*:last-child{margin-bottom:0}.gov-accordion-item[size=xs] .gov-accordion-item__header{gap:var(--gov-accordion-s-headline-gap, 0.5rem);min-height:var(--gov-accordion-s-min-height, 3rem);padding:var(--gov-accordion-s-padding-y, 0.75rem) var(--gov-accordion-s-padding-x, 0.5rem)}.gov-accordion-item[size=xs] .gov-accordion-item__arrow{width:var(--gov-accordion-s-icon-size, 0.75rem);height:var(--gov-accordion-s-icon-size, 0.75rem)}.gov-accordion-item[size=xs] .gov-accordion-item__icon{width:calc(var(--gov-text-m-font-size) * 1.2);height:calc(var(--gov-text-m-font-size) * 1.2);transform:translateY(var(--gov-accordion-s-icon-position, 0.0625rem))}.gov-accordion-item[size=xs] .gov-accordion-item__title{font-weight:var(--gov-text-m-font-weight);font-size:var(--gov-text-m-font-size);line-height:var(--gov-text-m-line-height);letter-spacing:var(--gov-text-m-letter-spacing);gap:var(--gov-accordion-s-headline-gap, 0.5rem)}.gov-accordion-item[size=xs] .gov-accordion-item__annot{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)}.gov-accordion-item[size=xs] .gov-accordion-item__content{padding:var(--gov-accordion-s-padding-inner, 1rem 0.5rem)}.gov-accordion-item[size=s] .gov-accordion-item__header{gap:var(--gov-accordion-s-headline-gap, 0.5rem);min-height:var(--gov-accordion-s-min-height, 3rem);padding:var(--gov-accordion-s-padding-y, 1.125rem) var(--gov-accordion-s-padding-x, 0.5rem)}.gov-accordion-item[size=s] .gov-accordion-item__arrow{width:var(--gov-accordion-s-icon-size, 0.75rem);height:var(--gov-accordion-s-icon-size, 0.75rem)}.gov-accordion-item[size=s] .gov-accordion-item__icon{width:calc(var(--gov-text-xl-font-size) * 1.2);height:calc(var(--gov-text-xl-font-size) * 1.2);transform:translateY(var(--gov-accordion-s-icon-position, 0.0625rem))}.gov-accordion-item[size=s] .gov-accordion-item__title{font-weight:var(--gov-text-xl-font-weight);font-size:var(--gov-text-xl-font-size);line-height:var(--gov-text-xl-line-height);letter-spacing:var(--gov-text-xl-letter-spacing);gap:var(--gov-accordion-s-headline-gap, 0.5rem)}.gov-accordion-item[size=s] .gov-accordion-item__annot{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)}.gov-accordion-item[size=s] .gov-accordion-item__content{padding:var(--gov-accordion-s-padding-inner, 1rem 0.5rem)}.gov-accordion-item[size=m] .gov-accordion-item__header{gap:var(--gov-accordion-m-headline-gap, 1rem);min-height:var(--gov-accordion-m-min-height, 4.5rem);padding:var(--gov-accordion-m-padding-y, 1.25rem) var(--gov-accordion-m-padding-x, 0.5rem)}.gov-accordion-item[size=m] .gov-accordion-item__arrow{width:var(--gov-accordion-m-icon-size, 1rem);height:var(--gov-accordion-m-icon-size, 1rem)}.gov-accordion-item[size=m] .gov-accordion-item__icon{width:calc(var(--gov-text-2xl-font-size) * 1.2);height:calc(var(--gov-text-2xl-font-size) * 1.2);transform:translateY(var(--gov-accordion-m-icon-position, 0.125rem))}.gov-accordion-item[size=m] .gov-accordion-item__title{font-weight:var(--gov-text-2xl-font-weight);font-size:var(--gov-text-2xl-font-size);line-height:var(--gov-text-2xl-line-height);letter-spacing:var(--gov-text-2xl-letter-spacing);gap:var(--gov-accordion-m-headline-gap, 1rem)}.gov-accordion-item[size=m] .gov-accordion-item__annot{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)}.gov-accordion-item[size=m] .gov-accordion-item__content{padding:var(--gov-accordion-m-padding-inner, 1.25rem 0.5rem)}.gov-accordion-item[size=l] .gov-accordion-item__header{gap:var(--gov-accordion-l-headline-gap, 1rem);min-height:var(--gov-accordion-l-min-height, 5.5rem);padding:var(--gov-accordion-l-padding-y, 1.375rem) var(--gov-accordion-l-padding-x, 0.5rem)}.gov-accordion-item[size=l] .gov-accordion-item__arrow{width:var(--gov-accordion-l-icon-size, 1.25rem);height:var(--gov-accordion-l-icon-size, 1.25rem)}.gov-accordion-item[size=l] .gov-accordion-item__icon{width:calc(var(--gov-text-3xl-font-size) * 1.2);height:calc(var(--gov-text-3xl-font-size) * 1.2);transform:translateY(var(--gov-accordion-l-icon-position, 0.125rem))}.gov-accordion-item[size=l] .gov-accordion-item__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);gap:var(--gov-accordion-l-headline-gap, 1rem)}.gov-accordion-item[size=l] .gov-accordion-item__annot{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)}.gov-accordion-item[size=l] .gov-accordion-item__content{padding:var(--gov-accordion-l-padding-inner, 1.25rem 0.5rem)}.gov-accordion-item[variant=primary] .gov-accordion-item__header{background-color:var(--gov-accordion-primary-background, transparent);color:var(--gov-accordion-primary-color, var(--gov-color-primary))}.gov-accordion-item[variant=primary] .gov-accordion-item__header::before{background-color:var(--gov-accordion-primary-separator, var(--gov-color-secondary-500))}@media not all and (pointer: coarse){.gov-accordion-item[variant=primary] .gov-accordion-item__header:hover{background-color:var(--gov-accordion-primary-background-hover, var(--gov-color-primary-200))}}.gov-accordion-item[variant=primary][disabled=""] .gov-accordion-item__header,.gov-accordion-item[variant=primary][disabled=true i] .gov-accordion-item__header,.gov-accordion-item[variant=primary][disabled="1"] .gov-accordion-item__header{color:var(--gov-accordion-primary-disabled-color, var(--gov-color-primary-400))}@media not all and (pointer: coarse){.gov-accordion-item[variant=primary][disabled=""] .gov-accordion-item__header:hover,.gov-accordion-item[variant=primary][disabled=true i] .gov-accordion-item__header:hover,.gov-accordion-item[variant=primary][disabled="1"] .gov-accordion-item__header:hover{background:transparent;cursor:not-allowed}}.gov-accordion-item[variant=secondary] .gov-accordion-item__header{background-color:var(--gov-accordion-secondary-background, transparent);color:var(--gov-accordion-secondary-color, var(--gov-color-secondary))}.gov-accordion-item[variant=secondary] .gov-accordion-item__header::before{background-color:var(--gov-accordion-secondary-separator, var(--gov-color-secondary-500))}@media not all and (pointer: coarse){.gov-accordion-item[variant=secondary] .gov-accordion-item__header:hover{background-color:var(--gov-accordion-secondary-background-hover, var(--gov-color-secondary-200))}}.gov-accordion-item[variant=secondary][disabled=""] .gov-accordion-item__header,.gov-accordion-item[variant=secondary][disabled=true i] .gov-accordion-item__header,.gov-accordion-item[variant=secondary][disabled="1"] .gov-accordion-item__header{color:var(--gov-accordion-secondary-disabled-color, var(--gov-color-secondary-600))}@media not all and (pointer: coarse){.gov-accordion-item[variant=secondary][disabled=""] .gov-accordion-item__header:hover,.gov-accordion-item[variant=secondary][disabled=true i] .gov-accordion-item__header:hover,.gov-accordion-item[variant=secondary][disabled="1"] .gov-accordion-item__header:hover{background:transparent;cursor:not-allowed}}@media (max-width: 47.99em){.gov-accordion-item__title{flex-wrap:wrap}.gov-accordion-item__label{flex:0 0 auto}}';const _=class{constructor(e){o(this,e);this.govChange=i(this,"gov-change",7);this.isExpandedState=undefined;this.variant="primary";this.identifier=undefined;this.size=undefined;this.label=undefined;this.annotation=undefined;this.disabled=false;this.isExpanded=false;this.triggerTag="h3";this.noBorder=false;this.h=m(this.host);this.triggerId=v("GovAccordionItem");this.contentId=v("GovAccordionContent")}validateLabel(o){if(!o){t(`[${c.root}]: Parameter label is required.`)}}validateTriggerTag(o){const i=["h1","h2","h3","h4","h5","h6","span"];if(o){if(!i.includes(o)){t(`[${c.root}]: Tag ${o} is not allowed.`)}}}validateSize(o){n(s,o,c.root)}validateVariant(o){n(g,o,c.root)}emmitChange(){this.govChange.emit({open:this.isExpandedState,component:c.root,ref:this.host})}componentWillLoad(){this.isExpandedState=this.isExpanded;this.getPropsFromParents();this.validateLabel(this.label);this.validateTriggerTag(this.triggerTag);this.validateSize(this.size);this.validateVariant(this.variant)}getPropsFromParents(){const o=this.h.getParent(d.root);if(o){this.size=o.getAttribute("size");this.variant=o.getAttribute("variant")}}render(){const o=this.identifier||this.triggerId;const i=this.contentId;const{isExpandedState:r,label:t}=this;const n=this.triggerTag;return e(a,{class:this.h.classes(c.root),"no-border":this.noBorder,size:this.size,variant:this.variant,role:"listitem"},e("button",{id:o,class:c.header,"aria-expanded":l(r),"aria-controls":i,disabled:this.disabled,"aria-disabled":h(this.disabled),onClick:o=>{o.stopPropagation();this.toggle().finally()}},e(n,{class:c.title},this.h.hasSlot("icon")&&e("span",{class:c.icon},e("slot",{name:"icon"})),e("span",{class:c.name},e("span",{class:c.label},t),this.annotation&&e("span",{class:c.annot},this.annotation)),this.h.hasSlot("suffix")&&e("span",{class:c.suffix},e("slot",{name:"suffix"}))),e("gov-icon",{class:c.arrow,name:"chevron-down"})),e("div",{class:c.content,id:i,"aria-hidden":l(!r),hidden:!r,"aria-labelledby":o},e("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 r(this)}static get watchers(){return{label:["validateLabel"],triggerTag:["validateTriggerTag"],size:["validateSize"],variant:["validateVariant"]}}};_.style=p;export{_ as gov_accordion_item};
2
- //# sourceMappingURL=p-5176fad8.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-accordion/gov-accordion-item.scss?tag=gov-accordion-item","../../../packages/core/src/components/gov-accordion/gov-accordion-item.tsx"],"names":["govAccordionItemCss","GovAccordionItem","[object Object]","hostRef","this","h","govHost","host","triggerId","createID","contentId","newValue","govErrorLog","AccordionItemClass","root","validTags","includes","validateProp","AccordionSizes","AccordionVariants","govChange","emit","open","isExpandedState","component","ref","isExpanded","getPropsFromParents","validateLabel","label","validateTriggerTag","triggerTag","validateSize","size","validateVariant","variant","accordion","getParent","AccordionClass","getAttribute","identifier","TriggerTag","Host","class","classes","no-border","noBorder","role","id","header","aria-expanded","booleanString","aria-controls","disabled","aria-disabled","toBoolAttrIfDefined","onClick","e","stopPropagation","toggle","finally","title","hasSlot","icon","name","annotation","annot","suffix","arrow","content","aria-hidden","hidden","aria-labelledby","emmitChange"],"mappings":"+VAAA,MAAMA,EAAsB,yhTCoBfC,EAAgB,MAK5BC,YAAAC,+FAYwD,qHAqBnB,sBAI8B,sBAID,mBAIH,MA5C9DC,KAAKC,EAAIC,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,EACJmC,MAAO9B,EAAmBoC,OAAMC,gBACjBC,EAAc5B,GAAgB6B,gBAC9B1C,EACf2C,SAAUjD,KAAKiD,SAAQC,gBACRC,EAAoBnD,KAAKiD,UACxCG,QAAUC,IACTA,EAAEC,kBACFtD,KAAKuD,SAASC,YAEfvD,EAACoC,EAAU,CAACE,MAAO9B,EAAmBgD,OACpCzD,KAAKC,EAAEyD,QAAQ,SACfzD,EAAA,OAAA,CAAMsC,MAAO9B,EAAmBkD,MAC/B1D,EAAA,OAAA,CAAM2D,KAAK,UAIb3D,EAAA,OAAA,CAAMsC,MAAO9B,EAAmBmD,MAC/B3D,EAAA,OAAA,CAAMsC,MAAO9B,EAAmBgB,OAAQA,GACvCzB,KAAK6D,YAAc5D,EAAA,OAAA,CAAMsC,MAAO9B,EAAmBqD,OAAQ9D,KAAK6D,aAGjE7D,KAAKC,EAAEyD,QAAQ,WACfzD,EAAA,OAAA,CAAMsC,MAAO9B,EAAmBsD,QAC/B9D,EAAA,OAAA,CAAM2D,KAAK,aAKd3D,EAAA,WAAA,CAAUsC,MAAO9B,EAAmBuD,MAAOJ,KAAK,kBAEjD3D,EAAA,MAAA,CACCsC,MAAO9B,EAAmBwD,QAC1BrB,GAAItC,EAAS4D,cACAnB,GAAe5B,GAC5BgD,QAAShD,EAAeiD,kBACPhE,GACjBH,EAAA,OAAA,QAUJH,aACCE,KAAKmB,gBAAkB,KACvBnB,KAAKqE,cAONvE,cACCE,KAAKmB,gBAAkB,MACvBnB,KAAKqE,cAONvE,eACCE,KAAKmB,iBAAmBnB,KAAKmB,gBAC7BnB,KAAKqE,cAONvE,qBACC,OAAOE,KAAKmB","sourcesContent":["/*\n * Accordion - Item\n */\n\n$class: \".gov-accordion-item\";\n\n#{$class} {\n\t@include base();\n\t&__header {\n\t\t@include button-core();\n\t\t@include focus-outline();\n\t\tposition: relative;\n\t\tdisplay: flex;\n\t\tjustify-content: space-between;\n\t\talign-items: center;\n\t\twidth: 100%;\n\t\tborder-radius: 0;\n\t\ttext-align: left;\n\t\ttext-transform: none;\n\t\ttransition: background-color $t ease-in-out;\n\t\t&::before {\n\t\t\t@include pseudo();\n\t\t\tright: 0;\n\t\t\tbottom: -1px;\n\t\t\tleft: 0;\n\t\t\theight: 1px;\n\t\t}\n\n\t\t// STATES\n\t\t&:focus-visible {\n\t\t\t&::before {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t}\n\t\t@include parameter(\"aria-expanded\") {\n\t\t\t#{$class} {\n\t\t\t\t&__arrow {\n\t\t\t\t\ttransform: scale(-1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t&__arrow {\n\t\tflex: 0 0 auto;\n\t\talign-self: center;\n\t}\n\t&__icon {\n\t\tdisplay: inline-flex;\n\t\tvertical-align: middle;\n\t\tflex: 0 0 auto;\n\t}\n\t&__suffix {\n\t\tdisplay: inline-flex;\n\t\tvertical-align: middle;\n\t\tflex: 0 0 auto;\n\t\talign-self: start;\n\t\tmargin-left: auto;\n\t\tline-height: initial;\n\t}\n\t&__title {\n\t\t@include general;\n\t\tdisplay: flex;\n\t\tflex: 1 1 auto;\n\t\talign-items: flex-start;\n\t}\n\t&__name {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t}\n\t&__annot {\n\t\tcolor: color(\"secondary\");\n\t}\n\t&__content {\n\t\t@include reset-last-margin();\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $accordion-sizes {\n\t\t&[size=\"#{$size}\"] {\n\t\t\t#{$class} {\n\t\t\t\t&__header {\n\t\t\t\t\tgap: get(\"headline-gap\", $definitions);\n\t\t\t\t\tmin-height: get(\"min-height\", $definitions);\n\t\t\t\t\tpadding: get(\"padding-y\", $definitions) get(\"padding-x\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__arrow {\n\t\t\t\t\twidth: get(\"icon-size\", $definitions);\n\t\t\t\t\theight: get(\"icon-size\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__icon {\n\t\t\t\t\twidth: calc(get-font-size(get(\"font\", $definitions)) * 1.2);\n\t\t\t\t\theight: calc(get-font-size(get(\"font\", $definitions)) * 1.2);\n\t\t\t\t\ttransform: translateY(get(\"icon-position\", $definitions));\n\t\t\t\t}\n\t\t\t\t&__title {\n\t\t\t\t\t@include typography(get(\"font\", $definitions));\n\t\t\t\t\tgap: get(\"headline-gap\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__annot {\n\t\t\t\t\t@include typography(get(\"font-annot\", $definitions));\n\t\t\t\t}\n\t\t\t\t&__content {\n\t\t\t\t\tpadding: get(\"padding-inner\", $definitions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t@each $variant, $definitions in $accordion-variants {\n\t\t&[variant=\"#{$variant}\"] {\n\t\t\t#{$class} {\n\t\t\t\t&__header {\n\t\t\t\t\tbackground-color: get(\"background\", $definitions);\n\t\t\t\t\tcolor: get(\"color\", $definitions);\n\t\t\t\t\t&::before {\n\t\t\t\t\t\tbackground-color: get(\"separator\", $definitions);\n\t\t\t\t\t}\n\t\t\t\t\t@include hover() {\n\t\t\t\t\t\tbackground-color: get(\"background-hover\", $definitions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// STATES\n\t\t\t@include parameter(\"disabled\") {\n\t\t\t\t#{$class} {\n\t\t\t\t\t&__header {\n\t\t\t\t\t\tcolor: get(\"disabled-color\", $definitions);\n\t\t\t\t\t\t@include hover() {\n\t\t\t\t\t\t\tbackground: transparent;\n\t\t\t\t\t\t\tcursor: not-allowed;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// MQ\n\t@include mq($until: md) {\n\t\t&__title {\n\t\t\tflex-wrap: wrap;\n\t\t}\n\t\t&__label {\n\t\t\tflex: 0 0 auto;\n\t\t\t// max-width: calc(100% - 50px);\n\t\t}\n\t}\n}\n","import { Component, Element, h, Prop, State, Watch, Host, Method, Event, EventEmitter } from \"@stencil/core\"\nimport { govErrorLog } from \"../../helpers/Log/gov.log\"\nimport { validateProp } from \"../../helpers/Validate/props\"\nimport {\n\tAccordionSizeType,\n\tAccordionSizes,\n\tAccordionItemClass,\n\tAccordionVariantType,\n\tAccordionVariants, AccordionClass,\n} from \"./constants\"\nimport { createID } from \"../../utils/string.utils\"\nimport { booleanString, toBoolAttrIfDefined } from \"../../helpers/Dom/template\"\nimport { AccordionItemEvent } from \"./gov-accordion.types\"\nimport { govHost } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\n\n@Component({\n\ttag: \"gov-accordion-item\",\n\tstyleUrl: \"gov-accordion-item.scss\",\n})\nexport class GovAccordionItem {\n\tprivate readonly triggerId: string\n\tprivate readonly contentId: string\n\tprivate h: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.triggerId = createID(\"GovAccordionItem\")\n\t\tthis.contentId = createID(\"GovAccordionContent\")\n\t}\n\n\t@Element() readonly host: HTMLGovAccordionItemElement\n\t@State() isExpandedState: boolean\n\n\t/**\n\t * Style variation of the button.\n\t */\n\t@Prop({mutable: true}) variant?: AccordionVariantType = \"primary\"\n\t/**\n\t * Custom accordion item identifier. Otherwise, it will be generated\n\t */\n\t@Prop() readonly identifier: string\n\t/**\n\t * Accordion’s size.\n\t */\n\t@Prop({mutable: true}) size?: AccordionSizeType\n\t/**\n\t * Item name of the accordion\n\t */\n\t@Prop() readonly label: string\n\t/**\n\t * Item annotation of the accordion\n\t */\n\t@Prop() readonly annotation: string\n\t/**\n\t * Makes the button component disabled.\n\t * This prevents users from being able to interact with the button, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean = false\n\t/**\n\t * Defines whether the accordion is open or closed by default\n\t */\n\t@Prop({ attribute: \"is-expanded\" }) readonly isExpanded: boolean = false\n\t/**\n\t * Used to change the HTML tag in the accordion trigger for correct semantic structure\n\t */\n\t@Prop({ attribute: \"trigger-tag\" }) readonly triggerTag: string = \"h3\"\n\t/**\n\t * To remove the main underline of an item\n\t */\n\t@Prop({ attribute: \"no-border\" }) readonly noBorder: boolean = false\n\t/**\n\t * Called when the accordion state changes\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<AccordionItemEvent>\n\n\t@Watch(\"label\")\n\tvalidateLabel(newValue: string): void {\n\t\tif (!newValue) {\n\t\t\tgovErrorLog(`[${AccordionItemClass.root}]: Parameter label is required.`)\n\t\t}\n\t}\n\n\t@Watch(\"triggerTag\")\n\tvalidateTriggerTag(newValue: string): void {\n\t\tconst validTags = [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"span\"]\n\t\tif (newValue) {\n\t\t\tif (!validTags.includes(newValue)) {\n\t\t\t\tgovErrorLog(`[${AccordionItemClass.root}]: Tag ${newValue} is not allowed.`)\n\t\t\t}\n\t\t}\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(AccordionSizes, newValue, AccordionItemClass.root)\n\t}\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(AccordionVariants, newValue, AccordionItemClass.root)\n\t}\n\n\tprivate emmitChange(): void {\n\t\tthis.govChange.emit({\n\t\t\topen: this.isExpandedState,\n\t\t\tcomponent: AccordionItemClass.root,\n\t\t\tref: this.host,\n\t\t})\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.isExpandedState = this.isExpanded\n\t\tthis.getPropsFromParents()\n\n\t\tthis.validateLabel(this.label)\n\t\tthis.validateTriggerTag(this.triggerTag)\n\t\tthis.validateSize(this.size)\n\t\tthis.validateVariant(this.variant)\n\n\t}\n\n\tgetPropsFromParents() {\n\t\tconst accordion = this.h.getParent(AccordionClass.root)\n\t\tif(accordion) {\n\t\t\tthis.size = accordion.getAttribute('size') as AccordionSizeType\n\t\t\tthis.variant = accordion.getAttribute('variant') as AccordionVariantType\n\t\t}\n\t}\n\n\trender() {\n\t\tconst triggerId = this.identifier || this.triggerId\n\t\tconst contentId = this.contentId\n\t\tconst { isExpandedState, label } = this\n\t\tconst TriggerTag = this.triggerTag\n\n\t\treturn (\n\t\t\t<Host class={this.h.classes(AccordionItemClass.root)} no-border={this.noBorder} size={this.size} variant={this.variant} role=\"listitem\">\n\t\t\t\t<button\n\t\t\t\t\tid={triggerId}\n\t\t\t\t\tclass={AccordionItemClass.header}\n\t\t\t\t\taria-expanded={booleanString(isExpandedState)}\n\t\t\t\t\taria-controls={contentId}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\tonClick={(e: Event) => {\n\t\t\t\t\t\te.stopPropagation()\n\t\t\t\t\t\tthis.toggle().finally()\n\t\t\t\t\t}}>\n\t\t\t\t\t<TriggerTag class={AccordionItemClass.title}>\n\t\t\t\t\t\t{this.h.hasSlot(\"icon\") && (\n\t\t\t\t\t\t\t<span class={AccordionItemClass.icon}>\n\t\t\t\t\t\t\t\t<slot name=\"icon\" />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t<span class={AccordionItemClass.name}>\n\t\t\t\t\t\t\t<span class={AccordionItemClass.label}>{label}</span>\n\t\t\t\t\t\t\t{this.annotation && <span class={AccordionItemClass.annot}>{this.annotation}</span>}\n\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t{this.h.hasSlot(\"suffix\") && (\n\t\t\t\t\t\t\t<span class={AccordionItemClass.suffix}>\n\t\t\t\t\t\t\t\t<slot name=\"suffix\" />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</TriggerTag>\n\n\t\t\t\t\t<gov-icon class={AccordionItemClass.arrow} name=\"chevron-down\"></gov-icon>\n\t\t\t\t</button>\n\t\t\t\t<div\n\t\t\t\t\tclass={AccordionItemClass.content}\n\t\t\t\t\tid={contentId}\n\t\t\t\t\taria-hidden={booleanString(!isExpandedState)}\n\t\t\t\t\thidden={!isExpandedState}\n\t\t\t\t\taria-labelledby={triggerId}>\n\t\t\t\t\t<slot />\n\t\t\t\t</div>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\t/**\n\t * Opening the accordion\n\t */\n\t@Method()\n\tasync open(): Promise<void> {\n\t\tthis.isExpandedState = true\n\t\tthis.emmitChange()\n\t}\n\n\t/**\n\t * Closing the accordion\n\t */\n\t@Method()\n\tasync close(): Promise<void> {\n\t\tthis.isExpandedState = false\n\t\tthis.emmitChange()\n\t}\n\n\t/**\n\t * Accordion switch\n\t */\n\t@Method()\n\tasync toggle(): Promise<void> {\n\t\tthis.isExpandedState = !this.isExpandedState\n\t\tthis.emmitChange()\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync currentState(): Promise<boolean> {\n\t\treturn this.isExpandedState\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-badge/constants.ts","../../../packages/core/src/components/gov-badge/gov-badge.scss?tag=gov-badge","../../../packages/core/src/components/gov-badge/gov-badge.tsx"],"names":["NativeType","BadgeClass","root","inner","hasRight","hasLeft","govBadgeCss","GovBadge","[object Object]","hostRef","this","h","govHost","host","newValue","validateProp","ButtonVariants","ButtonSizes","Type","validateVariant","variant","validateSize","size","validateType","type","Tag","href","A","tag","nativeType","BUTTON","undefined","Host","class","classes","hasSlot","disabled","inverse","hoverable","target","aria-label","wcagLabel","onClick","onClickHandler","bind","name","e","stopPropagation","govClick","emit"],"mappings":"0RAEA,IAAYA,GAAZ,SAAYA,GACXA,EAAA,KAAA,IACAA,EAAA,QAAA,OACAA,EAAA,UAAA,UAHD,CAAYA,IAAAA,EAAU,KAQf,MAAMC,EAAa,CACzBC,KAAM,YACNC,MAAO,mBACPC,SAAU,uBACVC,QAAS,uBCdV,MAAMC,EAAc,86zECkBPC,EAAQ,MAGpBC,YAAAC,8DASoC,oBAKC,0DAcI,cAIN,iBAIK,oBAIM,mCAvC7CC,KAAKC,EAAI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rC,eAAesC,GACtBA,EAAEC,kBACF,GAAIrC,KAAK0B,WAAa,OAAS1B,KAAKkB,MAAQ5B,EAAW8B,OAAQ,CAC9DpB,KAAKsC,SAASC,KAAKH","sourcesContent":["import { ValueOf } from '../../types/interfaces'\n\nexport enum NativeType {\n\tA = 'a',\n\tSPAN = 'span',\n\tBUTTON = 'button',\n}\n\nexport type NativeTypesType = `${ValueOf<typeof NativeType>}`\n\nexport const BadgeClass = {\n\troot: 'gov-badge',\n\tinner: 'gov-badge__inner',\n\thasRight: 'gov-badge--has-right',\n\thasLeft: 'gov-badge--has-left',\n}\n","/*\n * Badge\n */\n\n// Shared definitions - button & badge\n@import \"../gov-button/gov-button-core.scss\";\n\n.gov-badge {\n\t@extend %button-core;\n\ta .gov-icon {\n\t\tmargin: 0;\n\t}\n\t.element {\n\t\tpadding: rem-calc(4 10);\n\t\tfont-family: $font-family-primary;\n\t\tfont-weight: 400;\n\t\tletter-spacing: initial;\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $button-sizes {\n\t\t$radius: calc(#{get(\"min-height\", $definitions)} * 0.5);\n\t\t&[size=\"#{$size}\"] {\n\t\t\t.element {\n\t\t\t\tborder-radius: $radius;\n\t\t\t}\n\n\t\t\t// HOVERS\n\t\t\t&[hoverable] .element {\n\t\t\t\t@include focus-outline($radius, $outline-offset);\n\t\t\t}\n\t\t}\n\t}\n\t@each $variant, $types in $badge-inverse-variants {\n\t\t&[type=\"solid\"][variant=\"#{$variant}\"] {\n\t\t\t@include parameter(\"inverse\") {\n\t\t\t\t.element {\n\t\t\t\t\tborder-width: rem-calc(1);\n\t\t\t\t\tborder-color: deep-map-get($badge-inverse-variants, $variant, \"border-color\");\n\t\t\t\t\tbackground-color: deep-map-get($badge-inverse-variants, $variant, \"bg\");\n\t\t\t\t\tcolor: deep-map-get($badge-inverse-variants, $variant, \"color\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t&--has-right > .element {\n\t\tpadding-top: 0 !important;\n\t\tpadding-bottom: 0 !important;\n\t\tpadding-right: 0 !important;\n\t}\n\n\t&--has-left > .element {\n\t\tpadding-top: 0 !important;\n\t\tpadding-bottom: 0 !important;\n\t\tpadding-left: 0 !important;\n\t}\n}\n","import { Component, Element, h, Host, Prop, Watch, Event, EventEmitter } from \"@stencil/core\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { validateProp } from \"../../helpers/Validate/props\"\nimport { govHost } from \"../../helpers/Dom/template\"\nimport { BadgeClass, NativeTypesType, NativeType } from \"./constants\"\nimport {\n\tButtonSizesType,\n\tTypesType,\n\tType,\n\tButtonVariantType,\n\tButtonVariants,\n\tButtonSizes,\n} from \"../gov-button/constants\"\n\n@Component({\n\ttag: \"gov-badge\",\n\tstyleUrl: \"gov-badge.scss\",\n})\nexport class GovBadge {\n\tprivate h: GovHost\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovBadgeElement\n\n\t/**\n\t * Determide if component should have inversed colors to be used on dark background\n\t */\n\t@Prop() readonly inverse: boolean = false\n\t/**\n\t * Makes the badge component disabled.\n\t * This prevents users from being able to interact with the button, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean = false\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href\n\t */\n\t@Prop() readonly href: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target\n\t */\n\t@Prop() readonly target: string\n\t/**\n\t * Badge’s size.\n\t */\n\t@Prop() readonly size: ButtonSizesType = \"m\"\n\t/**\n\t * Badges's type\n\t */\n\t@Prop() readonly type: TypesType = \"solid\"\n\t/**\n\t * Used to change the HMTL tag in the badge\n\t */\n\t@Prop() readonly tag: NativeTypesType = \"span\"\n\t/**\n\t * Style variation of the badge.\n\t */\n\t@Prop() readonly variant: ButtonVariantType = \"primary\"\n\t/**\n\t * Adds accessible label for the button that is only shown for screen readers.\n\t * Typically, this label text replaces the visible text on the button for users who use assistive technology.\n\t */\n\t@Prop({ attribute: \"wcag-label\" }) readonly wcagLabel: string\n\t/**\n\t * Emitted when the button click.\n\t */\n\t@Event({ eventName: \"gov-click\" }) govClick: EventEmitter<PointerEvent>\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(ButtonVariants, newValue, BadgeClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(ButtonSizes, newValue, BadgeClass.root)\n\t}\n\n\t@Watch(\"type\")\n\tvalidateType(newValue: string): void {\n\t\tvalidateProp(Type, newValue, BadgeClass.root)\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t\tthis.validateType(this.type)\n\t}\n\n\trender() {\n\t\tconst Tag = this.href ? NativeType.A : this.tag\n\t\tconst nativeType = Tag == NativeType.BUTTON ? NativeType.BUTTON : undefined\n\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tclass={this.h.classes([\n\t\t\t\t\tBadgeClass.root,\n\t\t\t\t\tthis.h.hasSlot(\"right\") ? BadgeClass.hasRight : undefined,\n\t\t\t\t\tthis.h.hasSlot(\"left\") ? BadgeClass.hasLeft : undefined,\n\t\t\t\t])}\n\t\t\t\tdisabled={this.disabled}\n\t\t\t\thref={this.href}\n\t\t\t\tvariant={this.variant}\n\t\t\t\tsize={this.size}\n\t\t\t\ttype={this.type}\n\t\t\t\tinverse={this.inverse}\n\t\t\t\thoverable={Tag == NativeType.A || Tag == NativeType.BUTTON}\n\t\t\t>\n\t\t\t\t<Tag\n\t\t\t\t\tclass=\"element\"\n\t\t\t\t\thref={this.href}\n\t\t\t\t\ttarget={this.target}\n\t\t\t\t\taria-label={this.wcagLabel}\n\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\ttype={nativeType}>\n\t\t\t\t\t{this.h.hasSlot(\"left\") && <slot name=\"left\"></slot>}\n\t\t\t\t\t{this.h.hasSlot(\"left-icon\") && <slot name=\"left-icon\"></slot>}\n\t\t\t\t\t<slot />\n\t\t\t\t\t{this.h.hasSlot(\"right-icon\") && <slot name=\"right-icon\"></slot>}\n\t\t\t\t\t{this.h.hasSlot(\"right\") && <slot name=\"right\"></slot>}\n\t\t\t\t</Tag>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent): void {\n\t\te.stopPropagation()\n\t\tif (this.disabled === false && this.tag === NativeType.BUTTON) {\n\t\t\tthis.govClick.emit(e)\n\t\t}\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{r as t,h as o,H as i,g as s}from"./p-4af5e4f4.js";import{v as r}from"./p-26acf964.js";import{T as e,a,b as n,c as l,d as p}from"./p-404f469e.js";import{c as v}from"./p-24636c53.js";import{g as c}from"./p-3f37ddb6.js";import"./p-561fa17b.js";import"./p-ff7365ae.js";import"./p-55500e5a.js";import"./p-03990da5.js";const h='.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-tooltip{position:relative;display:inline;border-bottom:1px dashed currentcolor;color:var(--gov-color-primary);cursor:help}.gov-tooltip[icon=""],.gov-tooltip[icon=true i],.gov-tooltip[icon="1"]{display:inline-flex;width:1rem;height:1rem;border-bottom:0;color:inherit}.gov-tooltip[variant=secondary]{--gov-tooltip-content-bg-color:var(--gov-tooltip-secondary-bg-color, var(--gov-color-secondary));--gov-tooltip-content-text-color:var(--gov-tooltip-secondary-text-color, var(--gov-color-neutral-white))}.gov-tooltip[variant=secondary][inverse=""],.gov-tooltip[variant=secondary][inverse=true i],.gov-tooltip[variant=secondary][inverse="1"]{--gov-tooltip-content-bg-color:var(--gov-color-neutral-white);--gov-tooltip-content-text-color:var(--gov-tooltip-secondary-text-color-inverse, var(--gov-color-secondary))}.gov-tooltip[variant=primary]{--gov-tooltip-content-bg-color:var(--gov-tooltip-primary-bg-color, var(--gov-color-primary-300));--gov-tooltip-content-text-color:var(--gov-tooltip-primary-text-color, var(--gov-color-secondary))}.gov-tooltip[variant=primary][inverse=""],.gov-tooltip[variant=primary][inverse=true i],.gov-tooltip[variant=primary][inverse="1"]{--gov-tooltip-content-bg-color:var(--gov-color-neutral-white);--gov-tooltip-content-text-color:var(--gov-tooltip-primary-text-color-inverse, var(--gov-color-primary))}';const g=class{constructor(o){t(this,o);this.variant="primary";this.size="m";this.position="right";this.message=undefined;this.identifier=undefined;this.icon=undefined;this.h=c(this.host);this.tooltipId=v("GovTooltip")}validateVariant(t){r(l,t,n.root)}validateSize(t){r(p,t,n.root)}validatePosition(t){r(a,t,n.root)}componentWillLoad(){this.validateVariant(this.variant);this.validateSize(this.size);this.validatePosition(this.position);this.createContentWrapper();this.registerListeners()}createContentWrapper(){var t;const o=this.host.querySelector(e.root);if(o){this.content=o}else{this.content=document.createElement(e.root);this.content.innerHTML=this.message;this.host.appendChild(this.content)}this.content.setAttribute("id",(t=this.identifier)!==null&&t!==void 0?t:this.tooltipId)}registerListeners(){this.host.addEventListener("focus",(t=>{t.preventDefault();this.showTooltip()}));this.host.addEventListener("blur",(t=>{t.preventDefault();this.hideTooltip()}));this.host.addEventListener("mouseenter",(t=>{t.preventDefault();this.showTooltip()}));this.host.addEventListener("mouseleave",(t=>{t.preventDefault();this.hideTooltip()}))}verifyPositionSpace(){const t=12;const o=window.innerWidth;const i=this.host.getBoundingClientRect();const s=this.host.offsetWidth;const r={left:i.left+document.documentElement.scrollLeft,top:i.top+document.documentElement.scrollTop};const e=this.content.offsetWidth;if(this.position===a.LEFT){if(t+r.left<e){this.position=a.TOP;this.content.style.left="0px";this.content.style.width=window.innerWidth-r.left-t+"px";this.content.style.transform="none"}}else if(this.position===a.RIGHT){if(o-(r.left+s)<e){this.position=a.TOP;this.content.style.right="0px";this.content.style.left="auto";this.content.style.width=s+r.left+t+"px";this.content.style.transform="none"}}else{if(e/2>r.left){this.content.style.left="0px";this.content.style.width=window.innerWidth-r.left-t+"px";this.content.style.transform="none"}else if(e/2>o-(r.left+e)){this.content.style.right="0px";this.content.style.left="auto";this.content.style.width=s+r.left+t+"px";this.content.style.transform="none"}}}showTooltip(){if(this.content){this.verifyPositionSpace();this.content.setAttribute("is-visible","true")}}hideTooltip(){if(this.content){this.content.setAttribute("is-visible","false")}}render(){var t;return o(i,{class:this.h.classes(n.root),position:this.position,size:this.size,tabindex:0,"aria-describedby":(t=this.identifier)!==null&&t!==void 0?t:this.tooltipId,variant:this.variant},o("slot",null))}async show(){this.showTooltip()}async hide(){this.hideTooltip()}get host(){return s(this)}static get watchers(){return{variant:["validateVariant"],size:["validateSize"],position:["validatePosition"]}}};g.style=h;export{g as gov_tooltip};
2
- //# sourceMappingURL=p-8204070b.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-tooltip/gov-tooltip.scss?tag=gov-tooltip","../../../packages/core/src/components/gov-tooltip/gov-tooltip.tsx"],"names":["govTooltipCss","GovTooltip","[object Object]","hostRef","undefined","this","h","govHost","host","tooltipId","createID","newValue","validateProp","TooltipVariant","TooltipClass","root","TooltipSize","TooltipPosition","validateVariant","variant","validateSize","size","validatePosition","position","createContentWrapper","registerListeners","hasContentInside","querySelector","TooltipContentClass","content","document","createElement","innerHTML","message","appendChild","setAttribute","_a","identifier","addEventListener","e","preventDefault","showTooltip","hideTooltip","offset","windowWidth","window","innerWidth","trigger","getBoundingClientRect","trgWidth","offsetWidth","triggerPos","left","documentElement","scrollLeft","top","scrollTop","tltWidth","LEFT","TOP","style","width","transform","RIGHT","right","verifyPositionSpace","Host","class","classes","tabindex","aria-describedby"],"mappings":"gUAAA,MAAMA,EAAgB,wpDCoBTC,EAAU,M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,QAAQM,aAAa,aAAc,SAIlCjC,cACP,GAAIG,KAAKwB,QAAS,CACjBxB,KAAKwB,QAAQM,aAAa,aAAc,UAI1CjC,eACC,OACCI,EAAC4D,EAAI,CACJC,MAAO9D,KAAKC,EAAE8D,QAAQtD,EAAaC,MACnCQ,SAAUlB,KAAKkB,SACfF,KAAMhB,KAAKgB,KACXgD,SAAU,EAACC,oBACOlC,EAAA/B,KAAKgC,cAAU,MAAAD,SAAA,EAAAA,EAAI/B,KAAKI,UAC1CU,QAASd,KAAKc,SAEdb,EAAA,OAAA,OASHJ,aACCG,KAAKoC,cAONvC,aACCG,KAAKqC","sourcesContent":["/*\n * Tooltip\n */\n\n$class: \".gov-tooltip\";\n\n#{$class} {\n\tposition: relative;\n\tdisplay: inline;\n\tborder-bottom: 1px dashed currentcolor;\n\tcolor: color(\"primary\");\n\tcursor: help;\n\n\t// VARIANTS\n\t@include parameter(\"icon\") {\n\t\tdisplay: inline-flex;\n\t\twidth: rem-calc(16);\n\t\theight: rem-calc(16);\n\t\tborder-bottom: 0;\n\t\tcolor: inherit;\n\t}\n\t@each $variant, $definitions in $tooltip-content-variants {\n\t\t&[variant=\"#{$variant}\"] {\n\t\t\t--#{$prefix}tooltip-content-bg-color: #{get(\"bg-color\", $definitions)};\n\t\t\t--#{$prefix}tooltip-content-text-color: #{get(\"text-color\", $definitions)};\n\n\t\t\t// STATES\n\t\t\t@include parameter(\"inverse\") {\n\t\t\t\t--#{$prefix}tooltip-content-bg-color: #{color(\"neutral.white\")};\n\t\t\t\t--#{$prefix}tooltip-content-text-color: #{get(\"text-color-inverse\", $definitions)};\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, h, Host, Method, Prop, Watch } from '@stencil/core'\nimport { validateProp } from '../../helpers/Validate/props'\nimport {\n\tTooltipPosition,\n\tTooltipPositionType,\n\tTooltipSize,\n\tTooltipSizeType,\n\tTooltipClass,\n\tTooltipContentClass,\n\tTooltipVariant,\n\tTooltipVariantType,\n} from './constants'\nimport { createID } from '../../utils/string.utils'\nimport { govHost } from '../../helpers/Dom/template'\nimport { GovHost } from '../../helpers/Dom/template.types'\n\n@Component({\n\ttag: 'gov-tooltip',\n\tstyleUrl: 'gov-tooltip.scss',\n})\nexport class GovTooltip {\n\tprivate h: GovHost\n\tprivate content: HTMLGovTooltipContentElement\n\tprivate readonly tooltipId\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.tooltipId = createID('GovTooltip')\n\t}\n\n\t@Element() host: HTMLGovTooltipElement\n\t/**\n\t * Style variation of the tooltip\n\t */\n\t@Prop() readonly variant?: TooltipVariantType = 'primary'\n\t/**\n\t * Tooltip’s size.\n\t */\n\t@Prop() readonly size?: TooltipSizeType = 'm'\n\t/**\n\t * Tooltip display position\n\t */\n\t@Prop() position: TooltipPositionType = 'right'\n\t/**\n\t * Information contained in the tolltip\n\t */\n\t@Prop() readonly message: string = undefined\n\t/**\n\t * Custom tooltip identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Trigger is just an icon\n\t */\n\t@Prop({ attribute: 'icon' }) readonly icon: boolean = undefined\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(TooltipVariant, newValue, TooltipClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(TooltipSize, newValue, TooltipClass.root)\n\t}\n\n\t@Watch('position')\n\tvalidatePosition(newValue: string): void {\n\t\tvalidateProp(TooltipPosition, newValue, TooltipClass.root)\n\t}\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t\tthis.validatePosition(this.position)\n\n\t\tthis.createContentWrapper()\n\t\tthis.registerListeners()\n\t}\n\n\tprivate createContentWrapper() {\n\t\tconst hasContentInside = this.host.querySelector(TooltipContentClass.root) as HTMLGovTooltipContentElement\n\t\tif (hasContentInside) {\n\t\t\tthis.content = hasContentInside\n\t\t} else {\n\t\t\tthis.content = document.createElement(TooltipContentClass.root) as HTMLGovTooltipContentElement\n\t\t\tthis.content.innerHTML = this.message\n\t\t\tthis.host.appendChild(this.content)\n\t\t}\n\n\t\tthis.content.setAttribute('id', this.identifier ?? this.tooltipId)\n\t}\n\n\tprivate registerListeners() {\n\t\tthis.host.addEventListener('focus', e => {\n\t\t\te.preventDefault()\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener('blur', e => {\n\t\t\te.preventDefault()\n\t\t\tthis.hideTooltip()\n\t\t})\n\t\tthis.host.addEventListener('mouseenter', e => {\n\t\t\te.preventDefault()\n\t\t\tthis.showTooltip()\n\t\t})\n\t\tthis.host.addEventListener('mouseleave', e => {\n\t\t\te.preventDefault()\n\t\t\tthis.hideTooltip()\n\t\t})\n\t}\n\n\tprivate verifyPositionSpace() {\n\t\t// @TODO Improve positioning of broken lines\n\t\tconst offset = 12\n\t\tconst windowWidth = window.innerWidth\n\t\tconst trigger = this.host.getBoundingClientRect()\n\t\tconst trgWidth = this.host.offsetWidth\n\t\tconst triggerPos = {\n\t\t\tleft: trigger.left + document.documentElement.scrollLeft,\n\t\t\ttop: trigger.top + document.documentElement.scrollTop,\n\t\t}\n\t\tconst tltWidth = this.content.offsetWidth\n\t\tif (this.position === TooltipPosition.LEFT) {\n\t\t\tif (offset + triggerPos.left < tltWidth) {\n\t\t\t\tthis.position = TooltipPosition.TOP\n\t\t\t\tthis.content.style.left = '0px'\n\t\t\t\tthis.content.style.width = window.innerWidth - triggerPos.left - offset + 'px'\n\t\t\t\tthis.content.style.transform = 'none'\n\t\t\t}\n\t\t} else if (this.position === TooltipPosition.RIGHT) {\n\t\t\tif (windowWidth - (triggerPos.left + trgWidth) < tltWidth) {\n\t\t\t\tthis.position = TooltipPosition.TOP\n\t\t\t\tthis.content.style.right = '0px'\n\t\t\t\tthis.content.style.left = 'auto'\n\t\t\t\tthis.content.style.width = trgWidth + triggerPos.left + offset + 'px'\n\t\t\t\tthis.content.style.transform = 'none'\n\t\t\t}\n\t\t} else {\n\t\t\t// doesn't fit from the left\n\t\t\tif (tltWidth / 2 > triggerPos.left) {\n\t\t\t\tthis.content.style.left = '0px'\n\t\t\t\tthis.content.style.width = window.innerWidth - triggerPos.left - offset + 'px'\n\t\t\t\tthis.content.style.transform = 'none'\n\t\t\t}\n\t\t\t// doesn't fit from the right\n\t\t\telse if (tltWidth / 2 > windowWidth - (triggerPos.left + tltWidth)) {\n\t\t\t\tthis.content.style.right = '0px'\n\t\t\t\tthis.content.style.left = 'auto'\n\t\t\t\tthis.content.style.width = trgWidth + triggerPos.left + offset + 'px'\n\t\t\t\tthis.content.style.transform = 'none'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate showTooltip() {\n\t\tif (this.content) {\n\t\t\tthis.verifyPositionSpace()\n\t\t\tthis.content.setAttribute('is-visible', 'true')\n\t\t}\n\t}\n\n\tprivate hideTooltip() {\n\t\tif (this.content) {\n\t\t\tthis.content.setAttribute('is-visible', 'false')\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host\n\t\t\t\tclass={this.h.classes(TooltipClass.root)}\n\t\t\t\tposition={this.position}\n\t\t\t\tsize={this.size}\n\t\t\t\ttabindex={0}\n\t\t\t\taria-describedby={this.identifier ?? this.tooltipId}\n\t\t\t\tvariant={this.variant}\n\t\t\t>\n\t\t\t\t<slot />\n\t\t\t</Host>\n\t\t)\n\t}\n\n\t/**\n\t * Showing the modal\n\t */\n\t@Method()\n\tasync show(): Promise<void> {\n\t\tthis.showTooltip()\n\t}\n\n\t/**\n\t * Hidding the modal\n\t */\n\t@Method()\n\tasync hide(): Promise<void> {\n\t\tthis.hideTooltip()\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/utils/bool.utils.ts","../../../packages/core/src/components/gov-button/gov-button.scss?tag=gov-button","../../../packages/core/src/components/gov-button/gov-button.tsx"],"names":["toBool","value","indexOf","govButtonCss","Tags","GovButton","[object Object]","hostRef","this","h","govHost","host","newValue","validateProp","ButtonVariants","ButtonClass","root","Type","Sizes","NativeType","validateVariant","variant","validateType","type","validateSize","size","validateNativeType","nativeType","canValidateWcagOnRender","delay","validateWcag","classNames","prepareClasses","hasSlot","rootWithIcon","Tag","href","A","BUTTON","undefined","Host","hoverable","class","classes","inverse","ref","el","buttonRef","onClick","onClickHandler","bind","onFocus","onFocusHandler","onBlur","onBlurHandler","onMouseDown","isPressed","onMouseUp","disabled","id","identifier","target","download","hreflang","rel","name","tabindex","focusable","aria-activedescendant","wcagActiveDescendant","aria-describedby","aria-description","wcagDescription","aria-controls","wcagControls","aria-details","wcagDetails","aria-expanded","toBoolAttrIfDefined","wcagExpanded","aria-label","wcagLabel","aria-labelledby","wcagLabelledBy","aria-owns","wcagOwns","aria-haspopup","wcagHasPopup","aria-pressed","toBoolAttr","aria-disabled","aria-current","wcagCurrent","loading","e","stopPropagation","govClick","emit","component","originalEvent","govFocus","govBlur","focus","validateWcagRef","validateWcagLabel"],"mappings":"8bAAgBA,EAAOC,GACtB,UAAWA,IAAU,SAAU,CAC9B,MAAO,CAAC,OAAQ,OAAQ,OAAQ,KAAKC,QAAQD,MAAY,OACnD,UAAWA,IAAU,SAAU,CACrC,OAAOA,EAAQ,OACT,UAAWA,IAAU,UAAW,CACtC,OAAOA,MACD,CACN,OAAOA,EAAQ,KAAO,OCRxB,MAAME,EAAe,0hwECsBrB,IAAKC,GAAL,SAAKA,GACJA,EAAA,KAAA,IACAA,EAAA,UAAA,UAFD,CAAKA,IAAAA,EAAI,WASIC,EAAS,MAIrBC,YAAAC,wJAa2D,cAIN,sBAIhB,mBAID,wCASkB,sBAKN,0LAuCV,oYAwFjB,MArKpBC,KAAKC,EAAIC,EAAQF,KAAKG,MAkJvBL,gBAAgBM,GACfC,EAAaC,EAAgBF,EAAUG,EAAYC,MAIpDV,aAAaM,GACZC,EAAaI,EAAML,EAAUG,EAAYC,MAI1CV,aAAaM,GACZC,EAAaK,EAAON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AsB,wBAAyBtD,EAAYC,MAChFuF,EAAgB/F,KAAKkE,aAAc,gBAAiB3D,EAAYC,MAChEuF,EAAgB/F,KAAKoE,YAAa,eAAgB7D,EAAYC,MAC9DuF,EAAgB/F,KAAK6E,SAAU,YAAatE,EAAYC,MACxDuF,EAAgB/F,KAAK+E,aAAc,gBAAiBxE,EAAYC,MAChEwF,EAAkBhG,KAAKyE,UAAWzE,KAAK2E,eAAgBpE,EAAYC","sourcesContent":["export function toBool(value: any): boolean {\n\tif (typeof value === 'string') {\n\t\treturn ['true', 'True', 'TRUE', '1'].indexOf(value) !== -1\n\t} else if (typeof value === 'number') {\n\t\treturn value > 0\n\t} else if (typeof value === 'boolean') {\n\t\treturn value\n\t} else {\n\t\treturn value ? true : false\n\t}\n}\n","/*\n * Button\n */\n\n// Shared definitions - BUTTON & badge\n@import \"./gov-button-core.scss\";\n\n.gov-button {\n\t@extend %button-core;\n\tdisplay: inline-block;\n\t.element {\n\t\tborder-radius: #{$border-radius};\n\t}\n\n\t&[type=\"link\"] {\n\t\t.element {\n\t\t\tmin-height: inherit;\n\t\t\tpadding: 0 !important;\n\t\t\tline-height: inherit;\n\t\t\ttext-decoration: underline;\n\t\t\t@include hover() {\n\t\t\t\ttext-decoration: none;\n\t\t\t}\n\t\t}\n\t}\n\n\t// STATES\n\t&[loading=\"true\"],\n\t&[loading=\"1\"] {\n\t\t.element {\n\t\t\t> .gov-icon:not(.gov-spin-animation),\n\t\t\t> gov-icon:not(.gov-spin-animation) {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t\t.gov-icon {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $button-sizes {\n\t\t// Loading state\n\t\t&[loading=\"0\"][size=\"#{$size}\"],\n\t\t&[loading=\"false\"][size=\"#{$size}\"],\n\t\t&[loading=\"\"][size=\"#{$size}\"] {\n\t\t\t.element {\n\t\t\t\tpadding: get(\"padding-y\", $definitions) calc(((get(\"padding-x\", $definitions) * 3) + get(\"icon-size\", $definitions)) / 2);\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from \"@stencil/core\"\nimport { validateProp } from \"../../helpers/Validate/props\"\nimport {\n\tButtonSizesType,\n\tNativeTypesType,\n\tTypesType,\n\tButtonVariants,\n\tButtonVariantType,\n\tButtonClass,\n\tType,\n\tNativeType,\n\tButtonTargetType,\n} from \"./constants\"\nimport { govHost, toBoolAttr, toBoolAttrIfDefined, prepareClasses } from \"../../helpers/Dom/template\"\nimport { GovHost } from \"../../helpers/Dom/template.types\"\nimport { toBool } from \"../../utils/bool.utils\"\nimport { Sizes } from \"../../core/constants/sizes\"\nimport { validateWcagLabel, validateWcagRef } from \"../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../helpers/Dom/win\"\nimport { delay } from \"../../utils/utils\"\nimport { ButtonEvent } from \"./gov-button.types\"\n\nenum Tags {\n\tA = \"a\",\n\tBUTTON = \"button\",\n}\n\n@Component({\n\ttag: \"gov-button\",\n\tstyleUrl: \"gov-button.scss\",\n})\nexport class GovButton {\n\tprivate h: GovHost\n\tprivate buttonRef?: HTMLButtonElement\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t}\n\n\t@Element() host: HTMLGovButtonElement\n\n\t/**\n\t * Style variation of the button\n\t */\n\t@Prop({ reflect: true }) readonly variant?: ButtonVariantType\n\t/**\n\t * Button’s size\n\t */\n\t@Prop({ reflect: true }) readonly size?: ButtonSizesType = \"m\"\n\t/**\n\t * Button's type\n\t */\n\t@Prop({ reflect: true }) readonly type?: TypesType = \"solid\"\n\t/**\n\t * Expands the button to fill 100% of the container width\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Determine if component should have inversed colors to be used on dark background\n\t */\n\t@Prop() readonly inverse: boolean = false\n\t/**\n\t * The name of the button, which gets paired with the button's value when submitted as part of a form. Corresponds with the native HTML name attribute\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Makes the button component disabled.\n\t * This prevents users from being able to interact with the button, and conveys its inactive state to assistive technologies\n\t */\n\t@Prop({ reflect: true }) readonly disabled: boolean = false\n\t/**\n\t * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type\n\t */\n\t@Prop() readonly nativeType?: NativeTypesType = \"button\"\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href\n\t */\n\t@Prop() readonly href: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target\n\t */\n\t@Prop() readonly target?: ButtonTargetType\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download\n\t */\n\t@Prop() readonly download: boolean\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-hreflang\n\t */\n\t@Prop() readonly hreflang: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-referrerpolicy\n\t */\n\t@Prop() readonly referrerpolicy: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-rel\n\t */\n\t@Prop() readonly rel: string\n\t/**\n\t * Indicates whether an asynchronous process is running\n\t */\n\t@Prop() readonly loading: string\n\t/**\n\t * Same as original parametr\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/focusable\n\t */\n\t@Prop() readonly focusable: boolean = true\n\t/**\n\t * Custom button identifier\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * Indicates the id of a related component’s visually focused element\n\t */\n\t@Prop({ attribute: \"wcag-active-descendant\" }) readonly wcagActiveDescendant: string\n\t/**\n\t * Use this property to add an aria-controls attribute to the button. Use the attribute to point to the unique id of the content that the button manages\n\t */\n\t@Prop({ attribute: \"wcag-controls\" }) readonly wcagControls: string\n\t/**\n\t * Indicates the id of a component that describes the button\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Aria description the button\n\t */\n\t@Prop({ attribute: \"wcag-description\" }) readonly wcagDescription: string\n\t/**\n\t * Details of the component\n\t */\n\t@Prop({ attribute: \"wcag-details\" }) readonly wcagDetails: string\n\t/**\n\t * If a button expands or collapses adjacent content, then use the ariaExpanded prop to add the aria-expanded attribute to the button\n\t * Set the value to convey the current expanded (true) or collapsed (false) state of the content\n\t */\n\t@Prop({ attribute: \"wcag-expanded\" }) readonly wcagExpanded: boolean\n\t/**\n\t * Adds accessible label for the button that is only shown for screen readers\n\t * Typically, this label text replaces the visible text on the button for users who use assistive technology\n\t */\n\t@Prop({ attribute: \"wcag-label\" }) readonly wcagLabel: string\n\t/**\n\t * String of id's that indicate alternative labels elements\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component owned by the button\n\t */\n\t@Prop({ attribute: \"wcag-owns\" }) readonly wcagOwns: string\n\t/**\n\t * \tUse this property to add an aria-haspopup attribute to a button, if you are using it as a menu button\n\t */\n\t@Prop({ attribute: \"wcag-has-popup\" }) readonly wcagHasPopup: string\n\t/**\n\t * Tells screen reader the element is pressed\n\t */\n\t@Prop({ attribute: \"wcag-pressed\" }) readonly wcagPressed: string\n\t/**\n\t * Indicates the current item within a container or set of related elements\n\t */\n\t@Prop({ attribute: \"wcag-current\" }) readonly wcagCurrent: string\n\t/**\n\t * Emitted when the button click\n\t */\n\t@Event({ eventName: \"gov-click\" }) govClick: EventEmitter<ButtonEvent>\n\t/**\n\t * Emitted when the button has focus\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<ButtonEvent>\n\t/**\n\t * Emitted when the button loses focus\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<ButtonEvent>\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(ButtonVariants, newValue, ButtonClass.root)\n\t}\n\n\t@Watch(\"type\")\n\tvalidateType(newValue: string): void {\n\t\tvalidateProp(Type, newValue, ButtonClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(Sizes, newValue, ButtonClass.root)\n\t}\n\n\t@Watch(\"nativeType\")\n\tvalidateNativeType(newValue: string): void {\n\t\tvalidateProp(NativeType, newValue, ButtonClass.root)\n\t}\n\n\t@State() isPressed = false\n\n\tcomponentWillLoad(): void {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateType(this.type)\n\t\tthis.validateSize(this.size)\n\t\tthis.validateNativeType(this.nativeType)\n\t}\n\n\tasync componentDidRender() {\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\tget classNames(): string {\n\t\tconst { h } = this\n\n\t\treturn prepareClasses([ButtonClass.root, h.hasSlot(\"left-icon\") && ButtonClass.rootWithIcon, h.hasSlot(\"right-icon\") && ButtonClass.rootWithIcon])\n\t}\n\n\trender() {\n\t\tconst Tag = this.href ? Tags.A : Tags.BUTTON\n\t\tconst nativeType = Tag === Tags.A ? undefined : this.nativeType\n\n\t\treturn (\n\t\t\t<Host hoverable={true} size={this.size} variant={this.variant} class={this.h.classes(this.classNames)} type={this.type} inverse={this.inverse}>\n\t\t\t\t<Tag\n\t\t\t\t\tclass=\"element\"\n\t\t\t\t\tref={el => (this.buttonRef = el as HTMLButtonElement)}\n\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\tonMouseDown={() => (this.isPressed = true)}\n\t\t\t\t\tonMouseUp={() => (this.isPressed = false)}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\tid={this.identifier}\n\t\t\t\t\thref={this.href}\n\t\t\t\t\ttarget={this.target}\n\t\t\t\t\tdownload={this.download}\n\t\t\t\t\threflang={this.hreflang}\n\t\t\t\t\trel={this.rel}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\ttype={nativeType}\n\t\t\t\t\ttabindex={this.focusable ? \"0\" : \"-1\"}\n\t\t\t\t\taria-activedescendant={this.wcagActiveDescendant}\n\t\t\t\t\taria-describedby={this.wcagActiveDescendant}\n\t\t\t\t\taria-description={this.wcagDescription}\n\t\t\t\t\taria-controls={this.wcagControls}\n\t\t\t\t\taria-details={this.wcagDetails}\n\t\t\t\t\taria-expanded={toBoolAttrIfDefined(this.wcagExpanded)}\n\t\t\t\t\taria-label={this.wcagLabel}\n\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\taria-owns={this.wcagOwns}\n\t\t\t\t\taria-haspopup={toBoolAttrIfDefined(this.wcagHasPopup)}\n\t\t\t\t\taria-pressed={toBoolAttr(this.isPressed)}\n\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\taria-current={this.wcagCurrent}\n\t\t\t\t>\n\t\t\t\t\t{toBool(this.loading) && !this.h.hasSlot(\"right-icon\") &&\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon name=\"loader\" class=\"gov-spin-animation\"></gov-icon>}\n\t\t\t\t\t{this.h.hasSlot(\"left-icon\") && <slot name=\"left-icon\"></slot>}\n\t\t\t\t\t<slot />\n\t\t\t\t\t{this.h.hasSlot(\"right-icon\") && <slot name=\"right-icon\"></slot>}\n\t\t\t\t\t{toBool(this.loading) && this.h.hasSlot(\"right-icon\") &&\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon name=\"loader\" class=\"gov-spin-animation\"></gov-icon>}\n\t\t\t\t</Tag>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onClickHandler(e: PointerEvent): void {\n\t\te.stopPropagation()\n\t\tif (this.disabled === false) {\n\t\t\tthis.govClick.emit({\n\t\t\t\tcomponent: ButtonClass.root,\n\t\t\t\toriginalEvent: e,\n\t\t\t\tref: this.host,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: ButtonClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tref: this.host,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: ButtonClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tref: this.host,\n\t\t})\n\t}\n\n\t/**\n\t * Focus button element\n\t */\n\t@Method()\n\tasync setFocus(): Promise<void> {\n\t\tthis.buttonRef.focus()\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tif (this.focusable) {\n\t\t\tvalidateWcagRef(this.wcagActiveDescendant, \"aria-activedescendant\", ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagControls, \"aria-controls\", ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagDetails, \"aria-details\", ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagOwns, \"aria-owns\", ButtonClass.root)\n\t\t\tvalidateWcagRef(this.wcagHasPopup, \"aria-haspopup\", ButtonClass.root)\n\t\t\tvalidateWcagLabel(this.wcagLabel, this.wcagLabelledBy, ButtonClass.root)\n\t\t}\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/input/gov-form-input.scss?tag=gov-form-input","../../../packages/core/src/components/gov-form/input/gov-form-input.tsx"],"names":["govFormInputCss","Tags","GovFormInput","[object Object]","hostRef","this","h","govHost","host","inputId","createID","f","govForm","newValue","validateProp","FormInputVariants","FormInputClass","root","FormInputSizes","validateVariant","variant","validateSize","size","passAttrToControl","multiline","TEXTAREA","INPUT","passAttrToLabel","String","required","canValidateWcagOnRender","delay","validateWcag","Tag","Host","class","type","hasSlot","name","success","invalid","slot","inputType","disabled","id","identifier","onFocus","onFocusHandler","bind","onInput","onInputHandler","onBlur","onBlurHandler","onKeyUp","onKeyUpHandler","ref","el","inputRef","placeholder","value","readonly","toBoolAttrIfDefined","autocomplete","toOnOffAttrIfDefined","autocorrect","minlength","maxlength","rows","cols","role","aria-required","aria-invalid","aria-disabled","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-owns","wcagOwns","aria-expanded","wcagExpanded","aria-autocomplete","wcagAutocomplete","e","stopPropagation","focused","govFocus","emit","component","originalEvent","govBlur","govKeyUp","target","govInput","options","focus","validateWcagRef","validateWcagLabelFor"],"mappings":"ygBAAA,MAAMA,EAAkB,i8TCcxB,IAAKC,GAAL,SAAKA,GACJA,EAAA,SAAA,QACAA,EAAA,YAAA,YAFD,CAAKA,IAAAA,EAAI,WASIC,EAAY,MAMxBC,YAAAC,kQA0B6C,uGAqBR,6NAsCG,0NApFvCC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,QAAUC,EAAS,YACxBL,KAAKM,EAAIC,EAAQL,EAAQF,KAAKG,OAmI/BL,gBAAgBU,GACfC,EAAaC,EAAmBF,EAAUG,EAAeC,MAI1Dd,aAAaU,GACZC,EAAaI,EAAgBL,EAAUG,EAAeC,MAGvDd,oBACCE,KAAKc,gBAAgBd,KAAKe,SAC1Bf,KAAKgB,aAAahB,KAAKiB,MAEvBjB,KAAKM,EAAEY,kBAAkB,OAAQlB,KAAKmB,UAAYvB,EAAKwB,SAAWxB,EAAKyB,OACvErB,KAAKM,EAAEgB,gBAAgB,WAAYC,OAAOvB,KAAKwB,WAGhD1B,2BACC,GAAI2B,IAA2B,OACxBC,EAAM,WACN1B,KAAK2B,gBAIb7B,SACC,MAAM8B,EAAM5B,KAAKmB,UAAYvB,EAAKwB,SAAWxB,EAAKyB,MAElD,OACC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cxC,KAAKI,QAASJ,KAAKuE,eAAgB5D,EAAeC","sourcesContent":["/*\n * Input\n */\n\n@import \"../input/gov-form-input-core.scss\";\n$class: \".gov-form-input\";\n\n#{$class} {\n\t@extend %form-input-core;\n\n\t// STATES\n\t@include parameter(\"invalid\") {\n\t\t*[slot=\"right-icon\"]:not(.icon-validation):not(.icon-arrow) {\n\t\t\tdisplay: none;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t&[type=\"reset\"] {\n\t\tinput {\n\t\t\tborder-width: 0;\n\t\t\t&:focus {\n\t\t\t\toutline: none;\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch, Event, EventEmitter, State, Method } from '@stencil/core'\nimport { GovHost } from '../../../helpers/Dom/template.types'\nimport { FormInputSizes, FormInputSizesType, InputType, Type } from './constants'\nimport { createID } from '../../../utils/string.utils'\nimport { govHost, toBoolAttrIfDefined, toOnOffAttrIfDefined } from '../../../helpers/Dom/template'\nimport { FormInputClass, FormInputVariants, FormInputVariantType } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { canValidateWcagOnRender } from '../../../helpers/Dom/win'\nimport { delay } from '../../../utils/utils'\nimport { validateWcagLabelFor, validateWcagRef } from '../../../helpers/Validate/wcag'\nimport { GovForm } from '../../../helpers/Dom/form.types'\nimport { govForm } from '../../../helpers/Dom/form'\nimport { FormInputEvent } from \"./gov-form-input.types\"\n\nenum Tags {\n\tINPUT = 'input',\n\tTEXTAREA = 'textarea',\n}\n\n@Component({\n\ttag: 'gov-form-input',\n\tstyleUrl: 'gov-form-input.scss',\n})\nexport class GovFormInput {\n\tprivate f: GovForm\n\tprivate h: GovHost\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly inputId: string\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.inputId = createID('GovInput')\n\t\tthis.f = govForm(govHost(this.host))\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value: string\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: FormInputVariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: FormInputSizesType = 'm'\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Generates a texarea for the possibility of multiple lines\n\t */\n\t@Prop() readonly multiline: boolean\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n\t */\n\t@Prop() readonly rows: number\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-cols\n\t */\n\t@Prop() readonly cols: number\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-autocomplete\n\t */\n\t@Prop() readonly autocomplete: boolean\n\t/**\n\t * Same as original parameter https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-autocorrect\n\t */\n\t@Prop() readonly autocorrect: boolean\n\t/**\n\t * Defineds the visual style of input\n\t */\n\t@Prop() readonly type?: Type\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types\n\t */\n\t@Prop() readonly inputType: InputType = 'text'\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/input_role\n\t */\n\t@Prop() readonly role: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: 'wcag-described-by' }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: 'wcag-labelled-by' }) readonly wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value.\n\t */\n\t@Prop({ attribute: 'wcag-autocomplete' }) readonly wcagAutocomplete: string\n\t/**\n\t * Attribute is set on an element to indicate if a control is expanded or collapsed\n\t */\n\t@Prop({ attribute: 'wcag-expanded' }) readonly wcagExpanded: boolean\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FormInputEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FormInputEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-input' }) govInput: EventEmitter<FormInputEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-keyup' }) govKeyUp: EventEmitter<FormInputEvent>\n\t@State() focused: boolean\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormInputVariants, newValue, FormInputClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormInputSizes, newValue, FormInputClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\n\t\tthis.f.passAttrToControl('type', this.multiline ? Tags.TEXTAREA : Tags.INPUT)\n\t\tthis.f.passAttrToLabel('required', String(this.required))\n\t}\n\n\tasync componentDidRender() {\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst Tag = this.multiline ? Tags.TEXTAREA : Tags.INPUT\n\n\t\treturn (\n\t\t\t<Host class={FormInputClass.root} size={this.size} variant={this.variant} type={this.type}>\n\t\t\t\t{this.h.hasSlot('prefix') && <slot name=\"prefix\"></slot>}\n\t\t\t\t<span class=\"element\">\n\t\t\t\t\t{this.h.hasSlot('left-icon') && <slot name=\"left-icon\" />}\n\n\t\t\t\t\t{this.h.hasSlot('right-icon') && !(this.success || this.invalid) && <slot name=\"right-icon\" />}\n\n\t\t\t\t\t{this.success && !this.multiline && <gov-icon slot=\"right-icon\" class=\"icon-validation\" name=\"check-lg\"></gov-icon>}\n\t\t\t\t\t{this.invalid && !this.multiline && <gov-icon slot=\"right-icon\" class=\"icon-validation\" name=\"exclamation-lg\"></gov-icon>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\ttype={this.inputType}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\tid={this.identifier || this.inputId}\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonInput={this.onInputHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\tonKeyUp={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\treadonly={toBoolAttrIfDefined(this.readonly)}\n\t\t\t\t\t\tautocomplete={toOnOffAttrIfDefined(this.autocomplete)}\n\t\t\t\t\t\tautocorrect={toOnOffAttrIfDefined(this.autocorrect)}\n\t\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\trows={this.rows}\n\t\t\t\t\t\tcols={this.cols}\n\t\t\t\t\t\trole={this.role}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\taria-owns={this.wcagOwns}\n\t\t\t\t\t\taria-expanded={toBoolAttrIfDefined(this.wcagExpanded)}\n\t\t\t\t\t\taria-autocomplete={this.wcagAutocomplete}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t{this.h.hasSlot('sufix') && <slot name=\"sufix\"></slot>}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.focused = true\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormInputClass.root,\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.focused = false\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormInputClass.root,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onKeyUpHandler(e: KeyboardEvent) {\n\t\te.stopPropagation()\n\t\tthis.govKeyUp.emit({\n\t\t\tcomponent: FormInputClass.root,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit({\n\t\t\tcomponent: FormInputClass.root,\n\t\t\tvalue: this.value,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Sets the ordered value of the element\n\t */\n\t@Method()\n\tasync setValue(value: string): Promise<void> {\n\t\tthis.value = value\n\t}\n\n\t/**\n\t * Clears input value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\t}\n\n\t/**\n\t * Returns an instance of the native html input element\n\t */\n\t@Method()\n\tasync 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', FormInputClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormInputClass.root)\n\t\tvalidateWcagRef(this.wcagOwns, 'wcag-owns', FormInputClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.inputId, this.wcagLabelledBy, FormInputClass.root)\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.scss?tag=gov-form-multi-select","../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.tsx"],"names":["govFormMultiSelectCss","GovFormMultiSelect","[object Object]","hostRef","this","selectId","createID","listId","newValue","validateProp","FormMultiselectVariants","FormMultiSelectClass","root","FormMultiselectSizes","govChange","emit","component","value","validateVariant","variant","validateSize","size","Array","from","selectRef","querySelectorAll","filter","option","disabled","selected","map","name","textContent","autocompleteRef","addEventListener","onSelectHandler","bind","onInputHandler","onFocusHandler","onBlurHandler","setSearchCallback","Promise","resolve","data","getAvailableOptions","String","length","removeDiacritics","toLowerCase","indexOf","then","selectedOptions","findIndex","querySelector","newOption","index","getOptionIndex","getOptionElement","removeOption","splice","initAutocomplete","delay","forEach","selectOption","canValidateWcagOnRender","validateWcag","h","Host","class","wrap","identifier","required","invalid","placeholder","ref","el","minlength","wcagDescribedBy","wcagLabelledBy","wcagOwns","slot","hidden","aria-hidden","multiple","aria-disabled","toBoolAttrIfDefined","aria-required","aria-invalid","aria-describedby","aria-labelledby","aria-owns","role","id","list","item","wcagLabel","type","on-gov-click","onTagRemove","e","stopPropagation","focused","govFocus","originalEvent","govBlur","detail","clearValue","focus","options","validateWcagRef","validateWcagLabelFor"],"mappings":"sZAAA,MAAMA,EAAwB,86XCsBjBC,EAAkB,MAO9BC,YAAAC,+MAqBmD,sCASd,2MAqCgB,GAlEpDC,KAAKC,SAAWC,EAAS,aACzBF,KAAKG,OAASD,EAAS,gBAoExBJ,gBAAgBM,GACfC,EAAaC,EAAyBF,EAAUG,EAAqBC,MAItEV,aAAaM,GACZC,EAAaI,EAAsBL,EAAUG,EAAqBC,MAInEV,WAAWM,GACVJ,KAAKU,UAAUC,KAAK,CACnBC,UAAWL,EAAqBC,KAChCK,MAAOT,IAITN,oBACCE,KAAKc,gBAAgBd,KAAKe,SAC1Bf,KAAKgB,aAAahB,KAAKiB,MAGhBnB,sBACP,OAAOoB,MAAMC,KAAKnB,KAAKoB,UAAUC,iBAAiB,WAChDC,QAAQC,KAAgCA,EAAOC,UAAYD,EAAOE,YAClEC,KAAKH,IAAyB,CAAQI,KAAMJ,EAAOK,YAAaf,MAAOU,EAAOV,UAGzEf,mBACPE,KAAK6B,gBAAgBC,iBAAiB,aAAc9B,KAAK+B,gBAAgBC,KAAKhC,OAC9EA,KAAK6B,gBAAgBC,iBAAiB,YA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AAK,UACzChE,EAAOI,KACRmC,EAAA,aAAA,CACC6B,UAAW,4BAA8BpE,EAAOI,KAChDZ,QAAQ,UACR6E,KAAK,OACL3E,KAAK,IAAG4E,eACM,IAAM7F,KAAK8F,YAAYvE,IAErCuC,EAAA,WAAA,CAAUnC,KAAK,eAUf7B,eAAeiG,GACtBA,EAAEC,kBACFhG,KAAKiG,QAAU,KACfjG,KAAKkG,SAASvF,KAAK,CAClBC,UAAWL,EAAqBC,KAChC2F,cAAeJ,EACflF,MAAOb,KAAK+C,kBAINjD,cAAciG,GACrBA,EAAEC,kBACFD,EAAEC,kBACFhG,KAAKiG,QAAU,MACfjG,KAAKoG,QAAQzF,KAAK,CACjBC,UAAWL,EAAqBC,KAChC2F,cAAeJ,EACflF,MAAOb,KAAK+C,kBAINjD,eAAeiG,GACtB/F,KAAKa,MAASkF,EAAEM,OAA0BxF,MAC1CkF,EAAEC,kBAGKlG,gBAAgBiG,GACvBA,EAAEC,kBACF,MAAMnF,EAAQkF,EAAEM,OAChBrG,KAAK2D,aAAa9C,GAClBb,KAAKa,MAAQ,GACbb,KAAK6B,gBAAgByE,aACrBtG,KAAK6B,gBAAgB0E,QAGdzG,YAAYwD,GACnBtD,KAAKsD,aAAaA,GAOnBxD,eAAe0G,GACd,OAAOxG,KAAKoB,UAAUmF,MAAMC,GAO7B1G,eAAee,GACdb,KAAKa,MAAQA,EAOdf,oBACC,OAAOE,KAAKoB,UAObtB,qBACC2G,EAAgBzG,KAAKyE,gBAAiB,oBAAqBlE,EAAqBC,MAChFiG,EAAgBzG,KAAK0E,eAAgB,mBAAoBnE,EAAqBC,MAC9EiG,EAAgBzG,KAAK2E,SAAU,YAAapE,EAAqBC,MACjEkG,EAAqB1G,KAAKkE,YAAclE,KAAKC,SAAUD,KAAK0E,eAAgBnE,EAAqBC","sourcesContent":["/*\n * Multiselect\n */\n\n@import \"../select/gov-form-select-core.scss\";\n$class: \".gov-form-multi-select\";\n\n#{$class} {\n\t@extend %form-select-core;\n\tflex-wrap: wrap;\n\t&__wrap {\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8);\n\t\twidth: 100%;\n\t}\n\t&__list {\n\t\t@extend %reset-ul;\n\t\t@include typography($font-size-xs);\n\t\tdisplay: flex;\n\t\tgap: rem-calc(8);\n\t\tflex-wrap: wrap;\n\t}\n\t&__list > &__item {\n\t\t@extend %reset-ul-li;\n\t\tposition: relative;\n\t\tdisplay: flex;\n\t\tflex: 0 0 auto;\n\t\talign-items: center;\n\t\tpadding: rem-calc(0 0 0 8);\n\t\tbackground: $form-multiselect-bg;\n\t\ttransition: $t linear background-color;\n\t}\n}\n","import { Component, Element, h, State, Prop, Event, EventEmitter, Watch, Host, Method } from \"@stencil/core\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport {\n\tFormMultiselectSizesType,\n\tFormMultiselectVariants,\n\tFormMultiselectVariantType,\n\tFormMultiSelectClass,\n\tFormMultiselectSizes,\n} from \"./constants\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { createID, removeDiacritics } from \"../../../utils/string.utils\"\nimport { delay } from \"../../../utils/utils\"\nimport { Nullable } from \"../../../types/interfaces\"\nimport { FormMultiselectEvent, GovFormMultiSelectItem } from \"./gov-form-multi-select.types\"\nimport { FormInputEvent } from \"../input/gov-form-input.types\"\n\n@Component({\n\ttag: \"gov-form-multi-select\",\n\tstyleUrl: \"gov-form-multi-select.scss\",\n})\nexport class GovFormMultiSelect {\n\tprivate selectRef?: HTMLSelectElement\n\tprivate autocompleteRef?: HTMLGovFormAutocompleteElement\n\n\tprivate readonly selectId: string\n\tprivate readonly listId: string\n\n\tconstructor() {\n\t\tthis.selectId = createID(\"GovSelect\")\n\t\tthis.listId = createID(\"GovMultiList\")\n\t}\n\n\t@Element() host: HTMLGovFormSelectElement\n\t/**\n\t * Custom select identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * Custom select placeholder.\n\t */\n\t@Prop({ attribute: \"placeholder\" }) readonly placeholder: string\n\t/**\n\t * Style variation of the form select.\n\t */\n\t@Prop() readonly variant?: FormMultiselectVariantType\n\t/**\n\t * Select’s size.\n\t */\n\t@Prop() readonly size?: FormMultiselectSizesType = \"m\"\n\t/**\n\t * Name of the select.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the select component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-owns\" }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the select has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FormMultiselectEvent>\n\t/**\n\t * Emitted when the select loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormMultiselectEvent>\n\t/**\n\t * Emitted when the select change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormMultiselectEvent>\n\n\t@State() focused: boolean\n\t@State() value: string\n\t@State() selectedOptions: GovFormMultiSelectItem[] = []\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormMultiselectVariants, newValue, FormMultiSelectClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormMultiselectSizes, newValue, FormMultiSelectClass.root)\n\t}\n\n\t@Watch(\"selectedOptions\")\n\temitChange(newValue: GovFormMultiSelectItem[]) {\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormMultiSelectClass.root,\n\t\t\tvalue: newValue,\n\t\t})\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\tprivate getAvailableOptions(): GovFormMultiSelectItem[] {\n\t\treturn Array.from(this.selectRef.querySelectorAll(\"option\"))\n\t\t\t.filter((option: HTMLOptionElement) => !(option.disabled || option.selected))\n\t\t\t.map((option: HTMLOptionElement) => ({ name: option.textContent, value: option.value }))\n\t}\n\n\tprivate initAutocomplete() {\n\t\tthis.autocompleteRef.addEventListener(\"gov-select\", this.onSelectHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener(\"gov-input\", this.onInputHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener(\"gov-focus\", this.onFocusHandler.bind(this))\n\t\tthis.autocompleteRef.addEventListener(\"gov-blur\", this.onBlurHandler.bind(this))\n\t\tthis.autocompleteRef\n\t\t\t.setSearchCallback(value => {\n\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\tconst data = this.getAvailableOptions()\n\t\t\t\t\tif (String(value).length === 0) {\n\t\t\t\t\t\treturn resolve(data)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(\n\t\t\t\t\t\tdata.filter(({ name }) => {\n\t\t\t\t\t\t\tif (!name) return false\n\t\t\t\t\t\t\treturn removeDiacritics(name).toLowerCase().indexOf(removeDiacritics(value).toLowerCase()) > -1\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t})\n\t\t\t.then()\n\t}\n\n\tprivate getOptionIndex(value: GovFormMultiSelectItem): number {\n\t\treturn this.selectedOptions.findIndex(option => option.value === value.value && option.name === value.name)\n\t}\n\n\tprivate getOptionElement(value: GovFormMultiSelectItem): Nullable<HTMLOptionElement> {\n\t\treturn this.selectRef.querySelector(\"option[value=\\\"\" + value.value + \"\\\"]\") as HTMLOptionElement\n\t}\n\n\tprivate selectOption(newOption: GovFormMultiSelectItem) {\n\t\tconst index = this.getOptionIndex(newOption)\n\t\tif (index === -1) {\n\t\t\tthis.selectedOptions = [...this.selectedOptions, newOption]\n\t\t\tconst option = this.getOptionElement(newOption)\n\t\t\tif (option) {\n\t\t\t\toption.selected = true\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate removeOption(removeOption: GovFormMultiSelectItem) {\n\t\tconst index = this.getOptionIndex(removeOption)\n\t\tif (index !== -1) {\n\t\t\tthis.selectedOptions.splice(index, 1)\n\t\t\tthis.selectedOptions = [...this.selectedOptions]\n\t\t\tconst option = this.getOptionElement(removeOption)\n\t\t\tif (option) {\n\t\t\t\toption.selected = false\n\t\t\t}\n\t\t}\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.initAutocomplete()\n\t\tawait delay(0)\n\t\tthis.selectRef.querySelectorAll(\"option\").forEach((option: HTMLOptionElement) => {\n\t\t\tif (option.selected) {\n\t\t\t\tthis.selectOption({\n\t\t\t\t\tname: option.textContent,\n\t\t\t\t\tvalue: option.value,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormMultiSelectClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<div class={FormMultiSelectClass.wrap}>\n\t\t\t\t\t<div class=\"element\">\n\t\t\t\t\t\t<gov-form-autocomplete\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\tidentifier={this.identifier || this.selectId}\n\t\t\t\t\t\t\trequired={false}\n\t\t\t\t\t\t\tsize={this.size}\n\t\t\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\t\t\tref={el => (this.autocompleteRef = el as HTMLGovFormAutocompleteElement)}\n\t\t\t\t\t\t\tminlength={0}\n\t\t\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\t\t\twcagOwns={this.listId}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<gov-icon slot=\"right-icon\" class=\"icon-arrow\" name=\"chevron-down\"></gov-icon>\n\t\t\t\t\t\t<select\n\t\t\t\t\t\t\thidden\n\t\t\t\t\t\t\taria-hidden={true}\n\t\t\t\t\t\t\tmultiple\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\tref={el => (this.selectRef = el as HTMLSelectElement)}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\taria-owns={this.wcagOwns}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<slot></slot>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<ul role=\"listbox\" id={this.listId} class={FormMultiSelectClass.list}>\n\t\t\t\t\t{this.selectedOptions.map(option => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li class={FormMultiSelectClass.item} role=\"option\">\n\t\t\t\t\t\t\t\t{option.name}\n\t\t\t\t\t\t\t\t<gov-button\n\t\t\t\t\t\t\t\t\twcagLabel={\"Odebrat vybranou položku \" + option.name}\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\ttype=\"base\"\n\t\t\t\t\t\t\t\t\tsize=\"s\"\n\t\t\t\t\t\t\t\t\ton-gov-click={() => this.onTagRemove(option)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<gov-icon name=\"x-lg\"></gov-icon>\n\t\t\t\t\t\t\t\t</gov-button>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.focused = true\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormMultiSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.selectedOptions,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\te.stopPropagation()\n\t\tthis.focused = false\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormMultiSelectClass.root,\n\t\t\toriginalEvent: e,\n\t\t\tvalue: this.selectedOptions,\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: CustomEvent) {\n\t\tthis.value = (e.detail as FormInputEvent).value\n\t\te.stopPropagation()\n\t}\n\n\tprivate onSelectHandler(e: CustomEvent) {\n\t\te.stopPropagation()\n\t\tconst value = e.detail as GovFormMultiSelectItem\n\t\tthis.selectOption(value)\n\t\tthis.value = \"\"\n\t\tthis.autocompleteRef.clearValue()\n\t\tthis.autocompleteRef.focus()\n\t}\n\n\tprivate onTagRemove(removeOption: GovFormMultiSelectItem) {\n\t\tthis.removeOption(removeOption)\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.selectRef.focus(options)\n\t}\n\n\t/**\n\t * Sets the ordered value of the element\n\t */\n\t@Method()\n\tasync setValue(value: string): Promise<void> {\n\t\tthis.value = value\n\t}\n\n\t/**\n\t * Returns an instance of the native html select element\n\t */\n\t@Method()\n\tasync getInstance(): Promise<HTMLSelectElement> {\n\t\treturn this.selectRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormMultiSelectClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormMultiSelectClass.root)\n\t\tvalidateWcagRef(this.wcagOwns, \"wcag-owns\", FormMultiSelectClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.selectId, this.wcagLabelledBy, FormMultiSelectClass.root)\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{r as t,c as i,h as e,H as s,g as o}from"./p-4af5e4f4.js";import{c as a}from"./p-24636c53.js";import{F as r,a as n,b as h}from"./p-f687452c.js";import{v as l}from"./p-26acf964.js";import{t as c,h as m}from"./p-03990da5.js";import{a as d}from"./p-3f37ddb6.js";import"./p-55500e5a.js";import"./p-ff7365ae.js";import"./p-561fa17b.js";const p='.gov-form-autocomplete__list{margin:0;padding:0}.gov-form-autocomplete__list>.gov-form-autocomplete__item{margin:0;padding:0;background:none}.gov-form-autocomplete__list>.gov-form-autocomplete__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-form-autocomplete{position:relative;display:block;width:100%}.gov-form-autocomplete__list{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);position:absolute;top:100%;right:0;left:0;z-index:5;max-height:14.0625rem;margin-top:0.5rem;border:var(--gov-autocomplete-item-hover, 0.0625rem solid var(--gov-color-secondary-500));border-radius:var(--gov-border-radius, 0.1875rem);background:var(--gov-autocomplete-bg, var(--gov-color-neutral-white));overflow-x:hidden;overflow-y:auto;overscroll-behavior:none}.gov-form-autocomplete__list>.gov-form-autocomplete__item{padding:0.75rem 0.5rem;cursor:pointer}.gov-form-autocomplete__list:empty{display:none}.gov-form-autocomplete__item[aria-selected=""],.gov-form-autocomplete__item[aria-selected=true i],.gov-form-autocomplete__item[aria-selected="1"]{background:var(--gov-autocomplete-item-select, var(--gov-color-secondary-400))}@media not all and (pointer: coarse){.gov-form-autocomplete__item:hover{background:var(--gov-autocomplete-item-hover, var(--gov-color-primary-100))}}';const u=class{constructor(e){t(this,e);this.govFocus=i(this,"gov-focus",7);this.govBlur=i(this,"gov-blur",7);this.govInput=i(this,"gov-input",7);this.govSelect=i(this,"gov-select",7);this.templateResolver=t=>t[this.nameKey];this.value="";this.identifier=undefined;this.variant=undefined;this.success=undefined;this.size="m";this.nameKey="name";this.name=undefined;this.required=false;this.disabled=undefined;this.placeholder=undefined;this.readonly=undefined;this.invalid=undefined;this.minlength=2;this.maxlength=undefined;this.wcagDescribedBy=undefined;this.wcagLabelledBy=undefined;this.wcagOwns=undefined;this.focused=undefined;this.processing=false;this.arrowCounter=-1;this.list=[];this.listBoxId=a("GovListBox")}validateVariant(t){l(n,t,r.root)}validateSize(t){l(h,t,r.root)}onArrowUp(){if(this.arrowCounter>0){this.arrowCounter=this.arrowCounter-1}}onArrowDown(){if(this.arrowCounter<this.list.length-1){this.arrowCounter=this.arrowCounter+1}}doSearch(){if(Number.isInteger(this.minlength)&&String(this.value).length<=this.minlength&&this.minlength){this.list=[];this.arrowCounter=-1;this.processing=false;return}if(this.searchCallback){this.processing=true;this.searchCallback(this.value).then((t=>this.list=t)).catch((()=>this.list=[])).finally((()=>{this.arrowCounter=-1;this.processing=false}))}}componentWillLoad(){this.validateVariant(this.variant);this.validateSize(this.size)}render(){return e(s,{class:r.root,size:this.size,variant:this.variant},e("gov-form-input",{placeholder:this.placeholder,name:this.name,disabled:this.disabled,readonly:this.readonly,autocomplete:false,size:this.size,variant:this.variant,required:this.required,invalid:this.invalid,role:"searchbox",value:this.value,minlength:this.minlength,maxlength:this.maxlength,"on-gov-input":c(this.onInputHandler.bind(this),200),"on-gov-keyup":this.onKeyUpHandler.bind(this),"on-gov-focus":this.onFocusHandler.bind(this),"on-gov-blur":this.onBlurHandler.bind(this),wcagAutocomplete:"list",wcagDescribedBy:this.wcagDescribedBy,wcagLabelledBy:this.wcagLabelledBy,wcagOwns:[this.listBoxId,this.wcagOwns].join(" "),wcagExpanded:this.list.length&&this.focused,ref:t=>this.inputRef=t},e("slot",{slot:"right-icon",name:"right-icon"})),e("ul",{class:r.list,role:"listbox",id:this.listBoxId},this.list.map(((t,i)=>{const s=this.arrowCounter===i;return e("li",{class:r.item,innerHTML:this.templateResolver(t,s),role:"option","aria-posinset":i,tabindex:s?0:-1,"aria-setsize":this.list.length,onClick:()=>this.onSelectHandler(i),"aria-selected":d(s)})}))))}onFocusHandler(t){this.focused=true;this.arrowCounter=-1;if((this.value||this.minlength===0)&&this.searchCallback){this.doSearch()}t.stopPropagation();this.govFocus.emit({originalEvent:t,component:r.root,value:this.value,selected:null})}onBlurHandler(t){this.focused=false;setTimeout((()=>this.list=[]),200);this.arrowCounter=-1;t.stopPropagation();this.govBlur.emit({originalEvent:t,component:r.root,value:this.value,selected:null})}onInputHandler(t){this.value=t.target.value;t.stopPropagation();this.govInput.emit({originalEvent:t,component:r.root,value:this.value,selected:null});this.doSearch()}onSelectHandler(t=-1){let i=null;if(t>-1){i=this.list[t]}else if(m(this.arrowCounter,this.list)){i=this.list[this.arrowCounter]}if(i){this.govSelect.emit({component:r.root,value:this.value,selected:i});this.list=[];if(m(this.nameKey,i)&&typeof i[this.nameKey]==="string"){this.value=i[this.nameKey]}}}onKeyUpHandler(t){const i=t.detail.originalEvent;t.stopPropagation();if(i.keyCode===38)this.onArrowUp();else if(i.keyCode===40)this.onArrowDown();else if(i.keyCode===13)this.onSelectHandler()}async setFocus(t){return this.inputRef.focus(t)}async clearValue(){this.value="";this.inputRef.value="";await this.inputRef.clearValue()}async setSearchCallback(t){this.searchCallback=t}async setTemplateResolver(t){this.templateResolver=t}get host(){return o(this)}static get watchers(){return{variant:["validateVariant"],size:["validateSize"]}}};u.style=p;export{u as gov_form_autocomplete};
2
- //# sourceMappingURL=p-bb3afae6.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.scss?tag=gov-form-autocomplete","../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.tsx"],"names":["govFormAutocompleteCss","GovFormAutocomplete","[object Object]","hostRef","this","templateResolver","item","nameKey","listBoxId","createID","newValue","validateProp","FormAutocompleteVariants","FormAutocompleteClass","root","FormAutocompleteSizes","arrowCounter","list","length","Number","isInteger","minlength","String","value","processing","searchCallback","then","response","catch","finally","validateVariant","variant","validateSize","size","h","Host","class","placeholder","name","disabled","readonly","autocomplete","required","invalid","role","maxlength","on-gov-input","throttle","onInputHandler","bind","on-gov-keyup","onKeyUpHandler","on-gov-focus","onFocusHandler","on-gov-blur","onBlurHandler","wcagAutocomplete","wcagDescribedBy","wcagLabelledBy","wcagOwns","join","wcagExpanded","focused","ref","el","inputRef","slot","id","map","index","isSelected","innerHTML","aria-posinset","tabindex","aria-setsize","onClick","onSelectHandler","aria-selected","toBoolAttr","e","doSearch","stopPropagation","govFocus","emit","originalEvent","component","selected","setTimeout","govBlur","target","govInput","has","govSelect","event","detail","keyCode","onArrowUp","onArrowDown","options","focus","clearValue","callback"],"mappings":"iVAAA,MAAMA,EAAyB,mrDCelBC,EAAmB,MAM/BC,YAAAC,6JAFQC,KAAAC,iBAAiFC,GAAQA,EAAKF,KAAKG,oBA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-autocomplete\";\n\n#{$class} {\n\t@include base();\n\t&__list {\n\t\t@include typography($font-size-s);\n\t\t@extend %reset-ul;\n\t\tposition: absolute;\n\t\ttop: 100%;\n\t\tright: 0;\n\t\tleft: 0;\n\t\tz-index: 5;\n\t\tmax-height: rem-calc(225);\n\t\tmargin-top: rem-calc(8);\n\t\tborder: $form-autocomplete-border;\n\t\tborder-radius: $border-radius;\n\t\tbackground: $form-autocomplete-bg;\n\t\toverflow-x: hidden;\n\t\toverflow-y: auto;\n\t\toverscroll-behavior: none;\n\t}\n\t&__list > &__item {\n\t\t@extend %reset-ul-li;\n\t\tpadding: rem-calc(12 8);\n\t\tcursor: pointer;\n\t}\n\n\t// STATES\n\t&__list:empty {\n\t\tdisplay: none;\n\t}\n\n\t// HOVERS\n\t&__item {\n\t\t@include parameter(\"aria-selected\") {\n\t\t\tbackground: $form-autocomplete-item-select-bg;\n\t\t}\n\t\t@include hover() {\n\t\t\tbackground: $form-autocomplete-item-hover-bg;\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch, Event, EventEmitter, State, Method } from \"@stencil/core\"\nimport { SizesType } from \"./constants\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { FormAutocompleteClass, FormAutocompleteVariants, VariantType, FormAutocompleteSizes } from \"./constants\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { has, throttle } from \"../../../utils/utils\"\nimport { FormAutocompleteEvent, GovFormAutocompleteItem } from \"./gov-form-autocomplete.types\"\nimport { toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { Nullable } from \"../../../types/interfaces\"\nimport { FormInputEvent } from \"../input/gov-form-input.types\"\n\n@Component({\n\ttag: \"gov-form-autocomplete\",\n\tstyleUrl: \"gov-form-autocomplete.scss\",\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\n\tconstructor() {\n\t\tthis.listBoxId = createID(\"GovListBox\")\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value = \"\"\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: VariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = \"m\"\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop() readonly nameKey: string = \"name\"\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 2\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-owns\n\t */\n\t@Prop({ attribute: \"wcag-owns\" }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: \"gov-input\" }) govInput: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: \"gov-select\" }) govSelect: EventEmitter<FormAutocompleteEvent>\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteVariants, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && String(this.value).length <= this.minlength && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\trole={\"searchbox\"}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), 200)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\twcagAutocomplete={\"list\"}\n\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\twcagOwns={[this.listBoxId, this.wcagOwns].join(\" \")}\n\t\t\t\t\twcagExpanded={this.list.length && this.focused}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot slot=\"right-icon\" name=\"right-icon\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list} role={\"listbox\"} id={this.listBoxId}>\n\t\t\t\t\t{this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={\"option\"}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonClick={() => this.onSelectHandler(index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.arrowCounter = -1\n\t\tif ((this.value || this.minlength === 0) && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tsetTimeout(() => (this.list = []), 200)\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit({\n\t\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\t\tvalue: this.value,\n\t\t\t\tselected: selected\n\t\t\t})\n\t\t\tthis.list = []\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === \"string\") {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) this.onSelectHandler()\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = \"\"\n\t\tthis.inputRef.value = \"\"\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{r as o,h as r,H as t,g as e}from"./p-4af5e4f4.js";import{g as m}from"./p-3f37ddb6.js";import{g as i,b as s}from"./p-9cd80b05.js";import{c as a,s as l}from"./p-24636c53.js";import"./p-55500e5a.js";import"./p-03990da5.js";import"./p-ff7365ae.js";import"./p-ef79904e.js";import"./p-6278531b.js";import"./p-f687452c.js";import"./p-3464136c.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-form-control__holder{display:flex;flex-direction:column;padding:0;border:none}.gov-form-control__bottom>*:last-child{margin-bottom:0}.gov-form-control[type=file] .gov-form-label[slot=top] .gov-form-label__label{margin:0rem 0rem 0.5rem}.gov-form-control[type=file] .gov-form-control__bottom{margin:0.5rem 0rem 0rem}.gov-form-control[type=input] .gov-form-label .gov-form-label__label,.gov-form-control[type=select] .gov-form-label .gov-form-label__label,.gov-form-control[type=textarea] .gov-form-label .gov-form-label__label{margin:0rem 0rem 0.25rem}.gov-form-control[type=input] .gov-form-control__bottom,.gov-form-control[type=select] .gov-form-control__bottom,.gov-form-control[type=textarea] .gov-form-control__bottom{margin:0.25rem 0rem 0rem}.gov-form-control[size=xs][type=checkbox] .gov-form-control__bottom,.gov-form-control[size=xs][type=radio] .gov-form-control__bottom{margin-top:var(--gov-form-checkbox-core-xs-message-gap, 0.5rem);margin-left:calc(var(--gov-form-checkbox-core-xs-indicator-size, 1.25rem) + var(--gov-form-checkbox-core-xs-gap, 0.75rem))}.gov-form-control[size=s][type=checkbox] .gov-form-control__bottom,.gov-form-control[size=s][type=radio] .gov-form-control__bottom{margin-top:var(--gov-form-checkbox-core-s-message-gap, 0.5rem);margin-left:calc(var(--gov-form-checkbox-core-s-indicator-size, 1.375rem) + var(--gov-form-checkbox-core-s-gap, 0.75rem))}.gov-form-control[size=m][type=checkbox] .gov-form-control__bottom,.gov-form-control[size=m][type=radio] .gov-form-control__bottom{margin-top:var(--gov-form-checkbox-core-m-message-gap, 0.75rem);margin-left:calc(var(--gov-form-checkbox-core-m-indicator-size, 1.5rem) + var(--gov-form-checkbox-core-m-gap, 1rem))}.gov-form-control[size=l][type=checkbox] .gov-form-control__bottom,.gov-form-control[size=l][type=radio] .gov-form-control__bottom{margin-top:var(--gov-form-checkbox-core-l-message-gap, 0.75rem);margin-left:calc(var(--gov-form-checkbox-core-l-indicator-size, 2rem) + var(--gov-form-checkbox-core-l-gap, 1rem))}.gov-form-control[size=xs][type=switch] .gov-form-control__bottom{margin-top:var(--gov-form-switch-xs-message-gap, 0.5rem);margin-left:calc(var(--gov-form-switch-xs-indicator-height, 1.25rem) * 1.6666666667 + var(--gov-form-switch-xs-gap, 0.75rem))}.gov-form-control[size=s][type=switch] .gov-form-control__bottom{margin-top:var(--gov-form-switch-s-message-gap, 0.5rem);margin-left:calc(var(--gov-form-switch-s-indicator-height, 1.375rem) * 1.6666666667 + var(--gov-form-switch-s-gap, 0.75rem))}.gov-form-control[size=m][type=switch] .gov-form-control__bottom{margin-top:var(--gov-form-switch-m-message-gap, 0.75rem);margin-left:calc(var(--gov-form-switch-m-indicator-height, 1.5rem) * 1.6666666667 + var(--gov-form-switch-m-gap, 1rem))}.gov-form-control[size=l][type=switch] .gov-form-control__bottom{margin-top:var(--gov-form-switch-l-message-gap, 0.75rem);margin-left:calc(var(--gov-form-switch-l-indicator-height, 2rem) * 1.6666666667 + var(--gov-form-switch-l-gap, 1rem))}.gov-form-control[invalid=""] .gov-form-label[slot=top] .gov-form-label__label,.gov-form-control[invalid=true i] .gov-form-label[slot=top] .gov-form-label__label,.gov-form-control[invalid="1"] .gov-form-label[slot=top] .gov-form-label__label{color:var(--gov-form-state-color-error, var(--gov-color-error))}.gov-form-control[disabled=""] .gov-form-label__label,.gov-form-control[disabled=true i] .gov-form-label__label,.gov-form-control[disabled="1"] .gov-form-label__label{pointer-events:none}';const g=class{constructor(r){o(this,r);this.gap=undefined;this.identifier=undefined;this.invalid=false;this.disabled=false;this.success=false;this.fieldset=false;this.size="m";this.h=m(this.host);this.f=i(this.h);this.controlId=a("GovFormControl")}watchInvalid(){this.passChildAttrs()}componentDidRender(){this.passChildAttrs();this.syncControlMessages();this.formElementDescriptionControl()}disconnectedCallback(){var o;(o=this.observer)===null||o===void 0?void 0:o.disconnect()}passChildAttrs(){const o=["gov-form-select","gov-form-input","gov-form-switch","gov-form-checkbox","gov-form-radio","gov-form-multi-select","gov-form-file","gov-form-search"];this.h.passChildAttr(o,"size",this.size);this.h.passChildAttr(o,"invalid",this.invalid);this.h.passChildAttr(o,"disabled",this.disabled);this.h.passChildAttr(o,"success",this.success);if(this.f.hasGroupChildren===false){this.h.passChildAttr([...o,"gov-form-label"],"identifier",this.identifier||this.controlId)}}formElementDescriptionControl(){const o=this.host.querySelector("."+s.bottom);if(!o)return;this.observer=new MutationObserver(function(){this.syncControlMessages()}.bind(this));this.observer.observe(o,{childList:true})}syncControlMessages(){Promise.all(this.f.messageElements.map((o=>o.identifier()))).then((o=>{this.f.mainElementsInControl.forEach((r=>{const t=l(r.getAttribute("wcag-described-by"));r.removeAttribute("wcag-described-by");if(Array.isArray(t)){t.forEach((r=>r.indexOf("GovFormMessage")===-1?o.push(r):null))}if(o.length){r.setAttribute("wcag-described-by",o.join(" "))}}))}))}render(){const o=this.fieldset?"fieldset":"div";return r(t,{size:this.size,class:this.h.classes(s.root)},r(o,{class:s.holder},this.h.hasSlot("top")&&r("slot",{name:"top"}),r("slot",null),this.h.hasSlot("bottom")&&r("div",{class:s.bottom},r("slot",{name:"bottom"}))))}get host(){return e(this)}static get watchers(){return{invalid:["watchInvalid"]}}};g.style=c;export{g as gov_form_control};
2
- //# sourceMappingURL=p-d83b4bdc.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../packages/core/src/components/gov-form/control/gov-form-control.scss?tag=gov-form-control","../../../packages/core/src/components/gov-form/control/gov-form-control.tsx"],"names":["govFormControlCss","GovFormControl","[object Object]","hostRef","this","h","govHost","host","f","govForm","controlId","createID","passChildAttrs","syncControlMessages","formElementDescriptionControl","_a","observer","disconnect","formElements","passChildAttr","size","invalid","disabled","success","hasGroupChildren","identifier","bottomSlot","querySelector","FormControlClass","bottom","MutationObserver","bind","observe","childList","Promise","all","messageElements","map","message","then","ids","mainElementsInControl","forEach","element","currentValue","splitByWhitespace","getAttribute","removeAttribute","Array","isArray","id","indexOf","push","length","setAttribute","join","Tag","fieldset","Host","class","classes","root","holder","hasSlot","name"],"mappings":"2VAAA,MAAMA,EAAoB,uvHCYbC,EAAc,MAM1BC,YAAAC,uEAiBoC,oBAKC,mBAKD,oBAKC,gBAIU,IAnC9CC,KAAKC,EAAIC,EAAQF,KAAKG,MACtBH,KAAKI,EAAIC,EAAQL,KAAKC,GACtBD,KAAKM,UAAYC,EAAS,kBAsC3BT,eACCE,KAAKQ,iBAGNV,qBACCE,KAAKQ,iBACLR,KAAKS,sBACLT,KAAKU,gCAGNZ,8BACCa,EAAAX,KAAKY,YAAQ,MAAAD,SAAA,OAAA,EAAAA,EAAEE,aAGRf,iBACP,MAAMgB,EAAe,CACpB,kBACA,iBACA,kBACA,oBACA,iBACA,wBACA,gBACA,mBAEDd,KAAKC,EAAEc,cAAcD,EAAc,OAAQd,KAAKgB,MAChDhB,KAAKC,EAAEc,cAAcD,EAAc,UAAWd,KAAKiB,SACnDjB,KAAKC,EAAEc,cAAcD,EAAc,WAAYd,KAAKkB,UACpDlB,KAAKC,EAAEc,cAAcD,EAAc,UAAWd,KAAKmB,SAEnD,GAAInB,KAAKI,EAAEgB,mBAAqB,MAAO,CACtCpB,KAAKC,EAAEc,cAAc,IAAID,EAAc,kBAAmB,aAAcd,KAAKqB,YAAcrB,KAAKM,YAI1FR,gCACP,MAAMwB,EAAatB,KAAKG,KAAKoB,cAAc,IAAMC,EAAiBC,QAClE,IAAKH,EAAY,OACjBtB,KAAKY,SAAW,IAAIc,iBACnB,WACC1B,KAAKS,uBACJkB,KAAK3B,OAGRA,KAAKY,SAASgB,QAAQN,EAAY,CAAEO,UAAW,OAGxC/B,sBACPgC,QAAQC,IAAI/B,KAAKI,EAAE4B,gBAAgBC,KAAKC,GAAuCA,EAAQb,gBAAec,MAAMC,IAC3GpC,KAAKI,EAAEiC,sBAAsBC,SAASC,IACrC,MAAMC,EAAeC,EAAkBF,EAAQG,aAAa,sBAC5DH,EAAQI,gBAAgB,qBACxB,GAAIC,MAAMC,QAAQL,GAAe,CAChCA,EAAaF,SAAQQ,GAAOA,EAAGC,QAAQ,qBAAuB,EAAIX,EAAIY,KAAKF,GAAM,OAElF,GAAIV,EAAIa,OAAQ,CACfV,EAAQW,aAAa,oBAAqBd,EAAIe,KAAK,aAMvDrD,SACC,MAAMsD,EAAMpD,KAAKqD,SAAW,WAAa,MACzC,OACCpD,EAACqD,EAAI,CAACtC,KAAMhB,KAAKgB,KAAMuC,MAAOvD,KAAKC,EAAEuD,QAAQhC,EAAiBiC,OAC7DxD,EAACmD,EAAG,CAACG,MAAO/B,EAAiBkC,QAC3B1D,KAAKC,EAAE0D,QAAQ,QAAU1D,EAAA,OAAA,CAAM2D,KAAK,QACrC3D,EAAA,OAAA,MACCD,KAAKC,EAAE0D,QAAQ,WACf1D,EAAA,MAAA,CAAKsD,MAAO/B,EAAiBC,QAC5BxB,EAAA,OAAA,CAAM2D,KAAK","sourcesContent":["/*\n * Form Control\n */\n\n$class: \".gov-form-control\";\n\n#{$class} {\n\t&__holder {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tpadding: 0;\n\t\tborder: none;\n\t}\n\t&__bottom {\n\t\t@include reset-last-margin();\n\t}\n\n\t// VARIANTS\n\t&[type=\"file\"] {\n\t\t.gov-form-label[slot=\"top\"] .gov-form-label__label {\n\t\t\tmargin: rem-calc(0 0 8);\n\t\t}\n\t\t#{$class} {\n\t\t\t&__bottom {\n\t\t\t\tmargin: rem-calc(8 0 0);\n\t\t\t}\n\t\t}\n\t}\n\t&[type=\"input\"],\n\t&[type=\"select\"],\n\t&[type=\"textarea\"] {\n\t\t.gov-form-label .gov-form-label__label {\n\t\t\tmargin: rem-calc(0 0 4);\n\t\t}\n\t\t#{$class} {\n\t\t\t&__bottom {\n\t\t\t\tmargin: rem-calc(4 0 0);\n\t\t\t}\n\t\t}\n\t}\n\t// Checkbox, radio\n\t@each $size, $definitions in $form-checkbox-core-sizes {\n\t\t&[size=\"#{$size}\"][type=\"checkbox\"],\n\t\t&[size=\"#{$size}\"][type=\"radio\"] {\n\t\t\t#{$class} {\n\t\t\t\t$indicator-width: get(\"indicator-size\", $definitions);\n\t\t\t\t&__bottom {\n\t\t\t\t\tmargin-top: get(\"message-gap\", $definitions);\n\t\t\t\t\tmargin-left: calc($indicator-width + get(\"gap\", $definitions));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// Switch\n\t@each $size, $definitions in $form-switch-sizes {\n\t\t&[size=\"#{$size}\"][type=\"switch\"] {\n\t\t\t#{$class} {\n\t\t\t\t$indicator-ratio: calc(5 / 3);\n\t\t\t\t$indicator-width: calc(get(\"indicator-height\", $definitions) * $indicator-ratio);\n\t\t\t\t&__bottom {\n\t\t\t\t\tmargin-top: get(\"message-gap\", $definitions);\n\t\t\t\t\tmargin-left: calc($indicator-width + get(\"gap\", $definitions));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// STATES\n\t@include parameter(\"invalid\") {\n\t\t.gov-form-label[slot=\"top\"] .gov-form-label__label {\n\t\t\tcolor: $form-state-color-error;\n\t\t}\n\t}\n\t@include parameter(\"disabled\") {\n\t\t.gov-form-label__label {\n\t\t\tpointer-events: none;\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch } from '@stencil/core'\nimport { GovHost } from '../../../helpers/Dom/template.types'\nimport { GovForm } from '../../../helpers/Dom/form.types'\nimport { govHost } from '../../../helpers/Dom/template'\nimport { govForm } from '../../../helpers/Dom/form'\nimport { createID, splitByWhitespace } from '../../../utils/string.utils'\nimport { FormControlSizesType, FormControlClass } from './constants'\n\n@Component({\n\ttag: 'gov-form-control',\n\tstyleUrl: 'gov-form-control.scss',\n})\nexport class GovFormControl {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate readonly controlId: string\n\tprivate observer: MutationObserver\n\n\tconstructor() {\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t\tthis.controlId = createID('GovFormControl')\n\t}\n\n\t/**\n\t * Defines the space between nested components.\n\t */\n\t@Prop() readonly gap?: FormControlSizesType\n\t/**\n\t * Form element identifier\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Indicates the entered value of child form element does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean = false\n\t/**\n\t/**\n\t * Indicates the form element is disabled\n\t */\n\t@Prop() readonly disabled: boolean = false\n\t/**\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean = false\n\t/**\n\t * Use control as a fieldset for better accessibility.\n\t * Note: Don't forget to set the legend attribute of the gov-form-label component\n\t */\n\t@Prop() readonly fieldset: boolean = false\n\t/**\n\t * Form element size.\n\t */\n\t@Prop() readonly size?: FormControlSizesType = 'm'\n\n\t@Element() host: HTMLGovFormControlElement\n\n\t@Watch('invalid')\n\twatchInvalid(): void {\n\t\tthis.passChildAttrs()\n\t}\n\n\tcomponentDidRender() {\n\t\tthis.passChildAttrs()\n\t\tthis.syncControlMessages()\n\t\tthis.formElementDescriptionControl()\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tthis.observer?.disconnect()\n\t}\n\n\tprivate passChildAttrs() {\n\t\tconst formElements = [\n\t\t\t'gov-form-select',\n\t\t\t'gov-form-input',\n\t\t\t'gov-form-switch',\n\t\t\t'gov-form-checkbox',\n\t\t\t'gov-form-radio',\n\t\t\t'gov-form-multi-select',\n\t\t\t'gov-form-file',\n\t\t\t'gov-form-search',\n\t\t]\n\t\tthis.h.passChildAttr(formElements, 'size', this.size)\n\t\tthis.h.passChildAttr(formElements, 'invalid', this.invalid)\n\t\tthis.h.passChildAttr(formElements, 'disabled', this.disabled)\n\t\tthis.h.passChildAttr(formElements, 'success', this.success)\n\n\t\tif (this.f.hasGroupChildren === false) {\n\t\t\tthis.h.passChildAttr([...formElements, 'gov-form-label'], 'identifier', this.identifier || this.controlId)\n\t\t}\n\t}\n\n\tprivate formElementDescriptionControl() {\n\t\tconst bottomSlot = this.host.querySelector('.' + FormControlClass.bottom)\n\t\tif (!bottomSlot) return\n\t\tthis.observer = new MutationObserver(\n\t\t\tfunction () {\n\t\t\t\tthis.syncControlMessages()\n\t\t\t}.bind(this)\n\t\t)\n\n\t\tthis.observer.observe(bottomSlot, { childList: true })\n\t}\n\n\tprivate syncControlMessages() {\n\t\tPromise.all(this.f.messageElements.map((message: HTMLGovFormMessageElement) => message.identifier())).then((ids: string[]) => {\n\t\t\tthis.f.mainElementsInControl.forEach((element: Element) => {\n\t\t\t\tconst currentValue = splitByWhitespace(element.getAttribute('wcag-described-by'))\n\t\t\t\telement.removeAttribute('wcag-described-by')\n\t\t\t\tif (Array.isArray(currentValue)) {\n\t\t\t\t\tcurrentValue.forEach(id => (id.indexOf('GovFormMessage') === -1 ? ids.push(id) : null))\n\t\t\t\t}\n\t\t\t\tif (ids.length) {\n\t\t\t\t\telement.setAttribute('wcag-described-by', ids.join(' '))\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n\trender() {\n\t\tconst Tag = this.fieldset ? 'fieldset' : 'div'\n\t\treturn (\n\t\t\t<Host size={this.size} class={this.h.classes(FormControlClass.root)}>\n\t\t\t\t<Tag class={FormControlClass.holder}>\n\t\t\t\t\t{this.h.hasSlot('top') && <slot name=\"top\"></slot>}\n\t\t\t\t\t<slot></slot>\n\t\t\t\t\t{this.h.hasSlot('bottom') && (\n\t\t\t\t\t\t<div class={FormControlClass.bottom}>\n\t\t\t\t\t\t\t<slot name=\"bottom\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</Tag>\n\t\t\t</Host>\n\t\t)\n\t}\n}\n"]}