@cerberus-design/react 0.6.1 → 0.7.0-next-e86fd39
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.ts +336 -4
- package/build/legacy/aria-helpers/tabs.aria.js +2 -2
- package/build/legacy/aria-helpers/trap-focus.aria.js +7 -0
- package/build/legacy/aria-helpers/trap-focus.aria.js.map +1 -0
- package/build/legacy/chunk-2F5TB2EV.js +25 -0
- package/build/legacy/chunk-2F5TB2EV.js.map +1 -0
- package/build/legacy/chunk-4CAT3FHV.js +11 -0
- package/build/legacy/chunk-4CAT3FHV.js.map +1 -0
- package/build/legacy/chunk-4M3EUP57.js +22 -0
- package/build/legacy/chunk-4M3EUP57.js.map +1 -0
- package/build/{modern/chunk-X4YQ27D5.js → legacy/chunk-5GEC53G7.js} +5 -5
- package/build/legacy/{chunk-YJCWUN33.js → chunk-67S42J4B.js} +5 -16
- package/build/legacy/chunk-67S42J4B.js.map +1 -0
- package/build/legacy/{chunk-3CBN7U25.js → chunk-6TXQZ3PB.js} +6 -3
- package/build/legacy/chunk-6TXQZ3PB.js.map +1 -0
- package/build/legacy/{chunk-DQOYTLGB.js → chunk-7KJIZIAU.js} +9 -5
- package/build/legacy/chunk-7KJIZIAU.js.map +1 -0
- package/build/legacy/chunk-C45DY4VE.js +17 -0
- package/build/legacy/chunk-C45DY4VE.js.map +1 -0
- package/build/{modern/chunk-HE3HFKYU.js → legacy/chunk-CU7HXAKM.js} +5 -5
- package/build/legacy/{chunk-HE3HFKYU.js.map → chunk-CU7HXAKM.js.map} +1 -1
- package/build/legacy/chunk-D3ZXZA3U.js +155 -0
- package/build/legacy/chunk-D3ZXZA3U.js.map +1 -0
- package/build/legacy/chunk-DGPLSWFJ.js +208 -0
- package/build/legacy/chunk-DGPLSWFJ.js.map +1 -0
- package/build/legacy/{chunk-5XNLWIZO.js → chunk-EVEEQRH6.js} +2 -2
- package/build/legacy/chunk-EVEEQRH6.js.map +1 -0
- package/build/legacy/chunk-G3JEWPLM.js +29 -0
- package/build/legacy/chunk-G3JEWPLM.js.map +1 -0
- package/build/legacy/chunk-JI4YTPEJ.js +47 -0
- package/build/legacy/chunk-JI4YTPEJ.js.map +1 -0
- package/build/legacy/chunk-KESKDLX6.js +30 -0
- package/build/legacy/chunk-KESKDLX6.js.map +1 -0
- package/build/legacy/{chunk-S7HBD2A7.js → chunk-KFUXGX33.js} +2 -2
- package/build/legacy/chunk-OGSAAB6K.js +12 -0
- package/build/legacy/chunk-OGSAAB6K.js.map +1 -0
- package/build/{modern/chunk-G2QMBSK5.js → legacy/chunk-PMCYXRAH.js} +2 -2
- package/build/legacy/chunk-PMCYXRAH.js.map +1 -0
- package/build/legacy/{chunk-734PGVLT.js → chunk-TAZI77TP.js} +2 -2
- package/build/legacy/chunk-TPFNVGYA.js +21 -0
- package/build/legacy/chunk-TPFNVGYA.js.map +1 -0
- package/build/legacy/chunk-TZNYJ3G7.js +25 -0
- package/build/legacy/chunk-TZNYJ3G7.js.map +1 -0
- package/build/legacy/chunk-UPODPCRD.js +12 -0
- package/build/legacy/chunk-UPODPCRD.js.map +1 -0
- package/build/legacy/chunk-VULPMZUW.js +18 -0
- package/build/legacy/chunk-VULPMZUW.js.map +1 -0
- package/build/{modern/chunk-5GSXIYD3.js → legacy/chunk-X2JMXTBH.js} +6 -8
- package/build/{modern/chunk-5GSXIYD3.js.map → legacy/chunk-X2JMXTBH.js.map} +1 -1
- package/build/legacy/components/FeatureFlag.js +10 -0
- package/build/legacy/components/FeatureFlag.js.map +1 -0
- package/build/legacy/components/Input.js +4 -4
- package/build/legacy/components/Label.js +2 -2
- package/build/legacy/components/Modal.js +7 -0
- package/build/legacy/components/Modal.js.map +1 -0
- package/build/legacy/components/ModalDescription.js +7 -0
- package/build/legacy/components/ModalDescription.js.map +1 -0
- package/build/legacy/components/ModalHeader.js +7 -0
- package/build/legacy/components/ModalHeader.js.map +1 -0
- package/build/legacy/components/ModalHeading.js +7 -0
- package/build/legacy/components/ModalHeading.js.map +1 -0
- package/build/legacy/components/ModalIcon.js +7 -0
- package/build/legacy/components/ModalIcon.js.map +1 -0
- package/build/legacy/components/NavMenuList.js +1 -1
- package/build/legacy/components/Portal.js +7 -0
- package/build/legacy/components/Portal.js.map +1 -0
- package/build/legacy/components/Tab.js +3 -3
- package/build/legacy/components/TabList.js +2 -2
- package/build/legacy/components/TabPanel.js +2 -2
- package/build/legacy/components/Tag.js +1 -1
- package/build/legacy/components/Toggle.js +3 -3
- package/build/legacy/config/cerbIcons.js +1 -1
- package/build/legacy/config/defineIcons.js +2 -2
- package/build/legacy/context/confirm-modal.js +22 -0
- package/build/legacy/context/confirm-modal.js.map +1 -0
- package/build/legacy/context/feature-flags.js +10 -0
- package/build/legacy/context/feature-flags.js.map +1 -0
- package/build/legacy/context/prompt-modal.js +25 -0
- package/build/legacy/context/prompt-modal.js.map +1 -0
- package/build/legacy/context/tabs.js +1 -1
- package/build/legacy/hooks/useModal.js +8 -0
- package/build/legacy/hooks/useModal.js.map +1 -0
- package/build/legacy/index.js +89 -35
- package/build/modern/_tsup-dts-rollup.d.ts +336 -4
- package/build/modern/aria-helpers/tabs.aria.js +2 -2
- package/build/modern/aria-helpers/trap-focus.aria.js +7 -0
- package/build/modern/aria-helpers/trap-focus.aria.js.map +1 -0
- package/build/modern/chunk-2F5TB2EV.js +25 -0
- package/build/modern/chunk-2F5TB2EV.js.map +1 -0
- package/build/modern/chunk-4CAT3FHV.js +11 -0
- package/build/modern/chunk-4CAT3FHV.js.map +1 -0
- package/build/modern/chunk-4M3EUP57.js +22 -0
- package/build/modern/chunk-4M3EUP57.js.map +1 -0
- package/build/{legacy/chunk-X4YQ27D5.js → modern/chunk-5GEC53G7.js} +5 -5
- package/build/modern/{chunk-YJCWUN33.js → chunk-67S42J4B.js} +5 -16
- package/build/modern/chunk-67S42J4B.js.map +1 -0
- package/build/modern/{chunk-3CBN7U25.js → chunk-6TXQZ3PB.js} +6 -3
- package/build/modern/chunk-6TXQZ3PB.js.map +1 -0
- package/build/modern/{chunk-DQOYTLGB.js → chunk-7KJIZIAU.js} +9 -5
- package/build/modern/chunk-7KJIZIAU.js.map +1 -0
- package/build/modern/chunk-C45DY4VE.js +17 -0
- package/build/modern/chunk-C45DY4VE.js.map +1 -0
- package/build/modern/chunk-C5HLLGME.js +23 -0
- package/build/modern/chunk-C5HLLGME.js.map +1 -0
- package/build/{legacy/chunk-HE3HFKYU.js → modern/chunk-CU7HXAKM.js} +5 -5
- package/build/modern/{chunk-HE3HFKYU.js.map → chunk-CU7HXAKM.js.map} +1 -1
- package/build/modern/chunk-G3JEWPLM.js +29 -0
- package/build/modern/chunk-G3JEWPLM.js.map +1 -0
- package/build/modern/chunk-HBEEHHON.js +46 -0
- package/build/modern/chunk-HBEEHHON.js.map +1 -0
- package/build/modern/chunk-JIZQFTW6.js +29 -0
- package/build/modern/chunk-JIZQFTW6.js.map +1 -0
- package/build/modern/{chunk-S7HBD2A7.js → chunk-KFUXGX33.js} +2 -2
- package/build/modern/chunk-OGSAAB6K.js +12 -0
- package/build/modern/chunk-OGSAAB6K.js.map +1 -0
- package/build/{legacy/chunk-G2QMBSK5.js → modern/chunk-PMCYXRAH.js} +2 -2
- package/build/modern/chunk-PMCYXRAH.js.map +1 -0
- package/build/modern/chunk-TAVCJ54A.js +154 -0
- package/build/modern/chunk-TAVCJ54A.js.map +1 -0
- package/build/modern/{chunk-734PGVLT.js → chunk-TAZI77TP.js} +2 -2
- package/build/modern/chunk-TPFNVGYA.js +21 -0
- package/build/modern/chunk-TPFNVGYA.js.map +1 -0
- package/build/modern/chunk-UPODPCRD.js +12 -0
- package/build/modern/chunk-UPODPCRD.js.map +1 -0
- package/build/modern/chunk-VULPMZUW.js +18 -0
- package/build/modern/chunk-VULPMZUW.js.map +1 -0
- package/build/modern/chunk-WWG5QWXY.js +207 -0
- package/build/modern/chunk-WWG5QWXY.js.map +1 -0
- package/build/{legacy/chunk-5GSXIYD3.js → modern/chunk-X2JMXTBH.js} +6 -8
- package/build/{legacy/chunk-5GSXIYD3.js.map → modern/chunk-X2JMXTBH.js.map} +1 -1
- package/build/modern/{chunk-SLIOCQBZ.js → chunk-Z6IWNVPN.js} +2 -2
- package/build/modern/chunk-Z6IWNVPN.js.map +1 -0
- package/build/modern/components/FeatureFlag.js +10 -0
- package/build/modern/components/FeatureFlag.js.map +1 -0
- package/build/modern/components/Input.js +4 -4
- package/build/modern/components/Label.js +2 -2
- package/build/modern/components/Modal.js +7 -0
- package/build/modern/components/Modal.js.map +1 -0
- package/build/modern/components/ModalDescription.js +7 -0
- package/build/modern/components/ModalDescription.js.map +1 -0
- package/build/modern/components/ModalHeader.js +7 -0
- package/build/modern/components/ModalHeader.js.map +1 -0
- package/build/modern/components/ModalHeading.js +7 -0
- package/build/modern/components/ModalHeading.js.map +1 -0
- package/build/modern/components/ModalIcon.js +7 -0
- package/build/modern/components/ModalIcon.js.map +1 -0
- package/build/modern/components/NavMenuList.js +1 -1
- package/build/modern/components/Portal.js +7 -0
- package/build/modern/components/Portal.js.map +1 -0
- package/build/modern/components/Tab.js +3 -3
- package/build/modern/components/TabList.js +2 -2
- package/build/modern/components/TabPanel.js +2 -2
- package/build/modern/components/Tag.js +1 -1
- 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 +22 -0
- package/build/modern/context/confirm-modal.js.map +1 -0
- package/build/modern/context/feature-flags.js +10 -0
- package/build/modern/context/feature-flags.js.map +1 -0
- package/build/modern/context/prompt-modal.js +25 -0
- package/build/modern/context/prompt-modal.js.map +1 -0
- package/build/modern/context/tabs.js +1 -1
- package/build/modern/hooks/useModal.js +8 -0
- package/build/modern/hooks/useModal.js.map +1 -0
- package/build/modern/index.js +89 -35
- package/package.json +3 -2
- package/src/aria-helpers/trap-focus.aria.ts +29 -0
- package/src/components/FeatureFlag.tsx +14 -0
- package/src/components/Label.tsx +1 -1
- package/src/components/Modal.tsx +37 -0
- package/src/components/ModalDescription.tsx +23 -0
- package/src/components/ModalHeader.tsx +37 -0
- package/src/components/ModalHeading.tsx +23 -0
- package/src/components/ModalIcon.tsx +28 -0
- package/src/components/NavMenuList.tsx +1 -1
- package/src/components/Portal.tsx +22 -0
- package/src/components/Tab.tsx +3 -84
- package/src/components/TabList.tsx +2 -4
- package/src/components/TabPanel.tsx +3 -14
- package/src/components/Tag.tsx +1 -1
- package/src/config/cerbIcons.ts +11 -2
- package/src/config/defineIcons.ts +6 -3
- package/src/context/confirm-modal.tsx +185 -0
- package/src/context/feature-flags.tsx +60 -0
- package/src/context/prompt-modal.tsx +232 -0
- package/src/context/tabs.tsx +15 -5
- package/src/hooks/useModal.ts +34 -0
- package/src/index.ts +12 -0
- package/build/legacy/chunk-3CBN7U25.js.map +0 -1
- package/build/legacy/chunk-5MNCW677.js +0 -11
- package/build/legacy/chunk-5MNCW677.js.map +0 -1
- package/build/legacy/chunk-5XNLWIZO.js.map +0 -1
- package/build/legacy/chunk-DQOYTLGB.js.map +0 -1
- package/build/legacy/chunk-G2QMBSK5.js.map +0 -1
- package/build/legacy/chunk-YA2UV2AB.js +0 -126
- package/build/legacy/chunk-YA2UV2AB.js.map +0 -1
- package/build/legacy/chunk-YJCWUN33.js.map +0 -1
- package/build/modern/chunk-3CBN7U25.js.map +0 -1
- package/build/modern/chunk-5MNCW677.js +0 -11
- package/build/modern/chunk-5MNCW677.js.map +0 -1
- package/build/modern/chunk-DQOYTLGB.js.map +0 -1
- package/build/modern/chunk-G2QMBSK5.js.map +0 -1
- package/build/modern/chunk-SLIOCQBZ.js.map +0 -1
- package/build/modern/chunk-SUP7U42W.js +0 -125
- package/build/modern/chunk-SUP7U42W.js.map +0 -1
- package/build/modern/chunk-YJCWUN33.js.map +0 -1
- /package/build/legacy/{chunk-X4YQ27D5.js.map → chunk-5GEC53G7.js.map} +0 -0
- /package/build/legacy/{chunk-S7HBD2A7.js.map → chunk-KFUXGX33.js.map} +0 -0
- /package/build/legacy/{chunk-734PGVLT.js.map → chunk-TAZI77TP.js.map} +0 -0
- /package/build/modern/{chunk-X4YQ27D5.js.map → chunk-5GEC53G7.js.map} +0 -0
- /package/build/modern/{chunk-S7HBD2A7.js.map → chunk-KFUXGX33.js.map} +0 -0
- /package/build/modern/{chunk-734PGVLT.js.map → chunk-TAZI77TP.js.map} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/Portal.tsx
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
function Portal(props) {
|
|
4
|
+
const container = props.container || document.body;
|
|
5
|
+
return createPortal(props.children, container, props.key);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Portal
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-4CAT3FHV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Portal.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport interface PortalProps {\n container?: Element | DocumentFragment\n key?: null | string\n}\n\n/**\n * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.\n * @param container - The props for the Portal component.\n * @returns ReactPortal\n */\nexport function Portal(props: PropsWithChildren<PortalProps>) {\n const container = props.container || document.body\n return createPortal(props.children, container, props.key)\n}\n"],"mappings":";AACA,SAAS,oBAAoB;AAiBtB,SAAS,OAAO,OAAuC;AAC5D,QAAM,YAAY,MAAM,aAAa,SAAS;AAC9C,SAAO,aAAa,MAAM,UAAU,WAAW,MAAM,GAAG;AAC1D;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/context/feature-flags.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var FeatureFlagContext = createContext(null);
|
|
5
|
+
function FeatureFlags(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx(FeatureFlagContext.Provider, { value: props.flags, children: props.children });
|
|
7
|
+
}
|
|
8
|
+
function useFeatureFlags(key) {
|
|
9
|
+
const context = useContext(FeatureFlagContext);
|
|
10
|
+
if (context === null) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"useFeatureFlag must be used within a FeatureFlags Provider"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return context[key] ?? false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
FeatureFlags,
|
|
20
|
+
useFeatureFlags
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-4M3EUP57.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/feature-flags.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\n\n/**\n * This module provides a context and hook for feature flags.\n * @module\n */\n\nexport interface FeatureFlagValue {\n [key: string]: boolean\n}\n\nconst FeatureFlagContext = createContext<FeatureFlagValue | null>(null)\n\nexport interface FeatureFlagProviderProps {\n flags: FeatureFlagValue\n}\n\n/**\n * Provides feature flags to the application.\n * @param flags - The flags data for the provider.\n * @example\n * ```tsx\n * // This should be a JSON file or a server response.\n * const flags = {\n * featureOne: true,\n * featureTwo: false\n * }\n *\n * // Wrap the Provider around the root of your application.\n * <FeatureFlags flags={flags}>\n * <FeatureFlag flag=\"featureOne\">\n * This is visible.\n * </FeatureFlag>\n * <FeatureFlag flag=\"featureTwo\">\n * This is hidden.\n * </FeatureFlag>\n * </FeatureFlags>\n * ```\n */\nexport function FeatureFlags(\n props: PropsWithChildren<FeatureFlagProviderProps>,\n) {\n return (\n <FeatureFlagContext.Provider value={props.flags}>\n {props.children}\n </FeatureFlagContext.Provider>\n )\n}\n\nexport function useFeatureFlags(key: string): boolean {\n const context = useContext(FeatureFlagContext)\n if (context === null) {\n throw new Error(\n 'useFeatureFlag must be used within a FeatureFlags Provider',\n )\n }\n return context[key] ?? false\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAA0C;AA2C9D;AAhCJ,IAAM,qBAAqB,cAAuC,IAAI;AA4B/D,SAAS,aACd,OACA;AACA,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,MAAM,OACvC,gBAAM,UACT;AAEJ;AAEO,SAAS,gBAAgB,KAAsB;AACpD,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,QAAQ,GAAG,KAAK;AACzB;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useFieldContext
|
|
3
|
-
} from "./chunk-ZAU4JVLL.js";
|
|
4
1
|
import {
|
|
5
2
|
Show
|
|
6
3
|
} from "./chunk-4O4QFF4S.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
7
|
import {
|
|
8
8
|
$cerberusIcons
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6TXQZ3PB.js";
|
|
10
10
|
|
|
11
11
|
// src/components/Input.tsx
|
|
12
12
|
import { input } from "@cerberus/styled-system/recipes";
|
|
@@ -39,4 +39,4 @@ function Input(props) {
|
|
|
39
39
|
export {
|
|
40
40
|
Input
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-5GEC53G7.js.map
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-4O4QFF4S.js";
|
|
4
4
|
import {
|
|
5
5
|
useTabsContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7KJIZIAU.js";
|
|
7
7
|
|
|
8
8
|
// src/components/TabPanel.tsx
|
|
9
|
-
import {
|
|
9
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
function TabPanel(props) {
|
|
13
13
|
const { tab, ...nativeProps } = props;
|
|
14
|
-
const { active } = useTabsContext();
|
|
14
|
+
const { active, styles } = useTabsContext();
|
|
15
15
|
const isActive = useMemo(() => active === tab, [active, tab]);
|
|
16
16
|
return /* @__PURE__ */ jsx(Show, { when: isActive, children: /* @__PURE__ */ jsx(
|
|
17
17
|
"div",
|
|
@@ -19,18 +19,7 @@ function TabPanel(props) {
|
|
|
19
19
|
...nativeProps,
|
|
20
20
|
...isActive && { tabIndex: 0 },
|
|
21
21
|
"aria-labelledby": tab,
|
|
22
|
-
className: cx(
|
|
23
|
-
nativeProps.className,
|
|
24
|
-
css({
|
|
25
|
-
rounded: "md",
|
|
26
|
-
_focusVisible: {
|
|
27
|
-
boxShadow: "none",
|
|
28
|
-
outline: "3px solid",
|
|
29
|
-
outlineColor: "action.border.focus",
|
|
30
|
-
outlineOffset: "2px"
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
),
|
|
22
|
+
className: cx(nativeProps.className, styles.tabPanel),
|
|
34
23
|
id: `panel:${tab}`,
|
|
35
24
|
role: "tabpanel"
|
|
36
25
|
}
|
|
@@ -40,4 +29,4 @@ function TabPanel(props) {
|
|
|
40
29
|
export {
|
|
41
30
|
TabPanel
|
|
42
31
|
};
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-67S42J4B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/TabPanel.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { Show } from './Show'\n\n/**\n * This module provides a TabPanel component.\n * @module\n */\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n tab: string\n}\n\n/**\n * The TabPanel component provides a panel element to be used in a Tabs provider.\n * @param tab - the value of the tab that will be tracked as the active tab and used for aria attributes\n * @example\n * ```tsx\n * <TabPanel tab=\"overview\">\n * Overview content\n * </TabPanel>\n * ```\n */\nexport function TabPanel(props: TabPanelProps) {\n const { tab, ...nativeProps } = props\n const { active, styles } = useTabsContext()\n const isActive = useMemo(() => active === tab, [active, tab])\n\n return (\n <Show when={isActive}>\n <div\n {...nativeProps}\n {...(isActive && { tabIndex: 0 })}\n aria-labelledby={tab}\n className={cx(nativeProps.className, styles.tabPanel)}\n id={`panel:${tab}`}\n role=\"tabpanel\"\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,UAAU;AACnB,SAAS,eAAoC;AA8BvC;AAPC,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,KAAK,GAAG,YAAY,IAAI;AAChC,QAAM,EAAE,QAAQ,OAAO,IAAI,eAAe;AAC1C,QAAM,WAAW,QAAQ,MAAM,WAAW,KAAK,CAAC,QAAQ,GAAG,CAAC;AAE5D,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,YAAY,EAAE,UAAU,EAAE;AAAA,MAC/B,mBAAiB;AAAA,MACjB,WAAW,GAAG,YAAY,WAAW,OAAO,QAAQ;AAAA,MACpD,IAAI,SAAS,GAAG;AAAA,MAChB,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultIcons
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C45DY4VE.js";
|
|
4
4
|
|
|
5
5
|
// src/config/defineIcons.ts
|
|
6
6
|
function _validateIconsProperties(icons) {
|
|
@@ -12,7 +12,10 @@ function _validateIconsProperties(icons) {
|
|
|
12
12
|
}
|
|
13
13
|
function defineIcons(icons) {
|
|
14
14
|
_validateIconsProperties(icons);
|
|
15
|
-
$cerberusIcons =
|
|
15
|
+
$cerberusIcons = {
|
|
16
|
+
...defaultIcons,
|
|
17
|
+
...icons
|
|
18
|
+
};
|
|
16
19
|
return $cerberusIcons;
|
|
17
20
|
}
|
|
18
21
|
var $cerberusIcons = defaultIcons;
|
|
@@ -21,4 +24,4 @@ export {
|
|
|
21
24
|
defineIcons,
|
|
22
25
|
$cerberusIcons
|
|
23
26
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-6TXQZ3PB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/defineIcons.ts"],"sourcesContent":["import { defaultIcons, type DefinedIcons } from './cerbIcons'\n\nfunction _validateIconsProperties(icons: DefinedIcons) {\n if (!icons.invalid) {\n throw new Error(\n 'The an invalid property must be defined in your custom icons library.',\n )\n }\n}\n\nexport function defineIcons(icons: DefinedIcons): Required<DefinedIcons> {\n _validateIconsProperties(icons)\n $cerberusIcons = {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons>\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons = defaultIcons as Required<DefinedIcons>\n"],"mappings":";;;;;AAEA,SAAS,yBAAyB,OAAqB;AACrD,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,YAAY,OAA6C;AACvE,2BAAyB,KAAK;AAC9B,mBAAiB;AAAA,IACf,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACA,SAAO;AACT;AAIO,IAAI,iBAAiB;","names":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// src/context/tabs.tsx
|
|
2
|
+
import {
|
|
3
|
+
tabs
|
|
4
|
+
} from "@cerberus-design/styled-system/recipes";
|
|
2
5
|
import {
|
|
3
6
|
createContext,
|
|
4
7
|
useContext,
|
|
@@ -10,20 +13,21 @@ import {
|
|
|
10
13
|
import { jsx } from "react/jsx-runtime";
|
|
11
14
|
var TabsContext = createContext(null);
|
|
12
15
|
function Tabs(props) {
|
|
13
|
-
const { cache, active, id } = props;
|
|
16
|
+
const { cache, active, id, palette } = props;
|
|
14
17
|
const [activeTab, setActiveTab] = useState(() => cache ? "" : active ?? "");
|
|
15
|
-
const
|
|
18
|
+
const tabsList = useRef([]);
|
|
16
19
|
const uuid = useMemo(() => {
|
|
17
20
|
return id ? `cerberus-tabs-${id}` : "cerberus-tabs";
|
|
18
21
|
}, [id]);
|
|
19
22
|
const value = useMemo(
|
|
20
23
|
() => ({
|
|
21
|
-
tabs,
|
|
24
|
+
tabs: tabsList,
|
|
22
25
|
id: uuid,
|
|
23
26
|
active: activeTab,
|
|
27
|
+
styles: tabs({ palette }),
|
|
24
28
|
onTabUpdate: setActiveTab
|
|
25
29
|
}),
|
|
26
|
-
[activeTab, setActiveTab, uuid,
|
|
30
|
+
[activeTab, setActiveTab, palette, uuid, tabsList]
|
|
27
31
|
);
|
|
28
32
|
useEffect(() => {
|
|
29
33
|
if (cache) {
|
|
@@ -53,4 +57,4 @@ export {
|
|
|
53
57
|
Tabs,
|
|
54
58
|
useTabsContext
|
|
55
59
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-7KJIZIAU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/tabs.tsx"],"sourcesContent":["'use client'\n\nimport {\n tabs,\n type TabsVariantProps,\n} from '@cerberus-design/styled-system/recipes'\nimport type { Pretty } from '@cerberus-design/styled-system/types'\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a Tabs component and a hook to access its context.\n * @module\n */\n\nexport interface TabsContextValue {\n tabs: MutableRefObject<HTMLButtonElement[]>\n id: string\n active: string\n styles: Pretty<Record<'tabList' | 'tab' | 'tabPanel', string>>\n onTabUpdate: (active: string) => void\n}\n\nexport const TabsContext = createContext<TabsContextValue | null>(null)\n\nexport interface TabsProps {\n id?: string\n active?: string\n cache?: boolean\n}\n\n/**\n * The Tabs component provides a context to manage tab state.\n * @param id - the id of the tabs component,\n * @param active - the default active tab id,\n * @param cache - whether to cache the active tab state in local storage\n * @example\n * ```tsx\n * <Tabs cache>\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * <TabPanels>\n * <TabPanel id=\"overview\">Overview content</TabPanel>\n * <TabPanel id=\"guidelines\">Guidelines content</TabPanel>\n * </TabPanels>\n * </Tabs>\n * ```\n */\nexport function Tabs(\n props: PropsWithChildren<TabsProps & TabsVariantProps>,\n): JSX.Element {\n const { cache, active, id, palette } = props\n const [activeTab, setActiveTab] = useState(() => (cache ? '' : active ?? ''))\n const tabsList = useRef<HTMLButtonElement[]>([])\n const uuid = useMemo(() => {\n return id ? `cerberus-tabs-${id}` : 'cerberus-tabs'\n }, [id])\n\n const value = useMemo(\n () => ({\n tabs: tabsList,\n id: uuid,\n active: activeTab,\n styles: tabs({ palette }),\n onTabUpdate: setActiveTab,\n }),\n [activeTab, setActiveTab, palette, uuid, tabsList],\n )\n\n // Get the active tab from local storage\n useEffect(() => {\n if (cache) {\n const cachedTab = window.localStorage.getItem(uuid)\n setActiveTab(\n cache ? cachedTab || (props.active ?? '') : props.active ?? '',\n )\n }\n }, [cache, active, uuid])\n\n // Update the active tab in local storage\n useEffect(() => {\n if (cache && activeTab) {\n window.localStorage.setItem(uuid, activeTab)\n }\n }, [activeTab, cache])\n\n return (\n <TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>\n )\n}\n\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs Provider.')\n }\n return context\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAiFH;AAlEG,IAAM,cAAc,cAAuC,IAAI;AA2B/D,SAAS,KACd,OACa;AACb,QAAM,EAAE,OAAO,QAAQ,IAAI,QAAQ,IAAI;AACvC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,MAAO,QAAQ,KAAK,UAAU,EAAG;AAC5E,QAAM,WAAW,OAA4B,CAAC,CAAC;AAC/C,QAAM,OAAO,QAAQ,MAAM;AACzB,WAAO,KAAK,iBAAiB,EAAE,KAAK;AAAA,EACtC,GAAG,CAAC,EAAE,CAAC;AAEP,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAAA,MACxB,aAAa;AAAA,IACf;AAAA,IACA,CAAC,WAAW,cAAc,SAAS,MAAM,QAAQ;AAAA,EACnD;AAGA,YAAU,MAAM;AACd,QAAI,OAAO;AACT,YAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAClD;AAAA,QACE,QAAQ,cAAc,MAAM,UAAU,MAAM,MAAM,UAAU;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,IAAI,CAAC;AAGxB,YAAU,MAAM;AACd,QAAI,SAAS,WAAW;AACtB,aAAO,aAAa,QAAQ,MAAM,SAAS;AAAA,IAC7C;AAAA,EACF,GAAG,CAAC,WAAW,KAAK,CAAC;AAErB,SACE,oBAAC,YAAY,UAAZ,EAAqB,OAAe,gBAAM,UAAS;AAExD;AAEO,SAAS,iBAAmC;AACjD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/config/cerbIcons.ts
|
|
2
|
+
import {
|
|
3
|
+
Checkmark,
|
|
4
|
+
Information,
|
|
5
|
+
WarningFilled
|
|
6
|
+
} from "@cerberus/icons";
|
|
7
|
+
var defaultIcons = {
|
|
8
|
+
confirmModal: Information,
|
|
9
|
+
promptModal: Information,
|
|
10
|
+
invalid: WarningFilled,
|
|
11
|
+
toggleChecked: Checkmark
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
defaultIcons
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-C45DY4VE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/cerbIcons.ts"],"sourcesContent":["import {\n Checkmark,\n Information,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\n\nexport interface DefinedIcons {\n confirmModal?: CarbonIconType | ElementType\n promptModal?: CarbonIconType | ElementType\n invalid: CarbonIconType | ElementType\n toggleChecked?: CarbonIconType | ElementType\n}\n\nexport const defaultIcons: DefinedIcons = {\n confirmModal: Information,\n promptModal: Information,\n invalid: WarningFilled,\n toggleChecked: Checkmark,\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAUA,IAAM,eAA6B;AAAA,EACxC,cAAc;AAAA,EACd,aAAa;AAAA,EACb,SAAS;AAAA,EACT,eAAe;AACjB;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/hooks/useModal.ts
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
function useModal() {
|
|
4
|
+
const modalRef = useRef(null);
|
|
5
|
+
const show = useCallback(() => {
|
|
6
|
+
modalRef.current?.showModal();
|
|
7
|
+
}, []);
|
|
8
|
+
const close = useCallback(() => {
|
|
9
|
+
modalRef.current?.close();
|
|
10
|
+
}, []);
|
|
11
|
+
return useMemo(() => {
|
|
12
|
+
return {
|
|
13
|
+
modalRef,
|
|
14
|
+
show,
|
|
15
|
+
close
|
|
16
|
+
};
|
|
17
|
+
}, [modalRef, show, close]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
useModal
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-C5HLLGME.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useModal.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useMemo, useRef, type RefObject } from 'react'\n\n/**\n * This module provides a hook for using a custom modal.\n * @module\n */\n\ninterface UseModalReturnValue {\n modalRef: RefObject<HTMLDialogElement>\n show: () => void\n close: () => void\n}\n\nexport function useModal(): UseModalReturnValue {\n const modalRef = useRef<HTMLDialogElement | null>(null)\n\n const show = useCallback(() => {\n modalRef.current?.showModal()\n }, [])\n\n const close = useCallback(() => {\n modalRef.current?.close()\n }, [])\n\n return useMemo(() => {\n return {\n modalRef,\n show,\n close,\n }\n }, [modalRef, show, close])\n}\n"],"mappings":";AAEA,SAAS,aAAa,SAAS,cAA8B;AAatD,SAAS,WAAgC;AAC9C,QAAM,WAAW,OAAiC,IAAI;AAEtD,QAAM,OAAO,YAAY,MAAM;AAC7B,aAAS,SAAS,UAAU;AAAA,EAC9B,GAAG,CAAC,CAAC;AAEL,QAAM,QAAQ,YAAY,MAAM;AAC9B,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,CAAC;AAEL,SAAO,QAAQ,MAAM;AACnB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,MAAM,KAAK,CAAC;AAC5B;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useFieldContext
|
|
3
|
-
} from "./chunk-ZAU4JVLL.js";
|
|
4
1
|
import {
|
|
5
2
|
Show
|
|
6
3
|
} from "./chunk-4O4QFF4S.js";
|
|
4
|
+
import {
|
|
5
|
+
useFieldContext
|
|
6
|
+
} from "./chunk-ZAU4JVLL.js";
|
|
7
7
|
|
|
8
8
|
// src/components/Label.tsx
|
|
9
9
|
import { label } from "@cerberus/styled-system/recipes";
|
|
@@ -32,7 +32,7 @@ function Label(props) {
|
|
|
32
32
|
"span",
|
|
33
33
|
{
|
|
34
34
|
className: css({
|
|
35
|
-
color: "
|
|
35
|
+
color: "page.text.100",
|
|
36
36
|
fontSize: "inherit"
|
|
37
37
|
}),
|
|
38
38
|
children: "(required)"
|
|
@@ -46,4 +46,4 @@ function Label(props) {
|
|
|
46
46
|
export {
|
|
47
47
|
Label
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-CU7HXAKM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: '
|
|
1
|
+
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'page.text.100',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,KAAK,UAAmC;AACjD,SAAS,cAAc;AAiCnB,SAaI,KAbJ;AANG,SAAS,MAAM,OAAsC;AAC1D,QAAM,EAAE,QAAQ,MAAM,GAAG,YAAY,IAAI;AACzC,QAAM,EAAE,UAAU,SAAS,IAAI,gBAAgB;AAC/C,QAAM,QAAQ,SAAS,WAAW;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe;AAAA,MACf,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,QACrB,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,MAEC;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,MAAM,UACV;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,OAAO;AAAA,cACP,UAAU;AAAA,YACZ,CAAC;AAAA,YACF;AAAA;AAAA,QAED,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/components/ModalIcon.tsx
|
|
2
|
+
import { cx } from "@cerberus-design/styled-system/css";
|
|
3
|
+
import { circle } from "@cerberus-design/styled-system/patterns";
|
|
4
|
+
import {
|
|
5
|
+
modalIcon
|
|
6
|
+
} from "@cerberus-design/styled-system/recipes";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
function ModalIcon(props) {
|
|
9
|
+
const { palette, ...nativeProps } = props;
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
...nativeProps,
|
|
14
|
+
className: cx(
|
|
15
|
+
nativeProps.className,
|
|
16
|
+
modalIcon({
|
|
17
|
+
palette
|
|
18
|
+
}),
|
|
19
|
+
circle()
|
|
20
|
+
),
|
|
21
|
+
children: props.children
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
ModalIcon
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-G3JEWPLM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/ModalIcon.tsx"],"sourcesContent":["import { cx } from '@cerberus-design/styled-system/css'\nimport { circle } from '@cerberus-design/styled-system/patterns'\nimport {\n modalIcon,\n type ModalIconVariantProps,\n} from '@cerberus-design/styled-system/recipes'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\nexport type ModalIconBaseProps = HTMLAttributes<HTMLDivElement>\nexport type ModalIconProps = ModalIconBaseProps & ModalIconVariantProps\n\nexport function ModalIcon(props: PropsWithChildren<ModalIconProps>) {\n const { palette, ...nativeProps } = props\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n modalIcon({\n palette,\n }),\n circle(),\n )}\n >\n {props.children}\n </div>\n )\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAEK;AASH;AAHG,SAAS,UAAU,OAA0C;AAClE,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI;AACpC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,UAAU;AAAA,UACR;AAAA,QACF,CAAC;AAAA,QACD,OAAO;AAAA,MACT;AAAA,MAEC,gBAAM;AAAA;AAAA,EACT;AAEJ;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTabsKeyboardNavigation
|
|
3
|
+
} from "./chunk-KFUXGX33.js";
|
|
4
|
+
import {
|
|
5
|
+
useTabsContext
|
|
6
|
+
} from "./chunk-7KJIZIAU.js";
|
|
7
|
+
|
|
8
|
+
// src/components/Tab.tsx
|
|
9
|
+
import {
|
|
10
|
+
useMemo,
|
|
11
|
+
useTransition
|
|
12
|
+
} from "react";
|
|
13
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
function Tab(props) {
|
|
16
|
+
const { value, ...nativeProps } = props;
|
|
17
|
+
const { active, onTabUpdate, styles } = useTabsContext();
|
|
18
|
+
const [isPending, startTransition] = useTransition();
|
|
19
|
+
const { ref } = useTabsKeyboardNavigation();
|
|
20
|
+
const isActive = useMemo(() => active === value, [active, value]);
|
|
21
|
+
function handleClick(e) {
|
|
22
|
+
props.onClick?.(e);
|
|
23
|
+
startTransition(() => onTabUpdate(e.currentTarget.value));
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
"button",
|
|
27
|
+
{
|
|
28
|
+
...nativeProps,
|
|
29
|
+
...!isActive && { tabIndex: -1 },
|
|
30
|
+
"aria-controls": `panel:${value}`,
|
|
31
|
+
"aria-busy": isPending,
|
|
32
|
+
"aria-selected": isActive,
|
|
33
|
+
id: value,
|
|
34
|
+
className: cx(nativeProps.className, styles.tab),
|
|
35
|
+
onClick: handleClick,
|
|
36
|
+
role: "tab",
|
|
37
|
+
ref,
|
|
38
|
+
value
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
Tab
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=chunk-HBEEHHON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tab.tsx"],"sourcesContent":["'use client'\n\nimport {\n useMemo,\n useTransition,\n type ButtonHTMLAttributes,\n type MouseEvent,\n} from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { cx } from '@cerberus/styled-system/css'\nimport { useTabsKeyboardNavigation } from '../aria-helpers/tabs.aria'\n\n/**\n * This module provides a Tab component.\n * @module\n */\nexport interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n value: string\n}\n\n/**\n * The Tab component provides a tab element to be used in a TabList.\n * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)\n * @definition [Tab docs](https://cerberus.digitalu.design/react/tabs)\n * @param value - the id of the tab that will be tracked as the active tab and used for aria attributes\n * @example\n * ```tsx\n * <Tab value=\"overview\">\n * Overview\n * </Tab>\n * ```\n */\nexport function Tab(props: TabProps) {\n const { value, ...nativeProps } = props\n const { active, onTabUpdate, styles } = useTabsContext()\n const [isPending, startTransition] = useTransition()\n const { ref } = useTabsKeyboardNavigation()\n const isActive = useMemo(() => active === value, [active, value])\n\n function handleClick(e: MouseEvent<HTMLButtonElement>) {\n props.onClick?.(e)\n startTransition(() => onTabUpdate(e.currentTarget.value))\n }\n\n return (\n <button\n {...nativeProps}\n {...(!isActive && { tabIndex: -1 })}\n aria-controls={`panel:${value}`}\n aria-busy={isPending}\n aria-selected={isActive}\n id={value}\n className={cx(nativeProps.className, styles.tab)}\n onClick={handleClick}\n role=\"tab\"\n ref={ref}\n value={value}\n />\n )\n}\n"],"mappings":";;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,UAAU;AAoCf;AAbG,SAAS,IAAI,OAAiB;AACnC,QAAM,EAAE,OAAO,GAAG,YAAY,IAAI;AAClC,QAAM,EAAE,QAAQ,aAAa,OAAO,IAAI,eAAe;AACvD,QAAM,CAAC,WAAW,eAAe,IAAI,cAAc;AACnD,QAAM,EAAE,IAAI,IAAI,0BAA0B;AAC1C,QAAM,WAAW,QAAQ,MAAM,WAAW,OAAO,CAAC,QAAQ,KAAK,CAAC;AAEhE,WAAS,YAAY,GAAkC;AACrD,UAAM,UAAU,CAAC;AACjB,oBAAgB,MAAM,YAAY,EAAE,cAAc,KAAK,CAAC;AAAA,EAC1D;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,CAAC,YAAY,EAAE,UAAU,GAAG;AAAA,MACjC,iBAAe,SAAS,KAAK;AAAA,MAC7B,aAAW;AAAA,MACX,iBAAe;AAAA,MACf,IAAI;AAAA,MACJ,WAAW,GAAG,YAAY,WAAW,OAAO,GAAG;AAAA,MAC/C,SAAS;AAAA,MACT,MAAK;AAAA,MACL;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/aria-helpers/trap-focus.aria.ts
|
|
2
|
+
function trapFocus(modalRef) {
|
|
3
|
+
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
4
|
+
const focusable = Array.from(
|
|
5
|
+
modalRef.current?.querySelectorAll(focusableElements) ?? []
|
|
6
|
+
);
|
|
7
|
+
const firstFocusable = focusable[0];
|
|
8
|
+
const lastFocusable = focusable[focusable.length - 1];
|
|
9
|
+
return function handleKeyDown(event) {
|
|
10
|
+
if (event.key === "Tab") {
|
|
11
|
+
if (event.shiftKey) {
|
|
12
|
+
if (document.activeElement === firstFocusable) {
|
|
13
|
+
lastFocusable.focus();
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
if (document.activeElement === lastFocusable) {
|
|
18
|
+
firstFocusable.focus();
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
trapFocus
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-JIZQFTW6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/aria-helpers/trap-focus.aria.ts"],"sourcesContent":["import type { KeyboardEvent, KeyboardEventHandler, RefObject } from 'react'\n\nexport function trapFocus(\n modalRef: RefObject<HTMLDialogElement>,\n): KeyboardEventHandler<HTMLDialogElement> {\n const focusableElements =\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n const focusable = Array.from(\n modalRef.current?.querySelectorAll(focusableElements) ?? [],\n )\n const firstFocusable = focusable[0] as HTMLElement\n const lastFocusable = focusable[focusable.length - 1] as HTMLElement\n\n return function handleKeyDown(event: KeyboardEvent<HTMLDialogElement>) {\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstFocusable) {\n lastFocusable.focus()\n event.preventDefault()\n }\n } else {\n if (document.activeElement === lastFocusable) {\n firstFocusable.focus()\n event.preventDefault()\n }\n }\n }\n }\n}\n"],"mappings":";AAEO,SAAS,UACd,UACyC;AACzC,QAAM,oBACJ;AACF,QAAM,YAAY,MAAM;AAAA,IACtB,SAAS,SAAS,iBAAiB,iBAAiB,KAAK,CAAC;AAAA,EAC5D;AACA,QAAM,iBAAiB,UAAU,CAAC;AAClC,QAAM,gBAAgB,UAAU,UAAU,SAAS,CAAC;AAEpD,SAAO,SAAS,cAAc,OAAyC;AACrE,QAAI,MAAM,QAAQ,OAAO;AACvB,UAAI,MAAM,UAAU;AAClB,YAAI,SAAS,kBAAkB,gBAAgB;AAC7C,wBAAc,MAAM;AACpB,gBAAM,eAAe;AAAA,QACvB;AAAA,MACF,OAAO;AACL,YAAI,SAAS,kBAAkB,eAAe;AAC5C,yBAAe,MAAM;AACrB,gBAAM,eAAe;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useTabsContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7KJIZIAU.js";
|
|
4
4
|
|
|
5
5
|
// src/aria-helpers/tabs.aria.ts
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
@@ -61,4 +61,4 @@ function useTabsKeyboardNavigation() {
|
|
|
61
61
|
export {
|
|
62
62
|
useTabsKeyboardNavigation
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-KFUXGX33.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/components/ModalHeading.tsx
|
|
2
|
+
import { cx } from "@cerberus-design/styled-system/css";
|
|
3
|
+
import { modal } from "@cerberus-design/styled-system/recipes";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function ModalHeading(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx("p", { ...props, className: cx(props.className, modal().heading) });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
ModalHeading
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-OGSAAB6K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/ModalHeading.tsx"],"sourcesContent":["import { cx } from '@cerberus-design/styled-system/css'\nimport { modal } from '@cerberus-design/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeading component for a customizable modal.\n * @module\n */\n\nexport type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * The ModalHeading component is a heading element for a customizable modal.\n * @example\n * ```tsx\n * <Modal>\n * <ModalHeading>Modal Heading</ModalHeading>\n * </Modal>\n * ```\n */\nexport function ModalHeading(props: ModalHeadingProps) {\n return <p {...props} className={cx(props.className, modal().heading)} />\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,aAAa;AAoBb;AADF,SAAS,aAAa,OAA0B;AACrD,SAAO,oBAAC,OAAG,GAAG,OAAO,WAAW,GAAG,MAAM,WAAW,MAAM,EAAE,OAAO,GAAG;AACxE;","names":[]}
|
|
@@ -32,7 +32,7 @@ function getPosition(position) {
|
|
|
32
32
|
}
|
|
33
33
|
var navListStyles = vstack({
|
|
34
34
|
alignItems: "flex-start",
|
|
35
|
-
bgColor: "
|
|
35
|
+
bgColor: "page.surface.100",
|
|
36
36
|
boxShadow: "lg",
|
|
37
37
|
gap: "2",
|
|
38
38
|
opacity: "0",
|
|
@@ -83,4 +83,4 @@ export {
|
|
|
83
83
|
getPosition,
|
|
84
84
|
NavMenuList
|
|
85
85
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-PMCYXRAH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/NavMenuList.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\ninterface GetPositionResult {\n left: string\n right: string\n top: string\n bottom: string\n}\n\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'page.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n id: string\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n *\n * @example\n * ```tsx\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,eAAoC;AAC7C,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB;AAhFC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,gBAAgB,OAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AAoBM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,iBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,WAAW,GAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Portal
|
|
3
|
+
} from "./chunk-4CAT3FHV.js";
|
|
4
|
+
import {
|
|
5
|
+
Modal
|
|
6
|
+
} from "./chunk-TPFNVGYA.js";
|
|
7
|
+
import {
|
|
8
|
+
ModalDescription
|
|
9
|
+
} from "./chunk-UPODPCRD.js";
|
|
10
|
+
import {
|
|
11
|
+
ModalHeader
|
|
12
|
+
} from "./chunk-2F5TB2EV.js";
|
|
13
|
+
import {
|
|
14
|
+
ModalHeading
|
|
15
|
+
} from "./chunk-OGSAAB6K.js";
|
|
16
|
+
import {
|
|
17
|
+
ModalIcon
|
|
18
|
+
} from "./chunk-G3JEWPLM.js";
|
|
19
|
+
import {
|
|
20
|
+
Button
|
|
21
|
+
} from "./chunk-2ATICEW3.js";
|
|
22
|
+
import {
|
|
23
|
+
Show
|
|
24
|
+
} from "./chunk-4O4QFF4S.js";
|
|
25
|
+
import {
|
|
26
|
+
trapFocus
|
|
27
|
+
} from "./chunk-JIZQFTW6.js";
|
|
28
|
+
import {
|
|
29
|
+
$cerberusIcons
|
|
30
|
+
} from "./chunk-6TXQZ3PB.js";
|
|
31
|
+
import {
|
|
32
|
+
useModal
|
|
33
|
+
} from "./chunk-C5HLLGME.js";
|
|
34
|
+
|
|
35
|
+
// src/context/confirm-modal.tsx
|
|
36
|
+
import {
|
|
37
|
+
createContext,
|
|
38
|
+
useCallback,
|
|
39
|
+
useContext,
|
|
40
|
+
useMemo,
|
|
41
|
+
useRef,
|
|
42
|
+
useState
|
|
43
|
+
} from "react";
|
|
44
|
+
import { css } from "@cerberus-design/styled-system/css";
|
|
45
|
+
import { hstack } from "@cerberus-design/styled-system/patterns";
|
|
46
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
47
|
+
var ConfirmModalContext = createContext(null);
|
|
48
|
+
function ConfirmModal(props) {
|
|
49
|
+
const { modalRef, show, close } = useModal();
|
|
50
|
+
const resolveRef = useRef(null);
|
|
51
|
+
const [content, setContent] = useState(null);
|
|
52
|
+
const focusTrap = trapFocus(modalRef);
|
|
53
|
+
const ConfirmIcon = $cerberusIcons.confirmModal;
|
|
54
|
+
const palette = useMemo(
|
|
55
|
+
() => content?.kind === "destructive" ? "danger" : "action",
|
|
56
|
+
[content]
|
|
57
|
+
);
|
|
58
|
+
const handleChoice = useCallback(
|
|
59
|
+
(e) => {
|
|
60
|
+
const target = e.currentTarget;
|
|
61
|
+
if (target.value === "true") {
|
|
62
|
+
resolveRef.current?.(true);
|
|
63
|
+
}
|
|
64
|
+
resolveRef.current?.(false);
|
|
65
|
+
close();
|
|
66
|
+
},
|
|
67
|
+
[close]
|
|
68
|
+
);
|
|
69
|
+
const handleShow = useCallback(
|
|
70
|
+
(options) => {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
73
|
+
show();
|
|
74
|
+
resolveRef.current = resolve;
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
[show]
|
|
78
|
+
);
|
|
79
|
+
const value = useMemo(
|
|
80
|
+
() => ({
|
|
81
|
+
show: handleShow
|
|
82
|
+
}),
|
|
83
|
+
[handleShow]
|
|
84
|
+
);
|
|
85
|
+
return /* @__PURE__ */ jsxs(ConfirmModalContext.Provider, { value, children: [
|
|
86
|
+
props.children,
|
|
87
|
+
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
|
|
88
|
+
/* @__PURE__ */ jsxs(ModalHeader, { children: [
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
Show,
|
|
91
|
+
{
|
|
92
|
+
when: palette === "danger",
|
|
93
|
+
fallback: /* @__PURE__ */ jsx(ModalIcon, { palette: "action", children: /* @__PURE__ */ jsx(ConfirmIcon, { size: 24 }) }),
|
|
94
|
+
children: /* @__PURE__ */ jsx(ModalIcon, { palette: "danger", children: /* @__PURE__ */ jsx(ConfirmIcon, { size: 24 }) })
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsx(ModalHeading, { children: content?.heading }),
|
|
98
|
+
/* @__PURE__ */ jsx(ModalDescription, { children: content?.description })
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ jsxs(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
className: hstack({
|
|
104
|
+
gap: "4"
|
|
105
|
+
}),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
Button,
|
|
109
|
+
{
|
|
110
|
+
autoFocus: true,
|
|
111
|
+
className: css({
|
|
112
|
+
w: "1/2"
|
|
113
|
+
}),
|
|
114
|
+
name: "confirm",
|
|
115
|
+
onClick: handleChoice,
|
|
116
|
+
palette,
|
|
117
|
+
value: "true",
|
|
118
|
+
children: content?.actionText
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ jsx(
|
|
122
|
+
Button,
|
|
123
|
+
{
|
|
124
|
+
className: css({
|
|
125
|
+
w: "1/2"
|
|
126
|
+
}),
|
|
127
|
+
name: "cancel",
|
|
128
|
+
onClick: handleChoice,
|
|
129
|
+
usage: "outlined",
|
|
130
|
+
value: "false",
|
|
131
|
+
children: content?.cancelText
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
] }) })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
function useConfirmModal() {
|
|
141
|
+
const context = useContext(ConfirmModalContext);
|
|
142
|
+
if (context === null) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
"useConfirmModal must be used within a ConfirmModal Provider"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
return context;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
ConfirmModal,
|
|
152
|
+
useConfirmModal
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=chunk-TAVCJ54A.js.map
|