@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
@@ -30,10 +30,18 @@ const getLeftOffsetPerHorizontalPosition = (element: HTMLDivElement, screenWidth
30
30
  case 'right':
31
31
  // For smaller screens, if adjusting for right makes it go off screen on the left, adjust it to have a 16px space from the edge
32
32
  if (triggerDOMRect.left + rightOffset <= 0) {
33
+ // For extra small screens extra adjustment is needed e.g. <320px wide
34
+ if (triggerDOMRect.left + rightOffset - PANEL_WIDTH_SIZE <= -screenWidth) {
35
+ return rightOffset - (triggerDOMRect.left + rightOffset) + (screenWidth - PANEL_WIDTH_SIZE) / 2;
36
+ }
33
37
  return rightOffset - (triggerDOMRect.left + rightOffset) + 16;
34
38
  }
35
39
  return rightOffset;
36
40
  default:
41
+ // For extra small screens extra adjustment is needed e.g. <320px wide
42
+ if (triggerDOMRect?.left + PANEL_WIDTH_SIZE >= screenWidth) {
43
+ return -(triggerDOMRect?.left || 0) + (screenWidth - PANEL_WIDTH_SIZE) / 2;
44
+ }
37
45
  return 0;
38
46
  }
39
47
  };
@@ -14,6 +14,14 @@ export type PanelProps = {
14
14
  * Tag to render
15
15
  */
16
16
  headingTag?: keyof Pick<JSX.IntrinsicElements, 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'>;
17
+ /**
18
+ * onClose callback
19
+ */
20
+ onClose?: () => void;
21
+ /**
22
+ * Whether the popover is open by default
23
+ */
24
+ open?: boolean;
17
25
  /**
18
26
  * Placement of popover. If no placement provided it will default to top unless there is no space then will appear on bottom.
19
27
  */
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { useCallback, useEffect, useId, useLayoutEffect, useRef } from 'react';
3
+ import React, { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
4
4
  import { useOverlayTriggerState } from 'react-stately';
5
5
 
6
6
  import { Button } from '../button/index.js';
@@ -34,12 +34,15 @@ export function Popover({
34
34
  const panelId = useId();
35
35
  const styles = popoverStyles({ linkStyling });
36
36
  const ref = useRef<HTMLButtonElement & HTMLAnchorElement & HTMLSpanElement & HTMLDivElement>(null);
37
+ const [isOpenDefault, setIsOpenDefault] = useState(open);
37
38
 
38
39
  const handleClick = useCallback(
39
40
  (event: React.MouseEvent<HTMLElement>) => {
41
+ if (isOpenDefault) setIsOpenDefault(false);
40
42
  onClick(event);
41
43
  state.toggle();
42
44
  },
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
46
  [onClick, state],
44
47
  );
45
48
 
@@ -59,7 +62,8 @@ export function Popover({
59
62
 
60
63
  useLayoutEffect(() => {
61
64
  if (open) state.setOpen(true);
62
- }, [open, state]);
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, [open]);
63
67
 
64
68
  return (
65
69
  <div className={styles.base({ className })}>
@@ -70,6 +74,7 @@ export function Popover({
70
74
  soft={soft}
71
75
  aria-expanded={state.isOpen}
72
76
  aria-controls={panelId}
77
+ aria-haspopup="dialog"
73
78
  onClick={handleClick}
74
79
  ref={ref}
75
80
  size={size}
@@ -87,6 +92,15 @@ export function Popover({
87
92
  state={state}
88
93
  id={panelId}
89
94
  triggerRef={ref}
95
+ // Ensures popover heading doesn't get focused if default opened
96
+ open={isOpenDefault}
97
+ onClose={() => {
98
+ ref.current?.focus();
99
+ // Ensures focus handling works once popover is closed if it was default opened
100
+ if (isOpenDefault) {
101
+ setIsOpenDefault(false);
102
+ }
103
+ }}
90
104
  />
91
105
  )}
92
106
  </div>
@@ -58,7 +58,12 @@ function BaseSelectorCheckboxGroupOption(
58
58
  className={styles.base({})}
59
59
  >
60
60
  <VisuallyHidden>
61
- <input {...mergeProps(inputProps, focusProps)} ref={localRef} />
61
+ <input
62
+ {...mergeProps(inputProps, focusProps)}
63
+ // override the aria-describedby to prevent screen readers from reading the content of the option twice, once from the input and once from the cell
64
+ aria-describedby={undefined}
65
+ ref={localRef}
66
+ />
62
67
  </VisuallyHidden>
63
68
  {children}
64
69
  </FlexiCell>
@@ -55,7 +55,12 @@ function BaseSelectorRadioGroupOption(
55
55
  className={styles.base({})}
56
56
  >
57
57
  <VisuallyHidden>
58
- <input {...mergeProps(inputProps, focusProps)} ref={localRef} />
58
+ <input
59
+ {...mergeProps(inputProps, focusProps)}
60
+ // override the aria-describedby to prevent screen readers from reading the content of the option twice, once from the input and once from the cell
61
+ aria-describedby={undefined}
62
+ ref={localRef}
63
+ />
59
64
  </VisuallyHidden>
60
65
  {children}
61
66
  </FlexiCell>