@uh-design-system/component-library 0.5.2 → 0.6.0

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 (243) hide show
  1. package/dist/cjs/{utils-3412cbed.js → attributes-BMbXzbwU.js} +2 -28
  2. package/dist/cjs/component-library.cjs.js +7 -7
  3. package/dist/cjs/controlUtils-ofqiQxRF.js +42 -0
  4. package/dist/cjs/ds-accordion.cjs.entry.js +79 -0
  5. package/dist/cjs/ds-button.cjs.entry.js +107 -0
  6. package/dist/cjs/ds-card.cjs.entry.js +58 -0
  7. package/dist/cjs/ds-checkbox-group.cjs.entry.js +109 -49
  8. package/dist/cjs/ds-checkbox.cjs.entry.js +88 -79
  9. package/dist/cjs/ds-icon.cjs.entry.js +943 -0
  10. package/dist/cjs/ds-input-validity.cjs.entry.js +14 -15
  11. package/dist/cjs/ds-link-with-arrow.cjs.entry.js +21 -20
  12. package/dist/cjs/ds-link.cjs.entry.js +34 -31
  13. package/dist/cjs/ds-radio-button-group.cjs.entry.js +153 -0
  14. package/dist/cjs/ds-radio-button.cjs.entry.js +151 -0
  15. package/dist/cjs/ds-spinner.cjs.entry.js +62 -0
  16. package/dist/cjs/ds-text-input.cjs.entry.js +90 -77
  17. package/dist/cjs/ds-visually-hidden.cjs.entry.js +3 -6
  18. package/dist/cjs/index-Bp6Dd2i1.js +94 -0
  19. package/dist/cjs/{store-9bd20f3c.js → index-DwLFyR5p.js} +6 -2
  20. package/dist/cjs/{index-bf84b124.js → index-Mjp9Y-Sw.js} +701 -55
  21. package/dist/cjs/index.cjs.js +3 -5
  22. package/dist/cjs/{linkUtils-695da37c.js → linkUtils-onlbgKdI.js} +4 -2
  23. package/dist/cjs/loader.cjs.js +3 -5
  24. package/dist/cjs/utils-BjZTECpy.js +29 -0
  25. package/dist/collection/accessibility/stories/naming.stories.js +3 -3
  26. package/dist/collection/collection-manifest.json +78 -3
  27. package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.css +18 -17
  28. package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.js +91 -50
  29. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.examples.stories.js +6 -6
  30. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.features.stories.js +14 -14
  31. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.stories.js +24 -66
  32. package/dist/collection/components/01-base-components/ds-button/ds-button.css +124 -145
  33. package/dist/collection/components/01-base-components/ds-button/ds-button.js +150 -65
  34. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.examples.stories.js +121 -23
  35. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.features.stories.js +49 -42
  36. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.stories.js +16 -72
  37. package/dist/collection/components/01-base-components/ds-card/ds-card.css +127 -0
  38. package/dist/collection/components/01-base-components/ds-card/ds-card.js +303 -0
  39. package/dist/collection/components/01-base-components/ds-card/stories/ds-card.examples.stories.js +92 -0
  40. package/dist/collection/components/01-base-components/ds-card/stories/ds-card.features.stories.js +66 -0
  41. package/dist/collection/components/01-base-components/ds-card/stories/ds-card.stories.js +71 -0
  42. package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.css +46 -46
  43. package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.js +120 -111
  44. package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.features.stories.js +20 -20
  45. package/dist/collection/components/01-base-components/ds-checkbox/stories/ds-checkbox.stories.js +12 -25
  46. package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.css +2 -3
  47. package/dist/collection/components/01-base-components/ds-checkbox-group/ds-checkbox-group.js +214 -63
  48. package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.js +215 -50
  49. package/dist/collection/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.stories.js +30 -28
  50. package/dist/collection/components/01-base-components/ds-icon/ds-icon.js +36 -31
  51. package/dist/collection/components/01-base-components/ds-icon/stories/ds-icon.stories.js +10 -37
  52. package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.css +2 -2
  53. package/dist/collection/components/01-base-components/ds-input-validity/ds-input-validity.js +60 -30
  54. package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.features.stories.js +4 -4
  55. package/dist/collection/components/01-base-components/ds-input-validity/stories/ds-input-validity.stories.js +4 -9
  56. package/dist/collection/components/01-base-components/ds-link/ds-link.css +24 -14
  57. package/dist/collection/components/01-base-components/ds-link/ds-link.js +74 -75
  58. package/dist/collection/components/01-base-components/ds-link/stories/ds-link.examples.stories.js +27 -27
  59. package/dist/collection/components/01-base-components/ds-link/stories/ds-link.features.stories.js +38 -21
  60. package/dist/collection/components/01-base-components/ds-link/stories/ds-link.stories.js +8 -67
  61. package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.css +10 -12
  62. package/dist/collection/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.js +30 -52
  63. package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.examples.stories.js +4 -4
  64. package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.features.stories.js +6 -6
  65. package/dist/collection/components/01-base-components/ds-link-with-arrow/stories/ds-link-with-arrow.stories.js +4 -28
  66. package/dist/collection/components/01-base-components/ds-radio-button/ds-radio-button.css +115 -0
  67. package/dist/collection/components/01-base-components/ds-radio-button/ds-radio-button.js +449 -0
  68. package/dist/collection/components/01-base-components/ds-radio-button/stories/ds-radio-button.features.stories.js +72 -0
  69. package/dist/collection/components/01-base-components/ds-radio-button/stories/ds-radio-button.stories.js +22 -0
  70. package/dist/collection/components/01-base-components/ds-radio-button-group/ds-radio-button-group.css +30 -0
  71. package/dist/collection/components/01-base-components/ds-radio-button-group/ds-radio-button-group.js +360 -0
  72. package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.examples.stories.js +42 -0
  73. package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.features.stories.js +71 -0
  74. package/dist/collection/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.stories.js +60 -0
  75. package/dist/collection/components/01-base-components/ds-spinner/ds-spinner.css +279 -0
  76. package/dist/collection/components/01-base-components/ds-spinner/ds-spinner.js +221 -0
  77. package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.examples.stories.js +120 -0
  78. package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.features.stories.js +107 -0
  79. package/dist/collection/components/01-base-components/ds-spinner/stories/ds-spinner.stories.js +14 -0
  80. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.css +85 -118
  81. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +230 -155
  82. package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.examples.stories.js +26 -21
  83. package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.features.stories.js +40 -40
  84. package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.stories.js +30 -56
  85. package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js +1 -1
  86. package/dist/collection/store.js +7 -1
  87. package/dist/collection/utils/attributes/attributes.js +2 -2
  88. package/dist/collection/utils/button/buttonUtils.js +14 -0
  89. package/dist/collection/utils/colours/colourTypes.js +3 -3
  90. package/dist/collection/utils/colours/colourUtils.js +5 -3
  91. package/dist/collection/utils/controls/controlUtils.js +35 -1
  92. package/dist/collection/utils/link/linkUtils.js +3 -2
  93. package/dist/collection/utils/spinner/spinnerUtils.js +20 -0
  94. package/dist/collection/utils/tests/testUtils.js +1 -0
  95. package/dist/collection/utils/typography/typographyUtils.js +3 -3
  96. package/dist/collection/utils/utils.js +10 -9
  97. package/dist/component-library/{utils-cfc536bc.js → attributes-BD_lNRxn.js} +1 -1
  98. package/dist/component-library/component-library.css +1 -1
  99. package/dist/component-library/component-library.esm.js +1 -1
  100. package/dist/component-library/controlUtils-CNER0MvM.js +1 -0
  101. package/dist/component-library/ds-accordion.entry.js +1 -0
  102. package/dist/component-library/ds-button.entry.js +1 -0
  103. package/dist/component-library/ds-card.entry.js +1 -0
  104. package/dist/component-library/ds-checkbox-group.entry.js +1 -1
  105. package/dist/component-library/ds-checkbox.entry.js +1 -1
  106. package/dist/component-library/ds-icon.entry.js +1 -0
  107. package/dist/component-library/ds-input-validity.entry.js +1 -1
  108. package/dist/component-library/ds-link-with-arrow.entry.js +1 -1
  109. package/dist/component-library/ds-link.entry.js +1 -1
  110. package/dist/component-library/ds-radio-button-group.entry.js +1 -0
  111. package/dist/component-library/ds-radio-button.entry.js +1 -0
  112. package/dist/component-library/ds-spinner.entry.js +1 -0
  113. package/dist/component-library/ds-text-input.entry.js +1 -1
  114. package/dist/component-library/ds-visually-hidden.entry.js +1 -1
  115. package/dist/component-library/index-BfTCfPZ1.js +6 -0
  116. package/dist/component-library/index-Cm7V4EAn.js +2 -0
  117. package/dist/component-library/index-DuYjhvTn.js +1 -0
  118. package/dist/component-library/index.esm.js +1 -1
  119. package/dist/component-library/linkUtils-02nCfO0F.js +1 -0
  120. package/dist/component-library/utils-CqaqnfY4.js +1 -0
  121. package/dist/components/attributes.js +3 -3
  122. package/dist/components/controlUtils.js +35 -2
  123. package/dist/components/ds-accordion.js +58 -42
  124. package/dist/components/ds-button2.js +78 -39
  125. package/dist/components/ds-card.d.ts +11 -0
  126. package/dist/components/ds-card.js +91 -0
  127. package/dist/components/ds-checkbox-group.js +116 -56
  128. package/dist/components/ds-checkbox2.js +93 -80
  129. package/dist/components/ds-icon2.js +292 -292
  130. package/dist/components/ds-input-validity2.js +17 -14
  131. package/dist/components/ds-link-with-arrow.js +22 -22
  132. package/dist/components/ds-link.js +43 -40
  133. package/dist/components/ds-radio-button-group.d.ts +11 -0
  134. package/dist/components/ds-radio-button-group.js +185 -0
  135. package/dist/components/ds-radio-button.d.ts +11 -0
  136. package/dist/components/ds-radio-button.js +198 -0
  137. package/dist/components/ds-spinner.d.ts +11 -0
  138. package/dist/components/ds-spinner.js +6 -0
  139. package/dist/components/ds-spinner2.js +89 -0
  140. package/dist/components/ds-text-input.js +126 -104
  141. package/dist/components/ds-visually-hidden2.js +2 -3
  142. package/dist/components/index.js +208 -2
  143. package/dist/components/index2.js +713 -39
  144. package/dist/components/index3.js +69 -57
  145. package/dist/components/linkUtils.js +4 -2
  146. package/dist/docs.d.ts +443 -0
  147. package/dist/docs.json +4790 -0
  148. package/dist/esm/{utils-cfc536bc.js → attributes-BD_lNRxn.js} +3 -26
  149. package/dist/esm/component-library.js +6 -5
  150. package/dist/esm/controlUtils-CNER0MvM.js +37 -0
  151. package/dist/esm/ds-accordion.entry.js +77 -0
  152. package/dist/esm/ds-button.entry.js +105 -0
  153. package/dist/esm/ds-card.entry.js +56 -0
  154. package/dist/esm/ds-checkbox-group.entry.js +108 -46
  155. package/dist/esm/ds-checkbox.entry.js +78 -67
  156. package/dist/esm/ds-icon.entry.js +941 -0
  157. package/dist/esm/ds-input-validity.entry.js +14 -13
  158. package/dist/esm/ds-link-with-arrow.entry.js +21 -18
  159. package/dist/esm/ds-link.entry.js +34 -29
  160. package/dist/esm/ds-radio-button-group.entry.js +151 -0
  161. package/dist/esm/ds-radio-button.entry.js +149 -0
  162. package/dist/esm/ds-spinner.entry.js +60 -0
  163. package/dist/esm/ds-text-input.entry.js +88 -73
  164. package/dist/esm/ds-visually-hidden.entry.js +3 -4
  165. package/dist/esm/index-BfTCfPZ1.js +92 -0
  166. package/dist/esm/{index-434995e1.js → index-Cm7V4EAn.js} +699 -34
  167. package/dist/{components/store.js → esm/index-DuYjhvTn.js} +6 -3
  168. package/dist/esm/index.js +2 -2
  169. package/dist/esm/{linkUtils-3d1b28cf.js → linkUtils-02nCfO0F.js} +4 -2
  170. package/dist/esm/loader.js +4 -4
  171. package/dist/esm/utils-CqaqnfY4.js +25 -0
  172. package/dist/hydrate/index.d.ts +271 -0
  173. package/dist/hydrate/index.js +22280 -0
  174. package/dist/hydrate/index.mjs +22272 -0
  175. package/dist/hydrate/package.json +12 -0
  176. package/dist/styles/helpers.css +15 -0
  177. package/dist/styles/helpers.css.map +1 -0
  178. package/dist/styles/mixins/_breakpoints.scss +13 -0
  179. package/dist/styles/mixins/_focus.scss +26 -0
  180. package/dist/styles/mixins/_wrapper.scss +5 -0
  181. package/dist/styles/mixins/imports-default/_imports.scss +2 -0
  182. package/dist/styles/mixins/tokens/_breakpoints.scss +13 -0
  183. package/dist/styles/mixins/tokens/_semantic-colours.scss +75 -0
  184. package/dist/styles/mixins.scss +12 -0
  185. package/dist/styles/variables.css +176 -0
  186. package/dist/styles/variables.css.map +1 -0
  187. package/dist/types/components/01-base-components/ds-accordion/ds-accordion.d.ts +11 -8
  188. package/dist/types/components/01-base-components/ds-button/ds-button.d.ts +16 -11
  189. package/dist/types/components/01-base-components/ds-button/stories/ds-button.examples.stories.d.ts +1 -0
  190. package/dist/types/components/01-base-components/ds-button/stories/ds-button.features.stories.d.ts +1 -0
  191. package/dist/types/components/01-base-components/ds-card/ds-card.d.ts +20 -0
  192. package/dist/types/components/01-base-components/ds-card/stories/ds-card.examples.stories.d.ts +8 -0
  193. package/dist/types/components/01-base-components/ds-card/stories/ds-card.features.stories.d.ts +8 -0
  194. package/dist/types/components/01-base-components/ds-card/stories/ds-card.stories.d.ts +7 -0
  195. package/dist/types/components/01-base-components/ds-checkbox/ds-checkbox.d.ts +21 -22
  196. package/dist/types/components/01-base-components/ds-checkbox-group/ds-checkbox-group.d.ts +21 -11
  197. package/dist/types/components/01-base-components/ds-checkbox-group/stories/ds-checkbox-group.features.stories.d.ts +3 -0
  198. package/dist/types/components/01-base-components/ds-icon/ds-icon.d.ts +7 -5
  199. package/dist/types/components/01-base-components/ds-input-validity/ds-input-validity.d.ts +5 -6
  200. package/dist/types/components/01-base-components/ds-link/ds-link.d.ts +13 -14
  201. package/dist/types/components/01-base-components/ds-link/stories/ds-link.features.stories.d.ts +2 -0
  202. package/dist/types/components/01-base-components/ds-link-with-arrow/ds-link-with-arrow.d.ts +5 -7
  203. package/dist/types/components/01-base-components/ds-radio-button/ds-radio-button.d.ts +44 -0
  204. package/dist/types/components/01-base-components/ds-radio-button/stories/ds-radio-button.features.stories.d.ts +15 -0
  205. package/dist/types/components/01-base-components/ds-radio-button/stories/ds-radio-button.stories.d.ts +7 -0
  206. package/dist/types/components/01-base-components/ds-radio-button-group/ds-radio-button-group.d.ts +34 -0
  207. package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.examples.stories.d.ts +6 -0
  208. package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.features.stories.d.ts +11 -0
  209. package/dist/types/components/01-base-components/ds-radio-button-group/stories/ds-radio-button-group.stories.d.ts +7 -0
  210. package/dist/types/components/01-base-components/ds-spinner/ds-spinner.d.ts +17 -0
  211. package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.examples.stories.d.ts +7 -0
  212. package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.features.stories.d.ts +7 -0
  213. package/dist/types/components/01-base-components/ds-spinner/stories/ds-spinner.stories.d.ts +7 -0
  214. package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +37 -32
  215. package/dist/types/components.d.ts +1287 -228
  216. package/dist/types/stencil-public-runtime.d.ts +22 -0
  217. package/dist/types/store.d.ts +6 -1
  218. package/dist/types/utils/attributes/attributes.d.ts +1 -1
  219. package/dist/types/utils/button/buttonUtils.d.ts +1 -0
  220. package/dist/types/utils/colours/colourTypes.d.ts +3 -3
  221. package/dist/types/utils/controls/controlUtils.d.ts +2 -0
  222. package/dist/types/utils/link/linkUtils.d.ts +1 -1
  223. package/dist/types/utils/spinner/spinnerUtils.d.ts +1 -0
  224. package/dist/types/utils/tests/testUtils.d.ts +1 -0
  225. package/dist/types/utils/utils.d.ts +2 -1
  226. package/package.json +40 -36
  227. package/dist/cjs/controlUtils-041de0fd.js +0 -7
  228. package/dist/cjs/ds-accordion_3.cjs.entry.js +0 -1095
  229. package/dist/cjs/index-5b0b9d4c.js +0 -82
  230. package/dist/component-library/controlUtils-9ca4087b.js +0 -1
  231. package/dist/component-library/ds-accordion_3.entry.js +0 -1
  232. package/dist/component-library/index-434995e1.js +0 -2
  233. package/dist/component-library/index-72ac5051.js +0 -6
  234. package/dist/component-library/linkUtils-3d1b28cf.js +0 -1
  235. package/dist/component-library/store-b8d17c10.js +0 -1
  236. package/dist/esm/controlUtils-9ca4087b.js +0 -4
  237. package/dist/esm/ds-accordion_3.entry.js +0 -1089
  238. package/dist/esm/index-72ac5051.js +0 -80
  239. package/dist/esm/store-b8d17c10.js +0 -204
  240. package/dist/loader/package.json +0 -11
  241. /package/dist/cjs/{app-globals-3a1e7e63.js → app-globals-V2Kpy_OQ.js} +0 -0
  242. /package/dist/component-library/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -0
  243. /package/dist/esm/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -0
@@ -1,17 +1,28 @@
1
- import { r as registerInstance, c as createEvent, a as getElement, h, F as Fragment } from './index-434995e1.js';
2
- import { c as classNames } from './index-72ac5051.js';
3
- import { i as inheritAriaAttributes, c as idGenerator } from './utils-cfc536bc.js';
1
+ import { r as registerInstance, c as createEvent, g as getElement, h, F as Fragment } from './index-Cm7V4EAn.js';
2
+ import { c as classNames } from './index-BfTCfPZ1.js';
3
+ import { b as inheritAriaAttributes } from './attributes-BD_lNRxn.js';
4
+ import { i as idGenerator } from './utils-CqaqnfY4.js';
5
+ import { g as getRequiredText, a as getOptionalText, b as atLeastOneOption, c as allOptions } from './controlUtils-CNER0MvM.js';
6
+ import './index-DuYjhvTn.js';
4
7
 
5
- const dsCheckboxGroupCss = ".ds-checkbox-group{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0}.ds-checkbox-group__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-group__assistive-text{font-size:var(--ds-fontSize-14);color:var(--ds-textColor-secondary);line-height:var(--ds-lineHeight-large);margin-bottom:var(--ds-spacing-2xSmall)}.ds-checkbox-group__error{display:flex}.ds-checkbox-group__error--visible{padding-top:var(--ds-spacing-3xSmall)}.ds-checkbox-group>.ds-checkbox-group__checkboxes{display:inline-flex;flex-direction:column}.ds-checkbox-group--inset{margin-left:var(--ds-spacing-large)}.ds-checkbox-group--horizontal>.ds-checkbox-group__checkboxes{flex-direction:row;gap:var(--ds-spacing-small);flex-wrap:wrap}";
6
- const DsCheckboxGroupStyle0 = dsCheckboxGroupCss;
8
+ const dsCheckboxGroupCss = ".ds-checkbox-group{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0}.ds-checkbox-group__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-group__assistive-text{font-size:var(--ds-fontSize-14);color:var(--ds-palette-black-70);line-height:var(--ds-lineHeight-large);margin-bottom:var(--ds-spacing-2xSmall)}.ds-checkbox-group__error{display:flex}.ds-checkbox-group__error--visible{padding-top:var(--ds-spacing-3xSmall)}.ds-checkbox-group>.ds-checkbox-group__checkboxes{display:inline-flex;flex-direction:column}.ds-checkbox-group--inset{margin-left:var(--ds-spacing-large)}.ds-checkbox-group--horizontal>.ds-checkbox-group__checkboxes{flex-flow:row wrap;gap:var(--ds-spacing-small)}";
7
9
 
8
10
  const fieldsetIdGenerator = idGenerator('ds-checkbox-group');
9
11
  const DsCheckboxGroup = class {
10
12
  constructor(hostRef) {
11
13
  registerInstance(this, hostRef);
12
- this.dsCheckboxGroupChange = createEvent(this, "dsCheckboxGroupChange", 7);
13
- this.dsCheckboxGroupIndeterminateChildChange = createEvent(this, "dsCheckboxGroupIndeterminateChildChange", 7);
14
+ this.dsCheckboxGroupChange = createEvent(this, "dsCheckboxGroupChange");
15
+ this.dsCheckboxGroupIndeterminateChildChange = createEvent(this, "dsCheckboxGroupIndeterminateChildChange");
16
+ this.dsCheckboxGroupInvalidStateChange = createEvent(this, "dsCheckboxGroupInvalidStateChange");
17
+ if (hostRef.$hostElement$["s-ei"]) {
18
+ this.internals = hostRef.$hostElement$["s-ei"];
19
+ }
20
+ else {
21
+ this.internals = hostRef.$hostElement$.attachInternals();
22
+ hostRef.$hostElement$["s-ei"] = this.internals;
23
+ }
14
24
  }
25
+ checkboxElem;
15
26
  fieldsetId = fieldsetIdGenerator.next().value;
16
27
  checkboxId = `${this.fieldsetId}-checkbox`;
17
28
  errorTextId = `${this.fieldsetId}-error`;
@@ -19,23 +30,45 @@ const DsCheckboxGroup = class {
19
30
  nestedId = `${this.fieldsetId}-nested`;
20
31
  inheritedAttributes = {};
21
32
  get el() { return getElement(this); }
33
+ internals;
22
34
  dsCheckboxGroupChange;
23
35
  dsCheckboxGroupIndeterminateChildChange;
24
- legend;
25
- assistiveText;
26
- direction = 'vertical';
27
- errorText = '';
28
- text = '';
29
- checked = false;
30
- disabled = false;
31
- childElementsCount = 0;
36
+ dsCheckboxGroupInvalidStateChange;
37
+ dsLegend;
38
+ dsAssistiveText;
39
+ dsDirection = 'vertical';
40
+ dsErrorText = '';
41
+ dsText = '';
42
+ dsChecked = false;
43
+ dsDisabled = false;
44
+ dsRequired = false;
45
+ dsAllRequired = false;
46
+ dsOptional = false;
47
+ dsOptionalText;
48
+ childElementsCount = 1;
32
49
  checkedChildElementCount = 0;
33
50
  isIndeterminate = false;
34
51
  indeterminateChildCheckboxCount = 0;
52
+ showInternalsValidationMessage = false;
35
53
  elementIs = (localName) => (element) => element.localName === localName;
36
54
  elementIsCheckbox = this.elementIs('ds-checkbox');
37
55
  elementIsCheckboxGroup = this.elementIs('ds-checkbox-group');
38
- getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.errorText) && this.errorTextId].filter(Boolean).join(' ');
56
+ getLegendText = () => {
57
+ if (this.dsRequired || this.dsAllRequired) {
58
+ return getRequiredText(this.dsLegend);
59
+ }
60
+ if (this.dsOptional) {
61
+ return getOptionalText(this.dsLegend, this.dsOptionalText);
62
+ }
63
+ return this.dsLegend;
64
+ };
65
+ getAriaDescribedBy = () => [
66
+ !!this.dsAssistiveText && this.assistiveTextId,
67
+ (!!this.dsErrorText || (this.showInternalsValidationMessage && !!this.internals?.validationMessage)) && this.errorTextId,
68
+ ]
69
+ .filter(Boolean)
70
+ .join(' ');
71
+ getValidationMessage = () => this.dsErrorText || (this.showInternalsValidationMessage ? this.internals?.validationMessage : '');
39
72
  getChildElements = () => {
40
73
  const slot = this.el.shadowRoot.querySelector('slot');
41
74
  return (slot?.assignedElements() || []);
@@ -52,7 +85,7 @@ const DsCheckboxGroup = class {
52
85
  updateChildElementsChecked = (checked) => {
53
86
  this.checkedChildElementCount = checked ? this.childElementsCount : 0;
54
87
  this.updateChildElements((element) => {
55
- element.checked = checked;
88
+ element.dsChecked = checked;
56
89
  if (this.elementIsCheckboxGroup(element)) {
57
90
  (async () => {
58
91
  await element.setChecked(checked);
@@ -65,7 +98,7 @@ const DsCheckboxGroup = class {
65
98
  }
66
99
  watchCheckboxDisabledChange(newValue) {
67
100
  this.updateChildElements((element) => {
68
- element.disabled = newValue;
101
+ element.dsDisabled = newValue;
69
102
  });
70
103
  }
71
104
  watchCheckedChange(newValue) {
@@ -74,77 +107,106 @@ const DsCheckboxGroup = class {
74
107
  watchIndeterminateChange(newValue) {
75
108
  this.dsCheckboxGroupIndeterminateChildChange.emit({ id: this.fieldsetId, indeterminate: newValue });
76
109
  }
110
+ errorTextObserver(errorText) {
111
+ this.dsCheckboxGroupInvalidStateChange.emit(!!errorText);
112
+ }
77
113
  listenIndeterminateChildChange(event) {
78
114
  this.indeterminateChildCheckboxCount = event.detail.indeterminate ? this.indeterminateChildCheckboxCount + 1 : this.indeterminateChildCheckboxCount - 1;
79
115
  }
80
- watchCheckedChildElementCountChange(newValue, oldValue) {
81
- this.isIndeterminate =
82
- this.checkedChildElementCount !== this.childElementsCount && this.checkedChildElementCount < this.childElementsCount && this.checkedChildElementCount > 0;
83
- if (newValue === this.childElementsCount && newValue > oldValue) {
84
- this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
116
+ watchCheckedChildElementCountChange() {
117
+ this.isIndeterminate = this.checkedChildElementCount > 0 && this.checkedChildElementCount < this.childElementsCount;
118
+ if (this.dsRequired && this.checkedChildElementCount === 0) {
119
+ this.internals?.setValidity({ valueMissing: true }, atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
85
120
  }
86
- else if (oldValue === this.childElementsCount && newValue < oldValue) {
87
- this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: false });
121
+ else if (this.dsAllRequired && this.checkedChildElementCount !== this.childElementsCount) {
122
+ this.internals?.setValidity({ valueMissing: true }, allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
123
+ }
124
+ else {
125
+ this.internals?.setValidity({ valueMissing: false });
88
126
  }
89
127
  }
90
- updateCheckedChildElementCount = (event) => {
91
- if (event.detail.checked) {
92
- this.checkedChildElementCount = this.checkedChildElementCount === this.childElementsCount ? this.checkedChildElementCount : this.checkedChildElementCount + 1;
128
+ updateCheckedChildElementCount = (checked) => {
129
+ if (checked) {
130
+ this.checkedChildElementCount = Math.min(this.childElementsCount, this.checkedChildElementCount + 1);
93
131
  }
94
132
  else {
95
- this.checkedChildElementCount = this.checkedChildElementCount === 0 ? 0 : this.checkedChildElementCount - 1;
133
+ this.checkedChildElementCount = Math.max(0, this.checkedChildElementCount - 1);
96
134
  }
97
135
  };
98
136
  listenCheckboxChange(event) {
99
- if (event.detail.id === this.checkboxId) {
100
- this.updateChildElementsChecked(event.detail.checked);
137
+ if (!this.showInternalsValidationMessage) {
138
+ this.showInternalsValidationMessage = true;
139
+ }
140
+ if (event.target === this.el) {
141
+ this.updateChildElementsChecked(this.checkboxElem.dsChecked);
142
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: this.checkboxElem.dsChecked });
101
143
  return;
102
144
  }
103
- if (this.getChildCheckboxElements().includes(event.target)) {
104
- this.updateCheckedChildElementCount(event);
145
+ const target = event.target;
146
+ if (this.getChildCheckboxElements().includes(target)) {
147
+ const previousCheckedChildElementCount = this.checkedChildElementCount;
148
+ this.updateCheckedChildElementCount(target.dsChecked);
149
+ if (this.checkedChildElementCount === this.childElementsCount && this.checkedChildElementCount > previousCheckedChildElementCount) {
150
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
151
+ }
152
+ else if (previousCheckedChildElementCount === this.childElementsCount && this.checkedChildElementCount < previousCheckedChildElementCount) {
153
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: false });
154
+ }
105
155
  }
106
156
  }
107
157
  listenCheckboxGroupChange(event) {
108
158
  if (this.getChildElements().includes(event.target)) {
109
- this.updateCheckedChildElementCount(event);
159
+ event.stopPropagation();
160
+ this.updateCheckedChildElementCount(event.detail.checked);
110
161
  }
111
162
  }
112
- setChildElementCount = () => {
113
- this.childElementsCount = this.getChildElements().length;
114
- };
163
+ formResetCallback() {
164
+ this.internals?.setValidity({});
165
+ }
115
166
  componentWillLoad() {
116
167
  this.inheritedAttributes = inheritAriaAttributes(this.el, ['aria-labelledby']);
117
168
  }
118
169
  componentDidLoad() {
119
- this.setChildElementCount();
170
+ this.childElementsCount = this.getChildElements().length;
120
171
  this.updateChildCheckboxes(element => {
121
- element.setAttribute('data-errors-disabled', 'true');
172
+ element.setAttribute('ds-errors-disabled', 'true');
122
173
  });
174
+ if (this.dsRequired) {
175
+ this.internals?.setValidity({ valueMissing: true }, atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
176
+ }
177
+ else if (this.dsAllRequired) {
178
+ this.internals?.setValidity({ valueMissing: true }, allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
179
+ }
123
180
  }
124
181
  componentDidUpdate() {
125
- this.setChildElementCount();
182
+ const childElementCount = this.getChildElements().length;
183
+ if (this.childElementsCount !== childElementCount) {
184
+ this.childElementsCount = childElementCount;
185
+ }
126
186
  }
127
187
  render() {
128
188
  const classes = classNames('ds-checkbox-group', {
129
- 'ds-checkbox-group--horizontal': this.direction === 'horizontal',
189
+ 'ds-checkbox-group--horizontal': this.dsDirection === 'horizontal',
130
190
  });
131
191
  const legendClasses = classNames('ds-checkbox-group__legend');
132
192
  const assistiveTextClasses = classNames('ds-checkbox-group__assistive-text');
133
193
  const errorClasses = classNames('ds-checkbox-group__error', {
134
- 'ds-checkbox-group__error--visible': Boolean(this.errorText),
194
+ 'ds-checkbox-group__error--visible': Boolean(this.dsErrorText),
135
195
  });
136
196
  const nestedClasses = classNames('ds-checkbox-group', 'ds-checkbox-group--inset');
137
197
  const checkboxesClasses = classNames('ds-checkbox-group__checkboxes');
138
198
  const ariaDescribedBy = this.getAriaDescribedBy();
139
- return (h("fieldset", { key: '1029763130b4d2d138679c9f84ec72c0231fcc83', id: this.fieldsetId, class: classes, "aria-describedby": ariaDescribedBy, ...this.inheritedAttributes }, this.legend && h("legend", { key: 'a9be37aab510d5e402841c8bbda64190548bc1ea', class: legendClasses }, this.legend), this.assistiveText && (h("small", { key: '0ae42c2b46e52dad0570ad120180e662db43f2fa', class: assistiveTextClasses, id: this.assistiveTextId }, this.assistiveText)), this.text ? (h(Fragment, null, h("ds-checkbox", { id: this.checkboxId, text: this.text, checked: this.checkedChildElementCount === this.childElementsCount, disabled: this.disabled, indeterminate: this.indeterminateChildCheckboxCount > 0 || this.isIndeterminate }), h("fieldset", { id: this.nestedId, "aria-labelledby": this.checkboxId, class: nestedClasses }, h("slot", null)))) : (h("div", { class: checkboxesClasses }, h("slot", null))), h("div", { key: '3ea5bb7991a99c676cb50a24d1a679b6f68c96bf', class: errorClasses }, h("ds-input-validity", { key: '8d5ca5e80b2a5f985e09bf7039538a5a13278e8e', id: this.errorTextId, text: this.errorText, type: "error" }))));
199
+ return (h("fieldset", { key: '98ff7c5dd5c36c163ed1dfb177d5c0b28b93971a', id: this.fieldsetId, class: classes, "aria-describedby": ariaDescribedBy, ...this.inheritedAttributes }, this.dsLegend && h("legend", { key: '22274e3c85262fd08f69a9aa548d2910eaf30ce2', class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (h("small", { key: '4566b9d66b0be262548ddecd11f6eda5acc6d399', class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.dsText ? (h(Fragment, null, h("ds-checkbox", { ref: checkboxElem => (this.checkboxElem = checkboxElem), dsId: this.checkboxId, dsText: this.dsText, dsChecked: this.checkedChildElementCount === this.childElementsCount, dsDisabled: this.dsDisabled, dsIndeterminate: this.indeterminateChildCheckboxCount > 0 || this.isIndeterminate }), h("fieldset", { id: this.nestedId, "aria-labelledby": this.checkboxId, class: nestedClasses }, h("slot", null)))) : (h("div", { class: checkboxesClasses }, h("slot", null))), (!!this.dsErrorText || this.dsRequired || this.dsAllRequired) && (h("div", { key: 'd0a2dbc9d46967de609096d9a398b040f5228807', class: errorClasses }, h("ds-input-validity", { key: '409b5d8fbd59b26245cb828146f28eec3d010aaa', id: this.errorTextId, dsText: this.getValidationMessage(), dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
140
200
  }
201
+ static get formAssociated() { return true; }
141
202
  static get watchers() { return {
142
- "disabled": ["watchCheckboxDisabledChange"],
143
- "checked": ["watchCheckedChange"],
203
+ "dsDisabled": ["watchCheckboxDisabledChange"],
204
+ "dsChecked": ["watchCheckedChange"],
144
205
  "isIndeterminate": ["watchIndeterminateChange"],
206
+ "dsErrorText": ["errorTextObserver"],
145
207
  "checkedChildElementCount": ["watchCheckedChildElementCountChange"]
146
208
  }; }
147
209
  };
148
- DsCheckboxGroup.style = DsCheckboxGroupStyle0;
210
+ DsCheckboxGroup.style = dsCheckboxGroupCss;
149
211
 
150
212
  export { DsCheckboxGroup as ds_checkbox_group };
@@ -1,17 +1,17 @@
1
- import { r as registerInstance, c as createEvent, a as getElement, h, F as Fragment } from './index-434995e1.js';
2
- import { c as classNames } from './index-72ac5051.js';
3
- import { i as inheritAriaAttributes, b as inheritAttributes, g as getAriaLabel, c as idGenerator } from './utils-cfc536bc.js';
4
- import { g as getRequiredText, a as getOptionalText } from './controlUtils-9ca4087b.js';
5
- import { i as isValidation } from './store-b8d17c10.js';
1
+ import { r as registerInstance, c as createEvent, g as getElement, h, F as Fragment } from './index-Cm7V4EAn.js';
2
+ import { c as classNames } from './index-BfTCfPZ1.js';
3
+ import { i as inheritAttributes, b as inheritAriaAttributes } from './attributes-BD_lNRxn.js';
4
+ import { g as getRequiredText, a as getOptionalText } from './controlUtils-CNER0MvM.js';
5
+ import { i as isValidation } from './index-DuYjhvTn.js';
6
+ import { i as idGenerator } from './utils-CqaqnfY4.js';
6
7
 
7
- const dsCheckboxCss = ".ds-checkbox-fieldset{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0;gap:var(--ds-spacing-3xSmall)}.ds-checkbox-fieldset__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-fieldset__assistive-text{display:inline;font-size:var(--ds-fontSize-14);color:var(--ds-textColor-secondary);line-height:var(--ds-lineHeight-large)}.ds-checkbox{display:inline-flex;align-self:flex-start;align-items:center;flex-direction:row;flex-wrap:nowrap;text-wrap:wrap;word-wrap:break-word;word-break:break-all;white-space:normal;position:relative;cursor:pointer;user-select:none;width:auto;padding:var(--ds-spacing-xSmall)}.ds-checkbox--no-margin .ds-checkbox__input{margin-right:0}.ds-checkbox--disabled{color:var(--ds-textColor-disabled-onLight)}.ds-checkbox__span--optional{color:var(--ds-textColor-secondary);font-size:var(--ds-fontSize-14)}.ds-checkbox:has(.ds-checkbox__input:disabled){cursor:not-allowed}.ds-checkbox__input{cursor:pointer;-webkit-appearance:none;appearance:none;background-color:var(--ds-bgColor-white);margin:0;display:grid;place-content:center;height:24px;width:24px;flex-shrink:0;margin-right:var(--ds-spacing-xSmall);border-width:var(--ds-borderWidth-thin);border-style:solid;border-color:var(--ds-palette-black-50);}.ds-checkbox__input:focus-visible{box-shadow:0 0 0 var(--ds-borderWidth-thin) var(--ds-borderColor-white);outline-color:var(--ds-borderColor-black);outline-offset:var(--ds-borderWidth-thin);outline-style:solid;outline-width:var(--ds-borderWidth-thin)}.ds-checkbox__input:hover,.ds-checkbox__input:active{border-color:var(--ds-borderColor-default)}.ds-checkbox__input:hover{background-color:var(--ds-bgColor-white-hover)}.ds-checkbox__input:active{background-color:var(--ds-bgColor-white-active)}.ds-checkbox__input:disabled{background-color:var(--ds-bgColor-disabled-onLight);border-color:var(--ds-borderColor-disabled-onLight)}@media (forced-colors: active){.ds-checkbox__input:disabled{border-color:GrayText}}.ds-checkbox__input:checked,.ds-checkbox__input:indeterminate{background-color:var(--ds-bgColor-primary);border-color:var(--ds-borderColor-transparent)}.ds-checkbox__input:checked:hover,.ds-checkbox__input:indeterminate:hover{background-color:var(--ds-bgColor-primary-hover)}.ds-checkbox__input:checked:active,.ds-checkbox__input:indeterminate:active{background-color:var(--ds-bgColor-primary-active)}.ds-checkbox__input:checked:disabled,.ds-checkbox__input:indeterminate:disabled{background-color:var(--ds-bgColor-disabled-onLight)}.ds-checkbox__input:user-invalid,.ds-checkbox__input--invalid,.ds-checkbox__input--invalid:checked,.ds-checkbox__input--invalid:indeterminate{border-color:var(--ds-borderColor-danger)}.ds-checkbox__input:disabled{cursor:not-allowed;color:var(--ds-textColor-disabled-onLight)}.ds-checkbox__input::before{content:\"\";display:block;height:1em;width:1em;background-size:contain;background-repeat:no-repeat;background-position:center}.ds-checkbox__input:checked::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:checked:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23999999' /></svg>\")}.ds-checkbox__input:indeterminate::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:indeterminate:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23999999' /></svg>\")}.ds-checkbox-error{display:flex}.ds-checkbox-error--visible{padding-top:var(--ds-spacing-3xSmall);padding-left:var(--ds-spacing-xSmall)}";
8
- const DsCheckboxStyle0 = dsCheckboxCss;
8
+ const dsCheckboxCss = ":root{--ds-breakpoint-xSmall:20rem;--ds-breakpoint-small:30rem;--ds-breakpoint-medium:60rem;--ds-breakpoint-large:75rem;--ds-breakpoint-xLarge:90rem}.ds-checkbox-fieldset{display:inline-flex;flex-direction:column;border:none;padding:0;margin:0;gap:var(--ds-spacing-3xSmall)}.ds-checkbox-fieldset__legend{padding-inline:0;font-size:var(--ds-fontSize-16);font-weight:var(--ds-fontWeight-semibold);letter-spacing:var(--ds-letterSpacing-wide);line-height:var(--ds-lineHeight-large)}.ds-checkbox-fieldset__assistive-text{display:inline;font-size:var(--ds-fontSize-14);color:var(--ds-palette-black-70);line-height:var(--ds-lineHeight-large)}.ds-checkbox{display:inline-flex;align-self:flex-start;align-items:flex-start;flex-flow:row nowrap;text-wrap:wrap;word-wrap:break-word;white-space:normal;position:relative;cursor:pointer;user-select:none;width:auto;padding:var(--ds-spacing-xSmall)}.ds-checkbox__input{cursor:pointer;appearance:none;background-color:var(--ds-palette-white);margin:0;display:grid;place-content:center;height:24px;width:24px;flex-shrink:0;margin-right:var(--ds-spacing-xSmall);border-width:var(--ds-borderWidth-thin);border-style:solid;border-color:var(--ds-palette-black-50);}.ds-checkbox__input:focus-visible{box-shadow:0 0 0 var(--ds-borderWidth-thin) var(--ds-palette-white);outline:var(--ds-borderWidth-thin) solid var(--ds-palette-black-95);outline-offset:calc(var(--ds-borderWidth-thin) * 1)}.ds-checkbox__input:hover,.ds-checkbox__input:active{border-color:var(--ds-palette-black-50)}.ds-checkbox__input:hover{background-color:var(--ds-palette-black-10)}.ds-checkbox__input:active{background-color:var(--ds-palette-black-20)}.ds-checkbox__input:disabled{cursor:not-allowed;color:var(--ds-palette-black-40);background-color:var(--ds-overlay-black-10);border-color:var(--ds-overlay-black-15)}@media (forced-colors: active){.ds-checkbox__input:disabled{border-color:GrayText}}.ds-checkbox__input:user-invalid,.ds-checkbox__input--invalid,.ds-checkbox__input--invalid:checked,.ds-checkbox__input--invalid:indeterminate{border-color:var(--ds-palette-red-50)}.ds-checkbox__input:checked,.ds-checkbox__input:indeterminate{background-color:var(--ds-palette-mainBlue-70);border-color:var(--ds-overlay-black-00)}.ds-checkbox__input:checked:hover,.ds-checkbox__input:indeterminate:hover{background-color:var(--ds-palette-mainBlue-80)}.ds-checkbox__input:checked:active,.ds-checkbox__input:indeterminate:active{background-color:var(--ds-palette-mainBlue-90)}.ds-checkbox__input:checked:disabled,.ds-checkbox__input:indeterminate:disabled{background-color:var(--ds-overlay-black-10)}.ds-checkbox__input::before{content:\"\";display:block;height:1em;width:1em;background-size:contain;background-repeat:no-repeat;background-position:center}.ds-checkbox__input:checked::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:indeterminate::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23ffffff' /></svg>\")}.ds-checkbox__input:checked:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='16' height='13' viewBox='0 0 16 13' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' clip-rule='evenodd' d='M5.99997 7.87871L13.606 0.272705L15.7273 2.39403L5.99997 12.1214L0.272644 6.39402L2.39396 4.27271L5.99997 7.87871Z' fill='%23999999' /></svg>\")}.ds-checkbox__input:indeterminate:disabled::before{background-image:url(\"data:image/svg+xml;charset=utf-8,<svg width='14' height='4' viewBox='0 0 14 4' xmlns='http://www.w3.org/2000/svg'><rect width='13.3333' height='3' transform='matrix(1 0 0 -1 0.333313 3.5)' fill='%23999999' /></svg>\")}.ds-checkbox--no-margin .ds-checkbox__input{margin-right:0}.ds-checkbox--disabled{color:var(--ds-palette-black-40)}.ds-checkbox__span--optional{color:var(--ds-palette-black-70);font-size:var(--ds-fontSize-14)}.ds-checkbox:has(.ds-checkbox__input:disabled){cursor:not-allowed}.ds-checkbox-error{display:flex}.ds-checkbox-error--visible{padding-top:var(--ds-spacing-3xSmall);padding-left:var(--ds-spacing-xSmall)}";
9
9
 
10
10
  const checkboxIdGenerator = idGenerator('ds-checkbox');
11
11
  const DsCheckbox = class {
12
12
  constructor(hostRef) {
13
13
  registerInstance(this, hostRef);
14
- this.dsCheckboxInput = createEvent(this, "dsCheckboxInput", 7);
14
+ this.dsChange = createEvent(this, "dsChange");
15
15
  if (hostRef.$hostElement$["s-ei"]) {
16
16
  this.internals = hostRef.$hostElement$["s-ei"];
17
17
  }
@@ -20,97 +20,105 @@ const DsCheckbox = class {
20
20
  hostRef.$hostElement$["s-ei"] = this.internals;
21
21
  }
22
22
  }
23
+ checkboxGroup = null;
23
24
  inputElem;
24
25
  labelId;
25
26
  inputValidityId;
26
27
  assistiveTextId;
27
28
  inheritedAttributes = {};
28
- initialChecked;
29
29
  labelClicked = false;
30
30
  get el() { return getElement(this); }
31
31
  internals;
32
- dsCheckboxInput;
33
- identifier = checkboxIdGenerator.next().value;
34
- checked = false;
35
- legend;
36
- assistiveText;
37
- text;
38
- indeterminate = false;
39
- disabled = false;
40
- errorText = '';
41
- errorsDisabled = false;
42
- required = false;
43
- optional = false;
44
- optionalText;
45
- ariaLabel;
46
- value = this.checked.toString();
32
+ dsId = checkboxIdGenerator.next().value;
33
+ dsChecked = false;
34
+ dsLegend;
35
+ dsAssistiveText;
36
+ dsText;
37
+ dsIndeterminate = false;
38
+ dsDisabled = false;
39
+ dsErrorText = '';
40
+ dsErrorsDisabled = false;
41
+ dsRequired = false;
42
+ dsOptional = false;
43
+ dsOptionalText;
44
+ dsAriaLabel;
45
+ dsChange;
46
+ invalid = !!this.dsErrorText;
47
+ initialChecked = this.dsChecked;
47
48
  validationMessage;
48
49
  setIds = () => {
49
- this.labelId = `${this.identifier}-label`;
50
- this.inputValidityId = `${this.identifier}-validity`;
51
- this.assistiveTextId = `${this.identifier}-assistive-text`;
50
+ this.labelId = `${this.dsId}-label`;
51
+ this.inputValidityId = `${this.dsId}-validity`;
52
+ this.assistiveTextId = `${this.dsId}-assistive-text`;
52
53
  };
53
- getValidationMessage = () => (!this.errorsDisabled ? this.errorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
54
+ getValidationMessage = () => (!this.dsErrorsDisabled ? this.dsErrorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
54
55
  getLegendText = () => {
55
- if (this.required) {
56
- return getRequiredText(this.legend);
56
+ if (this.dsRequired) {
57
+ return getRequiredText(this.dsLegend);
57
58
  }
58
- if (this.optional) {
59
- return getOptionalText(this.legend, this.optionalText);
59
+ if (this.dsOptional) {
60
+ return getOptionalText(this.dsLegend, this.dsOptionalText);
60
61
  }
61
- return this.legend;
62
+ return this.dsLegend;
62
63
  };
63
64
  getCheckboxText = () => {
64
- if (this.legend) {
65
- return this.text;
65
+ if (this.dsLegend) {
66
+ return this.dsText;
66
67
  }
67
- if (this.required) {
68
- return getRequiredText(this.text);
68
+ if (this.dsRequired) {
69
+ return getRequiredText(this.dsText);
69
70
  }
70
- if (this.optional) {
71
- return getOptionalText(this.text, this.optionalText);
71
+ if (this.dsOptional) {
72
+ return getOptionalText(this.dsText, this.dsOptionalText);
72
73
  }
73
- return this.text;
74
- };
75
- getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
76
- restoreInitialState = () => {
77
- this.checked = this.initialChecked;
78
- this.value = this.checked.toString();
79
- this.internals?.setValidity({});
80
- this.internals?.setFormValue(this.value);
81
- };
82
- setInitialState = () => {
83
- this.initialChecked = this.checked;
84
- this.value = this.checked.toString();
85
- this.internals?.setFormValue(this.value);
74
+ return this.dsText;
86
75
  };
76
+ getAriaDescribedBy = () => [Boolean(this.dsAssistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
87
77
  formResetCallback() {
88
- this.restoreInitialState();
78
+ this.dsChecked = this.initialChecked;
79
+ this.internals?.setValidity({});
80
+ this.internals?.setFormValue(this.dsChecked.toString());
81
+ }
82
+ connectedCallback() {
83
+ this.checkboxGroup = this.el.closest('ds-checkbox-group');
84
+ if (this.checkboxGroup) {
85
+ this.invalid = !!this.checkboxGroup.dsErrorText;
86
+ this.checkboxGroup.addEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
87
+ }
88
+ }
89
+ disconnectedCallback() {
90
+ if (this.checkboxGroup) {
91
+ this.checkboxGroup.removeEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
92
+ }
93
+ this.checkboxGroup = null;
89
94
  }
95
+ updateInvalidState = (e) => {
96
+ this.invalid = e.detail;
97
+ };
90
98
  componentWillLoad() {
91
- this.setInitialState();
92
99
  this.setIds();
93
100
  this.inheritedAttributes = {
94
101
  ...inheritAriaAttributes(this.el, ['aria-label', 'aria-describedby', 'aria-hidden', 'aria-invalid']),
95
102
  ...inheritAttributes(this, this.el),
96
103
  };
97
- if (isValidation('server') || this.errorText) {
104
+ if (isValidation('server') || this.dsErrorText) {
98
105
  this.validationMessage = this.getValidationMessage();
99
106
  }
100
107
  }
108
+ dsCheckedObserver(isChecked) {
109
+ this.dsChange.emit(isChecked);
110
+ }
101
111
  handleInput = (e) => {
102
112
  const target = e.target;
103
- this.checked = target.checked;
104
- this.value = target.checked.toString();
105
- this.internals?.setFormValue(this.value);
106
- this.dsCheckboxInput.emit({ id: this.identifier, checked: target.checked });
113
+ this.dsChecked = target.checked;
114
+ this.internals?.setFormValue(target.checked.toString());
107
115
  if (isValidation('client') && this.validationMessage) {
108
116
  this.validationMessage = this.getValidationMessage();
109
117
  }
110
118
  };
111
119
  handleKeyUp = (event) => {
112
120
  if (event.key === 'Enter') {
113
- this.inputElem.dispatchEvent(new Event('input'));
121
+ this.inputElem.click();
114
122
  }
115
123
  };
116
124
  handleBlur = () => {
@@ -127,32 +135,35 @@ const DsCheckbox = class {
127
135
  };
128
136
  renderCheckbox() {
129
137
  const classes = classNames('ds-checkbox', {
130
- 'ds-checkbox--disabled': this.disabled,
131
- 'ds-checkbox--no-margin': Boolean(!this.text),
138
+ 'ds-checkbox--disabled': this.dsDisabled,
139
+ 'ds-checkbox--no-margin': Boolean(!this.dsText),
132
140
  });
133
141
  const inputClasses = classNames('ds-checkbox__input', {
134
- 'ds-checkbox__input--invalid': Boolean(this.errorText),
142
+ 'ds-checkbox__input--invalid': Boolean(this.dsErrorText) || this.invalid,
135
143
  });
136
144
  const errorClasses = classNames('ds-checkbox-error', {
137
145
  'ds-checkbox-error--visible': Boolean(this.validationMessage),
138
146
  });
139
147
  const ariaDescribedBy = this.getAriaDescribedBy();
140
- return (h(Fragment, null, h("div", null, h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, h("input", { ref: inputElem => (this.inputElem = inputElem), type: "checkbox", class: inputClasses, checked: this.checked, indeterminate: this.indeterminate, onInput: this.handleInput, onKeyUp: this.handleKeyUp, onBlur: this.handleBlur, value: this.value, disabled: this.disabled, required: this.required, id: this.identifier, "aria-describedby": ariaDescribedBy, "aria-label": getAriaLabel(this.getCheckboxText(), this.ariaLabel), "aria-invalid": this.errorText ? true : undefined, ...this.inheritedAttributes }), this.getCheckboxText())), !this.errorsDisabled && (h("div", { class: errorClasses }, h("ds-input-validity", { id: this.inputValidityId, text: this.validationMessage, type: "error", role: "alert" })))));
148
+ return (h(Fragment, null, h("div", null, h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, h("input", { ref: inputElem => (this.inputElem = inputElem), type: "checkbox", class: inputClasses, checked: this.dsChecked, indeterminate: this.dsIndeterminate, onInput: this.handleInput, onKeyUp: this.handleKeyUp, onBlur: this.handleBlur, value: this.dsChecked.toString(), disabled: this.dsDisabled, required: this.dsRequired, id: this.dsId, "aria-describedby": ariaDescribedBy, "aria-label": this.dsAriaLabel, "aria-invalid": this.dsErrorText ? true : undefined, ...this.inheritedAttributes }), this.getCheckboxText())), !this.dsErrorsDisabled && (h("div", { class: errorClasses }, h("ds-input-validity", { id: this.inputValidityId, dsText: this.validationMessage, dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
141
149
  }
142
150
  renderFieldset() {
143
151
  const fieldsetClasses = classNames('ds-checkbox-fieldset');
144
152
  const legendClasses = classNames('ds-checkbox-fieldset__legend');
145
153
  const assistiveTextClasses = classNames('ds-checkbox-fieldset__assistive-text');
146
- return (h("fieldset", { class: fieldsetClasses }, h("legend", { class: legendClasses }, this.getLegendText()), this.assistiveText && (h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.assistiveText)), this.renderCheckbox()));
154
+ return (h("fieldset", { class: fieldsetClasses }, h("legend", { class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.renderCheckbox()));
147
155
  }
148
156
  render() {
149
- if (this.legend) {
157
+ if (this.dsLegend) {
150
158
  return this.renderFieldset();
151
159
  }
152
160
  return this.renderCheckbox();
153
161
  }
154
162
  static get formAssociated() { return true; }
163
+ static get watchers() { return {
164
+ "dsChecked": ["dsCheckedObserver"]
165
+ }; }
155
166
  };
156
- DsCheckbox.style = DsCheckboxStyle0;
167
+ DsCheckbox.style = dsCheckboxCss;
157
168
 
158
169
  export { DsCheckbox as ds_checkbox };