@westpac/ui 0.53.2 → 0.55.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 (69) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/component-type.json +1 -1
  3. package/dist/components/accordion/components/accordion-item/accordion-item.styles.js +9 -1
  4. package/dist/components/autocomplete/components/autocomplete-list-box/autocomplete-list-box.component.js +1 -1
  5. package/dist/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.js +1 -1
  6. package/dist/components/button/button.component.d.ts +1 -0
  7. package/dist/components/button/button.component.js +3 -2
  8. package/dist/components/button/button.styles.d.ts +9 -0
  9. package/dist/components/button/button.styles.js +12 -1
  10. package/dist/components/button/button.types.d.ts +5 -0
  11. package/dist/components/button-dropdown/button-dropdown.component.d.ts +1 -1
  12. package/dist/components/button-dropdown/button-dropdown.component.js +2 -2
  13. package/dist/components/button-dropdown/button-dropdown.types.d.ts +5 -0
  14. package/dist/components/button-group/button-group.component.js +1 -0
  15. package/dist/components/checkbox-group/checkbox-group.component.js +1 -0
  16. package/dist/components/header/header.component.js +2 -1
  17. package/dist/components/header/header.types.d.ts +2 -1
  18. package/dist/components/modal/components/modal-backdrop/modal-backdrop.component.d.ts +1 -1
  19. package/dist/components/modal/components/modal-backdrop/modal-backdrop.component.js +3 -3
  20. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.d.ts +39 -20
  21. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.js +52 -11
  22. package/dist/components/modal/components/modal-backdrop/modal-backdrop.types.d.ts +5 -0
  23. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.js +8 -2
  24. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.d.ts +54 -0
  25. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.js +64 -4
  26. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.js +9 -3
  27. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.d.ts +12 -0
  28. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.js +25 -8
  29. package/dist/components/modal/components/modal-dialog/modal-dialog.component.d.ts +1 -1
  30. package/dist/components/modal/components/modal-dialog/modal-dialog.component.js +49 -4
  31. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.d.ts +27 -0
  32. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.js +39 -6
  33. package/dist/components/modal/components/modal-dialog/modal-dialog.types.d.ts +33 -0
  34. package/dist/components/modal/modal.component.d.ts +1 -1
  35. package/dist/components/modal/modal.component.js +4 -2
  36. package/dist/components/popover/components/panel/panel.styles.js +1 -1
  37. package/dist/components/radio-group/radio-group.component.js +1 -0
  38. package/dist/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.js +1 -0
  39. package/dist/components/selector/components/selector-radio-group/selector-radio-group.component.js +1 -0
  40. package/dist/css/westpac-ui.css +226 -25
  41. package/dist/css/westpac-ui.min.css +226 -25
  42. package/package.json +6 -6
  43. package/src/components/accordion/components/accordion-item/accordion-item.styles.ts +7 -1
  44. package/src/components/autocomplete/components/autocomplete-list-box/autocomplete-list-box.component.tsx +1 -1
  45. package/src/components/autocomplete/components/autocomplete-popover/autocomplete-popover.component.tsx +1 -4
  46. package/src/components/button/button.component.tsx +2 -0
  47. package/src/components/button/button.styles.ts +10 -1
  48. package/src/components/button/button.types.ts +5 -0
  49. package/src/components/button-dropdown/button-dropdown.component.tsx +2 -1
  50. package/src/components/button-dropdown/button-dropdown.types.ts +5 -0
  51. package/src/components/button-group/button-group.component.tsx +1 -0
  52. package/src/components/checkbox-group/checkbox-group.component.tsx +1 -0
  53. package/src/components/header/header.component.tsx +3 -1
  54. package/src/components/header/header.types.ts +2 -1
  55. package/src/components/modal/components/modal-backdrop/modal-backdrop.component.tsx +5 -2
  56. package/src/components/modal/components/modal-backdrop/modal-backdrop.styles.ts +35 -15
  57. package/src/components/modal/components/modal-backdrop/modal-backdrop.types.ts +5 -0
  58. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.tsx +7 -3
  59. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.ts +45 -3
  60. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.tsx +8 -3
  61. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.ts +22 -6
  62. package/src/components/modal/components/modal-dialog/modal-dialog.component.tsx +51 -5
  63. package/src/components/modal/components/modal-dialog/modal-dialog.styles.ts +28 -5
  64. package/src/components/modal/components/modal-dialog/modal-dialog.types.ts +33 -0
  65. package/src/components/modal/modal.component.tsx +4 -2
  66. package/src/components/popover/components/panel/panel.styles.ts +1 -1
  67. package/src/components/radio-group/radio-group.component.tsx +1 -0
  68. package/src/components/selector/components/selector-checkbox-group/selector-checkbox-group.component.tsx +1 -0
  69. package/src/components/selector/components/selector-radio-group/selector-radio-group.component.tsx +1 -0
@@ -1,29 +1,46 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
  export const styles = tv({
3
3
  slots: {
4
- base: 'flex gap-1',
4
+ base: 'flex gap-1 rounded-b-[3px] bg-white',
5
5
  primaryBtn: '',
6
- secondaryBtn: 'no-underline hover:underline'
6
+ secondaryBtn: ''
7
7
  },
8
8
  variants: {
9
9
  size: {
10
10
  full: {
11
- base: 'px-4 py-3'
11
+ base: 'px-4 pb-3'
12
12
  },
13
13
  lg: {
14
- base: '-mt-6 px-12 pb-12'
14
+ base: 'px-12 pb-12'
15
15
  },
16
16
  md: {
17
- base: '-mt-2 px-7 pb-7'
17
+ base: 'px-7 pb-7'
18
18
  },
19
19
  sm: {
20
- base: '-mt-2 flex-col px-5 pb-5'
20
+ base: 'flex-col px-5 pb-5 '
21
21
  },
22
22
  fluid: {
23
- base: '-mt-2 px-5 pb-5 max-md:flex-col'
23
+ base: 'px-5 pb-5 max-md:flex-col'
24
24
  }
25
+ },
26
+ compact: {
27
+ true: '',
28
+ false: ''
25
29
  }
26
- }
30
+ },
31
+ compoundSlots: [
32
+ {
33
+ slots: [
34
+ 'base'
35
+ ],
36
+ size: [
37
+ 'lg',
38
+ 'md'
39
+ ],
40
+ compact: true,
41
+ className: 'min-h-[90px] px-5 pb-5 pt-3'
42
+ }
43
+ ]
27
44
  }, {
28
45
  responsiveVariants: [
29
46
  'xsl',
@@ -5,7 +5,7 @@ export declare const useModalDialogContext: () => ModalDialogContextValue;
5
5
  /**
6
6
  * @private
7
7
  */
8
- export declare function ModalDialog({ className, body, onClose, size, ...props }: ModalDialogProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ModalDialog({ className, body, onClose, size, compact, ...props }: ModalDialogProps): import("react/jsx-runtime").JSX.Element;
9
9
  export declare namespace ModalDialog {
10
10
  var Body: typeof ModalDialogBody;
11
11
  var Footer: typeof ModalDialogFooter;
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { createContext, useContext, useRef } from 'react';
2
+ import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
3
3
  import { useDialog, useFocusRing } from 'react-aria';
4
4
  import { CloseIcon } from '../../../../components/icon/index.js';
5
5
  import { ModalDialogBody } from './components/modal-dialog-body/index.js';
@@ -8,16 +8,55 @@ import { styles as dialogStyles } from './modal-dialog.styles.js';
8
8
  const ModalDialogContext = createContext({
9
9
  size: 'md'
10
10
  });
11
+ const SCROLL_BUFFER = 10;
11
12
  export const useModalDialogContext = ()=>useContext(ModalDialogContext);
12
- export function ModalDialog({ className, body, onClose, size = 'md', ...props }) {
13
+ export function ModalDialog({ className, body, onClose, size, compact, ...props }) {
13
14
  const { children } = props;
14
15
  const { isFocusVisible, focusProps } = useFocusRing();
16
+ const [scrolled, setScrolled] = useState(false);
17
+ const [scrollAtBottom, setScrollAtBottom] = useState(false);
15
18
  const styles = dialogStyles({
16
19
  size,
17
- isFocusVisible
20
+ isFocusVisible,
21
+ compact,
22
+ scrolled
18
23
  });
24
+ const [canScroll, setCanScroll] = useState(false);
25
+ const [footerPresent, setFooterPresent] = useState(false);
19
26
  const ref = useRef(null);
27
+ const bodyRef = useRef(null);
20
28
  const { dialogProps, titleProps } = useDialog(props, ref);
29
+ const handleScroll = useCallback(()=>{
30
+ if (bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) {
31
+ const { scrollTop, scrollHeight, clientHeight } = bodyRef.current;
32
+ setScrolled(scrollTop > SCROLL_BUFFER);
33
+ setScrollAtBottom(scrollTop + clientHeight >= scrollHeight - SCROLL_BUFFER);
34
+ }
35
+ }, [
36
+ bodyRef
37
+ ]);
38
+ useEffect(()=>{
39
+ const bodyElement = bodyRef.current;
40
+ if (!bodyElement) {
41
+ setCanScroll(false);
42
+ return;
43
+ }
44
+ bodyElement.addEventListener('scroll', handleScroll);
45
+ const updateCanScroll = ()=>{
46
+ setCanScroll(bodyElement.scrollHeight > bodyElement.clientHeight);
47
+ };
48
+ updateCanScroll();
49
+ const resizeObserver = new ResizeObserver(()=>{
50
+ updateCanScroll();
51
+ });
52
+ resizeObserver.observe(bodyElement);
53
+ return ()=>{
54
+ resizeObserver.disconnect();
55
+ bodyElement.removeEventListener('scroll', handleScroll);
56
+ };
57
+ }, [
58
+ bodyRef
59
+ ]);
21
60
  return React.createElement("div", {
22
61
  ...dialogProps,
23
62
  ref: ref,
@@ -37,7 +76,13 @@ export function ModalDialog({ className, body, onClose, size = 'md', ...props })
37
76
  className: styles.title()
38
77
  }, props.title), React.createElement(ModalDialogContext.Provider, {
39
78
  value: {
40
- size
79
+ size,
80
+ scrollingRef: bodyRef,
81
+ canScroll,
82
+ compact,
83
+ footerPresent,
84
+ setFooterPresent,
85
+ scrollAtBottom
41
86
  }
42
87
  }, body ? React.createElement(ModalDialogBody, null, children) : children));
43
88
  }
@@ -30,6 +30,15 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
30
30
  close: string;
31
31
  };
32
32
  };
33
+ compact: {
34
+ true: string;
35
+ false: string;
36
+ };
37
+ scrolled: {
38
+ true: {
39
+ title: string;
40
+ };
41
+ };
33
42
  }, {
34
43
  base: string;
35
44
  title: string;
@@ -68,6 +77,15 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
68
77
  close: string;
69
78
  };
70
79
  };
80
+ compact: {
81
+ true: string;
82
+ false: string;
83
+ };
84
+ scrolled: {
85
+ true: {
86
+ title: string;
87
+ };
88
+ };
71
89
  }, {
72
90
  base: string;
73
91
  title: string;
@@ -104,6 +122,15 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
104
122
  close: string;
105
123
  };
106
124
  };
125
+ compact: {
126
+ true: string;
127
+ false: string;
128
+ };
129
+ scrolled: {
130
+ true: {
131
+ title: string;
132
+ };
133
+ };
107
134
  }, {
108
135
  base: string;
109
136
  title: string;
@@ -1,14 +1,14 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
  export const styles = tv({
3
3
  slots: {
4
- base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white text-text outline-none',
5
- title: 'typography-body-7 pb-4 pt-9 font-bold text-text',
4
+ base: 'relative flex max-h-full max-w-full flex-col rounded bg-white text-text outline-none',
5
+ title: 'typography-body-7 pb-4 pt-9 font-bold text-text transition-shadow delay-0 duration-200 ease-[ease]',
6
6
  close: 'absolute right-0 top-0 block p-3'
7
7
  },
8
8
  variants: {
9
9
  size: {
10
10
  full: {
11
- base: 'max-h-screen w-full flex-1',
11
+ base: 'h-screen max-h-screen w-full flex-1 rounded-none',
12
12
  close: 'p-2',
13
13
  title: 'px-4 py-3'
14
14
  },
@@ -18,14 +18,14 @@ export const styles = tv({
18
18
  },
19
19
  md: {
20
20
  base: 'w-[37.5rem]',
21
- title: 'px-7 '
21
+ title: 'px-7'
22
22
  },
23
23
  sm: {
24
24
  base: 'w-[25rem]',
25
25
  title: 'px-5'
26
26
  },
27
27
  fluid: {
28
- base: 'w-full',
28
+ base: 'w-screen',
29
29
  title: 'px-5'
30
30
  }
31
31
  },
@@ -36,8 +36,41 @@ export const styles = tv({
36
36
  false: {
37
37
  close: 'outline-none'
38
38
  }
39
+ },
40
+ compact: {
41
+ true: '',
42
+ false: ''
43
+ },
44
+ scrolled: {
45
+ true: {
46
+ title: 'shadow-[0px_2px_5px_0px] shadow-black/30'
47
+ }
39
48
  }
40
- }
49
+ },
50
+ compoundSlots: [
51
+ {
52
+ slots: [
53
+ 'base'
54
+ ],
55
+ size: [
56
+ 'md',
57
+ 'lg'
58
+ ],
59
+ compact: true,
60
+ className: 'max-h-[80vh] overflow-hidden'
61
+ },
62
+ {
63
+ slots: [
64
+ 'title'
65
+ ],
66
+ size: [
67
+ 'lg',
68
+ 'md'
69
+ ],
70
+ compact: true,
71
+ className: 'min-h-[90px] px-5 pb-4 pt-6'
72
+ }
73
+ ]
41
74
  }, {
42
75
  responsiveVariants: [
43
76
  'xsl',
@@ -1,3 +1,4 @@
1
+ import { RefObject } from 'react';
1
2
  import { type AriaDialogProps } from 'react-aria';
2
3
  import { type VariantProps } from 'tailwind-variants';
3
4
  import { styles } from './modal-dialog.styles.js';
@@ -15,6 +16,12 @@ export type ModalDialogProps = {
15
16
  * Additional className for Dialog
16
17
  */
17
18
  className?: string;
19
+ /**
20
+ * Alternate styling for **medium** and **large** sizes. Other sizes will continue to scroll within the backdrop.
21
+ *
22
+ * Keeps entire modal in view by adding internal scrolling and reducing internal padding.
23
+ */
24
+ compact?: boolean;
18
25
  /**
19
26
  * Full screen
20
27
  */
@@ -33,9 +40,35 @@ export type ModalDialogProps = {
33
40
  title?: string;
34
41
  } & AriaDialogProps;
35
42
  export type ModalDialogContextValue = {
43
+ /**
44
+ * Whether container can scroll
45
+ */
46
+ canScroll?: boolean;
47
+ /**
48
+ * Alternate styling for **medium** and **large** sizes. Other sizes will continue to scroll within the backdrop.
49
+ *
50
+ * Keeps entire modal in view by adding internal scrolling and reducing internal padding.
51
+ */
52
+ compact?: boolean;
53
+ /**
54
+ * Whether footer is present for styling
55
+ */
56
+ footerPresent?: boolean;
57
+ /**
58
+ * Sets whether footer is present for styling
59
+ */
60
+ setFooterPresent?: (present: boolean) => void;
36
61
  /**
37
62
  * Size of dialog
38
63
  */
39
64
  size?: Variants['size'];
65
+ /**
66
+ * Whether scroll is at bottom of the scrollable area
67
+ */
68
+ scrollAtBottom?: boolean;
69
+ /**
70
+ * Ref to use for scrolling animations
71
+ */
72
+ scrollingRef?: RefObject<HTMLDivElement>;
40
73
  };
41
74
  export {};
@@ -1,2 +1,2 @@
1
1
  import { type ModalProps } from './modal.types.js';
2
- export declare function Modal({ children, backdropStyle, title, role, body, size, className, fullscreen, ...props }: ModalProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Modal({ children, backdropStyle, title, role, body, size, className, fullscreen, compact, ...props }: ModalProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,11 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import { ModalBackdrop, ModalDialog } from './components/index.js';
4
- export function Modal({ children, backdropStyle, title, role, body, size, className, fullscreen, ...props }) {
4
+ export function Modal({ children, backdropStyle, title, role, body, size = 'md', className, fullscreen, compact = false, ...props }) {
5
5
  return React.createElement(ModalBackdrop, {
6
6
  size: size,
7
7
  className: backdropStyle,
8
+ compact: compact,
8
9
  ...props
9
10
  }, React.createElement(ModalDialog, {
10
11
  fullscreen: fullscreen,
@@ -13,6 +14,7 @@ export function Modal({ children, backdropStyle, title, role, body, size, classN
13
14
  role: role,
14
15
  body: body,
15
16
  size: size,
16
- className: className
17
+ className: className,
18
+ compact: compact
17
19
  }, children));
18
20
  }
@@ -8,7 +8,7 @@ export const styles = tv({
8
8
  after:left-[1.5px] after:top-0 after:size-0 after:border-x-[6.5px] after:border-t-[11px] after:border-x-[transparent] after:border-t-white
9
9
  `,
10
10
  closeBtn: 'absolute right-1 top-1 h-3 p-0 hover:opacity-80',
11
- content: 'w-[17.625rem] rounded-[3px] bg-white py-4 pl-3 pr-5',
11
+ content: 'w-[18.75rem] rounded-[3px] bg-white py-4 pl-3 pr-5',
12
12
  heading: 'typography-body-9 mb-2 font-medium text-text focus-visible:focus-outline',
13
13
  body: 'typography-body-10 text-text focus-visible:focus-outline'
14
14
  },
@@ -12,6 +12,7 @@ export const RadioGroupContext = createContext({
12
12
  size: 'medium',
13
13
  state: {
14
14
  name: '',
15
+ defaultSelectedValue: null,
15
16
  isDisabled: false,
16
17
  isReadOnly: false,
17
18
  isRequired: false,
@@ -7,6 +7,7 @@ import { ErrorMessage, Hint, Label } from '../../../index.js';
7
7
  import { styles } from './selector-checkbox-group.styles.js';
8
8
  export const SelectorCheckboxGroupContext = createContext({
9
9
  value: [],
10
+ defaultValue: [],
10
11
  isDisabled: false,
11
12
  isReadOnly: false,
12
13
  isSelected: ()=>false,
@@ -9,6 +9,7 @@ export const SelectorRadioGroupContext = createContext({
9
9
  orientation: 'vertical',
10
10
  state: {
11
11
  name: '',
12
+ defaultSelectedValue: null,
12
13
  isDisabled: false,
13
14
  isReadOnly: false,
14
15
  isRequired: false,