@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
package/dist/components/date-picker-beta/components/calendar/components/select/select.styles.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: '!typography-body-8 appearance-none border-none !bg-none pl-0 pr-4 font-semibold',
|
|
5
|
+
caret: 'pointer-events-none absolute right-0 top-1/2 -translate-y-1/2 touch-none'
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
isFocusVisible: {
|
|
9
|
+
true: {
|
|
10
|
+
base: 'focus-outline'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
package/dist/components/date-picker-beta/components/calendar/components/select/select.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import { mergeProps, useDateSegment, useFocusRing } from 'react-aria';
|
|
4
|
+
import { styles as dateSegmentStyles } from './date-segment.styles.js';
|
|
5
|
+
export function DateSegment({ segment, state, separator, ...props }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { focusProps, isFocusVisible } = useFocusRing();
|
|
8
|
+
const { segmentProps } = useDateSegment(segment, state, ref);
|
|
9
|
+
const styles = dateSegmentStyles({
|
|
10
|
+
isFocusVisible,
|
|
11
|
+
isPlaceholder: segment.isPlaceholder,
|
|
12
|
+
isSeparator: segmentProps.role !== 'spinbutton'
|
|
13
|
+
});
|
|
14
|
+
return React.createElement("span", {
|
|
15
|
+
...props,
|
|
16
|
+
...mergeProps(focusProps, segmentProps),
|
|
17
|
+
ref: ref,
|
|
18
|
+
className: styles
|
|
19
|
+
}, segment.type === 'literal' ? separator || segment.text : segment.text);
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
isPlaceholder: {
|
|
3
|
+
true: string;
|
|
4
|
+
false: string;
|
|
5
|
+
};
|
|
6
|
+
isFocusVisible: {
|
|
7
|
+
true: string;
|
|
8
|
+
false: string;
|
|
9
|
+
};
|
|
10
|
+
isSeparator: {
|
|
11
|
+
true: string;
|
|
12
|
+
false: string;
|
|
13
|
+
};
|
|
14
|
+
}, undefined, "font-light disabled:form-control-disabled", {
|
|
15
|
+
responsiveVariants: string[];
|
|
16
|
+
}, {
|
|
17
|
+
isPlaceholder: {
|
|
18
|
+
true: string;
|
|
19
|
+
false: string;
|
|
20
|
+
};
|
|
21
|
+
isFocusVisible: {
|
|
22
|
+
true: string;
|
|
23
|
+
false: string;
|
|
24
|
+
};
|
|
25
|
+
isSeparator: {
|
|
26
|
+
true: string;
|
|
27
|
+
false: string;
|
|
28
|
+
};
|
|
29
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
30
|
+
isPlaceholder: {
|
|
31
|
+
true: string;
|
|
32
|
+
false: string;
|
|
33
|
+
};
|
|
34
|
+
isFocusVisible: {
|
|
35
|
+
true: string;
|
|
36
|
+
false: string;
|
|
37
|
+
};
|
|
38
|
+
isSeparator: {
|
|
39
|
+
true: string;
|
|
40
|
+
false: string;
|
|
41
|
+
};
|
|
42
|
+
}, undefined, "font-light disabled:form-control-disabled", {
|
|
43
|
+
responsiveVariants: string[];
|
|
44
|
+
}, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
base: 'font-light disabled:form-control-disabled',
|
|
4
|
+
variants: {
|
|
5
|
+
isPlaceholder: {
|
|
6
|
+
true: 'text-text-50 opacity-100',
|
|
7
|
+
false: ''
|
|
8
|
+
},
|
|
9
|
+
isFocusVisible: {
|
|
10
|
+
true: 'focus-outline',
|
|
11
|
+
false: ''
|
|
12
|
+
},
|
|
13
|
+
isSeparator: {
|
|
14
|
+
true: 'px-0.5 text-text-50',
|
|
15
|
+
false: ''
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
responsiveVariants: [
|
|
20
|
+
'xsl',
|
|
21
|
+
'sm',
|
|
22
|
+
'md',
|
|
23
|
+
'lg',
|
|
24
|
+
'xl'
|
|
25
|
+
]
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createCalendar } from '@internationalized/date';
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { useDateField, useLocale } from 'react-aria';
|
|
5
|
+
import { useDateFieldState } from 'react-stately';
|
|
6
|
+
import { DateSegment } from './components/date-segment/date-segment.component.js';
|
|
7
|
+
export function DateField({ separator, ...props }) {
|
|
8
|
+
const { locale } = useLocale();
|
|
9
|
+
const state = useDateFieldState({
|
|
10
|
+
...props,
|
|
11
|
+
locale,
|
|
12
|
+
createCalendar
|
|
13
|
+
});
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
const { fieldProps } = useDateField(props, state, ref);
|
|
16
|
+
return React.createElement("div", {
|
|
17
|
+
...fieldProps,
|
|
18
|
+
ref: ref
|
|
19
|
+
}, state.segments.map((segment, i)=>React.createElement(DateSegment, {
|
|
20
|
+
separator: separator,
|
|
21
|
+
key: i,
|
|
22
|
+
segment: segment,
|
|
23
|
+
state: state
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { useDialog } from 'react-aria';
|
|
3
|
+
export function Dialog({ title, children, ...props }) {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
const { dialogProps, titleProps } = useDialog(props, ref);
|
|
6
|
+
return React.createElement("div", {
|
|
7
|
+
...dialogProps,
|
|
8
|
+
ref: ref,
|
|
9
|
+
className: "p-3"
|
|
10
|
+
}, title && React.createElement("h3", {
|
|
11
|
+
...titleProps,
|
|
12
|
+
style: {
|
|
13
|
+
marginTop: 0
|
|
14
|
+
}
|
|
15
|
+
}, title), children);
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Overlay, usePopover } from 'react-aria';
|
|
3
|
+
import { CloseIcon } from '../../../icon/index.js';
|
|
4
|
+
import { styles as popoverStyles } from './popover.styles.js';
|
|
5
|
+
export function Popover({ state, portalContainer, children, showAsBottomSheet, ...props }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { popoverProps, underlayProps } = usePopover({
|
|
8
|
+
...props,
|
|
9
|
+
popoverRef: ref,
|
|
10
|
+
containerPadding: 0,
|
|
11
|
+
offset: 0
|
|
12
|
+
}, state);
|
|
13
|
+
const styles = popoverStyles({
|
|
14
|
+
showAsBottomSheet
|
|
15
|
+
});
|
|
16
|
+
return React.createElement(Overlay, {
|
|
17
|
+
portalContainer: portalContainer
|
|
18
|
+
}, React.createElement("div", {
|
|
19
|
+
...underlayProps,
|
|
20
|
+
className: styles.underlay()
|
|
21
|
+
}), React.createElement("div", {
|
|
22
|
+
...popoverProps,
|
|
23
|
+
ref: ref,
|
|
24
|
+
className: styles.popover()
|
|
25
|
+
}, React.createElement("div", {
|
|
26
|
+
className: styles.header()
|
|
27
|
+
}, React.createElement("p", {
|
|
28
|
+
className: styles.headerLabel()
|
|
29
|
+
}, "Choose a date"), React.createElement("button", {
|
|
30
|
+
className: styles.closeButton(),
|
|
31
|
+
onClick: ()=>state.close(),
|
|
32
|
+
"aria-label": "Close window"
|
|
33
|
+
}, React.createElement(CloseIcon, {
|
|
34
|
+
color: "primary",
|
|
35
|
+
className: "block",
|
|
36
|
+
size: "small"
|
|
37
|
+
}))), children));
|
|
38
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
showAsBottomSheet: {
|
|
3
|
+
true: {
|
|
4
|
+
underlay: string;
|
|
5
|
+
popover: string;
|
|
6
|
+
header: string;
|
|
7
|
+
headerLabel: string;
|
|
8
|
+
closeButton: string;
|
|
9
|
+
};
|
|
10
|
+
false: {
|
|
11
|
+
underlay: string;
|
|
12
|
+
closeButton: string;
|
|
13
|
+
headerLabel: string;
|
|
14
|
+
popover: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
underlay: string;
|
|
19
|
+
popover: string;
|
|
20
|
+
header: string;
|
|
21
|
+
headerLabel: string;
|
|
22
|
+
closeButton: string;
|
|
23
|
+
}, undefined, {
|
|
24
|
+
responsiveVariants: string[];
|
|
25
|
+
}, {
|
|
26
|
+
showAsBottomSheet: {
|
|
27
|
+
true: {
|
|
28
|
+
underlay: string;
|
|
29
|
+
popover: string;
|
|
30
|
+
header: string;
|
|
31
|
+
headerLabel: string;
|
|
32
|
+
closeButton: string;
|
|
33
|
+
};
|
|
34
|
+
false: {
|
|
35
|
+
underlay: string;
|
|
36
|
+
closeButton: string;
|
|
37
|
+
headerLabel: string;
|
|
38
|
+
popover: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
underlay: string;
|
|
43
|
+
popover: string;
|
|
44
|
+
header: string;
|
|
45
|
+
headerLabel: string;
|
|
46
|
+
closeButton: string;
|
|
47
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
48
|
+
showAsBottomSheet: {
|
|
49
|
+
true: {
|
|
50
|
+
underlay: string;
|
|
51
|
+
popover: string;
|
|
52
|
+
header: string;
|
|
53
|
+
headerLabel: string;
|
|
54
|
+
closeButton: string;
|
|
55
|
+
};
|
|
56
|
+
false: {
|
|
57
|
+
underlay: string;
|
|
58
|
+
closeButton: string;
|
|
59
|
+
headerLabel: string;
|
|
60
|
+
popover: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}, {
|
|
64
|
+
underlay: string;
|
|
65
|
+
popover: string;
|
|
66
|
+
header: string;
|
|
67
|
+
headerLabel: string;
|
|
68
|
+
closeButton: string;
|
|
69
|
+
}, undefined, {
|
|
70
|
+
responsiveVariants: string[];
|
|
71
|
+
}, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
underlay: 'fixed inset-0',
|
|
5
|
+
popover: 'bg-white',
|
|
6
|
+
header: '',
|
|
7
|
+
headerLabel: '',
|
|
8
|
+
closeButton: 'flex items-center justify-center focus-outline'
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
showAsBottomSheet: {
|
|
12
|
+
true: {
|
|
13
|
+
underlay: 'animate-fadeIn bg-black/20',
|
|
14
|
+
popover: '!fixed inset-x-0 !bottom-0 !left-0 !top-auto animate-slideUp overflow-auto rounded-t px-[8%] pb-3',
|
|
15
|
+
header: 'mx-[-8vw] flex items-center justify-between border-b border-b-border px-3.5 py-2',
|
|
16
|
+
headerLabel: 'typography-body-10 text-text',
|
|
17
|
+
closeButton: 'pointer-events-none touch-none rounded-full bg-white opacity-0 focus:pointer-events-auto focus:touch-auto focus:opacity-100'
|
|
18
|
+
},
|
|
19
|
+
false: {
|
|
20
|
+
underlay: '',
|
|
21
|
+
closeButton: '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',
|
|
22
|
+
headerLabel: 'hidden',
|
|
23
|
+
popover: '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)]'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
responsiveVariants: [
|
|
29
|
+
'xsl',
|
|
30
|
+
'sm',
|
|
31
|
+
'md',
|
|
32
|
+
'lg',
|
|
33
|
+
'xl'
|
|
34
|
+
]
|
|
35
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AriaPopoverProps } from 'react-aria';
|
|
3
|
+
import { OverlayTriggerState } from 'react-stately';
|
|
4
|
+
export type PopoverProps = Omit<AriaPopoverProps, 'popoverRef'> & {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
showAsBottomSheet?: boolean;
|
|
7
|
+
state: OverlayTriggerState;
|
|
8
|
+
portalContainer?: Element;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type DatePickerBetaProps } from './date-picker.types.js';
|
|
2
|
+
export declare function DatePickerBeta({ size, className, bottomSheetView, isDateUnavailable, disableDaysOfWeek, disableWeekends, separator, portalContainer, ...props }: DatePickerBetaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { getDayOfWeek, isWeekend } from '@internationalized/date';
|
|
3
|
+
import React, { useMemo, useRef } from 'react';
|
|
4
|
+
import { useButton, useDatePicker, useLocale } from 'react-aria';
|
|
5
|
+
import { useDatePickerState } from 'react-stately';
|
|
6
|
+
import { useBreakpoint } from '../../hook/breakpoints.hook.js';
|
|
7
|
+
import { Button } from '../button/index.js';
|
|
8
|
+
import { CalendarIcon } from '../icon/index.js';
|
|
9
|
+
import { Calendar } from './components/calendar/calendar.component.js';
|
|
10
|
+
import { DateField } from './components/date-field/date-field.component.js';
|
|
11
|
+
import { Dialog } from './components/dialog/dialog.component.js';
|
|
12
|
+
import { Popover } from './components/popover/popover.component.js';
|
|
13
|
+
import { styles as datePickerStyles } from './date-picker.styles.js';
|
|
14
|
+
const BREAKPOINTS_DECRECENT = [
|
|
15
|
+
'xl',
|
|
16
|
+
'lg',
|
|
17
|
+
'md',
|
|
18
|
+
'sm',
|
|
19
|
+
'xsl',
|
|
20
|
+
'initial'
|
|
21
|
+
];
|
|
22
|
+
export function DatePickerBeta({ size = 'medium', className, bottomSheetView = {
|
|
23
|
+
initial: true,
|
|
24
|
+
xsl: false
|
|
25
|
+
}, isDateUnavailable, disableDaysOfWeek, disableWeekends, separator, portalContainer, ...props }) {
|
|
26
|
+
const { locale } = useLocale();
|
|
27
|
+
const enhancedIsDateUnavailable = useMemo(()=>{
|
|
28
|
+
return disableDaysOfWeek || disableWeekends ? (date)=>{
|
|
29
|
+
let conditions = [
|
|
30
|
+
(isDateUnavailable === null || isDateUnavailable === void 0 ? void 0 : isDateUnavailable(date)) || false
|
|
31
|
+
];
|
|
32
|
+
if (disableDaysOfWeek) {
|
|
33
|
+
conditions = [
|
|
34
|
+
disableDaysOfWeek.indexOf(getDayOfWeek(date, locale)) !== -1,
|
|
35
|
+
...conditions
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (disableWeekends) {
|
|
39
|
+
conditions = [
|
|
40
|
+
isWeekend(date, locale),
|
|
41
|
+
...conditions
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
return conditions.some((condition)=>condition);
|
|
45
|
+
} : isDateUnavailable;
|
|
46
|
+
}, [
|
|
47
|
+
disableDaysOfWeek,
|
|
48
|
+
disableWeekends,
|
|
49
|
+
isDateUnavailable,
|
|
50
|
+
locale
|
|
51
|
+
]);
|
|
52
|
+
const state = useDatePickerState({
|
|
53
|
+
isDateUnavailable: enhancedIsDateUnavailable,
|
|
54
|
+
...props
|
|
55
|
+
});
|
|
56
|
+
const styles = datePickerStyles({
|
|
57
|
+
size,
|
|
58
|
+
isInvalid: state.isInvalid,
|
|
59
|
+
isDisabled: props.isDisabled
|
|
60
|
+
});
|
|
61
|
+
const breakpoint = useBreakpoint();
|
|
62
|
+
const ref = useRef(null);
|
|
63
|
+
const { groupProps, labelProps, fieldProps, buttonProps, dialogProps, calendarProps } = useDatePicker({
|
|
64
|
+
isDateUnavailable: enhancedIsDateUnavailable,
|
|
65
|
+
...props
|
|
66
|
+
}, state, ref);
|
|
67
|
+
const showAsBottomSheet = useMemo(()=>{
|
|
68
|
+
if (typeof bottomSheetView === 'boolean') {
|
|
69
|
+
return bottomSheetView;
|
|
70
|
+
}
|
|
71
|
+
const currentBreakpointIndex = BREAKPOINTS_DECRECENT.findIndex((bp)=>bp === breakpoint);
|
|
72
|
+
const finalBreakPoint = [
|
|
73
|
+
breakpoint,
|
|
74
|
+
...BREAKPOINTS_DECRECENT.slice(currentBreakpointIndex)
|
|
75
|
+
].find((currentBreakpoint)=>bottomSheetView[currentBreakpoint] !== undefined);
|
|
76
|
+
return bottomSheetView[finalBreakPoint] || false;
|
|
77
|
+
}, [
|
|
78
|
+
bottomSheetView,
|
|
79
|
+
breakpoint
|
|
80
|
+
]);
|
|
81
|
+
const buttonRef = useRef(null);
|
|
82
|
+
const { buttonProps: newButtonProps } = useButton(buttonProps, buttonRef);
|
|
83
|
+
const brandContainer = useMemo(()=>{
|
|
84
|
+
return document.querySelector('[data-theme]') || document.querySelector('[class^="theme-"], [class*=" theme-"]') || undefined;
|
|
85
|
+
}, []);
|
|
86
|
+
return React.createElement(React.Fragment, null, React.createElement("div", labelProps, props.label), React.createElement("div", {
|
|
87
|
+
...props,
|
|
88
|
+
...groupProps,
|
|
89
|
+
ref: ref,
|
|
90
|
+
className: styles.input({
|
|
91
|
+
className
|
|
92
|
+
})
|
|
93
|
+
}, React.createElement(DateField, {
|
|
94
|
+
separator: separator,
|
|
95
|
+
...fieldProps
|
|
96
|
+
}), React.createElement(Button, {
|
|
97
|
+
look: "faint",
|
|
98
|
+
className: styles.button(),
|
|
99
|
+
iconColor: "muted",
|
|
100
|
+
size: size,
|
|
101
|
+
iconAfter: CalendarIcon,
|
|
102
|
+
...newButtonProps,
|
|
103
|
+
"aria-labelledby": undefined
|
|
104
|
+
})), state.isOpen && React.createElement(Popover, {
|
|
105
|
+
portalContainer: portalContainer || brandContainer,
|
|
106
|
+
showAsBottomSheet: showAsBottomSheet,
|
|
107
|
+
state: state,
|
|
108
|
+
triggerRef: ref,
|
|
109
|
+
placement: "bottom left"
|
|
110
|
+
}, React.createElement(Dialog, dialogProps, React.createElement(Calendar, {
|
|
111
|
+
...calendarProps,
|
|
112
|
+
firstDayOfWeek: props.firstDayOfWeek
|
|
113
|
+
}))));
|
|
114
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export declare const styles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
size: {
|
|
3
|
+
small: {
|
|
4
|
+
input: string;
|
|
5
|
+
button: string;
|
|
6
|
+
};
|
|
7
|
+
medium: {
|
|
8
|
+
input: string;
|
|
9
|
+
button: string;
|
|
10
|
+
};
|
|
11
|
+
large: {
|
|
12
|
+
input: string;
|
|
13
|
+
button: string;
|
|
14
|
+
};
|
|
15
|
+
xlarge: {
|
|
16
|
+
input: string;
|
|
17
|
+
button: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
isInvalid: {
|
|
21
|
+
true: {
|
|
22
|
+
input: string;
|
|
23
|
+
};
|
|
24
|
+
false: {};
|
|
25
|
+
};
|
|
26
|
+
isDisabled: {
|
|
27
|
+
true: {
|
|
28
|
+
input: string;
|
|
29
|
+
};
|
|
30
|
+
false: {};
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
input: string;
|
|
34
|
+
button: string;
|
|
35
|
+
}, undefined, {
|
|
36
|
+
responsiveVariants: string[];
|
|
37
|
+
}, {
|
|
38
|
+
size: {
|
|
39
|
+
small: {
|
|
40
|
+
input: string;
|
|
41
|
+
button: string;
|
|
42
|
+
};
|
|
43
|
+
medium: {
|
|
44
|
+
input: string;
|
|
45
|
+
button: string;
|
|
46
|
+
};
|
|
47
|
+
large: {
|
|
48
|
+
input: string;
|
|
49
|
+
button: string;
|
|
50
|
+
};
|
|
51
|
+
xlarge: {
|
|
52
|
+
input: string;
|
|
53
|
+
button: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
isInvalid: {
|
|
57
|
+
true: {
|
|
58
|
+
input: string;
|
|
59
|
+
};
|
|
60
|
+
false: {};
|
|
61
|
+
};
|
|
62
|
+
isDisabled: {
|
|
63
|
+
true: {
|
|
64
|
+
input: string;
|
|
65
|
+
};
|
|
66
|
+
false: {};
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
input: string;
|
|
70
|
+
button: string;
|
|
71
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
72
|
+
size: {
|
|
73
|
+
small: {
|
|
74
|
+
input: string;
|
|
75
|
+
button: string;
|
|
76
|
+
};
|
|
77
|
+
medium: {
|
|
78
|
+
input: string;
|
|
79
|
+
button: string;
|
|
80
|
+
};
|
|
81
|
+
large: {
|
|
82
|
+
input: string;
|
|
83
|
+
button: string;
|
|
84
|
+
};
|
|
85
|
+
xlarge: {
|
|
86
|
+
input: string;
|
|
87
|
+
button: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
isInvalid: {
|
|
91
|
+
true: {
|
|
92
|
+
input: string;
|
|
93
|
+
};
|
|
94
|
+
false: {};
|
|
95
|
+
};
|
|
96
|
+
isDisabled: {
|
|
97
|
+
true: {
|
|
98
|
+
input: string;
|
|
99
|
+
};
|
|
100
|
+
false: {};
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
input: string;
|
|
104
|
+
button: string;
|
|
105
|
+
}, undefined, {
|
|
106
|
+
responsiveVariants: string[];
|
|
107
|
+
}, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const styles = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
input: 'form-control flex items-center border-borderDark disabled:form-control-disabled',
|
|
5
|
+
button: 'flex h-auto items-center justify-center rounded-l-none border-y-0 border-l border-r-0 border-l-borderDark bg-light'
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
small: {
|
|
10
|
+
input: 'form-control-small gap-1.5',
|
|
11
|
+
button: '-my-0.5 -mr-1.5 mb-[-0.25rem] min-h-5 py-[0.25rem]'
|
|
12
|
+
},
|
|
13
|
+
medium: {
|
|
14
|
+
input: 'form-control-medium gap-2',
|
|
15
|
+
button: 'my-[-0.3125rem] -mr-2 min-h-6 py-[0.3125rem]'
|
|
16
|
+
},
|
|
17
|
+
large: {
|
|
18
|
+
input: 'form-control-large gap-2.5',
|
|
19
|
+
button: 'my-[-0.5rem] -mr-2.5 min-h-7 py-[0.5rem]'
|
|
20
|
+
},
|
|
21
|
+
xlarge: {
|
|
22
|
+
input: 'form-control-xlarge gap-3',
|
|
23
|
+
button: '-my-1.5 -mr-3 mb-[-0.625rem] min-h-8 py-1.5'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
isInvalid: {
|
|
27
|
+
true: {
|
|
28
|
+
input: 'border-danger'
|
|
29
|
+
},
|
|
30
|
+
false: {}
|
|
31
|
+
},
|
|
32
|
+
isDisabled: {
|
|
33
|
+
true: {
|
|
34
|
+
input: 'form-control-disabled'
|
|
35
|
+
},
|
|
36
|
+
false: {}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
responsiveVariants: [
|
|
41
|
+
'xsl',
|
|
42
|
+
'sm',
|
|
43
|
+
'md',
|
|
44
|
+
'lg',
|
|
45
|
+
'xl'
|
|
46
|
+
]
|
|
47
|
+
});
|