@westpac/ui 0.59.2 → 0.59.4
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.
- package/.eslintrc.cjs +1 -1
- package/CHANGELOG.md +18 -0
- package/assets/icons/filled/arrow-back-filled.svg +3 -0
- package/assets/icons/filled/arrow-down-filled.svg +3 -0
- package/assets/icons/filled/arrow-forward-filled.svg +3 -0
- package/assets/icons/filled/arrow-up-filled.svg +3 -0
- package/assets/icons/outlined/arrow-back-outlined.svg +3 -0
- package/assets/icons/outlined/arrow-down-outlined.svg +3 -0
- package/assets/icons/outlined/arrow-forward-outlined.svg +3 -0
- package/assets/icons/outlined/arrow-up-outlined.svg +3 -0
- package/dist/component-type.json +1 -1
- package/dist/components/date-picker-beta/date-picker.styles.js +4 -4
- package/dist/components/icon/components/arrow-back-icon.d.ts +2 -0
- package/dist/components/icon/components/arrow-back-icon.js +12 -0
- package/dist/components/icon/components/arrow-down-icon.d.ts +2 -0
- package/dist/components/icon/components/arrow-down-icon.js +12 -0
- package/dist/components/icon/components/arrow-forward-icon.d.ts +2 -0
- package/dist/components/icon/components/arrow-forward-icon.js +12 -0
- package/dist/components/icon/components/arrow-up-icon.d.ts +2 -0
- package/dist/components/icon/components/arrow-up-icon.js +12 -0
- package/dist/components/icon/icon.styles.js +5 -5
- package/dist/components/icon/index.d.ts +4 -0
- package/dist/components/icon/index.js +4 -0
- package/dist/components/input-group/components/input-group-supporting-text/input-group-supporting-text.styles.d.ts +1 -1
- package/dist/components/input-group/components/input-group-supporting-text/input-group-supporting-text.styles.js +1 -1
- package/dist/components/link/link.styles.d.ts +0 -6
- package/dist/components/link/link.styles.js +5 -7
- package/dist/components/popover/components/panel/panel.component.d.ts +1 -1
- package/dist/components/popover/components/panel/panel.component.js +29 -12
- package/dist/components/popover/components/panel/panel.types.d.ts +8 -0
- package/dist/components/popover/popover.component.js +14 -4
- package/dist/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.js +1 -0
- package/dist/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.js +1 -0
- package/dist/css/westpac-ui.css +222 -36
- package/dist/css/westpac-ui.min.css +222 -36
- package/package.json +6 -5
- package/src/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.types.ts +0 -4
- package/src/components/date-picker-beta/date-picker.styles.ts +4 -4
- package/src/components/icon/components/arrow-back-icon.tsx +17 -0
- package/src/components/icon/components/arrow-down-icon.tsx +17 -0
- package/src/components/icon/components/arrow-forward-icon.tsx +17 -0
- package/src/components/icon/components/arrow-up-icon.tsx +17 -0
- package/src/components/icon/icon.styles.ts +5 -5
- package/src/components/icon/index.ts +4 -0
- package/src/components/input-group/components/input-group-supporting-text/input-group-supporting-text.styles.ts +1 -1
- package/src/components/link/link.component.tsx +1 -0
- package/src/components/link/link.styles.ts +5 -7
- package/src/components/popover/components/panel/panel.component.tsx +41 -23
- package/src/components/popover/components/panel/panel.types.ts +8 -0
- package/src/components/popover/popover.component.tsx +16 -2
- package/src/components/selector/components/selector-checkbox-group/components/selector-checkbox-group-option/selector-checkbox-group-option.component.tsx +6 -1
- package/src/components/selector/components/selector-radio-group/components/selector-radio-group-option/selector-radio-group-option.component.tsx +6 -1
|
@@ -5,11 +5,11 @@ export const styles = tv(
|
|
|
5
5
|
base: 'inline-block transition-colors disabled:pointer-events-none disabled:opacity-50',
|
|
6
6
|
variants: {
|
|
7
7
|
size: {
|
|
8
|
-
xsmall: 'size-2',
|
|
9
|
-
small: 'size-3',
|
|
10
|
-
medium: 'size-4',
|
|
11
|
-
large: 'size-6',
|
|
12
|
-
xlarge: 'size-8',
|
|
8
|
+
xsmall: 'size-2 min-h-2 min-w-2',
|
|
9
|
+
small: 'size-3 min-h-3 min-w-3',
|
|
10
|
+
medium: 'size-4 min-h-4 min-w-4',
|
|
11
|
+
large: 'size-6 min-h-6 min-w-6',
|
|
12
|
+
xlarge: 'size-8 min-h-8 min-w-8',
|
|
13
13
|
},
|
|
14
14
|
color: {
|
|
15
15
|
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';
|
|
@@ -3,19 +3,17 @@ import { tv } from 'tailwind-variants';
|
|
|
3
3
|
export const styles = tv(
|
|
4
4
|
{
|
|
5
5
|
slots: {
|
|
6
|
-
base: '
|
|
7
|
-
iconBefore: 'mr-1',
|
|
8
|
-
iconAfter: 'ml-1',
|
|
6
|
+
base: 'bg-[transparent] hover:underline',
|
|
7
|
+
iconBefore: 'relative bottom-[0.1em] mr-1',
|
|
8
|
+
iconAfter: 'relative bottom-[0.1em] ml-1',
|
|
9
9
|
},
|
|
10
10
|
variants: {
|
|
11
11
|
type: {
|
|
12
12
|
inline: {
|
|
13
|
-
base: '
|
|
14
|
-
iconBefore: 'self-center',
|
|
15
|
-
iconAfter: 'self-center',
|
|
13
|
+
base: 'inline text-link',
|
|
16
14
|
},
|
|
17
15
|
standalone: {
|
|
18
|
-
base: '
|
|
16
|
+
base: 'text-text',
|
|
19
17
|
},
|
|
20
18
|
},
|
|
21
19
|
underline: {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
|
4
|
+
import { ButtonRef } from '../../../button/button.types.js';
|
|
5
5
|
import { Button } from '../../../button/index.js';
|
|
6
6
|
import { CloseIcon } from '../../../icon/index.js';
|
|
7
7
|
|
|
@@ -17,10 +17,14 @@ export function BasePanel({
|
|
|
17
17
|
placement = 'top',
|
|
18
18
|
id,
|
|
19
19
|
triggerRef,
|
|
20
|
+
onClose,
|
|
21
|
+
open,
|
|
20
22
|
portal,
|
|
21
23
|
}: PanelProps) {
|
|
22
24
|
const popoverRef = useRef<HTMLDivElement>(null);
|
|
23
25
|
const arrowRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const headingRef = useRef<HTMLHeadingElement>(null);
|
|
27
|
+
const buttonRef = useRef<ButtonRef>(null);
|
|
24
28
|
const { popoverPosition, arrowPosition, localPlacement } = usePanel({
|
|
25
29
|
state,
|
|
26
30
|
placement,
|
|
@@ -29,30 +33,44 @@ export function BasePanel({
|
|
|
29
33
|
popoverRef,
|
|
30
34
|
});
|
|
31
35
|
const styles = panelStyles({ placement: localPlacement });
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (state.isOpen && !open) {
|
|
38
|
+
if (headingRef.current) {
|
|
39
|
+
headingRef.current.focus();
|
|
40
|
+
} else {
|
|
41
|
+
buttonRef.current?.focus();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
}, [state.isOpen]);
|
|
46
|
+
|
|
32
47
|
return (
|
|
33
|
-
<
|
|
34
|
-
<div
|
|
35
|
-
|
|
36
|
-
{heading
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{content}
|
|
43
|
-
</div>
|
|
44
|
-
<Button
|
|
45
|
-
look="link"
|
|
46
|
-
size="small"
|
|
47
|
-
onClick={() => state.close()}
|
|
48
|
-
className={styles.closeBtn()}
|
|
49
|
-
iconAfter={() => <CloseIcon color="muted" size="small" aria-hidden />}
|
|
50
|
-
aria-label="Close popover"
|
|
51
|
-
/>
|
|
48
|
+
<div style={popoverPosition} className={styles.popover()} test-id="popover" id={id} ref={popoverRef} role="dialog">
|
|
49
|
+
<div className={styles.content()}>
|
|
50
|
+
{heading && (
|
|
51
|
+
<Tag className={styles.heading()} tabIndex={-1} ref={headingRef}>
|
|
52
|
+
{heading}
|
|
53
|
+
</Tag>
|
|
54
|
+
)}
|
|
55
|
+
<div className={styles.body()} id="popover-content">
|
|
56
|
+
{content}
|
|
52
57
|
</div>
|
|
53
|
-
<
|
|
58
|
+
<Button
|
|
59
|
+
look="link"
|
|
60
|
+
tag="button"
|
|
61
|
+
size="small"
|
|
62
|
+
ref={buttonRef}
|
|
63
|
+
onClick={() => {
|
|
64
|
+
onClose?.();
|
|
65
|
+
state.close();
|
|
66
|
+
}}
|
|
67
|
+
className={styles.closeBtn()}
|
|
68
|
+
iconAfter={() => <CloseIcon color="muted" size="small" aria-hidden />}
|
|
69
|
+
aria-label="Close popover"
|
|
70
|
+
/>
|
|
54
71
|
</div>
|
|
55
|
-
|
|
72
|
+
<div aria-hidden className={styles.arrow()} style={arrowPosition} test-id="arrow" ref={arrowRef} />
|
|
73
|
+
</div>
|
|
56
74
|
);
|
|
57
75
|
}
|
|
58
76
|
|
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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>
|