@cerberus-design/react 0.13.2-next-61259ca → 0.14.0-next-01a1b5e

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 (71) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +103 -107
  2. package/build/legacy/components/Tabs.client.cjs +104 -0
  3. package/build/legacy/components/Tabs.client.cjs.map +1 -0
  4. package/build/legacy/context/tabs.cjs +53 -24
  5. package/build/legacy/context/tabs.cjs.map +1 -1
  6. package/build/legacy/index.cjs +320 -371
  7. package/build/legacy/index.cjs.map +1 -1
  8. package/build/legacy/utils/index.cjs +21 -2
  9. package/build/legacy/utils/index.cjs.map +1 -1
  10. package/build/legacy/utils/localStorage.cjs +44 -0
  11. package/build/legacy/utils/localStorage.cjs.map +1 -0
  12. package/build/modern/_tsup-dts-rollup.d.ts +103 -107
  13. package/build/modern/{chunk-FRWNAVDM.js → chunk-77B4HFKT.js} +4 -4
  14. package/build/modern/{chunk-G7AGKII3.js → chunk-BHSYQCDV.js} +4 -4
  15. package/build/modern/{chunk-UTGEFJ3L.js → chunk-C5EHJUS5.js} +1 -1
  16. package/build/modern/{chunk-UTGEFJ3L.js.map → chunk-C5EHJUS5.js.map} +1 -1
  17. package/build/modern/chunk-FQLMPEYX.js +18 -0
  18. package/build/modern/chunk-FQLMPEYX.js.map +1 -0
  19. package/build/modern/chunk-N7O6D7BW.js +63 -0
  20. package/build/modern/chunk-N7O6D7BW.js.map +1 -0
  21. package/build/modern/chunk-RZ7NG77U.js +77 -0
  22. package/build/modern/chunk-RZ7NG77U.js.map +1 -0
  23. package/build/modern/{chunk-ECKJGCNH.js → chunk-T6U7AKKP.js} +4 -4
  24. package/build/modern/components/Tabs.client.js +18 -0
  25. package/build/modern/context/confirm-modal.js +2 -2
  26. package/build/modern/context/cta-modal.js +2 -2
  27. package/build/modern/context/prompt-modal.js +2 -2
  28. package/build/modern/context/tabs.js +2 -1
  29. package/build/modern/index.js +42 -40
  30. package/build/modern/index.js.map +1 -1
  31. package/build/modern/utils/index.js +8 -2
  32. package/build/modern/utils/localStorage.js +10 -0
  33. package/package.json +2 -2
  34. package/src/components/Tabs.client.tsx +113 -0
  35. package/src/context/tabs.tsx +66 -65
  36. package/src/index.ts +1 -4
  37. package/src/utils/index.ts +2 -0
  38. package/src/utils/localStorage.ts +28 -0
  39. package/build/legacy/aria-helpers/tabs.aria.cjs +0 -100
  40. package/build/legacy/aria-helpers/tabs.aria.cjs.map +0 -1
  41. package/build/legacy/components/Tab.cjs +0 -135
  42. package/build/legacy/components/Tab.cjs.map +0 -1
  43. package/build/legacy/components/TabList.cjs +0 -69
  44. package/build/legacy/components/TabList.cjs.map +0 -1
  45. package/build/legacy/components/TabPanel.cjs +0 -76
  46. package/build/legacy/components/TabPanel.cjs.map +0 -1
  47. package/build/modern/aria-helpers/tabs.aria.js +0 -9
  48. package/build/modern/chunk-AYIRV5CL.js +0 -32
  49. package/build/modern/chunk-AYIRV5CL.js.map +0 -1
  50. package/build/modern/chunk-ITOIXNJS.js +0 -64
  51. package/build/modern/chunk-ITOIXNJS.js.map +0 -1
  52. package/build/modern/chunk-RIFQSCHT.js +0 -58
  53. package/build/modern/chunk-RIFQSCHT.js.map +0 -1
  54. package/build/modern/chunk-SLF6SIPB.js +0 -46
  55. package/build/modern/chunk-SLF6SIPB.js.map +0 -1
  56. package/build/modern/chunk-UKPF7JOB.js +0 -33
  57. package/build/modern/chunk-UKPF7JOB.js.map +0 -1
  58. package/build/modern/components/Tab.js +0 -10
  59. package/build/modern/components/TabList.js +0 -9
  60. package/build/modern/components/TabList.js.map +0 -1
  61. package/build/modern/components/TabPanel.js +0 -10
  62. package/build/modern/components/TabPanel.js.map +0 -1
  63. package/src/aria-helpers/tabs.aria.ts +0 -70
  64. package/src/components/Tab.tsx +0 -68
  65. package/src/components/TabList.tsx +0 -51
  66. package/src/components/TabPanel.tsx +0 -49
  67. /package/build/modern/{chunk-FRWNAVDM.js.map → chunk-77B4HFKT.js.map} +0 -0
  68. /package/build/modern/{chunk-G7AGKII3.js.map → chunk-BHSYQCDV.js.map} +0 -0
  69. /package/build/modern/{chunk-ECKJGCNH.js.map → chunk-T6U7AKKP.js.map} +0 -0
  70. /package/build/modern/{aria-helpers/tabs.aria.js.map → components/Tabs.client.js.map} +0 -0
  71. /package/build/modern/{components/Tab.js.map → utils/localStorage.js.map} +0 -0
@@ -16,9 +16,6 @@ import {
16
16
  import {
17
17
  Button
18
18
  } from "./chunk-EXGKZGML.js";
19
- import {
20
- useModal
21
- } from "./chunk-KGQG5JGW.js";
22
19
  import {
23
20
  Avatar
24
21
  } from "./chunk-BU5JK37R.js";
@@ -31,6 +28,9 @@ import {
31
28
  import {
32
29
  $cerberusIcons
33
30
  } from "./chunk-DDOTCGGA.js";
31
+ import {
32
+ useModal
33
+ } from "./chunk-KGQG5JGW.js";
34
34
 
35
35
  // src/context/confirm-modal.tsx
36
36
  import {
@@ -170,4 +170,4 @@ export {
170
170
  ConfirmModal,
171
171
  useConfirmModal
172
172
  };
173
- //# sourceMappingURL=chunk-ECKJGCNH.js.map
173
+ //# sourceMappingURL=chunk-T6U7AKKP.js.map
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import {
3
+ Tab,
4
+ TabIndicator,
5
+ TabList,
6
+ TabPanel,
7
+ TabsList
8
+ } from "../chunk-N7O6D7BW.js";
9
+ import "../chunk-RZ7NG77U.js";
10
+ import "../chunk-FQLMPEYX.js";
11
+ export {
12
+ Tab,
13
+ TabIndicator,
14
+ TabList,
15
+ TabPanel,
16
+ TabsList
17
+ };
18
+ //# sourceMappingURL=Tabs.client.js.map
@@ -2,14 +2,13 @@
2
2
  import {
3
3
  ConfirmModal,
4
4
  useConfirmModal
5
- } from "../chunk-ECKJGCNH.js";
5
+ } from "../chunk-T6U7AKKP.js";
6
6
  import "../chunk-BE4EOU2P.js";
7
7
  import "../chunk-Q7BRMIBR.js";
8
8
  import "../chunk-XY6WL55R.js";
9
9
  import "../chunk-2UXE5PDG.js";
10
10
  import "../chunk-IQJDVFPP.js";
11
11
  import "../chunk-EXGKZGML.js";
12
- import "../chunk-KGQG5JGW.js";
13
12
  import "../chunk-BU5JK37R.js";
14
13
  import "../chunk-BUVVRQLZ.js";
15
14
  import "../chunk-JIZQFTW6.js";
@@ -17,6 +16,7 @@ import "../chunk-DDOTCGGA.js";
17
16
  import "../chunk-5KHU6MM5.js";
18
17
  import "../chunk-E3PAEB7Y.js";
19
18
  import "../chunk-HVKM54BA.js";
19
+ import "../chunk-KGQG5JGW.js";
20
20
  export {
21
21
  ConfirmModal,
22
22
  useConfirmModal
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CTAModal,
4
4
  useCTAModal
5
- } from "../chunk-FRWNAVDM.js";
5
+ } from "../chunk-77B4HFKT.js";
6
6
  import "../chunk-BE4EOU2P.js";
7
7
  import "../chunk-Q7BRMIBR.js";
8
8
  import "../chunk-XY6WL55R.js";
@@ -10,7 +10,6 @@ import "../chunk-2UXE5PDG.js";
10
10
  import "../chunk-IQJDVFPP.js";
11
11
  import "../chunk-APD6IX5R.js";
12
12
  import "../chunk-EXGKZGML.js";
13
- import "../chunk-KGQG5JGW.js";
14
13
  import "../chunk-BU5JK37R.js";
15
14
  import "../chunk-BUVVRQLZ.js";
16
15
  import "../chunk-JIZQFTW6.js";
@@ -18,6 +17,7 @@ import "../chunk-DDOTCGGA.js";
18
17
  import "../chunk-5KHU6MM5.js";
19
18
  import "../chunk-E3PAEB7Y.js";
20
19
  import "../chunk-HVKM54BA.js";
20
+ import "../chunk-KGQG5JGW.js";
21
21
  export {
22
22
  CTAModal,
23
23
  useCTAModal
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-G7AGKII3.js";
5
+ } from "../chunk-BHSYQCDV.js";
6
6
  import "../chunk-NMF2HYWO.js";
7
7
  import "../chunk-BE4EOU2P.js";
8
8
  import "../chunk-Q7BRMIBR.js";
@@ -12,7 +12,6 @@ import "../chunk-F7EWTOML.js";
12
12
  import "../chunk-IQJDVFPP.js";
13
13
  import "../chunk-UZDVOIW5.js";
14
14
  import "../chunk-EXGKZGML.js";
15
- import "../chunk-KGQG5JGW.js";
16
15
  import "../chunk-BU5JK37R.js";
17
16
  import "../chunk-BUVVRQLZ.js";
18
17
  import "../chunk-JIZQFTW6.js";
@@ -20,6 +19,7 @@ import "../chunk-DDOTCGGA.js";
20
19
  import "../chunk-5KHU6MM5.js";
21
20
  import "../chunk-E3PAEB7Y.js";
22
21
  import "../chunk-HVKM54BA.js";
22
+ import "../chunk-KGQG5JGW.js";
23
23
  export {
24
24
  PromptModal,
25
25
  usePromptModal
@@ -3,7 +3,8 @@ import {
3
3
  Tabs,
4
4
  TabsContext,
5
5
  useTabsContext
6
- } from "../chunk-RIFQSCHT.js";
6
+ } from "../chunk-RZ7NG77U.js";
7
+ import "../chunk-FQLMPEYX.js";
7
8
  export {
8
9
  Tabs,
9
10
  TabsContext,
@@ -1,15 +1,3 @@
1
- import {
2
- ThemeProvider,
3
- useThemeContext
4
- } from "./chunk-EB37HRCN.js";
5
- import {
6
- ConfirmModal,
7
- useConfirmModal
8
- } from "./chunk-ECKJGCNH.js";
9
- import {
10
- CTAModal,
11
- useCTAModal
12
- } from "./chunk-FRWNAVDM.js";
13
1
  import {
14
2
  NotificationCenter,
15
3
  useNotificationCenter
@@ -17,13 +5,11 @@ import {
17
5
  import {
18
6
  PromptModal,
19
7
  usePromptModal
20
- } from "./chunk-G7AGKII3.js";
8
+ } from "./chunk-BHSYQCDV.js";
21
9
  import {
22
- Tbody
23
- } from "./chunk-ZR37P4NZ.js";
24
- import {
25
- Td
26
- } from "./chunk-3R4TIF2X.js";
10
+ ThemeProvider,
11
+ useThemeContext
12
+ } from "./chunk-EB37HRCN.js";
27
13
  import {
28
14
  Text
29
15
  } from "./chunk-2ZNIYPDV.js";
@@ -42,6 +28,14 @@ import {
42
28
  import {
43
29
  Tooltip
44
30
  } from "./chunk-LPALHB6R.js";
31
+ import {
32
+ ConfirmModal,
33
+ useConfirmModal
34
+ } from "./chunk-T6U7AKKP.js";
35
+ import {
36
+ CTAModal,
37
+ useCTAModal
38
+ } from "./chunk-77B4HFKT.js";
45
39
  import {
46
40
  Option,
47
41
  Select
@@ -49,22 +43,31 @@ import {
49
43
  import {
50
44
  Spinner
51
45
  } from "./chunk-7SYJFI5E.js";
52
- import {
53
- Tab
54
- } from "./chunk-SLF6SIPB.js";
55
- import {
56
- TabList
57
- } from "./chunk-UKPF7JOB.js";
58
- import {
59
- TabPanel
60
- } from "./chunk-AYIRV5CL.js";
61
46
  import {
62
47
  Table,
63
48
  Tr
64
49
  } from "./chunk-B4CVET74.js";
50
+ import {
51
+ Tab,
52
+ TabIndicator,
53
+ TabList,
54
+ TabPanel,
55
+ TabsList
56
+ } from "./chunk-N7O6D7BW.js";
57
+ import {
58
+ Tabs,
59
+ TabsContext,
60
+ useTabsContext
61
+ } from "./chunk-RZ7NG77U.js";
65
62
  import {
66
63
  Tag
67
64
  } from "./chunk-F4LTOZAN.js";
65
+ import {
66
+ Tbody
67
+ } from "./chunk-ZR37P4NZ.js";
68
+ import {
69
+ Td
70
+ } from "./chunk-3R4TIF2X.js";
68
71
  import {
69
72
  NavMenuList,
70
73
  getPosition
@@ -191,9 +194,6 @@ import {
191
194
  import {
192
195
  Droppable
193
196
  } from "./chunk-TKI2CKHH.js";
194
- import {
195
- useModal
196
- } from "./chunk-KGQG5JGW.js";
197
197
  import {
198
198
  useRootColors
199
199
  } from "./chunk-RMVJK26W.js";
@@ -207,7 +207,11 @@ import {
207
207
  } from "./chunk-REO5GUNC.js";
208
208
  import {
209
209
  formatNotifyCount
210
- } from "./chunk-UTGEFJ3L.js";
210
+ } from "./chunk-C5EHJUS5.js";
211
+ import {
212
+ getLocalStorage,
213
+ setLocalStorage
214
+ } from "./chunk-FQLMPEYX.js";
211
215
  import {
212
216
  AccordionItemGroup
213
217
  } from "./chunk-F7XWOSN3.js";
@@ -233,14 +237,6 @@ import "./chunk-55J6XMHW.js";
233
237
  import {
234
238
  createNavTriggerProps
235
239
  } from "./chunk-JF76VIL3.js";
236
- import {
237
- useTabsKeyboardNavigation
238
- } from "./chunk-ITOIXNJS.js";
239
- import {
240
- Tabs,
241
- TabsContext,
242
- useTabsContext
243
- } from "./chunk-RIFQSCHT.js";
244
240
  import {
245
241
  trapFocus
246
242
  } from "./chunk-JIZQFTW6.js";
@@ -258,6 +254,9 @@ import {
258
254
  formatMilitaryToISO,
259
255
  useDate
260
256
  } from "./chunk-3BM6MZ4A.js";
257
+ import {
258
+ useModal
259
+ } from "./chunk-KGQG5JGW.js";
261
260
 
262
261
  // src/index.ts
263
262
  export * from "@dnd-kit/core";
@@ -340,11 +339,13 @@ export {
340
339
  Spinner,
341
340
  THEME_KEY,
342
341
  Tab,
342
+ TabIndicator,
343
343
  TabList,
344
344
  TabPanel,
345
345
  Table,
346
346
  Tabs,
347
347
  TabsContext,
348
+ TabsList,
348
349
  Tag,
349
350
  Tbody,
350
351
  Td,
@@ -362,8 +363,10 @@ export {
362
363
  formatMilitaryDate,
363
364
  formatMilitaryToISO,
364
365
  formatNotifyCount,
366
+ getLocalStorage,
365
367
  getPosition,
366
368
  processStatus,
369
+ setLocalStorage,
367
370
  trapFocus,
368
371
  useCTAModal,
369
372
  useConfirmModal,
@@ -376,7 +379,6 @@ export {
376
379
  usePromptModal,
377
380
  useRootColors,
378
381
  useTabsContext,
379
- useTabsKeyboardNavigation,
380
382
  useTheme,
381
383
  useThemeContext,
382
384
  useToggle
@@ -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/Accordion'\nexport * from './components/AccordionItemGroup'\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/DatePicker.client'\nexport * from './components/DatePicker.server'\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/Text'\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'\nexport * from './hooks/useRootColors'\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,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/Accordion'\nexport * from './components/AccordionItemGroup'\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/DatePicker.client'\nexport * from './components/DatePicker.server'\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/Tabs.client'\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/Text'\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'\nexport * from './hooks/useRootColors'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,cAAc;","names":[]}
@@ -1,7 +1,13 @@
1
1
  import {
2
2
  formatNotifyCount
3
- } from "../chunk-UTGEFJ3L.js";
3
+ } from "../chunk-C5EHJUS5.js";
4
+ import {
5
+ getLocalStorage,
6
+ setLocalStorage
7
+ } from "../chunk-FQLMPEYX.js";
4
8
  export {
5
- formatNotifyCount
9
+ formatNotifyCount,
10
+ getLocalStorage,
11
+ setLocalStorage
6
12
  };
7
13
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import {
3
+ getLocalStorage,
4
+ setLocalStorage
5
+ } from "../chunk-FQLMPEYX.js";
6
+ export {
7
+ getLocalStorage,
8
+ setLocalStorage
9
+ };
10
+ //# sourceMappingURL=localStorage.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.13.2-next-61259ca",
3
+ "version": "0.14.0-next-01a1b5e",
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.13.2-next-61259ca"
30
+ "@cerberus-design/styled-system": "0.14.0-next-01a1b5e"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -0,0 +1,113 @@
1
+ 'use client'
2
+
3
+ import { Tabs as ArkTabs } from '@ark-ui/react/tabs'
4
+ import { cx } from '@cerberus/styled-system/css'
5
+ import { useTabsContext } from '../context/tabs'
6
+
7
+ /**
8
+ * This module provides the Tabs family.
9
+ * @module
10
+ */
11
+
12
+ /**
13
+ * The tab list container for the Tabs group.
14
+ * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
15
+ * @example
16
+ * ```tsx
17
+ * <Tabs>
18
+ * <TabList description="Profile settings">
19
+ * <Tab value="overview">Overview</Tab>
20
+ * </TabList>
21
+ * <TabPanel tab="overview">...</TabPanel>
22
+ * </Tabs>
23
+ * ```
24
+ */
25
+ export function TabsList(props: ArkTabs.ListProps) {
26
+ const { children, ...tabsProps } = props
27
+ const { styles } = useTabsContext()
28
+
29
+ return (
30
+ <ArkTabs.List
31
+ {...tabsProps}
32
+ className={cx(tabsProps.className, styles.list)}
33
+ >
34
+ {children}
35
+ <TabIndicator />
36
+ </ArkTabs.List>
37
+ )
38
+ }
39
+
40
+ /**
41
+ * @deprecated Use `TabsList` instead.
42
+ */
43
+ export const TabList = TabsList
44
+
45
+ /**
46
+ * The trigger for the Tabs group.
47
+ * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
48
+ * @example
49
+ * ```tsx
50
+ * <Tabs>
51
+ * <TabList description="Profile settings">
52
+ * <Tab value="overview">Overview</Tab>
53
+ * </TabList>
54
+ * <TabPanel tab="overview">...</TabPanel>
55
+ * </Tabs>
56
+ * ```
57
+ */
58
+ export function Tab(props: ArkTabs.TriggerProps) {
59
+ const { styles } = useTabsContext()
60
+ return (
61
+ <ArkTabs.Trigger
62
+ {...props}
63
+ className={cx(props.className, styles.trigger)}
64
+ />
65
+ )
66
+ }
67
+
68
+ /**
69
+ * The indicator for the Tabs group which shows the active tab.
70
+ * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
71
+ * @example
72
+ * ```tsx
73
+ * <Tabs>
74
+ * <TabList description="Profile settings">
75
+ * <Tab value="overview">Overview</Tab>
76
+ * <TabsIndicator />
77
+ * </TabList>
78
+ * <TabPanel tab="overview">...</TabPanel>
79
+ * </Tabs>
80
+ * ```
81
+ */
82
+ export function TabIndicator(props: ArkTabs.IndicatorProps) {
83
+ const { styles } = useTabsContext()
84
+ return (
85
+ <ArkTabs.Indicator
86
+ {...props}
87
+ className={cx(props.className, styles.indicator)}
88
+ />
89
+ )
90
+ }
91
+
92
+ /**
93
+ * The content for the Tabs group.
94
+ * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
95
+ * @example
96
+ * ```tsx
97
+ * <Tabs>
98
+ * <TabList description="Profile settings">
99
+ * <Tab value="overview">Overview</Tab>
100
+ * </TabList>
101
+ * <TabPanel tab="overview">...</TabPanel>
102
+ * </Tabs>
103
+ * ```
104
+ */
105
+ export function TabPanel(props: ArkTabs.ContentProps) {
106
+ const { styles } = useTabsContext()
107
+ return (
108
+ <ArkTabs.Content
109
+ {...props}
110
+ className={cx(props.className, styles.content)}
111
+ />
112
+ )
113
+ }
@@ -1,17 +1,18 @@
1
1
  'use client'
2
2
 
3
+ import { Tabs as ArkTabs } from '@ark-ui/react/tabs'
3
4
  import { tabs, type TabsVariantProps } from '@cerberus/styled-system/recipes'
4
5
  import type { Pretty } from '@cerberus/styled-system/types'
5
6
  import {
6
7
  createContext,
8
+ useCallback,
7
9
  useContext,
8
10
  useEffect,
9
11
  useMemo,
10
- useRef,
11
12
  useState,
12
- type MutableRefObject,
13
13
  type PropsWithChildren,
14
14
  } from 'react'
15
+ import { getLocalStorage, setLocalStorage } from '../utils/localStorage'
15
16
 
16
17
  /**
17
18
  * This module provides a Tabs component and a hook to access its context.
@@ -19,103 +20,103 @@ import {
19
20
  */
20
21
 
21
22
  export interface TabsContextValue {
22
- /**
23
- * The ref for the tabs.
24
- */
25
- tabs: MutableRefObject<HTMLButtonElement[]>
26
- /**
27
- * The id of the tabs component.
28
- */
29
- id: string
30
- /**
31
- * The active tab id.
32
- */
33
- active: string
34
23
  /**
35
24
  * The styles for the tabs.
36
25
  */
37
- styles: Pretty<Record<'tabList' | 'tab' | 'tabPanel', string>>
38
- /**
39
- * Called when the active tab is updated.
40
- */
41
- onTabUpdate: (active: string) => void
26
+ styles: {
27
+ list: Pretty<string>
28
+ trigger: Pretty<string>
29
+ content: Pretty<string>
30
+ indicator: Pretty<string>
31
+ }
42
32
  }
43
33
 
44
34
  export const TabsContext = createContext<TabsContextValue | null>(null)
45
35
 
46
- export interface TabsProps {
36
+ export interface TabsProviderBaseProps extends ArkTabs.RootProps {
47
37
  /**
48
38
  * A unique identifier for the Tabs component. Typically used when there are
49
- * multiple Tabs components on the same page.
39
+ * multiple Tabs components on the same page and you want to uniquely cache
40
+ * the active tab state.
50
41
  */
51
- id?: string
42
+ uuid?: string
52
43
  /**
53
- * The default active tab id.
44
+ * The default tab to display when the component is first rendered.
54
45
  */
55
- active?: string
46
+ defaultValue?: string
56
47
  /**
57
48
  * Whether to cache the active tab state in local storage.
58
49
  */
59
50
  cache?: boolean
60
51
  }
61
52
 
53
+ export type TabsProviderProps = TabsProviderBaseProps & TabsVariantProps
54
+
62
55
  /**
63
56
  * The Tabs component provides a context to manage tab state.
64
- * @see https://cerberus.digitalu.design/react/tabs
57
+ * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
65
58
  * @example
66
59
  * ```tsx
67
60
  * <Tabs cache>
68
- * <TabList description="Button details">
69
- * <Tab id="overview">Overview</Tab>
70
- * <Tab id="guidelines">Guidelines</Tab>
71
- * </TabList>
72
- * <TabPanels>
73
- * <TabPanel id="overview">Overview content</TabPanel>
74
- * <TabPanel id="guidelines">Guidelines content</TabPanel>
75
- * </TabPanels>
61
+ * <TabsList>
62
+ * <Tab value="overview">Overview</Tab>
63
+ * <Tab value="guidelines">Guidelines</Tab>
64
+ * </TabsList>
65
+ * <TabPanel value="overview">Overview content</TabPanel>
66
+ * <TabPanel value="guidelines">Guidelines content</TabPanel>
76
67
  * </Tabs>
77
68
  * ```
78
69
  */
79
- export function Tabs(
80
- props: PropsWithChildren<TabsProps & TabsVariantProps>,
81
- ): JSX.Element {
82
- const { cache, active, id, palette } = props
83
- const [activeTab, setActiveTab] = useState(() => (cache ? '' : active ?? ''))
84
- const tabsList = useRef<HTMLButtonElement[]>([])
85
- const uuid = useMemo(() => {
86
- return id ? `cerberus-tabs-${id}` : 'cerberus-tabs'
87
- }, [id])
70
+ export function Tabs(props: PropsWithChildren<TabsProviderProps>): JSX.Element {
71
+ const { cache, defaultValue, palette, uuid, ...arkProps } = props
72
+ const [activeTab, setActiveTab] = useState<string | undefined>(() =>
73
+ cache ? '' : defaultValue,
74
+ )
75
+ const styles = tabs({ palette })
88
76
 
89
- const value = useMemo(
90
- () => ({
91
- tabs: tabsList,
92
- id: uuid,
93
- active: activeTab,
94
- styles: tabs({ palette }),
95
- onTabUpdate: setActiveTab,
96
- }),
97
- [activeTab, setActiveTab, palette, uuid, tabsList],
77
+ const cacheKey = useMemo(
78
+ () => (uuid ? `cerberus-tabs-${uuid}` : 'cerberus-tabs'),
79
+ [uuid],
98
80
  )
99
81
 
100
- // Get the active tab from local storage
101
- useEffect(() => {
102
- if (cache) {
103
- const cachedTab = window.localStorage.getItem(uuid)
104
- setActiveTab(
105
- cache ? cachedTab || (props.active ?? '') : props.active ?? '',
106
- )
107
- }
108
- }, [cache, active, uuid])
82
+ const handleValueChange = useCallback(
83
+ (details: { value: string }) => {
84
+ if (cache) {
85
+ setLocalStorage(cacheKey, details.value)
86
+ }
87
+ setActiveTab(details.value)
88
+ },
89
+ [cache],
90
+ )
109
91
 
110
- // Update the active tab in local storage
111
92
  useEffect(() => {
112
- if (cache && activeTab) {
113
- window.localStorage.setItem(uuid, activeTab)
93
+ if (cache && !activeTab) {
94
+ const cachedTab = getLocalStorage(cacheKey, defaultValue ?? '')
95
+ setActiveTab(cachedTab)
114
96
  }
115
- }, [activeTab, cache])
97
+ }, [cache, defaultValue, activeTab])
98
+
99
+ const value = useMemo(
100
+ () => ({
101
+ active: activeTab,
102
+ styles,
103
+ }),
104
+ [activeTab, palette, styles],
105
+ )
116
106
 
117
107
  return (
118
- <TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>
108
+ <TabsContext.Provider value={value}>
109
+ <ArkTabs.Root
110
+ {...arkProps}
111
+ aria-busy={!activeTab}
112
+ className={styles.root}
113
+ defaultValue={defaultValue}
114
+ onValueChange={handleValueChange}
115
+ value={activeTab}
116
+ >
117
+ {props.children}
118
+ </ArkTabs.Root>
119
+ </TabsContext.Provider>
119
120
  )
120
121
  }
121
122
 
package/src/index.ts CHANGED
@@ -41,9 +41,7 @@ export * from './components/ProgressBar'
41
41
  export * from './components/Radio'
42
42
  export * from './components/Select'
43
43
  export * from './components/Spinner'
44
- export * from './components/Tab'
45
- export * from './components/TabList'
46
- export * from './components/TabPanel'
44
+ export * from './components/Tabs.client'
47
45
  export * from './components/Table'
48
46
  export * from './components/Thead'
49
47
  export * from './components/Th'
@@ -79,7 +77,6 @@ export * from './hooks/useRootColors'
79
77
  // aria-helpers
80
78
 
81
79
  export * from './aria-helpers/nav-menu.aria'
82
- export * from './aria-helpers/tabs.aria'
83
80
  export * from './aria-helpers/trap-focus.aria'
84
81
 
85
82
  // utils