@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,21 +1,30 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var index = require('./index-Mjp9Y-Sw.js');
4
+ var index$1 = require('./index-Bp6Dd2i1.js');
5
+ var attributes = require('./attributes-BMbXzbwU.js');
6
+ var utils = require('./utils-BjZTECpy.js');
7
+ var controlUtils = require('./controlUtils-ofqiQxRF.js');
8
+ require('./index-DwLFyR5p.js');
4
9
 
5
- const index = require('./index-bf84b124.js');
6
- const index$1 = require('./index-5b0b9d4c.js');
7
- const utils = require('./utils-3412cbed.js');
8
-
9
- 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}";
10
- const DsCheckboxGroupStyle0 = dsCheckboxGroupCss;
10
+ 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)}";
11
11
 
12
12
  const fieldsetIdGenerator = utils.idGenerator('ds-checkbox-group');
13
13
  const DsCheckboxGroup = class {
14
14
  constructor(hostRef) {
15
15
  index.registerInstance(this, hostRef);
16
- this.dsCheckboxGroupChange = index.createEvent(this, "dsCheckboxGroupChange", 7);
17
- this.dsCheckboxGroupIndeterminateChildChange = index.createEvent(this, "dsCheckboxGroupIndeterminateChildChange", 7);
16
+ this.dsCheckboxGroupChange = index.createEvent(this, "dsCheckboxGroupChange");
17
+ this.dsCheckboxGroupIndeterminateChildChange = index.createEvent(this, "dsCheckboxGroupIndeterminateChildChange");
18
+ this.dsCheckboxGroupInvalidStateChange = index.createEvent(this, "dsCheckboxGroupInvalidStateChange");
19
+ if (hostRef.$hostElement$["s-ei"]) {
20
+ this.internals = hostRef.$hostElement$["s-ei"];
21
+ }
22
+ else {
23
+ this.internals = hostRef.$hostElement$.attachInternals();
24
+ hostRef.$hostElement$["s-ei"] = this.internals;
25
+ }
18
26
  }
27
+ checkboxElem;
19
28
  fieldsetId = fieldsetIdGenerator.next().value;
20
29
  checkboxId = `${this.fieldsetId}-checkbox`;
21
30
  errorTextId = `${this.fieldsetId}-error`;
@@ -23,23 +32,45 @@ const DsCheckboxGroup = class {
23
32
  nestedId = `${this.fieldsetId}-nested`;
24
33
  inheritedAttributes = {};
25
34
  get el() { return index.getElement(this); }
35
+ internals;
26
36
  dsCheckboxGroupChange;
27
37
  dsCheckboxGroupIndeterminateChildChange;
28
- legend;
29
- assistiveText;
30
- direction = 'vertical';
31
- errorText = '';
32
- text = '';
33
- checked = false;
34
- disabled = false;
35
- childElementsCount = 0;
38
+ dsCheckboxGroupInvalidStateChange;
39
+ dsLegend;
40
+ dsAssistiveText;
41
+ dsDirection = 'vertical';
42
+ dsErrorText = '';
43
+ dsText = '';
44
+ dsChecked = false;
45
+ dsDisabled = false;
46
+ dsRequired = false;
47
+ dsAllRequired = false;
48
+ dsOptional = false;
49
+ dsOptionalText;
50
+ childElementsCount = 1;
36
51
  checkedChildElementCount = 0;
37
52
  isIndeterminate = false;
38
53
  indeterminateChildCheckboxCount = 0;
54
+ showInternalsValidationMessage = false;
39
55
  elementIs = (localName) => (element) => element.localName === localName;
40
56
  elementIsCheckbox = this.elementIs('ds-checkbox');
41
57
  elementIsCheckboxGroup = this.elementIs('ds-checkbox-group');
42
- getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.errorText) && this.errorTextId].filter(Boolean).join(' ');
58
+ getLegendText = () => {
59
+ if (this.dsRequired || this.dsAllRequired) {
60
+ return controlUtils.getRequiredText(this.dsLegend);
61
+ }
62
+ if (this.dsOptional) {
63
+ return controlUtils.getOptionalText(this.dsLegend, this.dsOptionalText);
64
+ }
65
+ return this.dsLegend;
66
+ };
67
+ getAriaDescribedBy = () => [
68
+ !!this.dsAssistiveText && this.assistiveTextId,
69
+ (!!this.dsErrorText || (this.showInternalsValidationMessage && !!this.internals?.validationMessage)) && this.errorTextId,
70
+ ]
71
+ .filter(Boolean)
72
+ .join(' ');
73
+ getValidationMessage = () => this.dsErrorText || (this.showInternalsValidationMessage ? this.internals?.validationMessage : '');
43
74
  getChildElements = () => {
44
75
  const slot = this.el.shadowRoot.querySelector('slot');
45
76
  return (slot?.assignedElements() || []);
@@ -56,7 +87,7 @@ const DsCheckboxGroup = class {
56
87
  updateChildElementsChecked = (checked) => {
57
88
  this.checkedChildElementCount = checked ? this.childElementsCount : 0;
58
89
  this.updateChildElements((element) => {
59
- element.checked = checked;
90
+ element.dsChecked = checked;
60
91
  if (this.elementIsCheckboxGroup(element)) {
61
92
  (async () => {
62
93
  await element.setChecked(checked);
@@ -69,7 +100,7 @@ const DsCheckboxGroup = class {
69
100
  }
70
101
  watchCheckboxDisabledChange(newValue) {
71
102
  this.updateChildElements((element) => {
72
- element.disabled = newValue;
103
+ element.dsDisabled = newValue;
73
104
  });
74
105
  }
75
106
  watchCheckedChange(newValue) {
@@ -78,77 +109,106 @@ const DsCheckboxGroup = class {
78
109
  watchIndeterminateChange(newValue) {
79
110
  this.dsCheckboxGroupIndeterminateChildChange.emit({ id: this.fieldsetId, indeterminate: newValue });
80
111
  }
112
+ errorTextObserver(errorText) {
113
+ this.dsCheckboxGroupInvalidStateChange.emit(!!errorText);
114
+ }
81
115
  listenIndeterminateChildChange(event) {
82
116
  this.indeterminateChildCheckboxCount = event.detail.indeterminate ? this.indeterminateChildCheckboxCount + 1 : this.indeterminateChildCheckboxCount - 1;
83
117
  }
84
- watchCheckedChildElementCountChange(newValue, oldValue) {
85
- this.isIndeterminate =
86
- this.checkedChildElementCount !== this.childElementsCount && this.checkedChildElementCount < this.childElementsCount && this.checkedChildElementCount > 0;
87
- if (newValue === this.childElementsCount && newValue > oldValue) {
88
- this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
118
+ watchCheckedChildElementCountChange() {
119
+ this.isIndeterminate = this.checkedChildElementCount > 0 && this.checkedChildElementCount < this.childElementsCount;
120
+ if (this.dsRequired && this.checkedChildElementCount === 0) {
121
+ this.internals?.setValidity({ valueMissing: true }, controlUtils.atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
89
122
  }
90
- else if (oldValue === this.childElementsCount && newValue < oldValue) {
91
- this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: false });
123
+ else if (this.dsAllRequired && this.checkedChildElementCount !== this.childElementsCount) {
124
+ this.internals?.setValidity({ valueMissing: true }, controlUtils.allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
125
+ }
126
+ else {
127
+ this.internals?.setValidity({ valueMissing: false });
92
128
  }
93
129
  }
94
- updateCheckedChildElementCount = (event) => {
95
- if (event.detail.checked) {
96
- this.checkedChildElementCount = this.checkedChildElementCount === this.childElementsCount ? this.checkedChildElementCount : this.checkedChildElementCount + 1;
130
+ updateCheckedChildElementCount = (checked) => {
131
+ if (checked) {
132
+ this.checkedChildElementCount = Math.min(this.childElementsCount, this.checkedChildElementCount + 1);
97
133
  }
98
134
  else {
99
- this.checkedChildElementCount = this.checkedChildElementCount === 0 ? 0 : this.checkedChildElementCount - 1;
135
+ this.checkedChildElementCount = Math.max(0, this.checkedChildElementCount - 1);
100
136
  }
101
137
  };
102
138
  listenCheckboxChange(event) {
103
- if (event.detail.id === this.checkboxId) {
104
- this.updateChildElementsChecked(event.detail.checked);
139
+ if (!this.showInternalsValidationMessage) {
140
+ this.showInternalsValidationMessage = true;
141
+ }
142
+ if (event.target === this.el) {
143
+ this.updateChildElementsChecked(this.checkboxElem.dsChecked);
144
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: this.checkboxElem.dsChecked });
105
145
  return;
106
146
  }
107
- if (this.getChildCheckboxElements().includes(event.target)) {
108
- this.updateCheckedChildElementCount(event);
147
+ const target = event.target;
148
+ if (this.getChildCheckboxElements().includes(target)) {
149
+ const previousCheckedChildElementCount = this.checkedChildElementCount;
150
+ this.updateCheckedChildElementCount(target.dsChecked);
151
+ if (this.checkedChildElementCount === this.childElementsCount && this.checkedChildElementCount > previousCheckedChildElementCount) {
152
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: true });
153
+ }
154
+ else if (previousCheckedChildElementCount === this.childElementsCount && this.checkedChildElementCount < previousCheckedChildElementCount) {
155
+ this.dsCheckboxGroupChange.emit({ id: this.fieldsetId, checked: false });
156
+ }
109
157
  }
110
158
  }
111
159
  listenCheckboxGroupChange(event) {
112
160
  if (this.getChildElements().includes(event.target)) {
113
- this.updateCheckedChildElementCount(event);
161
+ event.stopPropagation();
162
+ this.updateCheckedChildElementCount(event.detail.checked);
114
163
  }
115
164
  }
116
- setChildElementCount = () => {
117
- this.childElementsCount = this.getChildElements().length;
118
- };
165
+ formResetCallback() {
166
+ this.internals?.setValidity({});
167
+ }
119
168
  componentWillLoad() {
120
- this.inheritedAttributes = utils.inheritAriaAttributes(this.el, ['aria-labelledby']);
169
+ this.inheritedAttributes = attributes.inheritAriaAttributes(this.el, ['aria-labelledby']);
121
170
  }
122
171
  componentDidLoad() {
123
- this.setChildElementCount();
172
+ this.childElementsCount = this.getChildElements().length;
124
173
  this.updateChildCheckboxes(element => {
125
- element.setAttribute('data-errors-disabled', 'true');
174
+ element.setAttribute('ds-errors-disabled', 'true');
126
175
  });
176
+ if (this.dsRequired) {
177
+ this.internals?.setValidity({ valueMissing: true }, controlUtils.atLeastOneOption(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
178
+ }
179
+ else if (this.dsAllRequired) {
180
+ this.internals?.setValidity({ valueMissing: true }, controlUtils.allOptions(), this.getChildCheckboxElements()?.[0].shadowRoot.querySelector('input'));
181
+ }
127
182
  }
128
183
  componentDidUpdate() {
129
- this.setChildElementCount();
184
+ const childElementCount = this.getChildElements().length;
185
+ if (this.childElementsCount !== childElementCount) {
186
+ this.childElementsCount = childElementCount;
187
+ }
130
188
  }
131
189
  render() {
132
190
  const classes = index$1.classNames('ds-checkbox-group', {
133
- 'ds-checkbox-group--horizontal': this.direction === 'horizontal',
191
+ 'ds-checkbox-group--horizontal': this.dsDirection === 'horizontal',
134
192
  });
135
193
  const legendClasses = index$1.classNames('ds-checkbox-group__legend');
136
194
  const assistiveTextClasses = index$1.classNames('ds-checkbox-group__assistive-text');
137
195
  const errorClasses = index$1.classNames('ds-checkbox-group__error', {
138
- 'ds-checkbox-group__error--visible': Boolean(this.errorText),
196
+ 'ds-checkbox-group__error--visible': Boolean(this.dsErrorText),
139
197
  });
140
198
  const nestedClasses = index$1.classNames('ds-checkbox-group', 'ds-checkbox-group--inset');
141
199
  const checkboxesClasses = index$1.classNames('ds-checkbox-group__checkboxes');
142
200
  const ariaDescribedBy = this.getAriaDescribedBy();
143
- return (index.h("fieldset", { key: '1029763130b4d2d138679c9f84ec72c0231fcc83', id: this.fieldsetId, class: classes, "aria-describedby": ariaDescribedBy, ...this.inheritedAttributes }, this.legend && index.h("legend", { key: 'a9be37aab510d5e402841c8bbda64190548bc1ea', class: legendClasses }, this.legend), this.assistiveText && (index.h("small", { key: '0ae42c2b46e52dad0570ad120180e662db43f2fa', class: assistiveTextClasses, id: this.assistiveTextId }, this.assistiveText)), this.text ? (index.h(index.Fragment, null, index.h("ds-checkbox", { id: this.checkboxId, text: this.text, checked: this.checkedChildElementCount === this.childElementsCount, disabled: this.disabled, indeterminate: this.indeterminateChildCheckboxCount > 0 || this.isIndeterminate }), index.h("fieldset", { id: this.nestedId, "aria-labelledby": this.checkboxId, class: nestedClasses }, index.h("slot", null)))) : (index.h("div", { class: checkboxesClasses }, index.h("slot", null))), index.h("div", { key: '3ea5bb7991a99c676cb50a24d1a679b6f68c96bf', class: errorClasses }, index.h("ds-input-validity", { key: '8d5ca5e80b2a5f985e09bf7039538a5a13278e8e', id: this.errorTextId, text: this.errorText, type: "error" }))));
201
+ return (index.h("fieldset", { key: '98ff7c5dd5c36c163ed1dfb177d5c0b28b93971a', id: this.fieldsetId, class: classes, "aria-describedby": ariaDescribedBy, ...this.inheritedAttributes }, this.dsLegend && index.h("legend", { key: '22274e3c85262fd08f69a9aa548d2910eaf30ce2', class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (index.h("small", { key: '4566b9d66b0be262548ddecd11f6eda5acc6d399', class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.dsText ? (index.h(index.Fragment, null, index.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 }), index.h("fieldset", { id: this.nestedId, "aria-labelledby": this.checkboxId, class: nestedClasses }, index.h("slot", null)))) : (index.h("div", { class: checkboxesClasses }, index.h("slot", null))), (!!this.dsErrorText || this.dsRequired || this.dsAllRequired) && (index.h("div", { key: 'd0a2dbc9d46967de609096d9a398b040f5228807', class: errorClasses }, index.h("ds-input-validity", { key: '409b5d8fbd59b26245cb828146f28eec3d010aaa', id: this.errorTextId, dsText: this.getValidationMessage(), dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
144
202
  }
203
+ static get formAssociated() { return true; }
145
204
  static get watchers() { return {
146
- "disabled": ["watchCheckboxDisabledChange"],
147
- "checked": ["watchCheckedChange"],
205
+ "dsDisabled": ["watchCheckboxDisabledChange"],
206
+ "dsChecked": ["watchCheckedChange"],
148
207
  "isIndeterminate": ["watchIndeterminateChange"],
208
+ "dsErrorText": ["errorTextObserver"],
149
209
  "checkedChildElementCount": ["watchCheckedChildElementCountChange"]
150
210
  }; }
151
211
  };
152
- DsCheckboxGroup.style = DsCheckboxGroupStyle0;
212
+ DsCheckboxGroup.style = dsCheckboxGroupCss;
153
213
 
154
214
  exports.ds_checkbox_group = DsCheckboxGroup;
@@ -1,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var index = require('./index-Mjp9Y-Sw.js');
4
+ var index$2 = require('./index-Bp6Dd2i1.js');
5
+ var attributes = require('./attributes-BMbXzbwU.js');
6
+ var controlUtils = require('./controlUtils-ofqiQxRF.js');
7
+ var index$1 = require('./index-DwLFyR5p.js');
8
+ var utils = require('./utils-BjZTECpy.js');
4
9
 
5
- const index = require('./index-bf84b124.js');
6
- const index$1 = require('./index-5b0b9d4c.js');
7
- const utils = require('./utils-3412cbed.js');
8
- const controlUtils = require('./controlUtils-041de0fd.js');
9
- const store = require('./store-9bd20f3c.js');
10
-
11
- 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)}";
12
- const DsCheckboxStyle0 = dsCheckboxCss;
10
+ 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)}";
13
11
 
14
12
  const checkboxIdGenerator = utils.idGenerator('ds-checkbox');
15
13
  const DsCheckbox = class {
16
14
  constructor(hostRef) {
17
15
  index.registerInstance(this, hostRef);
18
- this.dsCheckboxInput = index.createEvent(this, "dsCheckboxInput", 7);
16
+ this.dsChange = index.createEvent(this, "dsChange");
19
17
  if (hostRef.$hostElement$["s-ei"]) {
20
18
  this.internals = hostRef.$hostElement$["s-ei"];
21
19
  }
@@ -24,101 +22,109 @@ const DsCheckbox = class {
24
22
  hostRef.$hostElement$["s-ei"] = this.internals;
25
23
  }
26
24
  }
25
+ checkboxGroup = null;
27
26
  inputElem;
28
27
  labelId;
29
28
  inputValidityId;
30
29
  assistiveTextId;
31
30
  inheritedAttributes = {};
32
- initialChecked;
33
31
  labelClicked = false;
34
32
  get el() { return index.getElement(this); }
35
33
  internals;
36
- dsCheckboxInput;
37
- identifier = checkboxIdGenerator.next().value;
38
- checked = false;
39
- legend;
40
- assistiveText;
41
- text;
42
- indeterminate = false;
43
- disabled = false;
44
- errorText = '';
45
- errorsDisabled = false;
46
- required = false;
47
- optional = false;
48
- optionalText;
49
- ariaLabel;
50
- value = this.checked.toString();
34
+ dsId = checkboxIdGenerator.next().value;
35
+ dsChecked = false;
36
+ dsLegend;
37
+ dsAssistiveText;
38
+ dsText;
39
+ dsIndeterminate = false;
40
+ dsDisabled = false;
41
+ dsErrorText = '';
42
+ dsErrorsDisabled = false;
43
+ dsRequired = false;
44
+ dsOptional = false;
45
+ dsOptionalText;
46
+ dsAriaLabel;
47
+ dsChange;
48
+ invalid = !!this.dsErrorText;
49
+ initialChecked = this.dsChecked;
51
50
  validationMessage;
52
51
  setIds = () => {
53
- this.labelId = `${this.identifier}-label`;
54
- this.inputValidityId = `${this.identifier}-validity`;
55
- this.assistiveTextId = `${this.identifier}-assistive-text`;
52
+ this.labelId = `${this.dsId}-label`;
53
+ this.inputValidityId = `${this.dsId}-validity`;
54
+ this.assistiveTextId = `${this.dsId}-assistive-text`;
56
55
  };
57
- getValidationMessage = () => (!this.errorsDisabled ? this.errorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
56
+ getValidationMessage = () => (!this.dsErrorsDisabled ? this.dsErrorText || this.internals?.validationMessage || this.inputElem?.validationMessage : '');
58
57
  getLegendText = () => {
59
- if (this.required) {
60
- return controlUtils.getRequiredText(this.legend);
58
+ if (this.dsRequired) {
59
+ return controlUtils.getRequiredText(this.dsLegend);
61
60
  }
62
- if (this.optional) {
63
- return controlUtils.getOptionalText(this.legend, this.optionalText);
61
+ if (this.dsOptional) {
62
+ return controlUtils.getOptionalText(this.dsLegend, this.dsOptionalText);
64
63
  }
65
- return this.legend;
64
+ return this.dsLegend;
66
65
  };
67
66
  getCheckboxText = () => {
68
- if (this.legend) {
69
- return this.text;
67
+ if (this.dsLegend) {
68
+ return this.dsText;
70
69
  }
71
- if (this.required) {
72
- return controlUtils.getRequiredText(this.text);
70
+ if (this.dsRequired) {
71
+ return controlUtils.getRequiredText(this.dsText);
73
72
  }
74
- if (this.optional) {
75
- return controlUtils.getOptionalText(this.text, this.optionalText);
73
+ if (this.dsOptional) {
74
+ return controlUtils.getOptionalText(this.dsText, this.dsOptionalText);
76
75
  }
77
- return this.text;
78
- };
79
- getAriaDescribedBy = () => [Boolean(this.assistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
80
- restoreInitialState = () => {
81
- this.checked = this.initialChecked;
82
- this.value = this.checked.toString();
83
- this.internals?.setValidity({});
84
- this.internals?.setFormValue(this.value);
85
- };
86
- setInitialState = () => {
87
- this.initialChecked = this.checked;
88
- this.value = this.checked.toString();
89
- this.internals?.setFormValue(this.value);
76
+ return this.dsText;
90
77
  };
78
+ getAriaDescribedBy = () => [Boolean(this.dsAssistiveText) && this.assistiveTextId, Boolean(this.getValidationMessage()) && this.inputValidityId].filter(Boolean).join(' ');
91
79
  formResetCallback() {
92
- this.restoreInitialState();
80
+ this.dsChecked = this.initialChecked;
81
+ this.internals?.setValidity({});
82
+ this.internals?.setFormValue(this.dsChecked.toString());
93
83
  }
84
+ connectedCallback() {
85
+ this.checkboxGroup = this.el.closest('ds-checkbox-group');
86
+ if (this.checkboxGroup) {
87
+ this.invalid = !!this.checkboxGroup.dsErrorText;
88
+ this.checkboxGroup.addEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
89
+ }
90
+ }
91
+ disconnectedCallback() {
92
+ if (this.checkboxGroup) {
93
+ this.checkboxGroup.removeEventListener('dsCheckboxGroupInvalidStateChange', this.updateInvalidState);
94
+ }
95
+ this.checkboxGroup = null;
96
+ }
97
+ updateInvalidState = (e) => {
98
+ this.invalid = e.detail;
99
+ };
94
100
  componentWillLoad() {
95
- this.setInitialState();
96
101
  this.setIds();
97
102
  this.inheritedAttributes = {
98
- ...utils.inheritAriaAttributes(this.el, ['aria-label', 'aria-describedby', 'aria-hidden', 'aria-invalid']),
99
- ...utils.inheritAttributes(this, this.el),
103
+ ...attributes.inheritAriaAttributes(this.el, ['aria-label', 'aria-describedby', 'aria-hidden', 'aria-invalid']),
104
+ ...attributes.inheritAttributes(this, this.el),
100
105
  };
101
- if (store.isValidation('server') || this.errorText) {
106
+ if (index$1.isValidation('server') || this.dsErrorText) {
102
107
  this.validationMessage = this.getValidationMessage();
103
108
  }
104
109
  }
110
+ dsCheckedObserver(isChecked) {
111
+ this.dsChange.emit(isChecked);
112
+ }
105
113
  handleInput = (e) => {
106
114
  const target = e.target;
107
- this.checked = target.checked;
108
- this.value = target.checked.toString();
109
- this.internals?.setFormValue(this.value);
110
- this.dsCheckboxInput.emit({ id: this.identifier, checked: target.checked });
111
- if (store.isValidation('client') && this.validationMessage) {
115
+ this.dsChecked = target.checked;
116
+ this.internals?.setFormValue(target.checked.toString());
117
+ if (index$1.isValidation('client') && this.validationMessage) {
112
118
  this.validationMessage = this.getValidationMessage();
113
119
  }
114
120
  };
115
121
  handleKeyUp = (event) => {
116
122
  if (event.key === 'Enter') {
117
- this.inputElem.dispatchEvent(new Event('input'));
123
+ this.inputElem.click();
118
124
  }
119
125
  };
120
126
  handleBlur = () => {
121
- if (store.isValidation('client') && !this.labelClicked) {
127
+ if (index$1.isValidation('client') && !this.labelClicked) {
122
128
  this.validationMessage = this.getValidationMessage();
123
129
  }
124
130
  this.labelClicked = false;
@@ -130,33 +136,36 @@ const DsCheckbox = class {
130
136
  this.labelClicked = false;
131
137
  };
132
138
  renderCheckbox() {
133
- const classes = index$1.classNames('ds-checkbox', {
134
- 'ds-checkbox--disabled': this.disabled,
135
- 'ds-checkbox--no-margin': Boolean(!this.text),
139
+ const classes = index$2.classNames('ds-checkbox', {
140
+ 'ds-checkbox--disabled': this.dsDisabled,
141
+ 'ds-checkbox--no-margin': Boolean(!this.dsText),
136
142
  });
137
- const inputClasses = index$1.classNames('ds-checkbox__input', {
138
- 'ds-checkbox__input--invalid': Boolean(this.errorText),
143
+ const inputClasses = index$2.classNames('ds-checkbox__input', {
144
+ 'ds-checkbox__input--invalid': Boolean(this.dsErrorText) || this.invalid,
139
145
  });
140
- const errorClasses = index$1.classNames('ds-checkbox-error', {
146
+ const errorClasses = index$2.classNames('ds-checkbox-error', {
141
147
  'ds-checkbox-error--visible': Boolean(this.validationMessage),
142
148
  });
143
149
  const ariaDescribedBy = this.getAriaDescribedBy();
144
- return (index.h(index.Fragment, null, index.h("div", null, index.h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, index.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": utils.getAriaLabel(this.getCheckboxText(), this.ariaLabel), "aria-invalid": this.errorText ? true : undefined, ...this.inheritedAttributes }), this.getCheckboxText())), !this.errorsDisabled && (index.h("div", { class: errorClasses }, index.h("ds-input-validity", { id: this.inputValidityId, text: this.validationMessage, type: "error", role: "alert" })))));
150
+ return (index.h(index.Fragment, null, index.h("div", null, index.h("label", { id: this.labelId, class: classes, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp }, index.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 && (index.h("div", { class: errorClasses }, index.h("ds-input-validity", { id: this.inputValidityId, dsText: this.validationMessage, dsType: "error", dsAriaLive: "polite", dsAriaAtomic: "true" })))));
145
151
  }
146
152
  renderFieldset() {
147
- const fieldsetClasses = index$1.classNames('ds-checkbox-fieldset');
148
- const legendClasses = index$1.classNames('ds-checkbox-fieldset__legend');
149
- const assistiveTextClasses = index$1.classNames('ds-checkbox-fieldset__assistive-text');
150
- return (index.h("fieldset", { class: fieldsetClasses }, index.h("legend", { class: legendClasses }, this.getLegendText()), this.assistiveText && (index.h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.assistiveText)), this.renderCheckbox()));
153
+ const fieldsetClasses = index$2.classNames('ds-checkbox-fieldset');
154
+ const legendClasses = index$2.classNames('ds-checkbox-fieldset__legend');
155
+ const assistiveTextClasses = index$2.classNames('ds-checkbox-fieldset__assistive-text');
156
+ return (index.h("fieldset", { class: fieldsetClasses }, index.h("legend", { class: legendClasses }, this.getLegendText()), this.dsAssistiveText && (index.h("small", { class: assistiveTextClasses, id: this.assistiveTextId }, this.dsAssistiveText)), this.renderCheckbox()));
151
157
  }
152
158
  render() {
153
- if (this.legend) {
159
+ if (this.dsLegend) {
154
160
  return this.renderFieldset();
155
161
  }
156
162
  return this.renderCheckbox();
157
163
  }
158
164
  static get formAssociated() { return true; }
165
+ static get watchers() { return {
166
+ "dsChecked": ["dsCheckedObserver"]
167
+ }; }
159
168
  };
160
- DsCheckbox.style = DsCheckboxStyle0;
169
+ DsCheckbox.style = dsCheckboxCss;
161
170
 
162
171
  exports.ds_checkbox = DsCheckbox;