@westpac/ui 0.49.0 → 0.50.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.
- package/CHANGELOG.md +28 -0
- package/dist/component-type.json +1 -1
- package/dist/components/accordion/components/accordion-item/accordion-item.component.js +44 -24
- package/dist/components/accordion/components/accordion-item/accordion-item.styles.d.ts +18 -6
- package/dist/components/accordion/components/accordion-item/accordion-item.styles.js +10 -6
- package/dist/components/autocomplete/autocomplete.component.d.ts +1 -1
- package/dist/components/autocomplete/autocomplete.component.js +3 -2
- package/dist/components/autocomplete/autocomplete.types.d.ts +6 -0
- package/dist/components/date-picker-beta/components/calendar/calendar.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/calendar.component.js +101 -0
- package/dist/components/date-picker-beta/components/calendar/calendar.types.d.ts +2 -0
- package/dist/components/date-picker-beta/components/calendar/calendar.types.js +1 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.component.js +28 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.styles.d.ts +103 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.styles.js +39 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.types.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.types.js +1 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.component.js +26 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.types.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.types.js +1 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.component.js +23 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.styles.d.ts +28 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.styles.js +14 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.types.d.ts +2 -0
- package/dist/components/date-picker-beta/components/calendar/components/select/select.types.js +1 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.component.js +20 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.styles.d.ts +44 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.styles.js +26 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.types.d.ts +7 -0
- package/dist/components/date-picker-beta/components/date-field/components/date-segment/date-segment.types.js +1 -0
- package/dist/components/date-picker-beta/components/date-field/date-field.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/date-field/date-field.component.js +25 -0
- package/dist/components/date-picker-beta/components/date-field/date-field.types.d.ts +4 -0
- package/dist/components/date-picker-beta/components/date-field/date-field.types.js +1 -0
- package/dist/components/date-picker-beta/components/dialog/dialog.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/dialog/dialog.component.js +16 -0
- package/dist/components/date-picker-beta/components/dialog/dialog.types.d.ts +3 -0
- package/dist/components/date-picker-beta/components/dialog/dialog.types.js +1 -0
- package/dist/components/date-picker-beta/components/popover/popover.component.d.ts +5 -0
- package/dist/components/date-picker-beta/components/popover/popover.component.js +38 -0
- package/dist/components/date-picker-beta/components/popover/popover.styles.d.ts +71 -0
- package/dist/components/date-picker-beta/components/popover/popover.styles.js +35 -0
- package/dist/components/date-picker-beta/components/popover/popover.types.d.ts +9 -0
- package/dist/components/date-picker-beta/components/popover/popover.types.js +1 -0
- package/dist/components/date-picker-beta/date-picker.component.d.ts +2 -0
- package/dist/components/date-picker-beta/date-picker.component.js +114 -0
- package/dist/components/date-picker-beta/date-picker.styles.d.ts +107 -0
- package/dist/components/date-picker-beta/date-picker.styles.js +47 -0
- package/dist/components/date-picker-beta/date-picker.types.d.ts +32 -0
- package/dist/components/date-picker-beta/date-picker.types.js +1 -0
- package/dist/components/date-picker-beta/index.d.ts +2 -0
- package/dist/components/date-picker-beta/index.js +1 -0
- package/dist/components/footer/footer.component.js +4 -11
- package/dist/components/footer/footer.styles.d.ts +3 -21
- package/dist/components/footer/footer.styles.js +3 -9
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/css/westpac-ui.css +1025 -35
- package/dist/css/westpac-ui.min.css +1025 -35
- package/dist/hook/breakpoints.hook.js +59 -10
- package/dist/hook/index.d.ts +1 -0
- package/dist/hook/index.js +1 -0
- package/dist/tailwind/constants/colors.d.ts +25 -25
- package/dist/tailwind/tailwind-plugin.js +20 -0
- package/dist/tailwind/themes/index.d.ts +27 -27
- package/package.json +10 -5
- package/src/components/accordion/components/accordion-item/accordion-item.component.tsx +49 -32
- package/src/components/accordion/components/accordion-item/accordion-item.styles.ts +10 -6
- package/src/components/autocomplete/autocomplete.component.tsx +3 -1
- package/src/components/autocomplete/autocomplete.types.ts +6 -0
- package/src/components/date-picker-beta/components/calendar/calendar.component.tsx +106 -0
- package/src/components/date-picker-beta/components/calendar/calendar.types.ts +3 -0
- package/src/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.component.tsx +42 -0
- package/src/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.styles.ts +40 -0
- package/src/components/date-picker-beta/components/calendar/components/calendar-cell/calendar-cell.types.ts +8 -0
- package/src/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.component.tsx +36 -0
- package/src/components/date-picker-beta/components/calendar/components/calendar-grid/calendar-grid.types.ts +4 -0
- package/src/components/date-picker-beta/components/calendar/components/select/select.component.tsx +21 -0
- package/src/components/date-picker-beta/components/calendar/components/select/select.styles.ts +13 -0
- package/src/components/date-picker-beta/components/calendar/components/select/select.types.ts +3 -0
- package/src/components/date-picker-beta/components/date-field/components/date-segment/date-segment.component.tsx +26 -0
- package/src/components/date-picker-beta/components/date-field/components/date-segment/date-segment.styles.ts +22 -0
- package/src/components/date-picker-beta/components/date-field/components/date-segment/date-segment.types.ts +8 -0
- package/src/components/date-picker-beta/components/date-field/date-field.component.tsx +32 -0
- package/src/components/date-picker-beta/components/date-field/date-field.types.ts +3 -0
- package/src/components/date-picker-beta/components/dialog/dialog.component.tsx +23 -0
- package/src/components/date-picker-beta/components/dialog/dialog.types.ts +4 -0
- package/src/components/date-picker-beta/components/popover/popover.component.tsx +34 -0
- package/src/components/date-picker-beta/components/popover/popover.styles.ts +34 -0
- package/src/components/date-picker-beta/components/popover/popover.types.ts +10 -0
- package/src/components/date-picker-beta/date-picker.component.tsx +114 -0
- package/src/components/date-picker-beta/date-picker.styles.ts +44 -0
- package/src/components/date-picker-beta/date-picker.types.ts +40 -0
- package/src/components/date-picker-beta/index.ts +2 -0
- package/src/components/footer/footer.component.tsx +8 -12
- package/src/components/footer/footer.styles.ts +2 -6
- package/src/components/index.ts +1 -0
- package/src/hook/breakpoints.hook.ts +71 -11
- package/src/hook/index.ts +1 -0
- package/src/tailwind/tailwind-plugin.ts +20 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
export const styles = tv(
|
|
4
|
+
{
|
|
5
|
+
slots: {
|
|
6
|
+
underlay: 'fixed inset-0',
|
|
7
|
+
popover: 'bg-white',
|
|
8
|
+
header: '',
|
|
9
|
+
headerLabel: '',
|
|
10
|
+
closeButton: 'flex items-center justify-center focus-outline',
|
|
11
|
+
},
|
|
12
|
+
variants: {
|
|
13
|
+
showAsBottomSheet: {
|
|
14
|
+
true: {
|
|
15
|
+
underlay: 'animate-fadeIn bg-black/20',
|
|
16
|
+
popover: '!fixed inset-x-0 !bottom-0 !left-0 !top-auto animate-slideUp overflow-auto rounded-t px-[8%] pb-3',
|
|
17
|
+
header: 'mx-[-8vw] flex items-center justify-between border-b border-b-border px-3.5 py-2',
|
|
18
|
+
headerLabel: 'typography-body-10 text-text',
|
|
19
|
+
closeButton:
|
|
20
|
+
'pointer-events-none touch-none rounded-full bg-white opacity-0 focus:pointer-events-auto focus:touch-auto focus:opacity-100',
|
|
21
|
+
},
|
|
22
|
+
false: {
|
|
23
|
+
underlay: '',
|
|
24
|
+
closeButton:
|
|
25
|
+
'border-border pointer-events-none absolute right-0 top-0 size-5 -translate-y-1/2 translate-x-1/2 touch-none rounded-full border bg-white opacity-0 focus:pointer-events-auto focus:touch-auto focus:opacity-100',
|
|
26
|
+
headerLabel: 'hidden',
|
|
27
|
+
popover:
|
|
28
|
+
'absolute mt-1 scale-100 animate-fadeIn rounded border border-border bg-white opacity-100 shadow-[0_5px_10px_rgba(0,0,0,0.2)]',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{ responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
|
|
34
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AriaPopoverProps } from 'react-aria';
|
|
3
|
+
import { OverlayTriggerState } from 'react-stately';
|
|
4
|
+
|
|
5
|
+
export type PopoverProps = Omit<AriaPopoverProps, 'popoverRef'> & {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
showAsBottomSheet?: boolean;
|
|
8
|
+
state: OverlayTriggerState;
|
|
9
|
+
portalContainer?: Element;
|
|
10
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { DateValue, getDayOfWeek, isWeekend } from '@internationalized/date';
|
|
4
|
+
import React, { useMemo, useRef } from 'react';
|
|
5
|
+
import { useButton, useDatePicker, useLocale } from 'react-aria';
|
|
6
|
+
import { useDatePickerState } from 'react-stately';
|
|
7
|
+
|
|
8
|
+
import { useBreakpoint } from '../../hook/breakpoints.hook.js';
|
|
9
|
+
import { Breakpoint } from '../../tailwind/constants/index.js';
|
|
10
|
+
import { Button } from '../button/index.js';
|
|
11
|
+
import { CalendarIcon } from '../icon/index.js';
|
|
12
|
+
|
|
13
|
+
import { Calendar } from './components/calendar/calendar.component.js';
|
|
14
|
+
import { DateField } from './components/date-field/date-field.component.js';
|
|
15
|
+
import { Dialog } from './components/dialog/dialog.component.js';
|
|
16
|
+
import { Popover } from './components/popover/popover.component.js';
|
|
17
|
+
import { styles as datePickerStyles } from './date-picker.styles.js';
|
|
18
|
+
import { type DatePickerBetaProps } from './date-picker.types.js';
|
|
19
|
+
|
|
20
|
+
const BREAKPOINTS_DECRECENT = ['xl', 'lg', 'md', 'sm', 'xsl', 'initial'] as const;
|
|
21
|
+
export function DatePickerBeta({
|
|
22
|
+
size = 'medium',
|
|
23
|
+
className,
|
|
24
|
+
bottomSheetView = { initial: true, xsl: false },
|
|
25
|
+
isDateUnavailable,
|
|
26
|
+
disableDaysOfWeek,
|
|
27
|
+
disableWeekends,
|
|
28
|
+
separator,
|
|
29
|
+
portalContainer,
|
|
30
|
+
...props
|
|
31
|
+
}: DatePickerBetaProps) {
|
|
32
|
+
const { locale } = useLocale();
|
|
33
|
+
|
|
34
|
+
const enhancedIsDateUnavailable = useMemo(() => {
|
|
35
|
+
return disableDaysOfWeek || disableWeekends
|
|
36
|
+
? (date: DateValue) => {
|
|
37
|
+
let conditions = [isDateUnavailable?.(date) || false];
|
|
38
|
+
if (disableDaysOfWeek) {
|
|
39
|
+
conditions = [disableDaysOfWeek.indexOf(getDayOfWeek(date, locale)) !== -1, ...conditions];
|
|
40
|
+
}
|
|
41
|
+
if (disableWeekends) {
|
|
42
|
+
conditions = [isWeekend(date, locale), ...conditions];
|
|
43
|
+
}
|
|
44
|
+
return conditions.some(condition => condition);
|
|
45
|
+
}
|
|
46
|
+
: isDateUnavailable;
|
|
47
|
+
}, [disableDaysOfWeek, disableWeekends, isDateUnavailable, locale]);
|
|
48
|
+
|
|
49
|
+
const state = useDatePickerState({ isDateUnavailable: enhancedIsDateUnavailable, ...props });
|
|
50
|
+
const styles = datePickerStyles({ size, isInvalid: state.isInvalid, isDisabled: props.isDisabled });
|
|
51
|
+
const breakpoint = useBreakpoint();
|
|
52
|
+
const ref = useRef(null);
|
|
53
|
+
|
|
54
|
+
const { groupProps, labelProps, fieldProps, buttonProps, dialogProps, calendarProps } = useDatePicker(
|
|
55
|
+
{ isDateUnavailable: enhancedIsDateUnavailable, ...props },
|
|
56
|
+
state,
|
|
57
|
+
ref,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const showAsBottomSheet: boolean = useMemo(() => {
|
|
61
|
+
if (typeof bottomSheetView === 'boolean') {
|
|
62
|
+
return bottomSheetView;
|
|
63
|
+
}
|
|
64
|
+
const currentBreakpointIndex = BREAKPOINTS_DECRECENT.findIndex(bp => bp === breakpoint);
|
|
65
|
+
const finalBreakPoint = [breakpoint, ...BREAKPOINTS_DECRECENT.slice(currentBreakpointIndex)].find(
|
|
66
|
+
currentBreakpoint => bottomSheetView[currentBreakpoint] !== undefined,
|
|
67
|
+
) as Breakpoint | 'initial';
|
|
68
|
+
|
|
69
|
+
return bottomSheetView[finalBreakPoint] || false;
|
|
70
|
+
}, [bottomSheetView, breakpoint]);
|
|
71
|
+
|
|
72
|
+
const buttonRef = useRef(null);
|
|
73
|
+
|
|
74
|
+
const { buttonProps: newButtonProps } = useButton(buttonProps, buttonRef);
|
|
75
|
+
|
|
76
|
+
const brandContainer = useMemo(() => {
|
|
77
|
+
return (
|
|
78
|
+
document.querySelector('[data-theme]') ||
|
|
79
|
+
document.querySelector('[class^="theme-"], [class*=" theme-"]') ||
|
|
80
|
+
undefined
|
|
81
|
+
);
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<div {...labelProps}>{props.label}</div>
|
|
87
|
+
<div {...props} {...groupProps} ref={ref} className={styles.input({ className })}>
|
|
88
|
+
<DateField separator={separator} {...fieldProps} />
|
|
89
|
+
<Button
|
|
90
|
+
look="faint"
|
|
91
|
+
className={styles.button()}
|
|
92
|
+
iconColor="muted"
|
|
93
|
+
size={size}
|
|
94
|
+
iconAfter={CalendarIcon}
|
|
95
|
+
{...newButtonProps}
|
|
96
|
+
aria-labelledby={undefined}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
{state.isOpen && (
|
|
100
|
+
<Popover
|
|
101
|
+
portalContainer={portalContainer || brandContainer}
|
|
102
|
+
showAsBottomSheet={showAsBottomSheet}
|
|
103
|
+
state={state}
|
|
104
|
+
triggerRef={ref}
|
|
105
|
+
placement="bottom left"
|
|
106
|
+
>
|
|
107
|
+
<Dialog {...dialogProps}>
|
|
108
|
+
<Calendar {...calendarProps} firstDayOfWeek={props.firstDayOfWeek} />
|
|
109
|
+
</Dialog>
|
|
110
|
+
</Popover>
|
|
111
|
+
)}
|
|
112
|
+
</>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
export const styles = tv(
|
|
4
|
+
{
|
|
5
|
+
slots: {
|
|
6
|
+
input: 'form-control flex items-center border-borderDark disabled:form-control-disabled',
|
|
7
|
+
button:
|
|
8
|
+
'flex h-auto items-center justify-center rounded-l-none border-y-0 border-l border-r-0 border-l-borderDark bg-light',
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
small: {
|
|
13
|
+
input: 'form-control-small gap-1.5',
|
|
14
|
+
button: '-my-0.5 -mr-1.5 mb-[-0.25rem] min-h-5 py-[0.25rem]',
|
|
15
|
+
},
|
|
16
|
+
medium: {
|
|
17
|
+
input: 'form-control-medium gap-2',
|
|
18
|
+
button: 'my-[-0.3125rem] -mr-2 min-h-6 py-[0.3125rem]',
|
|
19
|
+
},
|
|
20
|
+
large: {
|
|
21
|
+
input: 'form-control-large gap-2.5',
|
|
22
|
+
button: 'my-[-0.5rem] -mr-2.5 min-h-7 py-[0.5rem]',
|
|
23
|
+
},
|
|
24
|
+
xlarge: {
|
|
25
|
+
input: 'form-control-xlarge gap-3',
|
|
26
|
+
button: '-my-1.5 -mr-3 mb-[-0.625rem] min-h-8 py-1.5',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
isInvalid: {
|
|
30
|
+
true: {
|
|
31
|
+
input: 'border-danger',
|
|
32
|
+
},
|
|
33
|
+
false: {},
|
|
34
|
+
},
|
|
35
|
+
isDisabled: {
|
|
36
|
+
true: {
|
|
37
|
+
input: 'form-control-disabled',
|
|
38
|
+
},
|
|
39
|
+
false: {},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{ responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
|
|
44
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { DateValue } from 'react-aria';
|
|
3
|
+
import { DatePickerStateOptions } from 'react-stately';
|
|
4
|
+
import { VariantProps } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
import { Breakpoint } from '../../tailwind/constants/index.js';
|
|
7
|
+
|
|
8
|
+
import { styles } from './date-picker.styles.js';
|
|
9
|
+
|
|
10
|
+
type Variants = VariantProps<typeof styles>;
|
|
11
|
+
|
|
12
|
+
export type DatePickerBetaProps<T extends DateValue = DateValue> = DatePickerStateOptions<T> &
|
|
13
|
+
Variants &
|
|
14
|
+
Omit<HTMLAttributes<HTMLDivElement>, 'invalid'> & {
|
|
15
|
+
/**
|
|
16
|
+
* Determines whether to display the component as a bottom sheet view.
|
|
17
|
+
* Can also accept an object to conditionally enable the bottom sheet based on breakpoints.
|
|
18
|
+
*/
|
|
19
|
+
bottomSheetView?: boolean | Partial<Record<Breakpoint | 'initial', boolean>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An array of numbers representing the days of the week to disable.
|
|
23
|
+
* For example, to disable Monday, Wednesday, and Saturday: [0, 2, 5].
|
|
24
|
+
*/
|
|
25
|
+
disableDaysOfWeek?: number[];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* If true, disables selection of weekend days (Saturday and Sunday).
|
|
29
|
+
*/
|
|
30
|
+
disableWeekends?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Separator character used in the date field. Defaults to "/".
|
|
34
|
+
*/
|
|
35
|
+
separator?: string;
|
|
36
|
+
/**
|
|
37
|
+
* portal container for date picker
|
|
38
|
+
*/
|
|
39
|
+
portalContainer?: Element;
|
|
40
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useFocusRing } from 'react-aria';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { VisuallyHidden } from '../index.js';
|
|
7
7
|
import {
|
|
8
8
|
BOMMultibrandSmallLogo,
|
|
9
9
|
BSAMultibrandSmallLogo,
|
|
@@ -54,18 +54,14 @@ export function Footer({
|
|
|
54
54
|
return (
|
|
55
55
|
<footer className={styles.base({ className })} {...props}>
|
|
56
56
|
<div className={styles.wrapper()}>
|
|
57
|
-
<
|
|
58
|
-
<GridItem span={12}>{children}</GridItem>
|
|
59
|
-
</Grid>
|
|
57
|
+
<div>{children}</div>
|
|
60
58
|
{!hideLogo && (
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</GridItem>
|
|
68
|
-
</Grid>
|
|
59
|
+
<div className={styles.logoWrapper()}>
|
|
60
|
+
<a href={logoLink} className={styles.link()} {...focusProps}>
|
|
61
|
+
{srOnlyText && <VisuallyHidden>{srOnlyText}</VisuallyHidden>}
|
|
62
|
+
<Logo align="right" aria-label={logoAssistiveText} />
|
|
63
|
+
</a>
|
|
64
|
+
</div>
|
|
69
65
|
)}
|
|
70
66
|
</div>
|
|
71
67
|
</footer>
|
|
@@ -4,9 +4,9 @@ export const styles = tv(
|
|
|
4
4
|
{
|
|
5
5
|
slots: {
|
|
6
6
|
base: 'relative overflow-hidden border-t border-t-border',
|
|
7
|
-
wrapper: 'pt-3 max-md:px-2 max-md:pb-3 md:px-4 md:pb-
|
|
8
|
-
topRow: '',
|
|
7
|
+
wrapper: 'pt-3 max-md:px-2 max-md:pb-3 md:px-4 md:pb-3',
|
|
9
8
|
link: 'float-right block',
|
|
9
|
+
logoWrapper: 'flex justify-end',
|
|
10
10
|
},
|
|
11
11
|
variants: {
|
|
12
12
|
offsetSidebar: {
|
|
@@ -18,10 +18,6 @@ export const styles = tv(
|
|
|
18
18
|
isFocusVisible: {
|
|
19
19
|
true: { link: 'focus-outline' },
|
|
20
20
|
},
|
|
21
|
-
hideLogo: {
|
|
22
|
-
true: '',
|
|
23
|
-
false: { topRow: 'max-md:mb-7 md:mb-4' },
|
|
24
|
-
},
|
|
25
21
|
},
|
|
26
22
|
},
|
|
27
23
|
{ responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
|
package/src/components/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './switch/index.js';
|
|
|
17
17
|
export * from './progress-bar/index.js';
|
|
18
18
|
export * from './link/index.js';
|
|
19
19
|
export * from './date-picker/index.js';
|
|
20
|
+
export * from './date-picker-beta/index.js';
|
|
20
21
|
export * from './grid/index.js';
|
|
21
22
|
export * from './table/index.js';
|
|
22
23
|
export * from './panel/index.js';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { useEffect
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { create } from 'zustand';
|
|
2
3
|
|
|
3
4
|
import { BREAKPOINTS, Breakpoint } from '../tailwind/constants/index.js';
|
|
4
5
|
|
|
5
6
|
function checkBreakpoint(): Breakpoint | 'initial' {
|
|
7
|
+
if (typeof window === 'undefined') {
|
|
8
|
+
return 'initial';
|
|
9
|
+
}
|
|
6
10
|
const breakpointsAsArray = Object.entries(BREAKPOINTS).reverse() as [Breakpoint, string][];
|
|
7
11
|
const breakpoint = breakpointsAsArray.find(([, value]) => window.matchMedia(`(min-width: ${value})`).matches) as [
|
|
8
12
|
Breakpoint,
|
|
@@ -11,18 +15,74 @@ function checkBreakpoint(): Breakpoint | 'initial' {
|
|
|
11
15
|
return breakpoint ? breakpoint[0] : 'initial';
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const BREAKPOINTS_ENTRIES = Object.entries(BREAKPOINTS);
|
|
19
|
+
const BREAKPOINTS_MEDIA: Record<Breakpoint | 'initial', string> = BREAKPOINTS_ENTRIES.reduce(
|
|
20
|
+
(acc, [key, value], index) => {
|
|
21
|
+
const finalValue = (() => {
|
|
22
|
+
const nextBreakpoint = BREAKPOINTS_ENTRIES[index + 1];
|
|
23
|
+
if (nextBreakpoint) {
|
|
24
|
+
return `(min-width: ${value}) and (max-width: ${+nextBreakpoint[1].replace('px', '') - 1}px)`;
|
|
25
|
+
}
|
|
26
|
+
return `(min-width: ${value})`;
|
|
27
|
+
})();
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
setBreakpoint(breakpoint);
|
|
21
|
-
};
|
|
22
|
-
window.addEventListener('resize', listener);
|
|
23
|
-
return () => {
|
|
24
|
-
window.removeEventListener('resize', listener);
|
|
29
|
+
return {
|
|
30
|
+
...acc,
|
|
31
|
+
[key]: finalValue,
|
|
25
32
|
};
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
initial: `(max-width: ${+BREAKPOINTS_ENTRIES[0][1].replace('px', '') - 1}px)`,
|
|
36
|
+
} as Record<Breakpoint | 'initial', string>,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
type BreakpointState = {
|
|
40
|
+
breakpoint: Breakpoint | 'initial';
|
|
41
|
+
mediaQueryListeners:
|
|
42
|
+
| {
|
|
43
|
+
mq: MediaQueryList;
|
|
44
|
+
listener: (e: MediaQueryListEvent) => void;
|
|
45
|
+
}[]
|
|
46
|
+
| null;
|
|
47
|
+
initialised: boolean;
|
|
48
|
+
ensureInitialized: () => void;
|
|
49
|
+
removeListeners: () => void;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const useBreakpointStore = create<BreakpointState>()((set, get) => ({
|
|
53
|
+
breakpoint: 'initial',
|
|
54
|
+
mediaQueryListeners: null,
|
|
55
|
+
initialised: false,
|
|
56
|
+
ensureInitialized: () => {
|
|
57
|
+
if (get().initialised) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const listeners = Object.entries(BREAKPOINTS_MEDIA).map(([label, query]) => {
|
|
61
|
+
const mq = window.matchMedia(query);
|
|
62
|
+
const listener = (e: MediaQueryListEvent) => {
|
|
63
|
+
if (e.matches) {
|
|
64
|
+
set({ breakpoint: label as Breakpoint });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
mq.addEventListener('change', listener);
|
|
68
|
+
return {
|
|
69
|
+
mq,
|
|
70
|
+
listener,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
set({ mediaQueryListeners: listeners, initialised: true, breakpoint: checkBreakpoint() });
|
|
74
|
+
},
|
|
75
|
+
removeListeners: () => {
|
|
76
|
+
get().mediaQueryListeners?.forEach(({ mq, listener }) => {
|
|
77
|
+
mq.removeEventListener('change', listener);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
export function useBreakpoint() {
|
|
83
|
+
const { breakpoint, ensureInitialized: initIfNotInitialised } = useBreakpointStore();
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
initIfNotInitialised();
|
|
26
86
|
}, []);
|
|
27
87
|
|
|
28
88
|
return breakpoint;
|
package/src/hook/index.ts
CHANGED
|
@@ -129,6 +129,24 @@ export const WestpacUIKitBasePlugin = plugin.withOptions(
|
|
|
129
129
|
transform: 'translateY(0)',
|
|
130
130
|
},
|
|
131
131
|
},
|
|
132
|
+
fadeInUp: {
|
|
133
|
+
'0%': {
|
|
134
|
+
opacity: '0',
|
|
135
|
+
transform: 'translateY(10vh)',
|
|
136
|
+
},
|
|
137
|
+
'100%': {
|
|
138
|
+
opacity: '1',
|
|
139
|
+
transform: 'translateY(0)',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
slideUp: {
|
|
143
|
+
'0%': {
|
|
144
|
+
transform: 'translateY(100%)',
|
|
145
|
+
},
|
|
146
|
+
'100%': {
|
|
147
|
+
transform: 'translateY(0)',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
132
150
|
maxHeightIn: {
|
|
133
151
|
'0%': { maxHeight: '0' },
|
|
134
152
|
},
|
|
@@ -137,6 +155,8 @@ export const WestpacUIKitBasePlugin = plugin.withOptions(
|
|
|
137
155
|
skeleton: 'waveLines 2s infinite ease-out',
|
|
138
156
|
fadeIn: 'fadeIn 0.2s ease',
|
|
139
157
|
fadeInDown: 'fadeInDown 0.4s ease',
|
|
158
|
+
fadeInUp: 'fadeInUp 0.4s ease',
|
|
159
|
+
slideUp: 'slideUp 0.4s ease',
|
|
140
160
|
maxHeightIn: 'maxHeightIn 0.4s ease',
|
|
141
161
|
},
|
|
142
162
|
boxShadow: {
|