@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.
- package/build/legacy/_tsup-dts-rollup.d.cts +103 -107
- package/build/legacy/components/Tabs.client.cjs +104 -0
- package/build/legacy/components/Tabs.client.cjs.map +1 -0
- package/build/legacy/context/tabs.cjs +53 -24
- package/build/legacy/context/tabs.cjs.map +1 -1
- package/build/legacy/index.cjs +320 -371
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/utils/index.cjs +21 -2
- package/build/legacy/utils/index.cjs.map +1 -1
- package/build/legacy/utils/localStorage.cjs +44 -0
- package/build/legacy/utils/localStorage.cjs.map +1 -0
- package/build/modern/_tsup-dts-rollup.d.ts +103 -107
- package/build/modern/{chunk-FRWNAVDM.js → chunk-77B4HFKT.js} +4 -4
- package/build/modern/{chunk-G7AGKII3.js → chunk-BHSYQCDV.js} +4 -4
- package/build/modern/{chunk-UTGEFJ3L.js → chunk-C5EHJUS5.js} +1 -1
- package/build/modern/{chunk-UTGEFJ3L.js.map → chunk-C5EHJUS5.js.map} +1 -1
- package/build/modern/chunk-FQLMPEYX.js +18 -0
- package/build/modern/chunk-FQLMPEYX.js.map +1 -0
- package/build/modern/chunk-N7O6D7BW.js +63 -0
- package/build/modern/chunk-N7O6D7BW.js.map +1 -0
- package/build/modern/chunk-RZ7NG77U.js +77 -0
- package/build/modern/chunk-RZ7NG77U.js.map +1 -0
- package/build/modern/{chunk-ECKJGCNH.js → chunk-T6U7AKKP.js} +4 -4
- package/build/modern/components/Tabs.client.js +18 -0
- package/build/modern/context/confirm-modal.js +2 -2
- package/build/modern/context/cta-modal.js +2 -2
- package/build/modern/context/prompt-modal.js +2 -2
- package/build/modern/context/tabs.js +2 -1
- package/build/modern/index.js +42 -40
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +8 -2
- package/build/modern/utils/localStorage.js +10 -0
- package/package.json +2 -2
- package/src/components/Tabs.client.tsx +113 -0
- package/src/context/tabs.tsx +66 -65
- package/src/index.ts +1 -4
- package/src/utils/index.ts +2 -0
- package/src/utils/localStorage.ts +28 -0
- package/build/legacy/aria-helpers/tabs.aria.cjs +0 -100
- package/build/legacy/aria-helpers/tabs.aria.cjs.map +0 -1
- package/build/legacy/components/Tab.cjs +0 -135
- package/build/legacy/components/Tab.cjs.map +0 -1
- package/build/legacy/components/TabList.cjs +0 -69
- package/build/legacy/components/TabList.cjs.map +0 -1
- package/build/legacy/components/TabPanel.cjs +0 -76
- package/build/legacy/components/TabPanel.cjs.map +0 -1
- package/build/modern/aria-helpers/tabs.aria.js +0 -9
- package/build/modern/chunk-AYIRV5CL.js +0 -32
- package/build/modern/chunk-AYIRV5CL.js.map +0 -1
- package/build/modern/chunk-ITOIXNJS.js +0 -64
- package/build/modern/chunk-ITOIXNJS.js.map +0 -1
- package/build/modern/chunk-RIFQSCHT.js +0 -58
- package/build/modern/chunk-RIFQSCHT.js.map +0 -1
- package/build/modern/chunk-SLF6SIPB.js +0 -46
- package/build/modern/chunk-SLF6SIPB.js.map +0 -1
- package/build/modern/chunk-UKPF7JOB.js +0 -33
- package/build/modern/chunk-UKPF7JOB.js.map +0 -1
- package/build/modern/components/Tab.js +0 -10
- package/build/modern/components/TabList.js +0 -9
- package/build/modern/components/TabList.js.map +0 -1
- package/build/modern/components/TabPanel.js +0 -10
- package/build/modern/components/TabPanel.js.map +0 -1
- package/src/aria-helpers/tabs.aria.ts +0 -70
- package/src/components/Tab.tsx +0 -68
- package/src/components/TabList.tsx +0 -51
- package/src/components/TabPanel.tsx +0 -49
- /package/build/modern/{chunk-FRWNAVDM.js.map → chunk-77B4HFKT.js.map} +0 -0
- /package/build/modern/{chunk-G7AGKII3.js.map → chunk-BHSYQCDV.js.map} +0 -0
- /package/build/modern/{chunk-ECKJGCNH.js.map → chunk-T6U7AKKP.js.map} +0 -0
- /package/build/modern/{aria-helpers/tabs.aria.js.map → components/Tabs.client.js.map} +0 -0
- /package/build/modern/{components/Tab.js.map → utils/localStorage.js.map} +0 -0
|
@@ -20,15 +20,34 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/utils/index.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
-
formatNotifyCount: () => formatNotifyCount
|
|
23
|
+
formatNotifyCount: () => formatNotifyCount,
|
|
24
|
+
getLocalStorage: () => getLocalStorage,
|
|
25
|
+
setLocalStorage: () => setLocalStorage
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(utils_exports);
|
|
28
|
+
|
|
29
|
+
// src/utils/localStorage.ts
|
|
30
|
+
function getLocalStorage(key, defaultValue) {
|
|
31
|
+
const value = window.localStorage.getItem(key);
|
|
32
|
+
if (value) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
return defaultValue;
|
|
36
|
+
}
|
|
37
|
+
function setLocalStorage(key, value) {
|
|
38
|
+
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
39
|
+
window.localStorage.setItem(key, stringValue);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/utils/index.ts
|
|
26
43
|
function formatNotifyCount(count) {
|
|
27
44
|
if (count > 99) return "99+";
|
|
28
45
|
return count.toString();
|
|
29
46
|
}
|
|
30
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
48
|
0 && (module.exports = {
|
|
32
|
-
formatNotifyCount
|
|
49
|
+
formatNotifyCount,
|
|
50
|
+
getLocalStorage,
|
|
51
|
+
setLocalStorage
|
|
33
52
|
});
|
|
34
53
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["/**\n * This module contains utility functions that are used across your app.\n * @module Utils\n */\n\n/**\n * Formats the count of notifications to be displayed in the notification badge.\n * @param count - The number of notifications.\n * @returns The formatted count of notifications.\n * @example\n * ```tsx\n * const count = formatNotifyCount(100)\n * console.log(count) // '99+'\n * ```\n */\nexport function formatNotifyCount(count: number): string {\n if (count > 99) return '99+'\n return count.toString()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.ts","../../../src/utils/localStorage.ts"],"sourcesContent":["/**\n * This module contains utility functions that are used across your app.\n * @module Utils\n */\n\n/**\n * Formats the count of notifications to be displayed in the notification badge.\n * @param count - The number of notifications.\n * @returns The formatted count of notifications.\n * @example\n * ```tsx\n * const count = formatNotifyCount(100)\n * console.log(count) // '99+'\n * ```\n */\nexport function formatNotifyCount(count: number): string {\n if (count > 99) return '99+'\n return count.toString()\n}\n\nexport * from './localStorage'\n","'use client'\n\n/**\n * A utility function to get a value from local storage.\n * @param key The key to get from local storage.\n * @param defaultValue The fallback value if the key is not found.\n * @returns key or defaultValue\n */\nexport function getLocalStorage<T extends string>(\n key: string,\n defaultValue: T,\n): T {\n const value = window.localStorage.getItem(key)\n if (value) {\n return value as T\n }\n return defaultValue\n}\n\n/**\n * A utility function to set a value in local storage.\n * @param key The key to set in local storage.\n * @param value The value to set in local storage.\n */\nexport function setLocalStorage<T>(key: string, value: T): void {\n const stringValue = typeof value === 'string' ? value : JSON.stringify(value)\n window.localStorage.setItem(key, stringValue)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,SAAS,gBACd,KACA,cACG;AACH,QAAM,QAAQ,OAAO,aAAa,QAAQ,GAAG;AAC7C,MAAI,OAAO;AACT,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOO,SAAS,gBAAmB,KAAa,OAAgB;AAC9D,QAAM,cAAc,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;AAC5E,SAAO,aAAa,QAAQ,KAAK,WAAW;AAC9C;;;ADZO,SAAS,kBAAkB,OAAuB;AACvD,MAAI,QAAQ,GAAI,QAAO;AACvB,SAAO,MAAM,SAAS;AACxB;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/utils/localStorage.ts
|
|
22
|
+
var localStorage_exports = {};
|
|
23
|
+
__export(localStorage_exports, {
|
|
24
|
+
getLocalStorage: () => getLocalStorage,
|
|
25
|
+
setLocalStorage: () => setLocalStorage
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(localStorage_exports);
|
|
28
|
+
function getLocalStorage(key, defaultValue) {
|
|
29
|
+
const value = window.localStorage.getItem(key);
|
|
30
|
+
if (value) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
return defaultValue;
|
|
34
|
+
}
|
|
35
|
+
function setLocalStorage(key, value) {
|
|
36
|
+
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
37
|
+
window.localStorage.setItem(key, stringValue);
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getLocalStorage,
|
|
42
|
+
setLocalStorage
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=localStorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/localStorage.ts"],"sourcesContent":["'use client'\n\n/**\n * A utility function to get a value from local storage.\n * @param key The key to get from local storage.\n * @param defaultValue The fallback value if the key is not found.\n * @returns key or defaultValue\n */\nexport function getLocalStorage<T extends string>(\n key: string,\n defaultValue: T,\n): T {\n const value = window.localStorage.getItem(key)\n if (value) {\n return value as T\n }\n return defaultValue\n}\n\n/**\n * A utility function to set a value in local storage.\n * @param key The key to set in local storage.\n * @param value The value to set in local storage.\n */\nexport function setLocalStorage<T>(key: string, value: T): void {\n const stringValue = typeof value === 'string' ? value : JSON.stringify(value)\n window.localStorage.setItem(key, stringValue)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,gBACd,KACA,cACG;AACH,QAAM,QAAQ,OAAO,aAAa,QAAQ,GAAG;AAC7C,MAAI,OAAO;AACT,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOO,SAAS,gBAAmB,KAAa,OAAgB;AAC9D,QAAM,cAAc,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;AAC5E,SAAO,aAAa,QAAQ,KAAK,WAAW;AAC9C;","names":[]}
|
|
@@ -102,7 +102,6 @@ import { MouseEvent as MouseEvent_2 } from 'react';
|
|
|
102
102
|
import { MouseEventHandler } from 'react';
|
|
103
103
|
import { MouseSensor } from '@dnd-kit/core';
|
|
104
104
|
import { MouseSensorOptions } from '@dnd-kit/core';
|
|
105
|
-
import { MutableRefObject } from 'react';
|
|
106
105
|
import { NotificationVariantProps } from '@cerberus/styled-system/recipes';
|
|
107
106
|
import type { OptionHTMLAttributes } from 'react';
|
|
108
107
|
import { Over } from '@dnd-kit/core';
|
|
@@ -136,6 +135,7 @@ import { SensorResponse } from '@dnd-kit/core';
|
|
|
136
135
|
import { Sensors } from '@dnd-kit/core';
|
|
137
136
|
import type { SVGProps } from 'react';
|
|
138
137
|
import type { TableHTMLAttributes } from 'react';
|
|
138
|
+
import { Tabs as Tabs_2 } from '@ark-ui/react/tabs';
|
|
139
139
|
import { TabsVariantProps } from '@cerberus/styled-system/recipes';
|
|
140
140
|
import { TagVariantProps } from '@cerberus/styled-system/recipes';
|
|
141
141
|
import { TbodyVariantProps } from '@cerberus/styled-system/recipes';
|
|
@@ -1536,6 +1536,17 @@ export { getClientRect }
|
|
|
1536
1536
|
|
|
1537
1537
|
export { getFirstCollision }
|
|
1538
1538
|
|
|
1539
|
+
/**
|
|
1540
|
+
* A utility function to get a value from local storage.
|
|
1541
|
+
* @param key The key to get from local storage.
|
|
1542
|
+
* @param defaultValue The fallback value if the key is not found.
|
|
1543
|
+
* @returns key or defaultValue
|
|
1544
|
+
*/
|
|
1545
|
+
declare function getLocalStorage<T extends string>(key: string, defaultValue: T): T;
|
|
1546
|
+
export { getLocalStorage }
|
|
1547
|
+
export { getLocalStorage as getLocalStorage_alias_1 }
|
|
1548
|
+
export { getLocalStorage as getLocalStorage_alias_2 }
|
|
1549
|
+
|
|
1539
1550
|
/**
|
|
1540
1551
|
* @deprecated use the {@link Menu} family instead
|
|
1541
1552
|
*/
|
|
@@ -2614,6 +2625,16 @@ export { SensorResponse }
|
|
|
2614
2625
|
|
|
2615
2626
|
export { Sensors }
|
|
2616
2627
|
|
|
2628
|
+
/**
|
|
2629
|
+
* A utility function to set a value in local storage.
|
|
2630
|
+
* @param key The key to set in local storage.
|
|
2631
|
+
* @param value The value to set in local storage.
|
|
2632
|
+
*/
|
|
2633
|
+
declare function setLocalStorage<T>(key: string, value: T): void;
|
|
2634
|
+
export { setLocalStorage }
|
|
2635
|
+
export { setLocalStorage as setLocalStorage_alias_1 }
|
|
2636
|
+
export { setLocalStorage as setLocalStorage_alias_2 }
|
|
2637
|
+
|
|
2617
2638
|
/**
|
|
2618
2639
|
* This module contains the Avatar component.
|
|
2619
2640
|
* @module
|
|
@@ -2782,24 +2803,40 @@ export { StaticTagProps }
|
|
|
2782
2803
|
export { StaticTagProps as StaticTagProps_alias_1 }
|
|
2783
2804
|
|
|
2784
2805
|
/**
|
|
2785
|
-
* The
|
|
2786
|
-
* @definition [
|
|
2787
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
2788
|
-
* @memberof module:Tabs
|
|
2806
|
+
* The trigger for the Tabs group.
|
|
2807
|
+
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
2789
2808
|
* @example
|
|
2790
2809
|
* ```tsx
|
|
2791
2810
|
* <Tabs>
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
2811
|
+
* <TabList description="Profile settings">
|
|
2812
|
+
* <Tab value="overview">Overview</Tab>
|
|
2794
2813
|
* </TabList>
|
|
2795
2814
|
* <TabPanel tab="overview">...</TabPanel>
|
|
2796
2815
|
* </Tabs>
|
|
2797
2816
|
* ```
|
|
2798
2817
|
*/
|
|
2799
|
-
declare function Tab(props:
|
|
2818
|
+
declare function Tab(props: Tabs_2.TriggerProps): JSX_2.Element;
|
|
2800
2819
|
export { Tab }
|
|
2801
2820
|
export { Tab as Tab_alias_1 }
|
|
2802
2821
|
|
|
2822
|
+
/**
|
|
2823
|
+
* The indicator for the Tabs group which shows the active tab.
|
|
2824
|
+
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
2825
|
+
* @example
|
|
2826
|
+
* ```tsx
|
|
2827
|
+
* <Tabs>
|
|
2828
|
+
* <TabList description="Profile settings">
|
|
2829
|
+
* <Tab value="overview">Overview</Tab>
|
|
2830
|
+
* <TabsIndicator />
|
|
2831
|
+
* </TabList>
|
|
2832
|
+
* <TabPanel tab="overview">...</TabPanel>
|
|
2833
|
+
* </Tabs>
|
|
2834
|
+
* ```
|
|
2835
|
+
*/
|
|
2836
|
+
declare function TabIndicator(props: Tabs_2.IndicatorProps): JSX_2.Element;
|
|
2837
|
+
export { TabIndicator }
|
|
2838
|
+
export { TabIndicator as TabIndicator_alias_1 }
|
|
2839
|
+
|
|
2803
2840
|
/**
|
|
2804
2841
|
* An accessible table component.
|
|
2805
2842
|
* @definition [ARIA Table pattern](https://www.w3.org/WAI/ARIA/apg/patterns/table/)
|
|
@@ -2829,95 +2866,45 @@ export { TableProps }
|
|
|
2829
2866
|
export { TableProps as TableProps_alias_1 }
|
|
2830
2867
|
|
|
2831
2868
|
/**
|
|
2832
|
-
*
|
|
2833
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
2834
|
-
* @memberof module:Tabs
|
|
2835
|
-
* @example
|
|
2836
|
-
* ```tsx
|
|
2837
|
-
* <TabList description="Button details">
|
|
2838
|
-
* <Tab id="overview">Overview</Tab>
|
|
2839
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
2840
|
-
* </TabList>
|
|
2841
|
-
* ```
|
|
2869
|
+
* @deprecated Use `TabsList` instead.
|
|
2842
2870
|
*/
|
|
2843
|
-
declare
|
|
2871
|
+
declare const TabList: typeof TabsList;
|
|
2844
2872
|
export { TabList }
|
|
2845
2873
|
export { TabList as TabList_alias_1 }
|
|
2846
2874
|
|
|
2847
2875
|
/**
|
|
2848
|
-
*
|
|
2849
|
-
* @
|
|
2850
|
-
*/
|
|
2851
|
-
declare interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
2852
|
-
/**
|
|
2853
|
-
* A description of what the tab list contains. Required for accessibility.
|
|
2854
|
-
*/
|
|
2855
|
-
description: string;
|
|
2856
|
-
}
|
|
2857
|
-
export { TabListProps }
|
|
2858
|
-
export { TabListProps as TabListProps_alias_1 }
|
|
2859
|
-
|
|
2860
|
-
/**
|
|
2861
|
-
* The TabPanel component provides a panel element to be used in a Tabs
|
|
2862
|
-
* provider.
|
|
2863
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
2864
|
-
* @memberof module:Tabs
|
|
2876
|
+
* The content for the Tabs group.
|
|
2877
|
+
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
2865
2878
|
* @example
|
|
2866
2879
|
* ```tsx
|
|
2867
|
-
* <
|
|
2868
|
-
*
|
|
2869
|
-
* </
|
|
2880
|
+
* <Tabs>
|
|
2881
|
+
* <TabList description="Profile settings">
|
|
2882
|
+
* <Tab value="overview">Overview</Tab>
|
|
2883
|
+
* </TabList>
|
|
2884
|
+
* <TabPanel tab="overview">...</TabPanel>
|
|
2885
|
+
* </Tabs>
|
|
2870
2886
|
* ```
|
|
2871
2887
|
*/
|
|
2872
|
-
declare function TabPanel(props:
|
|
2888
|
+
declare function TabPanel(props: Tabs_2.ContentProps): JSX_2.Element;
|
|
2873
2889
|
export { TabPanel }
|
|
2874
2890
|
export { TabPanel as TabPanel_alias_1 }
|
|
2875
2891
|
|
|
2876
|
-
/**
|
|
2877
|
-
* This module provides a TabPanel component.
|
|
2878
|
-
* @module
|
|
2879
|
-
*/
|
|
2880
|
-
declare interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
2881
|
-
/**
|
|
2882
|
-
* The unique value of the Tab that is associated with the TabPanel.
|
|
2883
|
-
*/
|
|
2884
|
-
tab: string;
|
|
2885
|
-
}
|
|
2886
|
-
export { TabPanelProps }
|
|
2887
|
-
export { TabPanelProps as TabPanelProps_alias_1 }
|
|
2888
|
-
|
|
2889
|
-
/**
|
|
2890
|
-
* This module provides a Tab component.
|
|
2891
|
-
* @module
|
|
2892
|
-
*/
|
|
2893
|
-
declare interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
2894
|
-
/**
|
|
2895
|
-
* The id of the tab that will be tracked as the active tab and used for aria
|
|
2896
|
-
* attributes.
|
|
2897
|
-
*/
|
|
2898
|
-
value: string;
|
|
2899
|
-
}
|
|
2900
|
-
export { TabProps }
|
|
2901
|
-
export { TabProps as TabProps_alias_1 }
|
|
2902
|
-
|
|
2903
2892
|
/**
|
|
2904
2893
|
* The Tabs component provides a context to manage tab state.
|
|
2905
|
-
* @
|
|
2894
|
+
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
2906
2895
|
* @example
|
|
2907
2896
|
* ```tsx
|
|
2908
2897
|
* <Tabs cache>
|
|
2909
|
-
* <
|
|
2910
|
-
* <Tab
|
|
2911
|
-
* <Tab
|
|
2912
|
-
* </
|
|
2913
|
-
* <
|
|
2914
|
-
*
|
|
2915
|
-
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
2916
|
-
* </TabPanels>
|
|
2898
|
+
* <TabsList>
|
|
2899
|
+
* <Tab value="overview">Overview</Tab>
|
|
2900
|
+
* <Tab value="guidelines">Guidelines</Tab>
|
|
2901
|
+
* </TabsList>
|
|
2902
|
+
* <TabPanel value="overview">Overview content</TabPanel>
|
|
2903
|
+
* <TabPanel value="guidelines">Guidelines content</TabPanel>
|
|
2917
2904
|
* </Tabs>
|
|
2918
2905
|
* ```
|
|
2919
2906
|
*/
|
|
2920
|
-
declare function Tabs(props: PropsWithChildren<
|
|
2907
|
+
declare function Tabs(props: PropsWithChildren<TabsProviderProps>): JSX.Element;
|
|
2921
2908
|
export { Tabs }
|
|
2922
2909
|
export { Tabs as Tabs_alias_1 }
|
|
2923
2910
|
|
|
@@ -2930,47 +2917,62 @@ export { TabsContext as TabsContext_alias_1 }
|
|
|
2930
2917
|
* @module Tabs
|
|
2931
2918
|
*/
|
|
2932
2919
|
declare interface TabsContextValue {
|
|
2933
|
-
/**
|
|
2934
|
-
* The ref for the tabs.
|
|
2935
|
-
*/
|
|
2936
|
-
tabs: MutableRefObject<HTMLButtonElement[]>;
|
|
2937
|
-
/**
|
|
2938
|
-
* The id of the tabs component.
|
|
2939
|
-
*/
|
|
2940
|
-
id: string;
|
|
2941
|
-
/**
|
|
2942
|
-
* The active tab id.
|
|
2943
|
-
*/
|
|
2944
|
-
active: string;
|
|
2945
2920
|
/**
|
|
2946
2921
|
* The styles for the tabs.
|
|
2947
2922
|
*/
|
|
2948
|
-
styles:
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2923
|
+
styles: {
|
|
2924
|
+
list: Pretty<string>;
|
|
2925
|
+
trigger: Pretty<string>;
|
|
2926
|
+
content: Pretty<string>;
|
|
2927
|
+
indicator: Pretty<string>;
|
|
2928
|
+
};
|
|
2953
2929
|
}
|
|
2954
2930
|
export { TabsContextValue }
|
|
2955
2931
|
export { TabsContextValue as TabsContextValue_alias_1 }
|
|
2956
2932
|
|
|
2957
|
-
|
|
2933
|
+
/**
|
|
2934
|
+
* This module provides the Tabs family.
|
|
2935
|
+
* @module
|
|
2936
|
+
*/
|
|
2937
|
+
/**
|
|
2938
|
+
* The tab list container for the Tabs group.
|
|
2939
|
+
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
2940
|
+
* @example
|
|
2941
|
+
* ```tsx
|
|
2942
|
+
* <Tabs>
|
|
2943
|
+
* <TabList description="Profile settings">
|
|
2944
|
+
* <Tab value="overview">Overview</Tab>
|
|
2945
|
+
* </TabList>
|
|
2946
|
+
* <TabPanel tab="overview">...</TabPanel>
|
|
2947
|
+
* </Tabs>
|
|
2948
|
+
* ```
|
|
2949
|
+
*/
|
|
2950
|
+
declare function TabsList(props: Tabs_2.ListProps): JSX_2.Element;
|
|
2951
|
+
export { TabsList }
|
|
2952
|
+
export { TabsList as TabsList_alias_1 }
|
|
2953
|
+
|
|
2954
|
+
declare interface TabsProviderBaseProps extends Tabs_2.RootProps {
|
|
2958
2955
|
/**
|
|
2959
2956
|
* A unique identifier for the Tabs component. Typically used when there are
|
|
2960
|
-
* multiple Tabs components on the same page
|
|
2957
|
+
* multiple Tabs components on the same page and you want to uniquely cache
|
|
2958
|
+
* the active tab state.
|
|
2961
2959
|
*/
|
|
2962
|
-
|
|
2960
|
+
uuid?: string;
|
|
2963
2961
|
/**
|
|
2964
|
-
* The default
|
|
2962
|
+
* The default tab to display when the component is first rendered.
|
|
2965
2963
|
*/
|
|
2966
|
-
|
|
2964
|
+
defaultValue?: string;
|
|
2967
2965
|
/**
|
|
2968
2966
|
* Whether to cache the active tab state in local storage.
|
|
2969
2967
|
*/
|
|
2970
2968
|
cache?: boolean;
|
|
2971
2969
|
}
|
|
2972
|
-
export {
|
|
2973
|
-
export {
|
|
2970
|
+
export { TabsProviderBaseProps }
|
|
2971
|
+
export { TabsProviderBaseProps as TabsProviderBaseProps_alias_1 }
|
|
2972
|
+
|
|
2973
|
+
declare type TabsProviderProps = TabsProviderBaseProps & TabsVariantProps;
|
|
2974
|
+
export { TabsProviderProps }
|
|
2975
|
+
export { TabsProviderProps as TabsProviderProps_alias_1 }
|
|
2974
2976
|
|
|
2975
2977
|
/**
|
|
2976
2978
|
* The Tag component is used to display a meta descriptions.
|
|
@@ -3522,12 +3524,6 @@ declare function useTabsContext(): TabsContextValue;
|
|
|
3522
3524
|
export { useTabsContext }
|
|
3523
3525
|
export { useTabsContext as useTabsContext_alias_1 }
|
|
3524
3526
|
|
|
3525
|
-
declare function useTabsKeyboardNavigation(): {
|
|
3526
|
-
ref: (tab: HTMLButtonElement) => void;
|
|
3527
|
-
};
|
|
3528
|
-
export { useTabsKeyboardNavigation }
|
|
3529
|
-
export { useTabsKeyboardNavigation as useTabsKeyboardNavigation_alias_1 }
|
|
3530
|
-
|
|
3531
3527
|
/**
|
|
3532
3528
|
* Provides a hook for using the theme for a single instance of the application.
|
|
3533
3529
|
* @see https://cerberus.digitalu.design/react/use-theme
|
|
@@ -19,9 +19,6 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
Button
|
|
21
21
|
} from "./chunk-EXGKZGML.js";
|
|
22
|
-
import {
|
|
23
|
-
useModal
|
|
24
|
-
} from "./chunk-KGQG5JGW.js";
|
|
25
22
|
import {
|
|
26
23
|
Avatar
|
|
27
24
|
} from "./chunk-BU5JK37R.js";
|
|
@@ -34,6 +31,9 @@ import {
|
|
|
34
31
|
import {
|
|
35
32
|
$cerberusIcons
|
|
36
33
|
} from "./chunk-DDOTCGGA.js";
|
|
34
|
+
import {
|
|
35
|
+
useModal
|
|
36
|
+
} from "./chunk-KGQG5JGW.js";
|
|
37
37
|
|
|
38
38
|
// src/context/cta-modal.tsx
|
|
39
39
|
import {
|
|
@@ -151,4 +151,4 @@ export {
|
|
|
151
151
|
CTAModal,
|
|
152
152
|
useCTAModal
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-77B4HFKT.js.map
|
|
@@ -25,9 +25,6 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
Button
|
|
27
27
|
} from "./chunk-EXGKZGML.js";
|
|
28
|
-
import {
|
|
29
|
-
useModal
|
|
30
|
-
} from "./chunk-KGQG5JGW.js";
|
|
31
28
|
import {
|
|
32
29
|
Avatar
|
|
33
30
|
} from "./chunk-BU5JK37R.js";
|
|
@@ -40,6 +37,9 @@ import {
|
|
|
40
37
|
import {
|
|
41
38
|
$cerberusIcons
|
|
42
39
|
} from "./chunk-DDOTCGGA.js";
|
|
40
|
+
import {
|
|
41
|
+
useModal
|
|
42
|
+
} from "./chunk-KGQG5JGW.js";
|
|
43
43
|
|
|
44
44
|
// src/context/prompt-modal.tsx
|
|
45
45
|
import {
|
|
@@ -240,4 +240,4 @@ export {
|
|
|
240
240
|
PromptModal,
|
|
241
241
|
usePromptModal
|
|
242
242
|
};
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-BHSYQCDV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["/**\n * This module contains utility functions that are used across your app.\n * @module Utils\n */\n\n/**\n * Formats the count of notifications to be displayed in the notification badge.\n * @param count - The number of notifications.\n * @returns The formatted count of notifications.\n * @example\n * ```tsx\n * const count = formatNotifyCount(100)\n * console.log(count) // '99+'\n * ```\n */\nexport function formatNotifyCount(count: number): string {\n if (count > 99) return '99+'\n return count.toString()\n}\n"],"mappings":";AAeO,SAAS,kBAAkB,OAAuB;AACvD,MAAI,QAAQ,GAAI,QAAO;AACvB,SAAO,MAAM,SAAS;AACxB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["/**\n * This module contains utility functions that are used across your app.\n * @module Utils\n */\n\n/**\n * Formats the count of notifications to be displayed in the notification badge.\n * @param count - The number of notifications.\n * @returns The formatted count of notifications.\n * @example\n * ```tsx\n * const count = formatNotifyCount(100)\n * console.log(count) // '99+'\n * ```\n */\nexport function formatNotifyCount(count: number): string {\n if (count > 99) return '99+'\n return count.toString()\n}\n\nexport * from './localStorage'\n"],"mappings":";AAeO,SAAS,kBAAkB,OAAuB;AACvD,MAAI,QAAQ,GAAI,QAAO;AACvB,SAAO,MAAM,SAAS;AACxB;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/utils/localStorage.ts
|
|
2
|
+
function getLocalStorage(key, defaultValue) {
|
|
3
|
+
const value = window.localStorage.getItem(key);
|
|
4
|
+
if (value) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
return defaultValue;
|
|
8
|
+
}
|
|
9
|
+
function setLocalStorage(key, value) {
|
|
10
|
+
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
11
|
+
window.localStorage.setItem(key, stringValue);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
getLocalStorage,
|
|
16
|
+
setLocalStorage
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-FQLMPEYX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/localStorage.ts"],"sourcesContent":["'use client'\n\n/**\n * A utility function to get a value from local storage.\n * @param key The key to get from local storage.\n * @param defaultValue The fallback value if the key is not found.\n * @returns key or defaultValue\n */\nexport function getLocalStorage<T extends string>(\n key: string,\n defaultValue: T,\n): T {\n const value = window.localStorage.getItem(key)\n if (value) {\n return value as T\n }\n return defaultValue\n}\n\n/**\n * A utility function to set a value in local storage.\n * @param key The key to set in local storage.\n * @param value The value to set in local storage.\n */\nexport function setLocalStorage<T>(key: string, value: T): void {\n const stringValue = typeof value === 'string' ? value : JSON.stringify(value)\n window.localStorage.setItem(key, stringValue)\n}\n"],"mappings":";AAQO,SAAS,gBACd,KACA,cACG;AACH,QAAM,QAAQ,OAAO,aAAa,QAAQ,GAAG;AAC7C,MAAI,OAAO;AACT,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOO,SAAS,gBAAmB,KAAa,OAAgB;AAC9D,QAAM,cAAc,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;AAC5E,SAAO,aAAa,QAAQ,KAAK,WAAW;AAC9C;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTabsContext
|
|
3
|
+
} from "./chunk-RZ7NG77U.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Tabs.client.tsx
|
|
6
|
+
import { Tabs as ArkTabs } from "@ark-ui/react/tabs";
|
|
7
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function TabsList(props) {
|
|
10
|
+
const { children, ...tabsProps } = props;
|
|
11
|
+
const { styles } = useTabsContext();
|
|
12
|
+
return /* @__PURE__ */ jsxs(
|
|
13
|
+
ArkTabs.List,
|
|
14
|
+
{
|
|
15
|
+
...tabsProps,
|
|
16
|
+
className: cx(tabsProps.className, styles.list),
|
|
17
|
+
children: [
|
|
18
|
+
children,
|
|
19
|
+
/* @__PURE__ */ jsx(TabIndicator, {})
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
var TabList = TabsList;
|
|
25
|
+
function Tab(props) {
|
|
26
|
+
const { styles } = useTabsContext();
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
ArkTabs.Trigger,
|
|
29
|
+
{
|
|
30
|
+
...props,
|
|
31
|
+
className: cx(props.className, styles.trigger)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function TabIndicator(props) {
|
|
36
|
+
const { styles } = useTabsContext();
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
ArkTabs.Indicator,
|
|
39
|
+
{
|
|
40
|
+
...props,
|
|
41
|
+
className: cx(props.className, styles.indicator)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function TabPanel(props) {
|
|
46
|
+
const { styles } = useTabsContext();
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
ArkTabs.Content,
|
|
49
|
+
{
|
|
50
|
+
...props,
|
|
51
|
+
className: cx(props.className, styles.content)
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
TabsList,
|
|
58
|
+
TabList,
|
|
59
|
+
Tab,
|
|
60
|
+
TabIndicator,
|
|
61
|
+
TabPanel
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=chunk-N7O6D7BW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tabs.client.tsx"],"sourcesContent":["'use client'\n\nimport { Tabs as ArkTabs } from '@ark-ui/react/tabs'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useTabsContext } from '../context/tabs'\n\n/**\n * This module provides the Tabs family.\n * @module\n */\n\n/**\n * The tab list container for the Tabs group.\n * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)\n * @example\n * ```tsx\n * <Tabs>\n * <TabList description=\"Profile settings\">\n * <Tab value=\"overview\">Overview</Tab>\n * </TabList>\n * <TabPanel tab=\"overview\">...</TabPanel>\n * </Tabs>\n * ```\n */\nexport function TabsList(props: ArkTabs.ListProps) {\n const { children, ...tabsProps } = props\n const { styles } = useTabsContext()\n\n return (\n <ArkTabs.List\n {...tabsProps}\n className={cx(tabsProps.className, styles.list)}\n >\n {children}\n <TabIndicator />\n </ArkTabs.List>\n )\n}\n\n/**\n * @deprecated Use `TabsList` instead.\n */\nexport const TabList = TabsList\n\n/**\n * The trigger for the Tabs group.\n * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)\n * @example\n * ```tsx\n * <Tabs>\n * <TabList description=\"Profile settings\">\n * <Tab value=\"overview\">Overview</Tab>\n * </TabList>\n * <TabPanel tab=\"overview\">...</TabPanel>\n * </Tabs>\n * ```\n */\nexport function Tab(props: ArkTabs.TriggerProps) {\n const { styles } = useTabsContext()\n return (\n <ArkTabs.Trigger\n {...props}\n className={cx(props.className, styles.trigger)}\n />\n )\n}\n\n/**\n * The indicator for the Tabs group which shows the active tab.\n * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)\n * @example\n * ```tsx\n * <Tabs>\n * <TabList description=\"Profile settings\">\n * <Tab value=\"overview\">Overview</Tab>\n * <TabsIndicator />\n * </TabList>\n * <TabPanel tab=\"overview\">...</TabPanel>\n * </Tabs>\n * ```\n */\nexport function TabIndicator(props: ArkTabs.IndicatorProps) {\n const { styles } = useTabsContext()\n return (\n <ArkTabs.Indicator\n {...props}\n className={cx(props.className, styles.indicator)}\n />\n )\n}\n\n/**\n * The content for the Tabs group.\n * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)\n * @example\n * ```tsx\n * <Tabs>\n * <TabList description=\"Profile settings\">\n * <Tab value=\"overview\">Overview</Tab>\n * </TabList>\n * <TabPanel tab=\"overview\">...</TabPanel>\n * </Tabs>\n * ```\n */\nexport function TabPanel(props: ArkTabs.ContentProps) {\n const { styles } = useTabsContext()\n return (\n <ArkTabs.Content\n {...props}\n className={cx(props.className, styles.content)}\n />\n )\n}\n"],"mappings":";;;;;AAEA,SAAS,QAAQ,eAAe;AAChC,SAAS,UAAU;AA0Bf,SAKE,KALF;AALG,SAAS,SAAS,OAA0B;AACjD,QAAM,EAAE,UAAU,GAAG,UAAU,IAAI;AACnC,QAAM,EAAE,OAAO,IAAI,eAAe;AAElC,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,UAAU,WAAW,OAAO,IAAI;AAAA,MAE7C;AAAA;AAAA,QACD,oBAAC,gBAAa;AAAA;AAAA;AAAA,EAChB;AAEJ;AAKO,IAAM,UAAU;AAehB,SAAS,IAAI,OAA6B;AAC/C,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,OAAO,OAAO;AAAA;AAAA,EAC/C;AAEJ;AAgBO,SAAS,aAAa,OAA+B;AAC1D,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,OAAO,SAAS;AAAA;AAAA,EACjD;AAEJ;AAeO,SAAS,SAAS,OAA6B;AACpD,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,OAAO,OAAO;AAAA;AAAA,EAC/C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLocalStorage,
|
|
3
|
+
setLocalStorage
|
|
4
|
+
} from "./chunk-FQLMPEYX.js";
|
|
5
|
+
|
|
6
|
+
// src/context/tabs.tsx
|
|
7
|
+
import { Tabs as ArkTabs } from "@ark-ui/react/tabs";
|
|
8
|
+
import { tabs } from "@cerberus/styled-system/recipes";
|
|
9
|
+
import {
|
|
10
|
+
createContext,
|
|
11
|
+
useCallback,
|
|
12
|
+
useContext,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
var TabsContext = createContext(null);
|
|
19
|
+
function Tabs(props) {
|
|
20
|
+
const { cache, defaultValue, palette, uuid, ...arkProps } = props;
|
|
21
|
+
const [activeTab, setActiveTab] = useState(
|
|
22
|
+
() => cache ? "" : defaultValue
|
|
23
|
+
);
|
|
24
|
+
const styles = tabs({ palette });
|
|
25
|
+
const cacheKey = useMemo(
|
|
26
|
+
() => uuid ? `cerberus-tabs-${uuid}` : "cerberus-tabs",
|
|
27
|
+
[uuid]
|
|
28
|
+
);
|
|
29
|
+
const handleValueChange = useCallback(
|
|
30
|
+
(details) => {
|
|
31
|
+
if (cache) {
|
|
32
|
+
setLocalStorage(cacheKey, details.value);
|
|
33
|
+
}
|
|
34
|
+
setActiveTab(details.value);
|
|
35
|
+
},
|
|
36
|
+
[cache]
|
|
37
|
+
);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (cache && !activeTab) {
|
|
40
|
+
const cachedTab = getLocalStorage(cacheKey, defaultValue ?? "");
|
|
41
|
+
setActiveTab(cachedTab);
|
|
42
|
+
}
|
|
43
|
+
}, [cache, defaultValue, activeTab]);
|
|
44
|
+
const value = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
active: activeTab,
|
|
47
|
+
styles
|
|
48
|
+
}),
|
|
49
|
+
[activeTab, palette, styles]
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
52
|
+
ArkTabs.Root,
|
|
53
|
+
{
|
|
54
|
+
...arkProps,
|
|
55
|
+
"aria-busy": !activeTab,
|
|
56
|
+
className: styles.root,
|
|
57
|
+
defaultValue,
|
|
58
|
+
onValueChange: handleValueChange,
|
|
59
|
+
value: activeTab,
|
|
60
|
+
children: props.children
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
}
|
|
64
|
+
function useTabsContext() {
|
|
65
|
+
const context = useContext(TabsContext);
|
|
66
|
+
if (!context) {
|
|
67
|
+
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
68
|
+
}
|
|
69
|
+
return context;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
TabsContext,
|
|
74
|
+
Tabs,
|
|
75
|
+
useTabsContext
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chunk-RZ7NG77U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/tabs.tsx"],"sourcesContent":["'use client'\n\nimport { Tabs as ArkTabs } from '@ark-ui/react/tabs'\nimport { tabs, type TabsVariantProps } from '@cerberus/styled-system/recipes'\nimport type { Pretty } from '@cerberus/styled-system/types'\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type PropsWithChildren,\n} from 'react'\nimport { getLocalStorage, setLocalStorage } from '../utils/localStorage'\n\n/**\n * This module provides a Tabs component and a hook to access its context.\n * @module Tabs\n */\n\nexport interface TabsContextValue {\n /**\n * The styles for the tabs.\n */\n styles: {\n list: Pretty<string>\n trigger: Pretty<string>\n content: Pretty<string>\n indicator: Pretty<string>\n }\n}\n\nexport const TabsContext = createContext<TabsContextValue | null>(null)\n\nexport interface TabsProviderBaseProps extends ArkTabs.RootProps {\n /**\n * A unique identifier for the Tabs component. Typically used when there are\n * multiple Tabs components on the same page and you want to uniquely cache\n * the active tab state.\n */\n uuid?: string\n /**\n * The default tab to display when the component is first rendered.\n */\n defaultValue?: string\n /**\n * Whether to cache the active tab state in local storage.\n */\n cache?: boolean\n}\n\nexport type TabsProviderProps = TabsProviderBaseProps & TabsVariantProps\n\n/**\n * The Tabs component provides a context to manage tab state.\n * @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)\n * @example\n * ```tsx\n * <Tabs cache>\n * <TabsList>\n * <Tab value=\"overview\">Overview</Tab>\n * <Tab value=\"guidelines\">Guidelines</Tab>\n * </TabsList>\n * <TabPanel value=\"overview\">Overview content</TabPanel>\n * <TabPanel value=\"guidelines\">Guidelines content</TabPanel>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: PropsWithChildren<TabsProviderProps>): JSX.Element {\n const { cache, defaultValue, palette, uuid, ...arkProps } = props\n const [activeTab, setActiveTab] = useState<string | undefined>(() =>\n cache ? '' : defaultValue,\n )\n const styles = tabs({ palette })\n\n const cacheKey = useMemo(\n () => (uuid ? `cerberus-tabs-${uuid}` : 'cerberus-tabs'),\n [uuid],\n )\n\n const handleValueChange = useCallback(\n (details: { value: string }) => {\n if (cache) {\n setLocalStorage(cacheKey, details.value)\n }\n setActiveTab(details.value)\n },\n [cache],\n )\n\n useEffect(() => {\n if (cache && !activeTab) {\n const cachedTab = getLocalStorage(cacheKey, defaultValue ?? '')\n setActiveTab(cachedTab)\n }\n }, [cache, defaultValue, activeTab])\n\n const value = useMemo(\n () => ({\n active: activeTab,\n styles,\n }),\n [activeTab, palette, styles],\n )\n\n return (\n <TabsContext.Provider value={value}>\n <ArkTabs.Root\n {...arkProps}\n aria-busy={!activeTab}\n className={styles.root}\n defaultValue={defaultValue}\n onValueChange={handleValueChange}\n value={activeTab}\n >\n {props.children}\n </ArkTabs.Root>\n </TabsContext.Provider>\n )\n}\n\n/**\n * Used to access the tabs context.\n * @returns The tabs context.\n */\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs Provider.')\n }\n return context\n}\n"],"mappings":";;;;;;AAEA,SAAS,QAAQ,eAAe;AAChC,SAAS,YAAmC;AAE5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA+FD;AA3EC,IAAM,cAAc,cAAuC,IAAI;AAoC/D,SAAS,KAAK,OAA0D;AAC7E,QAAM,EAAE,OAAO,cAAc,SAAS,MAAM,GAAG,SAAS,IAAI;AAC5D,QAAM,CAAC,WAAW,YAAY,IAAI;AAAA,IAA6B,MAC7D,QAAQ,KAAK;AAAA,EACf;AACA,QAAM,SAAS,KAAK,EAAE,QAAQ,CAAC;AAE/B,QAAM,WAAW;AAAA,IACf,MAAO,OAAO,iBAAiB,IAAI,KAAK;AAAA,IACxC,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,YAA+B;AAC9B,UAAI,OAAO;AACT,wBAAgB,UAAU,QAAQ,KAAK;AAAA,MACzC;AACA,mBAAa,QAAQ,KAAK;AAAA,IAC5B;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,YAAU,MAAM;AACd,QAAI,SAAS,CAAC,WAAW;AACvB,YAAM,YAAY,gBAAgB,UAAU,gBAAgB,EAAE;AAC9D,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,OAAO,cAAc,SAAS,CAAC;AAEnC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,IACA,CAAC,WAAW,SAAS,MAAM;AAAA,EAC7B;AAEA,SACE,oBAAC,YAAY,UAAZ,EAAqB,OACpB;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACE,GAAG;AAAA,MACJ,aAAW,CAAC;AAAA,MACZ,WAAW,OAAO;AAAA,MAClB;AAAA,MACA,eAAe;AAAA,MACf,OAAO;AAAA,MAEN,gBAAM;AAAA;AAAA,EACT,GACF;AAEJ;AAMO,SAAS,iBAAmC;AACjD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|