@westpac/ui 0.16.0 → 0.18.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 (127) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/component-type.json +1 -1
  3. package/dist/components/accordion/accordion.component.d.ts +2 -1
  4. package/dist/components/autocomplete/autocomplete.component.js +4 -2
  5. package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.d.ts +1 -1
  6. package/dist/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.js +1 -1
  7. package/dist/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.js +2 -1
  8. package/dist/components/badge/badge.component.js +3 -1
  9. package/dist/components/badge/badge.styles.js +1 -1
  10. package/dist/components/bottom-sheet/bottom-sheet.component.d.ts +1 -1
  11. package/dist/components/bottom-sheet/bottom-sheet.component.js +7 -2
  12. package/dist/components/bottom-sheet/bottom-sheet.types.d.ts +20 -0
  13. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.d.ts +1 -1
  14. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.js +26 -11
  15. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.d.ts +47 -0
  16. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.js +20 -0
  17. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.types.d.ts +17 -1
  18. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.d.ts +1 -1
  19. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.js +8 -14
  20. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.d.ts +11 -0
  21. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.js +17 -0
  22. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.d.ts +0 -5
  23. package/dist/components/button-group/button-group.component.js +58 -11
  24. package/dist/components/button-group/button-group.types.d.ts +9 -1
  25. package/dist/components/button-group/components/button-group-button/button-group-button.component.js +1 -2
  26. package/dist/components/checkbox-group/checkbox-group.component.js +61 -10
  27. package/dist/components/checkbox-group/checkbox-group.types.d.ts +5 -1
  28. package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.js +1 -2
  29. package/dist/components/date-picker/date-picker.types.d.ts +1 -0
  30. package/dist/components/error-message/error-message.types.d.ts +3 -2
  31. package/dist/components/icon/components/x-icon.d.ts +2 -0
  32. package/dist/components/icon/components/x-icon.js +40 -0
  33. package/dist/components/icon/index.d.ts +1 -1
  34. package/dist/components/icon/index.js +1 -1
  35. package/dist/components/list/components/list-item/list-item.component.d.ts +1 -1
  36. package/dist/components/list/list.utils.d.ts +1 -1
  37. package/dist/components/modal/components/modal-backdrop/modal-backdrop.component.js +4 -2
  38. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.d.ts +10 -0
  39. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.js +7 -2
  40. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.js +7 -2
  41. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.d.ts +43 -5
  42. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.js +30 -1
  43. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.d.ts +1 -1
  44. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.js +21 -4
  45. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.d.ts +47 -5
  46. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.js +32 -1
  47. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.types.d.ts +16 -0
  48. package/dist/components/modal/components/modal-dialog/modal-dialog.component.d.ts +2 -1
  49. package/dist/components/modal/components/modal-dialog/modal-dialog.component.js +11 -2
  50. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.d.ts +18 -0
  51. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.js +16 -7
  52. package/dist/components/modal/components/modal-dialog/modal-dialog.types.d.ts +6 -0
  53. package/dist/components/popover/components/panel/panel.styles.js +2 -2
  54. package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.component.js +1 -2
  55. package/dist/components/radio-group/radio-group.component.js +58 -11
  56. package/dist/components/radio-group/radio-group.types.d.ts +5 -1
  57. package/dist/components/repeater/repeater.component.js +4 -2
  58. package/dist/components/selector/components/selector-button-group/selector-button-group.component.js +9 -7
  59. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +50 -1
  60. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +1 -1
  61. package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +58 -11
  62. package/dist/components/selector/components/selector-radio-group/selector-radio-group.types.d.ts +5 -1
  63. package/dist/components/tabs/components/tabs-tab/tabs-tab.component.js +1 -1
  64. package/dist/components/tabs/tabs.component.d.ts +6 -2
  65. package/dist/components/tabs/tabs.component.js +7 -1
  66. package/dist/constants/message.d.ts +1 -0
  67. package/dist/constants/message.js +1 -0
  68. package/dist/css/westpac-ui.css +192 -100
  69. package/dist/css/westpac-ui.min.css +192 -100
  70. package/package.json +10 -10
  71. package/src/components/accordion/accordion.component.tsx +3 -3
  72. package/src/components/accordion/components/accordion-item/accordion-item.component.tsx +2 -2
  73. package/src/components/autocomplete/autocomplete.component.tsx +5 -1
  74. package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.component.tsx +1 -1
  75. package/src/components/autocomplete/components/autocomplete-list-box/components/autocomplete-list-box-option/autocomplete-list-box-option.styles.ts +1 -1
  76. package/src/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.tsx +4 -1
  77. package/src/components/badge/badge.component.tsx +2 -1
  78. package/src/components/badge/badge.styles.ts +1 -1
  79. package/src/components/bottom-sheet/bottom-sheet.component.tsx +20 -2
  80. package/src/components/bottom-sheet/bottom-sheet.types.ts +20 -0
  81. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.tsx +33 -14
  82. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.ts +16 -0
  83. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.types.ts +17 -1
  84. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx +11 -26
  85. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.ts +14 -0
  86. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.ts +0 -5
  87. package/src/components/button-group/button-group.component.tsx +58 -11
  88. package/src/components/button-group/button-group.types.ts +9 -2
  89. package/src/components/button-group/components/button-group-button/button-group-button.component.tsx +1 -2
  90. package/src/components/checkbox-group/checkbox-group.component.tsx +62 -10
  91. package/src/components/checkbox-group/checkbox-group.types.ts +5 -1
  92. package/src/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.component.tsx +1 -2
  93. package/src/components/date-picker/date-picker.types.ts +4 -0
  94. package/src/components/error-message/error-message.component.tsx +2 -2
  95. package/src/components/error-message/error-message.types.ts +2 -1
  96. package/src/components/icon/components/x-icon.tsx +37 -0
  97. package/src/components/icon/index.ts +1 -1
  98. package/src/components/modal/components/modal-backdrop/modal-backdrop.component.tsx +5 -2
  99. package/src/components/modal/components/modal-backdrop/modal-backdrop.styles.ts +7 -2
  100. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.tsx +6 -2
  101. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.ts +15 -3
  102. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.tsx +25 -4
  103. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.ts +15 -3
  104. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.types.ts +16 -0
  105. package/src/components/modal/components/modal-dialog/modal-dialog.component.tsx +10 -3
  106. package/src/components/modal/components/modal-dialog/modal-dialog.styles.ts +14 -5
  107. package/src/components/modal/components/modal-dialog/modal-dialog.types.ts +7 -0
  108. package/src/components/pagination/pagination.component.tsx +6 -6
  109. package/src/components/popover/components/panel/panel.styles.ts +2 -2
  110. package/src/components/radio-group/components/radio-group-radio/radio-group-radio.component.tsx +1 -2
  111. package/src/components/radio-group/radio-group.component.tsx +57 -13
  112. package/src/components/radio-group/radio-group.types.ts +5 -1
  113. package/src/components/repeater/repeater.component.tsx +2 -0
  114. package/src/components/selector/components/selector-button-group/selector-button-group.component.tsx +10 -7
  115. package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +49 -0
  116. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +1 -1
  117. package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +58 -11
  118. package/src/components/selector/components/selector-radio-group/selector-radio-group.types.ts +5 -1
  119. package/src/components/tabs/components/tabs-tab/tabs-tab.component.tsx +1 -1
  120. package/src/components/tabs/tabs.component.tsx +26 -5
  121. package/src/constants/message.ts +1 -0
  122. package/src/tailwind/utils/create-font-sizes.ts +11 -8
  123. package/src/tailwind/utils/generate-font-components.ts +18 -15
  124. package/src/tailwind/utils/generate-form-control.ts +11 -8
  125. package/dist/components/icon/components/twitter-icon.d.ts +0 -2
  126. package/dist/components/icon/components/twitter-icon.js +0 -35
  127. package/src/components/icon/components/twitter-icon.tsx +0 -37
@@ -65,6 +65,10 @@ export type DatePickerProps = {
65
65
  * onOpen
66
66
  */
67
67
  onOpen?: (...args: any[]) => unknown;
68
+ /*
69
+ * placeholder
70
+ */
71
+ placeholder?: string;
68
72
  /**
69
73
  * Size of datepicker input
70
74
  */
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
 
3
3
  import { AlertIcon } from '../../components/icon/index.js';
4
4
 
@@ -21,7 +21,7 @@ export function ErrorMessage({ className, tag: Tag = 'div', icon: Icon, message,
21
21
  ) : (
22
22
  <Tag className={styles.base({ className: `${className} mb-2` })} {...props}>
23
23
  <FinalIcon copyrightYear="2023" className={styles.icon({})} size="xsmall" look="outlined" />
24
- {message}
24
+ {message as ReactNode}
25
25
  </Tag>
26
26
  );
27
27
  }
@@ -1,4 +1,5 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
+ import { AriaFieldProps } from 'react-aria';
2
3
 
3
4
  export type ErrorMessageProps = {
4
5
  /**
@@ -8,7 +9,7 @@ export type ErrorMessageProps = {
8
9
  /**
9
10
  * Message or messages
10
11
  */
11
- message?: ReactNode | ReactNode[];
12
+ message?: AriaFieldProps['errorMessage'];
12
13
  /**
13
14
  * Tag to render
14
15
  */
@@ -0,0 +1,37 @@
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 XIcon({ look = 'filled', 'aria-label': ariaLabel = 'X', copyrightYear = '2024', ...props }: IconProps) {
7
+ return (
8
+ <Icon aria-label={ariaLabel} copyrightYear={copyrightYear} {...props}>
9
+ {look === 'filled' ? (
10
+ <Fragment>
11
+ <path fill="currentColor" d="M15.815 19.008h2.12L8.178 5.04h-2.12l9.757 13.968Z" />
12
+ <path
13
+ fill="currentColor"
14
+ fill-rule="evenodd"
15
+ d="M2 0a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2Zm17.315 4-5.824 6.775L19.825 20h-4.659l-4.265-6.212L5.56 20H4.18l6.107-7.104L4.18 4H8.84l4.039 5.883L17.935 4h1.38Z"
16
+ clip-rule="evenodd"
17
+ />
18
+ </Fragment>
19
+ ) : (
20
+ <Fragment>
21
+ <path
22
+ fill="currentColor"
23
+ fill-rule="evenodd"
24
+ d="m19.315 4-5.824 6.775L19.825 20h-4.659l-4.265-6.212L5.56 20H4.18l6.107-7.104L4.18 4H8.84l4.039 5.883L17.935 4h1.38Zm-3.5 15.008h2.12L8.178 5.04h-2.12l9.757 13.968Z"
25
+ clip-rule="evenodd"
26
+ />
27
+ <path
28
+ fill="currentColor"
29
+ fill-rule="evenodd"
30
+ d="M0 2a2 2 0 0 1 2-2h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2Zm2 0h20v20H2V2Z"
31
+ clip-rule="evenodd"
32
+ />
33
+ </Fragment>
34
+ )}
35
+ </Icon>
36
+ );
37
+ }
@@ -211,7 +211,6 @@ export { TransferIcon } from './components/transfer-icon.js';
211
211
  export { TransportIcon } from './components/transport-icon.js';
212
212
  export { TravelExploreIcon } from './components/travel-explore-icon.js';
213
213
  export { TuneIcon } from './components/tune-icon.js';
214
- export { TwitterIcon } from './components/twitter-icon.js';
215
214
  export { UmbrellaIcon } from './components/umbrella-icon.js';
216
215
  export { UploadIcon } from './components/upload-icon.js';
217
216
  export { VerifiedIcon } from './components/verified-icon.js';
@@ -229,6 +228,7 @@ export { WindowsNewIcon } from './components/windows-new-icon.js';
229
228
  export { WineGlassIcon } from './components/wine-glass-icon.js';
230
229
  export { WordFileIcon } from './components/word-file-icon.js';
231
230
  export { WriteIcon } from './components/write-icon.js';
231
+ export { XIcon } from './components/x-icon.js';
232
232
  export { YammerIcon } from './components/yammer-icon.js';
233
233
  export { YoutubeIcon } from './components/youtube-icon.js';
234
234
  export { ZipFileIcon } from './components/zip-file-icon.js';
@@ -11,7 +11,7 @@ export function ModalBackdrop({ zIndex = 100, portalContainer, size, ...props }:
11
11
  const { children, state, className } = props;
12
12
 
13
13
  const ref = useRef(null);
14
- const styles = backdropStyles({ className, fullscreen: size === 'full' });
14
+ const styles = backdropStyles({ className, fullscreen: size === 'full', fluid: size === 'fluid' });
15
15
 
16
16
  const { modalProps, underlayProps } = useModalOverlay(props, state, ref);
17
17
 
@@ -20,8 +20,11 @@ export function ModalBackdrop({ zIndex = 100, portalContainer, size, ...props }:
20
20
  return null;
21
21
  }
22
22
 
23
+ // This is required so branding applies correctly by default due to portal location, can be overridden with portalContainer prop
24
+ const brandContainer = document.querySelector('[data-theme]') || document.querySelector('[className="data-theme"]');
25
+
23
26
  return (
24
- <Overlay portalContainer={portalContainer}>
27
+ <Overlay portalContainer={portalContainer || brandContainer || document.body}>
25
28
  <div style={{ zIndex }} className={styles.base()} {...underlayProps}>
26
29
  <div {...modalProps} ref={ref} className={styles.modal()}>
27
30
  {children}
@@ -2,8 +2,8 @@ import { tv } from 'tailwind-variants';
2
2
 
3
3
  export const styles = tv({
4
4
  slots: {
5
- base: 'fixed inset-0 z-50 flex animate-fadeIn justify-center overflow-y-auto bg-black/50 p-2',
6
- modal: 'relative top-5 z-10 h-fit w-full animate-fadeInDown',
5
+ base: 'fixed inset-0 z-50 flex animate-fadeIn items-center justify-center overflow-y-auto bg-black/50 p-2',
6
+ modal: 'relative top-3 z-10 h-fit w-full animate-fadeInDown',
7
7
  },
8
8
  variants: {
9
9
  fullscreen: {
@@ -12,5 +12,10 @@ export const styles = tv({
12
12
  base: 'flex flex-col p-0',
13
13
  },
14
14
  },
15
+ fluid: {
16
+ true: {
17
+ modal: 'px-2',
18
+ },
19
+ },
15
20
  },
16
21
  });
@@ -1,11 +1,15 @@
1
1
  import React from 'react';
2
2
 
3
- import { styles } from './modal-dialog-body.styles.js';
3
+ import { useModalDialogContext } from '../../modal-dialog.component.js';
4
+
5
+ import { styles as modalBodyStyles } from './modal-dialog-body.styles.js';
4
6
  import { type ModalDialogBodyProps } from './modal-dialog-body.types.js';
5
7
 
6
8
  export function ModalDialogBody({ className, children, ...props }: ModalDialogBodyProps) {
9
+ const { size } = useModalDialogContext();
10
+ const styles = modalBodyStyles({ size });
7
11
  return (
8
- <div className={styles({ className })} {...props}>
12
+ <div className={styles.base({ className })} {...props}>
9
13
  {children}
10
14
  </div>
11
15
  );
@@ -1,5 +1,17 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
- export const styles = tv({
4
- base: 'flex-1 overflow-auto px-4 py-3',
5
- });
3
+ export const styles = tv(
4
+ {
5
+ slots: { base: 'flex-1 overflow-auto' },
6
+ variants: {
7
+ size: {
8
+ full: { base: 'px-4 py-3' },
9
+ lg: { base: 'px-12 pb-12' },
10
+ md: { base: 'px-7 pb-7' },
11
+ sm: { base: 'px-5 pb-7' },
12
+ fluid: { base: 'px-5 pb-7' },
13
+ },
14
+ },
15
+ },
16
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
17
+ );
@@ -1,12 +1,33 @@
1
+ 'use client';
2
+
1
3
  import React from 'react';
2
4
 
3
- import { styles } from './modal-dialog-footer.styles.js';
5
+ import { Button } from '../../../../../button/index.js';
6
+ import { useModalDialogContext } from '../../modal-dialog.component.js';
7
+
8
+ import { styles as modalFooterStyles } from './modal-dialog-footer.styles.js';
4
9
  import { type ModalDialogFooterProps } from './modal-dialog-footer.types.js';
5
10
 
6
- export function ModalDialogFooter({ className, children, ...props }: ModalDialogFooterProps) {
11
+ export function ModalDialogFooter({
12
+ className,
13
+ primaryLabel,
14
+ primaryOnClick,
15
+ secondaryLabel,
16
+ secondaryOnClick,
17
+ ...props
18
+ }: ModalDialogFooterProps) {
19
+ const { size } = useModalDialogContext();
20
+ const styles = modalFooterStyles({ size });
7
21
  return (
8
- <div className={styles({ className })} {...props}>
9
- {children}
22
+ <div className={styles.base({ className })} {...props}>
23
+ <Button look="primary" size="large" className={styles.primaryBtn()} onClick={primaryOnClick}>
24
+ {primaryLabel}
25
+ </Button>
26
+ {secondaryLabel && (
27
+ <Button look="link" size="large" className={styles.secondaryBtn()} onClick={secondaryOnClick}>
28
+ {secondaryLabel}
29
+ </Button>
30
+ )}
10
31
  </div>
11
32
  );
12
33
  }
@@ -1,5 +1,17 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
- export const styles = tv({
4
- base: 'border-t border-t-border bg-background px-3 py-2',
5
- });
3
+ export const styles = tv(
4
+ {
5
+ slots: { base: 'flex gap-1', primaryBtn: '', secondaryBtn: 'no-underline hover:underline' },
6
+ variants: {
7
+ size: {
8
+ full: { base: 'px-4 py-3' },
9
+ lg: { base: '-mt-6 px-12 pb-12' },
10
+ md: { base: '-mt-2 px-7 pb-7' },
11
+ sm: { base: '-mt-2 flex-col px-5 pb-5' },
12
+ fluid: { base: '-mt-2 px-5 pb-5 max-md:flex-col' },
13
+ },
14
+ },
15
+ },
16
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
17
+ );
@@ -5,4 +5,20 @@ export type ModalDialogFooterProps = {
5
5
  * Footer content
6
6
  */
7
7
  children?: ReactNode;
8
+ /**
9
+ * Label for primary button
10
+ */
11
+ primaryLabel: string;
12
+ /**
13
+ * onClick for primary button
14
+ */
15
+ primaryOnClick: () => void;
16
+ /**
17
+ * Label for secondary button
18
+ */
19
+ secondaryLabel?: string;
20
+ /**
21
+ * onClick for secondary button
22
+ */
23
+ secondaryOnClick?: () => void;
8
24
  } & HTMLAttributes<HTMLElement>;
@@ -1,4 +1,6 @@
1
- import React, { useRef } from 'react';
1
+ 'use client';
2
+
3
+ import React, { createContext, useContext, useRef } from 'react';
2
4
  import { useDialog, useFocusRing } from 'react-aria';
3
5
 
4
6
  import { CloseIcon } from '../../../../components/icon/index.js';
@@ -6,8 +8,11 @@ import { CloseIcon } from '../../../../components/icon/index.js';
6
8
  import { ModalDialogBody } from './components/modal-dialog-body/index.js';
7
9
  import { ModalDialogFooter } from './components/modal-dialog-footer/index.js';
8
10
  import { styles as dialogStyles } from './modal-dialog.styles.js';
9
- import { type ModalDialogProps } from './modal-dialog.types.js';
11
+ import { ModalDialogContextValue, type ModalDialogProps } from './modal-dialog.types.js';
12
+
13
+ const ModalDialogContext = createContext<ModalDialogContextValue>({ size: 'md' });
10
14
 
15
+ export const useModalDialogContext = () => useContext(ModalDialogContext);
11
16
  /**
12
17
  * @private
13
18
  */
@@ -32,7 +37,9 @@ export function ModalDialog({ className, body, onClose, size = 'md', ...props }:
32
37
  {props.title}
33
38
  </h3>
34
39
  )}
35
- {body ? <ModalDialogBody>{children}</ModalDialogBody> : children}
40
+ <ModalDialogContext.Provider value={{ size }}>
41
+ {body ? <ModalDialogBody>{children}</ModalDialogBody> : children}
42
+ </ModalDialogContext.Provider>
36
43
  </div>
37
44
  );
38
45
  }
@@ -3,23 +3,32 @@ import { tv } from 'tailwind-variants';
3
3
  export const styles = tv(
4
4
  {
5
5
  slots: {
6
- base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white outline-none',
7
- title: 'border-b border-b-heading pb-2 pl-4 pr-5 pt-3 text-lg font-medium',
8
- close: 'absolute right-1 top-1 block p-1',
6
+ base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white text-text outline-none',
7
+ title: 'typography-body-7 pb-4 pt-9 font-bold text-text',
8
+ close: 'absolute right-0 top-0 block p-3',
9
9
  },
10
10
  variants: {
11
11
  size: {
12
12
  full: {
13
13
  base: 'max-h-screen w-full flex-1',
14
+ close: 'p-2',
15
+ title: 'px-4 py-3',
14
16
  },
15
17
  lg: {
16
- base: 'w-[56.25rem]',
18
+ base: 'w-[50rem]',
19
+ title: 'px-12 pt-12',
17
20
  },
18
21
  md: {
19
22
  base: 'w-[37.5rem]',
23
+ title: 'px-7 ',
20
24
  },
21
25
  sm: {
22
- base: 'w-[18.75rem]',
26
+ base: 'w-[25rem]',
27
+ title: 'px-5',
28
+ },
29
+ fluid: {
30
+ base: 'w-full',
31
+ title: 'px-5',
23
32
  },
24
33
  },
25
34
  isFocusVisible: {
@@ -35,3 +35,10 @@ export type ModalDialogProps = {
35
35
  */
36
36
  title?: string;
37
37
  } & AriaDialogProps;
38
+
39
+ export type ModalDialogContextValue = {
40
+ /**
41
+ * Size of dialog
42
+ */
43
+ size?: Variants['size'];
44
+ };
@@ -23,12 +23,12 @@ export function Pagination({
23
23
 
24
24
  const generateHandleOnClickBackwards = useCallback(
25
25
  (
26
- current: number,
27
- infinite: boolean,
28
- forwardOnly: boolean,
29
- onChange: (page: number) => unknown,
30
- pages: PaginationProps['pages'],
31
- ) =>
26
+ current: number,
27
+ infinite: boolean,
28
+ forwardOnly: boolean,
29
+ onChange: (page: number) => unknown,
30
+ pages: PaginationProps['pages'],
31
+ ) =>
32
32
  () => {
33
33
  if (infinite && forwardOnly) {
34
34
  return onChange(pages.length);
@@ -9,8 +9,8 @@ export const styles = tv(
9
9
  'absolute h-0 w-0 border-x-[8px] border-t-[12px] border-x-[transparent] border-t-muted after:absolute after:h-0 after:w-0 after:border-x-[7px] after:border-t-[11px] after:border-x-[transparent] after:border-t-white',
10
10
  closeBtn: 'absolute right-1 top-1 m-1 p-0 hover:opacity-80',
11
11
  content: 'w-[17.625rem] py-4 pl-3 pr-5',
12
- heading: 'typography-body-9 mb-2 font-bold',
13
- body: 'typography-body-10',
12
+ heading: 'typography-body-9 mb-2 font-bold text-text',
13
+ body: 'typography-body-10 text-text',
14
14
  },
15
15
  variants: {
16
16
  placement: {
@@ -9,8 +9,7 @@ import { styles as radioStyles } from './radio-group-radio.styles.js';
9
9
  import { type RadioGroupRadioProps } from './radio-group-radio.types.js';
10
10
 
11
11
  function BaseRadioGroupRadio({ className, hint, label, ...props }: RadioGroupRadioProps, ref: any) {
12
- const state = useContext(RadioGroupContext);
13
- const { size, orientation } = state;
12
+ const { state, size, orientation } = useContext(RadioGroupContext);
14
13
  const localRef = useRef(null);
15
14
  const { inputProps, isSelected, isDisabled } = useRadio({ ...props, children: label }, state, localRef);
16
15
  const { isFocusVisible, focusProps } = useFocusRing();
@@ -4,6 +4,7 @@ import React, { createContext, useEffect, useId, useMemo, useRef, useState } fro
4
4
  import { useFocusRing, useRadioGroup } from 'react-aria';
5
5
  import { useRadioGroupState } from 'react-stately';
6
6
 
7
+ import { FUNCTION_NOT_IMPLEMENTED } from '../../constants/message.js';
7
8
  import { Button } from '../button/index.js';
8
9
  import { ExpandMoreIcon } from '../icon/index.js';
9
10
  import { ErrorMessage, Hint, Label, RadioGroupRadio } from '../index.js';
@@ -12,18 +13,63 @@ import { styles as radioGroupStyles } from './radio-group.styles.js';
12
13
  import { type RadioGroupContextState, type RadioGroupProps } from './radio-group.types.js';
13
14
 
14
15
  export const RadioGroupContext = createContext<RadioGroupContextState>({
15
- // TODO: Remove deprecated name prop once React Aria removes it from RadioGroupState
16
- name: '',
17
- isDisabled: false,
18
- isReadOnly: false,
19
- isRequired: false,
20
- validationState: null,
21
- selectedValue: null,
22
- setSelectedValue: () => null,
23
- lastFocusedValue: null,
24
- setLastFocusedValue: () => null,
25
16
  orientation: 'vertical',
26
17
  size: 'medium',
18
+ state: {
19
+ name: '',
20
+ isDisabled: false,
21
+ isReadOnly: false,
22
+ isRequired: false,
23
+ validationState: null,
24
+ selectedValue: null,
25
+ setSelectedValue: () => null,
26
+ lastFocusedValue: null,
27
+ setLastFocusedValue: () => null,
28
+ isInvalid: false,
29
+ realtimeValidation: {
30
+ isInvalid: false,
31
+ validationErrors: [],
32
+ validationDetails: {
33
+ badInput: false,
34
+ customError: false,
35
+ patternMismatch: false,
36
+ rangeOverflow: false,
37
+ rangeUnderflow: false,
38
+ stepMismatch: false,
39
+ tooLong: false,
40
+ tooShort: false,
41
+ typeMismatch: false,
42
+ valid: false,
43
+ valueMissing: false,
44
+ },
45
+ },
46
+ displayValidation: {
47
+ isInvalid: false,
48
+ validationErrors: [],
49
+ validationDetails: {
50
+ badInput: false,
51
+ customError: false,
52
+ patternMismatch: false,
53
+ rangeOverflow: false,
54
+ rangeUnderflow: false,
55
+ stepMismatch: false,
56
+ tooLong: false,
57
+ tooShort: false,
58
+ typeMismatch: false,
59
+ valid: false,
60
+ valueMissing: false,
61
+ },
62
+ },
63
+ updateValidation: function (): void {
64
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
65
+ },
66
+ resetValidation: function (): void {
67
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
68
+ },
69
+ commitValidation: function (): void {
70
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
71
+ },
72
+ },
27
73
  });
28
74
 
29
75
  export function RadioGroup({
@@ -70,9 +116,7 @@ export function RadioGroup({
70
116
  <ErrorMessage {...errorMessageProps} message={errorMessage} />
71
117
  )}
72
118
  <div className={styles.radioWrapper()} id={panelId}>
73
- <RadioGroupContext.Provider value={{ ...state, orientation, size }}>
74
- {childrenToRender}
75
- </RadioGroupContext.Provider>
119
+ <RadioGroupContext.Provider value={{ state, orientation, size }}>{childrenToRender}</RadioGroupContext.Provider>
76
120
  {hiddenOptions && (
77
121
  <Button
78
122
  onClick={() => setHiddenOptions(false)}
@@ -41,4 +41,8 @@ export type RadioGroupContextState = {
41
41
  * Controls size of `Radio` components, can't be applied directly on `Radio`
42
42
  */
43
43
  size: 'medium' | 'large';
44
- } & RadioGroupState;
44
+ /**
45
+ * State
46
+ */
47
+ state: RadioGroupState;
48
+ };
@@ -99,6 +99,7 @@ export function Repeater({
99
99
  size="small"
100
100
  soft
101
101
  onClick={() => handleRemove(item.id, index)}
102
+ type="button"
102
103
  >
103
104
  Remove
104
105
  </Button>
@@ -118,6 +119,7 @@ export function Repeater({
118
119
  size="small"
119
120
  soft
120
121
  onClick={() => handleAdd()}
122
+ type="button"
121
123
  >
122
124
  {addText}
123
125
  </Button>
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { createContext, useCallback, useState } from 'react';
3
+ import { createContext, useCallback, useMemo, useState } from 'react';
4
4
  import { useField } from 'react-aria';
5
5
 
6
6
  import { ErrorMessage, Hint, Label } from '../../../index.js';
@@ -35,12 +35,15 @@ export function SelectorButtonGroup({
35
35
  [selected, setSelected],
36
36
  );
37
37
 
38
- const state: SelectorButtonGroupContextState = {
39
- value: selected,
40
- onClick: (id: string) => handleChange(id),
41
- validationState: errorMessage ? 'invalid' : 'valid',
42
- isDisabled,
43
- };
38
+ const state: SelectorButtonGroupContextState = useMemo(
39
+ () => ({
40
+ value: selected,
41
+ onClick: (id: string) => handleChange(id),
42
+ validationState: errorMessage ? 'invalid' : 'valid',
43
+ isDisabled,
44
+ }),
45
+ [selected],
46
+ );
44
47
 
45
48
  const { labelProps, fieldProps, descriptionProps, errorMessageProps } = useField({
46
49
  validationState: state.validationState,
@@ -4,6 +4,7 @@ import React, { createContext } from 'react';
4
4
  import { useCheckboxGroup } from 'react-aria';
5
5
  import { useCheckboxGroupState } from 'react-stately';
6
6
 
7
+ import { FUNCTION_NOT_IMPLEMENTED } from '../../../../constants/message.js';
7
8
  import { ErrorMessage, Hint, Label } from '../../../index.js';
8
9
 
9
10
  import { styles } from './selector-checkbox-group.styles.js';
@@ -22,6 +23,54 @@ export const SelectorCheckboxGroupContext = createContext<SelectorCheckboxGroupC
22
23
  removeValue: () => null,
23
24
  toggleValue: () => null,
24
25
  validationState: 'valid',
26
+ isInvalid: false,
27
+ isRequired: false,
28
+ setInvalid: function (): void {
29
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
30
+ },
31
+ realtimeValidation: {
32
+ isInvalid: false,
33
+ validationErrors: [],
34
+ validationDetails: {
35
+ badInput: false,
36
+ customError: false,
37
+ patternMismatch: false,
38
+ rangeOverflow: false,
39
+ rangeUnderflow: false,
40
+ stepMismatch: false,
41
+ tooLong: false,
42
+ tooShort: false,
43
+ typeMismatch: false,
44
+ valid: false,
45
+ valueMissing: false,
46
+ },
47
+ },
48
+ displayValidation: {
49
+ isInvalid: false,
50
+ validationErrors: [],
51
+ validationDetails: {
52
+ badInput: false,
53
+ customError: false,
54
+ patternMismatch: false,
55
+ rangeOverflow: false,
56
+ rangeUnderflow: false,
57
+ stepMismatch: false,
58
+ tooLong: false,
59
+ tooShort: false,
60
+ typeMismatch: false,
61
+ valid: false,
62
+ valueMissing: false,
63
+ },
64
+ },
65
+ updateValidation: function (): void {
66
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
67
+ },
68
+ resetValidation: function (): void {
69
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
70
+ },
71
+ commitValidation: function (): void {
72
+ throw new Error(FUNCTION_NOT_IMPLEMENTED);
73
+ },
25
74
  });
26
75
 
27
76
  export function SelectorCheckboxGroup(props: SelectorCheckboxGroupProps) {
@@ -24,7 +24,7 @@ function BaseSelectorRadioGroupOption(
24
24
  }: SelectorRadioGroupOptionProps,
25
25
  ref: any,
26
26
  ) {
27
- const state = useContext(SelectorRadioGroupContext);
27
+ const { state } = useContext(SelectorRadioGroupContext);
28
28
  const localRef = useRef(null);
29
29
  const { inputProps, isSelected, isDisabled } = useRadio({ ...props, value, children }, state, localRef);
30
30
  const { isFocusVisible, focusProps } = useFocusRing();