@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,4 +1,4 @@
1
- import { h } from "@stencil/core";
1
+ import { Fragment, h } from "@stencil/core";
2
2
  import classNames from "classnames";
3
3
  import { inheritAriaAttributes, inheritSpecifiedAttributes, inheritAttributes } from "../../../utils/attributes/attributes";
4
4
  export class DsButton {
@@ -6,18 +6,26 @@ export class DsButton {
6
6
  buttonEl;
7
7
  pressedKeys = new Set();
8
8
  el;
9
- value = '';
10
- variant = 'primary';
11
- colour = 'blue';
12
- size = 'medium';
13
- fontWeight = 'normal';
14
- icon = '';
15
- iconPosition = 'start';
16
- type = 'button';
17
- disabled = false;
18
- fullWidth = false;
19
- ariaDisabled = 'false';
9
+ dsValue = '';
10
+ dsVariant = 'primary';
11
+ dsColour = 'blue';
12
+ dsSize = 'medium';
13
+ dsIcon = '';
14
+ dsIconPosition = 'start';
15
+ dsType = 'button';
16
+ dsDisabled = false;
17
+ dsIsLoading = false;
18
+ dsUseSpinner = false;
19
+ dsSpinnerHiddenText;
20
+ dsFullWidth = false;
21
+ dsAriaDisabled = 'false';
22
+ async dsFocus() {
23
+ this.buttonEl.focus();
24
+ }
20
25
  componentWillLoad() {
26
+ if (this.dsUseSpinner && !this.dsSpinnerHiddenText) {
27
+ throw new Error('dsSpinnerHiddenText is required when dsUseSpinner is true.');
28
+ }
21
29
  this.inheritedAttributes = {
22
30
  ...inheritAriaAttributes(this.el, ['aria-disabled']),
23
31
  ...inheritSpecifiedAttributes(this.el, [
@@ -43,7 +51,7 @@ export class DsButton {
43
51
  case 'Enter':
44
52
  case ' ':
45
53
  this.pressedKeys.add(event.key);
46
- this.buttonEl.classList.add(`${this.colour}--active`);
54
+ this.buttonEl.classList.add(`${this.dsColour}--active`);
47
55
  break;
48
56
  }
49
57
  };
@@ -53,20 +61,37 @@ export class DsButton {
53
61
  case ' ':
54
62
  this.pressedKeys.delete(event.key);
55
63
  if (this.pressedKeys.size === 0) {
56
- this.buttonEl.classList.remove(`${this.colour}--active`);
64
+ this.buttonEl.classList.remove(`${this.dsColour}--active`);
57
65
  }
58
66
  break;
59
67
  }
60
68
  };
61
- render() {
62
- const classes = classNames(`ds-button ${this.variant} ${this.colour} ${this.size}`, {
63
- 'icon-start': this.icon && this.iconPosition === 'start' && this.value,
64
- 'icon-end': this.icon && this.iconPosition === 'end' && this.value,
65
- 'icon-only': this.icon && !this.value,
69
+ getSpinnerColour = () => {
70
+ if (this.dsVariant === 'primary') {
71
+ if (this.dsColour === 'blue')
72
+ return 'white';
73
+ if (this.dsColour === 'white')
74
+ return 'black';
75
+ if (this.dsColour === 'black')
76
+ return 'white';
77
+ }
78
+ return this.dsColour;
79
+ };
80
+ renderButton = () => {
81
+ const classes = classNames(`ds-button ${this.dsVariant} ${this.dsColour} ${this.dsSize}`, {
82
+ 'icon-start': this.dsIcon && this.dsIconPosition === 'start' && this.dsValue,
83
+ 'icon-end': this.dsIcon && this.dsIconPosition === 'end' && this.dsValue,
84
+ 'icon-only': this.dsIcon && !this.dsValue,
66
85
  });
67
- const iconSize = this.size === 'small' ? '1rem' : undefined;
68
- const isDisabled = this.disabled || this.ariaDisabled === 'true';
69
- return (h("button", { key: 'a88d1c763917de40eeaefc79cadace3a107a761e', ref: el => (this.buttonEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, class: classes, style: { fontWeight: this.fontWeight }, type: this.type, "aria-disabled": isDisabled ? 'true' : 'false', ...this.inheritedAttributes }, h("slot", { key: '5a576ddabcd8be9957832560a1503ffc9b0a4b4c', name: "prefix" }, this.icon && this.iconPosition === 'start' && h("ds-icon", { key: '44506977ee4a8e0d2044efa9c4e66f52e901c98c', name: this.icon, size: iconSize })), this.value && h("span", { key: '0a2a0ff071b51cfb9df7f4bc27b1ea6469f3a47e', class: "button-value" }, this.value), h("slot", { key: '757002ca6ed2f98f692b8f5b630ecfd0f6e83f5c', name: "suffix" }, this.icon && this.iconPosition === 'end' && h("ds-icon", { key: '2605d1808580c30f68717660a516d07fe8fcfc59', name: this.icon, size: iconSize }))));
86
+ const iconSize = this.dsSize === 'small' ? '1rem' : undefined;
87
+ return (h("button", { ref: el => (this.buttonEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, class: classes, type: this.dsType, "aria-disabled": this.dsAriaDisabled == 'true' ? 'true' : 'false', disabled: this.dsDisabled, ...this.inheritedAttributes }, this.dsIsLoading ? (h(Fragment, null, h("ds-spinner", { dsHiddenAssistiveText: this.dsSpinnerHiddenText, dsSpinnerColor: this.getSpinnerColour(), dsSize: this.dsSize == 'small' ? 'small' : 'medium' }), this.dsValue && h("span", { class: "button-value" }, this.dsValue))) : (h(Fragment, null, h("slot", { name: "prefix" }, this.dsIcon && this.dsIconPosition === 'start' && h("ds-icon", { dsName: this.dsIcon, dsSize: iconSize })), this.dsValue && h("span", { class: "button-value" }, this.dsValue), h("slot", { name: "suffix" }, this.dsIcon && this.dsIconPosition === 'end' && h("ds-icon", { dsName: this.dsIcon, dsSize: iconSize }))))));
88
+ };
89
+ render() {
90
+ const buttonElement = this.renderButton();
91
+ return (this.dsUseSpinner ?
92
+ h("div", { "aria-live": "polite" }, buttonElement)
93
+ :
94
+ buttonElement);
70
95
  }
71
96
  static get is() { return "ds-button"; }
72
97
  static get encapsulation() { return "scoped"; }
@@ -82,8 +107,9 @@ export class DsButton {
82
107
  }
83
108
  static get properties() {
84
109
  return {
85
- "value": {
110
+ "dsValue": {
86
111
  "type": "string",
112
+ "attribute": "ds-value",
87
113
  "mutable": false,
88
114
  "complexType": {
89
115
  "original": "string",
@@ -107,12 +133,12 @@ export class DsButton {
107
133
  },
108
134
  "getter": false,
109
135
  "setter": false,
110
- "attribute": "value",
111
136
  "reflect": false,
112
137
  "defaultValue": "''"
113
138
  },
114
- "variant": {
139
+ "dsVariant": {
115
140
  "type": "string",
141
+ "attribute": "ds-variant",
116
142
  "mutable": false,
117
143
  "complexType": {
118
144
  "original": "'primary' | 'secondary' | 'supplementary'",
@@ -123,16 +149,16 @@ export class DsButton {
123
149
  "optional": false,
124
150
  "docs": {
125
151
  "tags": [],
126
- "text": ""
152
+ "text": "Variant of the button"
127
153
  },
128
154
  "getter": false,
129
155
  "setter": false,
130
- "attribute": "variant",
131
156
  "reflect": false,
132
157
  "defaultValue": "'primary'"
133
158
  },
134
- "colour": {
159
+ "dsColour": {
135
160
  "type": "string",
161
+ "attribute": "ds-colour",
136
162
  "mutable": false,
137
163
  "complexType": {
138
164
  "original": "'blue' | 'black' | 'white'",
@@ -143,16 +169,16 @@ export class DsButton {
143
169
  "optional": false,
144
170
  "docs": {
145
171
  "tags": [],
146
- "text": ""
172
+ "text": "Colour of the button"
147
173
  },
148
174
  "getter": false,
149
175
  "setter": false,
150
- "attribute": "colour",
151
176
  "reflect": false,
152
177
  "defaultValue": "'blue'"
153
178
  },
154
- "size": {
179
+ "dsSize": {
155
180
  "type": "string",
181
+ "attribute": "ds-size",
156
182
  "mutable": false,
157
183
  "complexType": {
158
184
  "original": "'small' | 'medium'",
@@ -163,16 +189,16 @@ export class DsButton {
163
189
  "optional": false,
164
190
  "docs": {
165
191
  "tags": [],
166
- "text": ""
192
+ "text": "Size of the button"
167
193
  },
168
194
  "getter": false,
169
195
  "setter": false,
170
- "attribute": "size",
171
196
  "reflect": false,
172
197
  "defaultValue": "'medium'"
173
198
  },
174
- "fontWeight": {
199
+ "dsIcon": {
175
200
  "type": "string",
201
+ "attribute": "ds-icon",
176
202
  "mutable": false,
177
203
  "complexType": {
178
204
  "original": "string",
@@ -183,76 +209,96 @@ export class DsButton {
183
209
  "optional": false,
184
210
  "docs": {
185
211
  "tags": [],
186
- "text": ""
212
+ "text": "Icon to display alongside the button text"
187
213
  },
188
214
  "getter": false,
189
215
  "setter": false,
190
- "attribute": "font-weight",
191
216
  "reflect": false,
192
- "defaultValue": "'normal'"
217
+ "defaultValue": "''"
193
218
  },
194
- "icon": {
219
+ "dsIconPosition": {
195
220
  "type": "string",
221
+ "attribute": "ds-icon-position",
196
222
  "mutable": false,
197
223
  "complexType": {
198
- "original": "string",
199
- "resolved": "string",
224
+ "original": "'start' | 'end'",
225
+ "resolved": "\"end\" | \"start\"",
200
226
  "references": {}
201
227
  },
202
228
  "required": false,
203
229
  "optional": false,
204
230
  "docs": {
205
231
  "tags": [],
206
- "text": ""
232
+ "text": "Whether to display the icon before or after the button text"
207
233
  },
208
234
  "getter": false,
209
235
  "setter": false,
210
- "attribute": "icon",
211
236
  "reflect": false,
212
- "defaultValue": "''"
237
+ "defaultValue": "'start'"
213
238
  },
214
- "iconPosition": {
239
+ "dsType": {
215
240
  "type": "string",
241
+ "attribute": "ds-type",
216
242
  "mutable": false,
217
243
  "complexType": {
218
- "original": "'start' | 'end'",
219
- "resolved": "\"end\" | \"start\"",
244
+ "original": "'button' | 'submit' | 'reset'",
245
+ "resolved": "\"button\" | \"reset\" | \"submit\"",
220
246
  "references": {}
221
247
  },
222
248
  "required": false,
223
249
  "optional": false,
224
250
  "docs": {
225
251
  "tags": [],
226
- "text": ""
252
+ "text": "Passed to the `type` attribute of the `button` element"
227
253
  },
228
254
  "getter": false,
229
255
  "setter": false,
230
- "attribute": "icon-position",
231
256
  "reflect": false,
232
- "defaultValue": "'start'"
257
+ "defaultValue": "'button'"
233
258
  },
234
- "type": {
235
- "type": "string",
259
+ "dsDisabled": {
260
+ "type": "boolean",
261
+ "attribute": "ds-disabled",
236
262
  "mutable": false,
237
263
  "complexType": {
238
- "original": "'button' | 'submit' | 'reset'",
239
- "resolved": "\"button\" | \"reset\" | \"submit\"",
264
+ "original": "boolean",
265
+ "resolved": "boolean",
240
266
  "references": {}
241
267
  },
242
268
  "required": false,
243
269
  "optional": false,
244
270
  "docs": {
245
271
  "tags": [],
246
- "text": ""
272
+ "text": "Passed to the `disabled` attribute of the `button` element"
247
273
  },
248
274
  "getter": false,
249
275
  "setter": false,
250
- "attribute": "type",
251
276
  "reflect": false,
252
- "defaultValue": "'button'"
277
+ "defaultValue": "false"
278
+ },
279
+ "dsIsLoading": {
280
+ "type": "boolean",
281
+ "attribute": "ds-is-loading",
282
+ "mutable": false,
283
+ "complexType": {
284
+ "original": "boolean",
285
+ "resolved": "boolean",
286
+ "references": {}
287
+ },
288
+ "required": false,
289
+ "optional": false,
290
+ "docs": {
291
+ "tags": [],
292
+ "text": "Displays a loading spinner in the button"
293
+ },
294
+ "getter": false,
295
+ "setter": false,
296
+ "reflect": false,
297
+ "defaultValue": "false"
253
298
  },
254
- "disabled": {
299
+ "dsUseSpinner": {
255
300
  "type": "boolean",
301
+ "attribute": "ds-use-spinner",
256
302
  "mutable": false,
257
303
  "complexType": {
258
304
  "original": "boolean",
@@ -263,16 +309,35 @@ export class DsButton {
263
309
  "optional": false,
264
310
  "docs": {
265
311
  "tags": [],
266
- "text": ""
312
+ "text": "Wraps the button in a container where `aria-live` is set to `polite`"
267
313
  },
268
314
  "getter": false,
269
315
  "setter": false,
270
- "attribute": "disabled",
271
316
  "reflect": false,
272
317
  "defaultValue": "false"
273
318
  },
274
- "fullWidth": {
319
+ "dsSpinnerHiddenText": {
320
+ "type": "string",
321
+ "attribute": "ds-spinner-hidden-text",
322
+ "mutable": false,
323
+ "complexType": {
324
+ "original": "string",
325
+ "resolved": "string",
326
+ "references": {}
327
+ },
328
+ "required": false,
329
+ "optional": false,
330
+ "docs": {
331
+ "tags": [],
332
+ "text": "Information for screen readers when spinner is displayed"
333
+ },
334
+ "getter": false,
335
+ "setter": false,
336
+ "reflect": false
337
+ },
338
+ "dsFullWidth": {
275
339
  "type": "boolean",
340
+ "attribute": "ds-full-width",
276
341
  "mutable": false,
277
342
  "complexType": {
278
343
  "original": "boolean",
@@ -283,16 +348,16 @@ export class DsButton {
283
348
  "optional": false,
284
349
  "docs": {
285
350
  "tags": [],
286
- "text": ""
351
+ "text": "Displays the button as full width"
287
352
  },
288
353
  "getter": false,
289
354
  "setter": false,
290
- "attribute": "full-width",
291
355
  "reflect": false,
292
356
  "defaultValue": "false"
293
357
  },
294
- "ariaDisabled": {
358
+ "dsAriaDisabled": {
295
359
  "type": "string",
360
+ "attribute": "ds-aria-disabled",
296
361
  "mutable": false,
297
362
  "complexType": {
298
363
  "original": "string",
@@ -303,15 +368,35 @@ export class DsButton {
303
368
  "optional": false,
304
369
  "docs": {
305
370
  "tags": [],
306
- "text": ""
371
+ "text": "Passed to the `aria-disabled` attribute of the `button` element"
307
372
  },
308
373
  "getter": false,
309
374
  "setter": false,
310
- "attribute": "aria-disabled",
311
375
  "reflect": false,
312
376
  "defaultValue": "'false'"
313
377
  }
314
378
  };
315
379
  }
380
+ static get methods() {
381
+ return {
382
+ "dsFocus": {
383
+ "complexType": {
384
+ "signature": "() => Promise<void>",
385
+ "parameters": [],
386
+ "references": {
387
+ "Promise": {
388
+ "location": "global",
389
+ "id": "global::Promise"
390
+ }
391
+ },
392
+ "return": "Promise<void>"
393
+ },
394
+ "docs": {
395
+ "text": "Sets focus to the button element rendered inside `ds-button` component.",
396
+ "tags": []
397
+ }
398
+ }
399
+ };
400
+ }
316
401
  static get elementRef() { return "el"; }
317
402
  }
@@ -1,44 +1,65 @@
1
1
  import { html } from "lit";
2
2
  import { litTemplateResultToString } from "../../../../utils/utils";
3
+ import { handleButtonLoading } from "../../../../utils/button/buttonUtils";
3
4
  const meta = {
4
5
  title: 'Base Components/Button/Examples',
5
6
  component: 'ds-button',
6
7
  };
7
8
  export default meta;
9
+ const dsSbButtonGroupStyle = html `
10
+ <style>
11
+ .ds-sb-button-group {
12
+ display: flex;
13
+ gap: 0.5rem;
14
+ }
15
+ </style>
16
+ `;
17
+ const buttonGroupDOM = html `
18
+ <div class="ds-sb-button-group">
19
+ <ds-button ds-variant="primary" ds-value="Primary"></ds-button>
20
+ <ds-button ds-variant="secondary" ds-value="Secondary"></ds-button>
21
+ <ds-button ds-variant="supplementary" ds-value="Supplementary"></ds-button>
22
+ </div>
23
+ `;
8
24
  export const ButtonGroup = {
9
25
  render: () => html `
10
- <div class="button-group">
11
- <ds-button variant="primary" value="Primary"></ds-button>
12
- <ds-button variant="secondary" value="Secondary"></ds-button>
13
- <ds-button variant="supplementary" value="Supplementary"></ds-button>
14
- </div>
26
+ ${dsSbButtonGroupStyle}
27
+ ${buttonGroupDOM}
15
28
  `,
16
29
  };
30
+ const buttonGroupSmallDOM = html `
31
+ <div class="ds-sb-button-group">
32
+ <ds-button ds-variant="primary" ds-value="Primary" ds-size="small"></ds-button>
33
+ <ds-button ds-variant="secondary" ds-value="Secondary" ds-size="small"></ds-button>
34
+ <ds-button ds-variant="supplementary" ds-value="Supplementary" ds-size="small"></ds-button>
35
+ </div>
36
+ `;
17
37
  export const ButtonGroupSmall = {
18
38
  render: () => html `
19
- <div class="button-group">
20
- <ds-button variant="primary" value="Primary" size="small"></ds-button>
21
- <ds-button variant="secondary" value="Secondary" size="small"></ds-button>
22
- <ds-button variant="supplementary" value="Supplementary" size="small"></ds-button>
23
- </div>
39
+ ${dsSbButtonGroupStyle}
40
+ ${buttonGroupSmallDOM}
24
41
  `,
25
42
  };
43
+ const buttonGroupIconDOM = html `
44
+ <div class="ds-sb-button-group">
45
+ <ds-button ds-value="Button with text and icon" ds-icon="ds_flame"></ds-button>
46
+ <ds-button ds-value="Button with text and icon" ds-icon="ds_flame" ds-icon-position="end"></ds-button>
47
+ <ds-button ds-icon="ds_flame" aria-label="Button with icon"></ds-button>
48
+ </div>
49
+ `;
26
50
  export const ButtonGroupIcon = {
27
51
  render: () => html `
28
- <div class="button-group">
29
- <ds-button value="Button with text and icon" icon="ds_flame"></ds-button>
30
- <ds-button value="Button with text and icon" icon="ds_flame" icon-position="end"></ds-button>
31
- <ds-button icon="ds_flame" aria-label="Button with icon"></ds-button>
32
- </div>
52
+ ${dsSbButtonGroupStyle}
53
+ ${buttonGroupIconDOM}
33
54
  `,
34
55
  };
35
56
  const resetAndSubmitButtonDOM = html `
36
57
  <form class="ds-sb-reset-and-submit-button">
37
- <ds-text-input name="firstname" label="firstname"></ds-text-input>
38
- <ds-text-input name="lastname" label="lastname"></ds-text-input>
39
- <div class="button-group ds-sb-reset-and-submit-button__buttons">
40
- <ds-button value="reset" type="reset" variant="secondary"></ds-button>
41
- <ds-button value="submit" type="submit"></ds-button>
58
+ <ds-text-input ds-name="firstname" ds-label="firstname"></ds-text-input>
59
+ <ds-text-input ds-name="lastname" ds-label="lastname"></ds-text-input>
60
+ <div class="ds-sb-button-group ds-sb-reset-and-submit-button__buttons">
61
+ <ds-button ds-value="reset" ds-type="reset" ds-variant="secondary"></ds-button>
62
+ <ds-button ds-value="submit" ds-type="submit"></ds-button>
42
63
  </div>
43
64
  </form>
44
65
  `;
@@ -66,9 +87,86 @@ export const ResetAndSubmitButton = {
66
87
  };
67
88
  export const FullWidthWithIconsUsingSlots = {
68
89
  render: () => html `
69
- <ds-button style="width: 100%;" value="Full width with icons using slots">
70
- <ds-icon slot="prefix" name="ds_flame"></ds-icon>
71
- <ds-icon slot="suffix" name="ds_flame"></ds-icon>
90
+ <ds-button style="width: 100%;" ds-value="Full width with icons using slots">
91
+ <ds-icon slot="prefix" ds-name="ds_flame"></ds-icon>
92
+ <ds-icon slot="suffix" ds-name="ds_flame"></ds-icon>
72
93
  </ds-button>
73
94
  `,
74
95
  };
96
+ export const ButtonWithLoadingAnimation = {
97
+ render: () => html `
98
+ <style>
99
+ .ds-sb-example-load {
100
+ display: flex;
101
+ flex-direction: column;
102
+ gap: 1rem;
103
+ margin: 1rem 0;
104
+ max-width: 250px;
105
+ }
106
+ </style>
107
+ <div class="ds-sb-example-load">
108
+ <ds-button
109
+ ds-id="loading-button"
110
+ ds-variant="primary"
111
+ ds-value="Send"
112
+ ds-is-loading="false"
113
+ ds-use-spinner="true"
114
+ ds-spinner-hidden-text="Sending..."
115
+ @click=${(e) => {
116
+ const button = e.currentTarget;
117
+ handleButtonLoading(button, 'Send', 'Sending...');
118
+ }}
119
+ ></ds-button>
120
+ <ds-button
121
+ ds-id="loading-button"
122
+ ds-variant="secondary"
123
+ ds-value="Download"
124
+ ds-icon="download"
125
+ ds-is-loading="false"
126
+ ds-use-spinner="true"
127
+ ds-spinner-hidden-text="Downloading..."
128
+ @click=${(e) => {
129
+ const button = e.currentTarget;
130
+ handleButtonLoading(button, 'Download', 'Downloading...');
131
+ }}
132
+ ></ds-button>
133
+ <ds-button
134
+ ds-id="loading-button"
135
+ ds-variant="supplementary"
136
+ ds-value="Download"
137
+ ds-is-loading="false"
138
+ ds-use-spinner="true"
139
+ ds-spinner-hidden-text="Downloading..."
140
+ @click=${(e) => {
141
+ const button = e.currentTarget;
142
+ handleButtonLoading(button, 'Download', 'Downloading...');
143
+ }}
144
+ ></ds-button>
145
+ <ds-button
146
+ ds-id="loading-button"
147
+ ds-variant="supplementary"
148
+ ds-value="Download"
149
+ ds-is-loading="false"
150
+ ds-use-spinner="true"
151
+ ds-spinner-hidden-text="Downloading..."
152
+ @click=${(e) => {
153
+ const button = e.currentTarget;
154
+ handleButtonLoading(button, 'Download', '');
155
+ }}
156
+ ></ds-button>
157
+ </div>
158
+
159
+ <ds-button
160
+ ds-id="loading-button"
161
+ ds-variant="primary"
162
+ ds-value="Send"
163
+ ds-is-loading="false"
164
+ ds-use-spinner="true"
165
+ ds-spinner-hidden-text="Sending..."
166
+ @click=${(e) => {
167
+ const button = e.currentTarget;
168
+ handleButtonLoading(button, 'Send', 'Sending...');
169
+ }}
170
+ ></ds-button>
171
+ `,
172
+ };