@uh-design-system/component-library 0.1.0 → 0.2.0-alpha.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 (185) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +0 -2
  3. package/dist/cjs/ds-accordion_2.cjs.entry.js +930 -0
  4. package/dist/cjs/ds-button_2.cjs.entry.js +196 -0
  5. package/dist/cjs/ds-text-input.cjs.entry.js +137 -0
  6. package/dist/cjs/index-5a88e57b.js +82 -0
  7. package/dist/cjs/{index-eaf5876c.js → index-f7420801.js} +652 -149
  8. package/dist/cjs/index.cjs.js +0 -9
  9. package/dist/cjs/loader.cjs.js +2 -4
  10. package/dist/cjs/uh-component-library.cjs.js +3 -5
  11. package/dist/collection/collection-manifest.json +6 -2
  12. package/dist/collection/components/00-foundations/borders/borders.stories.js +7 -8
  13. package/dist/collection/components/00-foundations/breakpoints/breakpoints.stories.js +20 -0
  14. package/dist/collection/components/00-foundations/colours/colours.stories.js +9 -17
  15. package/dist/collection/components/00-foundations/icons/categories/actions.js +110 -0
  16. package/dist/collection/components/00-foundations/icons/categories/arrows.js +64 -0
  17. package/dist/collection/components/00-foundations/icons/categories/custom.js +10 -0
  18. package/dist/collection/components/00-foundations/icons/categories/information.js +94 -0
  19. package/dist/collection/components/00-foundations/icons/categories/media.js +76 -0
  20. package/dist/collection/components/00-foundations/icons/categories/navigation.js +50 -0
  21. package/dist/collection/components/00-foundations/icons/categories/notifications.js +64 -0
  22. package/dist/collection/components/00-foundations/icons/categories/text.js +18 -0
  23. package/dist/collection/components/00-foundations/icons/categories/users.js +52 -0
  24. package/dist/collection/components/00-foundations/icons/iconList.js +18 -293
  25. package/dist/collection/components/00-foundations/icons/icons.stories.js +0 -1
  26. package/dist/collection/components/00-foundations/spacing/spacing.stories.js +2 -3
  27. package/dist/collection/components/00-foundations/typography/typography.stories.js +52 -3
  28. package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.css +130 -0
  29. package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.js +217 -0
  30. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.examples.stories.js +43 -0
  31. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.features.stories.js +79 -0
  32. package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.stories.js +96 -0
  33. package/dist/collection/components/01-base-components/ds-button/ds-button.css +238 -0
  34. package/dist/collection/components/01-base-components/ds-button/ds-button.js +294 -0
  35. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.examples.stories.js +28 -0
  36. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.features.stories.js +77 -0
  37. package/dist/collection/components/01-base-components/ds-button/stories/ds-button.stories.js +79 -0
  38. package/dist/collection/components/01-base-components/ds-icon/ds-icon.css +1 -1
  39. package/dist/collection/components/01-base-components/ds-icon/ds-icon.js +18 -6
  40. package/dist/collection/components/01-base-components/ds-icon/ds-icon.stories.js +1 -2
  41. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.css +186 -0
  42. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.examples.stories.js +24 -0
  43. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.features.stories.js +126 -0
  44. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +665 -0
  45. package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.stories.js +73 -0
  46. package/dist/collection/components/01-base-components/ds-text-input/utils.js +16 -0
  47. package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.css +9 -0
  48. package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js +18 -0
  49. package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.stories.js +9 -0
  50. package/dist/collection/index.js +1 -11
  51. package/dist/collection/utils/attributes.js +107 -0
  52. package/dist/collection/utils/borders/borderUtils.js +24 -4
  53. package/dist/collection/utils/breakpoints/breakpointsUtils.js +58 -0
  54. package/dist/collection/utils/colours/colourTypes.js +19 -0
  55. package/dist/collection/utils/colours/colourUtils.js +67 -47
  56. package/dist/collection/utils/spacing/spacingUtils.js +21 -9
  57. package/dist/collection/utils/tests/testUtils.js +21 -6
  58. package/dist/collection/utils/typography/typographyUtils.js +0 -1
  59. package/dist/collection/utils/utils.js +48 -3
  60. package/dist/components/ds-accordion.d.ts +11 -0
  61. package/dist/components/ds-accordion.js +96 -0
  62. package/dist/components/ds-button.d.ts +11 -0
  63. package/dist/components/ds-button.js +6 -0
  64. package/dist/components/ds-button2.js +209 -0
  65. package/dist/components/ds-icon.js +1 -540
  66. package/dist/components/ds-icon2.js +890 -0
  67. package/dist/components/ds-text-input.d.ts +11 -0
  68. package/dist/components/ds-text-input.js +200 -0
  69. package/dist/components/ds-visually-hidden.d.ts +11 -0
  70. package/dist/components/ds-visually-hidden.js +6 -0
  71. package/dist/components/ds-visually-hidden2.js +31 -0
  72. package/dist/components/index.js +1 -9
  73. package/dist/components/{p-dcfb6eb2.js → index2.js} +616 -146
  74. package/dist/components/index3.js +80 -0
  75. package/dist/esm/app-globals-0f993ce5.js +0 -2
  76. package/dist/esm/ds-accordion_2.entry.js +925 -0
  77. package/dist/esm/ds-button_2.entry.js +191 -0
  78. package/dist/esm/ds-text-input.entry.js +133 -0
  79. package/dist/esm/index-097075ad.js +80 -0
  80. package/dist/esm/{index-1586ada2.js → index-1d0a6586.js} +652 -150
  81. package/dist/esm/index.js +0 -6
  82. package/dist/esm/loader.js +3 -5
  83. package/dist/esm/uh-component-library.js +4 -6
  84. package/dist/loader/cdn.js +1 -0
  85. package/dist/loader/index.cjs.js +1 -0
  86. package/{loader → dist/loader}/index.d.ts +1 -1
  87. package/dist/loader/index.es2017.js +1 -0
  88. package/{loader → dist/loader}/index.js +1 -1
  89. package/dist/types/components/00-foundations/breakpoints/breakpoints.stories.d.ts +6 -0
  90. package/dist/types/components/00-foundations/colours/colours.stories.d.ts +3 -2
  91. package/dist/types/components/00-foundations/icons/categories/actions.d.ts +5 -0
  92. package/dist/types/components/00-foundations/icons/categories/arrows.d.ts +5 -0
  93. package/dist/types/components/00-foundations/icons/categories/custom.d.ts +5 -0
  94. package/dist/types/components/00-foundations/icons/categories/information.d.ts +5 -0
  95. package/dist/types/components/00-foundations/icons/categories/media.d.ts +5 -0
  96. package/dist/types/components/00-foundations/icons/categories/navigation.d.ts +5 -0
  97. package/dist/types/components/00-foundations/icons/categories/notifications.d.ts +5 -0
  98. package/dist/types/components/00-foundations/icons/categories/text.d.ts +5 -0
  99. package/dist/types/components/00-foundations/icons/categories/users.d.ts +5 -0
  100. package/dist/types/components/00-foundations/typography/typography.stories.d.ts +6 -5
  101. package/dist/types/components/01-base-components/ds-accordion/ds-accordion.d.ts +17 -0
  102. package/dist/types/components/01-base-components/ds-accordion/stories/ds-accordion.examples.stories.d.ts +9 -0
  103. package/dist/types/components/01-base-components/ds-accordion/stories/ds-accordion.features.stories.d.ts +13 -0
  104. package/dist/types/components/01-base-components/ds-accordion/stories/ds-accordion.stories.d.ts +8 -0
  105. package/dist/types/components/01-base-components/ds-button/ds-button.d.ts +33 -0
  106. package/dist/types/components/01-base-components/ds-button/stories/ds-button.examples.stories.d.ts +6 -0
  107. package/dist/types/components/01-base-components/ds-button/stories/ds-button.features.stories.d.ts +17 -0
  108. package/dist/types/components/01-base-components/ds-button/stories/ds-button.stories.d.ts +8 -0
  109. package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +46 -0
  110. package/dist/types/components/01-base-components/ds-text-input/ds-text-input.examples.stories.d.ts +8 -0
  111. package/dist/types/components/01-base-components/ds-text-input/ds-text-input.features.stories.d.ts +18 -0
  112. package/dist/types/components/01-base-components/ds-text-input/ds-text-input.stories.d.ts +8 -0
  113. package/dist/types/components/01-base-components/ds-text-input/utils.d.ts +3 -0
  114. package/dist/types/components/01-base-components/ds-visually-hidden/ds-visually-hidden.d.ts +3 -0
  115. package/dist/types/components/01-base-components/ds-visually-hidden/ds-visually-hidden.stories.d.ts +7 -0
  116. package/dist/types/components.d.ts +152 -0
  117. package/dist/types/declarations.d.ts +4 -0
  118. package/dist/types/index.d.ts +0 -1
  119. package/dist/types/utils/attributes.d.ts +39 -0
  120. package/dist/types/utils/borders/borderUtils.d.ts +9 -0
  121. package/dist/types/utils/breakpoints/breakpointsUtils.d.ts +11 -0
  122. package/dist/types/utils/colours/colourTypes.d.ts +18 -0
  123. package/dist/types/utils/colours/colourUtils.d.ts +4 -14
  124. package/dist/types/utils/spacing/spacingUtils.d.ts +6 -3
  125. package/dist/types/utils/tests/testUtils.d.ts +2 -0
  126. package/dist/types/utils/utils.d.ts +20 -1
  127. package/dist/uh-component-library/app-globals-0f993ce5.js +1 -0
  128. package/dist/uh-component-library/ds-accordion_2.entry.js +1 -0
  129. package/dist/uh-component-library/ds-button_2.entry.js +1 -0
  130. package/dist/uh-component-library/ds-text-input.entry.js +1 -0
  131. package/dist/uh-component-library/index-097075ad.js +6 -0
  132. package/dist/uh-component-library/index-1d0a6586.js +2 -0
  133. package/dist/uh-component-library/index.esm.js +0 -2
  134. package/dist/uh-component-library/uh-component-library.esm.js +1 -2
  135. package/package.json +8 -15
  136. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  137. package/dist/cjs/ds-icon.cjs.entry.js +0 -522
  138. package/dist/cjs/ds-icon.cjs.entry.js.map +0 -1
  139. package/dist/cjs/index-eaf5876c.js.map +0 -1
  140. package/dist/cjs/index.cjs.js.map +0 -1
  141. package/dist/cjs/loader.cjs.js.map +0 -1
  142. package/dist/cjs/uh-component-library.cjs.js.map +0 -1
  143. package/dist/collection/components/00-foundations/borders/borders.stories.js.map +0 -1
  144. package/dist/collection/components/00-foundations/colours/colours.stories.js.map +0 -1
  145. package/dist/collection/components/00-foundations/icons/iconList.js.map +0 -1
  146. package/dist/collection/components/00-foundations/icons/icons.stories.js.map +0 -1
  147. package/dist/collection/components/00-foundations/spacing/spacing.stories.js.map +0 -1
  148. package/dist/collection/components/00-foundations/typography/headings.stories.js +0 -23
  149. package/dist/collection/components/00-foundations/typography/headings.stories.js.map +0 -1
  150. package/dist/collection/components/00-foundations/typography/text.stories.js +0 -17
  151. package/dist/collection/components/00-foundations/typography/text.stories.js.map +0 -1
  152. package/dist/collection/components/00-foundations/typography/typography.stories.js.map +0 -1
  153. package/dist/collection/components/01-base-components/ds-icon/ds-icon.js.map +0 -1
  154. package/dist/collection/components/01-base-components/ds-icon/ds-icon.stories.js.map +0 -1
  155. package/dist/collection/index.js.map +0 -1
  156. package/dist/collection/utils/borders/borderUtils.js.map +0 -1
  157. package/dist/collection/utils/colours/colourUtils.js.map +0 -1
  158. package/dist/collection/utils/spacing/spacingUtils.js.map +0 -1
  159. package/dist/collection/utils/tests/testUtils.js.map +0 -1
  160. package/dist/collection/utils/typography/typographyUtils.js.map +0 -1
  161. package/dist/collection/utils/utils.js.map +0 -1
  162. package/dist/components/ds-icon.js.map +0 -1
  163. package/dist/components/index.js.map +0 -1
  164. package/dist/components/p-dcfb6eb2.js.map +0 -1
  165. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  166. package/dist/esm/ds-icon.entry.js +0 -518
  167. package/dist/esm/ds-icon.entry.js.map +0 -1
  168. package/dist/esm/index-1586ada2.js.map +0 -1
  169. package/dist/esm/index.js.map +0 -1
  170. package/dist/esm/loader.js.map +0 -1
  171. package/dist/esm/uh-component-library.js.map +0 -1
  172. package/dist/types/components/00-foundations/typography/headings.stories.d.ts +0 -17
  173. package/dist/types/components/00-foundations/typography/text.stories.d.ts +0 -11
  174. package/dist/uh-component-library/index.esm.js.map +0 -1
  175. package/dist/uh-component-library/p-74d73de3.js +0 -3
  176. package/dist/uh-component-library/p-74d73de3.js.map +0 -1
  177. package/dist/uh-component-library/p-c7cd80a5.entry.js +0 -2
  178. package/dist/uh-component-library/p-c7cd80a5.entry.js.map +0 -1
  179. package/dist/uh-component-library/p-e1255160.js +0 -2
  180. package/dist/uh-component-library/p-e1255160.js.map +0 -1
  181. package/dist/uh-component-library/uh-component-library.esm.js.map +0 -1
  182. package/loader/cdn.js +0 -1
  183. package/loader/index.cjs.js +0 -1
  184. package/loader/index.es2017.js +0 -1
  185. /package/{loader → dist/loader}/package.json +0 -0
@@ -0,0 +1,79 @@
1
+ import { icons } from "../../../00-foundations/icons/iconList";
2
+ import { getAriaAttributeArgTypes } from "../../../../utils/attributes";
3
+ /**
4
+ * Button aria-attributes
5
+ *
6
+ * @see {@link https://w3c.github.io/aria/#button}
7
+ */
8
+ const buttonAriaAttributes = [
9
+ 'aria-busy',
10
+ 'aria-live',
11
+ 'aria-atomic',
12
+ 'aria-disabled',
13
+ 'aria-expanded',
14
+ 'aria-pressed',
15
+ 'aria-hidden',
16
+ 'aria-label',
17
+ 'aria-labelledby',
18
+ 'aria-controls',
19
+ 'aria-haspopup',
20
+ 'aria-describedby',
21
+ 'aria-relevant',
22
+ 'aria-details',
23
+ ];
24
+ const buttonAriaAttributeArgTypes = getAriaAttributeArgTypes(buttonAriaAttributes);
25
+ const meta = {
26
+ title: 'Base Components/Button',
27
+ component: 'ds-button',
28
+ };
29
+ export default meta;
30
+ export const Default = {
31
+ args: {
32
+ value: 'button',
33
+ fontWeight: '700',
34
+ disabled: false,
35
+ },
36
+ argTypes: {
37
+ value: { control: 'text' },
38
+ disabled: { control: 'boolean' },
39
+ fontWeight: {
40
+ control: 'select',
41
+ options: [400, 600, 650, 700],
42
+ },
43
+ },
44
+ };
45
+ export const Playground = {
46
+ argTypes: Object.assign(Object.assign(Object.assign({}, Default.argTypes), { variant: {
47
+ options: ['primary', 'secondary', 'supplementary'],
48
+ control: {
49
+ type: 'radio',
50
+ },
51
+ }, colour: {
52
+ options: ['blue', 'black', 'white'],
53
+ control: {
54
+ type: 'radio',
55
+ },
56
+ }, size: {
57
+ options: ['medium', 'small'],
58
+ control: {
59
+ type: 'radio',
60
+ },
61
+ }, fontWeight: {
62
+ control: 'select',
63
+ options: [400, 600, 650, 700],
64
+ }, icon: {
65
+ control: 'select',
66
+ options: icons.map(icon => icon.name),
67
+ }, iconPosition: {
68
+ options: ['start', 'end'],
69
+ control: {
70
+ type: 'radio',
71
+ },
72
+ }, type: {
73
+ options: ['submit', 'reset', 'button'],
74
+ control: {
75
+ type: 'radio',
76
+ },
77
+ } }), buttonAriaAttributeArgTypes),
78
+ args: Object.assign(Object.assign({}, Default.args), { variant: 'primary', colour: 'blue', size: 'medium', disabled: false, ariaLabel: '', ariaLabelledby: '', icon: '', iconPosition: 'start' }),
79
+ };
@@ -1,3 +1,3 @@
1
1
  :host {
2
- display: block;
2
+ display: inline;
3
3
  }
@@ -4,7 +4,7 @@ export class DsIcon {
4
4
  constructor() {
5
5
  this.name = undefined;
6
6
  this.colour = undefined;
7
- this.size = undefined;
7
+ this.size = '1.5rem';
8
8
  this.title = 'Icon';
9
9
  this.role = 'img';
10
10
  this.hidden = true;
@@ -31,8 +31,8 @@ export class DsIcon {
31
31
  }
32
32
  // get the colour of the icon
33
33
  getIconColour() {
34
- const cssVariable = `--colour-${this.colour}`;
35
- return getComputedStyle(document.documentElement).getPropertyValue(cssVariable) || this.colour;
34
+ const colour = this.colour ? `var(--${this.colour})` : 'currentColor';
35
+ return colour;
36
36
  }
37
37
  // set the attributes of the icon
38
38
  setIconAttributes(svgElement) {
@@ -52,7 +52,7 @@ export class DsIcon {
52
52
  }
53
53
  }
54
54
  render() {
55
- return (h(Fragment, { key: '8a2414880389617aa1f009bc7972201ee877ab65' }, h("span", { key: 'e7441e46ef7473d1e7d1a40b70eacc843ee742ea', class: "icon-container", innerHTML: this.getIcon(), "aria-hidden": this.hidden ? 'true' : 'false' })));
55
+ return (h(Fragment, { key: '8d8a1304c6293c49ecc830ec02227dff9852b8c5' }, h("span", { key: '83f992b6b58f24398fa84e0fe62a62e60ea72e1b', class: "icon-container", innerHTML: this.getIcon(), "aria-hidden": this.hidden ? 'true' : 'false' })));
56
56
  }
57
57
  static get is() { return "ds-icon"; }
58
58
  static get encapsulation() { return "shadow"; }
@@ -82,6 +82,8 @@ export class DsIcon {
82
82
  "tags": [],
83
83
  "text": ""
84
84
  },
85
+ "getter": false,
86
+ "setter": false,
85
87
  "attribute": "name",
86
88
  "reflect": false
87
89
  },
@@ -99,6 +101,8 @@ export class DsIcon {
99
101
  "tags": [],
100
102
  "text": ""
101
103
  },
104
+ "getter": false,
105
+ "setter": false,
102
106
  "attribute": "colour",
103
107
  "reflect": false
104
108
  },
@@ -116,8 +120,11 @@ export class DsIcon {
116
120
  "tags": [],
117
121
  "text": ""
118
122
  },
123
+ "getter": false,
124
+ "setter": false,
119
125
  "attribute": "size",
120
- "reflect": false
126
+ "reflect": false,
127
+ "defaultValue": "'1.5rem'"
121
128
  },
122
129
  "title": {
123
130
  "type": "string",
@@ -133,6 +140,8 @@ export class DsIcon {
133
140
  "tags": [],
134
141
  "text": ""
135
142
  },
143
+ "getter": false,
144
+ "setter": false,
136
145
  "attribute": "title",
137
146
  "reflect": false,
138
147
  "defaultValue": "'Icon'"
@@ -151,6 +160,8 @@ export class DsIcon {
151
160
  "tags": [],
152
161
  "text": ""
153
162
  },
163
+ "getter": false,
164
+ "setter": false,
154
165
  "attribute": "role",
155
166
  "reflect": false,
156
167
  "defaultValue": "'img'"
@@ -169,6 +180,8 @@ export class DsIcon {
169
180
  "tags": [],
170
181
  "text": ""
171
182
  },
183
+ "getter": false,
184
+ "setter": false,
172
185
  "attribute": "hidden",
173
186
  "reflect": false,
174
187
  "defaultValue": "true"
@@ -181,4 +194,3 @@ export class DsIcon {
181
194
  };
182
195
  }
183
196
  }
184
- //# sourceMappingURL=ds-icon.js.map
@@ -12,7 +12,7 @@ const meta = {
12
12
  name: 'Icon',
13
13
  },
14
14
  colour: {
15
- options: getColourVariables().map(colour => colour.name),
15
+ options: getColourVariables('palette').map(colour => colour.name),
16
16
  control: {
17
17
  type: 'select',
18
18
  },
@@ -53,4 +53,3 @@ Default.args = {
53
53
  title: 'Icon',
54
54
  hidden: true,
55
55
  };
56
- //# sourceMappingURL=ds-icon.stories.js.map
@@ -0,0 +1,186 @@
1
+ :root {
2
+ --ds-breakpoint-xSmall: 20rem;
3
+ --ds-breakpoint-small: 30rem;
4
+ --ds-breakpoint-medium: 60rem;
5
+ --ds-breakpoint-large: 75rem;
6
+ --ds-breakpoint-xLarge: 90rem;
7
+ }
8
+
9
+ :host {
10
+ display: block;
11
+ width: 288px;
12
+ }
13
+ @media (min-width: 75rem) {
14
+ :host {
15
+ width: 320px;
16
+ }
17
+ }
18
+
19
+ .label-container {
20
+ margin-block-end: var(--ds-spacing-2xSmall);
21
+ }
22
+ .label-container label {
23
+ font-family: var(--ds-fontFamily-body);
24
+ font-size: var(--ds-fontSize-16);
25
+ font-weight: var(--ds-fontWeight-semibold);
26
+ letter-spacing: var(--ds-letterSpacing-wide);
27
+ line-height: var(--ds-lineHeight-large);
28
+ color: var(--ds-textColor-default);
29
+ }
30
+ .label-container label.required::after {
31
+ content: " *";
32
+ color: var(--ds-textColor-secondary);
33
+ }
34
+ .label-container small {
35
+ font-family: var(--ds-fontFamily-body);
36
+ font-size: var(--ds-fontSize-14);
37
+ font-weight: var(--ds-fontWeight-regular);
38
+ letter-spacing: var(--ds-letterSpacing-wide);
39
+ line-height: var(--ds-lineHeight-large);
40
+ display: block;
41
+ margin-block-start: var(--ds-spacing-3xSmall);
42
+ color: var(--ds-textColor-secondary);
43
+ }
44
+
45
+ .input-container {
46
+ box-sizing: border-box;
47
+ width: 100%;
48
+ display: inline-flex;
49
+ position: relative;
50
+ align-items: center;
51
+ border-width: var(--ds-borderWidth-thin);
52
+ border-style: solid;
53
+ border-color: var(--ds-borderColor-default);
54
+ padding-inline: var(--ds-spacing-xSmall);
55
+ }
56
+ .input-container.invalid {
57
+ background-color: var(--ds-palette-danger-light);
58
+ border-color: var(--ds-borderColor-danger);
59
+ }
60
+ .input-container.valid {
61
+ background-color: var(--ds-palette-success-light);
62
+ border-color: var(--ds-borderColor-success);
63
+ }
64
+ .input-container.readonly, .input-container.disabled {
65
+ background-color: var(--ds-bgColor-disabled-onLight);
66
+ border-color: var(--ds-borderColor-disabled-onLight);
67
+ }
68
+ .input-container:has(input:active) {
69
+ outline: none;
70
+ }
71
+ .input-container:has(input:active):not:has(input:disabled, input:readonly) {
72
+ border-color: var(--ds-borderColor-primary);
73
+ }
74
+ .input-container.active:not(.input-container.disabled, .input-container.readonly) {
75
+ border-color: var(--ds-borderColor-primary);
76
+ }
77
+ .input-container:hover:not(.input-container.disabled, .input-container.readonly, .input-container.active) {
78
+ border-color: var(--ds-borderColor-black);
79
+ }
80
+ .input-container:focus-within {
81
+ outline-width: var(--ds-borderWidth-thin);
82
+ outline-offset: 1px;
83
+ outline-style: solid;
84
+ outline-color: var(--ds-palette-black);
85
+ }
86
+ .input-container:focus-within:not(.input-container:focus-within.invalid, .input-container:focus-within.valid, .input-container:focus-within.readonly) {
87
+ border-color: var(--ds-borderColor-primary);
88
+ }
89
+ .input-container:focus-within * > ds-button.suffix > button:focus-visible {
90
+ background-clip: padding-box;
91
+ outline-offset: -5px;
92
+ box-shadow: none;
93
+ height: var(--ds-spacing-xLarge);
94
+ background-color: var(--ds-bgColor-transparent-onLight-hover);
95
+ }
96
+ .input-container > input {
97
+ font-family: var(--ds-fontFamily-body);
98
+ font-size: var(--ds-fontSize-16);
99
+ font-weight: var(--ds-fontWeight-regular);
100
+ letter-spacing: var(--ds-letterSpacing-wide);
101
+ line-height: var(--ds-lineHeight-large);
102
+ width: 100%;
103
+ box-sizing: border-box;
104
+ background-color: unset;
105
+ flex-grow: 1;
106
+ height: var(--ds-spacing-xLarge);
107
+ line-height: var(--ds-fontSize-24);
108
+ color: var(--ds-textColor-default);
109
+ padding-block: var(--ds-spacing-4xSmall);
110
+ border: none;
111
+ }
112
+ .input-container > input:disabled {
113
+ color: var(--ds-textColor-disabled-onLight);
114
+ }
115
+ .input-container > input:disabled::placeholder {
116
+ color: var(--ds-textColor-disabled-onLight);
117
+ }
118
+ .input-container > input::placeholder {
119
+ font-family: var(--ds-fontFamily-body);
120
+ font-size: var(--ds-fontSize-16);
121
+ font-weight: var(--ds-fontWeight-regular);
122
+ letter-spacing: var(--ds-letterSpacing-wide);
123
+ line-height: var(--ds-lineHeight-large);
124
+ color: var(--ds-textColor-secondary);
125
+ }
126
+ .input-container > input:focus {
127
+ outline: none;
128
+ border: none;
129
+ }
130
+ .input-container > input[type=number] {
131
+ -moz-appearance: textfield;
132
+ }
133
+ .input-container > input::-webkit-search-decoration, .input-container > input::-webkit-search-cancel-button, .input-container > input::-webkit-search-results-button, .input-container > input::-webkit-search-results-decoration, .input-container > input::-webkit-inner-spin-button, .input-container > input::-webkit-outer-spin-button {
134
+ -webkit-appearance: none;
135
+ margin: 0;
136
+ }
137
+ .input-container:has(span.prefix, ds-icon.prefix) {
138
+ padding-inline-start: var(--ds-spacing-2xSmall);
139
+ }
140
+ .input-container:has(span.prefix, ds-icon.prefix) > input {
141
+ padding-inline-start: var(--ds-spacing-2xSmall);
142
+ }
143
+ .input-container:has(ds-button.suffix) {
144
+ padding-inline-end: unset;
145
+ }
146
+ .input-container span.prefix, .input-container span.suffix {
147
+ color: var(--ds-palette-black-70);
148
+ }
149
+ .input-container ds-icon.prefix, .input-container ::slotted([slot=prefix]) {
150
+ height: 1.5rem;
151
+ color: var(--ds-textColor-default);
152
+ }
153
+ .input-container ds-button.suffix {
154
+ margin-top: calc(var(--ds-spacing-3xSmall) * -1);
155
+ margin-right: calc(var(--ds-spacing-4xSmall) * -1);
156
+ max-height: 40px;
157
+ }
158
+
159
+ .error-text-container,
160
+ .success-text-container {
161
+ display: flex;
162
+ align-items: center;
163
+ margin-top: var(--ds-spacing-2xSmall);
164
+ gap: var(--ds-spacing-2xSmall);
165
+ }
166
+ .error-text-container ds-icon,
167
+ .success-text-container ds-icon {
168
+ display: block;
169
+ height: 1.5rem;
170
+ }
171
+ .error-text-container small,
172
+ .success-text-container small {
173
+ font-family: var(--ds-fontFamily-body);
174
+ font-size: var(--ds-fontSize-16);
175
+ font-weight: var(--ds-fontWeight-regular);
176
+ letter-spacing: var(--ds-letterSpacing-wide);
177
+ line-height: var(--ds-lineHeight-large);
178
+ }
179
+
180
+ .error-text-container {
181
+ color: var(--ds-textColor-danger);
182
+ }
183
+
184
+ .success-text-container {
185
+ color: var(--ds-textColor-success);
186
+ }
@@ -0,0 +1,24 @@
1
+ import { html } from "lit";
2
+ const meta = {
3
+ title: 'Base Components/TextInput/Examples',
4
+ component: 'ds-text-input',
5
+ };
6
+ export default meta;
7
+ export const CustomWidth = {
8
+ render: () => html `<div>
9
+ <ds-text-input label='Smaller input' style='width: 150px; margin-bottom: 1rem'></ds-text-input>
10
+ <ds-text-input label='Full width input' style='width: 100%'></ds-text-input>
11
+ </div>`,
12
+ };
13
+ export const UsingSlots = {
14
+ render: () => html `
15
+ <ds-text-input aria-label='Slotted label'>
16
+ <label id='label' slot='label'><b>Slotted label</b></label>
17
+ <p slot='help-text'>Lorem ipsum</p>
18
+ <ds-icon name='archive' slot='prefix'></ds-icon>
19
+ <small slot='suffix' style='margin-right: var(--spacing-2xSmall)'>Suffix</small>
20
+ <div slot='error-text'>Error text slot</div>
21
+ <div slot='success-text'>Success text slot</div>
22
+ </ds-text-input>
23
+ `,
24
+ };
@@ -0,0 +1,126 @@
1
+ import { getDsElem } from "../../../utils/tests/testUtils";
2
+ import { expect, userEvent, waitFor } from "@storybook/test";
3
+ const meta = {
4
+ title: 'Base Components/TextInput/Features',
5
+ component: 'ds-text-input',
6
+ };
7
+ export default meta;
8
+ export const WithPlaceholder = {};
9
+ WithPlaceholder.args = {
10
+ label: 'Label',
11
+ placeholder: 'Placeholder',
12
+ };
13
+ export const WithAssistiveText = {};
14
+ WithAssistiveText.args = {
15
+ label: 'Label',
16
+ assistiveText: 'Assistive text',
17
+ };
18
+ export const Disabled = {};
19
+ Disabled.args = {
20
+ label: 'Label',
21
+ disabled: true,
22
+ };
23
+ export const ReadOnly = {};
24
+ ReadOnly.args = {
25
+ label: 'Label',
26
+ value: 'Input text',
27
+ readonly: true,
28
+ };
29
+ export const Required = {};
30
+ Required.args = {
31
+ label: 'Label',
32
+ required: true,
33
+ };
34
+ export const Valid = {};
35
+ Valid.args = {
36
+ label: 'Label',
37
+ valid: true,
38
+ successText: 'Success text',
39
+ };
40
+ export const Invalid = {};
41
+ Invalid.args = {
42
+ label: 'Label',
43
+ invalid: true,
44
+ errorText: 'Error text',
45
+ };
46
+ export const WithIcon = {
47
+ args: {
48
+ label: 'Search',
49
+ icon: 'info',
50
+ helpText: 'Assistive text',
51
+ type: 'email',
52
+ },
53
+ };
54
+ export const PasswordInput = {
55
+ args: {
56
+ label: 'Label',
57
+ type: 'password',
58
+ actionButtonAriaLabel: 'Action button',
59
+ },
60
+ play: async ({ canvasElement, step }) => {
61
+ const dsElem = await getDsElem(canvasElement, 'ds-text-input');
62
+ const inputElem = dsElem.querySelector('input');
63
+ const suffixButton = dsElem.querySelector('ds-button.suffix');
64
+ await step('Input type should be password', () => {
65
+ expect(inputElem.type).toBe('password');
66
+ });
67
+ await step('Has suffix button', async () => {
68
+ expect(suffixButton).toBeInTheDocument();
69
+ });
70
+ await step('Clicking suffix button should set input type to text', async () => {
71
+ userEvent.click(suffixButton);
72
+ await waitFor(() => {
73
+ expect(inputElem.type).toBe('text');
74
+ });
75
+ });
76
+ await step('Clicking suffix button again should set input type to password', async () => {
77
+ userEvent.click(suffixButton);
78
+ await waitFor(() => {
79
+ expect(inputElem.type).toBe('password');
80
+ });
81
+ });
82
+ },
83
+ };
84
+ export const SearchInput = {
85
+ args: {
86
+ label: 'Label',
87
+ type: 'search',
88
+ actionButtonAriaLabel: 'Action button',
89
+ },
90
+ play: async ({ canvasElement, step }) => {
91
+ const dsElem = await getDsElem(canvasElement, 'ds-text-input');
92
+ await step('Has prefix icon', async () => {
93
+ const prefixIcon = dsElem.querySelector('ds-icon.prefix');
94
+ expect(prefixIcon).toBeInTheDocument();
95
+ });
96
+ await step('Enter search', async () => {
97
+ await userEvent.type(dsElem.querySelector('input'), 'search');
98
+ });
99
+ const clearBtn = dsElem.querySelector('ds-button.suffix');
100
+ await step('Clear button is visible', async () => {
101
+ expect(clearBtn).toBeDefined();
102
+ });
103
+ await step('Clicking clear button should clear the input', async () => {
104
+ userEvent.click(clearBtn);
105
+ await waitFor(() => {
106
+ expect(document.querySelector('ds-button')).toBeNull();
107
+ });
108
+ });
109
+ },
110
+ };
111
+ export const PrefixText = {
112
+ args: {
113
+ label: 'Phone number',
114
+ prefixText: '+358',
115
+ type: 'tel',
116
+ hiddenAssistiveText: 'Without the country code',
117
+ },
118
+ };
119
+ export const SuffixText = {
120
+ args: {
121
+ label: 'Timeout',
122
+ suffixText: 'minutes',
123
+ type: 'number',
124
+ hiddenAssistiveText: 'Enter the number of minutes',
125
+ },
126
+ };