@cerberus-design/react 0.13.2-next-c6aea71 → 0.13.2-next-b5a889e
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 +346 -23
- package/build/legacy/components/Accordion.cjs.map +1 -1
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
- 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 +525 -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/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/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/hooks/useDate.cjs +8 -0
- package/build/legacy/hooks/useDate.cjs.map +1 -1
- package/build/legacy/index.cjs +936 -608
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +346 -23
- package/build/modern/chunk-2ZNIYPDV.js +47 -0
- package/build/modern/chunk-2ZNIYPDV.js.map +1 -0
- package/build/modern/{chunk-ZTYKIWYQ.js → chunk-34E3UFFB.js} +1 -1
- 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-SPZYPRZ6.js → chunk-BU5JK37R.js} +2 -2
- 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-TM5AS6M6.js → chunk-ECKJGCNH.js} +6 -6
- package/build/modern/chunk-ECKJGCNH.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-CSMPRYNC.js → chunk-F7XWOSN3.js} +2 -2
- package/build/modern/{chunk-622N7YRT.js → chunk-FRWNAVDM.js} +8 -9
- package/build/modern/chunk-FRWNAVDM.js.map +1 -0
- package/build/modern/{chunk-4QBPJVEN.js → chunk-G7AGKII3.js} +11 -11
- package/build/modern/chunk-G7AGKII3.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-C3CDRCHS.js → chunk-M73ECA25.js} +4 -4
- package/build/modern/chunk-M73ECA25.js.map +1 -0
- package/build/modern/{chunk-W4DXACNV.js → chunk-O7QVCF3H.js} +3 -3
- package/build/modern/chunk-QX4V5V74.js +169 -0
- package/build/modern/chunk-QX4V5V74.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-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 +1 -1
- package/build/modern/components/AccordionItemGroup.js +2 -2
- 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 +32 -0
- package/build/modern/components/DatePicker.client.js.map +1 -0
- package/build/modern/components/DatePicker.server.js +31 -0
- package/build/modern/components/DatePicker.server.js.map +1 -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/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/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 +6 -6
- package/build/modern/context/cta-modal.js +6 -6
- package/build/modern/context/notification-center.js +7 -7
- package/build/modern/context/prompt-modal.js +9 -9
- package/build/modern/hooks/useDate.js +3 -1
- package/build/modern/index.js +118 -72
- package/build/modern/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Accordion.tsx +0 -1
- package/src/components/DatePicker.client.tsx +364 -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/Text.tsx +70 -0
- 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/hooks/useDate.ts +12 -0
- package/src/index.ts +3 -0
- package/build/modern/chunk-4QBPJVEN.js.map +0 -1
- package/build/modern/chunk-622N7YRT.js.map +0 -1
- package/build/modern/chunk-7SGPJM66.js.map +0 -1
- package/build/modern/chunk-C3CDRCHS.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-KCANMM64.js.map +0 -1
- package/build/modern/chunk-SXIXDXG3.js.map +0 -1
- package/build/modern/chunk-TM5AS6M6.js.map +0 -1
- package/build/modern/chunk-XEW6TJJ4.js.map +0 -1
- package/build/modern/chunk-ZTYKIWYQ.js.map +0 -1
- /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-CSMPRYNC.js.map → chunk-F7XWOSN3.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
|
@@ -0,0 +1,364 @@
|
|
|
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: Fix this format bug
|
|
54
|
+
// There is a bug with the Root component that causes random date selection onBlur after the first selection if the format prop is used.
|
|
55
|
+
const handleFormat = useCallback((value: DateValue) => {
|
|
56
|
+
return formatISOToMilitary(value.toString())
|
|
57
|
+
}, [])
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<ArkDP.Root
|
|
61
|
+
{...props}
|
|
62
|
+
{...states}
|
|
63
|
+
format={handleFormat}
|
|
64
|
+
positioning={{
|
|
65
|
+
placement: 'bottom-start',
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The input component for the DatePicker.
|
|
73
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <Field>
|
|
77
|
+
* <DatePicker name="start_date">
|
|
78
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
79
|
+
* <DatePickerInput />
|
|
80
|
+
* <DatePickerCalendar />
|
|
81
|
+
* </DatePicker>
|
|
82
|
+
* </Field>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export function DatePickerInput(props: DatePickerInputProps) {
|
|
86
|
+
const { invalid, ...fieldStates } = useFieldContext()
|
|
87
|
+
return (
|
|
88
|
+
<ArkDP.Control className={datePickerStyles.control}>
|
|
89
|
+
<DatePickerTrigger />
|
|
90
|
+
<ArkDP.Input
|
|
91
|
+
{...props}
|
|
92
|
+
{...fieldStates}
|
|
93
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
94
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
95
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
96
|
+
maxLength={11}
|
|
97
|
+
/>
|
|
98
|
+
</ArkDP.Control>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The input component for the DatePicker that uses ranges.
|
|
104
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <Field>
|
|
108
|
+
* <DatePicker name="start_date" selection="range">
|
|
109
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
110
|
+
* <RangePickerInput />
|
|
111
|
+
* <DatePickerCalendar />
|
|
112
|
+
* </DatePicker>
|
|
113
|
+
* </Field>
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function RangePickerInput(props: DatePickerInputProps) {
|
|
117
|
+
const { invalid, ...fieldStates } = useFieldContext()
|
|
118
|
+
return (
|
|
119
|
+
<ArkDP.Control data-range className={datePickerStyles.control}>
|
|
120
|
+
<DatePickerTrigger />
|
|
121
|
+
<ArkDP.Input
|
|
122
|
+
{...props}
|
|
123
|
+
{...fieldStates}
|
|
124
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
125
|
+
data-range-input
|
|
126
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
127
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
128
|
+
maxLength={11}
|
|
129
|
+
index={0}
|
|
130
|
+
/>
|
|
131
|
+
<ArkDP.Input
|
|
132
|
+
{...props}
|
|
133
|
+
{...fieldStates}
|
|
134
|
+
{...(invalid && { 'aria-invalid': true })}
|
|
135
|
+
data-range-input
|
|
136
|
+
data-range-end-input
|
|
137
|
+
className={cx(props.className, datePickerStyles.input)}
|
|
138
|
+
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
139
|
+
maxLength={11}
|
|
140
|
+
index={1}
|
|
141
|
+
/>
|
|
142
|
+
</ArkDP.Control>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The content component for the DatePicker which contains the calendar.
|
|
148
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
149
|
+
* @example
|
|
150
|
+
* ```tsx
|
|
151
|
+
* <Field>
|
|
152
|
+
* <DatePicker name="start_date">
|
|
153
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
154
|
+
* <DatePickerInput />
|
|
155
|
+
* <DatePickerCalendar />
|
|
156
|
+
* </DatePicker>
|
|
157
|
+
* </Field>
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export function DatePickerContent(props: DatePickerContentProps) {
|
|
161
|
+
const { children, ...contentProps } = props
|
|
162
|
+
return (
|
|
163
|
+
<Portal>
|
|
164
|
+
<ArkDP.Positioner className={datePickerStyles.positioner}>
|
|
165
|
+
<ArkDP.Content
|
|
166
|
+
{...contentProps}
|
|
167
|
+
className={cx(contentProps.className, datePickerStyles.content)}
|
|
168
|
+
>
|
|
169
|
+
{children}
|
|
170
|
+
</ArkDP.Content>
|
|
171
|
+
</ArkDP.Positioner>
|
|
172
|
+
</Portal>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The day view component for the DatePicker.
|
|
178
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
179
|
+
* @example
|
|
180
|
+
* ```tsx
|
|
181
|
+
* <Field>
|
|
182
|
+
* <DatePicker name="start_date">
|
|
183
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
184
|
+
* <DatePickerInput />
|
|
185
|
+
* <DatePickerCalendar />
|
|
186
|
+
* </DatePicker>
|
|
187
|
+
* </Field>
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export function DatePickerDayView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
191
|
+
function isToday(date: ArkDP.DateValue): boolean {
|
|
192
|
+
const today = new Date()
|
|
193
|
+
const formatted = today.toISOString().split('T')[0]
|
|
194
|
+
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
195
|
+
return formatted === arkDate
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isPastDay(date: ArkDP.DateValue): boolean {
|
|
199
|
+
const today = new Date()
|
|
200
|
+
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
201
|
+
return new Date(arkDate) < today
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function getDayValue(date: ArkDP.DateValue): 'today' | 'past' | 'future' {
|
|
205
|
+
if (isToday(date)) return 'today'
|
|
206
|
+
if (isPastDay(date)) return 'past'
|
|
207
|
+
return 'future'
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<DatePickerView {...props} view="day">
|
|
212
|
+
<DatePickerContext>
|
|
213
|
+
{(datePicker) => (
|
|
214
|
+
<>
|
|
215
|
+
<DatePickerViewControlGroup />
|
|
216
|
+
|
|
217
|
+
<DatePickerTable>
|
|
218
|
+
<ArkDP.TableHead>
|
|
219
|
+
<ArkDP.TableRow>
|
|
220
|
+
{datePicker.weekDays.map((weekDay, id) => (
|
|
221
|
+
<DatePickerTableHeader key={id}>
|
|
222
|
+
{weekDay.narrow}
|
|
223
|
+
</DatePickerTableHeader>
|
|
224
|
+
))}
|
|
225
|
+
</ArkDP.TableRow>
|
|
226
|
+
</ArkDP.TableHead>
|
|
227
|
+
|
|
228
|
+
<ArkDP.TableBody>
|
|
229
|
+
{datePicker.weeks.map((week, id) => (
|
|
230
|
+
<ArkDP.TableRow key={id}>
|
|
231
|
+
{week.map((day, id) => (
|
|
232
|
+
<DatePickerTableCell key={id} value={day}>
|
|
233
|
+
<DatePickerTableCellTrigger
|
|
234
|
+
data-date={getDayValue(day)}
|
|
235
|
+
>
|
|
236
|
+
{day.day}
|
|
237
|
+
</DatePickerTableCellTrigger>
|
|
238
|
+
</DatePickerTableCell>
|
|
239
|
+
))}
|
|
240
|
+
</ArkDP.TableRow>
|
|
241
|
+
))}
|
|
242
|
+
</ArkDP.TableBody>
|
|
243
|
+
</DatePickerTable>
|
|
244
|
+
</>
|
|
245
|
+
)}
|
|
246
|
+
</DatePickerContext>
|
|
247
|
+
</DatePickerView>
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The month view component for the DatePicker.
|
|
253
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* <Field>
|
|
257
|
+
* <DatePicker name="start_date">
|
|
258
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
259
|
+
* <DatePickerInput />
|
|
260
|
+
* <DatePickerCalendar />
|
|
261
|
+
* </DatePicker>
|
|
262
|
+
* </Field>
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function DatePickerMonthView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
266
|
+
return (
|
|
267
|
+
<ArkDP.View {...props} view="month">
|
|
268
|
+
<ArkDP.Context>
|
|
269
|
+
{(datePicker) => (
|
|
270
|
+
<>
|
|
271
|
+
<DatePickerViewControlGroup />
|
|
272
|
+
|
|
273
|
+
<DatePickerTable>
|
|
274
|
+
<ArkDP.TableBody>
|
|
275
|
+
{datePicker
|
|
276
|
+
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
277
|
+
.map((months, id) => (
|
|
278
|
+
<ArkDP.TableRow key={id}>
|
|
279
|
+
{months.map((month, id) => (
|
|
280
|
+
<DatePickerTableCell key={id} value={month.value}>
|
|
281
|
+
<DatePickerTableCellTrigger>
|
|
282
|
+
{month.label}
|
|
283
|
+
</DatePickerTableCellTrigger>
|
|
284
|
+
</DatePickerTableCell>
|
|
285
|
+
))}
|
|
286
|
+
</ArkDP.TableRow>
|
|
287
|
+
))}
|
|
288
|
+
</ArkDP.TableBody>
|
|
289
|
+
</DatePickerTable>
|
|
290
|
+
</>
|
|
291
|
+
)}
|
|
292
|
+
</ArkDP.Context>
|
|
293
|
+
</ArkDP.View>
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The year view component for the DatePicker.
|
|
299
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
300
|
+
* @example
|
|
301
|
+
* ```tsx
|
|
302
|
+
* <Field>
|
|
303
|
+
* <DatePicker name="start_date">
|
|
304
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
305
|
+
* <DatePickerInput />
|
|
306
|
+
* <DatePickerCalendar />
|
|
307
|
+
* </DatePicker>
|
|
308
|
+
* </Field>
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
export function DatePickerYearView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
312
|
+
return (
|
|
313
|
+
<ArkDP.View {...props} view="year">
|
|
314
|
+
<ArkDP.Context>
|
|
315
|
+
{(datePicker) => (
|
|
316
|
+
<>
|
|
317
|
+
<DatePickerViewControlGroup />
|
|
318
|
+
|
|
319
|
+
<DatePickerTable>
|
|
320
|
+
<ArkDP.TableBody>
|
|
321
|
+
{datePicker.getYearsGrid({ columns: 4 }).map((years, id) => (
|
|
322
|
+
<ArkDP.TableRow key={id}>
|
|
323
|
+
{years.map((year, id) => (
|
|
324
|
+
<DatePickerTableCell key={id} value={year.value}>
|
|
325
|
+
<DatePickerTableCellTrigger>
|
|
326
|
+
{year.label}
|
|
327
|
+
</DatePickerTableCellTrigger>
|
|
328
|
+
</DatePickerTableCell>
|
|
329
|
+
))}
|
|
330
|
+
</ArkDP.TableRow>
|
|
331
|
+
))}
|
|
332
|
+
</ArkDP.TableBody>
|
|
333
|
+
</DatePickerTable>
|
|
334
|
+
</>
|
|
335
|
+
)}
|
|
336
|
+
</ArkDP.Context>
|
|
337
|
+
</ArkDP.View>
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* An abstraction of the DatePicker content components that contain the
|
|
343
|
+
* different calendar views and controls.
|
|
344
|
+
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
345
|
+
* @example
|
|
346
|
+
* ```tsx
|
|
347
|
+
* <Field>
|
|
348
|
+
* <DatePicker name="start_date">
|
|
349
|
+
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
350
|
+
* <DatePickerInput />
|
|
351
|
+
* <DatePickerCalendar />
|
|
352
|
+
* </DatePicker>
|
|
353
|
+
* </Field>
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
export function DatePickerCalendar() {
|
|
357
|
+
return (
|
|
358
|
+
<DatePickerContent>
|
|
359
|
+
<DatePickerDayView />
|
|
360
|
+
<DatePickerMonthView />
|
|
361
|
+
<DatePickerYearView />
|
|
362
|
+
</DatePickerContent>
|
|
363
|
+
)
|
|
364
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DatePicker as ArkDP,
|
|
3
|
+
type DatePickerLabelProps,
|
|
4
|
+
type DatePickerTableCellProps,
|
|
5
|
+
type DatePickerTableCellTriggerProps,
|
|
6
|
+
type DatePickerTableHeaderProps,
|
|
7
|
+
type DatePickerTableProps,
|
|
8
|
+
type DatePickerTriggerProps,
|
|
9
|
+
type DatePickerViewControlProps,
|
|
10
|
+
} from '@ark-ui/react'
|
|
11
|
+
import { css, cx } from '@cerberus/styled-system/css'
|
|
12
|
+
import { datePicker, iconButton, label } from '@cerberus/styled-system/recipes'
|
|
13
|
+
import { $cerberusIcons } from '../config/defineIcons'
|
|
14
|
+
import { IconButton } from './IconButton'
|
|
15
|
+
import { Button } from './Button'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This module contains the DatePicker server family components.
|
|
19
|
+
* @module DatePicker
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// We are not exposing this to the public API
|
|
23
|
+
const datePickerStyles = datePicker()
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The label component for the DatePicker.
|
|
27
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <DatePickerLabel>
|
|
31
|
+
* <DatePickerLabel.Label>...</DatePickerLabel.Label>
|
|
32
|
+
* </DatePickerLabel>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function DatePickerLabel(props: DatePickerLabelProps) {
|
|
36
|
+
const { className, ...arkProps } = props
|
|
37
|
+
return (
|
|
38
|
+
<ArkDP.Label
|
|
39
|
+
{...arkProps}
|
|
40
|
+
className={cx(
|
|
41
|
+
className,
|
|
42
|
+
label({
|
|
43
|
+
size: 'sm',
|
|
44
|
+
}),
|
|
45
|
+
)}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The trigger component for the DatePicker which opens the calendar.
|
|
52
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <DatePickerTrigger />
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function DatePickerTrigger(props: DatePickerTriggerProps) {
|
|
59
|
+
const { calendar: CalendarIcon } = $cerberusIcons
|
|
60
|
+
return (
|
|
61
|
+
<ArkDP.Trigger
|
|
62
|
+
{...props}
|
|
63
|
+
className={cx(
|
|
64
|
+
props.className,
|
|
65
|
+
iconButton({
|
|
66
|
+
size: 'sm',
|
|
67
|
+
usage: 'ghost',
|
|
68
|
+
}),
|
|
69
|
+
datePickerStyles.trigger,
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
<CalendarIcon />
|
|
73
|
+
</ArkDP.Trigger>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The control component for the DatePicker which wraps the triggers to switch
|
|
79
|
+
* between calendar views.
|
|
80
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <DatePickerViewControl>
|
|
84
|
+
* <PrevTrigger />
|
|
85
|
+
* <ViewTrigger />
|
|
86
|
+
* <NextTrigger />
|
|
87
|
+
* </DatePickerViewControl>
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export function DatePickerViewControl(props: DatePickerViewControlProps) {
|
|
91
|
+
return (
|
|
92
|
+
<ArkDP.Control
|
|
93
|
+
{...props}
|
|
94
|
+
className={cx(props.className, datePickerStyles.viewControl)}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* An abstraction of the DatePicker control that contains the prev, view, and
|
|
101
|
+
* next triggers which control the calendar output.
|
|
102
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* <DatePickerViewControlGroup />
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export function DatePickerViewControlGroup(props: DatePickerViewControlProps) {
|
|
109
|
+
const { calendarPrev: PrevIcon, calendarNext: NextIcon } = $cerberusIcons
|
|
110
|
+
return (
|
|
111
|
+
<DatePickerViewControl {...props}>
|
|
112
|
+
<ArkDP.PrevTrigger asChild>
|
|
113
|
+
<IconButton ariaLabel="Previous" size="sm">
|
|
114
|
+
<PrevIcon />
|
|
115
|
+
</IconButton>
|
|
116
|
+
</ArkDP.PrevTrigger>
|
|
117
|
+
|
|
118
|
+
<ArkDP.ViewTrigger asChild>
|
|
119
|
+
<Button
|
|
120
|
+
className={css({
|
|
121
|
+
h: '2rem',
|
|
122
|
+
paddingInline: 'md',
|
|
123
|
+
})}
|
|
124
|
+
shape="rounded"
|
|
125
|
+
size="sm"
|
|
126
|
+
usage="ghost"
|
|
127
|
+
>
|
|
128
|
+
<ArkDP.RangeText />
|
|
129
|
+
</Button>
|
|
130
|
+
</ArkDP.ViewTrigger>
|
|
131
|
+
|
|
132
|
+
<ArkDP.NextTrigger asChild>
|
|
133
|
+
<IconButton ariaLabel="Next" size="sm">
|
|
134
|
+
<NextIcon />
|
|
135
|
+
</IconButton>
|
|
136
|
+
</ArkDP.NextTrigger>
|
|
137
|
+
</DatePickerViewControl>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The table component for the DatePicker.
|
|
143
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* <DatePickerTable />
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export function DatePickerTable(props: DatePickerTableProps) {
|
|
150
|
+
return (
|
|
151
|
+
<ArkDP.Table
|
|
152
|
+
{...props}
|
|
153
|
+
className={cx(props.className, datePickerStyles.table)}
|
|
154
|
+
/>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The header component for the DatePicker table.
|
|
160
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
161
|
+
* @example
|
|
162
|
+
* ```tsx
|
|
163
|
+
* <DatePickerTableHeader />
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export function DatePickerTableHeader(props: DatePickerTableHeaderProps) {
|
|
167
|
+
return (
|
|
168
|
+
<ArkDP.TableHeader
|
|
169
|
+
{...props}
|
|
170
|
+
className={cx(props.className, datePickerStyles.tableHeader)}
|
|
171
|
+
/>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The cell component for the DatePicker table.
|
|
177
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* <DatePickerTableCell />
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export function DatePickerTableCell(props: DatePickerTableCellProps) {
|
|
184
|
+
return (
|
|
185
|
+
<ArkDP.TableCell
|
|
186
|
+
{...props}
|
|
187
|
+
className={cx(props.className, datePickerStyles.tableCell)}
|
|
188
|
+
/>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The cell component for the DatePicker table.
|
|
194
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
195
|
+
* @example
|
|
196
|
+
* ```tsx
|
|
197
|
+
* <DatePickerTableCell />
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export function DatePickerTableCellTrigger(
|
|
201
|
+
props: DatePickerTableCellTriggerProps,
|
|
202
|
+
) {
|
|
203
|
+
return (
|
|
204
|
+
<ArkDP.TableCellTrigger
|
|
205
|
+
{...props}
|
|
206
|
+
className={cx(props.className, datePickerStyles.tableCellTrigger)}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The view container which wraps the control and content components.
|
|
213
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
214
|
+
* @example
|
|
215
|
+
* ```tsx
|
|
216
|
+
* <DatePickerView />
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export const DatePickerView = ArkDP.View
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The context component for the DatePicker which provides the DatePicker state.
|
|
223
|
+
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
224
|
+
* @example
|
|
225
|
+
* ```tsx
|
|
226
|
+
* <DatePickerContext />
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
export const DatePickerContext = ArkDP.Context
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type MouseEvent,
|
|
14
14
|
} from 'react'
|
|
15
15
|
import { $cerberusIcons } from '../config/defineIcons'
|
|
16
|
-
import type { IconType } from '../config/cerbIcons'
|
|
17
16
|
import { trapFocus } from '../aria-helpers/trap-focus.aria'
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -22,9 +21,13 @@ import { trapFocus } from '../aria-helpers/trap-focus.aria'
|
|
|
22
21
|
*/
|
|
23
22
|
|
|
24
23
|
function MatchNotificationIcon(props: NotificationVariantProps) {
|
|
25
|
-
const palette = props.palette || 'info'
|
|
24
|
+
const palette = (props.palette || 'info') as
|
|
25
|
+
| 'info'
|
|
26
|
+
| 'success'
|
|
27
|
+
| 'warning'
|
|
28
|
+
| 'danger'
|
|
26
29
|
const key = `${palette}Notification` as keyof typeof $cerberusIcons
|
|
27
|
-
const Icon = $cerberusIcons[key]
|
|
30
|
+
const Icon = $cerberusIcons[key]
|
|
28
31
|
return <Icon />
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -10,8 +10,8 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export type BaseNotificationDescriptionProps =
|
|
14
|
+
HTMLAttributes<HTMLParagraphElement>
|
|
15
15
|
export type NotificationDescriptionProps = BaseNotificationDescriptionProps &
|
|
16
16
|
NotificationVariantProps
|
|
17
17
|
|
|
@@ -10,8 +10,7 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
extends HTMLAttributes<HTMLParagraphElement> {}
|
|
13
|
+
export type BaseNotificationHeadingProps = HTMLAttributes<HTMLParagraphElement>
|
|
15
14
|
export type NotificationHeadingProps = BaseNotificationHeadingProps &
|
|
16
15
|
NotificationVariantProps
|
|
17
16
|
|
|
@@ -10,7 +10,7 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type ProgressBarBaseProps = HTMLAttributes<HTMLDivElement>
|
|
14
14
|
export type NonIndeterminateProgressBarProps = {
|
|
15
15
|
/**
|
|
16
16
|
* A unique identifier for the progress bar. Required for accessibility.
|