@westpac/ui 0.59.1 → 0.59.3

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 (49) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/CHANGELOG.md +17 -0
  3. package/assets/icons/filled/arrow-back-filled.svg +3 -0
  4. package/assets/icons/filled/arrow-down-filled.svg +3 -0
  5. package/assets/icons/filled/arrow-forward-filled.svg +3 -0
  6. package/assets/icons/filled/arrow-up-filled.svg +3 -0
  7. package/assets/icons/outlined/arrow-back-outlined.svg +3 -0
  8. package/assets/icons/outlined/arrow-down-outlined.svg +3 -0
  9. package/assets/icons/outlined/arrow-forward-outlined.svg +3 -0
  10. package/assets/icons/outlined/arrow-up-outlined.svg +3 -0
  11. package/dist/component-type.json +1 -1
  12. package/dist/components/icon/components/arrow-back-icon.d.ts +2 -0
  13. package/dist/components/icon/components/arrow-back-icon.js +12 -0
  14. package/dist/components/icon/components/arrow-down-icon.d.ts +2 -0
  15. package/dist/components/icon/components/arrow-down-icon.js +12 -0
  16. package/dist/components/icon/components/arrow-forward-icon.d.ts +2 -0
  17. package/dist/components/icon/components/arrow-forward-icon.js +12 -0
  18. package/dist/components/icon/components/arrow-up-icon.d.ts +2 -0
  19. package/dist/components/icon/components/arrow-up-icon.js +12 -0
  20. package/dist/components/icon/icon.styles.js +5 -5
  21. package/dist/components/icon/index.d.ts +4 -0
  22. package/dist/components/icon/index.js +4 -0
  23. package/dist/components/link/link.styles.d.ts +0 -6
  24. package/dist/components/link/link.styles.js +5 -7
  25. package/dist/components/popover/components/panel/panel.component.d.ts +1 -1
  26. package/dist/components/popover/components/panel/panel.component.js +29 -12
  27. package/dist/components/popover/components/panel/panel.hook.js +6 -0
  28. package/dist/components/popover/components/panel/panel.types.d.ts +8 -0
  29. package/dist/components/popover/popover.component.js +14 -4
  30. package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.js +1 -0
  31. package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +1 -0
  32. package/dist/css/westpac-ui.css +150 -36
  33. package/dist/css/westpac-ui.min.css +150 -36
  34. package/package.json +5 -4
  35. package/src/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.types.ts +0 -4
  36. package/src/components/icon/components/arrow-back-icon.tsx +17 -0
  37. package/src/components/icon/components/arrow-down-icon.tsx +17 -0
  38. package/src/components/icon/components/arrow-forward-icon.tsx +17 -0
  39. package/src/components/icon/components/arrow-up-icon.tsx +17 -0
  40. package/src/components/icon/icon.styles.ts +5 -5
  41. package/src/components/icon/index.ts +4 -0
  42. package/src/components/link/link.component.tsx +1 -0
  43. package/src/components/link/link.styles.ts +5 -7
  44. package/src/components/popover/components/panel/panel.component.tsx +41 -23
  45. package/src/components/popover/components/panel/panel.hook.tsx +8 -0
  46. package/src/components/popover/components/panel/panel.types.ts +8 -0
  47. package/src/components/popover/popover.component.tsx +16 -2
  48. package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.tsx +6 -1
  49. package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +6 -1
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from '../icon.types.js';
2
+ export declare function ArrowBackIcon({ look, 'aria-label': ariaLabel, copyrightYear, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Icon } from '../icon.component.js';
3
+ export function ArrowBackIcon({ look = 'filled', 'aria-label': ariaLabel = 'Arrow Back', copyrightYear = '2025', ...props }) {
4
+ return React.createElement(Icon, {
5
+ "aria-label": ariaLabel,
6
+ copyrightYear: copyrightYear,
7
+ ...props
8
+ }, React.createElement("path", {
9
+ d: "M12 20L13.41 18.59L7.83 13L20 13V11L7.83 11L13.41 5.41L12 4L4 12L12 20Z",
10
+ fill: "currentColor"
11
+ }));
12
+ }
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from '../icon.types.js';
2
+ export declare function ArrowDownIcon({ look, 'aria-label': ariaLabel, copyrightYear, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Icon } from '../icon.component.js';
3
+ export function ArrowDownIcon({ look = 'filled', 'aria-label': ariaLabel = 'Arrow Down', copyrightYear = '2025', ...props }) {
4
+ return React.createElement(Icon, {
5
+ "aria-label": ariaLabel,
6
+ copyrightYear: copyrightYear,
7
+ ...props
8
+ }, React.createElement("path", {
9
+ d: "M20 12L18.59 10.59L13 16.17V4L11 4L11 16.17L5.41 10.59L4 12L12 20L20 12Z",
10
+ fill: "currentColor"
11
+ }));
12
+ }
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from '../icon.types.js';
2
+ export declare function ArrowForwardIcon({ look, 'aria-label': ariaLabel, copyrightYear, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Icon } from '../icon.component.js';
3
+ export function ArrowForwardIcon({ look = 'filled', 'aria-label': ariaLabel = 'Arrow Forward', copyrightYear = '2025', ...props }) {
4
+ return React.createElement(Icon, {
5
+ "aria-label": ariaLabel,
6
+ copyrightYear: copyrightYear,
7
+ ...props
8
+ }, React.createElement("path", {
9
+ d: "M12 4L10.59 5.41L16.17 11H4V13H16.17L10.59 18.59L12 20L20 12L12 4Z",
10
+ fill: "currentColor"
11
+ }));
12
+ }
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from '../icon.types.js';
2
+ export declare function ArrowUpIcon({ look, 'aria-label': ariaLabel, copyrightYear, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Icon } from '../icon.component.js';
3
+ export function ArrowUpIcon({ look = 'filled', 'aria-label': ariaLabel = 'Arrow Up', copyrightYear = '2025', ...props }) {
4
+ return React.createElement(Icon, {
5
+ "aria-label": ariaLabel,
6
+ copyrightYear: copyrightYear,
7
+ ...props
8
+ }, React.createElement("path", {
9
+ d: "M4 12L5.41 13.41L11 7.83L11 20H13V7.83L18.59 13.41L20 12L12 4L4 12Z",
10
+ fill: "currentColor"
11
+ }));
12
+ }
@@ -3,11 +3,11 @@ export const styles = tv({
3
3
  base: 'inline-block transition-colors disabled:pointer-events-none disabled:opacity-50',
4
4
  variants: {
5
5
  size: {
6
- xsmall: 'size-2',
7
- small: 'size-3',
8
- medium: 'size-4',
9
- large: 'size-6',
10
- xlarge: 'size-8'
6
+ xsmall: 'size-2 min-h-2 min-w-2',
7
+ small: 'size-3 min-h-3 min-w-3',
8
+ medium: 'size-4 min-h-4 min-w-4',
9
+ large: 'size-6 min-h-6 min-w-6',
10
+ xlarge: 'size-8 min-h-8 min-w-8'
11
11
  },
12
12
  color: {
13
13
  success: 'text-success',
@@ -6,14 +6,18 @@ export { AlertIcon } from './components/alert-icon.js';
6
6
  export { AndroidIcon } from './components/android-icon.js';
7
7
  export { AppleIcon } from './components/apple-icon.js';
8
8
  export { ArchiveBoxIcon } from './components/archive-box-icon.js';
9
+ export { ArrowBackIcon } from './components/arrow-back-icon.js';
9
10
  export { ArrowBackCircleIcon } from './components/arrow-back-circle-icon.js';
11
+ export { ArrowDownIcon } from './components/arrow-down-icon.js';
10
12
  export { ArrowDownCircleIcon } from './components/arrow-down-circle-icon.js';
11
13
  export { ArrowForkIcon } from './components/arrow-fork-icon.js';
14
+ export { ArrowForwardIcon } from './components/arrow-forward-icon.js';
12
15
  export { ArrowForwardCircleIcon } from './components/arrow-forward-circle-icon.js';
13
16
  export { ArrowLeftIcon } from './components/arrow-left-icon.js';
14
17
  export { ArrowRightIcon } from './components/arrow-right-icon.js';
15
18
  export { ArrowSplitIcon } from './components/arrow-split-icon.js';
16
19
  export { ArrowThreadReplyIcon } from './components/arrow-thread-reply-icon.js';
20
+ export { ArrowUpIcon } from './components/arrow-up-icon.js';
17
21
  export { ArrowUpCircleIcon } from './components/arrow-up-circle-icon.js';
18
22
  export { AtmIcon } from './components/atm-icon.js';
19
23
  export { AttacheCaseIcon } from './components/attache-case-icon.js';
@@ -6,14 +6,18 @@ export { AlertIcon } from './components/alert-icon.js';
6
6
  export { AndroidIcon } from './components/android-icon.js';
7
7
  export { AppleIcon } from './components/apple-icon.js';
8
8
  export { ArchiveBoxIcon } from './components/archive-box-icon.js';
9
+ export { ArrowBackIcon } from './components/arrow-back-icon.js';
9
10
  export { ArrowBackCircleIcon } from './components/arrow-back-circle-icon.js';
11
+ export { ArrowDownIcon } from './components/arrow-down-icon.js';
10
12
  export { ArrowDownCircleIcon } from './components/arrow-down-circle-icon.js';
11
13
  export { ArrowForkIcon } from './components/arrow-fork-icon.js';
14
+ export { ArrowForwardIcon } from './components/arrow-forward-icon.js';
12
15
  export { ArrowForwardCircleIcon } from './components/arrow-forward-circle-icon.js';
13
16
  export { ArrowLeftIcon } from './components/arrow-left-icon.js';
14
17
  export { ArrowRightIcon } from './components/arrow-right-icon.js';
15
18
  export { ArrowSplitIcon } from './components/arrow-split-icon.js';
16
19
  export { ArrowThreadReplyIcon } from './components/arrow-thread-reply-icon.js';
20
+ export { ArrowUpIcon } from './components/arrow-up-icon.js';
17
21
  export { ArrowUpCircleIcon } from './components/arrow-up-circle-icon.js';
18
22
  export { AtmIcon } from './components/atm-icon.js';
19
23
  export { AttacheCaseIcon } from './components/attache-case-icon.js';
@@ -2,8 +2,6 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
2
2
  type: {
3
3
  inline: {
4
4
  base: string;
5
- iconBefore: string;
6
- iconAfter: string;
7
5
  };
8
6
  standalone: {
9
7
  base: string;
@@ -30,8 +28,6 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
30
28
  type: {
31
29
  inline: {
32
30
  base: string;
33
- iconBefore: string;
34
- iconAfter: string;
35
31
  };
36
32
  standalone: {
37
33
  base: string;
@@ -56,8 +52,6 @@ export declare const styles: import("tailwind-variants").TVReturnType<{
56
52
  type: {
57
53
  inline: {
58
54
  base: string;
59
- iconBefore: string;
60
- iconAfter: string;
61
55
  };
62
56
  standalone: {
63
57
  base: string;
@@ -1,19 +1,17 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
  export const styles = tv({
3
3
  slots: {
4
- base: 'inline-flex bg-[transparent] hover:underline',
5
- iconBefore: 'mr-1',
6
- iconAfter: 'ml-1'
4
+ base: 'bg-[transparent] hover:underline',
5
+ iconBefore: 'relative bottom-[0.1em] mr-1',
6
+ iconAfter: 'relative bottom-[0.1em] ml-1'
7
7
  },
8
8
  variants: {
9
9
  type: {
10
10
  inline: {
11
- base: 'items-baseline text-link',
12
- iconBefore: 'self-center',
13
- iconAfter: 'self-center'
11
+ base: 'inline text-link'
14
12
  },
15
13
  standalone: {
16
- base: 'items-center text-text'
14
+ base: 'text-text'
17
15
  }
18
16
  },
19
17
  underline: {
@@ -1,5 +1,5 @@
1
1
  import { type PanelProps } from './panel.types.js';
2
- export declare function BasePanel({ state, heading, headingTag: Tag, content, placement, id, triggerRef, portal, }: PanelProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function BasePanel({ state, heading, headingTag: Tag, content, placement, id, triggerRef, onClose, open, portal, }: PanelProps): import("react/jsx-runtime").JSX.Element;
3
3
  /**
4
4
  * @private
5
5
  */
@@ -1,13 +1,14 @@
1
- import React, { useRef } from 'react';
2
- import { FocusScope } from 'react-aria';
1
+ import React, { useEffect, useRef } from 'react';
3
2
  import { createPortal } from 'react-dom';
4
3
  import { Button } from '../../../button/index.js';
5
4
  import { CloseIcon } from '../../../icon/index.js';
6
5
  import { usePanel } from './panel.hook.js';
7
6
  import { styles as panelStyles } from './panel.styles.js';
8
- export function BasePanel({ state, heading, headingTag: Tag = 'h1', content, placement = 'top', id, triggerRef, portal }) {
7
+ export function BasePanel({ state, heading, headingTag: Tag = 'h1', content, placement = 'top', id, triggerRef, onClose, open, portal }) {
9
8
  const popoverRef = useRef(null);
10
9
  const arrowRef = useRef(null);
10
+ const headingRef = useRef(null);
11
+ const buttonRef = useRef(null);
11
12
  const { popoverPosition, arrowPosition, localPlacement } = usePanel({
12
13
  state,
13
14
  placement,
@@ -18,27 +19,43 @@ export function BasePanel({ state, heading, headingTag: Tag = 'h1', content, pla
18
19
  const styles = panelStyles({
19
20
  placement: localPlacement
20
21
  });
21
- return React.createElement(FocusScope, {
22
- autoFocus: true,
23
- restoreFocus: true
24
- }, React.createElement("div", {
22
+ useEffect(()=>{
23
+ if (state.isOpen && !open) {
24
+ if (headingRef.current) {
25
+ headingRef.current.focus();
26
+ } else {
27
+ var _buttonRef_current;
28
+ (_buttonRef_current = buttonRef.current) === null || _buttonRef_current === void 0 ? void 0 : _buttonRef_current.focus();
29
+ }
30
+ }
31
+ }, [
32
+ state.isOpen
33
+ ]);
34
+ return React.createElement("div", {
25
35
  style: popoverPosition,
26
36
  className: styles.popover(),
27
37
  "test-id": "popover",
28
38
  id: id,
29
- ref: popoverRef
39
+ ref: popoverRef,
40
+ role: "dialog"
30
41
  }, React.createElement("div", {
31
42
  className: styles.content()
32
43
  }, heading && React.createElement(Tag, {
33
44
  className: styles.heading(),
34
- tabIndex: 0
45
+ tabIndex: -1,
46
+ ref: headingRef
35
47
  }, heading), React.createElement("div", {
36
48
  className: styles.body(),
37
- tabIndex: 0
49
+ id: "popover-content"
38
50
  }, content), React.createElement(Button, {
39
51
  look: "link",
52
+ tag: "button",
40
53
  size: "small",
41
- onClick: ()=>state.close(),
54
+ ref: buttonRef,
55
+ onClick: ()=>{
56
+ onClose === null || onClose === void 0 ? void 0 : onClose();
57
+ state.close();
58
+ },
42
59
  className: styles.closeBtn(),
43
60
  iconAfter: ()=>React.createElement(CloseIcon, {
44
61
  color: "muted",
@@ -52,7 +69,7 @@ export function BasePanel({ state, heading, headingTag: Tag = 'h1', content, pla
52
69
  style: arrowPosition,
53
70
  "test-id": "arrow",
54
71
  ref: arrowRef
55
- })));
72
+ }));
56
73
  }
57
74
  export function Panel({ portal = false, ...props }) {
58
75
  if (portal) {
@@ -22,10 +22,16 @@ const getLeftOffsetPerHorizontalPosition = (element, screenWidth)=>{
22
22
  return (PANEL_WIDTH_SIZE - ((triggerDOMRect === null || triggerDOMRect === void 0 ? void 0 : triggerDOMRect.width) || 0)) / 2 * -1;
23
23
  case 'right':
24
24
  if (triggerDOMRect.left + rightOffset <= 0) {
25
+ if (triggerDOMRect.left + rightOffset - PANEL_WIDTH_SIZE <= -screenWidth) {
26
+ return rightOffset - (triggerDOMRect.left + rightOffset) + (screenWidth - PANEL_WIDTH_SIZE) / 2;
27
+ }
25
28
  return rightOffset - (triggerDOMRect.left + rightOffset) + 16;
26
29
  }
27
30
  return rightOffset;
28
31
  default:
32
+ if ((triggerDOMRect === null || triggerDOMRect === void 0 ? void 0 : triggerDOMRect.left) + PANEL_WIDTH_SIZE >= screenWidth) {
33
+ return -((triggerDOMRect === null || triggerDOMRect === void 0 ? void 0 : triggerDOMRect.left) || 0) + (screenWidth - PANEL_WIDTH_SIZE) / 2;
34
+ }
29
35
  return 0;
30
36
  }
31
37
  };
@@ -13,6 +13,14 @@ export type PanelProps = {
13
13
  * Tag to render
14
14
  */
15
15
  headingTag?: keyof Pick<JSX.IntrinsicElements, 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>;
16
+ /**
17
+ * onClose callback
18
+ */
19
+ onClose?: () => void;
20
+ /**
21
+ * Whether the popover is open by default
22
+ */
23
+ open?: boolean;
16
24
  /**
17
25
  * Placement of popover. If no placement provided it will default to top unless there is no space then will appear on bottom.
18
26
  */
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
2
+ import React, { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
3
3
  import { useOverlayTriggerState } from 'react-stately';
4
4
  import { Button } from '../button/index.js';
5
5
  import { Panel } from './components/panel/panel.component.js';
@@ -11,7 +11,9 @@ export function Popover({ children, className, headingTag, content, heading, onC
11
11
  linkStyling
12
12
  });
13
13
  const ref = useRef(null);
14
+ const [isOpenDefault, setIsOpenDefault] = useState(open);
14
15
  const handleClick = useCallback((event)=>{
16
+ if (isOpenDefault) setIsOpenDefault(false);
15
17
  onClick(event);
16
18
  state.toggle();
17
19
  }, [
@@ -35,8 +37,7 @@ export function Popover({ children, className, headingTag, content, heading, onC
35
37
  useLayoutEffect(()=>{
36
38
  if (open) state.setOpen(true);
37
39
  }, [
38
- open,
39
- state
40
+ open
40
41
  ]);
41
42
  return React.createElement("div", {
42
43
  className: styles.base({
@@ -49,6 +50,7 @@ export function Popover({ children, className, headingTag, content, heading, onC
49
50
  soft: soft,
50
51
  "aria-expanded": state.isOpen,
51
52
  "aria-controls": panelId,
53
+ "aria-haspopup": "dialog",
52
54
  onClick: handleClick,
53
55
  ref: ref,
54
56
  size: size,
@@ -61,6 +63,14 @@ export function Popover({ children, className, headingTag, content, heading, onC
61
63
  content: content,
62
64
  state: state,
63
65
  id: panelId,
64
- triggerRef: ref
66
+ triggerRef: ref,
67
+ open: isOpenDefault,
68
+ onClose: ()=>{
69
+ var _ref_current;
70
+ (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
71
+ if (isOpenDefault) {
72
+ setIsOpenDefault(false);
73
+ }
74
+ }
65
75
  }));
66
76
  }
@@ -40,6 +40,7 @@ function BaseSelectorCheckboxGroupOption({ className, children, value, withBorde
40
40
  className: styles.base({})
41
41
  }, React.createElement(VisuallyHidden, null, React.createElement("input", {
42
42
  ...mergeProps(inputProps, focusProps),
43
+ "aria-describedby": undefined,
43
44
  ref: localRef
44
45
  })), children);
45
46
  }
@@ -47,6 +47,7 @@ function BaseSelectorRadioGroupOption({ className, children, value, withBorder =
47
47
  className: styles.base({})
48
48
  }, React.createElement(VisuallyHidden, null, React.createElement("input", {
49
49
  ...mergeProps(inputProps, focusProps),
50
+ "aria-describedby": undefined,
50
51
  ref: localRef
51
52
  })), children);
52
53
  }