@cerberus-design/react 0.13.1-next-394d7c4 → 0.13.1-next-8e40fb6
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 +13 -14
- package/build/legacy/components/Portal.cjs +2 -6
- package/build/legacy/components/Portal.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +22 -25
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +20 -23
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +10 -13
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +29 -32
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/hooks/useRootColors.cjs +21 -6
- package/build/legacy/hooks/useRootColors.cjs.map +1 -1
- package/build/legacy/index.cjs +106 -94
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +13 -14
- package/build/modern/{chunk-B3LRHIEG.js → chunk-3XGLNXJJ.js} +2 -2
- package/build/modern/{chunk-S6JWPDB4.js → chunk-FBSESDWJ.js} +2 -2
- package/build/modern/{chunk-FHS7VVGN.js → chunk-GRUXP3NG.js} +2 -2
- package/build/modern/chunk-IQJDVFPP.js +10 -0
- package/build/modern/chunk-IQJDVFPP.js.map +1 -0
- package/build/modern/chunk-RMVJK26W.js +39 -0
- package/build/modern/chunk-RMVJK26W.js.map +1 -0
- package/build/modern/{chunk-SRPSJGNI.js → chunk-WFJWCZ7E.js} +2 -2
- package/build/modern/components/Portal.js +1 -2
- package/build/modern/context/confirm-modal.js +2 -2
- package/build/modern/context/cta-modal.js +2 -2
- package/build/modern/context/notification-center.js +2 -2
- package/build/modern/context/prompt-modal.js +2 -2
- package/build/modern/hooks/useRootColors.js +1 -1
- package/build/modern/index.js +6 -6
- package/package.json +3 -3
- package/src/components/Portal.tsx +6 -19
- package/src/hooks/useRootColors.ts +36 -12
- package/build/modern/chunk-K2PSHGS7.js +0 -11
- package/build/modern/chunk-K2PSHGS7.js.map +0 -1
- package/build/modern/chunk-RO4AJOVX.js +0 -24
- package/build/modern/chunk-RO4AJOVX.js.map +0 -1
- /package/build/modern/{chunk-B3LRHIEG.js.map → chunk-3XGLNXJJ.js.map} +0 -0
- /package/build/modern/{chunk-S6JWPDB4.js.map → chunk-FBSESDWJ.js.map} +0 -0
- /package/build/modern/{chunk-FHS7VVGN.js.map → chunk-GRUXP3NG.js.map} +0 -0
- /package/build/modern/{chunk-SRPSJGNI.js.map → chunk-WFJWCZ7E.js.map} +0 -0
package/build/legacy/index.cjs
CHANGED
|
@@ -1727,11 +1727,8 @@ function NotificationDescription(props) {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
|
|
1729
1729
|
// src/components/Portal.tsx
|
|
1730
|
-
var
|
|
1731
|
-
|
|
1732
|
-
const container = props.container || document.body;
|
|
1733
|
-
return (0, import_react_dom.createPortal)(props.children, container, props.key);
|
|
1734
|
-
}
|
|
1730
|
+
var import_react12 = require("@ark-ui/react");
|
|
1731
|
+
var Portal = import_react12.Portal;
|
|
1735
1732
|
|
|
1736
1733
|
// src/components/Radio.tsx
|
|
1737
1734
|
var import_css28 = require("@cerberus/styled-system/css");
|
|
@@ -1899,21 +1896,21 @@ function Spinner(props) {
|
|
|
1899
1896
|
}
|
|
1900
1897
|
|
|
1901
1898
|
// src/components/Tab.tsx
|
|
1902
|
-
var
|
|
1899
|
+
var import_react15 = require("react");
|
|
1903
1900
|
|
|
1904
1901
|
// src/context/tabs.tsx
|
|
1905
1902
|
var import_recipes24 = require("@cerberus/styled-system/recipes");
|
|
1906
|
-
var
|
|
1903
|
+
var import_react13 = require("react");
|
|
1907
1904
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1908
|
-
var TabsContext = (0,
|
|
1905
|
+
var TabsContext = (0, import_react13.createContext)(null);
|
|
1909
1906
|
function Tabs(props) {
|
|
1910
1907
|
const { cache, active, id, palette } = props;
|
|
1911
|
-
const [activeTab, setActiveTab] = (0,
|
|
1912
|
-
const tabsList = (0,
|
|
1913
|
-
const uuid = (0,
|
|
1908
|
+
const [activeTab, setActiveTab] = (0, import_react13.useState)(() => cache ? "" : active ?? "");
|
|
1909
|
+
const tabsList = (0, import_react13.useRef)([]);
|
|
1910
|
+
const uuid = (0, import_react13.useMemo)(() => {
|
|
1914
1911
|
return id ? `cerberus-tabs-${id}` : "cerberus-tabs";
|
|
1915
1912
|
}, [id]);
|
|
1916
|
-
const value = (0,
|
|
1913
|
+
const value = (0, import_react13.useMemo)(
|
|
1917
1914
|
() => ({
|
|
1918
1915
|
tabs: tabsList,
|
|
1919
1916
|
id: uuid,
|
|
@@ -1923,7 +1920,7 @@ function Tabs(props) {
|
|
|
1923
1920
|
}),
|
|
1924
1921
|
[activeTab, setActiveTab, palette, uuid, tabsList]
|
|
1925
1922
|
);
|
|
1926
|
-
(0,
|
|
1923
|
+
(0, import_react13.useEffect)(() => {
|
|
1927
1924
|
if (cache) {
|
|
1928
1925
|
const cachedTab = window.localStorage.getItem(uuid);
|
|
1929
1926
|
setActiveTab(
|
|
@@ -1931,7 +1928,7 @@ function Tabs(props) {
|
|
|
1931
1928
|
);
|
|
1932
1929
|
}
|
|
1933
1930
|
}, [cache, active, uuid]);
|
|
1934
|
-
(0,
|
|
1931
|
+
(0, import_react13.useEffect)(() => {
|
|
1935
1932
|
if (cache && activeTab) {
|
|
1936
1933
|
window.localStorage.setItem(uuid, activeTab);
|
|
1937
1934
|
}
|
|
@@ -1939,7 +1936,7 @@ function Tabs(props) {
|
|
|
1939
1936
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TabsContext.Provider, { value, children: props.children });
|
|
1940
1937
|
}
|
|
1941
1938
|
function useTabsContext() {
|
|
1942
|
-
const context = (0,
|
|
1939
|
+
const context = (0, import_react13.useContext)(TabsContext);
|
|
1943
1940
|
if (!context) {
|
|
1944
1941
|
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
1945
1942
|
}
|
|
@@ -1950,7 +1947,7 @@ function useTabsContext() {
|
|
|
1950
1947
|
var import_css30 = require("@cerberus/styled-system/css");
|
|
1951
1948
|
|
|
1952
1949
|
// src/aria-helpers/tabs.aria.ts
|
|
1953
|
-
var
|
|
1950
|
+
var import_react14 = require("react");
|
|
1954
1951
|
function getNextIndex(index, length) {
|
|
1955
1952
|
return index === length - 1 ? 0 : index + 1;
|
|
1956
1953
|
}
|
|
@@ -1959,8 +1956,8 @@ function getPrevIndex(index, length) {
|
|
|
1959
1956
|
}
|
|
1960
1957
|
function useTabsKeyboardNavigation() {
|
|
1961
1958
|
const { tabs: tabs2 } = useTabsContext();
|
|
1962
|
-
const [activeTab, setActiveTab] = (0,
|
|
1963
|
-
(0,
|
|
1959
|
+
const [activeTab, setActiveTab] = (0, import_react14.useState)(-1);
|
|
1960
|
+
(0, import_react14.useEffect)(() => {
|
|
1964
1961
|
const handleKeyDown = (event) => {
|
|
1965
1962
|
const index = activeTab === -1 ? tabs2.current.findIndex((tab) => tab.ariaSelected === "true") : activeTab;
|
|
1966
1963
|
const nextIndex = getNextIndex(index, tabs2.current.length);
|
|
@@ -2010,9 +2007,9 @@ var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
|
2010
2007
|
function Tab(props) {
|
|
2011
2008
|
const { value, ...nativeProps } = props;
|
|
2012
2009
|
const { active, onTabUpdate, styles } = useTabsContext();
|
|
2013
|
-
const [isPending, startTransition] = (0,
|
|
2010
|
+
const [isPending, startTransition] = (0, import_react15.useTransition)();
|
|
2014
2011
|
const { ref } = useTabsKeyboardNavigation();
|
|
2015
|
-
const isActive = (0,
|
|
2012
|
+
const isActive = (0, import_react15.useMemo)(() => active === value, [active, value]);
|
|
2016
2013
|
function handleClick(e) {
|
|
2017
2014
|
var _a;
|
|
2018
2015
|
(_a = props.onClick) == null ? void 0 : _a.call(props, e);
|
|
@@ -2063,12 +2060,12 @@ function TabList(props) {
|
|
|
2063
2060
|
|
|
2064
2061
|
// src/components/TabPanel.tsx
|
|
2065
2062
|
var import_css32 = require("@cerberus/styled-system/css");
|
|
2066
|
-
var
|
|
2063
|
+
var import_react16 = require("react");
|
|
2067
2064
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2068
2065
|
function TabPanel(props) {
|
|
2069
2066
|
const { tab, ...nativeProps } = props;
|
|
2070
2067
|
const { active, styles } = useTabsContext();
|
|
2071
|
-
const isActive = (0,
|
|
2068
|
+
const isActive = (0, import_react16.useMemo)(() => active === tab, [active, tab]);
|
|
2072
2069
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Show, { when: isActive, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2073
2070
|
"div",
|
|
2074
2071
|
{
|
|
@@ -2346,26 +2343,26 @@ function Tooltip(props) {
|
|
|
2346
2343
|
}
|
|
2347
2344
|
|
|
2348
2345
|
// src/context/confirm-modal.tsx
|
|
2349
|
-
var
|
|
2346
|
+
var import_react18 = require("react");
|
|
2350
2347
|
var import_css42 = require("@cerberus/styled-system/css");
|
|
2351
2348
|
var import_patterns16 = require("@cerberus/styled-system/patterns");
|
|
2352
2349
|
|
|
2353
2350
|
// src/hooks/useModal.ts
|
|
2354
|
-
var
|
|
2351
|
+
var import_react17 = require("react");
|
|
2355
2352
|
function useModal() {
|
|
2356
|
-
const modalRef = (0,
|
|
2357
|
-
const [isOpen, setIsOpen] = (0,
|
|
2358
|
-
const show = (0,
|
|
2353
|
+
const modalRef = (0, import_react17.useRef)(null);
|
|
2354
|
+
const [isOpen, setIsOpen] = (0, import_react17.useState)(false);
|
|
2355
|
+
const show = (0, import_react17.useCallback)(() => {
|
|
2359
2356
|
var _a;
|
|
2360
2357
|
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
2361
2358
|
setIsOpen(true);
|
|
2362
2359
|
}, []);
|
|
2363
|
-
const close = (0,
|
|
2360
|
+
const close = (0, import_react17.useCallback)(() => {
|
|
2364
2361
|
var _a;
|
|
2365
2362
|
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
2366
2363
|
setIsOpen(false);
|
|
2367
2364
|
}, []);
|
|
2368
|
-
return (0,
|
|
2365
|
+
return (0, import_react17.useMemo)(() => {
|
|
2369
2366
|
return {
|
|
2370
2367
|
modalRef,
|
|
2371
2368
|
show,
|
|
@@ -2378,19 +2375,19 @@ function useModal() {
|
|
|
2378
2375
|
// src/context/confirm-modal.tsx
|
|
2379
2376
|
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
2380
2377
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
2381
|
-
var ConfirmModalContext = (0,
|
|
2378
|
+
var ConfirmModalContext = (0, import_react18.createContext)(null);
|
|
2382
2379
|
function ConfirmModal(props) {
|
|
2383
2380
|
const { modalRef, show, close } = useModal();
|
|
2384
|
-
const resolveRef = (0,
|
|
2385
|
-
const [content, setContent] = (0,
|
|
2381
|
+
const resolveRef = (0, import_react18.useRef)(null);
|
|
2382
|
+
const [content, setContent] = (0, import_react18.useState)(null);
|
|
2386
2383
|
const focusTrap = trapFocus(modalRef);
|
|
2387
2384
|
const ConfirmIcon = $cerberusIcons.confirmModal;
|
|
2388
2385
|
const kind = (content == null ? void 0 : content.kind) ?? "non-destructive";
|
|
2389
|
-
const palette = (0,
|
|
2386
|
+
const palette = (0, import_react18.useMemo)(
|
|
2390
2387
|
() => kind === "destructive" ? "danger" : "action",
|
|
2391
2388
|
[kind]
|
|
2392
2389
|
);
|
|
2393
|
-
const handleChoice = (0,
|
|
2390
|
+
const handleChoice = (0, import_react18.useCallback)(
|
|
2394
2391
|
(e) => {
|
|
2395
2392
|
var _a, _b;
|
|
2396
2393
|
const target = e.currentTarget;
|
|
@@ -2402,7 +2399,7 @@ function ConfirmModal(props) {
|
|
|
2402
2399
|
},
|
|
2403
2400
|
[close]
|
|
2404
2401
|
);
|
|
2405
|
-
const handleShow = (0,
|
|
2402
|
+
const handleShow = (0, import_react18.useCallback)(
|
|
2406
2403
|
(options) => {
|
|
2407
2404
|
return new Promise((resolve) => {
|
|
2408
2405
|
setContent({ ...options });
|
|
@@ -2412,7 +2409,7 @@ function ConfirmModal(props) {
|
|
|
2412
2409
|
},
|
|
2413
2410
|
[show]
|
|
2414
2411
|
);
|
|
2415
|
-
const value = (0,
|
|
2412
|
+
const value = (0, import_react18.useMemo)(
|
|
2416
2413
|
() => ({
|
|
2417
2414
|
show: handleShow
|
|
2418
2415
|
}),
|
|
@@ -2491,7 +2488,7 @@ function ConfirmModal(props) {
|
|
|
2491
2488
|
] });
|
|
2492
2489
|
}
|
|
2493
2490
|
function useConfirmModal() {
|
|
2494
|
-
const context = (0,
|
|
2491
|
+
const context = (0, import_react18.useContext)(ConfirmModalContext);
|
|
2495
2492
|
if (context === null) {
|
|
2496
2493
|
throw new Error(
|
|
2497
2494
|
"useConfirmModal must be used within a ConfirmModal Provider"
|
|
@@ -2501,21 +2498,21 @@ function useConfirmModal() {
|
|
|
2501
2498
|
}
|
|
2502
2499
|
|
|
2503
2500
|
// src/context/cta-modal.tsx
|
|
2504
|
-
var
|
|
2501
|
+
var import_react19 = require("react");
|
|
2505
2502
|
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
2506
2503
|
var import_css43 = require("@cerberus/styled-system/css");
|
|
2507
2504
|
var import_jsx3 = require("@cerberus/styled-system/jsx");
|
|
2508
2505
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2509
|
-
var CTAModalContext = (0,
|
|
2506
|
+
var CTAModalContext = (0, import_react19.createContext)(null);
|
|
2510
2507
|
function CTAModal(props) {
|
|
2511
2508
|
var _a, _b;
|
|
2512
2509
|
const { modalRef, show, close } = useModal();
|
|
2513
|
-
const [content, setContent] = (0,
|
|
2510
|
+
const [content, setContent] = (0, import_react19.useState)(null);
|
|
2514
2511
|
const focusTrap = trapFocus(modalRef);
|
|
2515
2512
|
const FallbackIcon = $cerberusIcons.confirmModal;
|
|
2516
2513
|
const confirmIcon = content == null ? void 0 : content.icon;
|
|
2517
2514
|
const { close: CloseIcon } = $cerberusIcons;
|
|
2518
|
-
const handleShow = (0,
|
|
2515
|
+
const handleShow = (0, import_react19.useCallback)(
|
|
2519
2516
|
(options) => {
|
|
2520
2517
|
const maxActions = 2;
|
|
2521
2518
|
if (options.actions.length > maxActions) {
|
|
@@ -2528,7 +2525,7 @@ function CTAModal(props) {
|
|
|
2528
2525
|
},
|
|
2529
2526
|
[show]
|
|
2530
2527
|
);
|
|
2531
|
-
const handleActionClick = (0,
|
|
2528
|
+
const handleActionClick = (0, import_react19.useCallback)(
|
|
2532
2529
|
(event) => {
|
|
2533
2530
|
const index = event.currentTarget.getAttribute("data-index");
|
|
2534
2531
|
const action = content == null ? void 0 : content.actions[Number(index)];
|
|
@@ -2539,7 +2536,7 @@ function CTAModal(props) {
|
|
|
2539
2536
|
},
|
|
2540
2537
|
[content, close]
|
|
2541
2538
|
);
|
|
2542
|
-
const value = (0,
|
|
2539
|
+
const value = (0, import_react19.useMemo)(
|
|
2543
2540
|
() => ({
|
|
2544
2541
|
show: handleShow
|
|
2545
2542
|
}),
|
|
@@ -2601,7 +2598,7 @@ function CTAModal(props) {
|
|
|
2601
2598
|
] });
|
|
2602
2599
|
}
|
|
2603
2600
|
function useCTAModal() {
|
|
2604
|
-
const context = (0,
|
|
2601
|
+
const context = (0, import_react19.useContext)(CTAModalContext);
|
|
2605
2602
|
if (context === null) {
|
|
2606
2603
|
throw new Error("useCTAModal must be used within a CTAModal Provider");
|
|
2607
2604
|
}
|
|
@@ -2609,22 +2606,22 @@ function useCTAModal() {
|
|
|
2609
2606
|
}
|
|
2610
2607
|
|
|
2611
2608
|
// src/context/notification-center.tsx
|
|
2612
|
-
var
|
|
2609
|
+
var import_react20 = require("react");
|
|
2613
2610
|
var import_patterns17 = require("@cerberus/styled-system/patterns");
|
|
2614
2611
|
var import_recipes34 = require("@cerberus/styled-system/recipes");
|
|
2615
2612
|
var import_css44 = require("@cerberus/styled-system/css");
|
|
2616
2613
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2617
|
-
var NotificationsContext = (0,
|
|
2614
|
+
var NotificationsContext = (0, import_react20.createContext)(null);
|
|
2618
2615
|
function NotificationCenter(props) {
|
|
2619
|
-
const [activeNotifications, setActiveNotifications] = (0,
|
|
2616
|
+
const [activeNotifications, setActiveNotifications] = (0, import_react20.useState)([]);
|
|
2620
2617
|
const styles = (0, import_recipes34.notification)();
|
|
2621
|
-
const handleNotify = (0,
|
|
2618
|
+
const handleNotify = (0, import_react20.useCallback)((options) => {
|
|
2622
2619
|
setActiveNotifications((prev) => {
|
|
2623
2620
|
const id = `${options.palette}:${prev.length + 1}`;
|
|
2624
2621
|
return [...prev, { ...options, id }];
|
|
2625
2622
|
});
|
|
2626
2623
|
}, []);
|
|
2627
|
-
const handleClose = (0,
|
|
2624
|
+
const handleClose = (0, import_react20.useCallback)((e) => {
|
|
2628
2625
|
const target = e.currentTarget;
|
|
2629
2626
|
setActiveNotifications((prev) => {
|
|
2630
2627
|
const item = prev.find((option) => option.id === target.value);
|
|
@@ -2632,7 +2629,7 @@ function NotificationCenter(props) {
|
|
|
2632
2629
|
return prev.filter((option) => option.id !== target.value);
|
|
2633
2630
|
});
|
|
2634
2631
|
}, []);
|
|
2635
|
-
const handleCloseAll = (0,
|
|
2632
|
+
const handleCloseAll = (0, import_react20.useCallback)(() => {
|
|
2636
2633
|
setActiveNotifications((prev) => {
|
|
2637
2634
|
prev.forEach((item) => {
|
|
2638
2635
|
if (item.onClose) item.onClose();
|
|
@@ -2640,7 +2637,7 @@ function NotificationCenter(props) {
|
|
|
2640
2637
|
return [];
|
|
2641
2638
|
});
|
|
2642
2639
|
}, []);
|
|
2643
|
-
const value = (0,
|
|
2640
|
+
const value = (0, import_react20.useMemo)(
|
|
2644
2641
|
() => ({
|
|
2645
2642
|
notify: handleNotify
|
|
2646
2643
|
}),
|
|
@@ -2731,7 +2728,7 @@ function MatchNotification(props) {
|
|
|
2731
2728
|
}
|
|
2732
2729
|
}
|
|
2733
2730
|
function useNotificationCenter() {
|
|
2734
|
-
const context = (0,
|
|
2731
|
+
const context = (0, import_react20.useContext)(NotificationsContext);
|
|
2735
2732
|
if (!context) {
|
|
2736
2733
|
throw new Error(
|
|
2737
2734
|
"useNotificationCenter must be used within a NotificationsProvider"
|
|
@@ -2741,33 +2738,33 @@ function useNotificationCenter() {
|
|
|
2741
2738
|
}
|
|
2742
2739
|
|
|
2743
2740
|
// src/context/prompt-modal.tsx
|
|
2744
|
-
var
|
|
2741
|
+
var import_react21 = require("react");
|
|
2745
2742
|
var import_css45 = require("@cerberus/styled-system/css");
|
|
2746
2743
|
var import_patterns18 = require("@cerberus/styled-system/patterns");
|
|
2747
2744
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
2748
|
-
var PromptModalContext = (0,
|
|
2745
|
+
var PromptModalContext = (0, import_react21.createContext)(null);
|
|
2749
2746
|
function PromptModal(props) {
|
|
2750
2747
|
const { modalRef, show, close } = useModal();
|
|
2751
|
-
const resolveRef = (0,
|
|
2752
|
-
const [content, setContent] = (0,
|
|
2753
|
-
const [inputValue, setInputValue] = (0,
|
|
2748
|
+
const resolveRef = (0, import_react21.useRef)(null);
|
|
2749
|
+
const [content, setContent] = (0, import_react21.useState)(null);
|
|
2750
|
+
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
2754
2751
|
const focusTrap = trapFocus(modalRef);
|
|
2755
2752
|
const PromptIcon = $cerberusIcons.promptModal;
|
|
2756
|
-
const isValid = (0,
|
|
2753
|
+
const isValid = (0, import_react21.useMemo)(
|
|
2757
2754
|
() => inputValue === (content == null ? void 0 : content.key),
|
|
2758
2755
|
[inputValue, content]
|
|
2759
2756
|
);
|
|
2760
|
-
const palette = (0,
|
|
2757
|
+
const palette = (0, import_react21.useMemo)(
|
|
2761
2758
|
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
2762
2759
|
[content]
|
|
2763
2760
|
);
|
|
2764
|
-
const handleChange = (0,
|
|
2761
|
+
const handleChange = (0, import_react21.useCallback)(
|
|
2765
2762
|
(e) => {
|
|
2766
2763
|
setInputValue(e.currentTarget.value);
|
|
2767
2764
|
},
|
|
2768
2765
|
[content]
|
|
2769
2766
|
);
|
|
2770
|
-
const handleChoice = (0,
|
|
2767
|
+
const handleChoice = (0, import_react21.useCallback)(
|
|
2771
2768
|
(e) => {
|
|
2772
2769
|
var _a;
|
|
2773
2770
|
const target = e.currentTarget;
|
|
@@ -2778,7 +2775,7 @@ function PromptModal(props) {
|
|
|
2778
2775
|
},
|
|
2779
2776
|
[inputValue, close]
|
|
2780
2777
|
);
|
|
2781
|
-
const handleShow = (0,
|
|
2778
|
+
const handleShow = (0, import_react21.useCallback)(
|
|
2782
2779
|
(options) => {
|
|
2783
2780
|
return new Promise((resolve) => {
|
|
2784
2781
|
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
@@ -2788,7 +2785,7 @@ function PromptModal(props) {
|
|
|
2788
2785
|
},
|
|
2789
2786
|
[show]
|
|
2790
2787
|
);
|
|
2791
|
-
const value = (0,
|
|
2788
|
+
const value = (0, import_react21.useMemo)(
|
|
2792
2789
|
() => ({
|
|
2793
2790
|
show: handleShow
|
|
2794
2791
|
}),
|
|
@@ -2922,7 +2919,7 @@ function PromptModal(props) {
|
|
|
2922
2919
|
] });
|
|
2923
2920
|
}
|
|
2924
2921
|
function usePromptModal() {
|
|
2925
|
-
const context = (0,
|
|
2922
|
+
const context = (0, import_react21.useContext)(PromptModalContext);
|
|
2926
2923
|
if (context === null) {
|
|
2927
2924
|
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
2928
2925
|
}
|
|
@@ -2930,50 +2927,50 @@ function usePromptModal() {
|
|
|
2930
2927
|
}
|
|
2931
2928
|
|
|
2932
2929
|
// src/context/theme.tsx
|
|
2933
|
-
var
|
|
2930
|
+
var import_react23 = require("react");
|
|
2934
2931
|
|
|
2935
2932
|
// src/hooks/useTheme.ts
|
|
2936
|
-
var
|
|
2933
|
+
var import_react22 = require("react");
|
|
2937
2934
|
var THEME_KEY = "cerberus-theme";
|
|
2938
2935
|
var MODE_KEY = "cerberus-mode";
|
|
2939
2936
|
function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options = {}) {
|
|
2940
2937
|
const { updateMode, updateTheme, cache } = options;
|
|
2941
|
-
const [theme, setTheme] = (0,
|
|
2942
|
-
const [colorMode, setColorMode] = (0,
|
|
2943
|
-
const handleThemeChange = (0,
|
|
2938
|
+
const [theme, setTheme] = (0, import_react22.useState)(defaultTheme);
|
|
2939
|
+
const [colorMode, setColorMode] = (0, import_react22.useState)(defaultColorMode);
|
|
2940
|
+
const handleThemeChange = (0, import_react22.useCallback)(
|
|
2944
2941
|
(newTheme) => {
|
|
2945
2942
|
setTheme(newTheme);
|
|
2946
2943
|
updateTheme == null ? void 0 : updateTheme(newTheme);
|
|
2947
2944
|
},
|
|
2948
2945
|
[updateTheme]
|
|
2949
2946
|
);
|
|
2950
|
-
const handleColorModeChange = (0,
|
|
2947
|
+
const handleColorModeChange = (0, import_react22.useCallback)(
|
|
2951
2948
|
(newMode) => {
|
|
2952
2949
|
setColorMode(newMode);
|
|
2953
2950
|
updateMode == null ? void 0 : updateMode(newMode);
|
|
2954
2951
|
},
|
|
2955
2952
|
[updateMode]
|
|
2956
2953
|
);
|
|
2957
|
-
(0,
|
|
2954
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
2958
2955
|
const theme2 = localStorage.getItem(THEME_KEY);
|
|
2959
2956
|
if (theme2) {
|
|
2960
2957
|
setTheme(theme2);
|
|
2961
2958
|
}
|
|
2962
2959
|
}, []);
|
|
2963
|
-
(0,
|
|
2960
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
2964
2961
|
const mode = localStorage.getItem(MODE_KEY);
|
|
2965
2962
|
if (mode) {
|
|
2966
2963
|
setColorMode(mode);
|
|
2967
2964
|
}
|
|
2968
2965
|
}, []);
|
|
2969
|
-
(0,
|
|
2966
|
+
(0, import_react22.useEffect)(() => {
|
|
2970
2967
|
const root = document.documentElement;
|
|
2971
2968
|
root.dataset.pandaTheme = theme;
|
|
2972
2969
|
if (cache) {
|
|
2973
2970
|
localStorage.setItem(THEME_KEY, theme);
|
|
2974
2971
|
}
|
|
2975
2972
|
}, [theme, cache]);
|
|
2976
|
-
(0,
|
|
2973
|
+
(0, import_react22.useEffect)(() => {
|
|
2977
2974
|
const root = document.documentElement;
|
|
2978
2975
|
if (colorMode === "system") {
|
|
2979
2976
|
root.dataset.colorMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -2984,7 +2981,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
2984
2981
|
localStorage.setItem(MODE_KEY, colorMode);
|
|
2985
2982
|
}
|
|
2986
2983
|
}, [colorMode, cache]);
|
|
2987
|
-
return (0,
|
|
2984
|
+
return (0, import_react22.useMemo)(
|
|
2988
2985
|
() => ({
|
|
2989
2986
|
theme,
|
|
2990
2987
|
mode: colorMode,
|
|
@@ -2997,7 +2994,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
2997
2994
|
|
|
2998
2995
|
// src/context/theme.tsx
|
|
2999
2996
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
3000
|
-
var ThemeContext = (0,
|
|
2997
|
+
var ThemeContext = (0, import_react23.createContext)(
|
|
3001
2998
|
null
|
|
3002
2999
|
);
|
|
3003
3000
|
function ThemeProvider(props) {
|
|
@@ -3009,7 +3006,7 @@ function ThemeProvider(props) {
|
|
|
3009
3006
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
3010
3007
|
}
|
|
3011
3008
|
function useThemeContext() {
|
|
3012
|
-
const context = (0,
|
|
3009
|
+
const context = (0, import_react23.useContext)(ThemeContext);
|
|
3013
3010
|
if (!context) {
|
|
3014
3011
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
3015
3012
|
}
|
|
@@ -3017,13 +3014,13 @@ function useThemeContext() {
|
|
|
3017
3014
|
}
|
|
3018
3015
|
|
|
3019
3016
|
// src/hooks/useDate.ts
|
|
3020
|
-
var
|
|
3017
|
+
var import_react24 = require("react");
|
|
3021
3018
|
function useDate(options) {
|
|
3022
3019
|
const initialValue = (options == null ? void 0 : options.initialValue) ?? "";
|
|
3023
3020
|
const format = (options == null ? void 0 : options.format) ?? DateFormats.USMilitary;
|
|
3024
3021
|
const onChange = options == null ? void 0 : options.onChange;
|
|
3025
|
-
const [value, setValue] = (0,
|
|
3026
|
-
const handleChange = (0,
|
|
3022
|
+
const [value, setValue] = (0, import_react24.useState)(initialValue);
|
|
3023
|
+
const handleChange = (0, import_react24.useCallback)(
|
|
3027
3024
|
(e) => {
|
|
3028
3025
|
const newValue = formatMilitaryDate(e.currentTarget.value);
|
|
3029
3026
|
if (onChange) onChange(e);
|
|
@@ -3031,7 +3028,7 @@ function useDate(options) {
|
|
|
3031
3028
|
},
|
|
3032
3029
|
[onChange]
|
|
3033
3030
|
);
|
|
3034
|
-
return (0,
|
|
3031
|
+
return (0, import_react24.useMemo)(
|
|
3035
3032
|
() => ({
|
|
3036
3033
|
format,
|
|
3037
3034
|
value,
|
|
@@ -3104,11 +3101,11 @@ var MONTHS = [
|
|
|
3104
3101
|
];
|
|
3105
3102
|
|
|
3106
3103
|
// src/hooks/useToggle.ts
|
|
3107
|
-
var
|
|
3104
|
+
var import_react25 = require("react");
|
|
3108
3105
|
function useToggle(options) {
|
|
3109
|
-
const [checked, setChecked] = (0,
|
|
3106
|
+
const [checked, setChecked] = (0, import_react25.useState)((options == null ? void 0 : options.checked) ?? "");
|
|
3110
3107
|
const onChange = options == null ? void 0 : options.onChange;
|
|
3111
|
-
const handleChange = (0,
|
|
3108
|
+
const handleChange = (0, import_react25.useCallback)(
|
|
3112
3109
|
(e) => {
|
|
3113
3110
|
const target = e.currentTarget;
|
|
3114
3111
|
setChecked((prev) => {
|
|
@@ -3118,24 +3115,39 @@ function useToggle(options) {
|
|
|
3118
3115
|
},
|
|
3119
3116
|
[onChange]
|
|
3120
3117
|
);
|
|
3121
|
-
return (0,
|
|
3118
|
+
return (0, import_react25.useMemo)(() => ({ checked, handleChange }), [checked, handleChange]);
|
|
3122
3119
|
}
|
|
3123
3120
|
|
|
3124
3121
|
// src/hooks/useRootColors.ts
|
|
3125
|
-
var
|
|
3122
|
+
var import_react26 = require("react");
|
|
3126
3123
|
function useRootColors(colors = []) {
|
|
3127
|
-
const [state, dispatch] = (0,
|
|
3128
|
-
(0,
|
|
3124
|
+
const [state, dispatch] = (0, import_react26.useReducer)(rootColorsReducer, {});
|
|
3125
|
+
const handleRefetch = (0, import_react26.useCallback)(() => {
|
|
3126
|
+
return new Promise((resolve) => {
|
|
3127
|
+
dispatch(formatColors(colors));
|
|
3128
|
+
resolve();
|
|
3129
|
+
});
|
|
3130
|
+
}, []);
|
|
3131
|
+
(0, import_react26.useEffect)(() => {
|
|
3129
3132
|
if (Object.keys(state).length === colors.length) return;
|
|
3130
|
-
|
|
3131
|
-
|
|
3133
|
+
dispatch(formatColors(colors));
|
|
3134
|
+
console.log("updating colors in root hook");
|
|
3135
|
+
}, [colors]);
|
|
3136
|
+
return (0, import_react26.useMemo)(
|
|
3137
|
+
() => ({ colors: state, refetch: handleRefetch }),
|
|
3138
|
+
[state, handleRefetch]
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
function formatColors(colors) {
|
|
3142
|
+
const rootStyles = getComputedStyle(document.body);
|
|
3143
|
+
return colors.reduce(
|
|
3144
|
+
(acc, color) => {
|
|
3132
3145
|
const formattedColor = color.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase().replaceAll(".", "-");
|
|
3133
3146
|
acc[color] = rootStyles.getPropertyValue(`--cerberus-colors-${formattedColor}`).trim();
|
|
3134
3147
|
return acc;
|
|
3135
|
-
},
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
return state;
|
|
3148
|
+
},
|
|
3149
|
+
{}
|
|
3150
|
+
);
|
|
3139
3151
|
}
|
|
3140
3152
|
function rootColorsReducer(state, action) {
|
|
3141
3153
|
return { ...state, ...action };
|