@gov-design-system-ce/components 0.0.16 → 0.0.18

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 (280) hide show
  1. package/dist/cjs/core.cjs.js +1 -1
  2. package/dist/cjs/gov-accordion-item.cjs.entry.js +5 -1
  3. package/dist/cjs/gov-accordion-item.cjs.entry.js.map +1 -1
  4. package/dist/cjs/gov-accordion.cjs.entry.js +5 -1
  5. package/dist/cjs/gov-accordion.cjs.entry.js.map +1 -1
  6. package/dist/cjs/gov-app.cjs.entry.js +11 -8
  7. package/dist/cjs/gov-app.cjs.entry.js.map +1 -1
  8. package/dist/cjs/gov-backdrop.cjs.entry.js +0 -4
  9. package/dist/cjs/gov-backdrop.cjs.entry.js.map +1 -1
  10. package/dist/cjs/gov-button.cjs.entry.js +28 -14
  11. package/dist/cjs/gov-button.cjs.entry.js.map +1 -1
  12. package/dist/cjs/gov-form-autocomplete.cjs.entry.js +33 -14
  13. package/dist/cjs/gov-form-autocomplete.cjs.entry.js.map +1 -1
  14. package/dist/cjs/gov-form-checkbox.cjs.entry.js +25 -18
  15. package/dist/cjs/gov-form-checkbox.cjs.entry.js.map +1 -1
  16. package/dist/cjs/gov-form-file.cjs.entry.js +57 -27
  17. package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
  18. package/dist/cjs/gov-form-input.cjs.entry.js +21 -5
  19. package/dist/cjs/gov-form-input.cjs.entry.js.map +1 -1
  20. package/dist/cjs/gov-form-multi-select.cjs.entry.js +30 -19
  21. package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
  22. package/dist/cjs/gov-form-radio.cjs.entry.js +23 -16
  23. package/dist/cjs/gov-form-radio.cjs.entry.js.map +1 -1
  24. package/dist/cjs/gov-form-select.cjs.entry.js +27 -15
  25. package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
  26. package/dist/cjs/gov-form-switch.cjs.entry.js +23 -16
  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-loading.cjs.entry.js +1 -1
  30. package/dist/cjs/gov-loading.cjs.entry.js.map +1 -1
  31. package/dist/cjs/gov-modal.cjs.entry.js +1 -1
  32. package/dist/cjs/gov-modal.cjs.entry.js.map +1 -1
  33. package/dist/cjs/gov-pagination.cjs.entry.js +18 -10
  34. package/dist/cjs/gov-pagination.cjs.entry.js.map +1 -1
  35. package/dist/cjs/gov-prompt.cjs.entry.js +8 -8
  36. package/dist/cjs/gov-prompt.cjs.entry.js.map +1 -1
  37. package/dist/cjs/gov-tile.cjs.entry.js.map +1 -1
  38. package/dist/cjs/loader.cjs.js +1 -1
  39. package/dist/collection/components/gov-accordion/gov-accordion-item.js +9 -5
  40. package/dist/collection/components/gov-accordion/gov-accordion-item.js.map +1 -1
  41. package/dist/collection/components/gov-accordion/gov-accordion.js +9 -5
  42. package/dist/collection/components/gov-accordion/gov-accordion.js.map +1 -1
  43. package/dist/collection/components/gov-accordion/gov-accordion.types.js +2 -0
  44. package/dist/collection/components/gov-accordion/gov-accordion.types.js.map +1 -0
  45. package/dist/collection/components/gov-backdrop/gov-backdrop.js +0 -22
  46. package/dist/collection/components/gov-backdrop/gov-backdrop.js.map +1 -1
  47. package/dist/collection/components/gov-button/gov-button.css +2 -2
  48. package/dist/collection/components/gov-button/gov-button.js +54 -37
  49. package/dist/collection/components/gov-button/gov-button.js.map +1 -1
  50. package/dist/collection/components/gov-button/gov-button.types.js +2 -0
  51. package/dist/collection/components/gov-button/gov-button.types.js.map +1 -0
  52. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js +60 -38
  53. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.js.map +1 -1
  54. package/dist/collection/components/gov-form/autocomplete/gov-form-autocomplete.types.js.map +1 -1
  55. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js +60 -39
  56. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.js.map +1 -1
  57. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.types.js +2 -0
  58. package/dist/collection/components/gov-form/checkbox/gov-form-checkbox.types.js.map +1 -0
  59. package/dist/collection/components/gov-form/file/gov-form-file.js +129 -59
  60. package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
  61. package/dist/collection/components/gov-form/file/gov-form-file.types.js.map +1 -1
  62. package/dist/collection/components/gov-form/input/gov-form-input.js +42 -22
  63. package/dist/collection/components/gov-form/input/gov-form-input.js.map +1 -1
  64. package/dist/collection/components/gov-form/input/gov-form-input.types.js +2 -0
  65. package/dist/collection/components/gov-form/input/gov-form-input.types.js.map +1 -0
  66. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +53 -40
  67. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
  68. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.types.js +2 -0
  69. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.types.js.map +1 -0
  70. package/dist/collection/components/gov-form/radio/gov-form-radio.js +57 -36
  71. package/dist/collection/components/gov-form/radio/gov-form-radio.js.map +1 -1
  72. package/dist/collection/components/gov-form/radio/gov-form-radio.types.js +2 -0
  73. package/dist/collection/components/gov-form/radio/gov-form-radio.types.js.map +1 -0
  74. package/dist/collection/components/gov-form/select/gov-form-select.js +56 -37
  75. package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
  76. package/dist/collection/components/gov-form/select/gov-form-select.types.js +2 -0
  77. package/dist/collection/components/gov-form/select/gov-form-select.types.js.map +1 -0
  78. package/dist/collection/components/gov-form/switch/gov-form-switch.js +57 -36
  79. package/dist/collection/components/gov-form/switch/gov-form-switch.js.map +1 -1
  80. package/dist/collection/components/gov-form/switch/gov-form-switch.types.js +2 -0
  81. package/dist/collection/components/gov-form/switch/gov-form-switch.types.js.map +1 -0
  82. package/dist/collection/components/gov-loading/loading/gov-loading.js +1 -1
  83. package/dist/collection/components/gov-loading/loading/gov-loading.js.map +1 -1
  84. package/dist/collection/components/gov-modal/gov-modal.js +1 -1
  85. package/dist/collection/components/gov-modal/gov-modal.js.map +1 -1
  86. package/dist/collection/components/gov-pagination/gov-pagination.js +16 -13
  87. package/dist/collection/components/gov-pagination/gov-pagination.js.map +1 -1
  88. package/dist/collection/components/gov-pagination/gov-pagination.types.js +2 -0
  89. package/dist/collection/components/gov-pagination/gov-pagination.types.js.map +1 -0
  90. package/dist/collection/components/gov-promp/gov-prompt.js +18 -18
  91. package/dist/collection/components/gov-promp/gov-prompt.js.map +1 -1
  92. package/dist/collection/components/gov-tile/gov-tile.js.map +1 -1
  93. package/dist/collection/pages/Forms.js +3 -0
  94. package/dist/collection/pages/Forms.js.map +1 -1
  95. package/dist/collection/pages/Pagination.js +8 -8
  96. package/dist/collection/pages/Pagination.js.map +1 -1
  97. package/dist/collection/types/event.types.js +2 -0
  98. package/dist/collection/types/event.types.js.map +1 -0
  99. package/dist/collection/utils/array.utils.js +6 -1
  100. package/dist/collection/utils/array.utils.js.map +1 -1
  101. package/dist/components/gov-accordion-item.js +5 -1
  102. package/dist/components/gov-accordion-item.js.map +1 -1
  103. package/dist/components/gov-accordion.js +5 -1
  104. package/dist/components/gov-accordion.js.map +1 -1
  105. package/dist/components/gov-app.js +11 -8
  106. package/dist/components/gov-app.js.map +1 -1
  107. package/dist/components/gov-backdrop2.js +0 -5
  108. package/dist/components/gov-backdrop2.js.map +1 -1
  109. package/dist/components/gov-button2.js +28 -14
  110. package/dist/components/gov-button2.js.map +1 -1
  111. package/dist/components/gov-form-autocomplete2.js +33 -14
  112. package/dist/components/gov-form-autocomplete2.js.map +1 -1
  113. package/dist/components/gov-form-checkbox.js +27 -20
  114. package/dist/components/gov-form-checkbox.js.map +1 -1
  115. package/dist/components/gov-form-file.js +59 -27
  116. package/dist/components/gov-form-file.js.map +1 -1
  117. package/dist/components/gov-form-input2.js +22 -6
  118. package/dist/components/gov-form-input2.js.map +1 -1
  119. package/dist/components/gov-form-multi-select.js +30 -19
  120. package/dist/components/gov-form-multi-select.js.map +1 -1
  121. package/dist/components/gov-form-radio.js +25 -18
  122. package/dist/components/gov-form-radio.js.map +1 -1
  123. package/dist/components/gov-form-select2.js +28 -16
  124. package/dist/components/gov-form-select2.js.map +1 -1
  125. package/dist/components/gov-form-switch.js +25 -18
  126. package/dist/components/gov-form-switch.js.map +1 -1
  127. package/dist/components/gov-icon2.js +1 -1
  128. package/dist/components/gov-loading.js +1 -1
  129. package/dist/components/gov-loading.js.map +1 -1
  130. package/dist/components/gov-modal.js +1 -1
  131. package/dist/components/gov-modal.js.map +1 -1
  132. package/dist/components/gov-pagination.js +18 -10
  133. package/dist/components/gov-pagination.js.map +1 -1
  134. package/dist/components/gov-prompt.js +8 -8
  135. package/dist/components/gov-prompt.js.map +1 -1
  136. package/dist/components/gov-tile.js.map +1 -1
  137. package/dist/core/core.esm.js +1 -1
  138. package/dist/core/core.esm.js.map +1 -1
  139. package/dist/core/p-26260897.entry.js +2 -0
  140. package/dist/core/p-26260897.entry.js.map +1 -0
  141. package/dist/core/{p-30b162df.entry.js → p-354c6a6d.entry.js} +2 -2
  142. package/dist/core/p-354c6a6d.entry.js.map +1 -0
  143. package/dist/core/{p-e6b8c610.entry.js → p-3a50ac4c.entry.js} +2 -2
  144. package/dist/core/p-3a50ac4c.entry.js.map +1 -0
  145. package/dist/core/p-52f2f67c.entry.js +2 -0
  146. package/dist/core/p-52f2f67c.entry.js.map +1 -0
  147. package/dist/core/{p-e3141382.entry.js → p-5e5e925d.entry.js} +2 -2
  148. package/dist/core/p-5e5e925d.entry.js.map +1 -0
  149. package/dist/core/p-67006730.entry.js.map +1 -1
  150. package/dist/core/p-724921e7.entry.js +2 -0
  151. package/dist/core/p-724921e7.entry.js.map +1 -0
  152. package/dist/core/{p-d2f6053f.entry.js → p-8b2a6f87.entry.js} +2 -2
  153. package/dist/core/p-8b2a6f87.entry.js.map +1 -0
  154. package/dist/core/{p-9bdce72b.entry.js → p-8feb8960.entry.js} +2 -2
  155. package/dist/core/p-8feb8960.entry.js.map +1 -0
  156. package/dist/core/{p-f027a1a1.entry.js → p-a37ef1b2.entry.js} +2 -2
  157. package/dist/core/{p-bce96aac.entry.js → p-b2d1dd2a.entry.js} +2 -2
  158. package/dist/core/p-b2d1dd2a.entry.js.map +1 -0
  159. package/dist/core/{p-131c50d1.entry.js → p-b9b80796.entry.js} +2 -2
  160. package/dist/core/p-b9b80796.entry.js.map +1 -0
  161. package/dist/core/{p-b7587525.entry.js → p-bb3afae6.entry.js} +2 -2
  162. package/dist/core/p-bb3afae6.entry.js.map +1 -0
  163. package/dist/core/{p-c91928ed.entry.js → p-be799dfa.entry.js} +2 -2
  164. package/dist/core/p-be799dfa.entry.js.map +1 -0
  165. package/dist/core/{p-2426fa82.entry.js → p-c970a479.entry.js} +2 -2
  166. package/dist/core/p-c970a479.entry.js.map +1 -0
  167. package/dist/core/{p-471c0863.entry.js → p-cba27477.entry.js} +2 -2
  168. package/dist/core/p-cba27477.entry.js.map +1 -0
  169. package/dist/core/{p-93edcce2.entry.js → p-d79d0f7a.entry.js} +2 -2
  170. package/dist/core/p-d79d0f7a.entry.js.map +1 -0
  171. package/dist/core/{p-c836f7cd.entry.js → p-e51baf04.entry.js} +2 -2
  172. package/dist/core/p-e51baf04.entry.js.map +1 -0
  173. package/dist/core/{p-0272ffa0.entry.js → p-f73d482b.entry.js} +2 -2
  174. package/dist/core/p-f73d482b.entry.js.map +1 -0
  175. package/dist/custom-elements/index.js +1 -1
  176. package/dist/custom-elements/index.js.map +1 -1
  177. package/dist/esm/core.js +1 -1
  178. package/dist/esm/gov-accordion-item.entry.js +5 -1
  179. package/dist/esm/gov-accordion-item.entry.js.map +1 -1
  180. package/dist/esm/gov-accordion.entry.js +5 -1
  181. package/dist/esm/gov-accordion.entry.js.map +1 -1
  182. package/dist/esm/gov-app.entry.js +11 -8
  183. package/dist/esm/gov-app.entry.js.map +1 -1
  184. package/dist/esm/gov-backdrop.entry.js +0 -4
  185. package/dist/esm/gov-backdrop.entry.js.map +1 -1
  186. package/dist/esm/gov-button.entry.js +28 -14
  187. package/dist/esm/gov-button.entry.js.map +1 -1
  188. package/dist/esm/gov-form-autocomplete.entry.js +33 -14
  189. package/dist/esm/gov-form-autocomplete.entry.js.map +1 -1
  190. package/dist/esm/gov-form-checkbox.entry.js +25 -18
  191. package/dist/esm/gov-form-checkbox.entry.js.map +1 -1
  192. package/dist/esm/gov-form-file.entry.js +57 -27
  193. package/dist/esm/gov-form-file.entry.js.map +1 -1
  194. package/dist/esm/gov-form-input.entry.js +21 -5
  195. package/dist/esm/gov-form-input.entry.js.map +1 -1
  196. package/dist/esm/gov-form-multi-select.entry.js +30 -19
  197. package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
  198. package/dist/esm/gov-form-radio.entry.js +23 -16
  199. package/dist/esm/gov-form-radio.entry.js.map +1 -1
  200. package/dist/esm/gov-form-select.entry.js +27 -15
  201. package/dist/esm/gov-form-select.entry.js.map +1 -1
  202. package/dist/esm/gov-form-switch.entry.js +23 -16
  203. package/dist/esm/gov-form-switch.entry.js.map +1 -1
  204. package/dist/esm/gov-icon.entry.js +1 -1
  205. package/dist/esm/gov-loading.entry.js +1 -1
  206. package/dist/esm/gov-loading.entry.js.map +1 -1
  207. package/dist/esm/gov-modal.entry.js +1 -1
  208. package/dist/esm/gov-modal.entry.js.map +1 -1
  209. package/dist/esm/gov-pagination.entry.js +18 -10
  210. package/dist/esm/gov-pagination.entry.js.map +1 -1
  211. package/dist/esm/gov-prompt.entry.js +8 -8
  212. package/dist/esm/gov-prompt.entry.js.map +1 -1
  213. package/dist/esm/gov-tile.entry.js.map +1 -1
  214. package/dist/esm/loader.js +1 -1
  215. package/dist/hydrate/index.js +326 -187
  216. package/dist/stencil.config.js +1 -1
  217. package/dist/stencil.config.js.map +1 -1
  218. package/dist/types/components/gov-accordion/gov-accordion-item.d.ts +2 -2
  219. package/dist/types/components/gov-accordion/gov-accordion.d.ts +2 -2
  220. package/dist/types/components/gov-accordion/gov-accordion.types.d.ts +9 -0
  221. package/dist/types/components/gov-backdrop/gov-backdrop.d.ts +0 -4
  222. package/dist/types/components/gov-button/gov-button.d.ts +6 -5
  223. package/dist/types/components/gov-button/gov-button.types.d.ts +4 -0
  224. package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.d.ts +8 -8
  225. package/dist/types/components/gov-form/autocomplete/gov-form-autocomplete.types.d.ts +6 -0
  226. package/dist/types/components/gov-form/checkbox/gov-form-checkbox.d.ts +11 -8
  227. package/dist/types/components/gov-form/checkbox/gov-form-checkbox.types.d.ts +5 -0
  228. package/dist/types/components/gov-form/file/gov-form-file.d.ts +16 -8
  229. package/dist/types/components/gov-form/file/gov-form-file.types.d.ts +5 -0
  230. package/dist/types/components/gov-form/input/gov-form-input.d.ts +6 -5
  231. package/dist/types/components/gov-form/input/gov-form-input.types.d.ts +4 -0
  232. package/dist/types/components/gov-form/multiselect/gov-form-multi-select.d.ts +6 -6
  233. package/dist/types/components/gov-form/multiselect/gov-form-multi-select.types.d.ts +8 -0
  234. package/dist/types/components/gov-form/radio/gov-form-radio.d.ts +10 -7
  235. package/dist/types/components/gov-form/radio/gov-form-radio.types.d.ts +5 -0
  236. package/dist/types/components/gov-form/select/gov-form-select.d.ts +7 -6
  237. package/dist/types/components/gov-form/select/gov-form-select.types.d.ts +4 -0
  238. package/dist/types/components/gov-form/switch/gov-form-switch.d.ts +10 -7
  239. package/dist/types/components/gov-form/switch/gov-form-switch.types.d.ts +5 -0
  240. package/dist/types/components/gov-pagination/gov-pagination.d.ts +2 -1
  241. package/dist/types/components/gov-pagination/gov-pagination.types.d.ts +5 -0
  242. package/dist/types/components.d.ts +69 -54
  243. package/dist/types/types/event.types.d.ts +4 -0
  244. package/package.json +1 -1
  245. package/dist/collection/components/gov-accordion/gov-accordion-item.d.js +0 -2
  246. package/dist/collection/components/gov-accordion/gov-accordion-item.d.js.map +0 -1
  247. package/dist/collection/components/gov-form/checkbox/interfaces.js +0 -2
  248. package/dist/collection/components/gov-form/checkbox/interfaces.js.map +0 -1
  249. package/dist/collection/components/gov-form/multiselect/interfaces.js +0 -2
  250. package/dist/collection/components/gov-form/multiselect/interfaces.js.map +0 -1
  251. package/dist/collection/components/gov-form/radio/interfaces.js +0 -2
  252. package/dist/collection/components/gov-form/radio/interfaces.js.map +0 -1
  253. package/dist/collection/components/gov-form/switch/interfaces.js +0 -2
  254. package/dist/collection/components/gov-form/switch/interfaces.js.map +0 -1
  255. package/dist/core/p-0272ffa0.entry.js.map +0 -1
  256. package/dist/core/p-131c50d1.entry.js.map +0 -1
  257. package/dist/core/p-2426fa82.entry.js.map +0 -1
  258. package/dist/core/p-30b162df.entry.js.map +0 -1
  259. package/dist/core/p-337fb136.entry.js +0 -2
  260. package/dist/core/p-337fb136.entry.js.map +0 -1
  261. package/dist/core/p-402c2751.entry.js +0 -2
  262. package/dist/core/p-402c2751.entry.js.map +0 -1
  263. package/dist/core/p-405fc50f.entry.js +0 -2
  264. package/dist/core/p-405fc50f.entry.js.map +0 -1
  265. package/dist/core/p-471c0863.entry.js.map +0 -1
  266. package/dist/core/p-93edcce2.entry.js.map +0 -1
  267. package/dist/core/p-9bdce72b.entry.js.map +0 -1
  268. package/dist/core/p-b7587525.entry.js.map +0 -1
  269. package/dist/core/p-bce96aac.entry.js.map +0 -1
  270. package/dist/core/p-c836f7cd.entry.js.map +0 -1
  271. package/dist/core/p-c91928ed.entry.js.map +0 -1
  272. package/dist/core/p-d2f6053f.entry.js.map +0 -1
  273. package/dist/core/p-e3141382.entry.js.map +0 -1
  274. package/dist/core/p-e6b8c610.entry.js.map +0 -1
  275. package/dist/types/components/gov-accordion/gov-accordion-item.d.d.ts +0 -4
  276. package/dist/types/components/gov-form/checkbox/interfaces.d.ts +0 -4
  277. package/dist/types/components/gov-form/multiselect/interfaces.d.ts +0 -4
  278. package/dist/types/components/gov-form/radio/interfaces.d.ts +0 -4
  279. package/dist/types/components/gov-form/switch/interfaces.d.ts +0 -4
  280. /package/dist/core/{p-f027a1a1.entry.js.map → p-a37ef1b2.entry.js.map} +0 -0
@@ -22,12 +22,12 @@ const GovFormAutocomplete = class {
22
22
  this.govInput = index.createEvent(this, "gov-input", 7);
23
23
  this.govSelect = index.createEvent(this, "gov-select", 7);
24
24
  this.templateResolver = item => item[this.nameKey];
25
- this.value = '';
25
+ this.value = "";
26
26
  this.identifier = undefined;
27
27
  this.variant = undefined;
28
28
  this.success = undefined;
29
- this.size = 'm';
30
- this.nameKey = 'name';
29
+ this.size = "m";
30
+ this.nameKey = "name";
31
31
  this.name = undefined;
32
32
  this.required = false;
33
33
  this.disabled = undefined;
@@ -43,7 +43,7 @@ const GovFormAutocomplete = class {
43
43
  this.processing = false;
44
44
  this.arrowCounter = -1;
45
45
  this.list = [];
46
- this.listBoxId = string_utils.createID('GovListBox');
46
+ this.listBoxId = string_utils.createID("GovListBox");
47
47
  }
48
48
  validateVariant(newValue) {
49
49
  props.validateProp(constants.FormAutocompleteVariants, newValue, constants.FormAutocompleteClass.root);
@@ -84,9 +84,9 @@ const GovFormAutocomplete = class {
84
84
  this.validateSize(this.size);
85
85
  }
86
86
  render() {
87
- return (index.h(index.Host, { class: constants.FormAutocompleteClass.root, size: this.size, variant: this.variant }, index.h("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": utils.throttle(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: el => (this.inputRef = el) }, index.h("slot", { slot: "right-icon", name: "right-icon" })), index.h("ul", { class: constants.FormAutocompleteClass.list, role: 'listbox', id: this.listBoxId }, this.list.map((item, index$1) => {
87
+ return (index.h(index.Host, { class: constants.FormAutocompleteClass.root, size: this.size, variant: this.variant }, index.h("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": utils.throttle(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: el => (this.inputRef = el) }, index.h("slot", { slot: "right-icon", name: "right-icon" })), index.h("ul", { class: constants.FormAutocompleteClass.list, role: "listbox", id: this.listBoxId }, this.list.map((item, index$1) => {
88
88
  const isSelected = this.arrowCounter === index$1;
89
- return (index.h("li", { class: constants.FormAutocompleteClass.item, innerHTML: this.templateResolver(item, isSelected), role: 'option', "aria-posinset": index$1, tabindex: isSelected ? 0 : -1, "aria-setsize": this.list.length, onClick: () => this.onSelectHandler(index$1), "aria-selected": template.toBoolAttr(isSelected) }));
89
+ return (index.h("li", { class: constants.FormAutocompleteClass.item, innerHTML: this.templateResolver(item, isSelected), role: "option", "aria-posinset": index$1, tabindex: isSelected ? 0 : -1, "aria-setsize": this.list.length, onClick: () => this.onSelectHandler(index$1), "aria-selected": template.toBoolAttr(isSelected) }));
90
90
  }))));
91
91
  }
92
92
  onFocusHandler(e) {
@@ -96,19 +96,34 @@ const GovFormAutocomplete = class {
96
96
  this.doSearch();
97
97
  }
98
98
  e.stopPropagation();
99
- this.govFocus.emit(e);
99
+ this.govFocus.emit({
100
+ originalEvent: e,
101
+ component: constants.FormAutocompleteClass.root,
102
+ value: this.value,
103
+ selected: null
104
+ });
100
105
  }
101
106
  onBlurHandler(e) {
102
107
  this.focused = false;
103
108
  setTimeout(() => (this.list = []), 200);
104
109
  this.arrowCounter = -1;
105
110
  e.stopPropagation();
106
- this.govBlur.emit(e);
111
+ this.govBlur.emit({
112
+ originalEvent: e,
113
+ component: constants.FormAutocompleteClass.root,
114
+ value: this.value,
115
+ selected: null
116
+ });
107
117
  }
108
118
  onInputHandler(e) {
109
119
  this.value = e.target.value;
110
120
  e.stopPropagation();
111
- this.govInput.emit(e);
121
+ this.govInput.emit({
122
+ originalEvent: e,
123
+ component: constants.FormAutocompleteClass.root,
124
+ value: this.value,
125
+ selected: null
126
+ });
112
127
  this.doSearch();
113
128
  }
114
129
  onSelectHandler(index = -1) {
@@ -120,15 +135,19 @@ const GovFormAutocomplete = class {
120
135
  selected = this.list[this.arrowCounter];
121
136
  }
122
137
  if (selected) {
123
- this.govSelect.emit(selected);
138
+ this.govSelect.emit({
139
+ component: constants.FormAutocompleteClass.root,
140
+ value: this.value,
141
+ selected: selected
142
+ });
124
143
  this.list = [];
125
- if (utils.has(this.nameKey, selected) && typeof selected[this.nameKey] === 'string') {
144
+ if (utils.has(this.nameKey, selected) && typeof selected[this.nameKey] === "string") {
126
145
  this.value = selected[this.nameKey];
127
146
  }
128
147
  }
129
148
  }
130
149
  onKeyUpHandler(e) {
131
- const event = e.detail;
150
+ const event = e.detail.originalEvent;
132
151
  e.stopPropagation();
133
152
  if (event.keyCode === 38)
134
153
  this.onArrowUp();
@@ -147,8 +166,8 @@ const GovFormAutocomplete = class {
147
166
  * Clears whisperer value
148
167
  */
149
168
  async clearValue() {
150
- this.value = '';
151
- this.inputRef.value = '';
169
+ this.value = "";
170
+ this.inputRef.value = "";
152
171
  await this.inputRef.clearValue();
153
172
  }
154
173
  /**
@@ -1 +1 @@
1
- {"file":"gov-form-autocomplete.entry.cjs.js","mappings":";;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,grDAAg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AS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;MAC7B,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;MACd,IAAIA,SAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,EAAE;QAC9E,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;OACnC;KACD;GACD;EAEO,cAAc,CAAC,CAAc;IACpC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAuB,CAAA;IACvC,CAAC,CAAC,eAAe,EAAE,CAAA;IACnB,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE;MAAE,IAAI,CAAC,SAAS,EAAE,CAAA;SACrC,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE;MAAE,IAAI,CAAC,WAAW,EAAE,CAAA;SAC5C,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE;MAAE,IAAI,CAAC,eAAe,EAAE,CAAA;GACrD;;;;EAMD,MAAM,QAAQ,CAAC,OAAsB;IACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;GACnC;;;;EAMD,MAAM,UAAU;IACf,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACf,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAA;IAExB,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;GAChC;;;;EAMD,MAAM,iBAAiB,CAAC,QAAyC;IAChE,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAA;GAC9B;;;;;EAOD,MAAM,mBAAmB,CAAC,QAAmD;IAC5E,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAA;GAChC;;;;;;;;;;;","names":["createID","validateProp","FormAutocompleteVariants","FormAutocompleteClass","FormAutocompleteSizes","h","Host","throttle","index","toBoolAttr","has"],"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"],"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"],"version":3}
1
+ {"file":"gov-form-autocomplete.entry.cjs.js","mappings":";;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,grDAAgrD;;MCelsD,mBAAmB;EAM/B;;;;;;IAFQ,qBAAgB,GAAiE,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;iBAUnE,EAAE;;;;gBAgBd,GAAG;mBAIJ,MAAM;;oBASJ,KAAK;;;;;qBAqBL,CAAC;;;;;;sBAmChB,KAAK;wBACH,CAAC,CAAC;gBACiB,EAAE;IA9F5C,IAAI,CAAC,SAAS,GAAGA,qBAAQ,CAAC,YAAY,CAAC,CAAA;GACvC;EAgGD,eAAe,CAAC,QAAgB;IAC/BC,kBAAY,CAACC,kCAAwB,EAAE,QAAQ,EAAEC,+BAAqB,CAAC,IAAI,CAAC,CAAA;GAC5E;EAGD,YAAY,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","throttle","index","toBoolAttr","has"],"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"],"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 { FormAutocompleteEvent, GovFormAutocompleteItem } from \"./gov-form-autocomplete.types\"\nimport { toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { Nullable } from \"../../../types/interfaces\"\nimport { FormInputEvent } from \"../input/gov-form-input.types\"\n\n@Component({\n\ttag: \"gov-form-autocomplete\",\n\tstyleUrl: \"gov-form-autocomplete.scss\",\n})\nexport class GovFormAutocomplete {\n\tprivate inputRef?: HTMLGovFormInputElement\n\tprivate readonly listBoxId: string\n\tprivate searchCallback: (value: string) => Promise<GovFormAutocompleteItem[]>\n\tprivate templateResolver: (item: GovFormAutocompleteItem, selected: boolean) => string = item => item[this.nameKey]\n\n\tconstructor() {\n\t\tthis.listBoxId = createID(\"GovListBox\")\n\t}\n\n\t@Element() host: HTMLGovFormInputElement\n\t/**\n\t * Value of input\n\t */\n\t@Prop({ reflect: true, mutable: true }) value = \"\"\n\t/**\n\t * Custom input identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * Style variation of the form input.\n\t */\n\t@Prop() readonly variant?: VariantType\n\t/**\n\t * Indicates the entered value of child form element does conform to the format expected by the application.\n\t */\n\t@Prop() readonly success: boolean\n\t/**\n\t * Input’s size.\n\t */\n\t@Prop() readonly size?: SizesType = \"m\"\n\t/**\n\t * Main key name in the object\n\t */\n\t@Prop() readonly nameKey: string = \"name\"\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the input component disabled.\n\t * This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Text that appears in the form control when it has no value set\n\t */\n\t@Prop() readonly placeholder: string\n\t/**\n\t * The value is not editable\n\t */\n\t@Prop() readonly readonly: boolean\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Minimum length (number of characters) of value\n\t */\n\t@Prop() readonly minlength: number = 2\n\t/**\n\t * Maximum length (number of characters) of value\n\t */\n\t@Prop() readonly maxlength: number\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Same as original parameter\n\t * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-owns\n\t */\n\t@Prop({ attribute: \"wcag-owns\" }) readonly wcagOwns: string\n\t/**\n\t * Emitted when the input has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: \"gov-input\" }) govInput: EventEmitter<FormAutocompleteEvent>\n\t/**\n\t * Emitted when the input change value.\n\t */\n\t@Event({ eventName: \"gov-select\" }) govSelect: EventEmitter<FormAutocompleteEvent>\n\t@State() focused: boolean\n\t@State() processing = false\n\t@State() arrowCounter = -1\n\t@State() list: GovFormAutocompleteItem[] = []\n\n\t@Watch(\"variant\")\n\tvalidateVariant(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteVariants, newValue, FormAutocompleteClass.root)\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormAutocompleteSizes, newValue, FormAutocompleteClass.root)\n\t}\n\n\tprivate onArrowUp() {\n\t\tif (this.arrowCounter > 0) {\n\t\t\tthis.arrowCounter = this.arrowCounter - 1\n\t\t}\n\t}\n\n\tprivate onArrowDown() {\n\t\tif (this.arrowCounter < this.list.length - 1) {\n\t\t\tthis.arrowCounter = this.arrowCounter + 1\n\t\t}\n\t}\n\n\tprivate doSearch() {\n\t\tif (Number.isInteger(this.minlength) && String(this.value).length <= this.minlength && this.minlength) {\n\t\t\tthis.list = []\n\t\t\tthis.arrowCounter = -1\n\t\t\tthis.processing = false\n\t\t\treturn\n\t\t}\n\t\tif (this.searchCallback) {\n\t\t\tthis.processing = true\n\t\t\tthis.searchCallback(this.value)\n\t\t\t\t.then(response => (this.list = response))\n\t\t\t\t.catch(() => (this.list = []))\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.arrowCounter = -1\n\t\t\t\t\tthis.processing = false\n\t\t\t\t})\n\t\t}\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateVariant(this.variant)\n\t\tthis.validateSize(this.size)\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={FormAutocompleteClass.root} size={this.size} variant={this.variant}>\n\t\t\t\t<gov-form-input\n\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\tname={this.name}\n\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\tautocomplete={false}\n\t\t\t\t\tsize={this.size}\n\t\t\t\t\tvariant={this.variant}\n\t\t\t\t\trequired={this.required}\n\t\t\t\t\tinvalid={this.invalid}\n\t\t\t\t\trole={\"searchbox\"}\n\t\t\t\t\tvalue={this.value}\n\t\t\t\t\tminlength={this.minlength}\n\t\t\t\t\tmaxlength={this.maxlength}\n\t\t\t\t\ton-gov-input={throttle(this.onInputHandler.bind(this), 200)}\n\t\t\t\t\ton-gov-keyup={this.onKeyUpHandler.bind(this)}\n\t\t\t\t\ton-gov-focus={this.onFocusHandler.bind(this)}\n\t\t\t\t\ton-gov-blur={this.onBlurHandler.bind(this)}\n\t\t\t\t\twcagAutocomplete={\"list\"}\n\t\t\t\t\twcagDescribedBy={this.wcagDescribedBy}\n\t\t\t\t\twcagLabelledBy={this.wcagLabelledBy}\n\t\t\t\t\twcagOwns={[this.listBoxId, this.wcagOwns].join(\" \")}\n\t\t\t\t\twcagExpanded={this.list.length && this.focused}\n\t\t\t\t\tref={el => (this.inputRef = el as HTMLGovFormInputElement)}\n\t\t\t\t>\n\t\t\t\t\t<slot slot=\"right-icon\" name=\"right-icon\" />\n\t\t\t\t</gov-form-input>\n\t\t\t\t<ul class={FormAutocompleteClass.list} role={\"listbox\"} id={this.listBoxId}>\n\t\t\t\t\t{this.list.map((item, index) => {\n\t\t\t\t\t\tconst isSelected = this.arrowCounter === index\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\tclass={FormAutocompleteClass.item}\n\t\t\t\t\t\t\t\tinnerHTML={this.templateResolver(item, isSelected)}\n\t\t\t\t\t\t\t\trole={\"option\"}\n\t\t\t\t\t\t\t\taria-posinset={index}\n\t\t\t\t\t\t\t\ttabindex={isSelected ? 0 : -1}\n\t\t\t\t\t\t\t\taria-setsize={this.list.length}\n\t\t\t\t\t\t\t\tonClick={() => this.onSelectHandler(index)}\n\t\t\t\t\t\t\t\taria-selected={toBoolAttr(isSelected)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</ul>\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\tthis.focused = true\n\t\tthis.arrowCounter = -1\n\t\tif ((this.value || this.minlength === 0) && this.searchCallback) {\n\t\t\tthis.doSearch()\n\t\t}\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\tthis.focused = false\n\t\tsetTimeout(() => (this.list = []), 200)\n\t\tthis.arrowCounter = -1\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t}\n\n\tprivate onInputHandler(e: InputEvent) {\n\t\tthis.value = (e.target as HTMLGovFormInputElement).value\n\t\te.stopPropagation()\n\t\tthis.govInput.emit({\n\t\t\toriginalEvent: e,\n\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\tvalue: this.value,\n\t\t\tselected: null\n\t\t})\n\t\tthis.doSearch()\n\t}\n\n\tprivate onSelectHandler(index = -1) {\n\t\tlet selected: Nullable<GovFormAutocompleteItem> = null\n\t\tif (index > -1) {\n\t\t\tselected = this.list[index]\n\t\t} else if (has(this.arrowCounter, this.list)) {\n\t\t\tselected = this.list[this.arrowCounter]\n\t\t}\n\t\tif (selected) {\n\t\t\tthis.govSelect.emit({\n\t\t\t\tcomponent: FormAutocompleteClass.root,\n\t\t\t\tvalue: this.value,\n\t\t\t\tselected: selected\n\t\t\t})\n\t\t\tthis.list = []\n\t\t\tif (has(this.nameKey, selected) && typeof selected[this.nameKey] === \"string\") {\n\t\t\t\tthis.value = selected[this.nameKey]\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onKeyUpHandler(e: CustomEvent) {\n\t\tconst event = (e.detail as FormInputEvent).originalEvent as KeyboardEvent\n\t\te.stopPropagation()\n\t\tif (event.keyCode === 38) this.onArrowUp()\n\t\telse if (event.keyCode === 40) this.onArrowDown()\n\t\telse if (event.keyCode === 13) this.onSelectHandler()\n\t}\n\n\t/**\n\t * Returns the current state of the component\n\t */\n\t@Method()\n\tasync setFocus(options?: FocusOptions): Promise<void> {\n\t\treturn this.inputRef.focus(options)\n\t}\n\n\t/**\n\t * Clears whisperer value\n\t */\n\t@Method()\n\tasync clearValue(): Promise<void> {\n\t\tthis.value = \"\"\n\t\tthis.inputRef.value = \"\"\n\n\t\tawait this.inputRef.clearValue()\n\t}\n\n\t/**\n\t * Set a custom asynchronous function for the whisperer\n\t */\n\t@Method()\n\tasync setSearchCallback(callback: (value: string) => Promise<any>) {\n\t\tthis.searchCallback = callback\n\t}\n\n\t/**\n\t * Setting a custom whisper result template\n\t * @param callback\n\t */\n\t@Method()\n\tasync setTemplateResolver(callback: (item: GovFormAutocompleteItem) => string) {\n\t\tthis.templateResolver = callback\n\t}\n}\n"],"version":3}
@@ -38,62 +38,70 @@ const GovFormCheckbox = class {
38
38
  this.invalid = undefined;
39
39
  this.wcagDescribedBy = undefined;
40
40
  this.wcagLabelledBy = undefined;
41
- this.isChecked = undefined;
42
41
  this.checkboxId = string_utils.createID("GovCheckbox");
43
42
  this.h = template.govHost(this.host);
44
43
  this.f = form.govForm(this.h);
45
44
  }
46
- updateCheckedState(newValue) {
47
- this.isChecked = newValue;
48
- this.govChange.emit({
49
- checked: this.isChecked,
50
- value: this.value,
51
- });
52
- }
53
45
  validateSize(newValue) {
54
46
  props.validateProp(form.FormCheckboxSizes, newValue, form.FormCheckboxClass.root);
55
47
  }
56
48
  componentWillLoad() {
57
- this.isChecked = this.checked;
58
49
  this.f.passAttrToControl("type", "checkbox");
59
50
  }
60
51
  async componentDidRender() {
61
- this.f.passAttrToLabel('identifier', this.identifier || this.checkboxId);
62
- this.f.passAttrToLabel('required', String(this.required));
52
+ this.f.passAttrToLabel("identifier", this.identifier || this.checkboxId);
53
+ this.f.passAttrToLabel("required", String(this.required));
63
54
  if (win.canValidateWcagOnRender()) {
64
55
  await utils.delay(500);
65
56
  await this.validateWcag();
66
57
  }
67
58
  }
68
59
  render() {
69
- const { isChecked } = this;
70
60
  const wrapCheckbox = (children) => {
71
61
  if (this.noLabel) {
72
62
  return (index.h("label", null, children));
73
63
  }
74
64
  return children;
75
65
  };
76
- return (index.h(index.Host, { class: form.FormCheckboxClass.root, "is-checked": isChecked, size: this.size, invalid: template.toBoolAttrIfDefined(this.invalid) }, wrapCheckbox(index.h(Fragment.Fragment, null, index.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": template.toBoolAttr(this.isChecked), "aria-required": template.toBoolAttrIfDefined(this.required), "aria-invalid": template.toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": template.toBoolAttrIfDefined(this.disabled) }), index.h("span", null, index.h("slot", { name: "label" }), index.h("gov-icon", { class: form.FormCheckboxClass.check, name: "check-lg" }))))));
66
+ return (index.h(index.Host, { class: form.FormCheckboxClass.root, checked: this.checked, size: this.size, invalid: template.toBoolAttrIfDefined(this.invalid) }, wrapCheckbox(index.h(Fragment.Fragment, null, index.h("input", { id: this.identifier || this.checkboxId, type: "checkbox", value: this.value, name: this.name, checked: this.checked, onClick: this.onClickHandler.bind(this), onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, ref: el => (this.inputRef = el), "aria-checked": template.toBoolAttr(this.checked), "aria-required": template.toBoolAttrIfDefined(this.required), "aria-invalid": template.toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": template.toBoolAttrIfDefined(this.disabled) }), index.h("span", null, index.h("slot", { name: "label" }), index.h("gov-icon", { class: form.FormCheckboxClass.check, name: "check-lg" }))))));
77
67
  }
78
68
  onFocusHandler(e) {
79
69
  e.stopPropagation();
80
- this.govFocus.emit(e);
70
+ this.govFocus.emit({
71
+ component: form.FormCheckboxClass.root,
72
+ value: this.value,
73
+ checked: this.checked,
74
+ originalEvent: e,
75
+ });
81
76
  }
82
77
  onBlurHandler(e) {
83
78
  e.stopPropagation();
84
- this.govBlur.emit(e);
79
+ this.govBlur.emit({
80
+ component: form.FormCheckboxClass.root,
81
+ value: this.value,
82
+ checked: this.checked,
83
+ originalEvent: e,
84
+ });
85
85
  }
86
86
  onClickHandler(e) {
87
87
  e.stopPropagation();
88
88
  }
89
89
  onChangeHandler(e) {
90
- this.isChecked = e.target.checked;
90
+ this.checked = e.target.checked;
91
91
  e.stopPropagation();
92
92
  this.govChange.emit({
93
- checked: this.isChecked,
93
+ component: form.FormCheckboxClass.root,
94
94
  value: this.value,
95
+ checked: this.checked,
96
+ originalEvent: e,
95
97
  });
96
98
  }
99
+ /**
100
+ * Returns the reference of the native element
101
+ */
102
+ async getRef() {
103
+ return this.inputRef;
104
+ }
97
105
  /**
98
106
  * Validate the WCAG attributes of the component
99
107
  */
@@ -104,7 +112,6 @@ const GovFormCheckbox = class {
104
112
  }
105
113
  get host() { return index.getElement(this); }
106
114
  static get watchers() { return {
107
- "checked": ["updateCheckedState"],
108
115
  "size": ["validateSize"]
109
116
  }; }
110
117
  };
@@ -1 +1 @@
1
- {"file":"gov-form-checkbox.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,m2PAAm2P;;MCmBj3P,eAAe;EAM3B;;;;;;mBAeqD,KAAK;oBAKrB,KAAK;;;gBAaM,GAAG;;mBAQU,KAAK;;;;;IAxCjE,IAAI,CAAC,UAAU,GAAGA,qBAAQ,CAAC,aAAa,CAAC,CAAA;IAEzC,IAAI,CAAC,CAAC,GAAGC,gBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,CAAC,CAAC,GAAGC,YAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;GACxB;EAiED,kBAAkB,CAAC,QAAiB;IACnC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IACzB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;MACnB,OAAO,EAAE,IAAI,CAAC,SAAS;MACvB,KAAK,EAAE,IAAI,CAAC,KAAK;KACjB,CAAC,CAAA;GACF;EAGD,YAAY,CAAC,QAAgB;IAC5BC,kBAAY,CAACC,sBAAiB,EAAE,QAAQ,EAAEC,sBAAiB,CAAC,IAAI,CAAC,CAAA;GACjE;EAED,iBAAiB;IAChB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAA;IAE7B,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;GAC5C;EAED,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AChFS,yBAAoB,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAET,sBAAiB,CAAC,IAAI,CAAC,CAAA;GACrG;;;;;;;;;;;","names":["createID","govHost","govForm","validateProp","FormCheckboxSizes","FormCheckboxClass","canValidateWcagOnRender","delay","h","Host","toBoolAttrIfDefined","Fragment","toBoolAttr","validateWcagRef","validateWcagLabelFor"],"sources":["../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.scss?tag=gov-form-checkbox","../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.tsx"],"sourcesContent":["/*\n * Checkbox\n */\n\n@import \"../checkbox/gov-form-checkbox-core.scss\";\n$class: \".gov-form-checkbox\";\n\n#{$class} {\n\t@extend %form-checkbox-core;\n\tinput + span {\n\t\t&::before {\n\t\t\tborder-radius: $border-radius;\n\t\t}\n\t}\n\t&__check {\n\t\tposition: absolute;\n\t\tcolor: $form-checkbox-check-color;\n\t\topacity: 0;\n\t\ttransition: $t linear opacity;\n\t}\n\n\t// STATES\n\tinput:checked + span::before {\n\t\tbackground: $form-checkbox-indicator-bg;\n\t}\n\tinput:checked + span &__check {\n\t\topacity: 1;\n\t}\n\t@include parameter(\"invalid\") {\n\t\tinput:checked + span::before {\n\t\t\tbackground: $form-state-color-error;\n\t\t}\n\t}\n\t@include parameter(\"disabled\") {\n\t\tinput:checked + span::before {\n\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $form-checkbox-core-sizes {\n\t\t&[size=\"#{$size}\"] {\n\t\t\t#{$class} {\n\t\t\t\t&__check {\n\t\t\t\t\ttop: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\tleft: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\twidth: get(\"check-size\", $definitions);\n\t\t\t\t\theight: get(\"check-size\", $definitions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Host, h, Prop, State, Event, EventEmitter, Element, Watch, Method } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormCheckboxClass, FormCheckboxSizes, FormCheckboxSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost, toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport { GovFormCheckboxChangeEvent } from \"./interfaces\"\nimport Fragment from \"../../../helpers/Fragment\"\n\n@Component({\n\ttag: \"gov-form-checkbox\",\n\tstyleUrl: \"gov-form-checkbox.scss\",\n})\nexport class GovFormCheckbox {\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: HTMLGovFormCheckboxElement\n\t/**\n\t * Value of checkbox\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Checkbox default state\n\t */\n\t@Prop({ reflect: true }) readonly checked: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the checkbox component disabled.\n\t * This prevents users from being able to interact with the checkbox, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the checkbox.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Checkbox's size.\n\t */\n\t@Prop() readonly size?: FormCheckboxSizesType = \"m\"\n\t/**\n\t * Custom checkbox identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Emitted when the checkbox has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the checkbox loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FocusEvent>\n\t/**\n\t * Emitted when the checkbox change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<GovFormCheckboxChangeEvent>\n\n\t@State() isChecked: boolean\n\n\t@Watch(\"checked\")\n\tupdateCheckedState(newValue: boolean): void {\n\t\tthis.isChecked = newValue\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormCheckboxSizes, newValue, FormCheckboxClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.isChecked = this.checked\n\n\t\tthis.f.passAttrToControl(\"type\", \"checkbox\")\n\t}\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={FormCheckboxClass.root} is-checked={isChecked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tchecked={this.isChecked}\n\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\taria-checked={toBoolAttr(this.isChecked)}\n\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t<gov-icon class={FormCheckboxClass.check} name=\"check-lg\"></gov-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Fragment>\n\t\t\t\t)}\n\t\t\t</Host>\n\t\t)\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 onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.isChecked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tchecked: this.isChecked,\n\t\t\tvalue: this.value,\n\t\t})\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormCheckboxClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormCheckboxClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormCheckboxClass.root)\n\t}\n}\n"],"version":3}
1
+ {"file":"gov-form-checkbox.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,kBAAkB,GAAG,m2PAAm2P;;MCmBj3P,eAAe;EAO3B;;;;;;mBAekD,KAAK;oBAKlB,KAAK;;;gBAaM,GAAG;;mBAQU,KAAK;;;;IAxCjE,IAAI,CAAC,UAAU,GAAGA,qBAAQ,CAAC,aAAa,CAAC,CAAA;IAEzC,IAAI,CAAC,CAAC,GAAGC,gBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,CAAC,CAAC,GAAGC,YAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;GACxB;EA+DD,YAAY,CAAC,QAAgB;IAC5BC,kBAAY,CAACC,sBAAiB,EAAE,QAAQ,EAAEC,sBAAiB,CAAC,IAAI,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OAAO,GAAI,CAAC,CAAC,MAA2B,CAAC,OAAO,CAAA;IACrD,CAAC,CAAC,eAAe,EAAE,CAAA;IACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;MACnB,SAAS,EAAEA,sBAAiB,CAAC,IAAI;MACjC,KAAK,EAAE,IAAI,CAAC,KAAK;MACjB,OAAO,EAAE,IAAI,CAAC,OAAO;MACrB,aAAa,EAAE,CAAC;KAChB,CAAC,CAAA;GACF;;;;EAMD,MAAM,MAAM;IACX,OAAO,IAAI,CAAC,QAAQ,CAAA;GACpB;;;;EAMD,MAAM,YAAY;IACjBQ,oBAAe,CAAC,IAAI,CAAC,eAAe,EAAE,mBAAmB,EAAER,sBAAiB,CAAC,IAAI,CAAC,CAAA;IAClFQ,oBAAe,CAAC,IAAI,CAAC,cAAc,EAAE,kBAAkB,EAAER,sBAAiB,CAAC,IAAI,CAAC,CAAA;IAChFS,yBAAoB,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAET,sBAAiB,CAAC,IAAI,CAAC,CAAA;GACrG;;;;;;;;;;","names":["createID","govHost","govForm","validateProp","FormCheckboxSizes","FormCheckboxClass","canValidateWcagOnRender","delay","h","Host","toBoolAttrIfDefined","Fragment","toBoolAttr","validateWcagRef","validateWcagLabelFor"],"sources":["../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.scss?tag=gov-form-checkbox","../../../packages/core/src/components/gov-form/checkbox/gov-form-checkbox.tsx"],"sourcesContent":["/*\n * Checkbox\n */\n\n@import \"../checkbox/gov-form-checkbox-core.scss\";\n$class: \".gov-form-checkbox\";\n\n#{$class} {\n\t@extend %form-checkbox-core;\n\tinput + span {\n\t\t&::before {\n\t\t\tborder-radius: $border-radius;\n\t\t}\n\t}\n\t&__check {\n\t\tposition: absolute;\n\t\tcolor: $form-checkbox-check-color;\n\t\topacity: 0;\n\t\ttransition: $t linear opacity;\n\t}\n\n\t// STATES\n\tinput:checked + span::before {\n\t\tbackground: $form-checkbox-indicator-bg;\n\t}\n\tinput:checked + span &__check {\n\t\topacity: 1;\n\t}\n\t@include parameter(\"invalid\") {\n\t\tinput:checked + span::before {\n\t\t\tbackground: $form-state-color-error;\n\t\t}\n\t}\n\t@include parameter(\"disabled\") {\n\t\tinput:checked + span::before {\n\t\t\tborder-color: $form-state-bg-disabled;\n\t\t\tbackground-color: $form-state-bg-disabled;\n\t\t}\n\t}\n\n\t// VARIANTS\n\t@each $size, $definitions in $form-checkbox-core-sizes {\n\t\t&[size=\"#{$size}\"] {\n\t\t\t#{$class} {\n\t\t\t\t&__check {\n\t\t\t\t\ttop: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\tleft: calc((get(\"indicator-size\", $definitions) - get(\"check-size\", $definitions)) / 2);\n\t\t\t\t\twidth: get(\"check-size\", $definitions);\n\t\t\t\t\theight: get(\"check-size\", $definitions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Component, Host, h, Prop, Event, EventEmitter, Element, Watch, Method } from \"@stencil/core\"\nimport { createID } from \"../../../utils/string.utils\"\nimport { validateProp } from \"../../../helpers/Validate/props\"\nimport { FormCheckboxClass, FormCheckboxSizes, FormCheckboxSizesType } from \"./constants\"\nimport { toBoolAttrIfDefined } from \"../../../helpers/Dom/template\"\nimport { validateWcagLabelFor, validateWcagRef } from \"../../../helpers/Validate/wcag\"\nimport { canValidateWcagOnRender } from \"../../../helpers/Dom/win\"\nimport { delay } from \"../../../utils/utils\"\nimport { GovForm } from \"../../../helpers/Dom/form.types\"\nimport { govHost, toBoolAttr } from \"../../../helpers/Dom/template\"\nimport { GovHost } from \"../../../helpers/Dom/template.types\"\nimport { govForm } from \"../../../helpers/Dom/form\"\nimport Fragment from \"../../../helpers/Fragment\"\nimport { FormCheckboxEvent } from \"./gov-form-checkbox.types\"\n\n@Component({\n\ttag: \"gov-form-checkbox\",\n\tstyleUrl: \"gov-form-checkbox.scss\",\n})\nexport class GovFormCheckbox {\n\tprivate readonly h: GovHost\n\tprivate f: GovForm\n\tprivate inputRef?: HTMLInputElement\n\n\tprivate readonly checkboxId: string\n\n\tconstructor() {\n\t\tthis.checkboxId = createID(\"GovCheckbox\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormCheckboxElement\n\t/**\n\t * Value of checkbox\n\t */\n\t@Prop() readonly value: string\n\t/**\n\t * Checkbox default state\n\t */\n\t@Prop({ reflect: true, mutable: true }) checked = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the checkbox component disabled.\n\t * This prevents users from being able to interact with the checkbox, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop() readonly disabled: boolean\n\t/**\n\t * Name of the checkbox.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Checkboxes size.\n\t */\n\t@Prop() readonly size?: FormCheckboxSizesType = \"m\"\n\t/**\n\t * Custom checkbox identifier.\n\t */\n\t@Prop({ attribute: \"identifier\" }) readonly identifier: string\n\t/**\n\t * When you can't use the form label.\n\t */\n\t@Prop({ attribute: \"no-label\" }) readonly noLabel: boolean = false\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Indicates the id of a component that describes the input.\n\t */\n\t@Prop({ attribute: \"wcag-described-by\" }) readonly wcagDescribedBy: string\n\t/**\n\t * Indicates the id of a component that labels the input.\n\t */\n\t@Prop({ attribute: \"wcag-labelled-by\" }) readonly wcagLabelledBy: string\n\t/**\n\t * Emitted when the checkbox has focus.\n\t */\n\t@Event({ eventName: \"gov-focus\" }) govFocus: EventEmitter<FormCheckboxEvent>\n\t/**\n\t * Emitted when the checkbox loses focus.\n\t */\n\t@Event({ eventName: \"gov-blur\" }) govBlur: EventEmitter<FormCheckboxEvent>\n\t/**\n\t * Emitted when the checkbox change value.\n\t */\n\t@Event({ eventName: \"gov-change\" }) govChange: EventEmitter<FormCheckboxEvent>\n\n\t@Watch(\"size\")\n\tvalidateSize(newValue: string): void {\n\t\tvalidateProp(FormCheckboxSizes, newValue, FormCheckboxClass.root)\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToControl(\"type\", \"checkbox\")\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.f.passAttrToLabel(\"identifier\", this.identifier || this.checkboxId)\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tif (canValidateWcagOnRender()) {\n\t\t\tawait delay(500)\n\t\t\tawait this.validateWcag()\n\t\t}\n\t}\n\n\trender() {\n\t\tconst wrapCheckbox = (children) => {\n\t\t\tif (this.noLabel) {\n\t\t\t\treturn (\n\t\t\t\t\t<label>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</label>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn children\n\t\t}\n\n\t\treturn (\n\t\t\t<Host class={FormCheckboxClass.root} checked={this.checked} size={this.size} invalid={toBoolAttrIfDefined(this.invalid)}>\n\t\t\t\t{wrapCheckbox(\n\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid={this.identifier || this.checkboxId}\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\tchecked={this.checked}\n\t\t\t\t\t\t\tonClick={this.onClickHandler.bind(this)}\n\t\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\t\taria-checked={toBoolAttr(this.checked)}\n\t\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\t\taria-describedby={this.wcagDescribedBy}\n\t\t\t\t\t\t\taria-labelledby={this.wcagLabelledBy}\n\t\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<slot name=\"label\" />\n\t\t\t\t\t\t\t<gov-icon class={FormCheckboxClass.check} name=\"check-lg\"></gov-icon>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Fragment>,\n\t\t\t\t)}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onClickHandler(e: PointerEvent) {\n\t\te.stopPropagation()\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\tthis.checked = (e.target as HTMLInputElement).checked\n\t\te.stopPropagation()\n\t\tthis.govChange.emit({\n\t\t\tcomponent: FormCheckboxClass.root,\n\t\t\tvalue: this.value,\n\t\t\tchecked: this.checked,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Validate the WCAG attributes of the component\n\t */\n\t@Method()\n\tasync validateWcag(): Promise<void> {\n\t\tvalidateWcagRef(this.wcagDescribedBy, \"wcag-described-by\", FormCheckboxClass.root)\n\t\tvalidateWcagRef(this.wcagLabelledBy, \"wcag-labelled-by\", FormCheckboxClass.root)\n\t\tvalidateWcagLabelFor(this.identifier || this.checkboxId, this.wcagLabelledBy, FormCheckboxClass.root)\n\t}\n}\n"],"version":3}
@@ -62,7 +62,7 @@ const GovFormFile = class {
62
62
  this.govBlur = index.createEvent(this, "gov-blur", 7);
63
63
  this.govFiles = index.createEvent(this, "gov-files", 7);
64
64
  this.govAddFile = index.createEvent(this, "gov-add-file", 7);
65
- this.govRemovFile = index.createEvent(this, "gov-remove-file", 7);
65
+ this.govRemoveFile = index.createEvent(this, "gov-remove-file", 7);
66
66
  this.expanded = false;
67
67
  this.required = false;
68
68
  this.disabled = undefined;
@@ -72,26 +72,26 @@ const GovFormFile = class {
72
72
  this.maxFileSize = -1;
73
73
  this.identifier = undefined;
74
74
  this.invalid = undefined;
75
- this.errorSize = 'Soubor je větší než povolená velikost {FILE_SIZE}';
76
- this.errorAccept = 'Soubor tohoto typu není povolen';
77
- this.attachmentsLabel = 'Přílohy';
75
+ this.errorSize = "Soubor je větší než povolená velikost {FILE_SIZE}";
76
+ this.errorAccept = "Soubor tohoto typu není povolen";
77
+ this.attachmentsLabel = "Přílohy";
78
78
  this.wcagDescribedBy = undefined;
79
79
  this.wcagLabelledBy = undefined;
80
- this.wcagRemoveLabel = 'Odebrat soubor {FILE_NAME}';
81
- this.wcagAttachmentsLabel = 'Přílohy';
80
+ this.wcagRemoveLabel = "Odebrat soubor {FILE_NAME}";
81
+ this.wcagAttachmentsLabel = "Přílohy";
82
82
  this.files = [];
83
- this.fileId = string_utils.createID('GovInputFile');
83
+ this.fileId = string_utils.createID("GovInputFile");
84
84
  this.h = template.govHost(this.host);
85
85
  this.f = form.govForm(this.h);
86
86
  }
87
87
  registerListeners() {
88
88
  function highlight() {
89
- this.areaRef.classList.add('highlight');
89
+ this.areaRef.classList.add("highlight");
90
90
  }
91
91
  function unhighlight() {
92
- this.areaRef.classList.remove('highlight');
92
+ this.areaRef.classList.remove("highlight");
93
93
  }
94
- this.inputRef.addEventListener('change', e => {
94
+ this.inputRef.addEventListener("change", e => {
95
95
  e.preventDefault();
96
96
  e.stopPropagation();
97
97
  const files = e.target.files;
@@ -99,13 +99,13 @@ const GovFormFile = class {
99
99
  }, false);
100
100
  //this.inputRef.addEventListener('focus')
101
101
  if (this.expanded) {
102
- const events = ['dragover', 'dragleave'];
103
- const inEvents = ['dragenter', 'dragover', 'mouseenter'];
104
- const outEvents = ['dragleave', 'drop', 'mouseleave'];
102
+ const events = ["dragover", "dragleave"];
103
+ const inEvents = ["dragenter", "dragover", "mouseenter"];
104
+ const outEvents = ["dragleave", "drop", "mouseleave"];
105
105
  events.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false));
106
106
  inEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false));
107
107
  outEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false));
108
- this.areaRef.addEventListener('drop', this.handleDrop.bind(this), false);
108
+ this.areaRef.addEventListener("drop", this.handleDrop.bind(this), false);
109
109
  }
110
110
  }
111
111
  preventDefaults(e) {
@@ -120,23 +120,29 @@ const GovFormFile = class {
120
120
  Array.from(files).map(file => {
121
121
  const isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null;
122
122
  if (isFile === null) {
123
- const isSizeValid = typeof this.maxFileSize === 'number' && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true;
123
+ const isSizeValid = typeof this.maxFileSize === "number" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true;
124
124
  const isAcceptValid = fileAcceptValidation(file, this.accept);
125
125
  const newFile = {
126
- id: string_utils.createID('GovFormFile'),
126
+ id: string_utils.createID("GovFormFile"),
127
127
  file,
128
128
  acceptValid: isAcceptValid,
129
129
  sizeValid: isSizeValid,
130
130
  };
131
131
  this.files = [...this.files, newFile];
132
- this.govAddFile.emit(newFile);
132
+ this.govAddFile.emit({
133
+ component: FormFileClass.root,
134
+ file: newFile,
135
+ });
133
136
  }
134
137
  });
135
- this.govFiles.emit(this.files);
138
+ this.govFiles.emit({
139
+ component: FormFileClass.root,
140
+ files: this.files,
141
+ });
136
142
  }
137
143
  componentWillLoad() {
138
- this.f.passAttrToControl('type', 'File');
139
- this.f.passAttrToLabel('required', String(this.required));
144
+ this.f.passAttrToControl("type", "File");
145
+ this.f.passAttrToLabel("required", String(this.required));
140
146
  }
141
147
  async componentDidRender() {
142
148
  if (win.canValidateWcagOnRender()) {
@@ -146,7 +152,7 @@ const GovFormFile = class {
146
152
  this.registerListeners();
147
153
  }
148
154
  render() {
149
- return (index.h(index.Host, { class: this.h.classes([FormFileClass.root]), invalid: template.toBoolAttrIfDefined(this.invalid), expanded: template.toBoolAttrIfDefined(this.expanded) }, index.h("div", { class: FormFileClass.area, ref: el => (this.areaRef = el) }, index.h("slot", null), index.h("input", { class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled, "aria-required": template.toBoolAttrIfDefined(this.required), "aria-invalid": template.toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": template.toBoolAttrIfDefined(this.disabled) })), this.h.hasSlot('attachments') ? (index.h("div", { class: FormFileClass.attachments }, index.h("slot", { name: 'attachments' }))) : null, this.files.length && this.displayAttachments ? (index.h("div", { class: FormFileClass.attachments }, index.h("gov-attachments", { label: this.wcagAttachmentsLabel, "wcag-label": this.wcagAttachmentsLabel }, this.files.map(item => (index.h("gov-attachments-item", { "wcag-remove-labelled-by": item.id, "on-gov-remove": () => this.onRemoveFileHandler(item) }, index.h("span", { class: 'sr-only', id: item.id }, this.wcagRemoveLabel.replace('{FILE_NAME}', item.file.name)), item.file.name, item.acceptValid === false ? (index.h("gov-form-message", { slot: "message", variant: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), item.acceptValid === false ? this.errorAccept : null)) : null, item.sizeValid === false ? (index.h("gov-form-message", { slot: "message", variant: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), this.errorSize.replace('{FILE_SIZE}', formatBytes(this.maxFileSize * 1024)))) : null, index.h("span", { slot: "info" }, "(", formatBytes(item.file.size), ")"))))))) : null));
155
+ return (index.h(index.Host, { class: this.h.classes([FormFileClass.root]), invalid: template.toBoolAttrIfDefined(this.invalid), expanded: template.toBoolAttrIfDefined(this.expanded) }, index.h("div", { class: FormFileClass.area, ref: el => (this.areaRef = el) }, index.h("slot", null), index.h("input", { class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled, "aria-required": template.toBoolAttrIfDefined(this.required), "aria-invalid": template.toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-disabled": template.toBoolAttrIfDefined(this.disabled) })), this.h.hasSlot("attachments") ? (index.h("div", { class: FormFileClass.attachments }, index.h("slot", { name: "attachments" }))) : null, this.files.length && this.displayAttachments ? (index.h("div", { class: FormFileClass.attachments }, index.h("gov-attachments", { label: this.wcagAttachmentsLabel, "wcag-label": this.wcagAttachmentsLabel }, this.files.map(item => (index.h("gov-attachments-item", { "wcag-remove-labelled-by": item.id, "on-gov-remove": () => this.onRemoveFileHandler(item) }, index.h("span", { class: "sr-only", id: item.id }, this.wcagRemoveLabel.replace("{FILE_NAME}", item.file.name)), item.file.name, item.acceptValid === false ? (index.h("gov-form-message", { slot: "message", variant: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), item.acceptValid === false ? this.errorAccept : null)) : null, item.sizeValid === false ? (index.h("gov-form-message", { slot: "message", variant: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill" }), this.errorSize.replace("{FILE_SIZE}", formatBytes(this.maxFileSize * 1024)))) : null, index.h("span", { slot: "info" }, "(", formatBytes(item.file.size), ")"))))))) : null));
150
156
  }
151
157
  onRemoveFileHandler(file) {
152
158
  const index = this.files.findIndex(item => item.id === file.id);
@@ -155,27 +161,51 @@ const GovFormFile = class {
155
161
  const removeFile = this.files[index];
156
162
  files.splice(index, 1);
157
163
  this.files = [...files];
158
- this.govRemovFile.emit(removeFile);
159
- this.govFiles.emit(this.files);
164
+ this.govRemoveFile.emit({
165
+ component: FormFileClass.root,
166
+ file: removeFile,
167
+ });
168
+ this.govFiles.emit({
169
+ component: FormFileClass.root,
170
+ files,
171
+ });
160
172
  }
161
173
  }
162
174
  onFocusHandler(e) {
163
175
  e.stopPropagation();
164
- this.govFocus.emit(e);
176
+ this.govFocus.emit({
177
+ component: FormFileClass.root,
178
+ originalEvent: e,
179
+ });
165
180
  }
166
181
  onBlurHandler(e) {
167
182
  e.stopPropagation();
168
- this.govBlur.emit(e);
183
+ this.govBlur.emit({
184
+ component: FormFileClass.root,
185
+ originalEvent: e,
186
+ });
169
187
  }
170
188
  onChangeHandler(e) {
171
189
  e.stopPropagation();
172
190
  }
191
+ /**
192
+ * Returns the reference of the native element
193
+ */
194
+ async getRef() {
195
+ return this.inputRef;
196
+ }
197
+ /**
198
+ * Returns the reference of the native area element
199
+ */
200
+ async getAreaRef() {
201
+ return this.areaRef;
202
+ }
173
203
  /**
174
204
  * Validate the WCAG attributes of the component
175
205
  */
176
206
  async validateWcag() {
177
- wcag.validateWcagRef(this.wcagDescribedBy, 'wcag-described-by', FormFileClass.root);
178
- wcag.validateWcagRef(this.wcagLabelledBy, 'wcag-labelled-by', FormFileClass.root);
207
+ wcag.validateWcagRef(this.wcagDescribedBy, "wcag-described-by", FormFileClass.root);
208
+ wcag.validateWcagRef(this.wcagLabelledBy, "wcag-labelled-by", FormFileClass.root);
179
209
  wcag.validateWcagLabelFor(this.identifier || this.fileId, this.wcagLabelledBy, FormFileClass.root);
180
210
  }
181
211
  get host() { return index.getElement(this); }