@cerberus-design/react 0.12.0 → 0.13.1-next-e3e9e48

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.
Files changed (61) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +128 -1
  2. package/build/legacy/components/Portal.cjs +3 -5
  3. package/build/legacy/components/Portal.cjs.map +1 -1
  4. package/build/legacy/components/Tooltip.cjs +55 -0
  5. package/build/legacy/components/Tooltip.cjs.map +1 -0
  6. package/build/legacy/context/confirm-modal.cjs +2 -5
  7. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  8. package/build/legacy/context/cta-modal.cjs +2 -5
  9. package/build/legacy/context/cta-modal.cjs.map +1 -1
  10. package/build/legacy/context/notification-center.cjs +3 -6
  11. package/build/legacy/context/notification-center.cjs.map +1 -1
  12. package/build/legacy/context/prompt-modal.cjs +2 -5
  13. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  14. package/build/legacy/hooks/useDate.cjs +122 -0
  15. package/build/legacy/hooks/useDate.cjs.map +1 -0
  16. package/build/legacy/hooks/useModal.cjs.map +1 -1
  17. package/build/legacy/index.cjs +214 -93
  18. package/build/legacy/index.cjs.map +1 -1
  19. package/build/modern/_tsup-dts-rollup.d.ts +128 -1
  20. package/build/modern/{chunk-ZBMA5G54.js → chunk-7MM5KYEX.js} +4 -4
  21. package/build/modern/chunk-CZND26FC.js +98 -0
  22. package/build/modern/chunk-CZND26FC.js.map +1 -0
  23. package/build/modern/{chunk-T6LS5P5W.js → chunk-J4LOSTEP.js} +13 -13
  24. package/build/modern/chunk-K2PSHGS7.js +11 -0
  25. package/build/modern/chunk-K2PSHGS7.js.map +1 -0
  26. package/build/modern/{chunk-CSEHDNMJ.js → chunk-KFGI37CO.js} +12 -12
  27. package/build/modern/{chunk-7T3JIGM7.js → chunk-KGQG5JGW.js} +1 -1
  28. package/build/modern/chunk-KGQG5JGW.js.map +1 -0
  29. package/build/modern/chunk-KML4CTMK.js +33 -0
  30. package/build/modern/chunk-KML4CTMK.js.map +1 -0
  31. package/build/modern/{chunk-5OSUZUR4.js → chunk-KUT2YEEQ.js} +7 -7
  32. package/build/modern/chunk-KUT2YEEQ.js.map +1 -0
  33. package/build/modern/{chunk-VP5ERLAY.js → chunk-NCUHRVW2.js} +15 -15
  34. package/build/modern/components/FileStatus.js +2 -2
  35. package/build/modern/components/Portal.js +2 -1
  36. package/build/modern/components/Tooltip.js +7 -0
  37. package/build/modern/components/Tooltip.js.map +1 -0
  38. package/build/modern/context/confirm-modal.js +5 -5
  39. package/build/modern/context/cta-modal.js +5 -5
  40. package/build/modern/context/notification-center.js +3 -3
  41. package/build/modern/context/prompt-modal.js +6 -6
  42. package/build/modern/hooks/useDate.js +14 -0
  43. package/build/modern/hooks/useDate.js.map +1 -0
  44. package/build/modern/hooks/useModal.js +1 -1
  45. package/build/modern/index.js +43 -29
  46. package/build/modern/index.js.map +1 -1
  47. package/package.json +2 -2
  48. package/src/components/Portal.tsx +17 -6
  49. package/src/components/Tooltip.tsx +61 -0
  50. package/src/context/notification-center.tsx +1 -1
  51. package/src/hooks/useDate.ts +164 -0
  52. package/src/hooks/useModal.ts +1 -1
  53. package/src/index.ts +2 -0
  54. package/build/modern/chunk-5OSUZUR4.js.map +0 -1
  55. package/build/modern/chunk-7T3JIGM7.js.map +0 -1
  56. package/build/modern/chunk-GLY7GU5S.js +0 -14
  57. package/build/modern/chunk-GLY7GU5S.js.map +0 -1
  58. /package/build/modern/{chunk-ZBMA5G54.js.map → chunk-7MM5KYEX.js.map} +0 -0
  59. /package/build/modern/{chunk-T6LS5P5W.js.map → chunk-J4LOSTEP.js.map} +0 -0
  60. /package/build/modern/{chunk-CSEHDNMJ.js.map → chunk-KFGI37CO.js.map} +0 -0
  61. /package/build/modern/{chunk-VP5ERLAY.js.map → chunk-NCUHRVW2.js.map} +0 -0
@@ -2,21 +2,21 @@
2
2
  import {
3
3
  ConfirmModal,
4
4
  useConfirmModal
5
- } from "../chunk-CSEHDNMJ.js";
5
+ } from "../chunk-KFGI37CO.js";
6
+ import "../chunk-K2PSHGS7.js";
7
+ import "../chunk-ZFAIE47A.js";
6
8
  import "../chunk-2UXE5PDG.js";
7
- import "../chunk-GLY7GU5S.js";
8
9
  import "../chunk-BE4EOU2P.js";
9
10
  import "../chunk-Q7BRMIBR.js";
10
- import "../chunk-ZFAIE47A.js";
11
+ import "../chunk-KGQG5JGW.js";
11
12
  import "../chunk-SPZYPRZ6.js";
12
- import "../chunk-EXGKZGML.js";
13
13
  import "../chunk-BUVVRQLZ.js";
14
+ import "../chunk-EXGKZGML.js";
14
15
  import "../chunk-JIZQFTW6.js";
15
16
  import "../chunk-VERRHMW4.js";
16
17
  import "../chunk-F27AAKQ3.js";
17
18
  import "../chunk-CP7OUC2Q.js";
18
19
  import "../chunk-HVKM54BA.js";
19
- import "../chunk-7T3JIGM7.js";
20
20
  export {
21
21
  ConfirmModal,
22
22
  useConfirmModal
@@ -2,22 +2,22 @@
2
2
  import {
3
3
  CTAModal,
4
4
  useCTAModal
5
- } from "../chunk-T6LS5P5W.js";
5
+ } from "../chunk-J4LOSTEP.js";
6
+ import "../chunk-K2PSHGS7.js";
7
+ import "../chunk-ZFAIE47A.js";
6
8
  import "../chunk-2UXE5PDG.js";
7
- import "../chunk-GLY7GU5S.js";
8
9
  import "../chunk-BE4EOU2P.js";
9
10
  import "../chunk-Q7BRMIBR.js";
10
- import "../chunk-ZFAIE47A.js";
11
11
  import "../chunk-APD6IX5R.js";
12
+ import "../chunk-KGQG5JGW.js";
12
13
  import "../chunk-SPZYPRZ6.js";
13
- import "../chunk-EXGKZGML.js";
14
14
  import "../chunk-BUVVRQLZ.js";
15
+ import "../chunk-EXGKZGML.js";
15
16
  import "../chunk-JIZQFTW6.js";
16
17
  import "../chunk-VERRHMW4.js";
17
18
  import "../chunk-F27AAKQ3.js";
18
19
  import "../chunk-CP7OUC2Q.js";
19
20
  import "../chunk-HVKM54BA.js";
20
- import "../chunk-7T3JIGM7.js";
21
21
  export {
22
22
  CTAModal,
23
23
  useCTAModal
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  NotificationCenter,
4
4
  useNotificationCenter
5
- } from "../chunk-5OSUZUR4.js";
5
+ } from "../chunk-KUT2YEEQ.js";
6
+ import "../chunk-K2PSHGS7.js";
6
7
  import "../chunk-7SGPJM66.js";
7
8
  import "../chunk-XEW6TJJ4.js";
8
9
  import "../chunk-SXIXDXG3.js";
9
- import "../chunk-GLY7GU5S.js";
10
- import "../chunk-EXGKZGML.js";
11
10
  import "../chunk-BUVVRQLZ.js";
11
+ import "../chunk-EXGKZGML.js";
12
12
  import "../chunk-JIZQFTW6.js";
13
13
  import "../chunk-VERRHMW4.js";
14
14
  import "../chunk-F27AAKQ3.js";
@@ -2,24 +2,24 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-VP5ERLAY.js";
5
+ } from "../chunk-NCUHRVW2.js";
6
+ import "../chunk-K2PSHGS7.js";
7
+ import "../chunk-ZFAIE47A.js";
6
8
  import "../chunk-2UXE5PDG.js";
7
- import "../chunk-GLY7GU5S.js";
8
9
  import "../chunk-NKM6PISB.js";
9
10
  import "../chunk-NMF2HYWO.js";
10
11
  import "../chunk-BE4EOU2P.js";
11
12
  import "../chunk-Q7BRMIBR.js";
12
- import "../chunk-ZFAIE47A.js";
13
- import "../chunk-SPZYPRZ6.js";
14
- import "../chunk-EXGKZGML.js";
15
13
  import "../chunk-UZDVOIW5.js";
14
+ import "../chunk-KGQG5JGW.js";
15
+ import "../chunk-SPZYPRZ6.js";
16
16
  import "../chunk-BUVVRQLZ.js";
17
+ import "../chunk-EXGKZGML.js";
17
18
  import "../chunk-JIZQFTW6.js";
18
19
  import "../chunk-VERRHMW4.js";
19
20
  import "../chunk-F27AAKQ3.js";
20
21
  import "../chunk-CP7OUC2Q.js";
21
22
  import "../chunk-HVKM54BA.js";
22
- import "../chunk-7T3JIGM7.js";
23
23
  export {
24
24
  PromptModal,
25
25
  usePromptModal
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import {
3
+ DateFormats,
4
+ formatMilitaryDate,
5
+ formatMilitaryToISO,
6
+ useDate
7
+ } from "../chunk-CZND26FC.js";
8
+ export {
9
+ DateFormats,
10
+ formatMilitaryDate,
11
+ formatMilitaryToISO,
12
+ useDate
13
+ };
14
+ //# sourceMappingURL=useDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useModal
4
- } from "../chunk-7T3JIGM7.js";
4
+ } from "../chunk-KGQG5JGW.js";
5
5
  export {
6
6
  useModal
7
7
  };
@@ -1,23 +1,32 @@
1
+ import {
2
+ PromptModal,
3
+ usePromptModal
4
+ } from "./chunk-NCUHRVW2.js";
1
5
  import {
2
6
  ThemeProvider,
3
7
  useThemeContext
4
8
  } from "./chunk-EB37HRCN.js";
9
+ import {
10
+ Toggle
11
+ } from "./chunk-NMNONSHU.js";
12
+ import {
13
+ Tooltip
14
+ } from "./chunk-KML4CTMK.js";
5
15
  import {
6
16
  ConfirmModal,
7
17
  useConfirmModal
8
- } from "./chunk-CSEHDNMJ.js";
18
+ } from "./chunk-KFGI37CO.js";
9
19
  import {
10
20
  CTAModal,
11
21
  useCTAModal
12
- } from "./chunk-T6LS5P5W.js";
22
+ } from "./chunk-J4LOSTEP.js";
13
23
  import {
14
24
  NotificationCenter,
15
25
  useNotificationCenter
16
- } from "./chunk-5OSUZUR4.js";
26
+ } from "./chunk-KUT2YEEQ.js";
17
27
  import {
18
- PromptModal,
19
- usePromptModal
20
- } from "./chunk-VP5ERLAY.js";
28
+ TabPanel
29
+ } from "./chunk-AYIRV5CL.js";
21
30
  import {
22
31
  Table,
23
32
  Tr
@@ -41,8 +50,8 @@ import {
41
50
  Thead
42
51
  } from "./chunk-Y6QQCRQV.js";
43
52
  import {
44
- Toggle
45
- } from "./chunk-NMNONSHU.js";
53
+ Portal
54
+ } from "./chunk-K2PSHGS7.js";
46
55
  import {
47
56
  Radio
48
57
  } from "./chunk-FTPZHG6J.js";
@@ -60,8 +69,8 @@ import {
60
69
  TabList
61
70
  } from "./chunk-UKPF7JOB.js";
62
71
  import {
63
- TabPanel
64
- } from "./chunk-AYIRV5CL.js";
72
+ ModalHeader
73
+ } from "./chunk-ZFAIE47A.js";
65
74
  import {
66
75
  ModalHeading
67
76
  } from "./chunk-2UXE5PDG.js";
@@ -89,8 +98,8 @@ import {
89
98
  NotificationHeading
90
99
  } from "./chunk-SXIXDXG3.js";
91
100
  import {
92
- Portal
93
- } from "./chunk-GLY7GU5S.js";
101
+ FileUploader
102
+ } from "./chunk-W4DXACNV.js";
94
103
  import {
95
104
  Input
96
105
  } from "./chunk-NKM6PISB.js";
@@ -116,8 +125,8 @@ import {
116
125
  ModalDescription
117
126
  } from "./chunk-Q7BRMIBR.js";
118
127
  import {
119
- ModalHeader
120
- } from "./chunk-ZFAIE47A.js";
128
+ Checkbox
129
+ } from "./chunk-NB6DV4VA.js";
121
130
  import {
122
131
  CircularProgress
123
132
  } from "./chunk-6QHOKCV3.js";
@@ -140,7 +149,7 @@ import {
140
149
  import {
141
150
  FileStatus,
142
151
  processStatus
143
- } from "./chunk-ZBMA5G54.js";
152
+ } from "./chunk-7MM5KYEX.js";
144
153
  import {
145
154
  ProgressBar
146
155
  } from "./chunk-KCANMM64.js";
@@ -151,8 +160,12 @@ import {
151
160
  FieldMessage
152
161
  } from "./chunk-JWIJHSI6.js";
153
162
  import {
154
- FileUploader
155
- } from "./chunk-W4DXACNV.js";
163
+ Field,
164
+ useFieldContext
165
+ } from "./chunk-UZDVOIW5.js";
166
+ import {
167
+ useModal
168
+ } from "./chunk-KGQG5JGW.js";
156
169
  import {
157
170
  MODE_KEY,
158
171
  THEME_KEY,
@@ -172,19 +185,12 @@ import {
172
185
  import {
173
186
  Avatar
174
187
  } from "./chunk-SPZYPRZ6.js";
175
- import {
176
- Button
177
- } from "./chunk-EXGKZGML.js";
178
- import {
179
- Checkbox
180
- } from "./chunk-NB6DV4VA.js";
181
- import {
182
- Field,
183
- useFieldContext
184
- } from "./chunk-UZDVOIW5.js";
185
188
  import {
186
189
  Show
187
190
  } from "./chunk-BUVVRQLZ.js";
191
+ import {
192
+ Button
193
+ } from "./chunk-EXGKZGML.js";
188
194
  import "./chunk-55J6XMHW.js";
189
195
  import {
190
196
  createNavTriggerProps
@@ -208,8 +214,11 @@ import "./chunk-F27AAKQ3.js";
208
214
  import "./chunk-CP7OUC2Q.js";
209
215
  import "./chunk-HVKM54BA.js";
210
216
  import {
211
- useModal
212
- } from "./chunk-7T3JIGM7.js";
217
+ DateFormats,
218
+ formatMilitaryDate,
219
+ formatMilitaryToISO,
220
+ useDate
221
+ } from "./chunk-CZND26FC.js";
213
222
 
214
223
  // src/index.ts
215
224
  export * from "@dnd-kit/core";
@@ -224,6 +233,7 @@ export {
224
233
  Checkbox,
225
234
  CircularProgress,
226
235
  ConfirmModal,
236
+ DateFormats,
227
237
  Droppable,
228
238
  FeatureFlag,
229
239
  FeatureFlags,
@@ -280,15 +290,19 @@ export {
280
290
  Thead,
281
291
  ThemeProvider,
282
292
  Toggle,
293
+ Tooltip,
283
294
  Tr,
284
295
  createNavTriggerProps,
285
296
  defineIcons,
297
+ formatMilitaryDate,
298
+ formatMilitaryToISO,
286
299
  formatNotifyCount,
287
300
  getPosition,
288
301
  processStatus,
289
302
  trapFocus,
290
303
  useCTAModal,
291
304
  useConfirmModal,
305
+ useDate,
292
306
  useFeatureFlags,
293
307
  useFieldContext,
294
308
  useModal,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.12.0",
3
+ "version": "0.13.1-next-e3e9e48",
4
4
  "description": "The Cerberus Design React component library.",
5
5
  "browserslist": "> 0.25%, not dead",
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  "react-dom": "^18",
28
28
  "tsup": "^8.1.0",
29
29
  "@cerberus-design/configs": "0.0.0",
30
- "@cerberus-design/styled-system": "0.12.0"
30
+ "@cerberus-design/styled-system": "0.13.1-next-e3e9e48"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import type { PropsWithChildren } from 'react'
2
4
  import { createPortal } from 'react-dom'
3
5
 
@@ -22,12 +24,21 @@ export interface PortalProps {
22
24
  * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
23
25
  * @see https://cerberus.digitalu.design/react/portal
24
26
  * @definition [React Portal Docs](https://react.dev/reference/react-dom/createPortal)
27
+ * @example
28
+ * ```tsx
29
+ * 'use client'
30
+ *
31
+ * import { Portal } from '@cerberus/react'
32
+ *
33
+ * function SomeFeatureWithinSSRPage() {
34
+ * return (
35
+ * <Portal>
36
+ * <div>Portal Content outside of the React VDom tree</div>
37
+ * </Portal>
38
+ * )
39
+ * }
25
40
  */
26
41
  export function Portal(props: PropsWithChildren<PortalProps>) {
27
- if (typeof window !== 'undefined') {
28
- const container = props.container || document.body
29
- return createPortal(props.children, container, props.key)
30
- }
31
-
32
- return null
42
+ const container = props.container || document.body
43
+ return createPortal(props.children, container, props.key)
33
44
  }
@@ -0,0 +1,61 @@
1
+ import {
2
+ Tooltip as ArkTooltip,
3
+ type TooltipContentProps,
4
+ } from '@ark-ui/react/tooltip'
5
+ import { cx } from '@cerberus/styled-system/css'
6
+ import { tooltip } from '@cerberus/styled-system/recipes'
7
+ import type { ReactNode } from 'react'
8
+
9
+ /**
10
+ * This module contains the Tooltip component.
11
+ * @module Tooltip
12
+ */
13
+
14
+ export interface TooltipProps {
15
+ /**
16
+ * The text content to display in the tooltip.
17
+ */
18
+ content: ReactNode
19
+ /**
20
+ * The position of the tooltip relative to the trigger element.
21
+ */
22
+ position?: 'top' | 'right' | 'bottom' | 'left'
23
+ }
24
+
25
+ /**
26
+ * The Tooltip component is used to provide additional information about an element when it is hovered over.
27
+ * @definition [Tooltip docs](https://cerberus.digitalu.design/react/tooltip)
28
+ * @example
29
+ * ```tsx
30
+ * <Tooltip content="This is a tooltip">
31
+ * <Information />
32
+ * </Tooltip>
33
+ */
34
+ export function Tooltip(props: TooltipProps & TooltipContentProps) {
35
+ const { content, children, ...nativeProps } = props
36
+ const styles = tooltip()
37
+ const position = {
38
+ placement: props.position || 'top',
39
+ }
40
+
41
+ return (
42
+ <ArkTooltip.Root openDelay={400} positioning={position}>
43
+ <ArkTooltip.Trigger className={styles.trigger}>
44
+ {children}
45
+ </ArkTooltip.Trigger>
46
+
47
+ <ArkTooltip.Positioner>
48
+ <ArkTooltip.Content
49
+ {...nativeProps}
50
+ className={cx(nativeProps.className, styles.content)}
51
+ >
52
+ <ArkTooltip.Arrow className={styles.arrow}>
53
+ <ArkTooltip.ArrowTip className={styles.arrowTip} />
54
+ </ArkTooltip.Arrow>
55
+
56
+ {content}
57
+ </ArkTooltip.Content>
58
+ </ArkTooltip.Positioner>
59
+ </ArkTooltip.Root>
60
+ )
61
+ }
@@ -136,7 +136,7 @@ export function NotificationCenter(
136
136
  palette="action"
137
137
  shape="rounded"
138
138
  size="sm"
139
- usage="text"
139
+ usage="ghost"
140
140
  >
141
141
  Close all
142
142
  </Button>
@@ -0,0 +1,164 @@
1
+ 'use client'
2
+
3
+ import {
4
+ useState,
5
+ useCallback,
6
+ ChangeEvent,
7
+ useMemo,
8
+ type InputHTMLAttributes,
9
+ } from 'react'
10
+
11
+ export interface UseDateBase {
12
+ /**
13
+ * The format of the date input
14
+ */
15
+ format?: string
16
+ /**
17
+ * The callback to run when the date input changes
18
+ */
19
+ onChange?: InputHTMLAttributes<HTMLInputElement>['onChange']
20
+ }
21
+
22
+ export interface UseDateOptions extends UseDateBase {
23
+ /**
24
+ * The initial value of the date input
25
+ */
26
+ initialValue?: string
27
+ }
28
+
29
+ export interface UseDateReturn extends UseDateBase {
30
+ /**
31
+ * The ISO formatted date string
32
+ */
33
+ ISO: string
34
+ /**
35
+ * The value of the date input
36
+ */
37
+ value: string
38
+ }
39
+
40
+ /**
41
+ * A hook for formatting and validating date inputs. The date format defaults to US Military format.
42
+ * @example
43
+ * ```tsx
44
+ * const MyComponent = () => {
45
+ * const date = useDate({ initialValue: '01 JAN 2024' })
46
+ * return <input onChange={date.onChange} type="text" value={date.value} />
47
+ * }
48
+ */
49
+ export function useDate(options?: UseDateOptions): UseDateReturn {
50
+ const initialValue = options?.initialValue ?? ''
51
+ const format = options?.format ?? DateFormats.USMilitary
52
+ const onChange = options?.onChange
53
+ const [value, setValue] = useState(initialValue)
54
+
55
+ const handleChange = useCallback(
56
+ (e: ChangeEvent<HTMLInputElement>) => {
57
+ const newValue = formatMilitaryDate(e.currentTarget.value)
58
+ if (onChange) onChange(e)
59
+ setValue(newValue)
60
+ },
61
+ [onChange],
62
+ )
63
+
64
+ return useMemo(
65
+ () => ({
66
+ format,
67
+ value,
68
+ ISO: formatMilitaryToISO(value),
69
+ onChange: handleChange,
70
+ }),
71
+ [format, value, handleChange],
72
+ )
73
+ }
74
+
75
+ // helpers
76
+
77
+ /**
78
+ * Converts a string in US Military format to ISO format. Used within the `useDate` hook.
79
+ * @param input The string to format
80
+ * @returns The formatted string in ISO format (YYYY-MM-DD)
81
+ */
82
+ export function formatMilitaryToISO(input: string) {
83
+ const [day, month, year] = input.split(' ')
84
+ const monthIndex = MONTHS.findIndex((m) => m.startsWith(month))
85
+ const monthNum = monthIndex + 1
86
+ return `${year ?? '0000'}-${monthNum.toString().padStart(2, '0')}-${day.padStart(
87
+ 2,
88
+ '0',
89
+ )}`
90
+ }
91
+
92
+ /**
93
+ * Converts a string to US Military format. Used within the `useDate` hook.
94
+ * @param input The string to format
95
+ * @returns The formatted string in US Military format (DD MMM YYYY)
96
+ */
97
+ export function formatMilitaryDate(input: string): string {
98
+ let formatted = input.toUpperCase().replace(/[^0-9A-Z]/g, '')
99
+ let day = ''
100
+ let month = ''
101
+ let year = ''
102
+
103
+ // Format day
104
+ if (formatted.length >= 2) {
105
+ day = formatted.replace(/[^0-9]/g, '').slice(0, 2)
106
+ const dayNum = parseInt(day, 10)
107
+ if (dayNum > 31) day = '31'
108
+ else if (dayNum === 0) day = '01'
109
+ formatted = formatted.slice(2)
110
+ }
111
+
112
+ // Format month
113
+ if (formatted.length >= 3) {
114
+ month = formatted.slice(0, 3)
115
+ const monthIndex = MONTHS.findIndex((m) => m.startsWith(month))
116
+ if (monthIndex !== -1) {
117
+ month = MONTHS[monthIndex]
118
+ } else {
119
+ month = month.replace(/[^A-Z]/g, '')
120
+ }
121
+ formatted = formatted.slice(3)
122
+ }
123
+
124
+ // Format year
125
+ if (formatted.length > 0) {
126
+ year = formatted.slice(0, 4)
127
+ }
128
+
129
+ return [day, month, year].filter(Boolean).join(' ')
130
+ }
131
+
132
+ /**
133
+ * Date formatting options
134
+ * @example
135
+ * ```tsx
136
+ * const date = new Date()
137
+ * const formatted = date.format(DateFormats.USMilitary)
138
+ */
139
+ export const DateFormats = {
140
+ get ISO() {
141
+ return 'YYYY-MM-DD'
142
+ },
143
+ get USMilitary() {
144
+ return 'DD MMM YYYY'
145
+ },
146
+ get Months() {
147
+ return MONTHS
148
+ },
149
+ }
150
+
151
+ const MONTHS = [
152
+ 'JAN',
153
+ 'FEB',
154
+ 'MAR',
155
+ 'APR',
156
+ 'MAY',
157
+ 'JUN',
158
+ 'JUL',
159
+ 'AUG',
160
+ 'SEP',
161
+ 'OCT',
162
+ 'NOV',
163
+ 'DEC',
164
+ ]
@@ -7,7 +7,7 @@ import { useCallback, useMemo, useRef, useState, type RefObject } from 'react'
7
7
  * @module
8
8
  */
9
9
 
10
- interface UseModalReturnValue {
10
+ export interface UseModalReturnValue {
11
11
  /**
12
12
  * The ref for the modal.
13
13
  */
package/src/index.ts CHANGED
@@ -48,6 +48,7 @@ export * from './components/Tbody'
48
48
  export * from './components/Tag'
49
49
  export * from './components/Textarea'
50
50
  export * from './components/Toggle'
51
+ export * from './components/Tooltip'
51
52
  export * from './components/Show'
52
53
 
53
54
  // context
@@ -64,6 +65,7 @@ export * from './context/theme'
64
65
 
65
66
  // hooks
66
67
 
68
+ export * from './hooks/useDate'
67
69
  export * from './hooks/useModal'
68
70
  export * from './hooks/useTheme'
69
71
  export * from './hooks/useToggle'
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/context/notification-center.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Show } from '../components/Show'\nimport { NotificationHeading } from '../components/NotificationHeading'\nimport { NotificationDescription } from '../components/NotificationDescription'\nimport { Notification } from '../components/Notification'\nimport { animateIn, vstack } from '@cerberus/styled-system/patterns'\nimport { Portal, type PortalProps } from '../components/Portal'\nimport { notification } from '@cerberus/styled-system/recipes'\nimport { Button } from '../components/Button'\nimport { cx } from '@cerberus/styled-system/css'\n\n/**\n * This module provides a context and hook for notifications.\n * @module\n */\n\nexport interface NotifyOptions {\n /**\n * The palette of the notification.\n * @default 'info'\n */\n palette: 'info' | 'success' | 'warning' | 'danger'\n /**\n * The heading of the notification.\n */\n heading: string\n /**\n * The unique id of the notification.\n */\n id?: string\n /**\n * The description of the notification.\n */\n description?: ReactNode\n /**\n * The action to take when the notification is closed\n */\n onClose?: () => void\n}\n\nexport interface NotificationsValue {\n notify: (options: NotifyOptions) => void\n}\n\nconst NotificationsContext = createContext<NotificationsValue | null>(null)\n\nexport interface NotificationsProviderProps extends PortalProps {}\n\n/**\n * Provides a notification center to the app.\n * @see https://cerberus.digitalu.design/react/notification\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <Notifications>\n * <SomeFeatureSection />\n * </Notifications>\n *\n * // Use the hook to show a notification.\n * const notify = useNotifications()\n *\n * const handleClick = useCallback(() => {\n * notify({\n * palette: 'info',\n * heading: 'New feature!',\n * description: 'We have added a new feature to the app.',\n * })\n * }, [notify])\n * ```\n */\nexport function NotificationCenter(\n props: PropsWithChildren<NotificationsProviderProps>,\n) {\n const [activeNotifications, setActiveNotifications] = useState<\n NotifyOptions[]\n >([])\n const styles = notification()\n\n const handleNotify = useCallback((options: NotifyOptions) => {\n setActiveNotifications((prev) => {\n const id = `${options.palette}:${prev.length + 1}`\n return [...prev, { ...options, id }]\n })\n }, [])\n\n const handleClose = useCallback((e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n setActiveNotifications((prev) => {\n const item = prev.find((option) => option.id === target.value)\n if (item?.onClose) item.onClose()\n return prev.filter((option) => option.id !== target.value)\n })\n }, [])\n\n const handleCloseAll = useCallback(() => {\n setActiveNotifications((prev) => {\n prev.forEach((item) => {\n if (item.onClose) item.onClose()\n })\n return []\n })\n }, [])\n\n const value = useMemo(\n () => ({\n notify: handleNotify,\n }),\n [handleNotify],\n )\n\n // For some reason, the vstack pattern alignItems is not registering here.\n // So we are forcing it with the style prop.\n\n return (\n <NotificationsContext.Provider value={value}>\n {props.children}\n\n <Show when={activeNotifications.length > 0}>\n <Portal container={props.container}>\n <div className={styles.center}>\n <Show when={activeNotifications.length >= 4}>\n <Button\n className={cx(styles.closeAll, animateIn())}\n onClick={handleCloseAll}\n palette=\"action\"\n shape=\"rounded\"\n size=\"sm\"\n usage=\"text\"\n >\n Close all\n </Button>\n </Show>\n <div\n className={vstack({\n alignItems: 'flex-end',\n gap: '4',\n })}\n style={{\n alignItems: 'flex-end',\n }}\n >\n {activeNotifications.map((option) => (\n <MatchNotification\n key={option.id}\n {...option}\n onClose={handleClose}\n />\n ))}\n </div>\n </div>\n </Portal>\n </Show>\n </NotificationsContext.Provider>\n )\n}\n\ninterface MatchNotificationProps extends Omit<NotifyOptions, 'onClose'> {\n onClose: (e: MouseEvent<HTMLButtonElement>) => void\n key: string | undefined\n}\n\nfunction MatchNotification(props: MatchNotificationProps) {\n const { palette, id, onClose, heading, description } = props\n\n switch (palette) {\n case 'success':\n return (\n <Notification\n id={id!}\n key={id}\n onClose={onClose}\n open\n palette=\"success\"\n >\n <NotificationHeading palette=\"success\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"success\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'warning':\n return (\n <Notification\n id={id!}\n key={id}\n onClose={onClose}\n open\n palette=\"warning\"\n >\n <NotificationHeading palette=\"warning\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"warning\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'danger':\n return (\n <Notification id={id!} key={id} onClose={onClose} open palette=\"danger\">\n <NotificationHeading palette=\"danger\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"danger\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'info':\n default:\n return (\n <Notification id={id!} key={id} onClose={onClose} open palette=\"info\">\n <NotificationHeading palette=\"info\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"info\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n }\n}\n\n/**\n * The hook to use the NotificationCenter.\n * @returns The notify method to trigger a notification.\n * @example\n * ```tsx\n * const {notify} = useNotificationCenter()\n * notify({\n * palette: 'info',\n * heading: 'New feature',\n * description: 'We have added a new feature to the app.',\n * })\n * ```\n */\nexport function useNotificationCenter(): NotificationsValue {\n const context = useContext(NotificationsContext)\n if (!context) {\n throw new Error(\n 'useNotificationCenter must be used within a NotificationsProvider',\n )\n }\n return context\n}\n"],"mappings":"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","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/hooks/useModal.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useMemo, useRef, useState, type RefObject } from 'react'\n\n/**\n * This module provides a hook for using a custom modal.\n * @module\n */\n\ninterface UseModalReturnValue {\n /**\n * The ref for the modal.\n */\n modalRef: RefObject<HTMLDialogElement>\n /**\n * Shows the modal.\n */\n show: () => void\n /**\n * Closes the modal.\n */\n close: () => void\n /**\n * Whether the modal is open based on the show and close methods.\n */\n isOpen: boolean\n}\n\n/**\n * Provides a hook for using a custom modal via the native dialog element\n * methods.\n *\n * Cerberus modals use the native dialog element. This hook\n * does not control the modal via React state but rather by calling the\n * native dialog element's `showModal` and `close` methods.\n *\n * @memberof module:Modal\n * @see https://cerberus.digitalu.design/react/modal\n * @description [Moz Dev Dialog Docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)\n */\nexport function useModal(): UseModalReturnValue {\n const modalRef = useRef<HTMLDialogElement | null>(null)\n const [isOpen, setIsOpen] = useState<boolean>(false)\n\n const show = useCallback(() => {\n modalRef.current?.showModal()\n setIsOpen(true)\n }, [])\n\n const close = useCallback(() => {\n modalRef.current?.close()\n setIsOpen(false)\n }, [])\n\n return useMemo(() => {\n return {\n modalRef,\n show,\n close,\n isOpen,\n }\n }, [modalRef, show, close, isOpen])\n}\n"],"mappings":";AAEA,SAAS,aAAa,SAAS,QAAQ,gBAAgC;AAsChE,SAAS,WAAgC;AAC9C,QAAM,WAAW,OAAiC,IAAI;AACtD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkB,KAAK;AAEnD,QAAM,OAAO,YAAY,MAAM;AAC7B,aAAS,SAAS,UAAU;AAC5B,cAAU,IAAI;AAAA,EAChB,GAAG,CAAC,CAAC;AAEL,QAAM,QAAQ,YAAY,MAAM;AAC9B,aAAS,SAAS,MAAM;AACxB,cAAU,KAAK;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,SAAO,QAAQ,MAAM;AACnB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,MAAM,OAAO,MAAM,CAAC;AACpC;","names":[]}