@cerberus-design/react 1.0.0-rc.5 → 1.0.0-rc.7
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/dist/panda.buildinfo.json +349 -0
- package/package.json +8 -5
- package/src/components/AnimatingUploadIcon.tsx +0 -83
- package/src/components/accordion/index.ts +0 -3
- package/src/components/accordion/item-group.tsx +0 -70
- package/src/components/accordion/item-indicator.tsx +0 -27
- package/src/components/accordion/parts.ts +0 -53
- package/src/components/accordion/primitives.tsx +0 -86
- package/src/components/admonition/admonition.tsx +0 -62
- package/src/components/admonition/index.ts +0 -3
- package/src/components/admonition/match-avatar.tsx +0 -52
- package/src/components/admonition/parts.ts +0 -53
- package/src/components/admonition/primitives.tsx +0 -77
- package/src/components/avatar/avatar.tsx +0 -51
- package/src/components/avatar/index.ts +0 -5
- package/src/components/avatar/parts.ts +0 -37
- package/src/components/avatar/primitives.tsx +0 -38
- package/src/components/button/button.tsx +0 -62
- package/src/components/button/index.ts +0 -3
- package/src/components/button/parts.ts +0 -32
- package/src/components/button/primitives.tsx +0 -41
- package/src/components/carousel/carousel.tsx +0 -55
- package/src/components/carousel/index.ts +0 -3
- package/src/components/carousel/parts.ts +0 -71
- package/src/components/carousel/primitives.ts +0 -58
- package/src/components/checkbox/checkbox-icon.tsx +0 -39
- package/src/components/checkbox/checkbox.tsx +0 -42
- package/src/components/checkbox/index.ts +0 -3
- package/src/components/checkbox/parts.ts +0 -59
- package/src/components/checkbox/primitives.tsx +0 -77
- package/src/components/circular-progress/circular-progress.tsx +0 -49
- package/src/components/circular-progress/index.ts +0 -2
- package/src/components/circular-progress/primitives.ts +0 -80
- package/src/components/clipboard/copy-indicator.tsx +0 -22
- package/src/components/clipboard/copy-text.tsx +0 -13
- package/src/components/clipboard/index.ts +0 -2
- package/src/components/clipboard/parts.ts +0 -74
- package/src/components/clipboard/primitives.ts +0 -56
- package/src/components/clipboard/trigger.tsx +0 -14
- package/src/components/collapsible/index.ts +0 -2
- package/src/components/collapsible/parts.ts +0 -53
- package/src/components/collapsible/primitives.tsx +0 -53
- package/src/components/combobox/combobox.tsx +0 -67
- package/src/components/combobox/index.ts +0 -6
- package/src/components/combobox/item-group.tsx +0 -19
- package/src/components/combobox/item.tsx +0 -30
- package/src/components/combobox/parts.ts +0 -101
- package/src/components/combobox/primitives.tsx +0 -146
- package/src/components/combobox/use-stateful-collection.ts +0 -65
- package/src/components/cta-dialog/context.tsx +0 -38
- package/src/components/cta-dialog/index.ts +0 -2
- package/src/components/cta-dialog/provider.tsx +0 -186
- package/src/components/cta-dialog/trigger-item.tsx +0 -54
- package/src/components/cta-dialog/utils.ts +0 -57
- package/src/components/date-picker/calendar.tsx +0 -47
- package/src/components/date-picker/content.tsx +0 -21
- package/src/components/date-picker/date-picker.tsx +0 -20
- package/src/components/date-picker/day-view.tsx +0 -82
- package/src/components/date-picker/index.ts +0 -16
- package/src/components/date-picker/input.tsx +0 -26
- package/src/components/date-picker/month-view.tsx +0 -49
- package/src/components/date-picker/parts.ts +0 -167
- package/src/components/date-picker/primitives.tsx +0 -235
- package/src/components/date-picker/range-input.tsx +0 -38
- package/src/components/date-picker/trigger.tsx +0 -28
- package/src/components/date-picker/view-control-group.tsx +0 -54
- package/src/components/date-picker/year-view.tsx +0 -47
- package/src/components/dialog/close-icon-trigger.tsx +0 -36
- package/src/components/dialog/dialog.tsx +0 -42
- package/src/components/dialog/index.ts +0 -8
- package/src/components/dialog/parts.ts +0 -71
- package/src/components/dialog/primitives.tsx +0 -83
- package/src/components/feature-flag/feature-flag.tsx +0 -21
- package/src/components/feature-flag/index.ts +0 -1
- package/src/components/field/error-text.tsx +0 -19
- package/src/components/field/field.tsx +0 -93
- package/src/components/field/helper-text.tsx +0 -20
- package/src/components/field/index.ts +0 -7
- package/src/components/field/input.tsx +0 -47
- package/src/components/field/parts.ts +0 -77
- package/src/components/field/primitives.tsx +0 -135
- package/src/components/field/start-indicator.tsx +0 -23
- package/src/components/field/status-indicator.tsx +0 -58
- package/src/components/fieldset/fieldset.tsx +0 -54
- package/src/components/fieldset/index.ts +0 -3
- package/src/components/fieldset/parts.ts +0 -47
- package/src/components/fieldset/primitives.tsx +0 -48
- package/src/components/file-upload/file-status.tsx +0 -271
- package/src/components/file-upload/file-uploader.tsx +0 -60
- package/src/components/file-upload/helpers.ts +0 -28
- package/src/components/file-upload/img-preview.tsx +0 -41
- package/src/components/file-upload/index.ts +0 -6
- package/src/components/file-upload/parts.tsx +0 -132
- package/src/components/file-upload/primitives.ts +0 -161
- package/src/components/file-upload/utils.ts +0 -20
- package/src/components/for/for.tsx +0 -38
- package/src/components/for/index.ts +0 -1
- package/src/components/group/index.ts +0 -1
- package/src/components/group/primitives.ts +0 -7
- package/src/components/icon-button/button.tsx +0 -41
- package/src/components/icon-button/index.tsx +0 -2
- package/src/components/icon-button/primitives.ts +0 -19
- package/src/components/menu/index.ts +0 -2
- package/src/components/menu/menu.tsx +0 -144
- package/src/components/menu/primitives.ts +0 -84
- package/src/components/notifications/center.tsx +0 -88
- package/src/components/notifications/close-trigger.tsx +0 -21
- package/src/components/notifications/index.ts +0 -5
- package/src/components/notifications/match-icon.tsx +0 -41
- package/src/components/notifications/parts.ts +0 -53
- package/src/components/notifications/primitives.tsx +0 -66
- package/src/components/notifications/toaster.ts +0 -13
- package/src/components/notifications/types.ts +0 -44
- package/src/components/number-input/decrement-trigger.tsx +0 -16
- package/src/components/number-input/increment-trigger.tsx +0 -16
- package/src/components/number-input/index.ts +0 -3
- package/src/components/number-input/input.tsx +0 -33
- package/src/components/number-input/parts.ts +0 -65
- package/src/components/number-input/primitives.tsx +0 -74
- package/src/components/pagination/compact.tsx +0 -25
- package/src/components/pagination/index.ts +0 -6
- package/src/components/pagination/item-list.tsx +0 -34
- package/src/components/pagination/item.tsx +0 -6
- package/src/components/pagination/pagination.tsx +0 -53
- package/src/components/pagination/parts.ts +0 -65
- package/src/components/pagination/primitives.ts +0 -41
- package/src/components/pagination/triggers.tsx +0 -55
- package/src/components/pin-input/index.ts +0 -3
- package/src/components/pin-input/input.tsx +0 -22
- package/src/components/pin-input/parts.ts +0 -53
- package/src/components/pin-input/primitives.tsx +0 -46
- package/src/components/portal/index.ts +0 -1
- package/src/components/portal/portal.tsx +0 -28
- package/src/components/progress/index.ts +0 -2
- package/src/components/progress/primitives.ts +0 -37
- package/src/components/progress/progress-bar.tsx +0 -80
- package/src/components/radio/index.ts +0 -3
- package/src/components/radio/parts.ts +0 -65
- package/src/components/radio/primitives.tsx +0 -92
- package/src/components/radio/radio.tsx +0 -35
- package/src/components/rating/index.ts +0 -8
- package/src/components/rating/parts.tsx +0 -65
- package/src/components/rating/primitives.tsx +0 -64
- package/src/components/rating/rating.tsx +0 -75
- package/src/components/select/index.ts +0 -5
- package/src/components/select/option-group.tsx +0 -32
- package/src/components/select/option.tsx +0 -42
- package/src/components/select/parts.ts +0 -113
- package/src/components/select/primitives.tsx +0 -147
- package/src/components/select/select.tsx +0 -110
- package/src/components/show/index.ts +0 -1
- package/src/components/show/show.tsx +0 -48
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.tsx +0 -81
- package/src/components/split-button/button.tsx +0 -63
- package/src/components/split-button/index.tsx +0 -1
- package/src/components/switch/index.ts +0 -3
- package/src/components/switch/parts.ts +0 -53
- package/src/components/switch/primitives.tsx +0 -51
- package/src/components/switch/switch-indicator.tsx +0 -9
- package/src/components/switch/switch.tsx +0 -27
- package/src/components/table/index.ts +0 -3
- package/src/components/table/parts.ts +0 -83
- package/src/components/table/primitives.tsx +0 -115
- package/src/components/table/table.tsx +0 -73
- package/src/components/tabs/index.ts +0 -3
- package/src/components/tabs/parts.ts +0 -53
- package/src/components/tabs/primitives.tsx +0 -47
- package/src/components/tabs/tabs.tsx +0 -48
- package/src/components/tag/closable.tsx +0 -47
- package/src/components/tag/index.ts +0 -2
- package/src/components/tag/primitives.ts +0 -19
- package/src/components/tag/tag.tsx +0 -39
- package/src/components/text/index.ts +0 -1
- package/src/components/text/text.tsx +0 -55
- package/src/components/theme/index.ts +0 -1
- package/src/components/theme/theme.tsx +0 -34
- package/src/components/toggle/index.ts +0 -2
- package/src/components/toggle/parts.ts +0 -32
- package/src/components/toggle/primitives.tsx +0 -27
- package/src/components/tooltip/index.ts +0 -3
- package/src/components/tooltip/parts.ts +0 -59
- package/src/components/tooltip/primitives.ts +0 -56
- package/src/components/tooltip/tooltip.tsx +0 -46
- package/src/config/defineIcons.ts +0 -24
- package/src/config/icons/checkbox.icons.tsx +0 -98
- package/src/config/icons/default.ts +0 -69
- package/src/config/icons/pinned.icons.tsx +0 -31
- package/src/config/icons/sort.icons.tsx +0 -19
- package/src/config/index.ts +0 -41
- package/src/config/types.ts +0 -53
- package/src/context/cerberus.tsx +0 -53
- package/src/context/confirm-modal.tsx +0 -276
- package/src/context/feature-flags.tsx +0 -63
- package/src/context/field.tsx +0 -70
- package/src/context/navMenu.tsx +0 -89
- package/src/context/prompt-modal.tsx +0 -315
- package/src/context/theme.tsx +0 -83
- package/src/hooks/useModal.ts +0 -63
- package/src/hooks/useRootColors.ts +0 -72
- package/src/hooks/useTheme.ts +0 -121
- package/src/index.client.ts +0 -30
- package/src/index.ts +0 -76
- package/src/system/factory.ts +0 -32
- package/src/system/index.ts +0 -47
- package/src/system/primitive-factory.tsx +0 -180
- package/src/system/types.ts +0 -88
- package/src/types.ts +0 -23
- package/src/utils/index.ts +0 -51
- package/src/utils/localStorage.ts +0 -28
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState,
|
|
8
|
-
type MouseEvent,
|
|
9
|
-
type PropsWithChildren,
|
|
10
|
-
type ReactNode,
|
|
11
|
-
} from 'react'
|
|
12
|
-
import { HStack, VStack } from 'styled-system/jsx'
|
|
13
|
-
import { useCerberusContext } from '../../context/cerberus'
|
|
14
|
-
import { Show } from '../show/index'
|
|
15
|
-
import { For } from '../for/index'
|
|
16
|
-
import { Avatar } from '../avatar/avatar'
|
|
17
|
-
import {
|
|
18
|
-
Dialog,
|
|
19
|
-
DialogDescription,
|
|
20
|
-
DialogHeading,
|
|
21
|
-
DialogProvider,
|
|
22
|
-
DialogRootProps,
|
|
23
|
-
} from '../dialog/index'
|
|
24
|
-
import { DialogCloseIconTrigger } from '../dialog/close-icon-trigger'
|
|
25
|
-
import type { CTAButtonAction, CTAModalActionReturn } from './utils'
|
|
26
|
-
import {
|
|
27
|
-
CTAModalContext,
|
|
28
|
-
type CTAModalValue,
|
|
29
|
-
type ShowCTAModalOptions,
|
|
30
|
-
} from './context'
|
|
31
|
-
import { TriggerItem } from './trigger-item'
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* This module provides the provider and hook for the cta modal.
|
|
35
|
-
* @module 'react/cta-modal/provider'
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Provides a CTA modal to the app.
|
|
40
|
-
* @see https://cerberus.digitalu.design/react/cta-modal
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* // Wrap the Provider around the root of the feature.
|
|
44
|
-
* <CTAModal>
|
|
45
|
-
* <SomeFeatureSection />
|
|
46
|
-
* </CTAModal>
|
|
47
|
-
*
|
|
48
|
-
* // Use the hook to show the cta modal.
|
|
49
|
-
* const cta = useCTAModal()
|
|
50
|
-
*
|
|
51
|
-
* const handleClick = useCallback(async () => {
|
|
52
|
-
* const userConsent = await cta.show({
|
|
53
|
-
* heading: 'Create or copy a Cohort',
|
|
54
|
-
* description:
|
|
55
|
-
* 'Create a new cohort or copy and existing one.',
|
|
56
|
-
* icon: <Copy size={24} />,
|
|
57
|
-
* actions: [
|
|
58
|
-
* {
|
|
59
|
-
* text: 'Create Cohort',
|
|
60
|
-
* onClick: () => {},
|
|
61
|
-
* {
|
|
62
|
-
* text: 'Copy Cohort',
|
|
63
|
-
* onClick: () => {}
|
|
64
|
-
* }
|
|
65
|
-
* })
|
|
66
|
-
* setConsent(userConsent)
|
|
67
|
-
* }, [cta])
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export function CTAModal(props: PropsWithChildren<DialogRootProps>) {
|
|
71
|
-
const { children, ...rootProps } = props
|
|
72
|
-
|
|
73
|
-
const [open, setOpen] = useState<boolean>(false)
|
|
74
|
-
const [content, setContent] = useState<ShowCTAModalOptions | null>(null)
|
|
75
|
-
|
|
76
|
-
const confirmIcon = content?.icon
|
|
77
|
-
|
|
78
|
-
const { icons } = useCerberusContext()
|
|
79
|
-
const { confirmModal: FallbackIcon } = icons
|
|
80
|
-
|
|
81
|
-
const handleShow = useCallback(
|
|
82
|
-
(options: ShowCTAModalOptions) => {
|
|
83
|
-
setContent({ ...options })
|
|
84
|
-
setOpen(true)
|
|
85
|
-
},
|
|
86
|
-
[setOpen],
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
const handleActionClick = useCallback(
|
|
90
|
-
(event: MouseEvent<HTMLButtonElement>) => {
|
|
91
|
-
const index = Number(event.currentTarget.getAttribute('data-index'))
|
|
92
|
-
const contentActions = content?.actions as CTAModalActionReturn
|
|
93
|
-
const action = contentActions._actions[index] as CTAButtonAction
|
|
94
|
-
action?.handleClick?.(event)
|
|
95
|
-
setOpen(false)
|
|
96
|
-
},
|
|
97
|
-
[content, setOpen],
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
const value = useMemo(
|
|
101
|
-
() => ({
|
|
102
|
-
show: handleShow,
|
|
103
|
-
}),
|
|
104
|
-
[handleShow],
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<CTAModalContext.Provider value={value}>
|
|
109
|
-
{children}
|
|
110
|
-
|
|
111
|
-
<DialogProvider
|
|
112
|
-
lazyMount
|
|
113
|
-
open={open}
|
|
114
|
-
onOpenChange={(e) => setOpen(e.open)}
|
|
115
|
-
unmountOnExit
|
|
116
|
-
{...rootProps}
|
|
117
|
-
>
|
|
118
|
-
<Dialog
|
|
119
|
-
size="sm"
|
|
120
|
-
style={{
|
|
121
|
-
'--dialog-content-min-h': 'auto',
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
<DialogCloseIconTrigger />
|
|
125
|
-
|
|
126
|
-
<VStack gap="xl" w="full">
|
|
127
|
-
<VStack alignItems="flex-start" gap="md" w="full">
|
|
128
|
-
<VStack gap="lg" w="full">
|
|
129
|
-
<Avatar
|
|
130
|
-
gradient="charon-light"
|
|
131
|
-
fallback={
|
|
132
|
-
<Show
|
|
133
|
-
when={confirmIcon}
|
|
134
|
-
fallback={<FallbackIcon size={24} />}
|
|
135
|
-
>
|
|
136
|
-
{confirmIcon}
|
|
137
|
-
</Show>
|
|
138
|
-
}
|
|
139
|
-
/>
|
|
140
|
-
<DialogHeading>{content?.heading}</DialogHeading>
|
|
141
|
-
|
|
142
|
-
<Show when={content?.description}>
|
|
143
|
-
<DialogDescription textAlign="center">
|
|
144
|
-
{content?.description}
|
|
145
|
-
</DialogDescription>
|
|
146
|
-
</Show>
|
|
147
|
-
|
|
148
|
-
<Show when={content?.content}>
|
|
149
|
-
<DialogDescription textAlign="center">
|
|
150
|
-
{content?.content}
|
|
151
|
-
</DialogDescription>
|
|
152
|
-
</Show>
|
|
153
|
-
</VStack>
|
|
154
|
-
</VStack>
|
|
155
|
-
|
|
156
|
-
<HStack gap="md" w="full">
|
|
157
|
-
<For each={content?.actions._actions}>
|
|
158
|
-
{(action, index) => (
|
|
159
|
-
<Show
|
|
160
|
-
key={index}
|
|
161
|
-
when={content?.actions?.type === 'btnAction'}
|
|
162
|
-
fallback={
|
|
163
|
-
<TriggerItem asChild>{action as ReactNode}</TriggerItem>
|
|
164
|
-
}
|
|
165
|
-
>
|
|
166
|
-
<TriggerItem data-index={index} onClick={handleActionClick}>
|
|
167
|
-
{(action as CTAButtonAction)?.text}
|
|
168
|
-
</TriggerItem>
|
|
169
|
-
</Show>
|
|
170
|
-
)}
|
|
171
|
-
</For>
|
|
172
|
-
</HStack>
|
|
173
|
-
</VStack>
|
|
174
|
-
</Dialog>
|
|
175
|
-
</DialogProvider>
|
|
176
|
-
</CTAModalContext.Provider>
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export function useCTAModal(): CTAModalValue {
|
|
181
|
-
const context = useContext(CTAModalContext)
|
|
182
|
-
if (context === null) {
|
|
183
|
-
throw new Error('useCTAModal must be used within a CTAModal Provider')
|
|
184
|
-
}
|
|
185
|
-
return context
|
|
186
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ark } from '@ark-ui/react/factory'
|
|
2
|
-
import { css, cx } from 'styled-system/css'
|
|
3
|
-
import { button } from 'styled-system/recipes'
|
|
4
|
-
import { CerberusProps } from '../../system/types'
|
|
5
|
-
import { Button, type ButtonProps } from '../button/button'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This module provides the trigger item for the cta modal.
|
|
9
|
-
* @module 'react/cta-modal/trigger-item'
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export interface TriggerItemProps extends ButtonProps {
|
|
13
|
-
asChild?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Trigger item for the cta modal which renders content based on the actions.
|
|
18
|
-
* type.
|
|
19
|
-
*/
|
|
20
|
-
export function TriggerItem(props: CerberusProps<'button'> & TriggerItemProps) {
|
|
21
|
-
const { asChild, children, ...buttonProps } = props
|
|
22
|
-
|
|
23
|
-
if (asChild) {
|
|
24
|
-
return (
|
|
25
|
-
<ark.div
|
|
26
|
-
className={cx(
|
|
27
|
-
button({
|
|
28
|
-
shape: 'rounded',
|
|
29
|
-
usage: 'ghost',
|
|
30
|
-
}),
|
|
31
|
-
css({
|
|
32
|
-
w: '1/2',
|
|
33
|
-
}),
|
|
34
|
-
)}
|
|
35
|
-
asChild
|
|
36
|
-
>
|
|
37
|
-
{children}
|
|
38
|
-
</ark.div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Button
|
|
44
|
-
{...buttonProps}
|
|
45
|
-
className={css({
|
|
46
|
-
w: '1/2',
|
|
47
|
-
})}
|
|
48
|
-
shape="rounded"
|
|
49
|
-
usage="outlined"
|
|
50
|
-
>
|
|
51
|
-
{children}
|
|
52
|
-
</Button>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { MouseEventHandler, ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This module provide utility functions for the cta modal.
|
|
5
|
-
* @module 'react/cta-modal/utils'
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export type CTAButtonAction = {
|
|
9
|
-
/**
|
|
10
|
-
* The text of the button.
|
|
11
|
-
*/
|
|
12
|
-
text: string
|
|
13
|
-
/**
|
|
14
|
-
* The onClick handler for the button.
|
|
15
|
-
*/
|
|
16
|
-
handleClick: MouseEventHandler<HTMLButtonElement>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type CTAModalAction = (CTAButtonAction | ReactNode)[]
|
|
20
|
-
|
|
21
|
-
export interface CTAModalActionReturn {
|
|
22
|
-
/**
|
|
23
|
-
* The type of the action content.
|
|
24
|
-
*/
|
|
25
|
-
type: 'reactNode' | 'btnAction'
|
|
26
|
-
/**
|
|
27
|
-
* The actions for the cta modal. Max of 2 actions.
|
|
28
|
-
*/
|
|
29
|
-
_actions: CTAModalAction
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Creates the action data to pass to the cta modal `show` method.
|
|
34
|
-
*/
|
|
35
|
-
export function createCTAModalActions(
|
|
36
|
-
providedActions: CTAModalAction,
|
|
37
|
-
): CTAModalActionReturn {
|
|
38
|
-
if (providedActions.length !== 2) {
|
|
39
|
-
throw new Error('CTAModal must include 2 actions')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
providedActions.every(
|
|
44
|
-
(action) => (action as unknown as CTAButtonAction)?.handleClick,
|
|
45
|
-
)
|
|
46
|
-
) {
|
|
47
|
-
return {
|
|
48
|
-
type: 'btnAction',
|
|
49
|
-
_actions: providedActions as CTAButtonAction[],
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
type: 'reactNode',
|
|
55
|
-
_actions: providedActions as ReactNode[],
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { splitProps } from '../../utils/index'
|
|
2
|
-
import { DatePickerContent } from './content'
|
|
3
|
-
import { DatePickerDayView } from './day-view'
|
|
4
|
-
import { DatePickerMonthView } from './month-view'
|
|
5
|
-
import { DatePickerYearView } from './year-view'
|
|
6
|
-
import { DatePickerContentProps } from './primitives'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This module contains an abstraction of the DatePicker component.
|
|
10
|
-
* @module 'date-picker/calendar'
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface DatePickerCalendarProps {
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated - this is no longer needed.
|
|
16
|
-
*/
|
|
17
|
-
withModal?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* An abstraction of the DatePicker content components that contain the
|
|
22
|
-
* different calendar views and controls.
|
|
23
|
-
* @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <Field>
|
|
27
|
-
* <DatePicker name="start_date">
|
|
28
|
-
* <DatePickerLabel>Start date</DatePickerLabel>
|
|
29
|
-
* <DatePickerInput />
|
|
30
|
-
* <DatePickerCalendar />
|
|
31
|
-
* </DatePicker>
|
|
32
|
-
* </Field>
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function DatePickerCalendar(
|
|
36
|
-
props: DatePickerCalendarProps & DatePickerContentProps,
|
|
37
|
-
) {
|
|
38
|
-
const [, contentProps] = splitProps(props, ['withModal'])
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<DatePickerContent {...contentProps}>
|
|
42
|
-
<DatePickerDayView />
|
|
43
|
-
<DatePickerMonthView view="month" />
|
|
44
|
-
<DatePickerYearView view="year" />
|
|
45
|
-
</DatePickerContent>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DatePickerParts } from './parts'
|
|
2
|
-
import type { DatePickerContentProps } from './primitives'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This private module contains an abstraction of the DatePickerContent
|
|
6
|
-
* primitive.
|
|
7
|
-
* @module 'date-picker/content'
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* An abstraction of the DatePicker content that wraps the DatePickerParts
|
|
12
|
-
* primitives.
|
|
13
|
-
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
14
|
-
*/
|
|
15
|
-
export function DatePickerContent(props: DatePickerContentProps) {
|
|
16
|
-
return (
|
|
17
|
-
<DatePickerParts.Positioner>
|
|
18
|
-
<DatePickerParts.Content {...props} />
|
|
19
|
-
</DatePickerParts.Positioner>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { DatePickerParts } from './parts'
|
|
4
|
-
import type { DatePickerRootProps } from './primitives'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* DatePicker component is an abstraction of the DatePickerRoot primitive which
|
|
8
|
-
* is the context provider to the DatePicker.
|
|
9
|
-
* @description [Cerberus Docs](https://cerberus.digitalu.design/docs/components/date-picker)
|
|
10
|
-
*/
|
|
11
|
-
export function DatePicker(props: DatePickerRootProps) {
|
|
12
|
-
return (
|
|
13
|
-
<DatePickerParts.Root
|
|
14
|
-
positioning={{
|
|
15
|
-
placement: 'bottom-start',
|
|
16
|
-
}}
|
|
17
|
-
{...props}
|
|
18
|
-
/>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
DatePicker,
|
|
5
|
-
UseDatePickerContext,
|
|
6
|
-
} from '@ark-ui/react/date-picker'
|
|
7
|
-
import { DatePickerParts } from './parts'
|
|
8
|
-
import type { DatePickerViewProps } from './primitives'
|
|
9
|
-
import { DatePickerViewControlGroup } from './view-control-group'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This private module contains an abstraction of the DayView component.
|
|
13
|
-
* @module 'date-picker/day-view'
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export type DateValue = DatePicker.DateValue
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* An abstraction of the DatePickerDayView that renders the day view of the
|
|
20
|
-
* DatePicker.
|
|
21
|
-
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
22
|
-
*/
|
|
23
|
-
export function DatePickerDayView(props: Omit<DatePickerViewProps, 'view'>) {
|
|
24
|
-
function isToday(date: DateValue): boolean {
|
|
25
|
-
const today = new Date()
|
|
26
|
-
const formatted = today.toISOString().split('T')[0]
|
|
27
|
-
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
28
|
-
return formatted === arkDate
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function isPastDay(date: DateValue): boolean {
|
|
32
|
-
const today = new Date()
|
|
33
|
-
const arkDate = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
|
|
34
|
-
return new Date(arkDate) < today
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getDayValue(date: DateValue): 'today' | 'past' | 'future' {
|
|
38
|
-
if (isToday(date)) return 'today'
|
|
39
|
-
if (isPastDay(date)) return 'past'
|
|
40
|
-
return 'future'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<DatePickerParts.View {...props} view="day">
|
|
45
|
-
<DatePickerParts.Context>
|
|
46
|
-
{(datePickerData: UseDatePickerContext) => (
|
|
47
|
-
<>
|
|
48
|
-
<DatePickerViewControlGroup />
|
|
49
|
-
|
|
50
|
-
<DatePickerParts.Table>
|
|
51
|
-
<DatePickerParts.TableHead>
|
|
52
|
-
<DatePickerParts.TableRow>
|
|
53
|
-
{datePickerData.weekDays.map((weekDay, id) => (
|
|
54
|
-
<DatePickerParts.TableHeader key={id}>
|
|
55
|
-
{weekDay.narrow}
|
|
56
|
-
</DatePickerParts.TableHeader>
|
|
57
|
-
))}
|
|
58
|
-
</DatePickerParts.TableRow>
|
|
59
|
-
</DatePickerParts.TableHead>
|
|
60
|
-
|
|
61
|
-
<DatePickerParts.TableBody>
|
|
62
|
-
{datePickerData.weeks.map((week, id) => (
|
|
63
|
-
<DatePickerParts.TableRow key={id}>
|
|
64
|
-
{week.map((day, id) => (
|
|
65
|
-
<DatePickerParts.TableCell key={id} value={day}>
|
|
66
|
-
<DatePickerParts.TableCellTrigger
|
|
67
|
-
data-date={getDayValue(day)}
|
|
68
|
-
>
|
|
69
|
-
{day.day}
|
|
70
|
-
</DatePickerParts.TableCellTrigger>
|
|
71
|
-
</DatePickerParts.TableCell>
|
|
72
|
-
))}
|
|
73
|
-
</DatePickerParts.TableRow>
|
|
74
|
-
))}
|
|
75
|
-
</DatePickerParts.TableBody>
|
|
76
|
-
</DatePickerParts.Table>
|
|
77
|
-
</>
|
|
78
|
-
)}
|
|
79
|
-
</DatePickerParts.Context>
|
|
80
|
-
</DatePickerParts.View>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './parts'
|
|
2
|
-
export * from './primitives'
|
|
3
|
-
export * from './date-picker'
|
|
4
|
-
export * from './input'
|
|
5
|
-
export * from './range-input'
|
|
6
|
-
export * from './calendar'
|
|
7
|
-
|
|
8
|
-
// external dependencies
|
|
9
|
-
|
|
10
|
-
export { parseDate, type DateValue } from '@ark-ui/react/date-picker'
|
|
11
|
-
export {
|
|
12
|
-
CalendarDate,
|
|
13
|
-
today,
|
|
14
|
-
getLocalTimeZone,
|
|
15
|
-
DateFormatter,
|
|
16
|
-
} from '@internationalized/date'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DatePickerTrigger } from './trigger'
|
|
2
|
-
import { DatePickerParts } from './parts'
|
|
3
|
-
import type { DatePickerInputElProps } from './primitives'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This module contains an abstraction of the DatePickerInputEl primitive.
|
|
7
|
-
* @module 'date-picker/input'
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* An abstraction of the DatePicker input that wraps the input and the
|
|
12
|
-
* triggers to open the DatePicker and clear the value.
|
|
13
|
-
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
14
|
-
*/
|
|
15
|
-
export function DatePickerInput(props: DatePickerInputElProps) {
|
|
16
|
-
return (
|
|
17
|
-
<DatePickerParts.Control>
|
|
18
|
-
<DatePickerTrigger />
|
|
19
|
-
<DatePickerParts.Input
|
|
20
|
-
{...props}
|
|
21
|
-
maxLength={11}
|
|
22
|
-
placeholder={props.placeholder ?? 'MM/DD/YYYY'}
|
|
23
|
-
/>
|
|
24
|
-
</DatePickerParts.Control>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import type { UseDatePickerContext } from '@ark-ui/react/date-picker'
|
|
4
|
-
import { DatePickerParts } from './parts'
|
|
5
|
-
import { DatePickerViewControlGroup } from './view-control-group'
|
|
6
|
-
import type { DatePickerViewProps } from './primitives'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This private module contains an abstraction of the DatePickerMonthView
|
|
10
|
-
* component.
|
|
11
|
-
* @module 'date-picker/month-view'
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An abstraction of the DatePickerMonthView that renders the month view of the
|
|
16
|
-
* DatePicker.
|
|
17
|
-
* @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)
|
|
18
|
-
*/
|
|
19
|
-
export function DatePickerMonthView(props: DatePickerViewProps) {
|
|
20
|
-
return (
|
|
21
|
-
<DatePickerParts.View {...props} view="month">
|
|
22
|
-
<DatePickerParts.Context>
|
|
23
|
-
{(datePicker: UseDatePickerContext) => (
|
|
24
|
-
<>
|
|
25
|
-
<DatePickerViewControlGroup />
|
|
26
|
-
|
|
27
|
-
<DatePickerParts.Table>
|
|
28
|
-
<DatePickerParts.TableBody>
|
|
29
|
-
{datePicker
|
|
30
|
-
.getMonthsGrid({ columns: 4, format: 'short' })
|
|
31
|
-
.map((months, id) => (
|
|
32
|
-
<DatePickerParts.TableRow key={id}>
|
|
33
|
-
{months.map((month, id) => (
|
|
34
|
-
<DatePickerParts.TableCell key={id} value={month.value}>
|
|
35
|
-
<DatePickerParts.TableCellTrigger>
|
|
36
|
-
{month.label}
|
|
37
|
-
</DatePickerParts.TableCellTrigger>
|
|
38
|
-
</DatePickerParts.TableCell>
|
|
39
|
-
))}
|
|
40
|
-
</DatePickerParts.TableRow>
|
|
41
|
-
))}
|
|
42
|
-
</DatePickerParts.TableBody>
|
|
43
|
-
</DatePickerParts.Table>
|
|
44
|
-
</>
|
|
45
|
-
)}
|
|
46
|
-
</DatePickerParts.Context>
|
|
47
|
-
</DatePickerParts.View>
|
|
48
|
-
)
|
|
49
|
-
}
|