@cerberus-design/react 0.13.1 → 0.13.2
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 +83 -40
- package/build/legacy/components/ModalHeader.cjs +0 -1
- package/build/legacy/components/ModalHeader.cjs.map +1 -1
- package/build/legacy/components/Portal.cjs +2 -6
- package/build/legacy/components/Portal.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +58 -68
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +54 -58
- 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 -33
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/hooks/useRootColors.cjs +64 -0
- package/build/legacy/hooks/useRootColors.cjs.map +1 -0
- package/build/legacy/index.cjs +191 -164
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +83 -40
- package/build/modern/{chunk-KUT2YEEQ.js → chunk-3XGLNXJJ.js} +7 -7
- package/build/modern/chunk-3XGLNXJJ.js.map +1 -0
- package/build/modern/{chunk-NCUHRVW2.js → chunk-FBSESDWJ.js} +8 -8
- package/build/modern/{chunk-KFGI37CO.js → chunk-GRUXP3NG.js} +44 -50
- package/build/modern/chunk-GRUXP3NG.js.map +1 -0
- 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-J4LOSTEP.js → chunk-WFJWCZ7E.js} +45 -45
- package/build/modern/{chunk-J4LOSTEP.js.map → chunk-WFJWCZ7E.js.map} +1 -1
- package/build/modern/{chunk-ZFAIE47A.js → chunk-XY6WL55R.js} +1 -2
- package/build/modern/{chunk-ZFAIE47A.js.map → chunk-XY6WL55R.js.map} +1 -1
- package/build/modern/components/ModalHeader.js +1 -1
- package/build/modern/components/Portal.js +1 -2
- package/build/modern/context/confirm-modal.js +5 -5
- package/build/modern/context/cta-modal.js +6 -6
- package/build/modern/context/notification-center.js +4 -4
- package/build/modern/context/prompt-modal.js +5 -5
- package/build/modern/hooks/useRootColors.js +8 -0
- package/build/modern/hooks/useRootColors.js.map +1 -0
- package/build/modern/index.js +39 -35
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ModalHeader.tsx +0 -1
- package/src/components/Portal.tsx +6 -19
- package/src/context/confirm-modal.tsx +89 -66
- package/src/context/cta-modal.tsx +38 -38
- package/src/context/notification-center.tsx +1 -0
- package/src/hooks/useRootColors.ts +73 -0
- package/src/index.ts +1 -0
- package/build/modern/chunk-K2PSHGS7.js +0 -11
- package/build/modern/chunk-K2PSHGS7.js.map +0 -1
- package/build/modern/chunk-KFGI37CO.js.map +0 -1
- package/build/modern/chunk-KUT2YEEQ.js.map +0 -1
- /package/build/modern/{chunk-NCUHRVW2.js.map → chunk-FBSESDWJ.js.map} +0 -0
package/build/legacy/index.cjs
CHANGED
|
@@ -107,6 +107,7 @@ __export(src_exports, {
|
|
|
107
107
|
useNavMenuContext: () => useNavMenuContext,
|
|
108
108
|
useNotificationCenter: () => useNotificationCenter,
|
|
109
109
|
usePromptModal: () => usePromptModal,
|
|
110
|
+
useRootColors: () => useRootColors,
|
|
110
111
|
useTabsContext: () => useTabsContext,
|
|
111
112
|
useTabsKeyboardNavigation: () => useTabsKeyboardNavigation,
|
|
112
113
|
useTheme: () => useTheme,
|
|
@@ -1360,7 +1361,6 @@ function ModalHeader(props) {
|
|
|
1360
1361
|
(0, import_patterns9.vstack)({
|
|
1361
1362
|
alignItems: "flex-start",
|
|
1362
1363
|
gap: "md",
|
|
1363
|
-
mb: "md",
|
|
1364
1364
|
position: "relative"
|
|
1365
1365
|
})
|
|
1366
1366
|
)
|
|
@@ -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,
|
|
@@ -2376,19 +2373,21 @@ function useModal() {
|
|
|
2376
2373
|
}
|
|
2377
2374
|
|
|
2378
2375
|
// src/context/confirm-modal.tsx
|
|
2376
|
+
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
2379
2377
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
2380
|
-
var ConfirmModalContext = (0,
|
|
2378
|
+
var ConfirmModalContext = (0, import_react18.createContext)(null);
|
|
2381
2379
|
function ConfirmModal(props) {
|
|
2382
2380
|
const { modalRef, show, close } = useModal();
|
|
2383
|
-
const resolveRef = (0,
|
|
2384
|
-
const [content, setContent] = (0,
|
|
2381
|
+
const resolveRef = (0, import_react18.useRef)(null);
|
|
2382
|
+
const [content, setContent] = (0, import_react18.useState)(null);
|
|
2385
2383
|
const focusTrap = trapFocus(modalRef);
|
|
2386
2384
|
const ConfirmIcon = $cerberusIcons.confirmModal;
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2389
|
-
|
|
2385
|
+
const kind = (content == null ? void 0 : content.kind) ?? "non-destructive";
|
|
2386
|
+
const palette = (0, import_react18.useMemo)(
|
|
2387
|
+
() => kind === "destructive" ? "danger" : "action",
|
|
2388
|
+
[kind]
|
|
2390
2389
|
);
|
|
2391
|
-
const handleChoice = (0,
|
|
2390
|
+
const handleChoice = (0, import_react18.useCallback)(
|
|
2392
2391
|
(e) => {
|
|
2393
2392
|
var _a, _b;
|
|
2394
2393
|
const target = e.currentTarget;
|
|
@@ -2400,17 +2399,17 @@ function ConfirmModal(props) {
|
|
|
2400
2399
|
},
|
|
2401
2400
|
[close]
|
|
2402
2401
|
);
|
|
2403
|
-
const handleShow = (0,
|
|
2402
|
+
const handleShow = (0, import_react18.useCallback)(
|
|
2404
2403
|
(options) => {
|
|
2405
2404
|
return new Promise((resolve) => {
|
|
2406
|
-
setContent({ ...options
|
|
2405
|
+
setContent({ ...options });
|
|
2407
2406
|
show();
|
|
2408
2407
|
resolveRef.current = resolve;
|
|
2409
2408
|
});
|
|
2410
2409
|
},
|
|
2411
2410
|
[show]
|
|
2412
2411
|
);
|
|
2413
|
-
const value = (0,
|
|
2412
|
+
const value = (0, import_react18.useMemo)(
|
|
2414
2413
|
() => ({
|
|
2415
2414
|
show: handleShow
|
|
2416
2415
|
}),
|
|
@@ -2418,7 +2417,7 @@ function ConfirmModal(props) {
|
|
|
2418
2417
|
);
|
|
2419
2418
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(ConfirmModalContext.Provider, { value, children: [
|
|
2420
2419
|
props.children,
|
|
2421
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime50.
|
|
2420
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Modal, { onKeyDown: focusTrap, ref: modalRef, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx.VStack, { gap: "xl", w: "full", children: [
|
|
2422
2421
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(ModalHeader, { children: [
|
|
2423
2422
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2424
2423
|
"div",
|
|
@@ -2456,48 +2455,40 @@ function ConfirmModal(props) {
|
|
|
2456
2455
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
|
|
2457
2456
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
|
|
2458
2457
|
] }),
|
|
2459
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
),
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
value: "false",
|
|
2490
|
-
children: content == null ? void 0 : content.cancelText
|
|
2491
|
-
}
|
|
2492
|
-
)
|
|
2493
|
-
]
|
|
2494
|
-
}
|
|
2495
|
-
)
|
|
2496
|
-
] }) })
|
|
2458
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx.HStack, { gap: "4", w: "full", children: [
|
|
2459
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2460
|
+
Button,
|
|
2461
|
+
{
|
|
2462
|
+
autoFocus: true,
|
|
2463
|
+
className: (0, import_css42.css)({
|
|
2464
|
+
w: "1/2"
|
|
2465
|
+
}),
|
|
2466
|
+
name: "confirm",
|
|
2467
|
+
onClick: handleChoice,
|
|
2468
|
+
palette,
|
|
2469
|
+
value: "true",
|
|
2470
|
+
children: content == null ? void 0 : content.actionText
|
|
2471
|
+
}
|
|
2472
|
+
),
|
|
2473
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2474
|
+
Button,
|
|
2475
|
+
{
|
|
2476
|
+
className: (0, import_css42.css)({
|
|
2477
|
+
w: "1/2"
|
|
2478
|
+
}),
|
|
2479
|
+
name: "cancel",
|
|
2480
|
+
onClick: handleChoice,
|
|
2481
|
+
usage: "outlined",
|
|
2482
|
+
value: "false",
|
|
2483
|
+
children: content == null ? void 0 : content.cancelText
|
|
2484
|
+
}
|
|
2485
|
+
)
|
|
2486
|
+
] })
|
|
2487
|
+
] }) }) })
|
|
2497
2488
|
] });
|
|
2498
2489
|
}
|
|
2499
2490
|
function useConfirmModal() {
|
|
2500
|
-
const context = (0,
|
|
2491
|
+
const context = (0, import_react18.useContext)(ConfirmModalContext);
|
|
2501
2492
|
if (context === null) {
|
|
2502
2493
|
throw new Error(
|
|
2503
2494
|
"useConfirmModal must be used within a ConfirmModal Provider"
|
|
@@ -2507,21 +2498,21 @@ function useConfirmModal() {
|
|
|
2507
2498
|
}
|
|
2508
2499
|
|
|
2509
2500
|
// src/context/cta-modal.tsx
|
|
2510
|
-
var
|
|
2511
|
-
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
2512
|
-
var import_css43 = require("@cerberus/styled-system/css");
|
|
2501
|
+
var import_react19 = require("react");
|
|
2513
2502
|
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
2503
|
+
var import_css43 = require("@cerberus/styled-system/css");
|
|
2504
|
+
var import_jsx3 = require("@cerberus/styled-system/jsx");
|
|
2514
2505
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2515
|
-
var CTAModalContext = (0,
|
|
2506
|
+
var CTAModalContext = (0, import_react19.createContext)(null);
|
|
2516
2507
|
function CTAModal(props) {
|
|
2517
2508
|
var _a, _b;
|
|
2518
2509
|
const { modalRef, show, close } = useModal();
|
|
2519
|
-
const [content, setContent] = (0,
|
|
2510
|
+
const [content, setContent] = (0, import_react19.useState)(null);
|
|
2520
2511
|
const focusTrap = trapFocus(modalRef);
|
|
2521
2512
|
const FallbackIcon = $cerberusIcons.confirmModal;
|
|
2522
2513
|
const confirmIcon = content == null ? void 0 : content.icon;
|
|
2523
2514
|
const { close: CloseIcon } = $cerberusIcons;
|
|
2524
|
-
const handleShow = (0,
|
|
2515
|
+
const handleShow = (0, import_react19.useCallback)(
|
|
2525
2516
|
(options) => {
|
|
2526
2517
|
const maxActions = 2;
|
|
2527
2518
|
if (options.actions.length > maxActions) {
|
|
@@ -2534,7 +2525,7 @@ function CTAModal(props) {
|
|
|
2534
2525
|
},
|
|
2535
2526
|
[show]
|
|
2536
2527
|
);
|
|
2537
|
-
const handleActionClick = (0,
|
|
2528
|
+
const handleActionClick = (0, import_react19.useCallback)(
|
|
2538
2529
|
(event) => {
|
|
2539
2530
|
const index = event.currentTarget.getAttribute("data-index");
|
|
2540
2531
|
const action = content == null ? void 0 : content.actions[Number(index)];
|
|
@@ -2545,7 +2536,7 @@ function CTAModal(props) {
|
|
|
2545
2536
|
},
|
|
2546
2537
|
[content, close]
|
|
2547
2538
|
);
|
|
2548
|
-
const value = (0,
|
|
2539
|
+
const value = (0, import_react19.useMemo)(
|
|
2549
2540
|
() => ({
|
|
2550
2541
|
show: handleShow
|
|
2551
2542
|
}),
|
|
@@ -2567,47 +2558,47 @@ function CTAModal(props) {
|
|
|
2567
2558
|
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(IconButton, { ariaLabel: "Close modal", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(CloseIcon, {}) })
|
|
2568
2559
|
}
|
|
2569
2560
|
),
|
|
2570
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
2571
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx3.VStack, { gap: "xl", w: "full", children: [
|
|
2562
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ModalHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx3.VStack, { gap: "lg", w: "full", children: [
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2564
|
+
Avatar,
|
|
2565
|
+
{
|
|
2566
|
+
ariaLabel: "",
|
|
2567
|
+
gradient: "charon-light",
|
|
2568
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2569
|
+
Show,
|
|
2570
|
+
{
|
|
2571
|
+
when: Boolean(confirmIcon),
|
|
2572
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(FallbackIcon, { size: 24 }),
|
|
2573
|
+
children: confirmIcon
|
|
2574
|
+
}
|
|
2575
|
+
),
|
|
2576
|
+
src: ""
|
|
2577
|
+
}
|
|
2578
|
+
),
|
|
2588
2579
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
|
|
2589
2580
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
|
|
2590
|
-
] })
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2581
|
+
] }) }),
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx2.HStack, { gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Show, { when: Boolean((_a = content == null ? void 0 : content.actions) == null ? void 0 : _a.length), children: (_b = content == null ? void 0 : content.actions) == null ? void 0 : _b.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2583
|
+
Button,
|
|
2584
|
+
{
|
|
2585
|
+
"data-index": index,
|
|
2586
|
+
className: (0, import_css43.css)({
|
|
2587
|
+
w: "1/2"
|
|
2588
|
+
}),
|
|
2589
|
+
onClick: handleActionClick,
|
|
2590
|
+
shape: "rounded",
|
|
2591
|
+
usage: "outlined",
|
|
2592
|
+
children: action.text
|
|
2593
|
+
},
|
|
2594
|
+
index
|
|
2595
|
+
)) }) })
|
|
2596
|
+
] })
|
|
2606
2597
|
] }) })
|
|
2607
2598
|
] });
|
|
2608
2599
|
}
|
|
2609
2600
|
function useCTAModal() {
|
|
2610
|
-
const context = (0,
|
|
2601
|
+
const context = (0, import_react19.useContext)(CTAModalContext);
|
|
2611
2602
|
if (context === null) {
|
|
2612
2603
|
throw new Error("useCTAModal must be used within a CTAModal Provider");
|
|
2613
2604
|
}
|
|
@@ -2615,22 +2606,22 @@ function useCTAModal() {
|
|
|
2615
2606
|
}
|
|
2616
2607
|
|
|
2617
2608
|
// src/context/notification-center.tsx
|
|
2618
|
-
var
|
|
2609
|
+
var import_react20 = require("react");
|
|
2619
2610
|
var import_patterns17 = require("@cerberus/styled-system/patterns");
|
|
2620
2611
|
var import_recipes34 = require("@cerberus/styled-system/recipes");
|
|
2621
2612
|
var import_css44 = require("@cerberus/styled-system/css");
|
|
2622
2613
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2623
|
-
var NotificationsContext = (0,
|
|
2614
|
+
var NotificationsContext = (0, import_react20.createContext)(null);
|
|
2624
2615
|
function NotificationCenter(props) {
|
|
2625
|
-
const [activeNotifications, setActiveNotifications] = (0,
|
|
2616
|
+
const [activeNotifications, setActiveNotifications] = (0, import_react20.useState)([]);
|
|
2626
2617
|
const styles = (0, import_recipes34.notification)();
|
|
2627
|
-
const handleNotify = (0,
|
|
2618
|
+
const handleNotify = (0, import_react20.useCallback)((options) => {
|
|
2628
2619
|
setActiveNotifications((prev) => {
|
|
2629
2620
|
const id = `${options.palette}:${prev.length + 1}`;
|
|
2630
2621
|
return [...prev, { ...options, id }];
|
|
2631
2622
|
});
|
|
2632
2623
|
}, []);
|
|
2633
|
-
const handleClose = (0,
|
|
2624
|
+
const handleClose = (0, import_react20.useCallback)((e) => {
|
|
2634
2625
|
const target = e.currentTarget;
|
|
2635
2626
|
setActiveNotifications((prev) => {
|
|
2636
2627
|
const item = prev.find((option) => option.id === target.value);
|
|
@@ -2638,7 +2629,7 @@ function NotificationCenter(props) {
|
|
|
2638
2629
|
return prev.filter((option) => option.id !== target.value);
|
|
2639
2630
|
});
|
|
2640
2631
|
}, []);
|
|
2641
|
-
const handleCloseAll = (0,
|
|
2632
|
+
const handleCloseAll = (0, import_react20.useCallback)(() => {
|
|
2642
2633
|
setActiveNotifications((prev) => {
|
|
2643
2634
|
prev.forEach((item) => {
|
|
2644
2635
|
if (item.onClose) item.onClose();
|
|
@@ -2646,7 +2637,7 @@ function NotificationCenter(props) {
|
|
|
2646
2637
|
return [];
|
|
2647
2638
|
});
|
|
2648
2639
|
}, []);
|
|
2649
|
-
const value = (0,
|
|
2640
|
+
const value = (0, import_react20.useMemo)(
|
|
2650
2641
|
() => ({
|
|
2651
2642
|
notify: handleNotify
|
|
2652
2643
|
}),
|
|
@@ -2737,7 +2728,7 @@ function MatchNotification(props) {
|
|
|
2737
2728
|
}
|
|
2738
2729
|
}
|
|
2739
2730
|
function useNotificationCenter() {
|
|
2740
|
-
const context = (0,
|
|
2731
|
+
const context = (0, import_react20.useContext)(NotificationsContext);
|
|
2741
2732
|
if (!context) {
|
|
2742
2733
|
throw new Error(
|
|
2743
2734
|
"useNotificationCenter must be used within a NotificationsProvider"
|
|
@@ -2747,33 +2738,33 @@ function useNotificationCenter() {
|
|
|
2747
2738
|
}
|
|
2748
2739
|
|
|
2749
2740
|
// src/context/prompt-modal.tsx
|
|
2750
|
-
var
|
|
2741
|
+
var import_react21 = require("react");
|
|
2751
2742
|
var import_css45 = require("@cerberus/styled-system/css");
|
|
2752
2743
|
var import_patterns18 = require("@cerberus/styled-system/patterns");
|
|
2753
2744
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
2754
|
-
var PromptModalContext = (0,
|
|
2745
|
+
var PromptModalContext = (0, import_react21.createContext)(null);
|
|
2755
2746
|
function PromptModal(props) {
|
|
2756
2747
|
const { modalRef, show, close } = useModal();
|
|
2757
|
-
const resolveRef = (0,
|
|
2758
|
-
const [content, setContent] = (0,
|
|
2759
|
-
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)("");
|
|
2760
2751
|
const focusTrap = trapFocus(modalRef);
|
|
2761
2752
|
const PromptIcon = $cerberusIcons.promptModal;
|
|
2762
|
-
const isValid = (0,
|
|
2753
|
+
const isValid = (0, import_react21.useMemo)(
|
|
2763
2754
|
() => inputValue === (content == null ? void 0 : content.key),
|
|
2764
2755
|
[inputValue, content]
|
|
2765
2756
|
);
|
|
2766
|
-
const palette = (0,
|
|
2757
|
+
const palette = (0, import_react21.useMemo)(
|
|
2767
2758
|
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
2768
2759
|
[content]
|
|
2769
2760
|
);
|
|
2770
|
-
const handleChange = (0,
|
|
2761
|
+
const handleChange = (0, import_react21.useCallback)(
|
|
2771
2762
|
(e) => {
|
|
2772
2763
|
setInputValue(e.currentTarget.value);
|
|
2773
2764
|
},
|
|
2774
2765
|
[content]
|
|
2775
2766
|
);
|
|
2776
|
-
const handleChoice = (0,
|
|
2767
|
+
const handleChoice = (0, import_react21.useCallback)(
|
|
2777
2768
|
(e) => {
|
|
2778
2769
|
var _a;
|
|
2779
2770
|
const target = e.currentTarget;
|
|
@@ -2784,7 +2775,7 @@ function PromptModal(props) {
|
|
|
2784
2775
|
},
|
|
2785
2776
|
[inputValue, close]
|
|
2786
2777
|
);
|
|
2787
|
-
const handleShow = (0,
|
|
2778
|
+
const handleShow = (0, import_react21.useCallback)(
|
|
2788
2779
|
(options) => {
|
|
2789
2780
|
return new Promise((resolve) => {
|
|
2790
2781
|
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
@@ -2794,7 +2785,7 @@ function PromptModal(props) {
|
|
|
2794
2785
|
},
|
|
2795
2786
|
[show]
|
|
2796
2787
|
);
|
|
2797
|
-
const value = (0,
|
|
2788
|
+
const value = (0, import_react21.useMemo)(
|
|
2798
2789
|
() => ({
|
|
2799
2790
|
show: handleShow
|
|
2800
2791
|
}),
|
|
@@ -2928,7 +2919,7 @@ function PromptModal(props) {
|
|
|
2928
2919
|
] });
|
|
2929
2920
|
}
|
|
2930
2921
|
function usePromptModal() {
|
|
2931
|
-
const context = (0,
|
|
2922
|
+
const context = (0, import_react21.useContext)(PromptModalContext);
|
|
2932
2923
|
if (context === null) {
|
|
2933
2924
|
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
2934
2925
|
}
|
|
@@ -2936,50 +2927,50 @@ function usePromptModal() {
|
|
|
2936
2927
|
}
|
|
2937
2928
|
|
|
2938
2929
|
// src/context/theme.tsx
|
|
2939
|
-
var
|
|
2930
|
+
var import_react23 = require("react");
|
|
2940
2931
|
|
|
2941
2932
|
// src/hooks/useTheme.ts
|
|
2942
|
-
var
|
|
2933
|
+
var import_react22 = require("react");
|
|
2943
2934
|
var THEME_KEY = "cerberus-theme";
|
|
2944
2935
|
var MODE_KEY = "cerberus-mode";
|
|
2945
2936
|
function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options = {}) {
|
|
2946
2937
|
const { updateMode, updateTheme, cache } = options;
|
|
2947
|
-
const [theme, setTheme] = (0,
|
|
2948
|
-
const [colorMode, setColorMode] = (0,
|
|
2949
|
-
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)(
|
|
2950
2941
|
(newTheme) => {
|
|
2951
2942
|
setTheme(newTheme);
|
|
2952
2943
|
updateTheme == null ? void 0 : updateTheme(newTheme);
|
|
2953
2944
|
},
|
|
2954
2945
|
[updateTheme]
|
|
2955
2946
|
);
|
|
2956
|
-
const handleColorModeChange = (0,
|
|
2947
|
+
const handleColorModeChange = (0, import_react22.useCallback)(
|
|
2957
2948
|
(newMode) => {
|
|
2958
2949
|
setColorMode(newMode);
|
|
2959
2950
|
updateMode == null ? void 0 : updateMode(newMode);
|
|
2960
2951
|
},
|
|
2961
2952
|
[updateMode]
|
|
2962
2953
|
);
|
|
2963
|
-
(0,
|
|
2954
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
2964
2955
|
const theme2 = localStorage.getItem(THEME_KEY);
|
|
2965
2956
|
if (theme2) {
|
|
2966
2957
|
setTheme(theme2);
|
|
2967
2958
|
}
|
|
2968
2959
|
}, []);
|
|
2969
|
-
(0,
|
|
2960
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
2970
2961
|
const mode = localStorage.getItem(MODE_KEY);
|
|
2971
2962
|
if (mode) {
|
|
2972
2963
|
setColorMode(mode);
|
|
2973
2964
|
}
|
|
2974
2965
|
}, []);
|
|
2975
|
-
(0,
|
|
2966
|
+
(0, import_react22.useEffect)(() => {
|
|
2976
2967
|
const root = document.documentElement;
|
|
2977
2968
|
root.dataset.pandaTheme = theme;
|
|
2978
2969
|
if (cache) {
|
|
2979
2970
|
localStorage.setItem(THEME_KEY, theme);
|
|
2980
2971
|
}
|
|
2981
2972
|
}, [theme, cache]);
|
|
2982
|
-
(0,
|
|
2973
|
+
(0, import_react22.useEffect)(() => {
|
|
2983
2974
|
const root = document.documentElement;
|
|
2984
2975
|
if (colorMode === "system") {
|
|
2985
2976
|
root.dataset.colorMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -2990,7 +2981,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
2990
2981
|
localStorage.setItem(MODE_KEY, colorMode);
|
|
2991
2982
|
}
|
|
2992
2983
|
}, [colorMode, cache]);
|
|
2993
|
-
return (0,
|
|
2984
|
+
return (0, import_react22.useMemo)(
|
|
2994
2985
|
() => ({
|
|
2995
2986
|
theme,
|
|
2996
2987
|
mode: colorMode,
|
|
@@ -3003,7 +2994,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
3003
2994
|
|
|
3004
2995
|
// src/context/theme.tsx
|
|
3005
2996
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
3006
|
-
var ThemeContext = (0,
|
|
2997
|
+
var ThemeContext = (0, import_react23.createContext)(
|
|
3007
2998
|
null
|
|
3008
2999
|
);
|
|
3009
3000
|
function ThemeProvider(props) {
|
|
@@ -3015,7 +3006,7 @@ function ThemeProvider(props) {
|
|
|
3015
3006
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
3016
3007
|
}
|
|
3017
3008
|
function useThemeContext() {
|
|
3018
|
-
const context = (0,
|
|
3009
|
+
const context = (0, import_react23.useContext)(ThemeContext);
|
|
3019
3010
|
if (!context) {
|
|
3020
3011
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
3021
3012
|
}
|
|
@@ -3023,13 +3014,13 @@ function useThemeContext() {
|
|
|
3023
3014
|
}
|
|
3024
3015
|
|
|
3025
3016
|
// src/hooks/useDate.ts
|
|
3026
|
-
var
|
|
3017
|
+
var import_react24 = require("react");
|
|
3027
3018
|
function useDate(options) {
|
|
3028
3019
|
const initialValue = (options == null ? void 0 : options.initialValue) ?? "";
|
|
3029
3020
|
const format = (options == null ? void 0 : options.format) ?? DateFormats.USMilitary;
|
|
3030
3021
|
const onChange = options == null ? void 0 : options.onChange;
|
|
3031
|
-
const [value, setValue] = (0,
|
|
3032
|
-
const handleChange = (0,
|
|
3022
|
+
const [value, setValue] = (0, import_react24.useState)(initialValue);
|
|
3023
|
+
const handleChange = (0, import_react24.useCallback)(
|
|
3033
3024
|
(e) => {
|
|
3034
3025
|
const newValue = formatMilitaryDate(e.currentTarget.value);
|
|
3035
3026
|
if (onChange) onChange(e);
|
|
@@ -3037,7 +3028,7 @@ function useDate(options) {
|
|
|
3037
3028
|
},
|
|
3038
3029
|
[onChange]
|
|
3039
3030
|
);
|
|
3040
|
-
return (0,
|
|
3031
|
+
return (0, import_react24.useMemo)(
|
|
3041
3032
|
() => ({
|
|
3042
3033
|
format,
|
|
3043
3034
|
value,
|
|
@@ -3110,11 +3101,11 @@ var MONTHS = [
|
|
|
3110
3101
|
];
|
|
3111
3102
|
|
|
3112
3103
|
// src/hooks/useToggle.ts
|
|
3113
|
-
var
|
|
3104
|
+
var import_react25 = require("react");
|
|
3114
3105
|
function useToggle(options) {
|
|
3115
|
-
const [checked, setChecked] = (0,
|
|
3106
|
+
const [checked, setChecked] = (0, import_react25.useState)((options == null ? void 0 : options.checked) ?? "");
|
|
3116
3107
|
const onChange = options == null ? void 0 : options.onChange;
|
|
3117
|
-
const handleChange = (0,
|
|
3108
|
+
const handleChange = (0, import_react25.useCallback)(
|
|
3118
3109
|
(e) => {
|
|
3119
3110
|
const target = e.currentTarget;
|
|
3120
3111
|
setChecked((prev) => {
|
|
@@ -3124,7 +3115,42 @@ function useToggle(options) {
|
|
|
3124
3115
|
},
|
|
3125
3116
|
[onChange]
|
|
3126
3117
|
);
|
|
3127
|
-
return (0,
|
|
3118
|
+
return (0, import_react25.useMemo)(() => ({ checked, handleChange }), [checked, handleChange]);
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
// src/hooks/useRootColors.ts
|
|
3122
|
+
var import_react26 = require("react");
|
|
3123
|
+
function useRootColors(colors = []) {
|
|
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)(() => {
|
|
3132
|
+
if (Object.keys(state).length === colors.length) return;
|
|
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) => {
|
|
3145
|
+
const formattedColor = color.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase().replaceAll(".", "-");
|
|
3146
|
+
acc[color] = rootStyles.getPropertyValue(`--cerberus-colors-${formattedColor}`).trim();
|
|
3147
|
+
return acc;
|
|
3148
|
+
},
|
|
3149
|
+
{}
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
function rootColorsReducer(state, action) {
|
|
3153
|
+
return { ...state, ...action };
|
|
3128
3154
|
}
|
|
3129
3155
|
|
|
3130
3156
|
// src/utils/index.ts
|
|
@@ -3223,6 +3249,7 @@ __reExport(src_exports, require("@dnd-kit/core"), module.exports);
|
|
|
3223
3249
|
useNavMenuContext,
|
|
3224
3250
|
useNotificationCenter,
|
|
3225
3251
|
usePromptModal,
|
|
3252
|
+
useRootColors,
|
|
3226
3253
|
useTabsContext,
|
|
3227
3254
|
useTabsKeyboardNavigation,
|
|
3228
3255
|
useTheme,
|