@cerberus-design/react 0.13.2 → 0.14.0
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/build/legacy/_tsup-dts-rollup.d.cts +607 -129
- package/build/legacy/components/Accordion.cjs +101 -0
- package/build/legacy/components/Accordion.cjs.map +1 -0
- package/build/legacy/components/AccordionItemGroup.cjs +119 -0
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -0
- package/build/legacy/components/Admonition.cjs +3 -0
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +3 -0
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +3 -0
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +497 -0
- package/build/legacy/components/DatePicker.client.cjs.map +1 -0
- package/build/legacy/components/DatePicker.server.cjs +364 -0
- package/build/legacy/components/DatePicker.server.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +3 -0
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +3 -0
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +3 -0
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +3 -0
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/NotificationDescription.cjs.map +1 -1
- package/build/legacy/components/NotificationHeading.cjs.map +1 -1
- package/build/legacy/components/ProgressBar.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +3 -0
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tabs.client.cjs +104 -0
- package/build/legacy/components/Tabs.client.cjs.map +1 -0
- package/build/legacy/components/Tag.cjs +3 -0
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Text.cjs +59 -0
- package/build/legacy/components/Text.cjs.map +1 -0
- package/build/legacy/components/Toggle.cjs +3 -0
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/components/Tooltip.cjs +2 -2
- package/build/legacy/components/Tooltip.cjs.map +1 -1
- package/build/legacy/config/cerbIcons.cjs +3 -0
- package/build/legacy/config/cerbIcons.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +3 -0
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/config/icons/checkbox.icons.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +3 -0
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +5 -3
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +3 -0
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +3 -0
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/context/tabs.cjs +53 -24
- package/build/legacy/context/tabs.cjs.map +1 -1
- package/build/legacy/hooks/useDate.cjs +8 -0
- package/build/legacy/hooks/useDate.cjs.map +1 -1
- package/build/legacy/index.cjs +1083 -711
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/utils/index.cjs +21 -2
- package/build/legacy/utils/index.cjs.map +1 -1
- package/build/legacy/utils/localStorage.cjs +44 -0
- package/build/legacy/utils/localStorage.cjs.map +1 -0
- package/build/modern/_tsup-dts-rollup.d.ts +607 -129
- package/build/modern/chunk-2ZNIYPDV.js +47 -0
- package/build/modern/chunk-2ZNIYPDV.js.map +1 -0
- package/build/modern/chunk-34E3UFFB.js +75 -0
- package/build/modern/chunk-34E3UFFB.js.map +1 -0
- package/build/modern/{chunk-CZND26FC.js → chunk-3BM6MZ4A.js} +8 -1
- package/build/modern/{chunk-CZND26FC.js.map → chunk-3BM6MZ4A.js.map} +1 -1
- package/build/modern/{chunk-N4QTLDVM.js → chunk-4IMOKN2D.js} +3 -3
- package/build/modern/{chunk-F27AAKQ3.js → chunk-5KHU6MM5.js} +8 -2
- package/build/modern/chunk-5KHU6MM5.js.map +1 -0
- package/build/modern/{chunk-WFJWCZ7E.js → chunk-77B4HFKT.js} +13 -14
- package/build/modern/chunk-77B4HFKT.js.map +1 -0
- package/build/modern/{chunk-FBSESDWJ.js → chunk-BHSYQCDV.js} +16 -16
- package/build/modern/chunk-BHSYQCDV.js.map +1 -0
- package/build/modern/{chunk-SPZYPRZ6.js → chunk-BU5JK37R.js} +2 -2
- package/build/modern/{chunk-UTGEFJ3L.js → chunk-C5EHJUS5.js} +1 -1
- package/build/modern/{chunk-UTGEFJ3L.js.map → chunk-C5EHJUS5.js.map} +1 -1
- package/build/modern/{chunk-VERRHMW4.js → chunk-DDOTCGGA.js} +2 -2
- package/build/modern/{chunk-CP7OUC2Q.js → chunk-E3PAEB7Y.js} +1 -1
- package/build/modern/chunk-E3PAEB7Y.js.map +1 -0
- package/build/modern/{chunk-F72ZABKX.js → chunk-F4LTOZAN.js} +2 -2
- package/build/modern/{chunk-NKM6PISB.js → chunk-F7EWTOML.js} +2 -2
- package/build/modern/chunk-F7XWOSN3.js +39 -0
- package/build/modern/chunk-F7XWOSN3.js.map +1 -0
- package/build/modern/chunk-FQLMPEYX.js +18 -0
- package/build/modern/chunk-FQLMPEYX.js.map +1 -0
- package/build/modern/{chunk-7MM5KYEX.js → chunk-GI6CSUU4.js} +7 -7
- package/build/modern/{chunk-7SGPJM66.js → chunk-HP4ZN473.js} +2 -2
- package/build/modern/chunk-HP4ZN473.js.map +1 -0
- package/build/modern/chunk-IP5VFOPZ.js +132 -0
- package/build/modern/chunk-IP5VFOPZ.js.map +1 -0
- package/build/modern/{chunk-KML4CTMK.js → chunk-LPALHB6R.js} +3 -3
- package/build/modern/chunk-LPALHB6R.js.map +1 -0
- package/build/modern/{chunk-3XGLNXJJ.js → chunk-M73ECA25.js} +8 -8
- package/build/modern/chunk-M73ECA25.js.map +1 -0
- package/build/modern/chunk-N7O6D7BW.js +63 -0
- package/build/modern/chunk-N7O6D7BW.js.map +1 -0
- package/build/modern/{chunk-W4DXACNV.js → chunk-O7QVCF3H.js} +3 -3
- package/build/modern/chunk-RIZGWERR.js +161 -0
- package/build/modern/chunk-RIZGWERR.js.map +1 -0
- package/build/modern/chunk-RZ7NG77U.js +77 -0
- package/build/modern/chunk-RZ7NG77U.js.map +1 -0
- package/build/modern/{chunk-XL4JREDT.js → chunk-S25RHYZV.js} +2 -2
- package/build/modern/{chunk-SXIXDXG3.js → chunk-SLHYBPJ5.js} +1 -1
- package/build/modern/chunk-SLHYBPJ5.js.map +1 -0
- package/build/modern/{chunk-GRUXP3NG.js → chunk-T6U7AKKP.js} +10 -10
- package/build/modern/chunk-T6U7AKKP.js.map +1 -0
- package/build/modern/{chunk-XEW6TJJ4.js → chunk-UXY3KCC3.js} +1 -1
- package/build/modern/chunk-UXY3KCC3.js.map +1 -0
- package/build/modern/{chunk-NB6DV4VA.js → chunk-W2LSPRQ3.js} +2 -2
- package/build/modern/{chunk-KCANMM64.js → chunk-WZJ5UQNM.js} +1 -1
- package/build/modern/chunk-WZJ5UQNM.js.map +1 -0
- package/build/modern/{chunk-NMNONSHU.js → chunk-XVU2NQCW.js} +2 -2
- package/build/modern/components/Accordion.js +15 -0
- package/build/modern/components/AccordionItemGroup.js +9 -0
- package/build/modern/components/Admonition.js +5 -5
- package/build/modern/components/Avatar.js +4 -4
- package/build/modern/components/Checkbox.js +4 -4
- package/build/modern/components/DatePicker.client.js +31 -0
- package/build/modern/components/DatePicker.server.js +31 -0
- package/build/modern/components/FileStatus.js +7 -7
- package/build/modern/components/FileUploader.js +5 -5
- package/build/modern/components/Input.js +4 -4
- package/build/modern/components/Notification.js +4 -4
- package/build/modern/components/NotificationDescription.js +1 -1
- package/build/modern/components/NotificationHeading.js +1 -1
- package/build/modern/components/ProgressBar.js +1 -1
- package/build/modern/components/Select.js +4 -4
- package/build/modern/components/Tabs.client.js +18 -0
- package/build/modern/components/Tabs.client.js.map +1 -0
- package/build/modern/components/Tag.js +4 -4
- package/build/modern/components/Text.js +7 -0
- package/build/modern/components/Text.js.map +1 -0
- package/build/modern/components/Toggle.js +4 -4
- package/build/modern/components/Tooltip.js +1 -1
- package/build/modern/config/cerbIcons.js +2 -2
- package/build/modern/config/defineIcons.js +3 -3
- package/build/modern/config/icons/checkbox.icons.js +1 -1
- package/build/modern/context/confirm-modal.js +8 -8
- package/build/modern/context/cta-modal.js +8 -8
- package/build/modern/context/notification-center.js +7 -7
- package/build/modern/context/prompt-modal.js +11 -11
- package/build/modern/context/tabs.js +2 -1
- package/build/modern/hooks/useDate.js +3 -1
- package/build/modern/index.js +158 -94
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +8 -2
- package/build/modern/utils/localStorage.js +10 -0
- package/build/modern/utils/localStorage.js.map +1 -0
- package/package.json +2 -2
- package/src/components/Accordion.tsx +160 -0
- package/src/components/AccordionItemGroup.tsx +79 -0
- package/src/components/DatePicker.client.tsx +365 -0
- package/src/components/DatePicker.server.tsx +229 -0
- package/src/components/Notification.tsx +6 -3
- package/src/components/NotificationDescription.tsx +2 -2
- package/src/components/NotificationHeading.tsx +1 -2
- package/src/components/ProgressBar.tsx +1 -1
- package/src/components/Tabs.client.tsx +113 -0
- package/src/components/Text.tsx +70 -0
- package/src/components/Tooltip.tsx +2 -2
- package/src/config/cerbIcons.ts +9 -0
- package/src/config/icons/checkbox.icons.tsx +2 -2
- package/src/context/confirm-modal.tsx +1 -1
- package/src/context/cta-modal.tsx +6 -7
- package/src/context/notification-center.tsx +1 -1
- package/src/context/prompt-modal.tsx +1 -1
- package/src/context/tabs.tsx +66 -65
- package/src/hooks/useDate.ts +12 -0
- package/src/index.ts +6 -4
- package/src/utils/index.ts +2 -0
- package/src/utils/localStorage.ts +28 -0
- package/build/legacy/aria-helpers/tabs.aria.cjs +0 -100
- package/build/legacy/aria-helpers/tabs.aria.cjs.map +0 -1
- package/build/legacy/components/Tab.cjs +0 -135
- package/build/legacy/components/Tab.cjs.map +0 -1
- package/build/legacy/components/TabList.cjs +0 -69
- package/build/legacy/components/TabList.cjs.map +0 -1
- package/build/legacy/components/TabPanel.cjs +0 -76
- package/build/legacy/components/TabPanel.cjs.map +0 -1
- package/build/modern/aria-helpers/tabs.aria.js +0 -9
- package/build/modern/chunk-3XGLNXJJ.js.map +0 -1
- package/build/modern/chunk-7SGPJM66.js.map +0 -1
- package/build/modern/chunk-AYIRV5CL.js +0 -32
- package/build/modern/chunk-AYIRV5CL.js.map +0 -1
- package/build/modern/chunk-CP7OUC2Q.js.map +0 -1
- package/build/modern/chunk-F27AAKQ3.js.map +0 -1
- package/build/modern/chunk-FBSESDWJ.js.map +0 -1
- package/build/modern/chunk-GRUXP3NG.js.map +0 -1
- package/build/modern/chunk-ITOIXNJS.js +0 -64
- package/build/modern/chunk-ITOIXNJS.js.map +0 -1
- package/build/modern/chunk-KCANMM64.js.map +0 -1
- package/build/modern/chunk-KML4CTMK.js.map +0 -1
- package/build/modern/chunk-RIFQSCHT.js +0 -58
- package/build/modern/chunk-RIFQSCHT.js.map +0 -1
- package/build/modern/chunk-SLF6SIPB.js +0 -46
- package/build/modern/chunk-SLF6SIPB.js.map +0 -1
- package/build/modern/chunk-SXIXDXG3.js.map +0 -1
- package/build/modern/chunk-UKPF7JOB.js +0 -33
- package/build/modern/chunk-UKPF7JOB.js.map +0 -1
- package/build/modern/chunk-WFJWCZ7E.js.map +0 -1
- package/build/modern/chunk-XEW6TJJ4.js.map +0 -1
- package/build/modern/components/Tab.js +0 -10
- package/build/modern/components/TabList.js +0 -9
- package/build/modern/components/TabPanel.js +0 -10
- package/src/aria-helpers/tabs.aria.ts +0 -70
- package/src/components/Tab.tsx +0 -68
- package/src/components/TabList.tsx +0 -51
- package/src/components/TabPanel.tsx +0 -49
- /package/build/modern/{chunk-N4QTLDVM.js.map → chunk-4IMOKN2D.js.map} +0 -0
- /package/build/modern/{chunk-SPZYPRZ6.js.map → chunk-BU5JK37R.js.map} +0 -0
- /package/build/modern/{chunk-VERRHMW4.js.map → chunk-DDOTCGGA.js.map} +0 -0
- /package/build/modern/{chunk-F72ZABKX.js.map → chunk-F4LTOZAN.js.map} +0 -0
- /package/build/modern/{chunk-NKM6PISB.js.map → chunk-F7EWTOML.js.map} +0 -0
- /package/build/modern/{chunk-7MM5KYEX.js.map → chunk-GI6CSUU4.js.map} +0 -0
- /package/build/modern/{chunk-W4DXACNV.js.map → chunk-O7QVCF3H.js.map} +0 -0
- /package/build/modern/{chunk-XL4JREDT.js.map → chunk-S25RHYZV.js.map} +0 -0
- /package/build/modern/{chunk-NB6DV4VA.js.map → chunk-W2LSPRQ3.js.map} +0 -0
- /package/build/modern/{chunk-NMNONSHU.js.map → chunk-XVU2NQCW.js.map} +0 -0
- /package/build/modern/{aria-helpers/tabs.aria.js.map → components/Accordion.js.map} +0 -0
- /package/build/modern/components/{Tab.js.map → AccordionItemGroup.js.map} +0 -0
- /package/build/modern/components/{TabList.js.map → DatePicker.client.js.map} +0 -0
- /package/build/modern/components/{TabPanel.js.map → DatePicker.server.js.map} +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Accordion as ArkAccordion } from '@ark-ui/react'
|
|
2
|
+
import { ChevronDown } from '@cerberus/icons'
|
|
3
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
4
|
+
import {
|
|
5
|
+
accordion,
|
|
6
|
+
type AccordionVariantProps,
|
|
7
|
+
} from '@cerberus/styled-system/recipes'
|
|
8
|
+
|
|
9
|
+
export type AccordionProps = ArkAccordion.RootProps & AccordionVariantProps
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The context provider for the Accordion family.
|
|
13
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Accordion>
|
|
17
|
+
* <AccordionItemGroup heading="Item 1 heading" value="one">
|
|
18
|
+
* This is the content
|
|
19
|
+
* </AccordionItemGroup>
|
|
20
|
+
* </Accordion>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function Accordion(props: AccordionProps) {
|
|
24
|
+
const { size, className, ...rootProps } = props
|
|
25
|
+
const styles = accordion({ size })
|
|
26
|
+
return (
|
|
27
|
+
<ArkAccordion.Root
|
|
28
|
+
collapsible
|
|
29
|
+
className={cx(className, styles.root)}
|
|
30
|
+
{...rootProps}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type AccordionItemProps = ArkAccordion.ItemProps & AccordionVariantProps
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The item for the Accordion component.
|
|
39
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/accordion)
|
|
40
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <Accordion>
|
|
44
|
+
* <AccordionItem value="one">
|
|
45
|
+
* <AccordionTrigger>
|
|
46
|
+
* Accordion Item 1
|
|
47
|
+
* <AccordionIndicator />
|
|
48
|
+
* </AccordionTrigger>
|
|
49
|
+
* <AccordionContent>Accordion Item 1 content</AccordionContent>
|
|
50
|
+
* </AccordionItem>
|
|
51
|
+
* </Accordion>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function AccordionItem(props: AccordionItemProps) {
|
|
55
|
+
const { size, ...itemProps } = props
|
|
56
|
+
const styles = accordion({ size })
|
|
57
|
+
return (
|
|
58
|
+
<ArkAccordion.Item
|
|
59
|
+
{...itemProps}
|
|
60
|
+
className={cx(itemProps.className, styles.item)}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type AccordionItemTriggerProps = ArkAccordion.ItemTriggerProps &
|
|
66
|
+
AccordionVariantProps
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The trigger for the Accordion component.
|
|
70
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/accordion)
|
|
71
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* <Accordion>
|
|
75
|
+
* <AccordionItem value="one">
|
|
76
|
+
* <AccordionTrigger>
|
|
77
|
+
* Accordion Item 1
|
|
78
|
+
* <AccordionIndicator />
|
|
79
|
+
* </AccordionTrigger>
|
|
80
|
+
* <AccordionContent>Accordion Item 1 content</AccordionContent>
|
|
81
|
+
* </AccordionItem>
|
|
82
|
+
* </Accordion>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export function AccordionItemTrigger(props: AccordionItemTriggerProps) {
|
|
86
|
+
const { size, ...triggerProps } = props
|
|
87
|
+
const styles = accordion({ size })
|
|
88
|
+
return (
|
|
89
|
+
<ArkAccordion.ItemTrigger
|
|
90
|
+
{...triggerProps}
|
|
91
|
+
className={cx(triggerProps.className, styles.itemTrigger)}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type AccordionItemIndicatorProps = ArkAccordion.ItemIndicatorProps &
|
|
97
|
+
AccordionVariantProps
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The indicator for the Accordion component.
|
|
101
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/accordion)
|
|
102
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <Accordion>
|
|
106
|
+
* <AccordionItem value="one">
|
|
107
|
+
* <AccordionTrigger>
|
|
108
|
+
* Accordion Item 1
|
|
109
|
+
* <AccordionIndicator />
|
|
110
|
+
* </AccordionTrigger>
|
|
111
|
+
* <AccordionContent>Accordion Item 1 content</AccordionContent>
|
|
112
|
+
* </AccordionItem>
|
|
113
|
+
* </Accordion>
|
|
114
|
+
* ```
|
|
115
|
+
* */
|
|
116
|
+
export function AccordionItemIndicator(props: AccordionItemIndicatorProps) {
|
|
117
|
+
const { size, ...indicatorProps } = props
|
|
118
|
+
const styles = accordion({ size })
|
|
119
|
+
const iconSize = size === 'sm' ? 16 : '24'
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<ArkAccordion.ItemIndicator
|
|
123
|
+
{...indicatorProps}
|
|
124
|
+
className={cx(indicatorProps.className, styles.itemIndicator)}
|
|
125
|
+
>
|
|
126
|
+
<ChevronDown size={iconSize} />
|
|
127
|
+
</ArkAccordion.ItemIndicator>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type AccordionItemContentProps = ArkAccordion.ItemContentProps &
|
|
132
|
+
AccordionVariantProps
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The content for the Accordion component.
|
|
136
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/accordion)
|
|
137
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <Accordion>
|
|
141
|
+
* <AccordionItem value="one">
|
|
142
|
+
* <AccordionTrigger>
|
|
143
|
+
* Accordion Item 1
|
|
144
|
+
* <AccordionIndicator />
|
|
145
|
+
* </AccordionTrigger>
|
|
146
|
+
* <AccordionContent>Accordion Item 1 content</AccordionContent>
|
|
147
|
+
* </AccordionItem>
|
|
148
|
+
* </Accordion>
|
|
149
|
+
* ```
|
|
150
|
+
* */
|
|
151
|
+
export function AccordionItemContent(props: AccordionItemContentProps) {
|
|
152
|
+
const { size, ...contentProps } = props
|
|
153
|
+
const styles = accordion({ size })
|
|
154
|
+
return (
|
|
155
|
+
<ArkAccordion.ItemContent
|
|
156
|
+
{...contentProps}
|
|
157
|
+
className={cx(contentProps.className, styles.itemContent)}
|
|
158
|
+
/>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Accordion as ArkAccordion } from '@ark-ui/react'
|
|
2
|
+
import { type AccordionVariantProps } from '@cerberus/styled-system/recipes'
|
|
3
|
+
import type { PropsWithChildren } from 'react'
|
|
4
|
+
import { Show } from './Show'
|
|
5
|
+
import {
|
|
6
|
+
AccordionItem,
|
|
7
|
+
AccordionItemContent,
|
|
8
|
+
AccordionItemIndicator,
|
|
9
|
+
AccordionItemTrigger,
|
|
10
|
+
} from './Accordion'
|
|
11
|
+
import { css } from '@cerberus/styled-system/css'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This module contains an abstraction of the AccordionItem components.
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface AccordionItemGroupBaseProps extends ArkAccordion.ItemProps {
|
|
19
|
+
/**
|
|
20
|
+
* The heading of the accordion item to open and close the content.
|
|
21
|
+
*/
|
|
22
|
+
heading: string
|
|
23
|
+
/**
|
|
24
|
+
* The position of the arrow indicator.
|
|
25
|
+
*/
|
|
26
|
+
indicatorPosition?: 'start' | 'end'
|
|
27
|
+
}
|
|
28
|
+
export type AccordionItemGroupProps = AccordionItemGroupBaseProps &
|
|
29
|
+
AccordionVariantProps
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A grouped item for the Accordion component.
|
|
33
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/accordion)
|
|
34
|
+
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <Accordion>
|
|
38
|
+
* <AccordionItemGroup heading="Accordion Item 1" value="one">
|
|
39
|
+
* Accordion Item 1 content
|
|
40
|
+
* </AccordionItemGroup>
|
|
41
|
+
* </Accordion>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function AccordionItemGroup(
|
|
45
|
+
props: PropsWithChildren<AccordionItemGroupProps>,
|
|
46
|
+
) {
|
|
47
|
+
const {
|
|
48
|
+
size,
|
|
49
|
+
heading,
|
|
50
|
+
children,
|
|
51
|
+
indicatorPosition = 'end',
|
|
52
|
+
...itemProps
|
|
53
|
+
} = props
|
|
54
|
+
const triggerStyles =
|
|
55
|
+
indicatorPosition === 'start'
|
|
56
|
+
? {
|
|
57
|
+
gap: 'md',
|
|
58
|
+
justifyContent: 'flex-start',
|
|
59
|
+
}
|
|
60
|
+
: undefined
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<AccordionItem {...itemProps}>
|
|
64
|
+
<AccordionItemTrigger className={css(triggerStyles)} size={size}>
|
|
65
|
+
<Show when={indicatorPosition === 'start'}>
|
|
66
|
+
<AccordionItemIndicator size={size} />
|
|
67
|
+
</Show>
|
|
68
|
+
|
|
69
|
+
{heading}
|
|
70
|
+
|
|
71
|
+
<Show when={indicatorPosition === 'end'}>
|
|
72
|
+
<AccordionItemIndicator size={size} />
|
|
73
|
+
</Show>
|
|
74
|
+
</AccordionItemTrigger>
|
|
75
|
+
|
|
76
|
+
<AccordionItemContent size={size}>{children}</AccordionItemContent>
|
|
77
|
+
</AccordionItem>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DatePicker as ArkDP,
|
|
5
|
+
type DatePickerContentProps,
|
|
6
|
+
type DatePickerInputProps,
|
|
7
|
+
type DatePickerRootProps,
|
|
8
|
+
type DatePickerViewProps,
|
|
9
|
+
// type DateValue,
|
|
10
|
+
} from '@ark-ui/react'
|
|
11
|
+
import { Portal } from './Portal'
|
|
12
|
+
// import { useCallback } from 'react'
|
|
13
|
+
import { datePicker } from '@cerberus/styled-system/recipes'
|
|
14
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
15
|
+
import { useFieldContext } from '../context/field'
|
|
16
|
+
import {
|
|
17
|
+
DatePickerTrigger,
|
|
18
|
+
DatePickerView,
|
|
19
|
+
DatePickerContext,
|
|
20
|
+
DatePickerViewControlGroup,
|
|
21
|
+
DatePickerTable,
|
|
22
|
+
DatePickerTableHeader,
|
|
23
|
+
DatePickerTableCellTrigger,
|
|
24
|
+
DatePickerTableCell,
|
|
25
|
+
} from './DatePicker.server'
|
|
26
|
+
// import { formatISOToMilitary } from '../hooks/useDate'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This module contains the DatePicker client family components.
|
|
30
|
+
* @module DatePicker:client
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// We are not exposing this to the public API
|
|
34
|
+
const datePickerStyles = datePicker()
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The main context provider for the DatePicker family components.
|
|
38
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <Field>
|
|
42
|
+
* <DatePicker name="start_date">
|
|
43
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
44
|
+
* <DatePickerInput />
|
|
45
|
+
* <DatePickerCalendar />
|
|
46
|
+
* </DatePicker>
|
|
47
|
+
* </Field>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function DatePicker(props: DatePickerRootProps) {
|
|
51
|
+
const states = useFieldContext()
|
|
52
|
+
|
|
53
|
+
// TODO: Remove this once the bug is fixed: https://github.com/chakra-ui/ark/issues/3112
|
|
54
|
+
|
|
55
|
+
// There is a bug with the Root component that causes random date selection
|
|
56
|
+
// onBlur after the first selection if the format prop is used.
|
|
57
|
+
// const handleFormat = useCallback((value: DateValue) => {
|
|
58
|
+
// return formatISOToMilitary(value.toString())
|
|
59
|
+
// }, [])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<ArkDP.Root
|
|
63
|
+
{...props}
|
|
64
|
+
{...states}
|
|
65
|
+
positioning={{
|
|
66
|
+
placement: 'bottom-start',
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The input component for the DatePicker.
|
|
74
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <Field>
|
|
78
|
+
* <DatePicker name="start_date">
|
|
79
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
80
|
+
* <DatePickerInput />
|
|
81
|
+
* <DatePickerCalendar />
|
|
82
|
+
* </DatePicker>
|
|
83
|
+
* </Field>
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function DatePickerInput(props: DatePickerInputProps) {
|
|
87
|
+
const { invalid, ...fieldStates } = useFieldContext()
|
|
88
|
+
return (
|
|
89
|
+
<ArkDP.Control className={datePickerStyles.control}>
|
|
90
|
+
<DatePickerTrigger />
|
|
91
|
+
<ArkDP.Input
|
|
92
|
+
{...props}
|
|
93
|
+
{...fieldStates}
|
|
94
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
95
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
96
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
97
|
+
maxLength={11}
|
|
98
|
+
/>
|
|
99
|
+
</ArkDP.Control>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The input component for the DatePicker that uses ranges.
|
|
105
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <Field>
|
|
109
|
+
* <DatePicker name="start_date" selection="range">
|
|
110
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
111
|
+
* <RangePickerInput />
|
|
112
|
+
* <DatePickerCalendar />
|
|
113
|
+
* </DatePicker>
|
|
114
|
+
* </Field>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function RangePickerInput(props: DatePickerInputProps) {
|
|
118
|
+
const { invalid, ...fieldStates } = useFieldContext()
|
|
119
|
+
return (
|
|
120
|
+
<ArkDP.Control data-range className={datePickerStyles.control}>
|
|
121
|
+
<DatePickerTrigger />
|
|
122
|
+
<ArkDP.Input
|
|
123
|
+
{...props}
|
|
124
|
+
{...fieldStates}
|
|
125
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
126
|
+
data-range-input
|
|
127
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
128
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
129
|
+
maxLength={11}
|
|
130
|
+
index={0}
|
|
131
|
+
/>
|
|
132
|
+
<ArkDP.Input
|
|
133
|
+
{...props}
|
|
134
|
+
{...fieldStates}
|
|
135
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
136
|
+
data-range-input
|
|
137
|
+
data-range-end-input
|
|
138
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
139
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
140
|
+
maxLength={11}
|
|
141
|
+
index={1}
|
|
142
|
+
/>
|
|
143
|
+
</ArkDP.Control>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The content component for the DatePicker which contains the calendar.
|
|
149
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* <Field>
|
|
153
|
+
* <DatePicker name="start_date">
|
|
154
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
155
|
+
* <DatePickerInput />
|
|
156
|
+
* <DatePickerCalendar />
|
|
157
|
+
* </DatePicker>
|
|
158
|
+
* </Field>
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export function DatePickerContent(props: DatePickerContentProps) {
|
|
162
|
+
const { children, ...contentProps } = props
|
|
163
|
+
return (
|
|
164
|
+
<Portal>
|
|
165
|
+
<ArkDP.Positioner className={datePickerStyles.positioner}>
|
|
166
|
+
<ArkDP.Content
|
|
167
|
+
{...contentProps}
|
|
168
|
+
className={cx(contentProps.className, datePickerStyles.content)}
|
|
169
|
+
>
|
|
170
|
+
{children}
|
|
171
|
+
</ArkDP.Content>
|
|
172
|
+
</ArkDP.Positioner>
|
|
173
|
+
</Portal>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The day view component for the DatePicker.
|
|
179
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* <Field>
|
|
183
|
+
* <DatePicker name="start_date">
|
|
184
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
185
|
+
* <DatePickerInput />
|
|
186
|
+
* <DatePickerCalendar />
|
|
187
|
+
* </DatePicker>
|
|
188
|
+
* </Field>
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export function DatePickerDayView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
192
|
+
function isToday(date: ArkDP.DateValue): boolean {
|
|
193
|
+
const today = new Date()
|
|
194
|
+
const formatted = today.toISOString().split('T')[0]
|
|
195
|
+
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
196
|
+
return formatted === arkDate
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isPastDay(date: ArkDP.DateValue): boolean {
|
|
200
|
+
const today = new Date()
|
|
201
|
+
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
202
|
+
return new Date(arkDate) < today
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function getDayValue(date: ArkDP.DateValue): 'today' | 'past' | 'future' {
|
|
206
|
+
if (isToday(date)) return 'today'
|
|
207
|
+
if (isPastDay(date)) return 'past'
|
|
208
|
+
return 'future'
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<DatePickerView {...props} view="day">
|
|
213
|
+
<DatePickerContext>
|
|
214
|
+
{(datePicker) => (
|
|
215
|
+
<>
|
|
216
|
+
<DatePickerViewControlGroup />
|
|
217
|
+
|
|
218
|
+
<DatePickerTable>
|
|
219
|
+
<ArkDP.TableHead>
|
|
220
|
+
<ArkDP.TableRow>
|
|
221
|
+
{datePicker.weekDays.map((weekDay, id) => (
|
|
222
|
+
<DatePickerTableHeader key={id}>
|
|
223
|
+
{weekDay.narrow}
|
|
224
|
+
</DatePickerTableHeader>
|
|
225
|
+
))}
|
|
226
|
+
</ArkDP.TableRow>
|
|
227
|
+
</ArkDP.TableHead>
|
|
228
|
+
|
|
229
|
+
<ArkDP.TableBody>
|
|
230
|
+
{datePicker.weeks.map((week, id) => (
|
|
231
|
+
<ArkDP.TableRow key={id}>
|
|
232
|
+
{week.map((day, id) => (
|
|
233
|
+
<DatePickerTableCell key={id} value={day}>
|
|
234
|
+
<DatePickerTableCellTrigger
|
|
235
|
+
data-date={getDayValue(day)}
|
|
236
|
+
>
|
|
237
|
+
{day.day}
|
|
238
|
+
</DatePickerTableCellTrigger>
|
|
239
|
+
</DatePickerTableCell>
|
|
240
|
+
))}
|
|
241
|
+
</ArkDP.TableRow>
|
|
242
|
+
))}
|
|
243
|
+
</ArkDP.TableBody>
|
|
244
|
+
</DatePickerTable>
|
|
245
|
+
</>
|
|
246
|
+
)}
|
|
247
|
+
</DatePickerContext>
|
|
248
|
+
</DatePickerView>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The month view component for the DatePicker.
|
|
254
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
255
|
+
* @example
|
|
256
|
+
* ```tsx
|
|
257
|
+
* <Field>
|
|
258
|
+
* <DatePicker name="start_date">
|
|
259
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
260
|
+
* <DatePickerInput />
|
|
261
|
+
* <DatePickerCalendar />
|
|
262
|
+
* </DatePicker>
|
|
263
|
+
* </Field>
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export function DatePickerMonthView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
267
|
+
return (
|
|
268
|
+
<ArkDP.View {...props} view="month">
|
|
269
|
+
<ArkDP.Context>
|
|
270
|
+
{(datePicker) => (
|
|
271
|
+
<>
|
|
272
|
+
<DatePickerViewControlGroup />
|
|
273
|
+
|
|
274
|
+
<DatePickerTable>
|
|
275
|
+
<ArkDP.TableBody>
|
|
276
|
+
{datePicker
|
|
277
|
+
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
278
|
+
.map((months, id) => (
|
|
279
|
+
<ArkDP.TableRow key={id}>
|
|
280
|
+
{months.map((month, id) => (
|
|
281
|
+
<DatePickerTableCell key={id} value={month.value}>
|
|
282
|
+
<DatePickerTableCellTrigger>
|
|
283
|
+
{month.label}
|
|
284
|
+
</DatePickerTableCellTrigger>
|
|
285
|
+
</DatePickerTableCell>
|
|
286
|
+
))}
|
|
287
|
+
</ArkDP.TableRow>
|
|
288
|
+
))}
|
|
289
|
+
</ArkDP.TableBody>
|
|
290
|
+
</DatePickerTable>
|
|
291
|
+
</>
|
|
292
|
+
)}
|
|
293
|
+
</ArkDP.Context>
|
|
294
|
+
</ArkDP.View>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The year view component for the DatePicker.
|
|
300
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* <Field>
|
|
304
|
+
* <DatePicker name="start_date">
|
|
305
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
306
|
+
* <DatePickerInput />
|
|
307
|
+
* <DatePickerCalendar />
|
|
308
|
+
* </DatePicker>
|
|
309
|
+
* </Field>
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export function DatePickerYearView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
313
|
+
return (
|
|
314
|
+
<ArkDP.View {...props} view="year">
|
|
315
|
+
<ArkDP.Context>
|
|
316
|
+
{(datePicker) => (
|
|
317
|
+
<>
|
|
318
|
+
<DatePickerViewControlGroup />
|
|
319
|
+
|
|
320
|
+
<DatePickerTable>
|
|
321
|
+
<ArkDP.TableBody>
|
|
322
|
+
{datePicker.getYearsGrid({ columns: 4 }).map((years, id) => (
|
|
323
|
+
<ArkDP.TableRow key={id}>
|
|
324
|
+
{years.map((year, id) => (
|
|
325
|
+
<DatePickerTableCell key={id} value={year.value}>
|
|
326
|
+
<DatePickerTableCellTrigger>
|
|
327
|
+
{year.label}
|
|
328
|
+
</DatePickerTableCellTrigger>
|
|
329
|
+
</DatePickerTableCell>
|
|
330
|
+
))}
|
|
331
|
+
</ArkDP.TableRow>
|
|
332
|
+
))}
|
|
333
|
+
</ArkDP.TableBody>
|
|
334
|
+
</DatePickerTable>
|
|
335
|
+
</>
|
|
336
|
+
)}
|
|
337
|
+
</ArkDP.Context>
|
|
338
|
+
</ArkDP.View>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* An abstraction of the DatePicker content components that contain the
|
|
344
|
+
* different calendar views and controls.
|
|
345
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
346
|
+
* @example
|
|
347
|
+
* ```tsx
|
|
348
|
+
* <Field>
|
|
349
|
+
* <DatePicker name="start_date">
|
|
350
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
351
|
+
* <DatePickerInput />
|
|
352
|
+
* <DatePickerCalendar />
|
|
353
|
+
* </DatePicker>
|
|
354
|
+
* </Field>
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
export function DatePickerCalendar() {
|
|
358
|
+
return (
|
|
359
|
+
<DatePickerContent>
|
|
360
|
+
<DatePickerDayView />
|
|
361
|
+
<DatePickerMonthView />
|
|
362
|
+
<DatePickerYearView />
|
|
363
|
+
</DatePickerContent>
|
|
364
|
+
)
|
|
365
|
+
}
|