@gov-design-system-ce/components 0.0.10 → 0.0.12

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 (279) hide show
  1. package/dist/cjs/constants-97eea364.js +14 -0
  2. package/dist/cjs/constants-97eea364.js.map +1 -0
  3. package/dist/cjs/core.cjs.js +1 -1
  4. package/dist/cjs/{form-02872a5e.js → form-9b8b1740.js} +6 -2
  5. package/dist/cjs/form-9b8b1740.js.map +1 -0
  6. package/dist/cjs/gov-app.cjs.entry.js +3 -2
  7. package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
  8. package/dist/cjs/gov-button.cjs.entry.js +0 -2
  9. package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
  10. package/dist/cjs/gov-form-autocomplete.cjs.entry.js +0 -4
  11. package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
  12. package/dist/cjs/gov-form-checkbox.cjs.entry.js +2 -5
  13. package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
  14. package/dist/cjs/gov-form-control.cjs.entry.js +2 -2
  15. package/dist/cjs/gov-form-file.cjs.entry.js +2 -5
  16. package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
  17. package/dist/cjs/gov-form-input.cjs.entry.js +2 -6
  18. package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
  19. package/dist/cjs/gov-form-label.cjs.entry.js +5 -2
  20. package/dist/cjs/gov-form-label.cjs.entry.js.map +1 -1
  21. package/dist/cjs/gov-form-multi-select.cjs.entry.js +0 -4
  22. package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
  23. package/dist/cjs/gov-form-radio.cjs.entry.js +2 -5
  24. package/dist/cjs/gov-form-radio.cjs.entry.js.map +1 -1
  25. package/dist/cjs/gov-form-select.cjs.entry.js +2 -2
  26. package/dist/cjs/gov-form-switch.cjs.entry.js +2 -4
  27. package/dist/cjs/gov-form-switch.cjs.entry.js.map +1 -1
  28. package/dist/cjs/gov-icon.cjs.entry.js +1 -1
  29. package/dist/cjs/gov-pagination.cjs.entry.js +0 -2
  30. package/dist/cjs/gov-pagination.cjs.entry.js.map +1 -1
  31. package/dist/cjs/gov-tooltip.cjs.entry.js +2 -2
  32. package/dist/cjs/gov-tooltip.cjs.entry.js.map +1 -1
  33. package/dist/cjs/loader.cjs.js +1 -1
  34. package/dist/collection/components/gov-button/gov-button.js +0 -2
  35. package/dist/collection/components/gov-button/gov-button.js.map +1 -1
  36. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +0 -4
  37. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
  38. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js +0 -3
  39. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js.map +1 -1
  40. package/dist/collection/components/gov-form/file/gov-form-file.js +0 -3
  41. package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
  42. package/dist/collection/components/gov-form/input/gov-form-input.js +0 -4
  43. package/dist/collection/components/gov-form/input/gov-form-input.js.map +1 -1
  44. package/dist/collection/components/gov-form/label/constants.js +3 -0
  45. package/dist/collection/components/gov-form/label/constants.js.map +1 -1
  46. package/dist/collection/components/gov-form/label/gov-form-label.js +26 -2
  47. package/dist/collection/components/gov-form/label/gov-form-label.js.map +1 -1
  48. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +0 -4
  49. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
  50. package/dist/collection/components/gov-form/radio/gov-form-radio.js +0 -3
  51. package/dist/collection/components/gov-form/radio/gov-form-radio.js.map +1 -1
  52. package/dist/collection/components/gov-form/switch/gov-form-switch.js +0 -2
  53. package/dist/collection/components/gov-form/switch/gov-form-switch.js.map +1 -1
  54. package/dist/collection/components/gov-pagination/gov-pagination.js +0 -2
  55. package/dist/collection/components/gov-pagination/gov-pagination.js.map +1 -1
  56. package/dist/collection/components/gov-tooltip/gov-tooltip.js +2 -2
  57. package/dist/collection/components/gov-tooltip/gov-tooltip.js.map +1 -1
  58. package/dist/collection/helpers/Dom/form.js +4 -0
  59. package/dist/collection/helpers/Dom/form.js.map +1 -1
  60. package/dist/collection/pages/Forms.js +3 -2
  61. package/dist/collection/pages/Forms.js.map +1 -1
  62. package/dist/components/constants4.js +4 -0
  63. package/dist/components/constants4.js.map +1 -1
  64. package/dist/components/form.js +4 -0
  65. package/dist/components/form.js.map +1 -1
  66. package/dist/components/gov-accordion-item.js +0 -1
  67. package/dist/components/gov-accordion-item.js.map +1 -1
  68. package/dist/components/gov-accordion.js +0 -1
  69. package/dist/components/gov-accordion.js.map +1 -1
  70. package/dist/components/gov-alert.js +0 -1
  71. package/dist/components/gov-alert.js.map +1 -1
  72. package/dist/components/gov-app.js +3 -3
  73. package/dist/components/gov-app.js.map +1 -1
  74. package/dist/components/gov-attachments-item2.js +0 -1
  75. package/dist/components/gov-attachments-item2.js.map +1 -1
  76. package/dist/components/gov-attachments2.js +0 -1
  77. package/dist/components/gov-attachments2.js.map +1 -1
  78. package/dist/components/gov-backdrop2.js +0 -1
  79. package/dist/components/gov-backdrop2.js.map +1 -1
  80. package/dist/components/gov-badge2.js +0 -1
  81. package/dist/components/gov-badge2.js.map +1 -1
  82. package/dist/components/gov-breadcrumbs.js +0 -1
  83. package/dist/components/gov-breadcrumbs.js.map +1 -1
  84. package/dist/components/gov-button2.js +0 -3
  85. package/dist/components/gov-button2.js.map +1 -1
  86. package/dist/components/gov-card.js +0 -1
  87. package/dist/components/gov-card.js.map +1 -1
  88. package/dist/components/gov-container.js +0 -1
  89. package/dist/components/gov-container.js.map +1 -1
  90. package/dist/components/gov-cookiebar.js +0 -1
  91. package/dist/components/gov-cookiebar.js.map +1 -1
  92. package/dist/components/gov-empty.js +0 -1
  93. package/dist/components/gov-empty.js.map +1 -1
  94. package/dist/components/gov-error-code.js +0 -1
  95. package/dist/components/gov-error-code.js.map +1 -1
  96. package/dist/components/gov-form-autocomplete2.js +0 -5
  97. package/dist/components/gov-form-autocomplete2.js.map +1 -1
  98. package/dist/components/gov-form-checkbox.js +0 -4
  99. package/dist/components/gov-form-checkbox.js.map +1 -1
  100. package/dist/components/gov-form-control.js +0 -1
  101. package/dist/components/gov-form-control.js.map +1 -1
  102. package/dist/components/gov-form-file.js +0 -4
  103. package/dist/components/gov-form-file.js.map +1 -1
  104. package/dist/components/gov-form-group.js +0 -1
  105. package/dist/components/gov-form-group.js.map +1 -1
  106. package/dist/components/gov-form-input2.js +0 -5
  107. package/dist/components/gov-form-input2.js.map +1 -1
  108. package/dist/components/gov-form-label.js +3 -2
  109. package/dist/components/gov-form-label.js.map +1 -1
  110. package/dist/components/gov-form-message2.js +0 -1
  111. package/dist/components/gov-form-message2.js.map +1 -1
  112. package/dist/components/gov-form-multi-select.js +0 -5
  113. package/dist/components/gov-form-multi-select.js.map +1 -1
  114. package/dist/components/gov-form-password-power.js +0 -1
  115. package/dist/components/gov-form-password-power.js.map +1 -1
  116. package/dist/components/gov-form-radio.js +0 -4
  117. package/dist/components/gov-form-radio.js.map +1 -1
  118. package/dist/components/gov-form-search.js +0 -1
  119. package/dist/components/gov-form-search.js.map +1 -1
  120. package/dist/components/gov-form-select2.js +0 -1
  121. package/dist/components/gov-form-select2.js.map +1 -1
  122. package/dist/components/gov-form-switch.js +0 -3
  123. package/dist/components/gov-form-switch.js.map +1 -1
  124. package/dist/components/gov-grid-item.js +0 -1
  125. package/dist/components/gov-grid-item.js.map +1 -1
  126. package/dist/components/gov-grid.js +0 -1
  127. package/dist/components/gov-grid.js.map +1 -1
  128. package/dist/components/gov-icon2.js +1 -2
  129. package/dist/components/gov-icon2.js.map +1 -1
  130. package/dist/components/gov-layout-column.js +0 -1
  131. package/dist/components/gov-layout-column.js.map +1 -1
  132. package/dist/components/gov-layout.js +0 -1
  133. package/dist/components/gov-layout.js.map +1 -1
  134. package/dist/components/gov-loading.js +0 -1
  135. package/dist/components/gov-loading.js.map +1 -1
  136. package/dist/components/gov-message.js +0 -1
  137. package/dist/components/gov-message.js.map +1 -1
  138. package/dist/components/gov-modal.js +0 -1
  139. package/dist/components/gov-modal.js.map +1 -1
  140. package/dist/components/gov-nav-item.js +0 -1
  141. package/dist/components/gov-nav-item.js.map +1 -1
  142. package/dist/components/gov-nav.js +0 -1
  143. package/dist/components/gov-nav.js.map +1 -1
  144. package/dist/components/gov-pagination.js +0 -3
  145. package/dist/components/gov-pagination.js.map +1 -1
  146. package/dist/components/gov-prompt.js +0 -1
  147. package/dist/components/gov-prompt.js.map +1 -1
  148. package/dist/components/gov-side-nav-item.js +0 -1
  149. package/dist/components/gov-side-nav-item.js.map +1 -1
  150. package/dist/components/gov-side-nav.js +0 -1
  151. package/dist/components/gov-side-nav.js.map +1 -1
  152. package/dist/components/gov-spacer.js +0 -1
  153. package/dist/components/gov-spacer.js.map +1 -1
  154. package/dist/components/gov-statsbar-item.js +0 -1
  155. package/dist/components/gov-statsbar-item.js.map +1 -1
  156. package/dist/components/gov-statsbar.js +0 -1
  157. package/dist/components/gov-statsbar.js.map +1 -1
  158. package/dist/components/gov-stepper-item.js +0 -1
  159. package/dist/components/gov-stepper-item.js.map +1 -1
  160. package/dist/components/gov-stepper.js +0 -1
  161. package/dist/components/gov-stepper.js.map +1 -1
  162. package/dist/components/gov-tabs-item.js +0 -1
  163. package/dist/components/gov-tabs-item.js.map +1 -1
  164. package/dist/components/gov-tabs.js +0 -1
  165. package/dist/components/gov-tabs.js.map +1 -1
  166. package/dist/components/gov-tile.js +0 -1
  167. package/dist/components/gov-tile.js.map +1 -1
  168. package/dist/components/gov-tiles.js +0 -1
  169. package/dist/components/gov-tiles.js.map +1 -1
  170. package/dist/components/gov-toast.js +0 -1
  171. package/dist/components/gov-toast.js.map +1 -1
  172. package/dist/components/gov-tooltip-content.js +0 -1
  173. package/dist/components/gov-tooltip-content.js.map +1 -1
  174. package/dist/components/gov-tooltip.js +2 -3
  175. package/dist/components/gov-tooltip.js.map +1 -1
  176. package/dist/components/gov-wizzard-item.js +0 -1
  177. package/dist/components/gov-wizzard-item.js.map +1 -1
  178. package/dist/components/gov-wizzard.js +0 -1
  179. package/dist/components/gov-wizzard.js.map +1 -1
  180. package/dist/core/core.esm.js +1 -1
  181. package/dist/core/core.esm.js.map +1 -1
  182. package/dist/core/{p-6fd0c41d.entry.js → p-02c1b4db.entry.js} +2 -2
  183. package/dist/core/p-3464136c.js +2 -0
  184. package/dist/core/p-3464136c.js.map +1 -0
  185. package/dist/core/{p-35c42aea.entry.js → p-43811261.entry.js} +2 -2
  186. package/dist/core/{p-35c42aea.entry.js.map → p-43811261.entry.js.map} +1 -1
  187. package/dist/core/{p-9ceeba49.entry.js → p-4e12d6e3.entry.js} +2 -2
  188. package/dist/core/p-4e12d6e3.entry.js.map +1 -0
  189. package/dist/core/{p-e582a589.entry.js → p-533bd158.entry.js} +2 -2
  190. package/dist/core/{p-cc37a226.entry.js → p-595a2301.entry.js} +2 -2
  191. package/dist/core/p-595a2301.entry.js.map +1 -0
  192. package/dist/core/p-8d5c9030.entry.js +2 -0
  193. package/dist/core/p-8d5c9030.entry.js.map +1 -0
  194. package/dist/core/{p-bba09987.entry.js → p-9658b6ef.entry.js} +2 -2
  195. package/dist/core/p-9658b6ef.entry.js.map +1 -0
  196. package/dist/core/p-9ba104c3.entry.js +2 -0
  197. package/dist/core/p-9ba104c3.entry.js.map +1 -0
  198. package/dist/core/{p-af40ceef.js → p-9cd80b05.js} +2 -2
  199. package/dist/core/p-9cd80b05.js.map +1 -0
  200. package/dist/core/{p-1db2ac17.entry.js → p-9d51ea56.entry.js} +2 -2
  201. package/dist/core/{p-04fc18ab.entry.js → p-ae3e2d60.entry.js} +2 -2
  202. package/dist/core/p-ae3e2d60.entry.js.map +1 -0
  203. package/dist/core/{p-9c844f4d.entry.js → p-b37ca132.entry.js} +2 -2
  204. package/dist/core/p-b37ca132.entry.js.map +1 -0
  205. package/dist/core/{p-44dc2ef4.entry.js → p-b5284ce3.entry.js} +2 -2
  206. package/dist/core/p-b5284ce3.entry.js.map +1 -0
  207. package/dist/core/{p-f759342e.entry.js → p-d2d8998d.entry.js} +2 -2
  208. package/dist/core/p-d2d8998d.entry.js.map +1 -0
  209. package/dist/core/{p-851939ff.entry.js → p-e86bffd0.entry.js} +2 -2
  210. package/dist/core/p-e86bffd0.entry.js.map +1 -0
  211. package/dist/core/p-ef095a1f.entry.js +2 -0
  212. package/dist/core/p-ef095a1f.entry.js.map +1 -0
  213. package/dist/custom-elements/index.js +1 -1
  214. package/dist/custom-elements/index.js.map +1 -1
  215. package/dist/esm/constants-ebec7de8.js +12 -0
  216. package/dist/esm/constants-ebec7de8.js.map +1 -0
  217. package/dist/esm/core.js +1 -1
  218. package/dist/esm/{form-e2e12619.js → form-669a7180.js} +6 -2
  219. package/dist/esm/form-669a7180.js.map +1 -0
  220. package/dist/esm/gov-app.entry.js +3 -2
  221. package/dist/esm/gov-app.entry.js.map +1 -1
  222. package/dist/esm/gov-button.entry.js +0 -2
  223. package/dist/esm/gov-button.entry.js.map +1 -1
  224. package/dist/esm/gov-form-autocomplete.entry.js +0 -4
  225. package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
  226. package/dist/esm/gov-form-checkbox.entry.js +2 -5
  227. package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
  228. package/dist/esm/gov-form-control.entry.js +2 -2
  229. package/dist/esm/gov-form-file.entry.js +2 -5
  230. package/dist/esm/gov-form-file.entry.js.map +1 -1
  231. package/dist/esm/gov-form-input.entry.js +2 -6
  232. package/dist/esm/gov-form-input.entry.js.map +1 -1
  233. package/dist/esm/gov-form-label.entry.js +5 -2
  234. package/dist/esm/gov-form-label.entry.js.map +1 -1
  235. package/dist/esm/gov-form-multi-select.entry.js +0 -4
  236. package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
  237. package/dist/esm/gov-form-radio.entry.js +2 -5
  238. package/dist/esm/gov-form-radio.entry.js.map +1 -1
  239. package/dist/esm/gov-form-select.entry.js +2 -2
  240. package/dist/esm/gov-form-switch.entry.js +2 -4
  241. package/dist/esm/gov-form-switch.entry.js.map +1 -1
  242. package/dist/esm/gov-icon.entry.js +1 -1
  243. package/dist/esm/gov-pagination.entry.js +0 -2
  244. package/dist/esm/gov-pagination.entry.js.map +1 -1
  245. package/dist/esm/gov-tooltip.entry.js +2 -2
  246. package/dist/esm/gov-tooltip.entry.js.map +1 -1
  247. package/dist/esm/loader.js +1 -1
  248. package/dist/hydrate/index.js +13 -32
  249. package/dist/types/components/gov-form/label/constants.d.ts +4 -0
  250. package/dist/types/components/gov-form/label/gov-form-label.d.ts +5 -0
  251. package/dist/types/components/gov-tooltip/gov-tooltip.d.ts +1 -1
  252. package/dist/types/components.d.ts +9 -0
  253. package/package.json +1 -1
  254. package/dist/cjs/constants-736bf980.js +0 -10
  255. package/dist/cjs/constants-736bf980.js.map +0 -1
  256. package/dist/cjs/form-02872a5e.js.map +0 -1
  257. package/dist/core/p-04fc18ab.entry.js.map +0 -1
  258. package/dist/core/p-159c9835.entry.js +0 -2
  259. package/dist/core/p-159c9835.entry.js.map +0 -1
  260. package/dist/core/p-27977727.js +0 -2
  261. package/dist/core/p-27977727.js.map +0 -1
  262. package/dist/core/p-44dc2ef4.entry.js.map +0 -1
  263. package/dist/core/p-6b69dbd3.entry.js +0 -2
  264. package/dist/core/p-6b69dbd3.entry.js.map +0 -1
  265. package/dist/core/p-6b928a53.entry.js +0 -2
  266. package/dist/core/p-6b928a53.entry.js.map +0 -1
  267. package/dist/core/p-851939ff.entry.js.map +0 -1
  268. package/dist/core/p-9c844f4d.entry.js.map +0 -1
  269. package/dist/core/p-9ceeba49.entry.js.map +0 -1
  270. package/dist/core/p-af40ceef.js.map +0 -1
  271. package/dist/core/p-bba09987.entry.js.map +0 -1
  272. package/dist/core/p-cc37a226.entry.js.map +0 -1
  273. package/dist/core/p-f759342e.entry.js.map +0 -1
  274. package/dist/esm/constants-5c1382a4.js +0 -8
  275. package/dist/esm/constants-5c1382a4.js.map +0 -1
  276. package/dist/esm/form-e2e12619.js.map +0 -1
  277. /package/dist/core/{p-6fd0c41d.entry.js.map → p-02c1b4db.entry.js.map} +0 -0
  278. /package/dist/core/{p-e582a589.entry.js.map → p-533bd158.entry.js.map} +0 -0
  279. /package/dist/core/{p-1db2ac17.entry.js.map → p-9d51ea56.entry.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{r as t,c as i,h as e,H as s,g as o}from"./p-682c7cc6.js";import{c as a}from"./p-24636c53.js";import{F as r,a as h,b as n}from"./p-f687452c.js";import{v as l}from"./p-26acf964.js";import{t as m,h as c}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 f='.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)}}.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 p=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(h,t,r.root)}validateSize(t){l(n,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":m(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();t.preventDefault();this.govFocus.emit(t)}onBlurHandler(t){this.focused=false;setTimeout((()=>this.list=[]),200);this.arrowCounter=-1;t.stopPropagation();t.preventDefault();this.govBlur.emit(t)}onInputHandler(t){this.value=t.target.value;t.stopPropagation();t.preventDefault();this.govInput.emit(t);this.doSearch()}onSelectHandler(t=-1){let i=null;if(t>-1){i=this.list[t]}else if(c(this.arrowCounter,this.list)){i=this.list[this.arrowCounter]}if(i){this.govSelect.emit(i);this.list=[];if(c(this.nameKey,i)&&typeof i[this.nameKey]==="string"){this.value=i[this.nameKey]}}}onKeyUpHandler(t){const i=t.detail;t.stopPropagation();t.preventDefault();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"]}}};p.style=f;export{p as gov_form_autocomplete};
2
- //# sourceMappingURL=p-04fc18ab.entry.js.map
1
+ import{r as t,c as i,h as e,H as s,g as o}from"./p-682c7cc6.js";import{c as a}from"./p-24636c53.js";import{F as r,a as h,b as n}from"./p-f687452c.js";import{v as l}from"./p-26acf964.js";import{t as m,h as c}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 f='.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)}}.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 p=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(h,t,r.root)}validateSize(t){l(n,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":m(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(t)}onBlurHandler(t){this.focused=false;setTimeout((()=>this.list=[]),200);this.arrowCounter=-1;t.stopPropagation();this.govBlur.emit(t)}onInputHandler(t){this.value=t.target.value;t.stopPropagation();this.govInput.emit(t);this.doSearch()}onSelectHandler(t=-1){let i=null;if(t>-1){i=this.list[t]}else if(c(this.arrowCounter,this.list)){i=this.list[this.arrowCounter]}if(i){this.govSelect.emit(i);this.list=[];if(c(this.nameKey,i)&&typeof i[this.nameKey]==="string"){this.value=i[this.nameKey]}}}onKeyUpHandler(t){const i=t.detail;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"]}}};p.style=f;export{p as gov_form_autocomplete};
2
+ //# sourceMappingURL=p-ae3e2d60.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.scss?tag=gov-form-autocomplete","../../../packages/core/src/components/gov-form/autocomplete/gov-form-autocomplete.tsx"],"names":["govFormAutocompleteCss","GovFormAutocomplete","[object Object]","hostRef","this","templateResolver","item","nameKey","listBoxId","createID","newValue","validateProp","FormAutocompleteVariants","FormAutocompleteClass","root","FormAutocompleteSizes","arrowCounter","list","length","Number","isInteger","minlength","String","value","processing","searchCallback","then","response","catch","finally","validateVariant","variant","validateSize","size","h","Host","class","placeholder","name","disabled","readonly","autocomplete","required","invalid","role","maxlength","on-gov-input","throttle","onInputHandler","bind","on-gov-keyup","onKeyUpHandler","on-gov-focus","onFocusHandler","on-gov-blur","onBlurHandler","wcagAutocomplete","wcagDescribedBy","wcagLabelledBy","wcagOwns","join","wcagExpanded","focused","ref","el","inputRef","slot","id","map","index","isSelected","innerHTML","aria-posinset","tabindex","aria-setsize","onClick","onSelectHandler","aria-selected","toBoolAttr","e","doSearch","stopPropagation","govFocus","emit","setTimeout","govBlur","target","govInput","selected","has","govSelect","event","detail","keyCode","onArrowUp","onArrowDown","options","focus","clearValue","callback"],"mappings":"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","sourcesContent":["$class: \".gov-form-autocomplete\";\n\n#{$class} {\n\t@include base();\n\t&__list {\n\t\t@include typography($font-size-s);\n\t\t@extend %reset-ul;\n\t\tposition: absolute;\n\t\ttop: 100%;\n\t\tright: 0;\n\t\tleft: 0;\n\t\tz-index: 5;\n\t\tmax-height: rem-calc(225);\n\t\tmargin-top: rem-calc(8);\n\t\tborder: $form-autocomplete-border;\n\t\tborder-radius: $border-radius;\n\t\tbackground: $form-autocomplete-bg;\n\t\toverflow-x: hidden;\n\t\toverflow-y: auto;\n\t\toverscroll-behavior: none;\n\t}\n\t&__list > &__item {\n\t\t@extend %reset-ul-li;\n\t\tpadding: rem-calc(12 8);\n\t\tcursor: pointer;\n\t}\n\n\t// STATES\n\t&__list:empty {\n\t\tdisplay: none;\n\t}\n\n\t// HOVERS\n\t&__item {\n\t\t@include parameter(\"aria-selected\") {\n\t\t\tbackground: $form-autocomplete-item-select-bg;\n\t\t}\n\t\t@include hover() {\n\t\t\tbackground: $form-autocomplete-item-hover-bg;\n\t\t}\n\t}\n}\n","import { Component, Element, Host, h, Prop, Watch, Event, EventEmitter, State, Method } from '@stencil/core'\nimport { SizesType } from './constants'\nimport { createID } from '../../../utils/string.utils'\nimport { FormAutocompleteClass, FormAutocompleteVariants, VariantType, FormAutocompleteSizes } from './constants'\nimport { validateProp } from '../../../helpers/Validate/props'\nimport { has, throttle } from '../../../utils/utils'\nimport { GovFormAutocompleteItem } from './gov-form-autocomplete.types'\nimport { toBoolAttr } from '../../../helpers/Dom/template'\nimport { Nullable } from '../../../types/interfaces'\n\n@Component({\n\ttag: 'gov-form-autocomplete',\n\tstyleUrl: 'gov-form-autocomplete.scss',\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\n\tconstructor() {\n\t\tthis.listBoxId = createID('GovListBox')\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value = ''\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: 'identifier' }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: VariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = 'm'\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop() readonly nameKey: string = 'name'\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 2\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: 'wcag-described-by' }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: 'wcag-labelled-by' }) readonly wcagLabelledBy: string\n\t/**\n\t * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-owns\n\t */\n\t@Prop({ attribute: 'wcag-owns' }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: 'gov-focus' }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: 'gov-blur' }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-input' }) govInput: EventEmitter<InputEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: 'gov-select' }) govSelect: EventEmitter<GovFormAutocompleteItem>\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\n\t@Watch('variant')\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteVariants, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch('size')\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && String(this.value).length <= this.minlength && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\trole={'searchbox'}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), 200)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\twcagAutocomplete={'list'}\n\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\twcagOwns={[this.listBoxId, this.wcagOwns].join(' ')}\n\t\t\t\t\twcagExpanded={this.list.length && this.focused}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot slot=\"right-icon\" name=\"right-icon\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list} role={'listbox'} id={this.listBoxId}>\n\t\t\t\t\t{this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={'option'}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonClick={() => this.onSelectHandler(index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.arrowCounter = -1\n\t\tif ((this.value || this.minlength === 0) && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tsetTimeout(() => (this.list = []), 200)\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit(e)\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit(selected)\n\t\t\tthis.list = []\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === 'string') {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = e.detail as KeyboardEvent\n\t\te.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) this.onSelectHandler()\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = ''\n\t\tthis.inputRef.value = ''\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{r as t,h as o,H as i,g as s}from"./p-682c7cc6.js";import{v as r}from"./p-26acf964.js";import{T as e,a,b as n,c as l,d as v}from"./p-404f469e.js";import{c as h}from"./p-24636c53.js";import{g as p}from"./p-3f37ddb6.js";import"./p-561fa17b.js";import"./p-ff7365ae.js";import"./p-55500e5a.js";import"./p-03990da5.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)}}.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 d=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=p(this.host);this.tooltipId=h("GovTooltip")}validateVariant(t){r(l,t,n.root)}validateSize(t){r(v,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()}))}verifiyPositionSpace(){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.verifiyPositionSpace();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"]}}};d.style=c;export{d as gov_tooltip};
2
- //# sourceMappingURL=p-9c844f4d.entry.js.map
1
+ import{r as t,h as o,H as i,g as s}from"./p-682c7cc6.js";import{v as r}from"./p-26acf964.js";import{T as e,a,b as n,c as l,d as v}from"./p-404f469e.js";import{c as h}from"./p-24636c53.js";import{g as p}from"./p-3f37ddb6.js";import"./p-561fa17b.js";import"./p-ff7365ae.js";import"./p-55500e5a.js";import"./p-03990da5.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)}}.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 d=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=p(this.host);this.tooltipId=h("GovTooltip")}validateVariant(t){r(l,t,n.root)}validateSize(t){r(v,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"]}}};d.style=c;export{d as gov_tooltip};
2
+ //# sourceMappingURL=p-b37ca132.entry.js.map
@@ -0,0 +1 @@
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":"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","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,2 +1,2 @@
1
- import{r as o,c as i,h as r,H as t,g as e}from"./p-682c7cc6.js";import{c as s}from"./p-24636c53.js";import{v as a}from"./p-26acf964.js";import{g as c,e as h,f as g}from"./p-af40ceef.js";import{g as v,t as m}from"./p-3f37ddb6.js";import{a as f,b as l}from"./p-364b4792.js";import{c as n}from"./p-c20102ff.js";import{d}from"./p-03990da5.js";import{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-27977727.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)}}.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 _=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.isChecked=undefined;this.checkboxId=s("GovCheckbox");this.h=v(this.host);this.f=c(this.h)}updateCheckedState(o){this.isChecked=o;this.govChange.emit({checked:this.isChecked,value:this.value})}validateSize(o){a(g,o,h.root)}componentWillLoad(){this.isChecked=this.checked;this.f.passAttrToControl("type","switch")}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{isChecked:o}=this;const i=o=>{if(this.noLabel){return r("label",null,o)}return o};return r(t,{class:this.h.classes(h.root),"is-checked":o,size:this.size,invalid:m(this.invalid)},r("div",{class:h.holder},i(r(w,null,r("input",{class:h.input,id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.isChecked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,"aria-checked":this.isChecked,"aria-required":m(this.required),"aria-invalid":m(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":m(this.disabled)}),r("span",{class:h.indicator}),r("slot",{name:"label"})))))}onClickHandler(o){o.stopPropagation()}onFocusHandler(o){o.stopPropagation();o.preventDefault();this.govFocus.emit(o)}onBlurHandler(o){o.stopPropagation();o.preventDefault();this.govBlur.emit(o)}onChangeHandler(o){this.isChecked=o.target.checked;o.stopPropagation();this.govChange.emit({checked:this.isChecked,value:this.value})}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",h.root);f(this.wcagLabelledBy,"wcag-labelled-by",h.root);l(this.identifier||this.checkboxId,this.wcagLabelledBy,h.root)}get host(){return e(this)}static get watchers(){return{checked:["updateCheckedState"],size:["validateSize"]}}};_.style=p;export{_ as gov_form_switch};
2
- //# sourceMappingURL=p-44dc2ef4.entry.js.map
1
+ import{r as o,c as i,h as r,H as t,g as e}from"./p-682c7cc6.js";import{c as s}from"./p-24636c53.js";import{v as a}from"./p-26acf964.js";import{g as c,e as h,f as g}from"./p-9cd80b05.js";import{g as v,t as m}from"./p-3f37ddb6.js";import{a as f,b as l}from"./p-364b4792.js";import{c as n}from"./p-c20102ff.js";import{d}from"./p-03990da5.js";import{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)}}.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 _=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.isChecked=undefined;this.checkboxId=s("GovCheckbox");this.h=v(this.host);this.f=c(this.h)}updateCheckedState(o){this.isChecked=o;this.govChange.emit({checked:this.isChecked,value:this.value})}validateSize(o){a(g,o,h.root)}componentWillLoad(){this.isChecked=this.checked;this.f.passAttrToControl("type","switch")}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{isChecked:o}=this;const i=o=>{if(this.noLabel){return r("label",null,o)}return o};return r(t,{class:this.h.classes(h.root),"is-checked":o,size:this.size,invalid:m(this.invalid)},r("div",{class:h.holder},i(r(w,null,r("input",{class:h.input,id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.isChecked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,"aria-checked":this.isChecked,"aria-required":m(this.required),"aria-invalid":m(this.invalid),"aria-describedby":this.wcagDescribedBy,"aria-labelledby":this.wcagLabelledBy,"aria-disabled":m(this.disabled)}),r("span",{class:h.indicator}),r("slot",{name:"label"})))))}onClickHandler(o){o.stopPropagation()}onFocusHandler(o){o.stopPropagation();this.govFocus.emit(o)}onBlurHandler(o){o.stopPropagation();this.govBlur.emit(o)}onChangeHandler(o){this.isChecked=o.target.checked;o.stopPropagation();this.govChange.emit({checked:this.isChecked,value:this.value})}async validateWcag(){f(this.wcagDescribedBy,"wcag-described-by",h.root);f(this.wcagLabelledBy,"wcag-labelled-by",h.root);l(this.identifier||this.checkboxId,this.wcagLabelledBy,h.root)}get host(){return e(this)}static get watchers(){return{checked:["updateCheckedState"],size:["validateSize"]}}};_.style=p;export{_ as gov_form_switch};
2
+ //# sourceMappingURL=p-b5284ce3.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../packages/core/src/components/gov-form/switch/gov-form-switch.scss?tag=gov-form-switch","../../../packages/core/src/components/gov-form/switch/gov-form-switch.tsx"],"names":["govFormSwitchCss","GovFormSwitch","[object Object]","hostRef","this","checkboxId","createID","h","govHost","host","f","govForm","newValue","isChecked","govChange","emit","checked","value","validateProp","FormSwitchSizes","FormSwitchClass","root","passAttrToControl","passAttrToLabel","identifier","String","required","canValidateWcagOnRender","delay","validateWcag","wrapCheckbox","children","noLabel","Host","class","classes","is-checked","size","invalid","toBoolAttrIfDefined","holder","Fragment","input","id","type","name","onClick","onClickHandler","bind","onChange","onChangeHandler","onFocus","onFocusHandler","onBlur","onBlurHandler","aria-checked","aria-required","aria-invalid","aria-describedby","wcagDescribedBy","aria-labelledby","wcagLabelledBy","aria-disabled","disabled","indicator","e","stopPropagation","govFocus","govBlur","target","validateWcagRef","validateWcagLabelFor"],"mappings":"+hBAAA,MAAMA,EAAmB,iiUCmBZC,EAAa,MAMzBC,YAAAC,2JAe6D,mBAIR,oBAKhB,4DAaS,2IApC7CC,KAAKC,WAAaC,EAAS,eAE3BF,KAAKG,EAAIC,EAAQJ,KAAKK,MACtBL,KAAKM,EAAIC,EAAQP,KAAKG,GAkEvBL,mBAAmBU,GAClBR,KAAKS,UAAYD,EACjBR,KAAKU,UAAUC,KAAK,CACnBC,QAASZ,KAAKS,UACdI,MAAOb,KAAKa,QAKdf,aAAaU,GACZM,EAAaC,EAAiBP,EAAUQ,EAAgBC,MAGzDnB,oBACCE,KAAKS,UAAYT,KAAKY,QAEtBZ,KAAKM,EAAEY,kBAAkB,OAAQ,UAGlCpB,2BACCE,KAAKM,EAAEa,gBAAgB,aAAcnB,KAAKoB,YAAcpB,KAAKC,YAC7DD,KAAKM,EAAEa,gBAAgB,WAAYE,OAAOrB,KAAKsB,WAC/C,GAAIC,IAA2B,OACxBC,EAAM,WACNxB,KAAKyB,gBAIb3B,SACC,MAAMW,UAAEA,GAAcT,KACtB,MAAM0B,EAAgBC,IACrB,GAAI3B,KAAK4B,QAAS,CACjB,OACCzB,EAAA,QAAA,KACEwB,GAIJ,OAAOA,GAGR,OACCxB,EAAC0B,EAAI,CAACC,MAAO9B,KAAKG,EAAE4B,QAAQf,EAAgBC,MAAKe,aAAcvB,EAAWwB,KAAMjC,KAAKiC,KAAMC,QAASC,EAAoBnC,KAAKkC,UAC5H/B,EAAA,MAAA,CAAK2B,MAAOd,EAAgBoB,QAC1BV,EACAvB,EAACkC,EAAQ,KACRlC,EAAA,QAAA,CACC2B,MAAOd,EAAgBsB,MACvBC,GAAIvC,KAAKoB,YAAcpB,KAAKC,WAC5BuC,KAAK,WACL3B,MAAOb,KAAKa,MACZ4B,KAAMzC,KAAKyC,KACX7B,QAASZ,KAAKS,UACdiC,QAAS1C,KAAK2C,eAAeC,KAAK5C,MAClC6C,SAAU7C,KAAK8C,gBAAgBF,KAAK5C,MACpC+C,QAAS/C,KAAKgD,eAAeJ,KAAK5C,MAClCiD,OAAQjD,KAAKkD,cAAcN,KAAK5C,MAChCsB,SAAUtB,KAAKsB,SAAQ6B,eACTnD,KAAKS,UAAS2C,gBACbjB,EAAoBnC,KAAKsB,UAAS+B,eACnClB,EAAoBnC,KAAKkC,SAAQoB,mBAC7BtD,KAAKuD,gBAAeC,kBACrBxD,KAAKyD,eAAcC,gBACrBvB,EAAoBnC,KAAK2D,YAEzCxD,EAAA,OAAA,CAAM2B,MAAOd,EAAgB4C,YAC7BzD,EAAA,OAAA,CAAMsC,KAAK,cAQT3C,eAAe+D,GACtBA,EAAEC,kBAGKhE,eAAe+D,GACtBA,EAAEC,kBACF9D,KAAK+D,SAASpD,KAAKkD,GAGZ/D,cAAc+D,GACrBA,EAAEC,kBACF9D,KAAKgE,QAAQrD,KAAKkD,GAGX/D,gBAAgB+D,GACvB7D,KAAKS,UAAaoD,EAAEI,OAA4BrD,QAChDiD,EAAEC,kBACF9D,KAAKU,UAAUC,KAAK,CACnBC,QAASZ,KAAKS,UACdI,MAAOb,KAAKa,QAQdf,qBACCoE,EAAgBlE,KAAKuD,gBAAiB,oBAAqBvC,EAAgBC,MAC3EiD,EAAgBlE,KAAKyD,eAAgB,mBAAoBzC,EAAgBC,MACzEkD,EAAqBnE,KAAKoB,YAAcpB,KAAKC,WAAYD,KAAKyD,eAAgBzC,EAAgBC","sourcesContent":["/*\n * Switch\n */\n\n$class: \".gov-form-switch\";\n$indicator-ratio: calc(5 / 3);\n\n#{$class} {\n\tposition: relative;\n\tdisplay: flex;\n\t&__holder {\n\t\tdisplay: inline-flex;\n\t}\n\t&__input {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\tz-index: 1;\n\t\tmargin: 0;\n\t\tappearance: none;\n\t}\n\t.gov-form-label__label {\n\t\tposition: relative;\n\t\tz-index: 1;\n\t\tmargin-bottom: 0;\n\t\tcolor: $form-switch-color;\n\t}\n\t&__indicator {\n\t\tposition: relative;\n\t\tflex: 0 0 auto;\n\t\tborder: $form-switch-indicator-border;\n\t\tbackground-color: $form-switch-indicator-bg;\n\t\ttransition: $t linear background-color;\n\t\t&::before {\n\t\t\t@include pseudo();\n\t\t\tborder-radius: 50%;\n\t\t\tbackground-color: $form-switch-indicator-circle-bg;\n\t\t\ttransition: $t linear left;\n\t\t\tbox-shadow: $form-switch-indicator-circle-box-shadow;\n\t\t}\n\t}\n\n\t// STATES\n\t// focus\n\t&__input:focus-visible ~ &__indicator {\n\t\toutline: $outline;\n\t}\n\t// checked\n\t&__input:checked + &__indicator {\n\t\tborder-color: $form-switch-indicator-bg-checked;\n\t\tbackground-color: $form-switch-indicator-bg-checked;\n\t}\n\n\t// disabled\n\t@include parameter(\"disabled\") {\n\t\tpointer-events: none;\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-disabled;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\t&::before {\n\t\t\t\t\tbackground: $form-state-bg-input-disabled;\n\t\t\t\t}\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t\t}\n\t\t}\n\t}\n\n\t// invalid\n\t@include parameter(\"invalid\") {\n\t\t.gov-form-label__label {\n\t\t\tcolor: $form-state-color-error;\n\t\t}\n\t\t#{$class} {\n\t\t\t&__indicator {\n\t\t\t\tborder-color: $form-state-color-error;\n\t\t\t}\n\t\t\t&__input:checked + #{$class}__indicator {\n\t\t\t\tbackground-color: $form-state-color-error;\n\t\t\t}\n\t\t}\n\t}\n\n\t// sizes\n\t@each $size, $definitions in $form-switch-sizes {\n\t\t$indicator-width: calc(get(\"indicator-height\", $definitions) * $indicator-ratio);\n\t\t$indicator-height: get(\"indicator-height\", $definitions);\n\t\t$border-offset: calc(get(\"toggle-offset\", $definitions) - rem-calc(1));\n\n\t\t&[size=\"#{$size}\"] {\n\t\t\t.gov-form-label__label {\n\t\t\t\t@include typography($size);\n\t\t\t\tmargin-bottom: 0;\n\t\t\t\tmargin-left: calc(($indicator-width + get(\"gap\", $definitions)) * -1);\n\t\t\t\tpadding-top: calc(($indicator-height - (var(--gov-text-#{$size}-font-size) * 1.5)) / 2);\n\t\t\t\tpadding-left: calc($indicator-width + get(\"gap\", $definitions));\n\t\t\t}\n\t\t\t#{$class} {\n\t\t\t\t&__holder {\n\t\t\t\t\tgap: get(\"gap\", $definitions);\n\t\t\t\t}\n\t\t\t\t&__indicator {\n\t\t\t\t\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, State, Event, EventEmitter, Element, Watch, Method } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormSwitchClass, FormSwitchSizes, FormSwitchSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport { GovFormSwitchChangeEvent } from \"./interfaces\"\nimport Fragment from \"../../../helpers/Fragment\"\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\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 }) readonly checked: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the switch component disabled.\n\t * This prevents users from being able to interact with the switch, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the switch.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Switch's size.\n\t */\n\t@Prop() readonly size?: FormSwitchSizesType = \"m\"\n\t/**\n\t * Custom switch identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Emitted when the switch has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the switch loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the switch change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<GovFormSwitchChangeEvent>\n\n\t@State() isChecked: boolean\n\n\t@Watch(\"checked\")\n\tupdateCheckedState(newValue: boolean): void {\n\t\tthis.isChecked = newValue\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormSwitchSizes, newValue, FormSwitchClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.isChecked = this.checked\n\n\t\tthis.f.passAttrToControl(\"type\", \"switch\")\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel('identifier', this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel('required', String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst { isChecked } = this\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={this.h.classes(FormSwitchClass.root)} is-checked={isChecked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t<div class={FormSwitchClass.holder}>\n\t\t\t\t\t{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.isChecked}\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\trequired={this.required}\n\t\t\t\t\t\t\t\taria-checked={this.isChecked}\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(e)\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit(e)\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.isChecked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormSwitchClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormSwitchClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormSwitchClass.root)\n\t}\n}\n"]}