@westpac/ui 0.24.1 → 0.25.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 (182) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/assets/icons/filled/cancel-card-filled.svg +4 -0
  3. package/assets/icons/filled/circle-filled.svg +3 -0
  4. package/assets/icons/filled/quick-balance-filled.svg +3 -3
  5. package/assets/icons/filled/target-filled.svg +5 -0
  6. package/assets/icons/outlined/cancel-card-outlined.svg +4 -0
  7. package/assets/icons/outlined/circle-outlined.svg +3 -0
  8. package/assets/icons/outlined/quick-balance-outlined.svg +4 -6
  9. package/assets/icons/outlined/target-outlined.svg +5 -0
  10. package/dist/component-type.json +1 -1
  11. package/dist/components/accordion/accordion.component.d.ts +2 -12
  12. package/dist/components/accordion/accordion.styles.d.ts +7 -1
  13. package/dist/components/accordion/components/accordion-item/accordion-item.styles.d.ts +38 -1
  14. package/dist/components/alert/alert.styles.d.ts +38 -1
  15. package/dist/components/autocomplete/autocomplete.styles.d.ts +122 -1
  16. package/dist/components/autocomplete/components/autocomplete-item/autocomplete-item.component.d.ts +0 -1
  17. package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.d.ts +13 -1
  18. package/dist/components/badge/badge.component.d.ts +1 -1
  19. package/dist/components/badge/badge.styles.d.ts +30 -1
  20. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.d.ts +40 -22
  21. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.d.ts +7 -1
  22. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.d.ts +4 -3
  23. package/dist/components/breadcrumb/components/breadcrumb-item/breadcrumb-item.component.d.ts +3 -3
  24. package/dist/components/breadcrumb/components/breadcrumb-item/breadcrumb-item.styles.d.ts +12 -1
  25. package/dist/components/button/button.component.d.ts +7 -7
  26. package/dist/components/button/button.component.js +5 -4
  27. package/dist/components/button/button.styles.d.ts +67 -1
  28. package/dist/components/button/button.styles.js +9 -9
  29. package/dist/components/button/button.types.d.ts +7 -0
  30. package/dist/components/button-dropdown/button-dropdown.styles.d.ts +24 -1
  31. package/dist/components/button-dropdown/components/button-dropdown-heading/button-dropdown-heading.styles.d.ts +5 -1
  32. package/dist/components/button-dropdown/components/button-dropdown-panel/button-dropdown-panel.styles.d.ts +12 -1
  33. package/dist/components/button-group/button-group.styles.d.ts +25 -12
  34. package/dist/components/button-group/components/button-group-button/button-group-button.styles.d.ts +25 -1
  35. package/dist/components/checkbox-group/checkbox-group.styles.d.ts +22 -1
  36. package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.d.ts +1 -1
  37. package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.styles.d.ts +45 -1
  38. package/dist/components/circle/circle.styles.d.ts +3 -1
  39. package/dist/components/collapsible/collapsible.styles.d.ts +12 -1
  40. package/dist/components/compacta/compacta.styles.d.ts +20 -1
  41. package/dist/components/date-picker/date-picker.styles.d.ts +14 -1
  42. package/dist/components/error-message/error-message.styles.d.ts +26 -14
  43. package/dist/components/field/field.styles.d.ts +3 -1
  44. package/dist/components/filter/components/filter-buttons/filter-buttons.component.d.ts +1 -1
  45. package/dist/components/filter/components/filter-buttons/filter-buttons.component.js +183 -11
  46. package/dist/components/filter/components/filter-buttons/filter-buttons.styles.d.ts +55 -5
  47. package/dist/components/filter/components/filter-buttons/filter-buttons.styles.js +20 -1
  48. package/dist/components/filter/components/filter-buttons/filter-buttons.types.d.ts +0 -4
  49. package/dist/components/flexi-cell/components/flexi-cell-adornment/flexi-cell-adornment.styles.d.ts +17 -1
  50. package/dist/components/flexi-cell/components/flexi-cell-body/flexi-cell-body.styles.d.ts +15 -1
  51. package/dist/components/flexi-cell/components/flexi-cell-button/flexi-cell-button.styles.d.ts +5 -1
  52. package/dist/components/flexi-cell/components/flexi-cell-button/flexi-cell-button.types.d.ts +0 -1
  53. package/dist/components/flexi-cell/components/flexi-cell-circle/flexi-cell-circle.styles.d.ts +5 -1
  54. package/dist/components/flexi-cell/components/flexi-cell-footer/flexi-cell-footer.styles.d.ts +3 -1
  55. package/dist/components/flexi-cell/components/flexi-cell-hint/flexi-cell-hint.styles.d.ts +7 -1
  56. package/dist/components/flexi-cell/components/flexi-cell-label/flexi-cell-label.styles.d.ts +11 -1
  57. package/dist/components/flexi-cell/flexi-cell.component.js +4 -2
  58. package/dist/components/flexi-cell/flexi-cell.styles.d.ts +41 -1
  59. package/dist/components/flexi-cell/flexi-cell.types.d.ts +4 -0
  60. package/dist/components/footer/footer.styles.d.ts +26 -1
  61. package/dist/components/form/components/form-chit-chat/form-chit-chat.styles.d.ts +1 -5
  62. package/dist/components/form/components/form-group/form-group.styles.d.ts +12 -1
  63. package/dist/components/form/components/form-section/form-section.styles.d.ts +8 -1
  64. package/dist/components/grid/components/grid-container/grid-container.styles.d.ts +8 -1
  65. package/dist/components/grid/components/grid-item/grid-item.styles.d.ts +40 -1
  66. package/dist/components/grid/grid.styles.d.ts +3 -1
  67. package/dist/components/header/header.styles.d.ts +41 -1
  68. package/dist/components/heading/heading.styles.d.ts +24 -1
  69. package/dist/components/hint/hint.styles.d.ts +8 -1
  70. package/dist/components/icon/components/cancel-card-icon.d.ts +2 -0
  71. package/dist/components/icon/components/cancel-card-icon.js +48 -0
  72. package/dist/components/icon/components/circle-icon.d.ts +2 -0
  73. package/dist/components/icon/components/circle-icon.js +42 -0
  74. package/dist/components/icon/components/quick-balance-icon.js +20 -16
  75. package/dist/components/icon/components/target-icon.d.ts +2 -0
  76. package/dist/components/icon/components/target-icon.js +37 -0
  77. package/dist/components/icon/icon.styles.d.ts +33 -1
  78. package/dist/components/icon/index.d.ts +3 -0
  79. package/dist/components/icon/index.js +3 -0
  80. package/dist/components/input/input.component.d.ts +1 -1
  81. package/dist/components/input/input.styles.d.ts +35 -1
  82. package/dist/components/input-group/components/input-group-add-ons/components/input-group-add-on-default-add-on/input-group-add-on-default-add-on.styles.d.ts +1 -5
  83. package/dist/components/input-group/components/input-group-add-ons/components/input-group-add-on-icon-add-on/input-group-add-on-icon-add-on.styles.d.ts +14 -1
  84. package/dist/components/input-group/components/input-group-add-ons/components/input-group-add-on-text-add-on/input-group-add-on-text-add-on.styles.d.ts +14 -1
  85. package/dist/components/input-group/components/input-group-add-ons/input-group-add-ons.styles.d.ts +12 -1
  86. package/dist/components/input-group/components/input-group-supporting-text/input-group-supporting-text.styles.d.ts +1 -5
  87. package/dist/components/input-group/input-group.styles.d.ts +62 -1
  88. package/dist/components/label/label.styles.d.ts +12 -1
  89. package/dist/components/link/link.component.d.ts +6 -6
  90. package/dist/components/link/link.styles.d.ts +29 -1
  91. package/dist/components/list/components/list-item/list-item.component.d.ts +7 -7
  92. package/dist/components/list/components/list-item/list-item.styles.d.ts +74 -1
  93. package/dist/components/list/list.styles.d.ts +22 -1
  94. package/dist/components/list/list.utils.d.ts +0 -1
  95. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.d.ts +16 -1
  96. package/dist/components/modal/components/modal-backdrop/modal-backdrop.types.d.ts +0 -1
  97. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.d.ts +23 -1
  98. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.d.ts +25 -1
  99. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.d.ts +39 -1
  100. package/dist/components/modal/components/modal-dialog/modal-dialog.types.d.ts +0 -1
  101. package/dist/components/pagination/components/pagination-item/pagination-item.styles.d.ts +20 -1
  102. package/dist/components/pagination/pagination.hooks.d.ts +2 -3
  103. package/dist/components/pagination/pagination.styles.d.ts +6 -1
  104. package/dist/components/panel/components/panel-body/panel-body.styles.d.ts +5 -1
  105. package/dist/components/panel/components/panel-footer/panel-footer.styles.d.ts +5 -1
  106. package/dist/components/panel/panel.styles.d.ts +16 -1
  107. package/dist/components/pass-code/pass-code.styles.d.ts +23 -12
  108. package/dist/components/pass-code-view/pass-code-view.styles.d.ts +9 -1
  109. package/dist/components/pictogram/components/informative/target-pictogram.d.ts +2 -0
  110. package/dist/components/pictogram/components/informative/target-pictogram.js +46 -0
  111. package/dist/components/pictogram/index.d.ts +1 -0
  112. package/dist/components/pictogram/index.js +1 -0
  113. package/dist/components/pictogram/pictogram.styles.d.ts +16 -2
  114. package/dist/components/popover/components/panel/panel.styles.d.ts +22 -1
  115. package/dist/components/popover/popover.styles.d.ts +13 -1
  116. package/dist/components/popover/popover.utils.d.ts +1 -1
  117. package/dist/components/progress-bar/progress-bar.styles.d.ts +18 -1
  118. package/dist/components/progress-indicator/progress-indicator.styles.d.ts +15 -1
  119. package/dist/components/progress-rope/components/progress-rope-group-step/progress-rope-group-step.styles.d.ts +42 -1
  120. package/dist/components/progress-rope/components/progress-rope-step/progress-rope-step.styles.d.ts +84 -1
  121. package/dist/components/progress-rope/progress-rope.styles.d.ts +1 -5
  122. package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.component.d.ts +1 -1
  123. package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.styles.d.ts +47 -1
  124. package/dist/components/radio-group/radio-group.styles.d.ts +22 -1
  125. package/dist/components/repeater/repeater.styles.d.ts +29 -1
  126. package/dist/components/select/select.styles.d.ts +36 -1
  127. package/dist/components/selector/components/selector-button-group/components/selector-button-group-option/selector-button-group-option.component.d.ts +2 -5
  128. package/dist/components/selector/components/selector-button-group/components/selector-button-group-option/selector-button-group-option.styles.d.ts +28 -1
  129. package/dist/components/selector/components/selector-button-group/selector-button-group.component.d.ts +0 -1
  130. package/dist/components/selector/components/selector-button-group/selector-button-group.styles.d.ts +8 -1
  131. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.styles.d.ts +33 -1
  132. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.styles.d.ts +3 -1
  133. package/dist/components/selector/components/selector-label/selector-label.styles.d.ts +1 -5
  134. package/dist/components/selector/components/selector-link-group/components/selector-link-group-option/selector-link-group-option.component.d.ts +2 -5
  135. package/dist/components/selector/components/selector-link-group/components/selector-link-group-option/selector-link-group-option.styles.d.ts +22 -1
  136. package/dist/components/selector/components/selector-link-group/selector-link-group.component.d.ts +1 -2
  137. package/dist/components/selector/components/selector-link-group/selector-link-group.styles.d.ts +8 -1
  138. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.styles.d.ts +33 -1
  139. package/dist/components/selector/components/selector-radio-group/selector-radio-group.styles.d.ts +8 -1
  140. package/dist/components/skip-link/skip-link.styles.d.ts +1 -5
  141. package/dist/components/switch/switch.styles.d.ts +48 -1
  142. package/dist/components/symbol/symbol.styles.d.ts +3 -1
  143. package/dist/components/table/components/table-body/table-body.styles.d.ts +3 -1
  144. package/dist/components/table/components/table-caption/table-caption.styles.d.ts +3 -1
  145. package/dist/components/table/components/table-cell/table-cell.styles.d.ts +21 -1
  146. package/dist/components/table/components/table-footer/table-footer.styles.d.ts +11 -1
  147. package/dist/components/table/components/table-header/table-header.styles.d.ts +3 -1
  148. package/dist/components/table/components/table-header-cell/table-header-cell.styles.d.ts +11 -1
  149. package/dist/components/table/components/table-header-row/table-header-row.styles.d.ts +3 -1
  150. package/dist/components/table/components/table-row/table-row.styles.d.ts +19 -1
  151. package/dist/components/table/table.styles.d.ts +6 -1
  152. package/dist/components/tabs/components/tabs-tab/tabs-tab.styles.d.ts +27 -1
  153. package/dist/components/tabs/components/tabs-tab-panel/tabs-tab-panel.styles.d.ts +11 -1
  154. package/dist/components/tabs/tabs.component.d.ts +0 -1
  155. package/dist/components/tabs/tabs.styles.d.ts +28 -1
  156. package/dist/components/textarea/textarea.styles.d.ts +35 -1
  157. package/dist/components/visually-hidden/visually-hidden.styles.d.ts +1 -5
  158. package/dist/components/well/well.styles.d.ts +8 -1
  159. package/dist/css/westpac-ui.css +499 -124
  160. package/dist/css/westpac-ui.min.css +499 -124
  161. package/dist/tailwind/constants/colors.d.ts +5 -5
  162. package/dist/tailwind/tailwind-plugin.d.ts +1 -1
  163. package/dist/tailwind/tailwind-transformer.d.ts +1 -1
  164. package/dist/tailwind/themes/index.d.ts +7 -7
  165. package/dist/tailwind/utils/generate-font-components.d.ts +1 -1
  166. package/package.json +6 -5
  167. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.ts +4 -3
  168. package/src/components/button/button.component.tsx +6 -5
  169. package/src/components/button/button.styles.ts +9 -9
  170. package/src/components/button/button.types.ts +8 -0
  171. package/src/components/filter/components/filter-buttons/filter-buttons.component.tsx +206 -19
  172. package/src/components/filter/components/filter-buttons/filter-buttons.styles.ts +20 -1
  173. package/src/components/filter/components/filter-buttons/filter-buttons.types.ts +0 -4
  174. package/src/components/flexi-cell/flexi-cell.component.tsx +4 -1
  175. package/src/components/flexi-cell/flexi-cell.types.ts +4 -0
  176. package/src/components/icon/components/cancel-card-icon.tsx +41 -0
  177. package/src/components/icon/components/circle-icon.tsx +39 -0
  178. package/src/components/icon/components/quick-balance-icon.tsx +19 -23
  179. package/src/components/icon/components/target-icon.tsx +30 -0
  180. package/src/components/icon/index.ts +3 -0
  181. package/src/components/pictogram/components/informative/target-pictogram.tsx +40 -0
  182. package/src/components/pictogram/index.ts +1 -0
@@ -61,7 +61,7 @@ export declare const COLORS: {
61
61
  900: string;
62
62
  DEFAULT: string;
63
63
  };
64
- primary: {
64
+ focus: {
65
65
  100: string;
66
66
  50: string;
67
67
  200: string;
@@ -74,7 +74,7 @@ export declare const COLORS: {
74
74
  900: string;
75
75
  DEFAULT: string;
76
76
  };
77
- hero: {
77
+ primary: {
78
78
  100: string;
79
79
  50: string;
80
80
  200: string;
@@ -87,7 +87,7 @@ export declare const COLORS: {
87
87
  900: string;
88
88
  DEFAULT: string;
89
89
  };
90
- background: {
90
+ hero: {
91
91
  100: string;
92
92
  50: string;
93
93
  200: string;
@@ -100,7 +100,7 @@ export declare const COLORS: {
100
100
  900: string;
101
101
  DEFAULT: string;
102
102
  };
103
- borderDark: {
103
+ background: {
104
104
  100: string;
105
105
  50: string;
106
106
  200: string;
@@ -113,7 +113,7 @@ export declare const COLORS: {
113
113
  900: string;
114
114
  DEFAULT: string;
115
115
  };
116
- focus: {
116
+ borderDark: {
117
117
  100: string;
118
118
  50: string;
119
119
  200: string;
@@ -5,7 +5,7 @@ import { type PluginOptions } from './types/tailwind.types.js';
5
5
  export declare const WestpacUIKitBasePlugin: {
6
6
  (options: PluginOptions): {
7
7
  handler: import("tailwindcss/types/config.js").PluginCreator;
8
- config?: Partial<import("tailwindcss").Config> | undefined;
8
+ config?: Partial<import("tailwindcss").Config>;
9
9
  };
10
10
  __isOptionsFunction: true;
11
11
  };
@@ -2,7 +2,7 @@ import { type Config } from 'tailwindcss';
2
2
  export declare const withGEL: (config: Config) => {
3
3
  safelist: (string | {
4
4
  pattern: RegExp;
5
- variants?: string[] | undefined;
5
+ variants?: string[];
6
6
  } | undefined)[];
7
7
  plugins: (import("tailwindcss/types/config.js").PluginCreator | {
8
8
  handler: import("tailwindcss/types/config.js").PluginCreator;
@@ -59,7 +59,7 @@ export declare const THEMES: {
59
59
  900: string;
60
60
  DEFAULT: string;
61
61
  };
62
- primary: {
62
+ focus: {
63
63
  100: string;
64
64
  50: string;
65
65
  200: string;
@@ -72,7 +72,7 @@ export declare const THEMES: {
72
72
  900: string;
73
73
  DEFAULT: string;
74
74
  };
75
- hero: {
75
+ primary: {
76
76
  100: string;
77
77
  50: string;
78
78
  200: string;
@@ -85,7 +85,7 @@ export declare const THEMES: {
85
85
  900: string;
86
86
  DEFAULT: string;
87
87
  };
88
- white: {
88
+ hero: {
89
89
  100: string;
90
90
  50: string;
91
91
  200: string;
@@ -98,7 +98,7 @@ export declare const THEMES: {
98
98
  900: string;
99
99
  DEFAULT: string;
100
100
  };
101
- black: {
101
+ white: {
102
102
  100: string;
103
103
  50: string;
104
104
  200: string;
@@ -111,7 +111,7 @@ export declare const THEMES: {
111
111
  900: string;
112
112
  DEFAULT: string;
113
113
  };
114
- background: {
114
+ black: {
115
115
  100: string;
116
116
  50: string;
117
117
  200: string;
@@ -124,7 +124,7 @@ export declare const THEMES: {
124
124
  900: string;
125
125
  DEFAULT: string;
126
126
  };
127
- borderDark: {
127
+ background: {
128
128
  100: string;
129
129
  50: string;
130
130
  200: string;
@@ -137,7 +137,7 @@ export declare const THEMES: {
137
137
  900: string;
138
138
  DEFAULT: string;
139
139
  };
140
- focus: {
140
+ borderDark: {
141
141
  100: string;
142
142
  50: string;
143
143
  200: string;
@@ -2,4 +2,4 @@ import { CSSRuleObject, PluginAPI } from 'tailwindcss/types/config.js';
2
2
  export declare const generateFontComponents: (typographySizes: Record<string, {
3
3
  fontSize: string;
4
4
  lineHeight: string;
5
- }>, theme: PluginAPI['theme']) => CSSRuleObject[];
5
+ }>, theme: PluginAPI["theme"]) => CSSRuleObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westpac/ui",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -235,6 +235,7 @@
235
235
  "chokidar": "^3.5.3",
236
236
  "colorjs.io": "~0.4.5",
237
237
  "cross-env": "~7.0.3",
238
+ "csstype": "~3.1.3",
238
239
  "eslint": "^8.56.0",
239
240
  "eslint-plugin-storybook": "~0.6.15",
240
241
  "glob": "~10.3.3",
@@ -249,14 +250,14 @@
249
250
  "react-dom": "^18.2.0",
250
251
  "shx": "^0.3.4",
251
252
  "storybook": "^7.6.4",
252
- "tailwind-variants": "~0.1.13",
253
+ "tailwind-variants": "~0.2.1",
253
254
  "tailwindcss": "~3.3.2",
254
255
  "tailwindcss-themer": "~3.1.0",
255
256
  "ts-node": "~10.9.1",
256
- "typescript": "^5.1.6",
257
+ "typescript": "^5.5.4",
257
258
  "vite": "^5.2.12",
258
259
  "vitest": "^0.30.1",
259
- "@westpac/eslint-config": "~0.2.2",
260
+ "@westpac/eslint-config": "~0.4.0",
260
261
  "@westpac/test-config": "~0.0.0",
261
262
  "@westpac/ts-config": "~0.0.0"
262
263
  },
@@ -281,7 +282,7 @@
281
282
  "@types/node": "~20.12.12",
282
283
  "colorjs.io": "~0.4.5",
283
284
  "react": ">=18.2.0",
284
- "tailwind-variants": "~0.1.13",
285
+ "tailwind-variants": "~0.2.1",
285
286
  "tailwindcss": "~3.3.2",
286
287
  "tailwindcss-themer": "~3.1.0"
287
288
  },
@@ -1,4 +1,5 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { Property } from 'csstype';
2
+ import { ReactNode } from 'react';
2
3
  import { AriaModalOverlayProps } from 'react-aria';
3
4
  import { OverlayTriggerState } from 'react-stately';
4
5
 
@@ -10,7 +11,7 @@ export type ModalProps = AriaModalOverlayProps & {
10
11
  /**
11
12
  * Height of the Modal
12
13
  */
13
- height?: CSSProperties['height'];
14
+ height?: Property.Height;
14
15
  /**
15
16
  * Element where the modal will be rendered, by default it will be into the body
16
17
  */
@@ -22,5 +23,5 @@ export type ModalProps = AriaModalOverlayProps & {
22
23
  /**
23
24
  * Width of the Modal
24
25
  */
25
- width?: CSSProperties['width'];
26
+ width?: Property.Width;
26
27
  };
@@ -4,7 +4,7 @@ import React, { Ref, forwardRef, useMemo } from 'react';
4
4
  import { mergeProps, useFocusRing } from 'react-aria';
5
5
 
6
6
  import { styles as buttonStyles } from './button.styles.js';
7
- import { type ButtonProps } from './button.types.js';
7
+ import { type ButtonProps, ButtonRef } from './button.types.js';
8
8
  import { getIconSize } from './button.utils.js';
9
9
 
10
10
  function BaseButton(
@@ -19,13 +19,14 @@ function BaseButton(
19
19
  iconBefore: IconBefore,
20
20
  iconAfter: IconAfter,
21
21
  iconColor,
22
+ iconSize,
22
23
  children,
23
24
  ...props
24
25
  }: ButtonProps,
25
- ref: Ref<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement>,
26
+ ref: Ref<ButtonRef>,
26
27
  ) {
27
28
  const { isFocusVisible, focusProps } = useFocusRing();
28
- const iconSize = useMemo(() => getIconSize(size), [size]);
29
+ const btnIconSize = useMemo(() => iconSize || getIconSize(size), [iconSize, size]);
29
30
  const styles = buttonStyles({
30
31
  size,
31
32
  look,
@@ -38,9 +39,9 @@ function BaseButton(
38
39
 
39
40
  return (
40
41
  <Tag ref={ref} className={styles.base({ className })} {...mergeProps(props, focusProps)}>
41
- {IconBefore && <IconBefore size={iconSize} className={styles.iconBefore()} color={iconColor} aria-hidden />}
42
+ {IconBefore && <IconBefore size={btnIconSize} className={styles.iconBefore()} color={iconColor} aria-hidden />}
42
43
  <span className={styles.text()}>{children}</span>
43
- {IconAfter && <IconAfter size={iconSize} className={styles.iconAfter()} color={iconColor} aria-hidden />}
44
+ {IconAfter && <IconAfter size={btnIconSize} className={styles.iconAfter()} color={iconColor} aria-hidden />}
44
45
  </Tag>
45
46
  );
46
47
  }
@@ -6,7 +6,7 @@ import { tv } from 'tailwind-variants';
6
6
  export const styles = tv(
7
7
  {
8
8
  slots: {
9
- base: 'items-center justify-center rounded leading-[1.5] transition-[background] disabled:pointer-events-none disabled:opacity-50 group-first/add-on-before:rounded-r-none group-last/add-on-after:rounded-l-none',
9
+ base: 'items-center justify-center rounded leading-normal transition-[background] disabled:pointer-events-none disabled:opacity-50 group-first/add-on-before:rounded-r-none group-last/add-on-after:rounded-l-none',
10
10
  iconBefore: '',
11
11
  iconAfter: '',
12
12
  dropdown: 'ml-[0.4em]',
@@ -14,17 +14,17 @@ export const styles = tv(
14
14
  },
15
15
  variants: {
16
16
  size: {
17
- small: { base: 'typography-body-10 px-2 pb-[0.25rem] pt-0.5 active-theme-rams:before:h-[0.0625rem]' },
18
- medium: { base: 'typography-body-9 px-2 py-[0.3125rem] active-theme-rams:before:h-[0.125rem]' },
19
- large: { base: 'typography-body-9 px-2.5 py-[0.5rem] active-theme-rams:before:h-0.5' },
20
- xlarge: { base: 'typography-body-8 px-3 pb-[0.625rem] pt-1.5 active-theme-rams:before:h-[0.25rem]' },
17
+ small: { base: 'typography-body-10 active-theme-rams:before:h-[0.0625rem] px-2 pb-1 pt-0.5' },
18
+ medium: { base: 'typography-body-9 active-theme-rams:before:h-0.5 px-2 py-[0.3125rem]' },
19
+ large: { base: 'typography-body-9 active-theme-rams:before:h-0.5 px-2.5 py-2' },
20
+ xlarge: { base: 'typography-body-8 active-theme-rams:before:h-1 px-3 pb-2.5 pt-1.5' },
21
21
  },
22
22
  look: {
23
23
  primary: {
24
- base: 'relative border border-primary bg-primary text-white hover:bg-primary-70 active:bg-primary-50 active-theme-rams:border-b-pop active-theme-rams:before:absolute active-theme-rams:before:bottom-0 active-theme-rams:before:block active-theme-rams:before:w-full active-theme-rams:before:bg-pop',
24
+ base: 'border-primary bg-primary hover:bg-primary-70 active:bg-primary-50 active-theme-rams:border-b-pop active-theme-rams:before:absolute active-theme-rams:before:bottom-0 active-theme-rams:before:block active-theme-rams:before:w-full active-theme-rams:before:bg-pop relative border text-white',
25
25
  },
26
- hero: { base: 'border border-hero bg-hero text-white hover:bg-hero-70 active:bg-hero-50' },
27
- faint: { base: 'border border-border bg-light text-muted hover:bg-white active:bg-white' },
26
+ hero: { base: 'border-hero bg-hero hover:bg-hero-70 active:bg-hero-50 border text-white' },
27
+ faint: { base: 'border-border bg-light text-muted border hover:bg-white active:bg-white' },
28
28
  link: { base: 'text-link underline' },
29
29
  },
30
30
  soft: {
@@ -50,7 +50,7 @@ export const styles = tv(
50
50
  slots: ['base'],
51
51
  look: 'primary',
52
52
  soft: true,
53
- className: 'text-text hover:text-white active-theme-rams:text-primary active-theme-rams:hover:text-white',
53
+ className: 'text-text active-theme-rams:text-primary active-theme-rams:hover:text-white hover:text-white',
54
54
  },
55
55
  {
56
56
  slots: ['base'],
@@ -7,6 +7,8 @@ import { styles } from './button.styles.js';
7
7
 
8
8
  type Variants = VariantProps<typeof styles>;
9
9
 
10
+ export type ButtonRef = HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement;
11
+
10
12
  export type ButtonProps = {
11
13
  /**
12
14
  * Fit button width to its parent width.
@@ -31,6 +33,12 @@ export type ButtonProps = {
31
33
  * Defaults to the current text color.
32
34
  */
33
35
  iconColor?: IconProps['color'];
36
+ /**
37
+ * The size of the icon
38
+ *
39
+ * Defaults to system size depending on size of the button
40
+ */
41
+ iconSize?: IconProps['size'];
34
42
  /**
35
43
  * When true, children will use flex justify-between
36
44
  * @default false
@@ -1,36 +1,223 @@
1
- import React from 'react';
1
+ 'use client';
2
2
 
3
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
4
+
5
+ import { type ButtonRef } from '../../../button/button.types.js';
6
+ import { ArrowLeftIcon, ArrowRightIcon } from '../../../icon/index.js';
3
7
  import { Button } from '../../../index.js';
4
- import { generateAriaDescription } from '../../filter.util.js';
5
8
 
6
- import { styles } from './filter-buttons.styles.js';
9
+ import { styles as filterButtonsStyles } from './filter-buttons.styles.js';
7
10
  import { type FilterButtonsProps } from './filter-buttons.types.js';
8
11
 
9
12
  export function FilterButtons({
10
13
  filterButtons,
11
14
  onClick,
12
15
  selectedButton,
13
- resultsFound,
14
16
  tag: Tag = 'div',
15
17
  className,
16
18
  ...props
17
19
  }: FilterButtonsProps) {
20
+ const scrollContainerRef = useRef<HTMLUListElement>(null);
21
+ const [isScrollable, setIsScrollable] = useState({ left: false, right: false });
22
+ const scrollElementRefs = useRef<ButtonRef[]>(new Array(filterButtons.length));
23
+ const [scrollTarget, setScrollTarget] = useState({ left: -1, right: -1 });
24
+
25
+ const styles = filterButtonsStyles();
26
+
27
+ const setScroll = useCallback((scrollBy: boolean, scroll: number, container: HTMLUListElement) => {
28
+ if (scrollBy) {
29
+ container.scrollBy({
30
+ left: scroll,
31
+ behavior: 'smooth',
32
+ });
33
+ } else {
34
+ container.scrollTo({
35
+ left: scroll,
36
+ behavior: 'smooth',
37
+ });
38
+ }
39
+ }, []);
40
+
41
+ const handleScrollButton = useCallback((direction: string) => {
42
+ if (scrollContainerRef.current) {
43
+ const container = scrollContainerRef.current;
44
+
45
+ let targetElement;
46
+ let scrollX;
47
+ let scrollBy = true;
48
+ const buttonPaddingOffset = 20;
49
+ if (direction === 'left') {
50
+ if (scrollTarget.left === -1) {
51
+ scrollX = -container.clientWidth;
52
+ } else {
53
+ scrollBy = false;
54
+ targetElement = scrollElementRefs.current[scrollTarget.left];
55
+ scrollX = targetElement.offsetLeft + targetElement.offsetWidth - container.offsetWidth + buttonPaddingOffset;
56
+ }
57
+ } else {
58
+ if (scrollTarget.right === -1) {
59
+ scrollX = container.clientWidth;
60
+ } else {
61
+ scrollBy = false;
62
+ targetElement = scrollElementRefs.current[scrollTarget.right];
63
+ scrollX = targetElement.offsetLeft - buttonPaddingOffset;
64
+ }
65
+ }
66
+ setScroll(scrollBy, scrollX, container);
67
+ }
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, []);
70
+
71
+ const getTargetLeft = useCallback((element: HTMLButtonElement, cLeft: number, index: number, targetLeft: number) => {
72
+ const eLeft = element.offsetLeft;
73
+ const eRight = eLeft + element.clientWidth;
74
+
75
+ if (eLeft <= cLeft && eRight >= cLeft) {
76
+ targetLeft = index;
77
+ }
78
+
79
+ return targetLeft;
80
+ }, []);
81
+
82
+ const getTargetRight = useCallback(
83
+ (element: HTMLButtonElement, cRight: number, index: number, targetRight: number) => {
84
+ const eLeft = element.offsetLeft;
85
+ const eRight = eLeft + element.clientWidth;
86
+
87
+ if (eRight >= cRight && eLeft <= cRight) {
88
+ targetRight = index;
89
+ }
90
+
91
+ return targetRight;
92
+ },
93
+ [],
94
+ );
95
+
96
+ const adjustTargets = useCallback(
97
+ (element: HTMLButtonElement, cLeft: number, cRight: number, targetLeft: number, targetRight: number) => {
98
+ const eLeft = element.offsetLeft;
99
+ const eRight = eLeft + element.clientWidth;
100
+
101
+ if ((eRight >= cRight && eLeft <= cLeft) || targetRight === targetLeft + 1) {
102
+ if (targetRight >= filterButtons.length - 1) {
103
+ targetRight = -1;
104
+ } else {
105
+ targetRight = targetRight + 1;
106
+ }
107
+ if (targetLeft <= 0) {
108
+ targetLeft = -1;
109
+ } else {
110
+ targetLeft = targetLeft - 1;
111
+ }
112
+ }
113
+
114
+ return { targetLeft, targetRight };
115
+ },
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
+ [],
118
+ );
119
+
120
+ const handleScrollTarget = useCallback((container: HTMLUListElement) => {
121
+ let targetRight = scrollTarget.right;
122
+ let targetLeft = scrollTarget.left;
123
+ const cLeft = container.scrollLeft;
124
+ const cRight = cLeft + container.clientWidth;
125
+
126
+ scrollElementRefs.current.forEach((element: HTMLButtonElement, index: number) => {
127
+ targetLeft = getTargetLeft(element, cLeft, index, targetLeft);
128
+ targetRight = getTargetRight(element, cRight, index, targetRight);
129
+ const targets = adjustTargets(element, cLeft, cRight, targetLeft, targetRight);
130
+ targetLeft = targets.targetLeft;
131
+ targetRight = targets.targetRight;
132
+ if (targetLeft === filterButtons.length - 1) {
133
+ targetLeft -= 1;
134
+ }
135
+ });
136
+
137
+ setScrollTarget({ left: targetLeft, right: targetRight });
138
+ // eslint-disable-next-line react-hooks/exhaustive-deps
139
+ }, []);
140
+
141
+ const handleScrollable = useCallback((container: HTMLUListElement) => {
142
+ const isLeftScrollable = container.scrollLeft >= 1;
143
+ const isRightScrollable = container.scrollLeft < container.scrollWidth - container.clientWidth - 1;
144
+ setIsScrollable({ left: isLeftScrollable, right: isRightScrollable });
145
+ }, []);
146
+
147
+ const handleScroll = useCallback(() => {
148
+ const container = scrollContainerRef.current;
149
+ if (container) {
150
+ handleScrollTarget(container);
151
+ handleScrollable(container);
152
+ }
153
+ // eslint-disable-next-line react-hooks/exhaustive-deps
154
+ }, []);
155
+
156
+ useEffect(() => {
157
+ const container = scrollContainerRef.current;
158
+ if (container) {
159
+ handleScrollTarget(container);
160
+ handleScrollable(container);
161
+
162
+ container.addEventListener('scroll', handleScroll);
163
+ window.addEventListener('resize', handleScroll);
164
+ }
165
+
166
+ return () => {
167
+ container?.removeEventListener('scroll', handleScroll);
168
+ window.removeEventListener('reize', handleScroll);
169
+ };
170
+ // eslint-disable-next-line react-hooks/exhaustive-deps
171
+ }, []);
172
+
18
173
  return (
19
- <Tag className={styles({ className })} {...props}>
20
- {filterButtons.map(button => (
21
- <Button
22
- aria-pressed={button.id === selectedButton}
23
- aria-description={generateAriaDescription(button.id, selectedButton, filterButtons.length, resultsFound)}
24
- aria-label={button.text}
25
- look="hero"
26
- size="small"
27
- onClick={() => onClick(button.id)}
28
- key={button.id}
29
- soft={button.id !== selectedButton}
30
- >
31
- {button.text}
32
- </Button>
33
- ))}
174
+ <Tag className={styles.base({ className })}>
175
+ <Button
176
+ className={styles.scrollButton({ position: 'left', hidden: !isScrollable.left })}
177
+ onClick={() => handleScrollButton('left')}
178
+ look="link"
179
+ size="small"
180
+ iconBefore={ArrowLeftIcon}
181
+ iconColor="hero"
182
+ iconSize="medium"
183
+ aria-hidden="true"
184
+ />
185
+ <Button
186
+ className={styles.scrollButton({ position: 'right', hidden: !isScrollable.right })}
187
+ onClick={() => handleScrollButton('right')}
188
+ look="link"
189
+ size="small"
190
+ iconBefore={ArrowRightIcon}
191
+ iconColor="hero"
192
+ iconSize="medium"
193
+ aria-hidden="true"
194
+ />
195
+ <ul
196
+ className={styles.buttonList({ className })}
197
+ style={{
198
+ scrollbarWidth: 'none',
199
+ msOverflowStyle: 'none',
200
+ overflowX: 'scroll',
201
+ }}
202
+ {...props}
203
+ ref={scrollContainerRef}
204
+ role="list"
205
+ >
206
+ {filterButtons.map((button, index) => (
207
+ <Button
208
+ aria-pressed={button.id === selectedButton}
209
+ look="hero"
210
+ size="small"
211
+ onClick={() => onClick(button.id)}
212
+ key={button.id}
213
+ soft={button.id !== selectedButton}
214
+ button-index={index}
215
+ ref={(element: ButtonRef) => (scrollElementRefs.current[index] = element)}
216
+ >
217
+ {button.text}
218
+ </Button>
219
+ ))}
220
+ </ul>
34
221
  </Tag>
35
222
  );
36
223
  }
@@ -1,5 +1,24 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
3
  export const styles = tv({
4
- base: 'flex w-full gap-1 overflow-auto whitespace-nowrap',
4
+ slots: {
5
+ base: 'relative flex justify-start',
6
+ buttonList: 'flex w-full touch-pan-x gap-1 overflow-x-auto whitespace-nowrap',
7
+ scrollButton: 'absolute rounded-none contrast-more:bg-black',
8
+ },
9
+ variants: {
10
+ position: {
11
+ left: {
12
+ scrollButton: '-left-1 bg-[linear-gradient(90deg,_#fff_66%,_transparent)] pl-0',
13
+ },
14
+ right: {
15
+ scrollButton: '-right-1 bg-[linear-gradient(270deg,_#fff_66%,_transparent)] pr-0',
16
+ },
17
+ },
18
+ hidden: {
19
+ true: {
20
+ scrollButton: 'hidden',
21
+ },
22
+ },
23
+ },
5
24
  });
@@ -22,10 +22,6 @@ export type FilterButtonsProps = {
22
22
  * Function that is called when a button on the filter is clicked
23
23
  */
24
24
  onClick: (id: string) => unknown;
25
- /**
26
- * Needed for custom `aria-description`, number of results filter returns
27
- */
28
- resultsFound: number;
29
25
  /**
30
26
  * id of which button should be selected
31
27
  */
@@ -24,6 +24,7 @@ function FlexiCellBase(
24
24
  size = 'default',
25
25
  disabled,
26
26
  tabIndex,
27
+ body = true,
27
28
  ...props
28
29
  }: FlexiCellProps,
29
30
  ref: Ref<HTMLElement>,
@@ -58,8 +59,10 @@ function FlexiCellBase(
58
59
  <FlexiCellBody tag="a" href={href}>
59
60
  {children}
60
61
  </FlexiCellBody>
61
- ) : (
62
+ ) : body ? (
62
63
  <FlexiCellBody>{children}</FlexiCellBody>
64
+ ) : (
65
+ <div className="flex-1">{children}</div>
63
66
  )}
64
67
  {after}
65
68
  {withArrow && (
@@ -16,6 +16,10 @@ type BaseFlexiCellProps = {
16
16
  * Renders an element on the left
17
17
  */
18
18
  before?: ReactNode;
19
+ /**
20
+ * Wraps everything into FlexiCellBody
21
+ */
22
+ body?: boolean;
19
23
  /**
20
24
  * the middle content of FlexiCell
21
25
  */
@@ -0,0 +1,41 @@
1
+ import React, { Fragment } from 'react';
2
+
3
+ import { Icon } from '../icon.component.js';
4
+ import { type IconProps } from '../icon.types.js';
5
+
6
+ export function CancelCardIcon({
7
+ look = 'filled',
8
+ 'aria-label': ariaLabel = 'Cancel Card',
9
+ copyrightYear = '2024',
10
+ ...props
11
+ }: IconProps) {
12
+ return (
13
+ <Icon aria-label={ariaLabel} copyrightYear={copyrightYear} {...props}>
14
+ {look === 'filled' ? (
15
+ <Fragment>
16
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
17
+ <path
18
+ fill-rule="evenodd"
19
+ d="M1.416.002 0 1.416l.908.907A1.998 1.998 0 0 0 0 4v16a2 2 0 0 0 2 2h18.585l1.998 1.998 1.415-1.414-.908-.907L1.416.002ZM4.585 6H1v4h7.585l-4-4Z"
20
+ clip-rule="evenodd"
21
+ fill="currentColor"
22
+ />
23
+ <path d="M23 10h-8.758L24 19.757V4a2 2 0 0 0-2-2H6.242l4 4H23v4Z" fill="currentColor" />
24
+ </svg>
25
+ </Fragment>
26
+ ) : (
27
+ <Fragment>
28
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none">
29
+ <path
30
+ fill-rule="evenodd"
31
+ d="M1.416.002 0 1.416l.908.907A1.998 1.998 0 0 0 0 4v16a2 2 0 0 0 2 2h18.585l1.998 1.998 1.415-1.414-.908-.907L1.416.002ZM2.585 4H2v4h4.585l-4-4Zm8 8H2v8h16.585l-8-8Z"
32
+ clip-rule="evenodd"
33
+ fill="currentColor"
34
+ />
35
+ <path d="M22 8h-9.758l4 4H22v5.757l2 2V4a2 2 0 0 0-2-2H6.242l2 2H22v4Z" fill="currentColor" />
36
+ </svg>
37
+ </Fragment>
38
+ )}
39
+ </Icon>
40
+ );
41
+ }