@cerberus-design/react 0.14.2 → 0.15.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 +374 -80
- package/build/legacy/components/Accordion.cjs +4 -187
- package/build/legacy/components/Accordion.cjs.map +1 -1
- package/build/legacy/components/Accordion.client.cjs +64 -0
- package/build/legacy/components/Accordion.client.cjs.map +1 -0
- package/build/legacy/components/AccordionItemGroup.cjs +41 -185
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
- package/build/legacy/components/Admonition.cjs +89 -239
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Admonition.client.cjs +219 -0
- package/build/legacy/components/Admonition.client.cjs.map +1 -0
- package/build/legacy/components/AnimatingUploadIcon.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +23 -174
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +22 -168
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +129 -272
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/components/DatePicker.server.cjs +17 -271
- package/build/legacy/components/DatePicker.server.cjs.map +1 -1
- package/build/legacy/components/Dialog.cjs +86 -0
- package/build/legacy/components/Dialog.cjs.map +1 -0
- package/build/legacy/components/Dialog.client.cjs +95 -0
- package/build/legacy/components/Dialog.client.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +62 -212
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +29 -180
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +20 -172
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Modal.cjs.map +1 -1
- package/build/legacy/components/ModalDescription.cjs.map +1 -1
- package/build/legacy/components/ModalHeader.cjs.map +1 -1
- package/build/legacy/components/ModalHeading.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +26 -176
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +26 -178
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tag.cjs +16 -167
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +20 -172
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +3 -39
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/config/{cerbIcons.cjs → index.cjs} +22 -29
- package/build/legacy/config/index.cjs.map +1 -0
- package/build/legacy/config/types.cjs +19 -0
- package/build/legacy/config/types.cjs.map +1 -0
- package/build/legacy/context/cerberus.cjs +46 -0
- package/build/legacy/context/cerberus.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +105 -321
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +137 -336
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center/store.cjs +66 -0
- package/build/legacy/context/notification-center/store.cjs.map +1 -0
- package/build/legacy/context/notification-center/types.cjs +19 -0
- package/build/legacy/context/notification-center/types.cjs.map +1 -0
- package/build/legacy/context/notification-center.cjs +142 -249
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +185 -388
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +1577 -1456
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +374 -80
- package/build/modern/{chunk-BVCXVZAF.js → chunk-25HMVHLT.js} +6 -5
- package/build/modern/chunk-25HMVHLT.js.map +1 -0
- package/build/modern/chunk-36N4527B.js +1 -0
- package/build/modern/chunk-5EWCH7AI.js +82 -0
- package/build/modern/chunk-5EWCH7AI.js.map +1 -0
- package/build/modern/chunk-5SNLQZYP.js +25 -0
- package/build/modern/chunk-5SNLQZYP.js.map +1 -0
- package/build/modern/chunk-6BN3XKQF.js +42 -0
- package/build/modern/chunk-6BN3XKQF.js.map +1 -0
- package/build/modern/{chunk-2UXE5PDG.js → chunk-7NN3SJ7W.js} +1 -1
- package/build/modern/chunk-7NN3SJ7W.js.map +1 -0
- package/build/modern/{chunk-KWJ5FKX7.js → chunk-BAWZBF5Q.js} +5 -3
- package/build/modern/chunk-BAWZBF5Q.js.map +1 -0
- package/build/modern/{chunk-6BH5J5GF.js → chunk-BHB56M7S.js} +31 -46
- package/build/modern/chunk-BHB56M7S.js.map +1 -0
- package/build/modern/{chunk-HKJMLWVP.js → chunk-EDARV2EI.js} +5 -4
- package/build/modern/chunk-EDARV2EI.js.map +1 -0
- package/build/modern/{chunk-5OVH3INN.js → chunk-FGCO27TC.js} +25 -53
- package/build/modern/chunk-FGCO27TC.js.map +1 -0
- package/build/modern/{chunk-PVIMOXSO.js → chunk-GCQMH4QA.js} +5 -4
- package/build/modern/chunk-GCQMH4QA.js.map +1 -0
- package/build/modern/chunk-GITT5645.js +20 -0
- package/build/modern/chunk-GITT5645.js.map +1 -0
- package/build/modern/{chunk-TJCFYL5W.js → chunk-IGHMP4WA.js} +1 -20
- package/build/modern/chunk-IGHMP4WA.js.map +1 -0
- package/build/modern/chunk-ISCJ542I.js +82 -0
- package/build/modern/chunk-ISCJ542I.js.map +1 -0
- package/build/modern/{chunk-HVKM54BA.js → chunk-IW3LIRDG.js} +1 -1
- package/build/modern/chunk-IW3LIRDG.js.map +1 -0
- package/build/modern/chunk-JAROS4Q3.js +180 -0
- package/build/modern/chunk-JAROS4Q3.js.map +1 -0
- package/build/modern/{chunk-BE4EOU2P.js → chunk-JIRW4XOJ.js} +1 -1
- package/build/modern/chunk-JIRW4XOJ.js.map +1 -0
- package/build/modern/chunk-KDDPAJMR.js +9 -0
- package/build/modern/chunk-KDDPAJMR.js.map +1 -0
- package/build/modern/{chunk-XOROL3JY.js → chunk-KKHL3ZO4.js} +5 -4
- package/build/modern/chunk-KKHL3ZO4.js.map +1 -0
- package/build/modern/{chunk-U36UZJGZ.js → chunk-MZ3UCDUL.js} +5 -4
- package/build/modern/chunk-MZ3UCDUL.js.map +1 -0
- package/build/modern/{chunk-T2JOPPGL.js → chunk-N24COMHJ.js} +11 -4
- package/build/modern/chunk-N24COMHJ.js.map +1 -0
- package/build/modern/chunk-NJSETNRL.js +68 -0
- package/build/modern/chunk-NJSETNRL.js.map +1 -0
- package/build/modern/{chunk-XY6WL55R.js → chunk-NUMM4TNC.js} +1 -1
- package/build/modern/chunk-NUMM4TNC.js.map +1 -0
- package/build/modern/{chunk-FXLLRVAM.js → chunk-O6LFWUHI.js} +8 -6
- package/build/modern/chunk-O6LFWUHI.js.map +1 -0
- package/build/modern/{chunk-JJZQGR7A.js → chunk-RDRD6ACD.js} +9 -6
- package/build/modern/chunk-RDRD6ACD.js.map +1 -0
- package/build/modern/{chunk-XXWR7UGH.js → chunk-SD3OVTHT.js} +75 -103
- package/build/modern/chunk-SD3OVTHT.js.map +1 -0
- package/build/modern/chunk-TFL56AYR.js +56 -0
- package/build/modern/chunk-TFL56AYR.js.map +1 -0
- package/build/modern/chunk-V3M3ZOQI.js +38 -0
- package/build/modern/chunk-V3M3ZOQI.js.map +1 -0
- package/build/modern/{chunk-QK7R2XJM.js → chunk-XQICKZH4.js} +6 -5
- package/build/modern/chunk-XQICKZH4.js.map +1 -0
- package/build/modern/chunk-XZGXRRSQ.js +31 -0
- package/build/modern/chunk-XZGXRRSQ.js.map +1 -0
- package/build/modern/{chunk-KPUYKHLW.js → chunk-YKKNWILF.js} +71 -15
- package/build/modern/chunk-YKKNWILF.js.map +1 -0
- package/build/modern/{chunk-Q7BRMIBR.js → chunk-ZL6ZITLA.js} +1 -1
- package/build/modern/chunk-ZL6ZITLA.js.map +1 -0
- package/build/modern/components/Accordion.client.js +9 -0
- package/build/modern/components/Accordion.client.js.map +1 -0
- package/build/modern/components/Accordion.js +1 -7
- package/build/modern/components/AccordionItemGroup.js +4 -6
- package/build/modern/components/Admonition.client.js +11 -0
- package/build/modern/components/Admonition.client.js.map +1 -0
- package/build/modern/components/Admonition.js +4 -6
- package/build/modern/components/AnimatingUploadIcon.js +1 -1
- package/build/modern/components/Avatar.js +3 -5
- package/build/modern/components/Checkbox.js +2 -5
- package/build/modern/components/DatePicker.client.js +8 -7
- package/build/modern/components/DatePicker.server.js +3 -13
- package/build/modern/components/Dialog.client.js +10 -0
- package/build/modern/components/Dialog.client.js.map +1 -0
- package/build/modern/components/Dialog.js +24 -0
- package/build/modern/components/Dialog.js.map +1 -0
- package/build/modern/components/FileStatus.js +3 -6
- package/build/modern/components/FileUploader.js +3 -6
- package/build/modern/components/Input.js +2 -5
- package/build/modern/components/Modal.js +1 -1
- package/build/modern/components/ModalDescription.js +1 -1
- package/build/modern/components/ModalHeader.js +1 -1
- package/build/modern/components/ModalHeading.js +1 -1
- package/build/modern/components/Notification.js +2 -5
- package/build/modern/components/Select.js +2 -5
- package/build/modern/components/Tag.js +3 -5
- package/build/modern/components/Toggle.js +2 -5
- package/build/modern/config/defineIcons.js +2 -5
- package/build/modern/config/index.js +14 -0
- package/build/modern/config/index.js.map +1 -0
- package/build/modern/config/types.js +2 -0
- package/build/modern/config/types.js.map +1 -0
- package/build/modern/context/cerberus.js +10 -0
- package/build/modern/context/cerberus.js.map +1 -0
- package/build/modern/context/confirm-modal.js +5 -13
- package/build/modern/context/cta-modal.js +7 -14
- package/build/modern/context/notification-center/store.js +15 -0
- package/build/modern/context/notification-center/store.js.map +1 -0
- package/build/modern/context/notification-center/types.js +1 -0
- package/build/modern/context/notification-center/types.js.map +1 -0
- package/build/modern/context/notification-center.js +5 -7
- package/build/modern/context/prompt-modal.js +8 -15
- package/build/modern/index.js +111 -75
- package/build/modern/index.js.map +1 -1
- package/package.json +4 -8
- package/src/components/Accordion.client.tsx +46 -0
- package/src/components/Accordion.tsx +0 -37
- package/src/components/AccordionItemGroup.tsx +1 -1
- package/src/components/Admonition.client.tsx +73 -0
- package/src/components/Admonition.tsx +1 -70
- package/src/components/AnimatingUploadIcon.tsx +3 -3
- package/src/components/Avatar.tsx +5 -2
- package/src/components/Checkbox.tsx +10 -3
- package/src/components/DatePicker.client.tsx +111 -15
- package/src/components/DatePicker.server.tsx +2 -75
- package/src/components/Dialog.client.tsx +39 -0
- package/src/components/Dialog.tsx +165 -0
- package/src/components/FileStatus.tsx +5 -3
- package/src/components/FileUploader.tsx +3 -2
- package/src/components/Input.tsx +4 -2
- package/src/components/Modal.tsx +1 -16
- package/src/components/ModalDescription.tsx +1 -8
- package/src/components/ModalHeader.tsx +1 -10
- package/src/components/ModalHeading.tsx +1 -8
- package/src/components/Notification.tsx +9 -4
- package/src/components/Select.tsx +5 -2
- package/src/components/Tag.tsx +5 -2
- package/src/components/Toggle.tsx +4 -3
- package/src/config/defineIcons.ts +28 -16
- package/src/config/index.ts +28 -0
- package/src/config/types.ts +42 -0
- package/src/context/cerberus.tsx +44 -0
- package/src/context/confirm-modal.tsx +44 -42
- package/src/context/cta-modal.tsx +25 -38
- package/src/context/notification-center/store.ts +88 -0
- package/src/context/notification-center/types.ts +28 -0
- package/src/context/notification-center.tsx +81 -46
- package/src/context/prompt-modal.tsx +101 -103
- package/src/index.ts +15 -8
- package/build/legacy/config/cerbIcons.cjs.map +0 -1
- package/build/modern/chunk-2UXE5PDG.js.map +0 -1
- package/build/modern/chunk-5OVH3INN.js.map +0 -1
- package/build/modern/chunk-6BH5J5GF.js.map +0 -1
- package/build/modern/chunk-BC5SZDYY.js +0 -132
- package/build/modern/chunk-BC5SZDYY.js.map +0 -1
- package/build/modern/chunk-BE4EOU2P.js.map +0 -1
- package/build/modern/chunk-BVCXVZAF.js.map +0 -1
- package/build/modern/chunk-CRII2HNX.js +0 -55
- package/build/modern/chunk-CRII2HNX.js.map +0 -1
- package/build/modern/chunk-CVTON5DQ.js +0 -162
- package/build/modern/chunk-CVTON5DQ.js.map +0 -1
- package/build/modern/chunk-FXLLRVAM.js.map +0 -1
- package/build/modern/chunk-HKJMLWVP.js.map +0 -1
- package/build/modern/chunk-HVKM54BA.js.map +0 -1
- package/build/modern/chunk-JJZQGR7A.js.map +0 -1
- package/build/modern/chunk-KPUYKHLW.js.map +0 -1
- package/build/modern/chunk-KWJ5FKX7.js.map +0 -1
- package/build/modern/chunk-PVIMOXSO.js.map +0 -1
- package/build/modern/chunk-Q7BRMIBR.js.map +0 -1
- package/build/modern/chunk-QK7R2XJM.js.map +0 -1
- package/build/modern/chunk-QMF5ZNDG.js +0 -27
- package/build/modern/chunk-QMF5ZNDG.js.map +0 -1
- package/build/modern/chunk-QQOWWMZ3.js +0 -138
- package/build/modern/chunk-QQOWWMZ3.js.map +0 -1
- package/build/modern/chunk-T2JOPPGL.js.map +0 -1
- package/build/modern/chunk-TJCFYL5W.js.map +0 -1
- package/build/modern/chunk-U36UZJGZ.js.map +0 -1
- package/build/modern/chunk-XOROL3JY.js.map +0 -1
- package/build/modern/chunk-XXWR7UGH.js.map +0 -1
- package/build/modern/chunk-XY6WL55R.js.map +0 -1
- package/build/modern/config/cerbIcons.js +0 -9
- package/src/config/cerbIcons.ts +0 -73
- /package/build/modern/{config/cerbIcons.js.map → chunk-36N4527B.js.map} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dialog as ArkDialog,
|
|
3
|
+
type DialogContentProps as ArkDialogContentProps,
|
|
4
|
+
type DialogRootProps,
|
|
5
|
+
type DialogTitleProps,
|
|
6
|
+
} from '@ark-ui/react'
|
|
7
|
+
import {
|
|
8
|
+
dialog,
|
|
9
|
+
type DialogVariantProps,
|
|
10
|
+
} from '@cerberus/styled-system/recipes'
|
|
11
|
+
import { Portal } from './Portal'
|
|
12
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
13
|
+
|
|
14
|
+
export type DialogProviderProps = DialogRootProps
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The provider that controls the dialog components.
|
|
18
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <DialogProvider>
|
|
22
|
+
* <DialogTrigger asChild>
|
|
23
|
+
* <Button>Open Dialog</Button>
|
|
24
|
+
* </DialogTrigger>
|
|
25
|
+
* <Dialog>
|
|
26
|
+
* <Text>Dialog Content</Text>
|
|
27
|
+
* <DialogCloseTrigger>Close</DialogCloseTrigger>
|
|
28
|
+
* </Dialog>
|
|
29
|
+
* </DialogProvider>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function DialogProvider(props: DialogProviderProps) {
|
|
33
|
+
return <ArkDialog.Root {...props} />
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface DialogProps
|
|
37
|
+
extends Omit<ArkDialogContentProps, 'size'>,
|
|
38
|
+
DialogVariantProps {}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The content of the dialog. Must be used within the `DialogProvider` component.
|
|
42
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <DialogProvider>
|
|
46
|
+
* <DialogTrigger asChild>
|
|
47
|
+
* <Button>Open Dialog</Button>
|
|
48
|
+
* </DialogTrigger>
|
|
49
|
+
* <Dialog>
|
|
50
|
+
* <Text>Dialog Content</Text>
|
|
51
|
+
* </Dialog>
|
|
52
|
+
* </DialogProvider>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function Dialog(props: DialogProps) {
|
|
56
|
+
const { size, ...contentProps } = props
|
|
57
|
+
const styles = dialog({ size })
|
|
58
|
+
return (
|
|
59
|
+
<Portal>
|
|
60
|
+
<DialogBackdrop className={styles.backdrop} />
|
|
61
|
+
<DialogPositioner className={styles.positioner}>
|
|
62
|
+
<DialogContent className={styles.content} {...contentProps} />
|
|
63
|
+
</DialogPositioner>
|
|
64
|
+
</Portal>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The heading of the dialog. Must be used within the `DialogContent` component.
|
|
70
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <DialogProvider>
|
|
74
|
+
* <DialogTrigger asChild>
|
|
75
|
+
* <Button>Open Dialog</Button>
|
|
76
|
+
* </DialogTrigger>
|
|
77
|
+
* <Dialog>
|
|
78
|
+
* <DialogHeading>Dialog Title</DialogHeading>
|
|
79
|
+
* <Text>Dialog Content</Text>
|
|
80
|
+
* </Dialog>
|
|
81
|
+
* </DialogProvider>
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function DialogHeading(props: DialogTitleProps) {
|
|
85
|
+
const styles = dialog()
|
|
86
|
+
return (
|
|
87
|
+
<ArkDialog.Title {...props} className={cx(props.className, styles.title)} />
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The description of the dialog. Must be used within the `DialogContent` component.
|
|
93
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* <DialogProvider>
|
|
97
|
+
* <DialogTrigger asChild>
|
|
98
|
+
* <Button>Open Dialog</Button>
|
|
99
|
+
* </DialogTrigger>
|
|
100
|
+
* <Dialog>
|
|
101
|
+
* <DialogHeading>Dialog Title</DialogHeading>
|
|
102
|
+
* <DialogDescription>Dialog Description</DialogDescription>
|
|
103
|
+
* </Dialog>
|
|
104
|
+
* </DialogProvider>
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export function DialogDescription(props: DialogTitleProps) {
|
|
108
|
+
const styles = dialog()
|
|
109
|
+
return (
|
|
110
|
+
<ArkDialog.Description
|
|
111
|
+
{...props}
|
|
112
|
+
className={cx(props.className, styles.description)}
|
|
113
|
+
/>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The trigger that opens the dialog. Must be used within the `DialogProvider`
|
|
119
|
+
* component.
|
|
120
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* <DialogTrigger asChild>
|
|
124
|
+
* <Button>Open Dialog</Button>
|
|
125
|
+
* </DialogTrigger>
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export const DialogTrigger = ArkDialog.Trigger
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The trigger that closes the dialog. Must be used within the `DialogProvider`
|
|
132
|
+
* component.
|
|
133
|
+
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* <DialogProvider>
|
|
137
|
+
* <DialogTrigger asChild>
|
|
138
|
+
* <Button>Open Dialog</Button>
|
|
139
|
+
* </DialogTrigger>
|
|
140
|
+
* <Dialog>
|
|
141
|
+
* <Text>Dialog Content</Text>
|
|
142
|
+
* <DialogCloseTrigger>Close</DialogCloseTrigger>
|
|
143
|
+
* </Dialog>
|
|
144
|
+
* </DialogProvider>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export const DialogCloseTrigger = ArkDialog.CloseTrigger
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The backdrop of the dialog. Must be used within the `DialogProvider`
|
|
151
|
+
* component.
|
|
152
|
+
*/
|
|
153
|
+
export const DialogBackdrop = ArkDialog.Backdrop
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The positioner of the dialog. Must be used within the `DialogProvider`
|
|
157
|
+
* component.
|
|
158
|
+
*/
|
|
159
|
+
export const DialogPositioner = ArkDialog.Positioner
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The content of the dialog. Must be used within the `DialogProvider`
|
|
163
|
+
* component.
|
|
164
|
+
*/
|
|
165
|
+
export const DialogContent = ArkDialog.Content
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
} from '@cerberus/styled-system/recipes'
|
|
13
13
|
import { css, cx } from '@cerberus/styled-system/css'
|
|
14
14
|
import { hstack, vstack } from '@cerberus/styled-system/patterns'
|
|
15
|
-
import { $cerberusIcons } from '../config/defineIcons'
|
|
16
15
|
import { Field } from '../context/field'
|
|
16
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
17
17
|
import { FieldMessage } from './FieldMessage'
|
|
18
18
|
import { ProgressBar, type ProgressBarProps } from './ProgressBar'
|
|
19
19
|
import { IconButton } from './IconButton'
|
|
@@ -188,12 +188,13 @@ interface FileStatusElProps {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
function MatchFileStatusIcon(props: FileStatusElProps) {
|
|
191
|
+
const { icons } = useCerberusContext()
|
|
191
192
|
const {
|
|
192
193
|
waitingFileUploader: TodoIcon,
|
|
193
194
|
fileUploader: FileUploaderIcon,
|
|
194
195
|
invalidAlt: InvalidIcon,
|
|
195
196
|
successNotification: DoneIcon,
|
|
196
|
-
} =
|
|
197
|
+
} = icons
|
|
197
198
|
|
|
198
199
|
switch (props.status) {
|
|
199
200
|
case processStatus.TODO:
|
|
@@ -225,7 +226,8 @@ function MatchFileStatusText(props: FileStatusElProps) {
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
function MatchStatusAction(props: FileStatusElProps) {
|
|
228
|
-
const {
|
|
229
|
+
const { icons } = useCerberusContext()
|
|
230
|
+
const { close: CloseIcon, redo: RedoIcon, delete: TrashIcon } = icons
|
|
229
231
|
switch (props.status) {
|
|
230
232
|
case processStatus.TODO:
|
|
231
233
|
case processStatus.PROCESSING:
|
|
@@ -5,7 +5,7 @@ import { vstack } from '@cerberus/styled-system/patterns'
|
|
|
5
5
|
import { type InputHTMLAttributes } from 'react'
|
|
6
6
|
import { Show } from './Show'
|
|
7
7
|
import { fileUploader } from '@cerberus/styled-system/recipes'
|
|
8
|
-
import {
|
|
8
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
9
9
|
import { Avatar } from './Avatar'
|
|
10
10
|
|
|
11
11
|
export interface FileUploaderProps
|
|
@@ -29,8 +29,9 @@ export interface FileUploaderProps
|
|
|
29
29
|
* @see https://cerberus.digitalu.design/react/file-uploader
|
|
30
30
|
*/
|
|
31
31
|
export function FileUploader(props: FileUploaderProps) {
|
|
32
|
+
const { icons } = useCerberusContext()
|
|
32
33
|
const styles = fileUploader()
|
|
33
|
-
const { waitingFileUploader: Icon } =
|
|
34
|
+
const { waitingFileUploader: Icon } = icons
|
|
34
35
|
|
|
35
36
|
return (
|
|
36
37
|
<div
|
package/src/components/Input.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import type { InputHTMLAttributes, ReactNode } from 'react'
|
|
|
4
4
|
import { input, type InputVariantProps } from '@cerberus/styled-system/recipes'
|
|
5
5
|
import { cx } from '@cerberus/styled-system/css'
|
|
6
6
|
import { useFieldContext } from '../context/field'
|
|
7
|
-
import {
|
|
7
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
8
8
|
import { Show } from './Show'
|
|
9
9
|
|
|
10
10
|
export interface InputBaseProps
|
|
@@ -39,7 +39,9 @@ export function Input(props: InputProps) {
|
|
|
39
39
|
const inputStyles = input({ size })
|
|
40
40
|
const { invalid, ...fieldStates } = useFieldContext()
|
|
41
41
|
const hasEndIcon = Boolean(endIcon)
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
const { icons } = useCerberusContext()
|
|
44
|
+
const { invalid: InvalidIcon } = icons
|
|
43
45
|
|
|
44
46
|
return (
|
|
45
47
|
<div className={inputStyles.root}>
|
package/src/components/Modal.tsx
CHANGED
|
@@ -22,21 +22,6 @@ function ModalEl(props: ModalProps, ref: ForwardedRef<HTMLDialogElement>) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @see https://cerberus.digitalu.design/react/modal
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* const { modalRef } = useModal()
|
|
30
|
-
*
|
|
31
|
-
* <Modal ref={modalRef}>
|
|
32
|
-
* <Avatar icon={SomeIcon} />
|
|
33
|
-
* <ModalHeader>
|
|
34
|
-
* <ModalHeading>Modal Heading</ModalHeading>
|
|
35
|
-
* <ModalDescription>Modal description</ModalDescription>
|
|
36
|
-
* </ModalHeader>
|
|
37
|
-
*
|
|
38
|
-
* {props.children}
|
|
39
|
-
* </Modal>
|
|
40
|
-
* ```
|
|
25
|
+
* @deprecated use `Dialog` instead
|
|
41
26
|
*/
|
|
42
27
|
export const Modal = forwardRef(ModalEl)
|
|
@@ -10,14 +10,7 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
export type ModalDescriptionProps = HTMLAttributes<HTMLParagraphElement>
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @see https://cerberus.digitalu.design/react/modal
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* <Modal>
|
|
18
|
-
* <ModalDescription>Modal Heading</ModalDescription>
|
|
19
|
-
* </Modal>
|
|
20
|
-
* ```
|
|
13
|
+
* @deprecated use `DialogDescription` instead
|
|
21
14
|
*/
|
|
22
15
|
export function ModalDescription(props: ModalDescriptionProps) {
|
|
23
16
|
return <p {...props} className={cx(props.className, modal().description)} />
|
|
@@ -10,16 +10,7 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
export type ModalHeaderProps = HTMLAttributes<HTMLDivElement>
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @see https://cerberus.digitalu.design/react/modal
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* <Modal>
|
|
18
|
-
* <ModalHeader>
|
|
19
|
-
* <h2>Modal Heading</h2>
|
|
20
|
-
* </ModalHeader>
|
|
21
|
-
* </Modal>
|
|
22
|
-
* ```
|
|
13
|
+
* @deprecated there is no replacement for this component
|
|
23
14
|
*/
|
|
24
15
|
export function ModalHeader(props: ModalHeaderProps) {
|
|
25
16
|
return (
|
|
@@ -10,14 +10,7 @@ import type { HTMLAttributes } from 'react'
|
|
|
10
10
|
export type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @see https://cerberus.digitalu.design/react/modal
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* <Modal>
|
|
18
|
-
* <ModalHeading>Modal Heading</ModalHeading>
|
|
19
|
-
* </Modal>
|
|
20
|
-
* ```
|
|
13
|
+
* @deprecated use `DialogHeading` instead
|
|
21
14
|
*/
|
|
22
15
|
export function ModalHeading(props: ModalHeadingProps) {
|
|
23
16
|
return <p {...props} className={cx(props.className, modal().heading)} />
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
type PropsWithChildren,
|
|
13
13
|
type MouseEvent,
|
|
14
14
|
} from 'react'
|
|
15
|
-
import { $cerberusIcons } from '../config/defineIcons'
|
|
16
15
|
import { trapFocus } from '../aria-helpers/trap-focus.aria'
|
|
16
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* This module exports the Notification component.
|
|
@@ -21,13 +21,14 @@ import { trapFocus } from '../aria-helpers/trap-focus.aria'
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
function MatchNotificationIcon(props: NotificationVariantProps) {
|
|
24
|
+
const { icons } = useCerberusContext()
|
|
24
25
|
const palette = (props.palette || 'info') as
|
|
25
26
|
| 'info'
|
|
26
27
|
| 'success'
|
|
27
28
|
| 'warning'
|
|
28
29
|
| 'danger'
|
|
29
|
-
const key = `${palette}Notification` as keyof typeof
|
|
30
|
-
const Icon =
|
|
30
|
+
const key = `${palette}Notification` as keyof typeof icons
|
|
31
|
+
const Icon = icons[key]
|
|
31
32
|
return <Icon />
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -62,13 +63,17 @@ export type NotificationProps = NotificationBaseProps & NotificationVariantProps
|
|
|
62
63
|
export function Notification(props: PropsWithChildren<NotificationProps>) {
|
|
63
64
|
const { children, palette, onClose, ...nativeProps } = props
|
|
64
65
|
const ref = useRef<HTMLDialogElement>(null)
|
|
66
|
+
|
|
65
67
|
const onKeyDown = trapFocus(ref)
|
|
66
68
|
const styles = notification({ palette })
|
|
67
|
-
|
|
69
|
+
|
|
70
|
+
const { icons } = useCerberusContext()
|
|
71
|
+
const { close: CloseIcon } = icons
|
|
68
72
|
|
|
69
73
|
return (
|
|
70
74
|
<dialog
|
|
71
75
|
{...nativeProps}
|
|
76
|
+
data-placement="left"
|
|
72
77
|
className={cx(
|
|
73
78
|
nativeProps.className,
|
|
74
79
|
hstack({
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
type SelectVariantProps,
|
|
8
8
|
} from '@cerberus/styled-system/recipes'
|
|
9
9
|
import type { OptionHTMLAttributes, SelectHTMLAttributes } from 'react'
|
|
10
|
-
import { $cerberusIcons } from '../config/defineIcons'
|
|
11
10
|
import { useFieldContext } from '../context/field'
|
|
11
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
12
12
|
import { Show } from './Show'
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -50,7 +50,10 @@ export type SelectProps = Omit<
|
|
|
50
50
|
export function Select(props: SelectProps) {
|
|
51
51
|
const { describedBy, size, ...nativeProps } = props
|
|
52
52
|
const { invalid, ...fieldStates } = useFieldContext()
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
const { icons } = useCerberusContext()
|
|
55
|
+
const { invalid: InvalidIcon, selectArrow: SelectArrow } = icons
|
|
56
|
+
|
|
54
57
|
const styles = select({
|
|
55
58
|
size,
|
|
56
59
|
})
|
package/src/components/Tag.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
HTMLAttributes,
|
|
3
5
|
MouseEventHandler,
|
|
@@ -10,7 +12,7 @@ import {
|
|
|
10
12
|
tag,
|
|
11
13
|
type TagVariantProps,
|
|
12
14
|
} from '@cerberus/styled-system/recipes'
|
|
13
|
-
import {
|
|
15
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* This module contains the tag component.
|
|
@@ -71,7 +73,8 @@ export function Tag(props: PropsWithChildren<TagProps>): JSX.Element {
|
|
|
71
73
|
const isClosable = Boolean(onClick)
|
|
72
74
|
const shape = isClosable ? 'pill' : initShape
|
|
73
75
|
const closableStyles = isClosable ? closableCss : ''
|
|
74
|
-
const {
|
|
76
|
+
const { icons } = useCerberusContext()
|
|
77
|
+
const { close: Close } = icons
|
|
75
78
|
|
|
76
79
|
return (
|
|
77
80
|
<span
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
type ToggleVariantProps,
|
|
8
8
|
} from '@cerberus/styled-system/recipes'
|
|
9
9
|
import type { InputHTMLAttributes } from 'react'
|
|
10
|
-
import { $cerberusIcons } from '../config/defineIcons'
|
|
11
10
|
import { useFieldContext } from '../context/field'
|
|
11
|
+
import { useCerberusContext } from '../context/cerberus'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* This module provides a toggle component.
|
|
@@ -59,7 +59,8 @@ export function Toggle(props: ToggleProps) {
|
|
|
59
59
|
const { size, describedBy, ...nativeProps } = props
|
|
60
60
|
const styles = toggle({ size })
|
|
61
61
|
const { invalid, ...state } = useFieldContext()
|
|
62
|
-
const
|
|
62
|
+
const { icons } = useCerberusContext()
|
|
63
|
+
const CheckedIcon = icons.toggleChecked
|
|
63
64
|
|
|
64
65
|
return (
|
|
65
66
|
<span
|
|
@@ -83,7 +84,7 @@ export function Toggle(props: ToggleProps) {
|
|
|
83
84
|
}),
|
|
84
85
|
)}
|
|
85
86
|
>
|
|
86
|
-
<
|
|
87
|
+
<CheckedIcon />
|
|
87
88
|
</span>
|
|
88
89
|
</span>
|
|
89
90
|
)
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'
|
|
2
|
+
import { AnimatingUploadIcon } from '../components/AnimatingUploadIcon'
|
|
3
|
+
import type { DefinedIcons, IconType } from './types'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const defaultIcons: Pick<
|
|
6
|
+
DefinedIcons,
|
|
7
|
+
'checkbox' | 'fileUploader' | 'indeterminate'
|
|
8
|
+
> = {
|
|
9
|
+
checkbox: CheckmarkIcon,
|
|
10
|
+
fileUploader: AnimatingUploadIcon,
|
|
11
|
+
indeterminate: IndeterminateIcon,
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Defines the icons that will be used in Cerberus React components via the
|
|
16
|
+
* CerberusProvider.
|
|
17
|
+
* @param icons The icons that will be used in Cerberus React components.
|
|
18
|
+
* @returns Icons object compatible with the CerberusProvider SystemConfig.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const icons = defineIcons({
|
|
22
|
+
* accordionIndicator: MyAccordionIndicatorIcon,
|
|
23
|
+
* ...
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function defineIcons<T extends IconType>(
|
|
28
|
+
icons: DefinedIcons,
|
|
29
|
+
): Required<DefinedIcons<T>> {
|
|
30
|
+
return {
|
|
14
31
|
...defaultIcons,
|
|
15
32
|
...icons,
|
|
16
|
-
} as Required<DefinedIcons
|
|
17
|
-
return $cerberusIcons
|
|
33
|
+
} as Required<DefinedIcons<T>>
|
|
18
34
|
}
|
|
19
|
-
|
|
20
|
-
// Default icons
|
|
21
|
-
|
|
22
|
-
export let $cerberusIcons = defaultIcons as Required<DefinedIcons>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SystemConfig } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a system configuration object to be used on the CerberusProvider.
|
|
5
|
+
* @param options The system configuration options you want to customize.
|
|
6
|
+
* @returns A CerberusProvider-compatible system configuration object.
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const icons = defineIcons({
|
|
10
|
+
* accordionIndicator: MyAccordionIndicatorIcon,
|
|
11
|
+
* ...
|
|
12
|
+
* })
|
|
13
|
+
* const config = makeSystemConfig({
|
|
14
|
+
* icons,
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // In your app
|
|
18
|
+
* <CerberusProvider config={config}>
|
|
19
|
+
* <App />
|
|
20
|
+
* </CerberusProvider>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function makeSystemConfig(options: SystemConfig): SystemConfig {
|
|
24
|
+
return options
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export * from './defineIcons'
|
|
28
|
+
export * from './types'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This module contains the types for the Cerberus React configuration.
|
|
5
|
+
* @module config.types
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface SystemConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The icons that will be used in Cerberus React components.
|
|
11
|
+
*/
|
|
12
|
+
icons: Required<DefinedIcons>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DefinedIcons<T extends IconType = IconType> {
|
|
16
|
+
accordionIndicator: T
|
|
17
|
+
avatar: T
|
|
18
|
+
calendar: T
|
|
19
|
+
calendarPrev: T
|
|
20
|
+
calendarNext: T
|
|
21
|
+
checkbox?: T
|
|
22
|
+
close: T
|
|
23
|
+
confirmModal: T
|
|
24
|
+
delete: T
|
|
25
|
+
promptModal: T
|
|
26
|
+
waitingFileUploader: T
|
|
27
|
+
fileUploader?: T
|
|
28
|
+
indeterminate?: T
|
|
29
|
+
infoNotification: T
|
|
30
|
+
successNotification: T
|
|
31
|
+
warningNotification: T
|
|
32
|
+
dangerNotification: T
|
|
33
|
+
invalid: T
|
|
34
|
+
invalidAlt: T
|
|
35
|
+
redo: T
|
|
36
|
+
selectArrow: T
|
|
37
|
+
toggleChecked: T
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// types
|
|
41
|
+
|
|
42
|
+
export type IconType = ElementType
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, type PropsWithChildren } from 'react'
|
|
4
|
+
import type { SystemConfig } from '../config'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This module contains the Cerberus configuration context and helpers.
|
|
8
|
+
* @module context/cerberus
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type CerberusContextValue = SystemConfig
|
|
12
|
+
|
|
13
|
+
const CerberusContext = createContext<CerberusContextValue | null>(null)
|
|
14
|
+
|
|
15
|
+
interface CerberusProviderProps {
|
|
16
|
+
config: SystemConfig
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Cerberus configuration provider.
|
|
21
|
+
* @param props.config The Cerberus configuration created with
|
|
22
|
+
* `makeSystemConfig` helper.
|
|
23
|
+
*/
|
|
24
|
+
export function CerberusProvider(
|
|
25
|
+
props: PropsWithChildren<CerberusProviderProps>,
|
|
26
|
+
) {
|
|
27
|
+
return (
|
|
28
|
+
<CerberusContext.Provider value={props.config}>
|
|
29
|
+
{props.children}
|
|
30
|
+
</CerberusContext.Provider>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the Cerberus configuration context.
|
|
36
|
+
* @returns The Cerberus configuration context.
|
|
37
|
+
*/
|
|
38
|
+
export function useCerberusContext() {
|
|
39
|
+
const context = useContext(CerberusContext)
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error('useCerberus must be used within a CerberusProvider')
|
|
42
|
+
}
|
|
43
|
+
return context
|
|
44
|
+
}
|