@govtechsg/sgds-web-component 3.0.0-rc.1 → 3.0.0-rc.2

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 (478) hide show
  1. package/README.md +5 -5
  2. package/base/button.js +1 -1
  3. package/base/form-control-element.d.ts +4 -11
  4. package/base/form-control-element.js +13 -23
  5. package/base/form-control-element.js.map +1 -1
  6. package/components/Accordion/accordion-item.js +1 -1
  7. package/components/Accordion/index.umd.js +7 -19
  8. package/components/Accordion/index.umd.js.map +1 -1
  9. package/components/Accordion/sgds-accordion-item.d.ts +3 -7
  10. package/components/Accordion/sgds-accordion-item.js +6 -18
  11. package/components/Accordion/sgds-accordion-item.js.map +1 -1
  12. package/components/ActionCard/index.umd.js +407 -329
  13. package/components/ActionCard/index.umd.js.map +1 -1
  14. package/components/Alert/alert.js +1 -1
  15. package/components/Alert/index.umd.js +553 -485
  16. package/components/Alert/index.umd.js.map +1 -1
  17. package/components/Alert/sgds-alert.d.ts +2 -2
  18. package/components/Alert/sgds-alert.js +6 -13
  19. package/components/Alert/sgds-alert.js.map +1 -1
  20. package/components/Badge/badge.js +1 -1
  21. package/components/Badge/index.umd.js +8 -9
  22. package/components/Badge/index.umd.js.map +1 -1
  23. package/components/Badge/sgds-badge.d.ts +4 -5
  24. package/components/Badge/sgds-badge.js +5 -6
  25. package/components/Badge/sgds-badge.js.map +1 -1
  26. package/components/Button/index.umd.js +8 -81
  27. package/components/Button/index.umd.js.map +1 -1
  28. package/components/Button/sgds-button.js +1 -1
  29. package/components/Button/sgds-button.js.map +1 -1
  30. package/components/Checkbox/checkbox.js +1 -1
  31. package/components/Checkbox/index.umd.js +541 -475
  32. package/components/Checkbox/index.umd.js.map +1 -1
  33. package/components/Checkbox/sgds-checkbox-group.d.ts +7 -1
  34. package/components/Checkbox/sgds-checkbox-group.js +15 -4
  35. package/components/Checkbox/sgds-checkbox-group.js.map +1 -1
  36. package/components/Checkbox/sgds-checkbox.d.ts +30 -21
  37. package/components/Checkbox/sgds-checkbox.js +77 -60
  38. package/components/Checkbox/sgds-checkbox.js.map +1 -1
  39. package/components/ComboBox/index.umd.js +385 -216
  40. package/components/ComboBox/index.umd.js.map +1 -1
  41. package/components/Datepicker/datepicker-input.d.ts +4 -2
  42. package/components/Datepicker/datepicker-input.js +24 -7
  43. package/components/Datepicker/datepicker-input.js.map +1 -1
  44. package/components/Datepicker/index.umd.js +433 -244
  45. package/components/Datepicker/index.umd.js.map +1 -1
  46. package/components/Datepicker/sgds-datepicker.d.ts +1 -1
  47. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  48. package/components/Drawer/index.umd.js +2 -2
  49. package/components/Drawer/index.umd.js.map +1 -1
  50. package/components/Dropdown/index.umd.js +8 -81
  51. package/components/Dropdown/index.umd.js.map +1 -1
  52. package/components/FileUpload/file-upload.js +1 -1
  53. package/components/FileUpload/index.umd.js +579 -272
  54. package/components/FileUpload/index.umd.js.map +1 -1
  55. package/components/FileUpload/sgds-file-upload.d.ts +42 -30
  56. package/components/FileUpload/sgds-file-upload.js +147 -103
  57. package/components/FileUpload/sgds-file-upload.js.map +1 -1
  58. package/components/Footer/footer-item.js +6 -0
  59. package/components/Footer/footer-item.js.map +1 -0
  60. package/components/Footer/footer.js +1 -1
  61. package/components/Footer/index.d.ts +2 -0
  62. package/components/Footer/index.js +2 -0
  63. package/components/Footer/index.js.map +1 -1
  64. package/components/Footer/index.umd.js +93 -94
  65. package/components/Footer/index.umd.js.map +1 -1
  66. package/components/Footer/sgds-footer-item.d.ts +13 -0
  67. package/components/Footer/sgds-footer-item.js +27 -0
  68. package/components/Footer/sgds-footer-item.js.map +1 -0
  69. package/components/Footer/sgds-footer.d.ts +9 -30
  70. package/components/Footer/sgds-footer.js +65 -90
  71. package/components/Footer/sgds-footer.js.map +1 -1
  72. package/components/Icon/icon.js +6 -0
  73. package/components/Icon/icon.js.map +1 -0
  74. package/components/Icon/index.d.ts +6 -0
  75. package/components/Icon/index.js +4 -0
  76. package/components/Icon/index.js.map +1 -0
  77. package/components/Icon/index.umd.js +4389 -0
  78. package/components/Icon/index.umd.js.map +1 -0
  79. package/components/Icon/sgds-icon.d.ts +21 -0
  80. package/components/Icon/sgds-icon.js +64 -0
  81. package/components/Icon/sgds-icon.js.map +1 -0
  82. package/components/IconButton/icon-button.js +1 -1
  83. package/components/IconButton/index.umd.js +6 -9
  84. package/components/IconButton/index.umd.js.map +1 -1
  85. package/components/IconButton/sgds-icon-button.d.ts +2 -2
  86. package/components/IconButton/sgds-icon-button.js +4 -9
  87. package/components/IconButton/sgds-icon-button.js.map +1 -1
  88. package/components/Input/index.umd.js +1734 -1376
  89. package/components/Input/index.umd.js.map +1 -1
  90. package/components/Input/sgds-input.d.ts +41 -21
  91. package/components/Input/sgds-input.js +103 -66
  92. package/components/Input/sgds-input.js.map +1 -1
  93. package/components/Modal/index.umd.js +2 -2
  94. package/components/Modal/index.umd.js.map +1 -1
  95. package/components/QuantityToggle/index.umd.js +894 -316
  96. package/components/QuantityToggle/index.umd.js.map +1 -1
  97. package/components/QuantityToggle/sgds-quantity-toggle.d.ts +42 -15
  98. package/components/QuantityToggle/sgds-quantity-toggle.js +129 -62
  99. package/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  100. package/components/Radio/index.umd.js +516 -203
  101. package/components/Radio/index.umd.js.map +1 -1
  102. package/components/Radio/sgds-radio-group.d.ts +38 -27
  103. package/components/Radio/sgds-radio-group.js +100 -84
  104. package/components/Radio/sgds-radio-group.js.map +1 -1
  105. package/components/Radio/sgds-radio.js +1 -1
  106. package/components/Radio/sgds-radio.js.map +1 -1
  107. package/components/Stepper/index.umd.js +1 -0
  108. package/components/Stepper/index.umd.js.map +1 -1
  109. package/components/Stepper/sgds-stepper.d.ts +1 -0
  110. package/components/Stepper/sgds-stepper.js +1 -0
  111. package/components/Stepper/sgds-stepper.js.map +1 -1
  112. package/components/Switch/index.umd.js +21 -321
  113. package/components/Switch/index.umd.js.map +1 -1
  114. package/components/Switch/sgds-switch.js +1 -2
  115. package/components/Switch/sgds-switch.js.map +1 -1
  116. package/components/Textarea/index.umd.js +1554 -1336
  117. package/components/Textarea/index.umd.js.map +1 -1
  118. package/components/Textarea/sgds-textarea.d.ts +33 -22
  119. package/components/Textarea/sgds-textarea.js +78 -75
  120. package/components/Textarea/sgds-textarea.js.map +1 -1
  121. package/components/Textarea/textarea.js +1 -1
  122. package/components/Toast/index.umd.js +9 -21
  123. package/components/Toast/index.umd.js.map +1 -1
  124. package/components/Toast/sgds-toast.d.ts +2 -1
  125. package/components/Toast/sgds-toast.js +6 -18
  126. package/components/Toast/sgds-toast.js.map +1 -1
  127. package/components/Toast/toast.js +1 -1
  128. package/components/Tooltip/index.umd.js +14 -14
  129. package/components/Tooltip/index.umd.js.map +1 -1
  130. package/components/Tooltip/sgds-tooltip.d.ts +4 -7
  131. package/components/Tooltip/sgds-tooltip.js +14 -14
  132. package/components/Tooltip/sgds-tooltip.js.map +1 -1
  133. package/components/index.d.ts +1 -0
  134. package/components/index.js +1 -0
  135. package/components/index.js.map +1 -1
  136. package/components/index.umd.js +1318 -1124
  137. package/components/index.umd.js.map +1 -1
  138. package/icons/arrow-bar-down.svg +3 -0
  139. package/icons/arrow-bar-left.svg +3 -0
  140. package/icons/arrow-bar-right.svg +3 -0
  141. package/icons/arrow-bar-up.svg +3 -0
  142. package/icons/arrow-clockwise.svg +3 -0
  143. package/icons/arrow-down.svg +3 -0
  144. package/icons/arrow-left.svg +3 -0
  145. package/icons/arrow-repeat.svg +3 -0
  146. package/icons/arrow-right.svg +3 -0
  147. package/icons/arrow-up.svg +3 -0
  148. package/icons/bank-fill.svg +3 -0
  149. package/icons/bell-slash.svg +3 -0
  150. package/icons/bell.svg +3 -0
  151. package/icons/bi-funnel.svg +3 -0
  152. package/icons/bookmark-fill.svg +3 -0
  153. package/icons/bookmark.svg +3 -0
  154. package/icons/box-arrow-up-right.svg +3 -0
  155. package/icons/box-seam.svg +3 -0
  156. package/icons/building.svg +3 -0
  157. package/icons/calculator.svg +3 -0
  158. package/icons/calendar-check.svg +4 -0
  159. package/icons/calendar-x.svg +4 -0
  160. package/icons/calendar.svg +3 -0
  161. package/icons/camera.svg +3 -0
  162. package/icons/chat-left-text.svg +3 -0
  163. package/icons/check-circle-fill.svg +3 -0
  164. package/icons/check-circle.svg +3 -0
  165. package/icons/check.svg +3 -0
  166. package/icons/chevron-down.svg +3 -0
  167. package/icons/chevron-left.svg +3 -0
  168. package/icons/chevron-right.svg +3 -0
  169. package/icons/chevron-up .svg +3 -0
  170. package/icons/clock.svg +4 -0
  171. package/icons/cloud-check.svg +4 -0
  172. package/icons/cloud-download.svg +3 -0
  173. package/icons/cloud-upload.svg +3 -0
  174. package/icons/cloud.svg +3 -0
  175. package/icons/compass.svg +4 -0
  176. package/icons/cross.svg +3 -0
  177. package/icons/cursor-fill.svg +3 -0
  178. package/icons/cursor.svg +3 -0
  179. package/icons/dash-circle.svg +3 -0
  180. package/icons/dash-square.svg +3 -0
  181. package/icons/dash.svg +3 -0
  182. package/icons/download.svg +3 -0
  183. package/icons/exclamation-circle-fill.svg +3 -0
  184. package/icons/exclamation-circle.svg +4 -0
  185. package/icons/exclamation-triangle-fill.svg +3 -0
  186. package/icons/exclamation-triangle.svg +4 -0
  187. package/icons/exclamation.svg +4 -0
  188. package/icons/eye-fill.svg +3 -0
  189. package/icons/eye-slash-fill.svg +4 -0
  190. package/icons/eye-slash.svg +3 -0
  191. package/icons/eye.svg +3 -0
  192. package/icons/facebook.svg +3 -0
  193. package/icons/file-earmark-text.svg +3 -0
  194. package/icons/file-pdf.svg +4 -0
  195. package/icons/file-plus.svg +4 -0
  196. package/icons/file-text.svg +3 -0
  197. package/icons/file.svg +3 -0
  198. package/icons/files.svg +4 -0
  199. package/icons/folder-check.svg +4 -0
  200. package/icons/folder-minus.svg +4 -0
  201. package/icons/folder-plus.svg +4 -0
  202. package/icons/folder.svg +3 -0
  203. package/icons/gear.svg +3 -0
  204. package/icons/geo-alt.svg +4 -0
  205. package/icons/geo-fill.svg +4 -0
  206. package/icons/geo.svg +4 -0
  207. package/icons/google.svg +3 -0
  208. package/icons/grid-fill.svg +3 -0
  209. package/icons/hand-thumbs-down.svg +3 -0
  210. package/icons/hand-thumbs-up.svg +3 -0
  211. package/icons/hdd.svg +3 -0
  212. package/icons/house-door.svg +3 -0
  213. package/icons/house.svg +3 -0
  214. package/icons/image.svg +3 -0
  215. package/icons/inbox.svg +3 -0
  216. package/icons/info-circle-fill.svg +3 -0
  217. package/icons/info-circle.svg +4 -0
  218. package/icons/instagram.svg +3 -0
  219. package/icons/layers.svg +3 -0
  220. package/icons/layout-text-window-reverse.svg +3 -0
  221. package/icons/layout-text-window.svg +3 -0
  222. package/icons/layout.svg +3 -0
  223. package/icons/link.svg +3 -0
  224. package/icons/linkedin.svg +3 -0
  225. package/icons/list.svg +3 -0
  226. package/icons/lock-fill.svg +3 -0
  227. package/icons/lock.svg +3 -0
  228. package/icons/mail.svg +3 -0
  229. package/icons/map.svg +3 -0
  230. package/icons/paperclip.svg +3 -0
  231. package/icons/pencil.svg +3 -0
  232. package/icons/pending-circle.svg +3 -0
  233. package/icons/person-dash.svg +3 -0
  234. package/icons/person-plus.svg +3 -0
  235. package/icons/person-x.svg +3 -0
  236. package/icons/person.svg +3 -0
  237. package/icons/pin-map-fill.svg +3 -0
  238. package/icons/pin.svg +3 -0
  239. package/icons/placeholder.svg +3 -0
  240. package/icons/plus-circle.svg +3 -0
  241. package/icons/plus-square.svg +3 -0
  242. package/icons/plus.svg +3 -0
  243. package/icons/printer.svg +3 -0
  244. package/icons/question-circle.svg +4 -0
  245. package/icons/save.svg +3 -0
  246. package/icons/search.svg +3 -0
  247. package/icons/share.svg +3 -0
  248. package/icons/slash-circle.svg +3 -0
  249. package/icons/sliders.svg +3 -0
  250. package/icons/speedometer.svg +3 -0
  251. package/icons/star-fill.svg +3 -0
  252. package/icons/star.svg +3 -0
  253. package/icons/stoplights.svg +4 -0
  254. package/icons/telephone.svg +3 -0
  255. package/icons/three-dots-vertical.svg +3 -0
  256. package/icons/three-dots.svg +3 -0
  257. package/icons/toggle-off.svg +3 -0
  258. package/icons/toggle-on.svg +3 -0
  259. package/icons/trash.svg +3 -0
  260. package/icons/twitter-x.svg +3 -0
  261. package/icons/unlock.svg +3 -0
  262. package/icons/upload.svg +3 -0
  263. package/icons/window-dash.svg +4 -0
  264. package/icons/window-desktop.svg +4 -0
  265. package/icons/window-dock.svg +4 -0
  266. package/icons/window-fullscreen.svg +3 -0
  267. package/icons/window-plus.svg +4 -0
  268. package/icons/window-sidebar.svg +3 -0
  269. package/icons/window-split.svg +3 -0
  270. package/icons/window-stack.svg +3 -0
  271. package/icons/window-x.svg +4 -0
  272. package/icons/window.svg +3 -0
  273. package/icons/x-circle-fill.svg +3 -0
  274. package/icons/x-circle.svg +3 -0
  275. package/icons/youtube.svg +3 -0
  276. package/icons/zoom-in.svg +3 -0
  277. package/icons/zoom-out.svg +3 -0
  278. package/index.d.ts +1 -0
  279. package/index.js +1 -0
  280. package/index.js.map +1 -1
  281. package/index.umd.js +1338 -1119
  282. package/index.umd.js.map +1 -1
  283. package/internals/CloseButton/close-button.js +1 -1
  284. package/internals/CloseButton/sgds-close-button.js +1 -1
  285. package/internals/CloseButton/sgds-close-button.js.map +1 -1
  286. package/package.json +1 -1
  287. package/react/base/button.cjs.js +1 -1
  288. package/react/base/button.js +1 -1
  289. package/react/base/form-control-element.cjs.js +13 -23
  290. package/react/base/form-control-element.cjs.js.map +1 -1
  291. package/react/base/form-control-element.js +13 -23
  292. package/react/base/form-control-element.js.map +1 -1
  293. package/react/checkbox/index.cjs.js +2 -0
  294. package/react/checkbox/index.cjs.js.map +1 -1
  295. package/react/checkbox/index.d.ts +2 -0
  296. package/react/checkbox/index.js +2 -0
  297. package/react/checkbox/index.js.map +1 -1
  298. package/react/components/Accordion/accordion-item.cjs.js +1 -1
  299. package/react/components/Accordion/accordion-item.js +1 -1
  300. package/react/components/Accordion/sgds-accordion-item.cjs.js +6 -18
  301. package/react/components/Accordion/sgds-accordion-item.cjs.js.map +1 -1
  302. package/react/components/Accordion/sgds-accordion-item.js +6 -18
  303. package/react/components/Accordion/sgds-accordion-item.js.map +1 -1
  304. package/react/components/Alert/alert.cjs.js +1 -1
  305. package/react/components/Alert/alert.js +1 -1
  306. package/react/components/Alert/sgds-alert.cjs.js +5 -12
  307. package/react/components/Alert/sgds-alert.cjs.js.map +1 -1
  308. package/react/components/Alert/sgds-alert.js +6 -13
  309. package/react/components/Alert/sgds-alert.js.map +1 -1
  310. package/react/components/Badge/badge.cjs.js +1 -1
  311. package/react/components/Badge/badge.js +1 -1
  312. package/react/components/Badge/sgds-badge.cjs.js +5 -6
  313. package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
  314. package/react/components/Badge/sgds-badge.js +5 -6
  315. package/react/components/Badge/sgds-badge.js.map +1 -1
  316. package/react/components/Button/sgds-button.cjs.js +2 -2
  317. package/react/components/Button/sgds-button.cjs.js.map +1 -1
  318. package/react/components/Button/sgds-button.js +1 -1
  319. package/react/components/Button/sgds-button.js.map +1 -1
  320. package/react/components/Checkbox/checkbox.cjs.js +1 -1
  321. package/react/components/Checkbox/checkbox.js +1 -1
  322. package/react/components/Checkbox/sgds-checkbox-group.cjs.js +15 -4
  323. package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
  324. package/react/components/Checkbox/sgds-checkbox-group.js +15 -4
  325. package/react/components/Checkbox/sgds-checkbox-group.js.map +1 -1
  326. package/react/components/Checkbox/sgds-checkbox.cjs.js +77 -60
  327. package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
  328. package/react/components/Checkbox/sgds-checkbox.js +77 -60
  329. package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
  330. package/react/components/Datepicker/datepicker-input.cjs.js +24 -7
  331. package/react/components/Datepicker/datepicker-input.cjs.js.map +1 -1
  332. package/react/components/Datepicker/datepicker-input.js +24 -7
  333. package/react/components/Datepicker/datepicker-input.js.map +1 -1
  334. package/react/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  335. package/react/components/Datepicker/sgds-datepicker.js.map +1 -1
  336. package/react/components/FileUpload/file-upload.cjs.js +1 -1
  337. package/react/components/FileUpload/file-upload.js +1 -1
  338. package/react/components/FileUpload/sgds-file-upload.cjs.js +145 -101
  339. package/react/components/FileUpload/sgds-file-upload.cjs.js.map +1 -1
  340. package/react/components/FileUpload/sgds-file-upload.js +147 -103
  341. package/react/components/FileUpload/sgds-file-upload.js.map +1 -1
  342. package/react/components/Footer/footer-item.cjs.js +11 -0
  343. package/react/components/Footer/footer-item.cjs.js.map +1 -0
  344. package/react/components/Footer/footer-item.js +7 -0
  345. package/react/components/Footer/footer-item.js.map +1 -0
  346. package/react/components/Footer/footer.cjs.js +1 -1
  347. package/react/components/Footer/footer.js +1 -1
  348. package/react/components/Footer/sgds-footer-item.cjs.js +33 -0
  349. package/react/components/Footer/sgds-footer-item.cjs.js.map +1 -0
  350. package/react/components/Footer/sgds-footer-item.js +28 -0
  351. package/react/components/Footer/sgds-footer-item.js.map +1 -0
  352. package/react/components/Footer/sgds-footer.cjs.js +65 -90
  353. package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
  354. package/react/components/Footer/sgds-footer.js +65 -90
  355. package/react/components/Footer/sgds-footer.js.map +1 -1
  356. package/react/components/Icon/icon.cjs.js +11 -0
  357. package/react/components/Icon/icon.cjs.js.map +1 -0
  358. package/react/components/Icon/icon.js +7 -0
  359. package/react/components/Icon/icon.js.map +1 -0
  360. package/react/components/Icon/sgds-icon.cjs.js +70 -0
  361. package/react/components/Icon/sgds-icon.cjs.js.map +1 -0
  362. package/react/components/Icon/sgds-icon.js +65 -0
  363. package/react/components/Icon/sgds-icon.js.map +1 -0
  364. package/react/components/IconButton/icon-button.cjs.js +1 -1
  365. package/react/components/IconButton/icon-button.js +1 -1
  366. package/react/components/IconButton/sgds-icon-button.cjs.js +4 -9
  367. package/react/components/IconButton/sgds-icon-button.cjs.js.map +1 -1
  368. package/react/components/IconButton/sgds-icon-button.js +4 -9
  369. package/react/components/IconButton/sgds-icon-button.js.map +1 -1
  370. package/react/components/Input/sgds-input.cjs.js +101 -64
  371. package/react/components/Input/sgds-input.cjs.js.map +1 -1
  372. package/react/components/Input/sgds-input.js +103 -66
  373. package/react/components/Input/sgds-input.js.map +1 -1
  374. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js +128 -61
  375. package/react/components/QuantityToggle/sgds-quantity-toggle.cjs.js.map +1 -1
  376. package/react/components/QuantityToggle/sgds-quantity-toggle.js +129 -62
  377. package/react/components/QuantityToggle/sgds-quantity-toggle.js.map +1 -1
  378. package/react/components/Radio/sgds-radio-group.cjs.js +99 -83
  379. package/react/components/Radio/sgds-radio-group.cjs.js.map +1 -1
  380. package/react/components/Radio/sgds-radio-group.js +100 -84
  381. package/react/components/Radio/sgds-radio-group.js.map +1 -1
  382. package/react/components/Radio/sgds-radio.cjs.js +1 -1
  383. package/react/components/Radio/sgds-radio.cjs.js.map +1 -1
  384. package/react/components/Radio/sgds-radio.js +1 -1
  385. package/react/components/Radio/sgds-radio.js.map +1 -1
  386. package/react/components/Stepper/sgds-stepper.cjs.js +1 -0
  387. package/react/components/Stepper/sgds-stepper.cjs.js.map +1 -1
  388. package/react/components/Stepper/sgds-stepper.js +1 -0
  389. package/react/components/Stepper/sgds-stepper.js.map +1 -1
  390. package/react/components/Switch/sgds-switch.cjs.js +1 -2
  391. package/react/components/Switch/sgds-switch.cjs.js.map +1 -1
  392. package/react/components/Switch/sgds-switch.js +1 -2
  393. package/react/components/Switch/sgds-switch.js.map +1 -1
  394. package/react/components/Textarea/sgds-textarea.cjs.js +76 -73
  395. package/react/components/Textarea/sgds-textarea.cjs.js.map +1 -1
  396. package/react/components/Textarea/sgds-textarea.js +78 -75
  397. package/react/components/Textarea/sgds-textarea.js.map +1 -1
  398. package/react/components/Textarea/textarea.cjs.js +1 -1
  399. package/react/components/Textarea/textarea.js +1 -1
  400. package/react/components/Toast/sgds-toast.cjs.js +6 -18
  401. package/react/components/Toast/sgds-toast.cjs.js.map +1 -1
  402. package/react/components/Toast/sgds-toast.js +6 -18
  403. package/react/components/Toast/sgds-toast.js.map +1 -1
  404. package/react/components/Toast/toast.cjs.js +1 -1
  405. package/react/components/Toast/toast.js +1 -1
  406. package/react/components/Tooltip/sgds-tooltip.cjs.js +14 -14
  407. package/react/components/Tooltip/sgds-tooltip.cjs.js.map +1 -1
  408. package/react/components/Tooltip/sgds-tooltip.js +14 -14
  409. package/react/components/Tooltip/sgds-tooltip.js.map +1 -1
  410. package/react/footer-item/index.cjs.js +39 -0
  411. package/react/footer-item/index.cjs.js.map +1 -0
  412. package/react/footer-item/index.d.ts +3 -0
  413. package/react/footer-item/index.js +15 -0
  414. package/react/footer-item/index.js.map +1 -0
  415. package/react/icon/index.cjs.js +42 -0
  416. package/react/icon/index.cjs.js.map +1 -0
  417. package/react/icon/index.d.ts +6 -0
  418. package/react/icon/index.js +18 -0
  419. package/react/icon/index.js.map +1 -0
  420. package/react/index.cjs.js +64 -60
  421. package/react/index.cjs.js.map +1 -1
  422. package/react/index.d.ts +2 -0
  423. package/react/index.js +2 -0
  424. package/react/index.js.map +1 -1
  425. package/react/input/index.cjs.js +3 -1
  426. package/react/input/index.cjs.js.map +1 -1
  427. package/react/input/index.d.ts +2 -0
  428. package/react/input/index.js +3 -1
  429. package/react/input/index.js.map +1 -1
  430. package/react/internals/CloseButton/close-button.cjs.js +1 -1
  431. package/react/internals/CloseButton/close-button.js +1 -1
  432. package/react/internals/CloseButton/sgds-close-button.cjs.js +1 -1
  433. package/react/internals/CloseButton/sgds-close-button.cjs.js.map +1 -1
  434. package/react/internals/CloseButton/sgds-close-button.js +1 -1
  435. package/react/internals/CloseButton/sgds-close-button.js.map +1 -1
  436. package/react/styles/form-hint.cjs.js +1 -1
  437. package/react/styles/form-hint.js +1 -1
  438. package/react/styles/form-label.cjs.js +1 -1
  439. package/react/styles/form-label.js +1 -1
  440. package/react/utils/formSubmitController.cjs.js +64 -0
  441. package/react/utils/formSubmitController.cjs.js.map +1 -0
  442. package/react/utils/formSubmitController.js +60 -0
  443. package/react/utils/formSubmitController.js.map +1 -0
  444. package/react/utils/inputValidationController.cjs.js +130 -0
  445. package/react/utils/inputValidationController.cjs.js.map +1 -0
  446. package/react/utils/inputValidationController.js +126 -0
  447. package/react/utils/inputValidationController.js.map +1 -0
  448. package/react/utils/validatorMixin.cjs.js +108 -0
  449. package/react/utils/validatorMixin.cjs.js.map +1 -0
  450. package/react/utils/validatorMixin.js +104 -0
  451. package/react/utils/validatorMixin.js.map +1 -0
  452. package/styles/form-hint.js +1 -1
  453. package/styles/form-label.js +1 -1
  454. package/themes/day.css +1 -1
  455. package/themes/night.css +3 -2
  456. package/themes/root.css +1 -0
  457. package/utils/{form.d.ts → formSubmitController.d.ts} +10 -20
  458. package/utils/formSubmitController.js +59 -0
  459. package/utils/formSubmitController.js.map +1 -0
  460. package/utils/inputValidationController.d.ts +70 -0
  461. package/utils/inputValidationController.js +125 -0
  462. package/utils/inputValidationController.js.map +1 -0
  463. package/utils/validatorMixin.d.ts +24 -0
  464. package/utils/validatorMixin.js +103 -0
  465. package/utils/validatorMixin.js.map +1 -0
  466. package/base/form-check-element.d.ts +0 -50
  467. package/base/form-check-element.js +0 -169
  468. package/base/form-check-element.js.map +0 -1
  469. package/react/base/form-check-element.cjs.js +0 -175
  470. package/react/base/form-check-element.cjs.js.map +0 -1
  471. package/react/base/form-check-element.js +0 -170
  472. package/react/base/form-check-element.js.map +0 -1
  473. package/react/utils/form.cjs.js +0 -137
  474. package/react/utils/form.cjs.js.map +0 -1
  475. package/react/utils/form.js +0 -133
  476. package/react/utils/form.js.map +0 -1
  477. package/utils/form.js +0 -132
  478. package/utils/form.js.map +0 -1
@@ -144,7 +144,7 @@
144
144
  const { is: is$1, defineProperty: defineProperty$1, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getOwnPropertySymbols: getOwnPropertySymbols$1, getPrototypeOf: getPrototypeOf$1, } = Object;
145
145
  // Lets a minifier replace globalThis references with a minified name
146
146
  const global$3 = globalThis;
147
- let issueWarning$5;
147
+ let issueWarning$4;
148
148
  const trustedTypes$2 = global$3
149
149
  .trustedTypes;
150
150
  // Temporary workaround for https://crbug.com/993268
@@ -162,17 +162,17 @@
162
162
  const issuedWarnings = (global$3.litIssuedWarnings ??=
163
163
  new Set());
164
164
  // Issue a warning, if we haven't already.
165
- issueWarning$5 = (code, warning) => {
165
+ issueWarning$4 = (code, warning) => {
166
166
  warning += ` See https://lit.dev/msg/${code} for more information.`;
167
167
  if (!issuedWarnings.has(warning)) {
168
168
  console.warn(warning);
169
169
  issuedWarnings.add(warning);
170
170
  }
171
171
  };
172
- issueWarning$5('dev-mode', `Lit is in dev mode. Not recommended for production!`);
172
+ issueWarning$4('dev-mode', `Lit is in dev mode. Not recommended for production!`);
173
173
  // Issue polyfill support warning.
174
174
  if (global$3.ShadyDOM?.inUse && polyfillSupport$3 === undefined) {
175
- issueWarning$5('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
175
+ issueWarning$4('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
176
176
  `the \`polyfill-support\` module has not been loaded.`);
177
177
  }
178
178
  }
@@ -413,7 +413,7 @@
413
413
  `but it's actually declared as a value on the prototype. ` +
414
414
  `Usually this is due to using @property or @state on a method.`);
415
415
  }
416
- issueWarning$5('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
416
+ issueWarning$4('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
417
417
  `${this.name} was declared as a reactive property ` +
418
418
  `but it does not have a getter. This will be an error in a ` +
419
419
  `future version of Lit.`);
@@ -525,11 +525,11 @@
525
525
  this.elementStyles = this.finalizeStyles(this.styles);
526
526
  {
527
527
  if (this.hasOwnProperty('createProperty')) {
528
- issueWarning$5('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
528
+ issueWarning$4('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
529
529
  'The override will not be called with standard decorators');
530
530
  }
531
531
  if (this.hasOwnProperty('getPropertyDescriptor')) {
532
- issueWarning$5('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
532
+ issueWarning$4('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
533
533
  'The override will not be called with standard decorators');
534
534
  }
535
535
  }
@@ -737,7 +737,7 @@
737
737
  const attrValue = converter.toAttribute(value, options.type);
738
738
  if (this.constructor.enabledWarnings.includes('migration') &&
739
739
  attrValue === undefined) {
740
- issueWarning$5('undefined-attribute-value', `The attribute value for the ${name} property is ` +
740
+ issueWarning$4('undefined-attribute-value', `The attribute value for the ${name} property is ` +
741
741
  `undefined on element ${this.localName}. The attribute will be ` +
742
742
  `removed, but in the previous version of \`ReactiveElement\`, ` +
743
743
  `the attribute would not have changed.`);
@@ -803,7 +803,7 @@
803
803
  // If we have a property key, perform property update steps.
804
804
  if (name !== undefined) {
805
805
  if (name instanceof Event) {
806
- issueWarning$5(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
806
+ issueWarning$4(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
807
807
  }
808
808
  options ??= this.constructor.getPropertyOptions(name);
809
809
  const hasChanged = options.hasChanged ?? notEqual$1;
@@ -885,7 +885,7 @@
885
885
  if (this.constructor.enabledWarnings.includes('async-perform-update') &&
886
886
  typeof result?.then ===
887
887
  'function') {
888
- issueWarning$5('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
888
+ issueWarning$4('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
889
889
  `This behavior is deprecated and will be removed in a future ` +
890
890
  `version of ReactiveElement.`);
891
891
  }
@@ -1021,7 +1021,7 @@
1021
1021
  this.updated(changedProperties);
1022
1022
  if (this.isUpdatePending &&
1023
1023
  this.constructor.enabledWarnings.includes('change-in-update')) {
1024
- issueWarning$5('change-in-update', `Element ${this.localName} scheduled an update ` +
1024
+ issueWarning$4('change-in-update', `Element ${this.localName} scheduled an update ` +
1025
1025
  `(generally because a property was set) ` +
1026
1026
  `after an update completed, causing a new update to be scheduled. ` +
1027
1027
  `This is inefficient and should be avoided unless the next update ` +
@@ -1188,7 +1188,7 @@
1188
1188
  // This line will be used in regexes to search for ReactiveElement usage.
1189
1189
  (global$3.reactiveElementVersions ??= []).push('2.0.4');
1190
1190
  if (global$3.reactiveElementVersions.length > 1) {
1191
- issueWarning$5('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
1191
+ issueWarning$4('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
1192
1192
  `is not recommended.`);
1193
1193
  }
1194
1194
 
@@ -1219,11 +1219,11 @@
1219
1219
  // renders when errors are thrown preventing an endRender event from being
1220
1220
  // called.
1221
1221
  let debugLogRenderId = 0;
1222
- let issueWarning$4;
1222
+ let issueWarning$3;
1223
1223
  {
1224
1224
  global$2.litIssuedWarnings ??= new Set();
1225
1225
  // Issue a warning, if we haven't already.
1226
- issueWarning$4 = (code, warning) => {
1226
+ issueWarning$3 = (code, warning) => {
1227
1227
  warning += code
1228
1228
  ? ` See https://lit.dev/msg/${code} for more information.`
1229
1229
  : '';
@@ -1232,7 +1232,7 @@
1232
1232
  global$2.litIssuedWarnings.add(warning);
1233
1233
  }
1234
1234
  };
1235
- issueWarning$4('dev-mode', `Lit is in dev mode. Not recommended for production!`);
1235
+ issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
1236
1236
  }
1237
1237
  const wrap = global$2.ShadyDOM?.inUse &&
1238
1238
  global$2.ShadyDOM?.noPatch === true
@@ -1383,7 +1383,7 @@
1383
1383
  // handle. Instead we know that static values must have the field
1384
1384
  // `_$litStatic$`.
1385
1385
  if (values.some((val) => val?.['_$litStatic$'])) {
1386
- issueWarning$4('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\n` +
1386
+ issueWarning$3('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\n` +
1387
1387
  `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);
1388
1388
  }
1389
1389
  }
@@ -1663,7 +1663,7 @@
1663
1663
  throw new Error(m);
1664
1664
  }
1665
1665
  else
1666
- issueWarning$4('', m);
1666
+ issueWarning$3('', m);
1667
1667
  }
1668
1668
  }
1669
1669
  // TODO (justinfagnani): for attempted dynamic tag names, we don't
@@ -2509,7 +2509,7 @@
2509
2509
  // This line will be used in regexes to search for lit-html usage.
2510
2510
  (global$2.litHtmlVersions ??= []).push('3.2.0');
2511
2511
  if (global$2.litHtmlVersions.length > 1) {
2512
- issueWarning$4('multiple-versions', `Multiple versions of Lit loaded. ` +
2512
+ issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. ` +
2513
2513
  `Loading multiple versions is not recommended.`);
2514
2514
  }
2515
2515
  /**
@@ -2728,7 +2728,7 @@
2728
2728
  const { is, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, } = Object;
2729
2729
  // Lets a minifier replace globalThis references with a minified name
2730
2730
  const global = globalThis;
2731
- let issueWarning$3;
2731
+ let issueWarning$2;
2732
2732
  const trustedTypes = global
2733
2733
  .trustedTypes;
2734
2734
  // Temporary workaround for https://crbug.com/993268
@@ -2746,17 +2746,17 @@
2746
2746
  const issuedWarnings = (global.litIssuedWarnings ??=
2747
2747
  new Set());
2748
2748
  // Issue a warning, if we haven't already.
2749
- issueWarning$3 = (code, warning) => {
2749
+ issueWarning$2 = (code, warning) => {
2750
2750
  warning += ` See https://lit.dev/msg/${code} for more information.`;
2751
2751
  if (!issuedWarnings.has(warning)) {
2752
2752
  console.warn(warning);
2753
2753
  issuedWarnings.add(warning);
2754
2754
  }
2755
2755
  };
2756
- issueWarning$3('dev-mode', `Lit is in dev mode. Not recommended for production!`);
2756
+ issueWarning$2('dev-mode', `Lit is in dev mode. Not recommended for production!`);
2757
2757
  // Issue polyfill support warning.
2758
2758
  if (global.ShadyDOM?.inUse && polyfillSupport$1 === undefined) {
2759
- issueWarning$3('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
2759
+ issueWarning$2('polyfill-support-missing', `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
2760
2760
  `the \`polyfill-support\` module has not been loaded.`);
2761
2761
  }
2762
2762
  }
@@ -2997,7 +2997,7 @@
2997
2997
  `but it's actually declared as a value on the prototype. ` +
2998
2998
  `Usually this is due to using @property or @state on a method.`);
2999
2999
  }
3000
- issueWarning$3('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
3000
+ issueWarning$2('reactive-property-without-getter', `Field ${JSON.stringify(String(name))} on ` +
3001
3001
  `${this.name} was declared as a reactive property ` +
3002
3002
  `but it does not have a getter. This will be an error in a ` +
3003
3003
  `future version of Lit.`);
@@ -3109,11 +3109,11 @@
3109
3109
  this.elementStyles = this.finalizeStyles(this.styles);
3110
3110
  {
3111
3111
  if (this.hasOwnProperty('createProperty')) {
3112
- issueWarning$3('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
3112
+ issueWarning$2('no-override-create-property', 'Overriding ReactiveElement.createProperty() is deprecated. ' +
3113
3113
  'The override will not be called with standard decorators');
3114
3114
  }
3115
3115
  if (this.hasOwnProperty('getPropertyDescriptor')) {
3116
- issueWarning$3('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
3116
+ issueWarning$2('no-override-get-property-descriptor', 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +
3117
3117
  'The override will not be called with standard decorators');
3118
3118
  }
3119
3119
  }
@@ -3321,7 +3321,7 @@
3321
3321
  const attrValue = converter.toAttribute(value, options.type);
3322
3322
  if (this.constructor.enabledWarnings.includes('migration') &&
3323
3323
  attrValue === undefined) {
3324
- issueWarning$3('undefined-attribute-value', `The attribute value for the ${name} property is ` +
3324
+ issueWarning$2('undefined-attribute-value', `The attribute value for the ${name} property is ` +
3325
3325
  `undefined on element ${this.localName}. The attribute will be ` +
3326
3326
  `removed, but in the previous version of \`ReactiveElement\`, ` +
3327
3327
  `the attribute would not have changed.`);
@@ -3387,7 +3387,7 @@
3387
3387
  // If we have a property key, perform property update steps.
3388
3388
  if (name !== undefined) {
3389
3389
  if (name instanceof Event) {
3390
- issueWarning$3(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
3390
+ issueWarning$2(``, `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`);
3391
3391
  }
3392
3392
  options ??= this.constructor.getPropertyOptions(name);
3393
3393
  const hasChanged = options.hasChanged ?? notEqual;
@@ -3469,7 +3469,7 @@
3469
3469
  if (this.constructor.enabledWarnings.includes('async-perform-update') &&
3470
3470
  typeof result?.then ===
3471
3471
  'function') {
3472
- issueWarning$3('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
3472
+ issueWarning$2('async-perform-update', `Element ${this.localName} returned a Promise from performUpdate(). ` +
3473
3473
  `This behavior is deprecated and will be removed in a future ` +
3474
3474
  `version of ReactiveElement.`);
3475
3475
  }
@@ -3605,7 +3605,7 @@
3605
3605
  this.updated(changedProperties);
3606
3606
  if (this.isUpdatePending &&
3607
3607
  this.constructor.enabledWarnings.includes('change-in-update')) {
3608
- issueWarning$3('change-in-update', `Element ${this.localName} scheduled an update ` +
3608
+ issueWarning$2('change-in-update', `Element ${this.localName} scheduled an update ` +
3609
3609
  `(generally because a property was set) ` +
3610
3610
  `after an update completed, causing a new update to be scheduled. ` +
3611
3611
  `This is inefficient and should be avoided unless the next update ` +
@@ -3772,7 +3772,7 @@
3772
3772
  // This line will be used in regexes to search for ReactiveElement usage.
3773
3773
  (global.reactiveElementVersions ??= []).push('2.0.4');
3774
3774
  if (global.reactiveElementVersions.length > 1) {
3775
- issueWarning$3('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3775
+ issueWarning$2('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3776
3776
  `is not recommended.`);
3777
3777
  }
3778
3778
 
@@ -3789,13 +3789,13 @@
3789
3789
  */
3790
3790
  /*@__INLINE__*/
3791
3791
  const JSCompiler_renameProperty = (prop, _obj) => prop;
3792
- let issueWarning$2;
3792
+ let issueWarning$1;
3793
3793
  {
3794
3794
  // Ensure warnings are issued only 1x, even if multiple versions of Lit
3795
3795
  // are loaded.
3796
3796
  const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
3797
3797
  // Issue a warning, if we haven't already.
3798
- issueWarning$2 = (code, warning) => {
3798
+ issueWarning$1 = (code, warning) => {
3799
3799
  warning += ` See https://lit.dev/msg/${code} for more information.`;
3800
3800
  if (!issuedWarnings.has(warning)) {
3801
3801
  console.warn(warning);
@@ -3930,7 +3930,7 @@
3930
3930
  // This line will be used in regexes to search for LitElement usage.
3931
3931
  (globalThis.litElementVersions ??= []).push('4.1.0');
3932
3932
  if (globalThis.litElementVersions.length > 1) {
3933
- issueWarning$2('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3933
+ issueWarning$1('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
3934
3934
  `is not recommended.`);
3935
3935
  }
3936
3936
 
@@ -3939,13 +3939,13 @@
3939
3939
  * Copyright 2017 Google LLC
3940
3940
  * SPDX-License-Identifier: BSD-3-Clause
3941
3941
  */
3942
- let issueWarning$1;
3942
+ let issueWarning;
3943
3943
  {
3944
3944
  // Ensure warnings are issued only 1x, even if multiple versions of Lit
3945
3945
  // are loaded.
3946
3946
  const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
3947
3947
  // Issue a warning, if we haven't already.
3948
- issueWarning$1 = (code, warning) => {
3948
+ issueWarning = (code, warning) => {
3949
3949
  warning += ` See https://lit.dev/msg/${code} for more information.`;
3950
3950
  if (!issuedWarnings.has(warning)) {
3951
3951
  console.warn(warning);
@@ -3982,7 +3982,7 @@
3982
3982
  const standardProperty = (options = defaultPropertyDeclaration, target, context) => {
3983
3983
  const { kind, metadata } = context;
3984
3984
  if (metadata == null) {
3985
- issueWarning$1('missing-class-metadata', `The class ${target} is missing decorator metadata. This ` +
3985
+ issueWarning('missing-class-metadata', `The class ${target} is missing decorator metadata. This ` +
3986
3986
  `could mean that you're using a compiler that supports decorators ` +
3987
3987
  `but doesn't support decorator metadata, such as TypeScript 5.1. ` +
3988
3988
  `Please update your compiler.`);
@@ -4127,36 +4127,38 @@
4127
4127
  * Copyright 2017 Google LLC
4128
4128
  * SPDX-License-Identifier: BSD-3-Clause
4129
4129
  */
4130
- let issueWarning;
4131
4130
  {
4132
4131
  // Ensure warnings are issued only 1x, even if multiple versions of Lit
4133
4132
  // are loaded.
4134
- const issuedWarnings = (globalThis.litIssuedWarnings ??= new Set());
4135
- // Issue a warning, if we haven't already.
4136
- issueWarning = (code, warning) => {
4137
- warning += code
4138
- ? ` See https://lit.dev/msg/${code} for more information.`
4139
- : '';
4140
- if (!issuedWarnings.has(warning)) {
4141
- console.warn(warning);
4142
- issuedWarnings.add(warning);
4143
- }
4144
- };
4133
+ (globalThis.litIssuedWarnings ??= new Set());
4145
4134
  }
4135
+
4136
+ /**
4137
+ * @license
4138
+ * Copyright 2017 Google LLC
4139
+ * SPDX-License-Identifier: BSD-3-Clause
4140
+ */
4141
+ // Note, in the future, we may extend this decorator to support the use case
4142
+ // where the queried element may need to do work to become ready to interact
4143
+ // with (e.g. load some implementation code). If so, we might elect to
4144
+ // add a second argument defining a function that can be run to make the
4145
+ // queried element loaded/updated/ready.
4146
4146
  /**
4147
4147
  * A property decorator that converts a class property into a getter that
4148
- * executes a querySelector on the element's renderRoot.
4148
+ * returns a promise that resolves to the result of a querySelector on the
4149
+ * element's renderRoot done after the element's `updateComplete` promise
4150
+ * resolves. When the queried property may change with element state, this
4151
+ * decorator can be used instead of requiring users to await the
4152
+ * `updateComplete` before accessing the property.
4149
4153
  *
4150
4154
  * @param selector A DOMString containing one or more selectors to match.
4151
- * @param cache An optional boolean which when true performs the DOM query only
4152
- * once and caches the result.
4153
4155
  *
4154
4156
  * See: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
4155
4157
  *
4156
4158
  * ```ts
4157
4159
  * class MyElement {
4158
- * @query('#first')
4159
- * first: HTMLDivElement;
4160
+ * @queryAsync('#first')
4161
+ * first: Promise<HTMLDivElement>;
4160
4162
  *
4161
4163
  * render() {
4162
4164
  * return html`
@@ -4165,72 +4167,22 @@
4165
4167
  * `;
4166
4168
  * }
4167
4169
  * }
4170
+ *
4171
+ * // external usage
4172
+ * async doSomethingWithFirst() {
4173
+ * (await aMyElement.first).doSomething();
4174
+ * }
4168
4175
  * ```
4169
4176
  * @category Decorator
4170
4177
  */
4171
- function query(selector, cache) {
4172
- return ((protoOrTarget, nameOrContext, descriptor) => {
4173
- const doQuery = (el) => {
4174
- const result = (el.renderRoot?.querySelector(selector) ?? null);
4175
- if (result === null && cache && !el.hasUpdated) {
4176
- const name = typeof nameOrContext === 'object'
4177
- ? nameOrContext.name
4178
- : nameOrContext;
4179
- issueWarning('', `@query'd field ${JSON.stringify(String(name))} with the 'cache' ` +
4180
- `flag set for selector '${selector}' has been accessed before ` +
4181
- `the first update and returned null. This is expected if the ` +
4182
- `renderRoot tree has not been provided beforehand (e.g. via ` +
4183
- `Declarative Shadow DOM). Therefore the value hasn't been cached.`);
4184
- }
4185
- // TODO: if we want to allow users to assert that the query will never
4186
- // return null, we need a new option and to throw here if the result
4187
- // is null.
4188
- return result;
4189
- };
4190
- if (cache) {
4191
- // Accessors to wrap from either:
4192
- // 1. The decorator target, in the case of standard decorators
4193
- // 2. The property descriptor, in the case of experimental decorators
4194
- // on auto-accessors.
4195
- // 3. Functions that access our own cache-key property on the instance,
4196
- // in the case of experimental decorators on fields.
4197
- const { get, set } = typeof nameOrContext === 'object'
4198
- ? protoOrTarget
4199
- : descriptor ??
4200
- (() => {
4201
- const key = Symbol(`${String(nameOrContext)} (@query() cache)`)
4202
- ;
4203
- return {
4204
- get() {
4205
- return this[key];
4206
- },
4207
- set(v) {
4208
- this[key] = v;
4209
- },
4210
- };
4211
- })();
4212
- return desc(protoOrTarget, nameOrContext, {
4213
- get() {
4214
- let result = get.call(this);
4215
- if (result === undefined) {
4216
- result = doQuery(this);
4217
- if (result !== null || this.hasUpdated) {
4218
- set.call(this, result);
4219
- }
4220
- }
4221
- return result;
4222
- },
4223
- });
4224
- }
4225
- else {
4226
- // This object works as the return type for both standard and
4227
- // experimental decorators.
4228
- return desc(protoOrTarget, nameOrContext, {
4229
- get() {
4230
- return doQuery(this);
4231
- },
4232
- });
4233
- }
4178
+ function queryAsync(selector) {
4179
+ return ((obj, name) => {
4180
+ return desc(obj, name, {
4181
+ async get() {
4182
+ await this.updateComplete;
4183
+ return this.renderRoot?.querySelector(selector) ?? null;
4184
+ },
4185
+ });
4234
4186
  });
4235
4187
  }
4236
4188
 
@@ -4429,6 +4381,188 @@
4429
4381
  */
4430
4382
  const ifDefined = (value) => value ?? nothing;
4431
4383
 
4384
+ /**
4385
+ * @license
4386
+ * Copyright 2020 Google LLC
4387
+ * SPDX-License-Identifier: BSD-3-Clause
4388
+ */
4389
+ window.ShadyDOM?.inUse &&
4390
+ window.ShadyDOM?.noPatch === true
4391
+ ? window.ShadyDOM.wrap
4392
+ : (node) => node;
4393
+ /**
4394
+ * Tests whether a part has only a single-expression with no strings to
4395
+ * interpolate between.
4396
+ *
4397
+ * Only AttributePart and PropertyPart can have multiple expressions.
4398
+ * Multi-expression parts have a `strings` property and single-expression
4399
+ * parts do not.
4400
+ */
4401
+ const isSingleExpression = (part) => part.strings === undefined;
4402
+ // A sentinel value that can never appear as a part value except when set by
4403
+ // live(). Used to force a dirty-check to fail and cause a re-render.
4404
+ const RESET_VALUE = {};
4405
+ /**
4406
+ * Sets the committed value of a ChildPart directly without triggering the
4407
+ * commit stage of the part.
4408
+ *
4409
+ * This is useful in cases where a directive needs to update the part such
4410
+ * that the next update detects a value change or not. When value is omitted,
4411
+ * the next update will be guaranteed to be detected as a change.
4412
+ *
4413
+ * @param part
4414
+ * @param value
4415
+ */
4416
+ const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);
4417
+
4418
+ /**
4419
+ * @license
4420
+ * Copyright 2020 Google LLC
4421
+ * SPDX-License-Identifier: BSD-3-Clause
4422
+ */
4423
+ class LiveDirective extends Directive {
4424
+ constructor(partInfo) {
4425
+ super(partInfo);
4426
+ if (!(partInfo.type === PartType.PROPERTY ||
4427
+ partInfo.type === PartType.ATTRIBUTE ||
4428
+ partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {
4429
+ throw new Error('The `live` directive is not allowed on child or event bindings');
4430
+ }
4431
+ if (!isSingleExpression(partInfo)) {
4432
+ throw new Error('`live` bindings can only contain a single expression');
4433
+ }
4434
+ }
4435
+ render(value) {
4436
+ return value;
4437
+ }
4438
+ update(part, [value]) {
4439
+ if (value === noChange || value === nothing) {
4440
+ return value;
4441
+ }
4442
+ const element = part.element;
4443
+ const name = part.name;
4444
+ if (part.type === PartType.PROPERTY) {
4445
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4446
+ if (value === element[name]) {
4447
+ return noChange;
4448
+ }
4449
+ }
4450
+ else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {
4451
+ if (!!value === element.hasAttribute(name)) {
4452
+ return noChange;
4453
+ }
4454
+ }
4455
+ else if (part.type === PartType.ATTRIBUTE) {
4456
+ if (element.getAttribute(name) === String(value)) {
4457
+ return noChange;
4458
+ }
4459
+ }
4460
+ // Resets the part's value, causing its dirty-check to fail so that it
4461
+ // always sets the value.
4462
+ setCommittedValue(part);
4463
+ return value;
4464
+ }
4465
+ }
4466
+ /**
4467
+ * Checks binding values against live DOM values, instead of previously bound
4468
+ * values, when determining whether to update the value.
4469
+ *
4470
+ * This is useful for cases where the DOM value may change from outside of
4471
+ * lit-html, such as with a binding to an `<input>` element's `value` property,
4472
+ * a content editable elements text, or to a custom element that changes it's
4473
+ * own properties or attributes.
4474
+ *
4475
+ * In these cases if the DOM value changes, but the value set through lit-html
4476
+ * bindings hasn't, lit-html won't know to update the DOM value and will leave
4477
+ * it alone. If this is not what you want--if you want to overwrite the DOM
4478
+ * value with the bound value no matter what--use the `live()` directive:
4479
+ *
4480
+ * ```js
4481
+ * html`<input .value=${live(x)}>`
4482
+ * ```
4483
+ *
4484
+ * `live()` performs a strict equality check against the live DOM value, and if
4485
+ * the new value is equal to the live value, does nothing. This means that
4486
+ * `live()` should not be used when the binding will cause a type conversion. If
4487
+ * you use `live()` with an attribute binding, make sure that only strings are
4488
+ * passed in, or the binding will update every render.
4489
+ */
4490
+ const live = directive(LiveDirective);
4491
+
4492
+ var css_248z$6 = css`.invalid-feedback-container{display:flex;gap:var(--sgds-form-gap-sm)}.invalid-feedback{color:var(--sgds-form-danger-color);font-size:var(--sgds-font-size-1);font-weight:var(--sgds-font-weight-regular)}`;
4493
+
4494
+ var css_248z$5 = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}.form-text.disabled{opacity:var(--sgds-opacity-50)}`;
4495
+
4496
+ var css_248z$4 = css`.form-label{color:var(--sgds-form-color);margin-bottom:0}.form-label.disabled{opacity:var(--sgds-opacity-50)}.form-check-label{color:var(--sgds-form-color)}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:not-allowed}`;
4497
+
4498
+ var css_248z$3 = css`.form-control::placeholder{color:var(--sgds-form-color-subtle);font-family:var(--sgds-font-family-brand);font-weight:var(--sgds-font-weight-light);line-height:var(--sgds-line-height-heading)}`;
4499
+
4500
+ var css_248z$2 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-heading);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}::slotted(a[target=_blank]):after{background-color:currentColor;content:"/";display:inline-block;margin:0 .125rem;-webkit-mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;mask-size:73%;-webkit-mask-size:73%;padding:0 .45em}::slotted(a){color:var(--sgds-link);text-decoration:var(--sgds-link-decoration)}::slotted(a:hover){color:var(--sgds-link-hover-color)}::slotted(svg){vertical-align:middle}}`;
4501
+
4502
+ /**
4503
+ * @cssprop --sgds-{stateColor} - State colors in hexadecimal value
4504
+ * @cssprop --sgds-{stateColor}-rgb - State colors in rgb value
4505
+ * @cssprop --sgds-{stateColor}-{weights} - State colors with different weightage in hexadecimal value
4506
+ * @cssprop --sgds-gray-{weights} - State colors with different weightage in hexadecimal value
4507
+ * @cssprop --overlay-background-color - The drawer and modal component overlay background color
4508
+ * @cssprop --zindex-modal - The drawer and modal component z-index value
4509
+ */
4510
+ class SgdsElement extends LitElement {
4511
+ /** Emits a custom event with more convenient defaults. */
4512
+ emit(name, options) {
4513
+ const event = new CustomEvent(name, Object.assign({ bubbles: true, cancelable: false, composed: true, detail: {} }, options));
4514
+ this.dispatchEvent(event);
4515
+ return event;
4516
+ }
4517
+ }
4518
+ SgdsElement.styles = [css_248z$2];
4519
+
4520
+ function generateId (componentName = "", elementName = "") {
4521
+ return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
4522
+ }
4523
+
4524
+ class FormControlElement extends SgdsElement {
4525
+ constructor() {
4526
+ super(...arguments);
4527
+ /** The input's label */
4528
+ this.label = "";
4529
+ /** The input's hint text */
4530
+ this.hintText = "";
4531
+ /** Disables the input. */
4532
+ this.disabled = false;
4533
+ /** Marks the component as invalid. Replace the pseudo :invalid selector for absent in custom elements */
4534
+ this.invalid = false;
4535
+ this._controlId = generateId("input");
4536
+ this._labelId = generateId("label");
4537
+ }
4538
+ /** Programatically sets the invalid state of the input. Pass in boolean value in the argument */
4539
+ setInvalid(bool) {
4540
+ this.invalid = bool;
4541
+ if (bool) {
4542
+ this.emit("sgds-invalid");
4543
+ }
4544
+ else {
4545
+ this.emit("sgds-valid");
4546
+ }
4547
+ }
4548
+ }
4549
+ FormControlElement.styles = [...SgdsElement.styles, css_248z$6, css_248z$5, css_248z$4, css_248z$3];
4550
+ __decorate([
4551
+ property({ reflect: true })
4552
+ ], FormControlElement.prototype, "label", void 0);
4553
+ __decorate([
4554
+ property({ reflect: true })
4555
+ ], FormControlElement.prototype, "hintText", void 0);
4556
+ __decorate([
4557
+ property({ reflect: true })
4558
+ ], FormControlElement.prototype, "name", void 0);
4559
+ __decorate([
4560
+ property({ type: Boolean, reflect: true })
4561
+ ], FormControlElement.prototype, "disabled", void 0);
4562
+ __decorate([
4563
+ property({ type: Boolean, reflect: true })
4564
+ ], FormControlElement.prototype, "invalid", void 0);
4565
+
4432
4566
  // @defaultValue decorator
4433
4567
  const defaultValue = (propertyName = "value") => (proto, key) => {
4434
4568
  const ctor = proto.constructor;
@@ -4449,135 +4583,225 @@
4449
4583
  };
4450
4584
  };
4451
4585
 
4452
- const reportValidityOverloads = new WeakMap();
4453
- class FormSubmitController {
4586
+ /**
4587
+ * SGDS custom form validation methods and behaviours
4588
+ */
4589
+ class InputValidationController {
4454
4590
  constructor(host, options) {
4455
4591
  (this.host = host).addController(this);
4456
- this.options = Object.assign({ form: (input) => {
4457
- return input.closest("form");
4458
- }, name: (input) => input.name, value: (input) => input.value, defaultValue: (input) => input.defaultValue, disabled: (input) => input.disabled, reportValidity: (input) => {
4459
- return typeof input.reportValidity === "function" ? input.reportValidity() : true;
4460
- }, setValue: (input, value) => {
4461
- input.value = value;
4462
- } }, options);
4463
- this.handleFormData = this.handleFormData.bind(this);
4464
- this.handleFormSubmit = this.handleFormSubmit.bind(this);
4465
- this.handleFormReset = this.handleFormReset.bind(this);
4466
- this.reportFormValidity = this.reportFormValidity.bind(this);
4592
+ this._internals = this.host.attachInternals();
4593
+ this.options = Object.assign({ setInvalid: (host, value) => {
4594
+ host.invalid = value;
4595
+ }, value: (host) => {
4596
+ return host.value;
4597
+ }, input: (host) => host.input }, options);
4467
4598
  }
4468
4599
  hostConnected() {
4469
- this.form = this.options.form(this.host);
4470
- if (this.form) {
4471
- this.form.addEventListener("formdata", this.handleFormData);
4472
- this.form.addEventListener("submit", this.handleFormSubmit);
4473
- this.form.addEventListener("reset", this.handleFormReset);
4474
- // Overload the form's reportValidity() method so it looks at Shoelace form controls
4475
- if (!reportValidityOverloads.has(this.form)) {
4476
- reportValidityOverloads.set(this.form, this.form.reportValidity);
4477
- this.form.reportValidity = () => this.reportFormValidity();
4478
- }
4479
- }
4600
+ this.host.addEventListener("invalid", e => this.handleInvalid(e));
4480
4601
  }
4481
4602
  hostDisconnected() {
4482
- if (this.form) {
4483
- this.form.removeEventListener("formdata", this.handleFormData);
4484
- this.form.removeEventListener("submit", this.handleFormSubmit);
4485
- this.form.removeEventListener("reset", this.handleFormReset);
4486
- // Remove the overload and restore the original method
4487
- if (reportValidityOverloads.has(this.form)) {
4488
- this.form.reportValidity = reportValidityOverloads.get(this.form);
4489
- reportValidityOverloads.delete(this.form);
4490
- }
4491
- this.form = undefined;
4492
- }
4603
+ this.host.removeEventListener("invalid", e => this.handleInvalid(e));
4493
4604
  }
4494
- handleFormData(event) {
4495
- const disabled = this.options.disabled(this.host);
4496
- const name = this.options.name(this.host);
4605
+ /**
4606
+ * Prevents the native browser error message pop up when reportValidity() called by
4607
+ * associated form or the component's reportValidity during constraint validation
4608
+ * Sets invalid reactive prop to true
4609
+ */
4610
+ handleInvalid(e) {
4611
+ e.preventDefault();
4612
+ this.options.setInvalid(this.host, true);
4613
+ }
4614
+ /**
4615
+ * Sets invalid to false when invoked and
4616
+ * Updates the ValidityState based on new value, but
4617
+ * does not update invalid reactive prop
4618
+ * @param e
4619
+ */
4620
+ handleInput(e) {
4621
+ const input = e.target;
4622
+ this.options.setInvalid(this.host, false);
4623
+ this.validateInput(input);
4624
+ }
4625
+ /**
4626
+ * Validate the input's new value after onChange and
4627
+ * update invalid reactive prop
4628
+ * @param e
4629
+ */
4630
+ handleChange(e) {
4631
+ const input = e.target;
4632
+ this.validateInput(input);
4633
+ this.options.setInvalid(this.host, !this.checkValidity());
4634
+ }
4635
+ get form() {
4636
+ return this._internals.form;
4637
+ }
4638
+ get validity() {
4639
+ return this._internals.validity;
4640
+ }
4641
+ get validationMessage() {
4642
+ return this._internals.validationMessage;
4643
+ }
4644
+ get willValidate() {
4645
+ return this._internals.willValidate;
4646
+ }
4647
+ /**
4648
+ * Checks the validity and updates the invalid reactive prop of form components
4649
+ */
4650
+ updateInvalidState() {
4651
+ this.options.setInvalid(this.host, !this.checkValidity());
4652
+ }
4653
+ /**
4654
+ * Resets the ValidityState of the control
4655
+ */
4656
+ resetValidity() {
4657
+ return this._internals.setValidity({});
4658
+ }
4659
+ /**
4660
+ * Reports the validity
4661
+ */
4662
+ checkValidity() {
4663
+ return this._internals.checkValidity();
4664
+ }
4665
+ /**
4666
+ * Reports the validity with a error popup message
4667
+ */
4668
+ reportValidity() {
4669
+ return this._internals.reportValidity();
4670
+ }
4671
+ /**
4672
+ * Sets the form control value into FormData,
4673
+ * making the value of control accessible via FormData
4674
+ */
4675
+ setFormValue() {
4497
4676
  const value = this.options.value(this.host);
4498
- if (!disabled && typeof name === "string" && typeof value !== "undefined") {
4499
- if (Array.isArray(value)) {
4500
- value.forEach(val => {
4501
- event.formData.append(name, val.toString());
4502
- });
4503
- }
4504
- else {
4505
- event.formData.append(name, value.toString());
4506
- }
4507
- }
4677
+ this._internals.setFormValue(value);
4508
4678
  }
4509
- handleFormSubmit(event) {
4510
- const disabled = this.options.disabled(this.host);
4511
- const reportValidity = this.options.reportValidity;
4512
- if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
4513
- event.preventDefault();
4514
- event.stopImmediatePropagation();
4515
- }
4516
- }
4517
- handleFormReset() {
4518
- this.options.setValue(this.host, this.options.defaultValue(this.host));
4519
- }
4520
- reportFormValidity() {
4521
- //
4522
- // Shoelace form controls work hard to act like regular form controls. They support the Constraint Validation API
4523
- // and its associated methods such as setCustomValidity() and reportValidity(). However, the HTMLFormElement also
4524
- // has a reportValidity() method that will trigger validation on all child controls. Since we're not yet using
4525
- // ElementInternals, we need to overload this method so it looks for any element with the reportValidity() method.
4526
- //
4527
- // We preserve the original method in a WeakMap, but we don't call it from the overload because that would trigger
4528
- // validations in an unexpected order. When the element disconnects, we revert to the original behavior. This won't
4529
- // be necessary once we can use ElementInternals.
4530
- //
4531
- // Note that we're also honoring the form's novalidate attribute.
4532
- //
4533
- if (this.form && !this.form.noValidate) {
4534
- // This seems sloppy, but checking all elements will cover native inputs, Shoelace inputs, and other custom
4535
- // elements that support the constraint validation API.
4536
- const elements = this.form.querySelectorAll("*");
4537
- for (const element of elements) {
4538
- if (typeof element.reportValidity === "function") {
4539
- if (!element.reportValidity()) {
4540
- return false;
4541
- }
4679
+ /**
4680
+ * Updates the ValidityState of the input in form component at current state
4681
+ */
4682
+ validateInput(input) {
4683
+ /** When the form control is disabled, its always valid */
4684
+ if (this.options.input(this.host).disabled) {
4685
+ return this._internals.setValidity({});
4686
+ }
4687
+ // get the validity of the internal <input>
4688
+ const validState = input.validity;
4689
+ // if the input is invalid, show the correct error
4690
+ if (!validState.valid) {
4691
+ // loop through the error reasons
4692
+ for (const state in validState) {
4693
+ // if there is an error and corresponding attribute holding
4694
+ // the message
4695
+ if (validState[state]) {
4696
+ this.validationError = state.toString();
4697
+ // set the validity error reason and the corresponding
4698
+ // message
4699
+ this._internals.setValidity({ [this.validationError]: true }, input.validationMessage, input);
4542
4700
  }
4543
4701
  }
4544
4702
  }
4545
- return true;
4703
+ else {
4704
+ this._internals.setValidity({});
4705
+ }
4546
4706
  }
4547
- doAction(type, invoker) {
4548
- if (this.form) {
4549
- const button = document.createElement("button");
4550
- button.type = type;
4551
- button.style.position = "absolute";
4552
- button.style.width = "0";
4553
- button.style.height = "0";
4554
- button.style.clipPath = "inset(50%)";
4555
- button.style.overflow = "hidden";
4556
- button.style.whiteSpace = "nowrap";
4557
- // Pass form attributes through to the temporary button
4558
- if (invoker) {
4559
- ["formaction", "formmethod", "formnovalidate", "formtarget"].forEach(attr => {
4560
- if (invoker.hasAttribute(attr)) {
4561
- button.setAttribute(attr, invoker.getAttribute(attr));
4562
- }
4563
- });
4707
+ }
4708
+
4709
+ /**
4710
+ * @summary The FormValidationMixin used by the form components
4711
+ * @param superClass
4712
+ * @returns
4713
+ */
4714
+ const SgdsFormValidatorMixin = (superClass) => {
4715
+ class ToBeValidatedElement extends superClass {
4716
+ constructor() {
4717
+ super(...arguments);
4718
+ this._isTouched = false;
4719
+ }
4720
+ connectedCallback() {
4721
+ super.connectedCallback();
4722
+ this.inputValidationController = new InputValidationController(this);
4723
+ }
4724
+ async firstUpdated(changedProperties) {
4725
+ super.firstUpdated(changedProperties);
4726
+ /* Either input or sgds-input. For example, quantity-toggle uses sgds-input */
4727
+ this.input =
4728
+ this.shadowRoot.querySelector("input") || (await this.sgdsInput) || this.shadowRoot.querySelector("textarea");
4729
+ this._mixinValidate(this.input);
4730
+ }
4731
+ /**
4732
+ * Native lifecycle of Form-Associated Custom Element Callbacks
4733
+ */
4734
+ formResetCallback() {
4735
+ if (this._mixinResetFormControl) {
4736
+ this._mixinResetFormControl();
4564
4737
  }
4565
- this.form.append(button);
4566
- button.click();
4567
- button.remove();
4738
+ else {
4739
+ this.value = this.defaultValue;
4740
+ this._mixinResetValidity(this.input);
4741
+ }
4742
+ this._mixinSetFormValue();
4743
+ }
4744
+ /**
4745
+ *
4746
+ * Methods use by classes using this mixin
4747
+ */
4748
+ /**
4749
+ * OnChange of form component
4750
+ * 1. Make value of control accessible via FormData
4751
+ * 2. Run change handler
4752
+ */
4753
+ _mixinHandleChange(e) {
4754
+ this._mixinSetFormValue();
4755
+ this.inputValidationController.handleChange(e);
4756
+ }
4757
+ /**
4758
+ * OnChange of form component
4759
+ * 1. Make value of control accessible via FormData
4760
+ * 2. Run input handler
4761
+ */
4762
+ _mixinHandleInputChange(e) {
4763
+ this._mixinSetFormValue();
4764
+ this.inputValidationController.handleInput(e);
4765
+ }
4766
+ /**
4767
+ * During form resetting,
4768
+ * 1. ValidityState is reset
4769
+ * 2. invalid reactive prop is updated after the reset
4770
+ * 3. Revalidates the ValidityState (but do not update invalid prop)
4771
+ * to prepare for the next validity check
4772
+ * 4. Reset touched state to false for a pristine form
4773
+ */
4774
+ _mixinResetValidity(input) {
4775
+ this.inputValidationController.resetValidity();
4776
+ this.inputValidationController.updateInvalidState();
4777
+ this.inputValidationController.validateInput(input);
4778
+ this._isTouched ? (this._isTouched = false) : null;
4779
+ }
4780
+ _mixinValidate(input) {
4781
+ this.inputValidationController.validateInput(input);
4782
+ }
4783
+ _mixinSetFormValue() {
4784
+ this.inputValidationController.setFormValue();
4785
+ }
4786
+ _mixinCheckValidity() {
4787
+ return this.inputValidationController.checkValidity();
4788
+ }
4789
+ _mixinReportValidity() {
4790
+ return this.inputValidationController.reportValidity();
4791
+ }
4792
+ _mixinGetValidity() {
4793
+ return this.inputValidationController.validity;
4794
+ }
4795
+ _mixinGetValidationMessage() {
4796
+ return this.inputValidationController.validationMessage;
4568
4797
  }
4569
4798
  }
4570
- /** Resets the form, restoring all the control to their default value */
4571
- reset(invoker) {
4572
- this.doAction("reset", invoker);
4573
- }
4574
- /** Submits the form, triggering validation and form data injection. */
4575
- submit(invoker) {
4576
- // Calling form.submit() bypasses the submit event and constraint validation. To prevent this, we can inject a
4577
- // native submit button into the form, "click" it, then remove it to simulate a standard form submission.
4578
- this.doAction("submit", invoker);
4579
- }
4580
- }
4799
+ ToBeValidatedElement.formAssociated = true;
4800
+ __decorate([
4801
+ queryAsync("sgds-input")
4802
+ ], ToBeValidatedElement.prototype, "sgdsInput", void 0);
4803
+ return ToBeValidatedElement;
4804
+ };
4581
4805
 
4582
4806
  // @watch decorator
4583
4807
  //
@@ -4616,188 +4840,7 @@
4616
4840
  };
4617
4841
  }
4618
4842
 
4619
- var css_248z$5 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-heading);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}::slotted(a[target=_blank]):after{background-color:currentColor;content:"/";display:inline-block;margin:0 .125rem;-webkit-mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');mask-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right"><path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z"/><path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z"/></svg>');-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;mask-size:73%;-webkit-mask-size:73%;padding:0 .45em}::slotted(a){color:var(--sgds-link);text-decoration:var(--sgds-link-decoration)}::slotted(a:hover){color:var(--sgds-link-hover-color)}::slotted(svg){vertical-align:middle}}`;
4620
-
4621
- /**
4622
- * @cssprop --sgds-{stateColor} - State colors in hexadecimal value
4623
- * @cssprop --sgds-{stateColor}-rgb - State colors in rgb value
4624
- * @cssprop --sgds-{stateColor}-{weights} - State colors with different weightage in hexadecimal value
4625
- * @cssprop --sgds-gray-{weights} - State colors with different weightage in hexadecimal value
4626
- * @cssprop --overlay-background-color - The drawer and modal component overlay background color
4627
- * @cssprop --zindex-modal - The drawer and modal component z-index value
4628
- */
4629
- class SgdsElement extends LitElement {
4630
- /** Emits a custom event with more convenient defaults. */
4631
- emit(name, options) {
4632
- const event = new CustomEvent(name, Object.assign({ bubbles: true, cancelable: false, composed: true, detail: {} }, options));
4633
- this.dispatchEvent(event);
4634
- return event;
4635
- }
4636
- }
4637
- SgdsElement.styles = [css_248z$5];
4638
-
4639
- class FormCheckElement extends SgdsElement {
4640
- constructor() {
4641
- super(...arguments);
4642
- /**@internal */
4643
- this.formSubmitController = new FormSubmitController(this, {
4644
- value: (control) => (control.checked ? control.value : undefined),
4645
- defaultValue: (control) => control.defaultChecked,
4646
- setValue: (control, checked) => (control.checked = checked)
4647
- });
4648
- /** For aria-label when there is no appropriate text label visible */
4649
- this.ariaLabel = "checkbox";
4650
- /** Makes the checkbox a required field. */
4651
- this.required = false;
4652
- /** Draws the checkbox in a checked state. */
4653
- this.checked = false;
4654
- /** Disables the checkbox (so the user can't check / uncheck it). */
4655
- this.disabled = false;
4656
- /** Allows invalidFeedback, invalid and valid styles to be visible with the input */
4657
- this.hasFeedback = false;
4658
- /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
4659
- this.defaultChecked = false;
4660
- /** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
4661
- this.invalid = false;
4662
- /** Marks the checkbox input as indeterminate , with indeterminate logo */
4663
- this.indeterminate = false;
4664
- }
4665
- _handleInvalidChange() {
4666
- this.emit("sgds-validity-change", { detail: { invalid: this.invalid } });
4667
- }
4668
- /** Simulates a click on the checkbox. */
4669
- click() {
4670
- this.input.click();
4671
- }
4672
- /** Sets focus on the checkbox. */
4673
- focus(options) {
4674
- this.input.focus(options);
4675
- }
4676
- /** Removes focus from the checkbox. */
4677
- blur() {
4678
- this.input.blur();
4679
- }
4680
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
4681
- reportValidity() {
4682
- if (!this.input.reportValidity()) {
4683
- this.invalid = !this.input.checkValidity();
4684
- }
4685
- return this.input.reportValidity();
4686
- }
4687
- _handleChange() {
4688
- if (this.indeterminate) {
4689
- this.indeterminate = !this.indeterminate;
4690
- }
4691
- this.checked = !this.checked;
4692
- this.value = this.input.value;
4693
- this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
4694
- }
4695
- _handleKeyDown(event) {
4696
- const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
4697
- if (event.key === "Enter" && !hasModifier) {
4698
- this.click();
4699
- }
4700
- }
4701
- _handleInvalid(e) {
4702
- e.preventDefault();
4703
- this.invalid = true;
4704
- }
4705
- /** @internal */
4706
- handleDisabledChange() {
4707
- // Disabled form controls are always valid, so we need to recheck validity when the state changes
4708
- this.input.disabled = this.disabled;
4709
- this.invalid = !this.input.checkValidity();
4710
- }
4711
- /** @internal */
4712
- handleStateChange() {
4713
- this.invalid = !this.input.checkValidity();
4714
- }
4715
- render() {
4716
- return html `
4717
- <div
4718
- class=${classMap({
4719
- "form-check": true
4720
- })}
4721
- >
4722
- <input
4723
- class=${classMap({
4724
- "form-check-input": true,
4725
- "is-invalid": this.hasFeedback && this.invalid,
4726
- md: this._size === "md"
4727
- })}
4728
- type="checkbox"
4729
- id=${this._inputId}
4730
- aria-invalid=${this.invalid ? "true" : "false"}
4731
- name=${ifDefined(this.name)}
4732
- value=${ifDefined(this.value)}
4733
- ?checked=${this.checked}
4734
- ?indeterminate=${this.indeterminate}
4735
- ?disabled=${this.disabled}
4736
- ?required=${this.required}
4737
- aria-disabled=${this.disabled ? "true" : "false"}
4738
- aria-checked=${this.checked ? "true" : "false"}
4739
- @change=${this._handleChange}
4740
- @keydown=${this._handleKeyDown}
4741
- @invalid=${(e) => this._handleInvalid(e)}
4742
- />
4743
- <label for="${this._inputId}" aria-label=${ifDefined(this.ariaLabel)} class="form-check-label"
4744
- ><slot></slot
4745
- ></label>
4746
- </div>
4747
- `;
4748
- }
4749
- }
4750
- __decorate([
4751
- query('input[type="checkbox"]')
4752
- ], FormCheckElement.prototype, "input", void 0);
4753
- __decorate([
4754
- property({ type: String, reflect: true })
4755
- ], FormCheckElement.prototype, "name", void 0);
4756
- __decorate([
4757
- property({ type: String, reflect: true })
4758
- ], FormCheckElement.prototype, "ariaLabel", void 0);
4759
- __decorate([
4760
- property({ type: String, reflect: true })
4761
- ], FormCheckElement.prototype, "value", void 0);
4762
- __decorate([
4763
- property({ type: Boolean, reflect: true })
4764
- ], FormCheckElement.prototype, "required", void 0);
4765
- __decorate([
4766
- property({ type: Boolean, reflect: true })
4767
- ], FormCheckElement.prototype, "checked", void 0);
4768
- __decorate([
4769
- property({ type: Boolean, reflect: true })
4770
- ], FormCheckElement.prototype, "disabled", void 0);
4771
- __decorate([
4772
- property({ type: Boolean, reflect: true })
4773
- ], FormCheckElement.prototype, "hasFeedback", void 0);
4774
- __decorate([
4775
- defaultValue("checked")
4776
- ], FormCheckElement.prototype, "defaultChecked", void 0);
4777
- __decorate([
4778
- property({ type: Boolean, reflect: true })
4779
- ], FormCheckElement.prototype, "invalid", void 0);
4780
- __decorate([
4781
- property({ type: Boolean, reflect: true })
4782
- ], FormCheckElement.prototype, "indeterminate", void 0);
4783
- __decorate([
4784
- watch("invalid", { waitUntilFirstUpdate: true })
4785
- ], FormCheckElement.prototype, "_handleInvalidChange", null);
4786
- __decorate([
4787
- property({ type: String })
4788
- ], FormCheckElement.prototype, "_size", void 0);
4789
- __decorate([
4790
- watch("disabled", { waitUntilFirstUpdate: true })
4791
- ], FormCheckElement.prototype, "handleDisabledChange", null);
4792
- __decorate([
4793
- watch("checked", { waitUntilFirstUpdate: true })
4794
- ], FormCheckElement.prototype, "handleStateChange", null);
4795
-
4796
- function genId (componentName = "", elementName = "") {
4797
- return `id-${Math.random().toString().substring(2, 6)}-sgds-${componentName}-${elementName}`;
4798
- }
4799
-
4800
- var css_248z$4 = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input,.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-bg);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:var(--sgds-form-border-radius-md)}.form-check-input:focus,.form-check-input:focus-visible{box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path d="M14.347 3.979a.522.522 0 0 1 0 .739L7.043 12.02a.521.521 0 0 1-.738 0L2.653 8.369a.522.522 0 1 1 .739-.738l3.282 3.283 6.934-6.935a.52.52 0 0 1 .739 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}.form-check-input:indeterminate,.form-check-input[indeterminate]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-check-input:checked.is-invalid,.form-check-input[checked].is-invalid{background-color:var(--sgds-form-danger-bg)}`;
4843
+ var css_248z$1 = css`input{margin:0}.form-check{display:flex;gap:var(--sgds-form-gap-md);padding:var(--sgds-form-padding-inline-sm) 0}.form-check-input,.form-check-input-container{height:var(--sgds-form-height-sm);width:var(--sgds-form-width-xs)}.form-check-input{appearance:none;background-color:var(--sgds-form-bg);background-image:var(--sgds-radio-bg-image);background-position:50%;background-repeat:no-repeat;background-size:auto;border:var(--sgds-form-border-width-default) solid var(--sgds-form-border-color);border-radius:var(--sgds-form-border-radius-md)}.form-check-input:focus,.form-check-input:focus-visible{box-shadow:var(--sgds-form-box-shadow-focus);outline:0}.form-check-input:checked,.form-check-input[checked]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path d="M14.347 3.979a.522.522 0 0 1 0 .739L7.043 12.02a.521.521 0 0 1-.738 0L2.653 8.369a.522.522 0 1 1 .739-.738l3.282 3.283 6.934-6.935a.52.52 0 0 1 .739 0Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}.form-check-input:indeterminate,.form-check-input[indeterminate]{--sgds-radio-bg-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5Z" fill="%23fff"/></svg>');background-color:var(--sgds-form-primary-bg)}:host([disabled]) .form-check{cursor:not-allowed;opacity:var(--sgds-opacity-50)}.form-check-input.is-invalid{border:var(--sgds-form-border-width-thick) solid var(--sgds-form-danger-border-color)}.form-check-input:checked.is-invalid,.form-check-input[checked].is-invalid{background-color:var(--sgds-form-danger-bg)}.form-check-input:indeterminate.is-invalid,.form-check-input[indeterminate].is-invalid{background-color:var(--sgds-form-danger-bg)}`;
4801
4844
 
4802
4845
  /**
4803
4846
  * @summary Checkbox component is used when you require users to select multiple items from a list.
@@ -4805,36 +4848,29 @@
4805
4848
  * @slot default - The label of checkbox.
4806
4849
  *
4807
4850
  * @event sgds-change - Emitted when the checked state changes.
4851
+ * @event sgds-blur - Emitted when input is not in focus.
4852
+ * @event sgds-focus - Emitted when input is in focus.
4808
4853
  * @event sgds-validity-change - Emitted when the invalid state changes. This event is used by sgds-checkbox-group to check the invalid state change of its children
4809
4854
  */
4810
- class SgdsCheckbox extends SgdsElement {
4855
+ class SgdsCheckbox extends SgdsFormValidatorMixin(FormControlElement) {
4811
4856
  constructor() {
4812
4857
  super(...arguments);
4813
- /**@internal */
4814
- this.formSubmitController = new FormSubmitController(this, {
4815
- value: (control) => (control.checked ? control.value : undefined),
4816
- defaultValue: (control) => control.defaultChecked,
4817
- setValue: (control, checked) => (control.checked = checked)
4818
- });
4819
- /** Makes the checkbox a required field. */
4820
- this.required = false;
4821
4858
  /** Draws the checkbox in a checked state. */
4822
4859
  this.checked = false;
4823
- /** Disables the checkbox (so the user can't check / uncheck it). */
4824
- this.disabled = false;
4825
4860
  /** Allows invalidFeedback, invalid and valid styles to be visible with the input */
4826
4861
  this.hasFeedback = false;
4827
4862
  /** Gets or sets the default value used to reset this element. The initial value corresponds to the one originally specified in the HTML that created this element. */
4828
4863
  this.defaultChecked = false;
4829
- /** Marks the checkbox input as invalid. Replace the pseudo :invalid selector for absent in custom elements */
4830
- this.invalid = false;
4831
4864
  /** Marks the checkbox input as indeterminate , with indeterminate logo */
4832
4865
  this.indeterminate = false;
4833
- /** @internal For Id/For pair of the HTML form control and label. */
4834
- this._inputId = genId("checkbox");
4866
+ /** Makes the checkbox a required field. */
4867
+ this.required = false;
4868
+ this._isTouched = false;
4835
4869
  }
4836
4870
  _handleInvalidChange() {
4837
- this.emit("sgds-validity-change", { detail: { invalid: this.invalid } });
4871
+ this.emit("sgds-validity-change", {
4872
+ detail: { invalid: this.invalid, validationMessage: this.input.validationMessage }
4873
+ });
4838
4874
  }
4839
4875
  /** Simulates a click on the checkbox. */
4840
4876
  click() {
@@ -4848,19 +4884,13 @@
4848
4884
  blur() {
4849
4885
  this.input.blur();
4850
4886
  }
4851
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
4852
- reportValidity() {
4853
- if (!this.input.reportValidity()) {
4854
- this.invalid = !this.input.checkValidity();
4855
- }
4856
- return this.input.reportValidity();
4857
- }
4858
- _handleChange() {
4887
+ _handleChange(e) {
4859
4888
  if (this.indeterminate) {
4860
4889
  this.indeterminate = !this.indeterminate;
4861
4890
  }
4862
4891
  this.checked = !this.checked;
4863
4892
  this.value = this.input.value;
4893
+ super._mixinHandleChange(e);
4864
4894
  this.emit("sgds-change", { detail: { checked: this.checked, value: this.value } });
4865
4895
  }
4866
4896
  _handleKeyDown(event) {
@@ -4869,6 +4899,13 @@
4869
4899
  this.click();
4870
4900
  }
4871
4901
  }
4902
+ _handleBlur() {
4903
+ this._isTouched = true;
4904
+ this.emit("sgds-blur");
4905
+ }
4906
+ _handleFocus() {
4907
+ this.emit("sgds-focus");
4908
+ }
4872
4909
  _handleInvalid(e) {
4873
4910
  e.preventDefault();
4874
4911
  this.invalid = true;
@@ -4876,12 +4913,43 @@
4876
4913
  /** @internal */
4877
4914
  _handleDisabledChange() {
4878
4915
  // Disabled form controls are always valid, so we need to recheck validity when the state changes
4879
- this.input.disabled = this.disabled;
4880
- this.invalid = !this.input.checkValidity();
4916
+ this.setInvalid(false);
4881
4917
  }
4882
- /** @internal */
4883
- _handleStateChange() {
4884
- this.invalid = !this.input.checkValidity();
4918
+ _handleIsTouched() {
4919
+ if (this._isTouched) {
4920
+ this.invalid = !this.input.checkValidity();
4921
+ }
4922
+ }
4923
+ _mixinResetFormControl() {
4924
+ this._isTouched = false;
4925
+ this.checked = this.input.checked = this.defaultChecked;
4926
+ this.input.dispatchEvent(new InputEvent("reset"));
4927
+ this._mixinResetValidity(this.input);
4928
+ }
4929
+ /**
4930
+ * Checks for validity. Under the hood, HTMLFormElement's reportValidity method calls this method to check for component's validity state
4931
+ * Note that the native error popup is prevented for SGDS form components by default. Instead the validation message shows up in the feedback container of SgdsInput
4932
+ */
4933
+ reportValidity() {
4934
+ return this._mixinReportValidity();
4935
+ }
4936
+ /**
4937
+ * Checks for validity without any native error popup message
4938
+ */
4939
+ checkValidity() {
4940
+ return this._mixinCheckValidity();
4941
+ }
4942
+ /**
4943
+ * Returns the ValidityState object
4944
+ */
4945
+ get validity() {
4946
+ return this._mixinGetValidity();
4947
+ }
4948
+ /**
4949
+ * Returns the validation message based on the ValidityState
4950
+ */
4951
+ get validationMessage() {
4952
+ return this._mixinGetValidationMessage();
4885
4953
  }
4886
4954
  render() {
4887
4955
  return html `
@@ -4893,45 +4961,35 @@
4893
4961
  "is-invalid": this.hasFeedback && this.invalid
4894
4962
  })}
4895
4963
  type="checkbox"
4896
- id=${this._inputId}
4964
+ id=${this._controlId}
4897
4965
  aria-invalid=${this.invalid ? "true" : "false"}
4898
4966
  name=${ifDefined(this.name)}
4899
- value=${ifDefined(this.value)}
4900
- ?checked=${this.checked}
4901
4967
  ?indeterminate=${this.indeterminate}
4902
- ?disabled=${this.disabled}
4903
4968
  ?required=${this.required}
4904
4969
  aria-disabled=${this.disabled ? "true" : "false"}
4905
4970
  aria-checked=${this.checked ? "true" : "false"}
4906
- @change=${this._handleChange}
4971
+ @change=${(e) => this._handleChange(e)}
4907
4972
  @keydown=${this._handleKeyDown}
4908
4973
  @invalid=${(e) => this._handleInvalid(e)}
4974
+ .checked=${live(this.checked)}
4975
+ .disabled=${this.disabled}
4976
+ .required=${this.required}
4977
+ @blur=${this._handleBlur}
4978
+ @focus=${this._handleFocus}
4909
4979
  />
4910
4980
  </div>
4911
- <label for="${this._inputId}" class="form-check-label"><slot></slot></label>
4981
+ <label for="${this._controlId}" class="form-check-label" id="${this._labelId}"><slot></slot></label>
4912
4982
  </div>
4913
4983
  `;
4914
4984
  }
4915
4985
  }
4916
- SgdsCheckbox.styles = [...FormCheckElement.styles, css_248z$4];
4917
- __decorate([
4918
- query('input[type="checkbox"]')
4919
- ], SgdsCheckbox.prototype, "input", void 0);
4920
- __decorate([
4921
- property({ type: String, reflect: true })
4922
- ], SgdsCheckbox.prototype, "name", void 0);
4986
+ SgdsCheckbox.styles = [...FormControlElement.styles, css_248z$1];
4923
4987
  __decorate([
4924
4988
  property({ type: String, reflect: true })
4925
4989
  ], SgdsCheckbox.prototype, "value", void 0);
4926
- __decorate([
4927
- property({ type: Boolean, reflect: true })
4928
- ], SgdsCheckbox.prototype, "required", void 0);
4929
4990
  __decorate([
4930
4991
  property({ type: Boolean, reflect: true })
4931
4992
  ], SgdsCheckbox.prototype, "checked", void 0);
4932
- __decorate([
4933
- property({ type: Boolean, reflect: true })
4934
- ], SgdsCheckbox.prototype, "disabled", void 0);
4935
4993
  __decorate([
4936
4994
  property({ type: Boolean, reflect: true })
4937
4995
  ], SgdsCheckbox.prototype, "hasFeedback", void 0);
@@ -4940,10 +4998,13 @@
4940
4998
  ], SgdsCheckbox.prototype, "defaultChecked", void 0);
4941
4999
  __decorate([
4942
5000
  property({ type: Boolean, reflect: true })
4943
- ], SgdsCheckbox.prototype, "invalid", void 0);
5001
+ ], SgdsCheckbox.prototype, "indeterminate", void 0);
4944
5002
  __decorate([
4945
5003
  property({ type: Boolean, reflect: true })
4946
- ], SgdsCheckbox.prototype, "indeterminate", void 0);
5004
+ ], SgdsCheckbox.prototype, "required", void 0);
5005
+ __decorate([
5006
+ state()
5007
+ ], SgdsCheckbox.prototype, "_isTouched", void 0);
4947
5008
  __decorate([
4948
5009
  watch("invalid", { waitUntilFirstUpdate: true })
4949
5010
  ], SgdsCheckbox.prototype, "_handleInvalidChange", null);
@@ -4951,21 +5012,20 @@
4951
5012
  watch("disabled", { waitUntilFirstUpdate: true })
4952
5013
  ], SgdsCheckbox.prototype, "_handleDisabledChange", null);
4953
5014
  __decorate([
4954
- watch("checked", { waitUntilFirstUpdate: true })
4955
- ], SgdsCheckbox.prototype, "_handleStateChange", null);
4956
-
4957
- var css_248z$3 = css`.invalid-feedback-container{display:flex;gap:var(--sgds-form-gap-sm)}.invalid-feedback{color:var(--sgds-form-danger-color);font-size:var(--sgds-font-size-1);font-weight:var(--sgds-font-weight-regular)}`;
4958
-
4959
- var css_248z$2 = css`.form-label{margin-bottom:0}.form-check-label,.form-label{color:var(--sgds-form-color)}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:not-allowed}`;
5015
+ watch("_isTouched", { waitUntilFirstUpdate: true })
5016
+ ], SgdsCheckbox.prototype, "_handleIsTouched", null);
4960
5017
 
4961
- var css_248z$1 = css`:host{--sgds-checkbox-group-gap:var(--sgds-spacer-2)}fieldset{border:0;gap:var(--sgds-form-gap-md);margin:0;min-width:0;padding:0}.label-hint-container,fieldset{display:flex;flex-direction:column}.label-hint-container{gap:var(--sgds-form-gap-sm)}.label-hint-container .form-label{color:var(--sgds-form-color);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular)}.checkbox-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}`;
4962
-
4963
- var css_248z = css`.form-text{color:var(--sgds-form-color-subtle);font-size:var(--sgds-font-size-1)}`;
5018
+ var css_248z = css`:host{--sgds-checkbox-group-gap:var(--sgds-spacer-2)}fieldset{border:0;gap:var(--sgds-form-gap-md);margin:0;min-width:0;padding:0}.label-hint-container,fieldset{display:flex;flex-direction:column}.label-hint-container{gap:var(--sgds-form-gap-sm)}.label-hint-container .form-label{color:var(--sgds-form-color);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular)}.checkbox-container{display:flex;flex-direction:column;gap:var(--sgds-form-gap-md)}`;
4964
5019
 
5020
+ /**
5021
+ * @summary CheckboxGroup is the container that group multiple checkboxes under a single question field.
5022
+ * It handles the display of validation feedback of its checkboxes children.
5023
+ *
5024
+ * @slot default - Pass in `sgds-checkbox` into the default slot
5025
+ */
4965
5026
  class SgdsCheckboxGroup extends SgdsElement {
4966
5027
  constructor() {
4967
5028
  super();
4968
- /**@internal */
4969
5029
  this.hasInvalidCheckbox = false;
4970
5030
  /** The checkbox group's label */
4971
5031
  this.label = "";
@@ -4977,6 +5037,7 @@
4977
5037
  this.hintText = "";
4978
5038
  this.addEventListener("sgds-validity-change", (e) => {
4979
5039
  this.hasInvalidCheckbox = e.detail.invalid;
5040
+ this.validationMessage = e.detail.validationMessage;
4980
5041
  });
4981
5042
  }
4982
5043
  _checkInvalidState() {
@@ -5004,7 +5065,7 @@
5004
5065
  ${this._renderHintText()}
5005
5066
  </div>
5006
5067
  <div class="checkbox-container">
5007
- <slot name="checkbox"></slot>
5068
+ <slot></slot>
5008
5069
  </div>
5009
5070
  ${this.hasInvalidCheckbox && this.hasFeedback
5010
5071
  ? html `
@@ -5015,7 +5076,9 @@
5015
5076
  fill="#B90000"
5016
5077
  />
5017
5078
  </svg>
5018
- <div id="checkbox-feedback" tabindex="0" class="invalid-feedback">${this.invalidFeedback}</div>
5079
+ <div id="checkbox-feedback" tabindex="0" class="invalid-feedback">
5080
+ ${this.invalidFeedback ? this.invalidFeedback : this.validationMessage}
5081
+ </div>
5019
5082
  </div>
5020
5083
  `
5021
5084
  : nothing}
@@ -5023,13 +5086,16 @@
5023
5086
  `;
5024
5087
  }
5025
5088
  }
5026
- SgdsCheckboxGroup.styles = [...SgdsElement.styles, css_248z$3, css_248z$2, css_248z$1, css_248z];
5089
+ SgdsCheckboxGroup.styles = [...SgdsElement.styles, css_248z$6, css_248z$4, css_248z, css_248z$5];
5027
5090
  __decorate([
5028
- queryAssignedElements({ slot: "checkbox", flatten: true })
5091
+ queryAssignedElements({ flatten: true })
5029
5092
  ], SgdsCheckboxGroup.prototype, "checkboxes", void 0);
5030
5093
  __decorate([
5031
5094
  state()
5032
5095
  ], SgdsCheckboxGroup.prototype, "hasInvalidCheckbox", void 0);
5096
+ __decorate([
5097
+ state()
5098
+ ], SgdsCheckboxGroup.prototype, "validationMessage", void 0);
5033
5099
  __decorate([
5034
5100
  property({ reflect: true })
5035
5101
  ], SgdsCheckboxGroup.prototype, "label", void 0);