@cerberus-design/react 0.11.1-next-2ed68bd → 0.11.1-next-c28b077
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 +79 -0
- package/build/legacy/components/Admonition.cjs +1 -1
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +1 -1
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +1 -1
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/FileStatus.cjs +1 -1
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +1 -1
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +1 -1
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/ModalHeader.cjs +2 -1
- package/build/legacy/components/ModalHeader.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +3 -3
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +1 -1
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tag.cjs +3 -3
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +1 -1
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/cerbIcons.cjs +1 -1
- package/build/legacy/config/cerbIcons.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +1 -1
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +3 -2
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +567 -0
- package/build/legacy/context/cta-modal.cjs.map +1 -0
- package/build/legacy/context/notification-center.cjs +3 -3
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +3 -2
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +201 -88
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +79 -0
- package/build/modern/{chunk-RDQHHCFR.js → chunk-5OSUZUR4.js} +2 -2
- package/build/modern/{chunk-KLUBAM4U.js → chunk-7SGPJM66.js} +4 -4
- package/build/modern/chunk-7SGPJM66.js.map +1 -0
- package/build/modern/{chunk-3NE6C66J.js → chunk-C7UVOGPZ.js} +5 -5
- package/build/modern/{chunk-TMR7JGMP.js → chunk-F27AAKQ3.js} +3 -3
- package/build/modern/chunk-F27AAKQ3.js.map +1 -0
- package/build/modern/{chunk-BOCAJC3S.js → chunk-F72ZABKX.js} +2 -2
- package/build/modern/chunk-JVIFMN67.js +155 -0
- package/build/modern/chunk-JVIFMN67.js.map +1 -0
- package/build/modern/{chunk-KF6V5JLW.js → chunk-N4QTLDVM.js} +3 -3
- package/build/modern/{chunk-MDIUFBDX.js → chunk-NB6DV4VA.js} +2 -2
- package/build/modern/{chunk-UJKS4DDN.js → chunk-NKM6PISB.js} +2 -2
- package/build/modern/{chunk-YWCTMLLO.js → chunk-NMNONSHU.js} +2 -2
- package/build/modern/{chunk-X4Y4WTRU.js → chunk-PJGUYNKD.js} +4 -4
- package/build/modern/{chunk-ZX6DBC2Z.js → chunk-SPZYPRZ6.js} +2 -2
- package/build/modern/{chunk-FT7DFRHQ.js → chunk-VERRHMW4.js} +2 -2
- package/build/modern/{chunk-HCB5NQ5J.js → chunk-W4DXACNV.js} +3 -3
- package/build/modern/{chunk-PA5EB7EO.js → chunk-XL4JREDT.js} +2 -2
- package/build/modern/{chunk-6EJXHRAP.js → chunk-ZBMA5G54.js} +3 -3
- package/build/modern/{chunk-ULYQLKWA.js → chunk-ZFAIE47A.js} +3 -2
- package/build/modern/{chunk-ULYQLKWA.js.map → chunk-ZFAIE47A.js.map} +1 -1
- package/build/modern/components/Admonition.js +4 -4
- package/build/modern/components/Avatar.js +3 -3
- package/build/modern/components/Checkbox.js +3 -3
- package/build/modern/components/FileStatus.js +4 -4
- package/build/modern/components/FileUploader.js +4 -4
- package/build/modern/components/Input.js +3 -3
- package/build/modern/components/ModalHeader.js +1 -1
- package/build/modern/components/Notification.js +3 -3
- package/build/modern/components/Select.js +3 -3
- package/build/modern/components/Tag.js +3 -3
- package/build/modern/components/Toggle.js +3 -3
- package/build/modern/config/cerbIcons.js +1 -1
- package/build/modern/config/defineIcons.js +2 -2
- package/build/modern/context/confirm-modal.js +5 -5
- package/build/modern/context/cta-modal.js +25 -0
- package/build/modern/context/cta-modal.js.map +1 -0
- package/build/modern/context/notification-center.js +4 -4
- package/build/modern/context/prompt-modal.js +6 -6
- package/build/modern/index.js +22 -16
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ModalHeader.tsx +1 -0
- package/src/components/Notification.tsx +2 -2
- package/src/config/cerbIcons.ts +2 -2
- package/src/context/cta-modal.tsx +210 -0
- package/src/index.ts +1 -0
- package/build/modern/chunk-KLUBAM4U.js.map +0 -1
- package/build/modern/chunk-TMR7JGMP.js.map +0 -1
- /package/build/modern/{chunk-RDQHHCFR.js.map → chunk-5OSUZUR4.js.map} +0 -0
- /package/build/modern/{chunk-3NE6C66J.js.map → chunk-C7UVOGPZ.js.map} +0 -0
- /package/build/modern/{chunk-BOCAJC3S.js.map → chunk-F72ZABKX.js.map} +0 -0
- /package/build/modern/{chunk-KF6V5JLW.js.map → chunk-N4QTLDVM.js.map} +0 -0
- /package/build/modern/{chunk-MDIUFBDX.js.map → chunk-NB6DV4VA.js.map} +0 -0
- /package/build/modern/{chunk-UJKS4DDN.js.map → chunk-NKM6PISB.js.map} +0 -0
- /package/build/modern/{chunk-YWCTMLLO.js.map → chunk-NMNONSHU.js.map} +0 -0
- /package/build/modern/{chunk-X4Y4WTRU.js.map → chunk-PJGUYNKD.js.map} +0 -0
- /package/build/modern/{chunk-ZX6DBC2Z.js.map → chunk-SPZYPRZ6.js.map} +0 -0
- /package/build/modern/{chunk-FT7DFRHQ.js.map → chunk-VERRHMW4.js.map} +0 -0
- /package/build/modern/{chunk-HCB5NQ5J.js.map → chunk-W4DXACNV.js.map} +0 -0
- /package/build/modern/{chunk-PA5EB7EO.js.map → chunk-XL4JREDT.js.map} +0 -0
- /package/build/modern/{chunk-6EJXHRAP.js.map → chunk-ZBMA5G54.js.map} +0 -0
package/build/legacy/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(src_exports, {
|
|
|
27
27
|
AdmonitionHeading: () => AdmonitionHeading,
|
|
28
28
|
Avatar: () => Avatar,
|
|
29
29
|
Button: () => Button,
|
|
30
|
+
CTAModal: () => CTAModal,
|
|
30
31
|
Checkbox: () => Checkbox,
|
|
31
32
|
CircularProgress: () => CircularProgress,
|
|
32
33
|
ConfirmModal: () => ConfirmModal,
|
|
@@ -86,6 +87,7 @@ __export(src_exports, {
|
|
|
86
87
|
getPosition: () => getPosition,
|
|
87
88
|
processStatus: () => processStatus,
|
|
88
89
|
trapFocus: () => trapFocus,
|
|
90
|
+
useCTAModal: () => useCTAModal,
|
|
89
91
|
useConfirmModal: () => useConfirmModal,
|
|
90
92
|
useFeatureFlags: () => useFeatureFlags,
|
|
91
93
|
useFieldContext: () => useFieldContext,
|
|
@@ -246,7 +248,7 @@ function AnimatingUploadIcon(props) {
|
|
|
246
248
|
var defaultIcons = {
|
|
247
249
|
avatar: import_icons.UserFilled,
|
|
248
250
|
checkbox: CheckmarkIcon,
|
|
249
|
-
close: import_icons.
|
|
251
|
+
close: import_icons.Close,
|
|
250
252
|
confirmModal: import_icons.Information,
|
|
251
253
|
delete: import_icons.TrashCan,
|
|
252
254
|
promptModal: import_icons.Information,
|
|
@@ -1304,7 +1306,8 @@ function ModalHeader(props) {
|
|
|
1304
1306
|
(0, import_patterns9.vstack)({
|
|
1305
1307
|
alignItems: "flex-start",
|
|
1306
1308
|
gap: "md",
|
|
1307
|
-
mb: "md"
|
|
1309
|
+
mb: "md",
|
|
1310
|
+
position: "relative"
|
|
1308
1311
|
})
|
|
1309
1312
|
)
|
|
1310
1313
|
}
|
|
@@ -1560,7 +1563,6 @@ var import_css24 = require("@cerberus/styled-system/css");
|
|
|
1560
1563
|
var import_patterns11 = require("@cerberus/styled-system/patterns");
|
|
1561
1564
|
var import_recipes18 = require("@cerberus/styled-system/recipes");
|
|
1562
1565
|
var import_react10 = require("react");
|
|
1563
|
-
var import_icons2 = require("@cerberus/icons");
|
|
1564
1566
|
|
|
1565
1567
|
// src/aria-helpers/trap-focus.aria.ts
|
|
1566
1568
|
function trapFocus(modalRef) {
|
|
@@ -1601,6 +1603,7 @@ function Notification(props) {
|
|
|
1601
1603
|
const ref = (0, import_react10.useRef)(null);
|
|
1602
1604
|
const onKeyDown = trapFocus(ref);
|
|
1603
1605
|
const styles = (0, import_recipes18.notification)({ palette });
|
|
1606
|
+
const { close: CloseIcon } = $cerberusIcons;
|
|
1604
1607
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
1605
1608
|
"dialog",
|
|
1606
1609
|
{
|
|
@@ -1635,7 +1638,7 @@ function Notification(props) {
|
|
|
1635
1638
|
className: styles.close,
|
|
1636
1639
|
onClick: onClose,
|
|
1637
1640
|
value: props.id,
|
|
1638
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1641
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(CloseIcon, {})
|
|
1639
1642
|
}
|
|
1640
1643
|
)
|
|
1641
1644
|
]
|
|
@@ -2425,23 +2428,131 @@ function useConfirmModal() {
|
|
|
2425
2428
|
return context;
|
|
2426
2429
|
}
|
|
2427
2430
|
|
|
2428
|
-
// src/context/
|
|
2431
|
+
// src/context/cta-modal.tsx
|
|
2429
2432
|
var import_react17 = require("react");
|
|
2430
|
-
var
|
|
2431
|
-
var import_recipes32 = require("@cerberus/styled-system/recipes");
|
|
2433
|
+
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
2432
2434
|
var import_css41 = require("@cerberus/styled-system/css");
|
|
2435
|
+
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
2433
2436
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
2434
|
-
var
|
|
2437
|
+
var CTAModalContext = (0, import_react17.createContext)(null);
|
|
2438
|
+
function CTAModal(props) {
|
|
2439
|
+
var _a, _b;
|
|
2440
|
+
const { modalRef, show, close } = useModal();
|
|
2441
|
+
const [content, setContent] = (0, import_react17.useState)(null);
|
|
2442
|
+
const focusTrap = trapFocus(modalRef);
|
|
2443
|
+
const FallbackIcon = $cerberusIcons.confirmModal;
|
|
2444
|
+
const confirmIcon = content == null ? void 0 : content.icon;
|
|
2445
|
+
const { close: CloseIcon } = $cerberusIcons;
|
|
2446
|
+
const handleShow = (0, import_react17.useCallback)(
|
|
2447
|
+
(options) => {
|
|
2448
|
+
const maxActions = 2;
|
|
2449
|
+
if (options.actions.length > maxActions) {
|
|
2450
|
+
throw new Error(
|
|
2451
|
+
`CTA Modal only supports a maximum of ${maxActions} actions.`
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
setContent({ ...options });
|
|
2455
|
+
show();
|
|
2456
|
+
},
|
|
2457
|
+
[show]
|
|
2458
|
+
);
|
|
2459
|
+
const handleActionClick = (0, import_react17.useCallback)(
|
|
2460
|
+
(event) => {
|
|
2461
|
+
const index = event.currentTarget.getAttribute("data-index");
|
|
2462
|
+
const action = content == null ? void 0 : content.actions[Number(index)];
|
|
2463
|
+
if (typeof (action == null ? void 0 : action.onClick) === "function") {
|
|
2464
|
+
action.onClick(event);
|
|
2465
|
+
}
|
|
2466
|
+
close();
|
|
2467
|
+
},
|
|
2468
|
+
[content, close]
|
|
2469
|
+
);
|
|
2470
|
+
const value = (0, import_react17.useMemo)(
|
|
2471
|
+
() => ({
|
|
2472
|
+
show: handleShow
|
|
2473
|
+
}),
|
|
2474
|
+
[handleShow]
|
|
2475
|
+
);
|
|
2476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(CTAModalContext.Provider, { value, children: [
|
|
2477
|
+
props.children,
|
|
2478
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2480
|
+
"span",
|
|
2481
|
+
{
|
|
2482
|
+
className: (0, import_css41.css)({
|
|
2483
|
+
padding: "md",
|
|
2484
|
+
position: "absolute",
|
|
2485
|
+
right: 0,
|
|
2486
|
+
top: 0,
|
|
2487
|
+
zIndex: "decorator"
|
|
2488
|
+
}),
|
|
2489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(IconButton, { ariaLabel: "Close modal", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CloseIcon, {}) })
|
|
2490
|
+
}
|
|
2491
|
+
),
|
|
2492
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(ModalHeader, { children: [
|
|
2493
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_jsx.HStack, { justify: "center", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2494
|
+
Avatar,
|
|
2495
|
+
{
|
|
2496
|
+
ariaLabel: "",
|
|
2497
|
+
gradient: "charon-light",
|
|
2498
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2499
|
+
Show,
|
|
2500
|
+
{
|
|
2501
|
+
when: Boolean(confirmIcon),
|
|
2502
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(FallbackIcon, { size: 24 }),
|
|
2503
|
+
children: confirmIcon
|
|
2504
|
+
}
|
|
2505
|
+
),
|
|
2506
|
+
src: ""
|
|
2507
|
+
}
|
|
2508
|
+
) }),
|
|
2509
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx2.VStack, { gap: "lg", w: "full", children: [
|
|
2510
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
|
|
2512
|
+
] })
|
|
2513
|
+
] }),
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_jsx.HStack, { gap: "md", pt: "sm", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime49.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_runtime49.jsx)(
|
|
2515
|
+
Button,
|
|
2516
|
+
{
|
|
2517
|
+
"data-index": index,
|
|
2518
|
+
className: (0, import_css41.css)({
|
|
2519
|
+
w: "1/2"
|
|
2520
|
+
}),
|
|
2521
|
+
onClick: handleActionClick,
|
|
2522
|
+
shape: "rounded",
|
|
2523
|
+
usage: "outlined",
|
|
2524
|
+
children: action.text
|
|
2525
|
+
},
|
|
2526
|
+
index
|
|
2527
|
+
)) }) })
|
|
2528
|
+
] }) })
|
|
2529
|
+
] });
|
|
2530
|
+
}
|
|
2531
|
+
function useCTAModal() {
|
|
2532
|
+
const context = (0, import_react17.useContext)(CTAModalContext);
|
|
2533
|
+
if (context === null) {
|
|
2534
|
+
throw new Error("useCTAModal must be used within a CTAModal Provider");
|
|
2535
|
+
}
|
|
2536
|
+
return context;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
// src/context/notification-center.tsx
|
|
2540
|
+
var import_react18 = require("react");
|
|
2541
|
+
var import_patterns17 = require("@cerberus/styled-system/patterns");
|
|
2542
|
+
var import_recipes32 = require("@cerberus/styled-system/recipes");
|
|
2543
|
+
var import_css42 = require("@cerberus/styled-system/css");
|
|
2544
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
2545
|
+
var NotificationsContext = (0, import_react18.createContext)(null);
|
|
2435
2546
|
function NotificationCenter(props) {
|
|
2436
|
-
const [activeNotifications, setActiveNotifications] = (0,
|
|
2547
|
+
const [activeNotifications, setActiveNotifications] = (0, import_react18.useState)([]);
|
|
2437
2548
|
const styles = (0, import_recipes32.notification)();
|
|
2438
|
-
const handleNotify = (0,
|
|
2549
|
+
const handleNotify = (0, import_react18.useCallback)((options) => {
|
|
2439
2550
|
setActiveNotifications((prev) => {
|
|
2440
2551
|
const id = `${options.palette}:${prev.length + 1}`;
|
|
2441
2552
|
return [...prev, { ...options, id }];
|
|
2442
2553
|
});
|
|
2443
2554
|
}, []);
|
|
2444
|
-
const handleClose = (0,
|
|
2555
|
+
const handleClose = (0, import_react18.useCallback)((e) => {
|
|
2445
2556
|
const target = e.currentTarget;
|
|
2446
2557
|
setActiveNotifications((prev) => {
|
|
2447
2558
|
const item = prev.find((option) => option.id === target.value);
|
|
@@ -2449,7 +2560,7 @@ function NotificationCenter(props) {
|
|
|
2449
2560
|
return prev.filter((option) => option.id !== target.value);
|
|
2450
2561
|
});
|
|
2451
2562
|
}, []);
|
|
2452
|
-
const handleCloseAll = (0,
|
|
2563
|
+
const handleCloseAll = (0, import_react18.useCallback)(() => {
|
|
2453
2564
|
setActiveNotifications((prev) => {
|
|
2454
2565
|
prev.forEach((item) => {
|
|
2455
2566
|
if (item.onClose) item.onClose();
|
|
@@ -2457,19 +2568,19 @@ function NotificationCenter(props) {
|
|
|
2457
2568
|
return [];
|
|
2458
2569
|
});
|
|
2459
2570
|
}, []);
|
|
2460
|
-
const value = (0,
|
|
2571
|
+
const value = (0, import_react18.useMemo)(
|
|
2461
2572
|
() => ({
|
|
2462
2573
|
notify: handleNotify
|
|
2463
2574
|
}),
|
|
2464
2575
|
[handleNotify]
|
|
2465
2576
|
);
|
|
2466
|
-
return /* @__PURE__ */ (0,
|
|
2577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(NotificationsContext.Provider, { value, children: [
|
|
2467
2578
|
props.children,
|
|
2468
|
-
/* @__PURE__ */ (0,
|
|
2469
|
-
/* @__PURE__ */ (0,
|
|
2579
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Show, { when: activeNotifications.length > 0, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Portal, { container: props.container, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: styles.center, children: [
|
|
2580
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Show, { when: activeNotifications.length >= 4, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2470
2581
|
Button,
|
|
2471
2582
|
{
|
|
2472
|
-
className: (0,
|
|
2583
|
+
className: (0, import_css42.cx)(styles.closeAll, (0, import_patterns17.animateIn)()),
|
|
2473
2584
|
onClick: handleCloseAll,
|
|
2474
2585
|
palette: "action",
|
|
2475
2586
|
shape: "rounded",
|
|
@@ -2478,7 +2589,7 @@ function NotificationCenter(props) {
|
|
|
2478
2589
|
children: "Close all"
|
|
2479
2590
|
}
|
|
2480
2591
|
) }),
|
|
2481
|
-
/* @__PURE__ */ (0,
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2482
2593
|
"div",
|
|
2483
2594
|
{
|
|
2484
2595
|
className: (0, import_patterns17.vstack)({
|
|
@@ -2488,7 +2599,7 @@ function NotificationCenter(props) {
|
|
|
2488
2599
|
style: {
|
|
2489
2600
|
alignItems: "flex-end"
|
|
2490
2601
|
},
|
|
2491
|
-
children: activeNotifications.map((option) => /* @__PURE__ */ (0,
|
|
2602
|
+
children: activeNotifications.map((option) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2492
2603
|
MatchNotification,
|
|
2493
2604
|
{
|
|
2494
2605
|
...option,
|
|
@@ -2505,7 +2616,7 @@ function MatchNotification(props) {
|
|
|
2505
2616
|
const { palette, id, onClose, heading, description } = props;
|
|
2506
2617
|
switch (palette) {
|
|
2507
2618
|
case "success":
|
|
2508
|
-
return /* @__PURE__ */ (0,
|
|
2619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
2509
2620
|
Notification,
|
|
2510
2621
|
{
|
|
2511
2622
|
id,
|
|
@@ -2513,14 +2624,14 @@ function MatchNotification(props) {
|
|
|
2513
2624
|
open: true,
|
|
2514
2625
|
palette: "success",
|
|
2515
2626
|
children: [
|
|
2516
|
-
/* @__PURE__ */ (0,
|
|
2517
|
-
/* @__PURE__ */ (0,
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationHeading, { palette: "success", children: heading }),
|
|
2628
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationDescription, { palette: "success", children: description })
|
|
2518
2629
|
]
|
|
2519
2630
|
},
|
|
2520
2631
|
id
|
|
2521
2632
|
);
|
|
2522
2633
|
case "warning":
|
|
2523
|
-
return /* @__PURE__ */ (0,
|
|
2634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
2524
2635
|
Notification,
|
|
2525
2636
|
{
|
|
2526
2637
|
id,
|
|
@@ -2528,27 +2639,27 @@ function MatchNotification(props) {
|
|
|
2528
2639
|
open: true,
|
|
2529
2640
|
palette: "warning",
|
|
2530
2641
|
children: [
|
|
2531
|
-
/* @__PURE__ */ (0,
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationHeading, { palette: "warning", children: heading }),
|
|
2643
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationDescription, { palette: "warning", children: description })
|
|
2533
2644
|
]
|
|
2534
2645
|
},
|
|
2535
2646
|
id
|
|
2536
2647
|
);
|
|
2537
2648
|
case "danger":
|
|
2538
|
-
return /* @__PURE__ */ (0,
|
|
2539
|
-
/* @__PURE__ */ (0,
|
|
2540
|
-
/* @__PURE__ */ (0,
|
|
2649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Notification, { id, onClose, open: true, palette: "danger", children: [
|
|
2650
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationHeading, { palette: "danger", children: heading }),
|
|
2651
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationDescription, { palette: "danger", children: description })
|
|
2541
2652
|
] }, id);
|
|
2542
2653
|
case "info":
|
|
2543
2654
|
default:
|
|
2544
|
-
return /* @__PURE__ */ (0,
|
|
2545
|
-
/* @__PURE__ */ (0,
|
|
2546
|
-
/* @__PURE__ */ (0,
|
|
2655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Notification, { id, onClose, open: true, palette: "info", children: [
|
|
2656
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationHeading, { palette: "info", children: heading }),
|
|
2657
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NotificationDescription, { palette: "info", children: description })
|
|
2547
2658
|
] }, id);
|
|
2548
2659
|
}
|
|
2549
2660
|
}
|
|
2550
2661
|
function useNotificationCenter() {
|
|
2551
|
-
const context = (0,
|
|
2662
|
+
const context = (0, import_react18.useContext)(NotificationsContext);
|
|
2552
2663
|
if (!context) {
|
|
2553
2664
|
throw new Error(
|
|
2554
2665
|
"useNotificationCenter must be used within a NotificationsProvider"
|
|
@@ -2558,33 +2669,33 @@ function useNotificationCenter() {
|
|
|
2558
2669
|
}
|
|
2559
2670
|
|
|
2560
2671
|
// src/context/prompt-modal.tsx
|
|
2561
|
-
var
|
|
2562
|
-
var
|
|
2672
|
+
var import_react19 = require("react");
|
|
2673
|
+
var import_css43 = require("@cerberus/styled-system/css");
|
|
2563
2674
|
var import_patterns18 = require("@cerberus/styled-system/patterns");
|
|
2564
|
-
var
|
|
2565
|
-
var PromptModalContext = (0,
|
|
2675
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2676
|
+
var PromptModalContext = (0, import_react19.createContext)(null);
|
|
2566
2677
|
function PromptModal(props) {
|
|
2567
2678
|
const { modalRef, show, close } = useModal();
|
|
2568
|
-
const resolveRef = (0,
|
|
2569
|
-
const [content, setContent] = (0,
|
|
2570
|
-
const [inputValue, setInputValue] = (0,
|
|
2679
|
+
const resolveRef = (0, import_react19.useRef)(null);
|
|
2680
|
+
const [content, setContent] = (0, import_react19.useState)(null);
|
|
2681
|
+
const [inputValue, setInputValue] = (0, import_react19.useState)("");
|
|
2571
2682
|
const focusTrap = trapFocus(modalRef);
|
|
2572
2683
|
const PromptIcon = $cerberusIcons.promptModal;
|
|
2573
|
-
const isValid = (0,
|
|
2684
|
+
const isValid = (0, import_react19.useMemo)(
|
|
2574
2685
|
() => inputValue === (content == null ? void 0 : content.key),
|
|
2575
2686
|
[inputValue, content]
|
|
2576
2687
|
);
|
|
2577
|
-
const palette = (0,
|
|
2688
|
+
const palette = (0, import_react19.useMemo)(
|
|
2578
2689
|
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
2579
2690
|
[content]
|
|
2580
2691
|
);
|
|
2581
|
-
const handleChange = (0,
|
|
2692
|
+
const handleChange = (0, import_react19.useCallback)(
|
|
2582
2693
|
(e) => {
|
|
2583
2694
|
setInputValue(e.currentTarget.value);
|
|
2584
2695
|
},
|
|
2585
2696
|
[content]
|
|
2586
2697
|
);
|
|
2587
|
-
const handleChoice = (0,
|
|
2698
|
+
const handleChoice = (0, import_react19.useCallback)(
|
|
2588
2699
|
(e) => {
|
|
2589
2700
|
var _a;
|
|
2590
2701
|
const target = e.currentTarget;
|
|
@@ -2595,7 +2706,7 @@ function PromptModal(props) {
|
|
|
2595
2706
|
},
|
|
2596
2707
|
[inputValue, close]
|
|
2597
2708
|
);
|
|
2598
|
-
const handleShow = (0,
|
|
2709
|
+
const handleShow = (0, import_react19.useCallback)(
|
|
2599
2710
|
(options) => {
|
|
2600
2711
|
return new Promise((resolve) => {
|
|
2601
2712
|
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
@@ -2605,42 +2716,42 @@ function PromptModal(props) {
|
|
|
2605
2716
|
},
|
|
2606
2717
|
[show]
|
|
2607
2718
|
);
|
|
2608
|
-
const value = (0,
|
|
2719
|
+
const value = (0, import_react19.useMemo)(
|
|
2609
2720
|
() => ({
|
|
2610
2721
|
show: handleShow
|
|
2611
2722
|
}),
|
|
2612
2723
|
[handleShow]
|
|
2613
2724
|
);
|
|
2614
|
-
return /* @__PURE__ */ (0,
|
|
2725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(PromptModalContext.Provider, { value, children: [
|
|
2615
2726
|
props.children,
|
|
2616
|
-
/* @__PURE__ */ (0,
|
|
2617
|
-
/* @__PURE__ */ (0,
|
|
2618
|
-
/* @__PURE__ */ (0,
|
|
2727
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
2728
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ModalHeader, { children: [
|
|
2729
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2619
2730
|
"div",
|
|
2620
2731
|
{
|
|
2621
2732
|
className: (0, import_patterns18.hstack)({
|
|
2622
2733
|
justify: "center",
|
|
2623
2734
|
w: "full"
|
|
2624
2735
|
}),
|
|
2625
|
-
children: /* @__PURE__ */ (0,
|
|
2736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2626
2737
|
Show,
|
|
2627
2738
|
{
|
|
2628
2739
|
when: palette === "danger",
|
|
2629
|
-
fallback: /* @__PURE__ */ (0,
|
|
2740
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2630
2741
|
Avatar,
|
|
2631
2742
|
{
|
|
2632
2743
|
ariaLabel: "",
|
|
2633
2744
|
gradient: "charon-light",
|
|
2634
|
-
icon: /* @__PURE__ */ (0,
|
|
2745
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(PromptIcon, { size: 24 }),
|
|
2635
2746
|
src: ""
|
|
2636
2747
|
}
|
|
2637
2748
|
),
|
|
2638
|
-
children: /* @__PURE__ */ (0,
|
|
2749
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2639
2750
|
Avatar,
|
|
2640
2751
|
{
|
|
2641
2752
|
ariaLabel: "",
|
|
2642
2753
|
gradient: "hades-dark",
|
|
2643
|
-
icon: /* @__PURE__ */ (0,
|
|
2754
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(PromptIcon, { size: 24 }),
|
|
2644
2755
|
src: ""
|
|
2645
2756
|
}
|
|
2646
2757
|
)
|
|
@@ -2648,10 +2759,10 @@ function PromptModal(props) {
|
|
|
2648
2759
|
)
|
|
2649
2760
|
}
|
|
2650
2761
|
),
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2652
|
-
/* @__PURE__ */ (0,
|
|
2762
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
|
|
2763
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
|
|
2653
2764
|
] }),
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
2765
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2655
2766
|
"div",
|
|
2656
2767
|
{
|
|
2657
2768
|
className: (0, import_patterns18.vstack)({
|
|
@@ -2659,11 +2770,11 @@ function PromptModal(props) {
|
|
|
2659
2770
|
mt: "4",
|
|
2660
2771
|
mb: "8"
|
|
2661
2772
|
}),
|
|
2662
|
-
children: /* @__PURE__ */ (0,
|
|
2663
|
-
/* @__PURE__ */ (0,
|
|
2773
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Field, { invalid: !isValid, children: [
|
|
2774
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
2664
2775
|
Label,
|
|
2665
2776
|
{
|
|
2666
|
-
className: (0,
|
|
2777
|
+
className: (0, import_css43.css)({
|
|
2667
2778
|
gap: 1,
|
|
2668
2779
|
justifyContent: "flex-start"
|
|
2669
2780
|
}),
|
|
@@ -2671,10 +2782,10 @@ function PromptModal(props) {
|
|
|
2671
2782
|
size: "md",
|
|
2672
2783
|
children: [
|
|
2673
2784
|
"Type",
|
|
2674
|
-
/* @__PURE__ */ (0,
|
|
2785
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2675
2786
|
"strong",
|
|
2676
2787
|
{
|
|
2677
|
-
className: (0,
|
|
2788
|
+
className: (0, import_css43.css)({
|
|
2678
2789
|
textTransform: "uppercase"
|
|
2679
2790
|
}),
|
|
2680
2791
|
children: content == null ? void 0 : content.key
|
|
@@ -2684,7 +2795,7 @@ function PromptModal(props) {
|
|
|
2684
2795
|
]
|
|
2685
2796
|
}
|
|
2686
2797
|
),
|
|
2687
|
-
/* @__PURE__ */ (0,
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2688
2799
|
Input,
|
|
2689
2800
|
{
|
|
2690
2801
|
id: "confirm",
|
|
@@ -2696,7 +2807,7 @@ function PromptModal(props) {
|
|
|
2696
2807
|
] })
|
|
2697
2808
|
}
|
|
2698
2809
|
),
|
|
2699
|
-
/* @__PURE__ */ (0,
|
|
2810
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
2700
2811
|
"div",
|
|
2701
2812
|
{
|
|
2702
2813
|
className: (0, import_patterns18.hstack)({
|
|
@@ -2704,11 +2815,11 @@ function PromptModal(props) {
|
|
|
2704
2815
|
gap: "4"
|
|
2705
2816
|
}),
|
|
2706
2817
|
children: [
|
|
2707
|
-
/* @__PURE__ */ (0,
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2708
2819
|
Button,
|
|
2709
2820
|
{
|
|
2710
2821
|
autoFocus: true,
|
|
2711
|
-
className: (0,
|
|
2822
|
+
className: (0, import_css43.css)({
|
|
2712
2823
|
w: "1/2"
|
|
2713
2824
|
}),
|
|
2714
2825
|
disabled: !isValid,
|
|
@@ -2719,10 +2830,10 @@ function PromptModal(props) {
|
|
|
2719
2830
|
children: content == null ? void 0 : content.actionText
|
|
2720
2831
|
}
|
|
2721
2832
|
),
|
|
2722
|
-
/* @__PURE__ */ (0,
|
|
2833
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
2723
2834
|
Button,
|
|
2724
2835
|
{
|
|
2725
|
-
className: (0,
|
|
2836
|
+
className: (0, import_css43.css)({
|
|
2726
2837
|
w: "1/2"
|
|
2727
2838
|
}),
|
|
2728
2839
|
name: "cancel",
|
|
@@ -2739,7 +2850,7 @@ function PromptModal(props) {
|
|
|
2739
2850
|
] });
|
|
2740
2851
|
}
|
|
2741
2852
|
function usePromptModal() {
|
|
2742
|
-
const context = (0,
|
|
2853
|
+
const context = (0, import_react19.useContext)(PromptModalContext);
|
|
2743
2854
|
if (context === null) {
|
|
2744
2855
|
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
2745
2856
|
}
|
|
@@ -2747,50 +2858,50 @@ function usePromptModal() {
|
|
|
2747
2858
|
}
|
|
2748
2859
|
|
|
2749
2860
|
// src/context/theme.tsx
|
|
2750
|
-
var
|
|
2861
|
+
var import_react21 = require("react");
|
|
2751
2862
|
|
|
2752
2863
|
// src/hooks/useTheme.ts
|
|
2753
|
-
var
|
|
2864
|
+
var import_react20 = require("react");
|
|
2754
2865
|
var THEME_KEY = "cerberus-theme";
|
|
2755
2866
|
var MODE_KEY = "cerberus-mode";
|
|
2756
2867
|
function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options = {}) {
|
|
2757
2868
|
const { updateMode, updateTheme, cache } = options;
|
|
2758
|
-
const [theme, setTheme] = (0,
|
|
2759
|
-
const [colorMode, setColorMode] = (0,
|
|
2760
|
-
const handleThemeChange = (0,
|
|
2869
|
+
const [theme, setTheme] = (0, import_react20.useState)(defaultTheme);
|
|
2870
|
+
const [colorMode, setColorMode] = (0, import_react20.useState)(defaultColorMode);
|
|
2871
|
+
const handleThemeChange = (0, import_react20.useCallback)(
|
|
2761
2872
|
(newTheme) => {
|
|
2762
2873
|
setTheme(newTheme);
|
|
2763
2874
|
updateTheme == null ? void 0 : updateTheme(newTheme);
|
|
2764
2875
|
},
|
|
2765
2876
|
[updateTheme]
|
|
2766
2877
|
);
|
|
2767
|
-
const handleColorModeChange = (0,
|
|
2878
|
+
const handleColorModeChange = (0, import_react20.useCallback)(
|
|
2768
2879
|
(newMode) => {
|
|
2769
2880
|
setColorMode(newMode);
|
|
2770
2881
|
updateMode == null ? void 0 : updateMode(newMode);
|
|
2771
2882
|
},
|
|
2772
2883
|
[updateMode]
|
|
2773
2884
|
);
|
|
2774
|
-
(0,
|
|
2885
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2775
2886
|
const theme2 = localStorage.getItem(THEME_KEY);
|
|
2776
2887
|
if (theme2) {
|
|
2777
2888
|
setTheme(theme2);
|
|
2778
2889
|
}
|
|
2779
2890
|
}, []);
|
|
2780
|
-
(0,
|
|
2891
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2781
2892
|
const mode = localStorage.getItem(MODE_KEY);
|
|
2782
2893
|
if (mode) {
|
|
2783
2894
|
setColorMode(mode);
|
|
2784
2895
|
}
|
|
2785
2896
|
}, []);
|
|
2786
|
-
(0,
|
|
2897
|
+
(0, import_react20.useEffect)(() => {
|
|
2787
2898
|
const root = document.documentElement;
|
|
2788
2899
|
root.dataset.pandaTheme = theme;
|
|
2789
2900
|
if (cache) {
|
|
2790
2901
|
localStorage.setItem(THEME_KEY, theme);
|
|
2791
2902
|
}
|
|
2792
2903
|
}, [theme, cache]);
|
|
2793
|
-
(0,
|
|
2904
|
+
(0, import_react20.useEffect)(() => {
|
|
2794
2905
|
const root = document.documentElement;
|
|
2795
2906
|
if (colorMode === "system") {
|
|
2796
2907
|
root.dataset.colorMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -2801,7 +2912,7 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
2801
2912
|
localStorage.setItem(MODE_KEY, colorMode);
|
|
2802
2913
|
}
|
|
2803
2914
|
}, [colorMode, cache]);
|
|
2804
|
-
return (0,
|
|
2915
|
+
return (0, import_react20.useMemo)(
|
|
2805
2916
|
() => ({
|
|
2806
2917
|
theme,
|
|
2807
2918
|
mode: colorMode,
|
|
@@ -2813,8 +2924,8 @@ function useTheme(defaultTheme = "cerberus", defaultColorMode = "light", options
|
|
|
2813
2924
|
}
|
|
2814
2925
|
|
|
2815
2926
|
// src/context/theme.tsx
|
|
2816
|
-
var
|
|
2817
|
-
var ThemeContext = (0,
|
|
2927
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2928
|
+
var ThemeContext = (0, import_react21.createContext)(
|
|
2818
2929
|
null
|
|
2819
2930
|
);
|
|
2820
2931
|
function ThemeProvider(props) {
|
|
@@ -2823,10 +2934,10 @@ function ThemeProvider(props) {
|
|
|
2823
2934
|
updateMode: props.updateMode,
|
|
2824
2935
|
updateTheme: props.updateTheme
|
|
2825
2936
|
});
|
|
2826
|
-
return /* @__PURE__ */ (0,
|
|
2937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
2827
2938
|
}
|
|
2828
2939
|
function useThemeContext() {
|
|
2829
|
-
const context = (0,
|
|
2940
|
+
const context = (0, import_react21.useContext)(ThemeContext);
|
|
2830
2941
|
if (!context) {
|
|
2831
2942
|
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
2832
2943
|
}
|
|
@@ -2834,11 +2945,11 @@ function useThemeContext() {
|
|
|
2834
2945
|
}
|
|
2835
2946
|
|
|
2836
2947
|
// src/hooks/useToggle.ts
|
|
2837
|
-
var
|
|
2948
|
+
var import_react22 = require("react");
|
|
2838
2949
|
function useToggle(options) {
|
|
2839
|
-
const [checked, setChecked] = (0,
|
|
2950
|
+
const [checked, setChecked] = (0, import_react22.useState)((options == null ? void 0 : options.checked) ?? "");
|
|
2840
2951
|
const onChange = options == null ? void 0 : options.onChange;
|
|
2841
|
-
const handleChange = (0,
|
|
2952
|
+
const handleChange = (0, import_react22.useCallback)(
|
|
2842
2953
|
(e) => {
|
|
2843
2954
|
const target = e.currentTarget;
|
|
2844
2955
|
setChecked((prev) => {
|
|
@@ -2848,7 +2959,7 @@ function useToggle(options) {
|
|
|
2848
2959
|
},
|
|
2849
2960
|
[onChange]
|
|
2850
2961
|
);
|
|
2851
|
-
return (0,
|
|
2962
|
+
return (0, import_react22.useMemo)(() => ({ checked, handleChange }), [checked, handleChange]);
|
|
2852
2963
|
}
|
|
2853
2964
|
|
|
2854
2965
|
// src/utils/index.ts
|
|
@@ -2867,6 +2978,7 @@ __reExport(src_exports, require("@dnd-kit/core"), module.exports);
|
|
|
2867
2978
|
AdmonitionHeading,
|
|
2868
2979
|
Avatar,
|
|
2869
2980
|
Button,
|
|
2981
|
+
CTAModal,
|
|
2870
2982
|
Checkbox,
|
|
2871
2983
|
CircularProgress,
|
|
2872
2984
|
ConfirmModal,
|
|
@@ -2926,6 +3038,7 @@ __reExport(src_exports, require("@dnd-kit/core"), module.exports);
|
|
|
2926
3038
|
getPosition,
|
|
2927
3039
|
processStatus,
|
|
2928
3040
|
trapFocus,
|
|
3041
|
+
useCTAModal,
|
|
2929
3042
|
useConfirmModal,
|
|
2930
3043
|
useFeatureFlags,
|
|
2931
3044
|
useFieldContext,
|