@cerberus-design/react 0.13.1-next-8c8a5ee → 0.13.1-next-b2ca1e0
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 +28 -0
- package/build/legacy/hooks/useRootColors.cjs +64 -0
- package/build/legacy/hooks/useRootColors.cjs.map +1 -0
- package/build/legacy/index.cjs +37 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +28 -0
- package/build/modern/{chunk-5KHGTLFM.js → chunk-B3LRHIEG.js} +6 -6
- package/build/modern/{chunk-4D6VIGNQ.js → chunk-FHS7VVGN.js} +6 -6
- package/build/modern/chunk-RMVJK26W.js +39 -0
- package/build/modern/chunk-RMVJK26W.js.map +1 -0
- package/build/modern/{chunk-MMHCX2RG.js → chunk-S6JWPDB4.js} +6 -6
- package/build/modern/{chunk-MXMVC3ZQ.js → chunk-SRPSJGNI.js} +9 -9
- package/build/modern/context/confirm-modal.js +3 -3
- package/build/modern/context/cta-modal.js +4 -4
- package/build/modern/context/notification-center.js +3 -3
- package/build/modern/context/prompt-modal.js +3 -3
- package/build/modern/hooks/useRootColors.js +8 -0
- package/build/modern/hooks/useRootColors.js.map +1 -0
- package/build/modern/index.js +37 -33
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/useRootColors.ts +73 -0
- package/src/index.ts +1 -0
- /package/build/modern/{chunk-5KHGTLFM.js.map → chunk-B3LRHIEG.js.map} +0 -0
- /package/build/modern/{chunk-4D6VIGNQ.js.map → chunk-FHS7VVGN.js.map} +0 -0
- /package/build/modern/{chunk-MMHCX2RG.js.map → chunk-S6JWPDB4.js.map} +0 -0
- /package/build/modern/{chunk-MXMVC3ZQ.js.map → chunk-SRPSJGNI.js.map} +0 -0
|
@@ -2097,6 +2097,23 @@ export { RadioRecipe as RadioRecipe_alias_1 }
|
|
|
2097
2097
|
|
|
2098
2098
|
export { rectIntersection }
|
|
2099
2099
|
|
|
2100
|
+
/**
|
|
2101
|
+
* This module provides a hook to get Cerberus colors from the document root.
|
|
2102
|
+
* @module useRootColors
|
|
2103
|
+
*/
|
|
2104
|
+
declare interface RootColorsResult {
|
|
2105
|
+
/**
|
|
2106
|
+
* A record of Cerberus colors where the key is the token name provided and the value is the color hex.
|
|
2107
|
+
*/
|
|
2108
|
+
colors: Record<string, string>;
|
|
2109
|
+
/**
|
|
2110
|
+
* A function to refetch the Cerberus colors from the document root. Useful when you need the latest colors after a theme/mode change.
|
|
2111
|
+
*/
|
|
2112
|
+
refetch: () => Promise<void>;
|
|
2113
|
+
}
|
|
2114
|
+
export { RootColorsResult }
|
|
2115
|
+
export { RootColorsResult as RootColorsResult_alias_1 }
|
|
2116
|
+
|
|
2100
2117
|
export { ScreenReaderInstructions }
|
|
2101
2118
|
|
|
2102
2119
|
/**
|
|
@@ -3010,6 +3027,17 @@ declare function usePromptModal(): PromptModalValue;
|
|
|
3010
3027
|
export { usePromptModal }
|
|
3011
3028
|
export { usePromptModal as usePromptModal_alias_1 }
|
|
3012
3029
|
|
|
3030
|
+
/**
|
|
3031
|
+
* This hook returns a record of Cerberus colors from the document root.
|
|
3032
|
+
* This is useful when you are working with a component that uses the `<canvas>`
|
|
3033
|
+
* element.
|
|
3034
|
+
* @param colors - An array of Cerberus tokens to get from the document root (i.e. `['dataViz.diverging.50', 'dataViz.diverging.200']`).
|
|
3035
|
+
* @returns A record of Cerberus colors where the key is the token name provided and the value is the color hex.
|
|
3036
|
+
*/
|
|
3037
|
+
declare function useRootColors(colors?: string[]): RootColorsResult;
|
|
3038
|
+
export { useRootColors }
|
|
3039
|
+
export { useRootColors as useRootColors_alias_1 }
|
|
3040
|
+
|
|
3013
3041
|
export { useSensor }
|
|
3014
3042
|
|
|
3015
3043
|
export { useSensors }
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NotificationHeading
|
|
3
|
+
} from "./chunk-SXIXDXG3.js";
|
|
1
4
|
import {
|
|
2
5
|
Portal
|
|
3
6
|
} from "./chunk-K2PSHGS7.js";
|
|
@@ -8,14 +11,11 @@ import {
|
|
|
8
11
|
NotificationDescription
|
|
9
12
|
} from "./chunk-XEW6TJJ4.js";
|
|
10
13
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
Button
|
|
15
|
+
} from "./chunk-EXGKZGML.js";
|
|
13
16
|
import {
|
|
14
17
|
Show
|
|
15
18
|
} from "./chunk-BUVVRQLZ.js";
|
|
16
|
-
import {
|
|
17
|
-
Button
|
|
18
|
-
} from "./chunk-EXGKZGML.js";
|
|
19
19
|
|
|
20
20
|
// src/context/notification-center.tsx
|
|
21
21
|
import {
|
|
@@ -159,4 +159,4 @@ export {
|
|
|
159
159
|
NotificationCenter,
|
|
160
160
|
useNotificationCenter
|
|
161
161
|
};
|
|
162
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-B3LRHIEG.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Portal
|
|
3
3
|
} from "./chunk-K2PSHGS7.js";
|
|
4
|
+
import {
|
|
5
|
+
ModalDescription
|
|
6
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
4
7
|
import {
|
|
5
8
|
ModalHeader
|
|
6
9
|
} from "./chunk-XY6WL55R.js";
|
|
@@ -11,8 +14,8 @@ import {
|
|
|
11
14
|
Modal
|
|
12
15
|
} from "./chunk-BE4EOU2P.js";
|
|
13
16
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
Button
|
|
18
|
+
} from "./chunk-EXGKZGML.js";
|
|
16
19
|
import {
|
|
17
20
|
useModal
|
|
18
21
|
} from "./chunk-KGQG5JGW.js";
|
|
@@ -22,9 +25,6 @@ import {
|
|
|
22
25
|
import {
|
|
23
26
|
Show
|
|
24
27
|
} from "./chunk-BUVVRQLZ.js";
|
|
25
|
-
import {
|
|
26
|
-
Button
|
|
27
|
-
} from "./chunk-EXGKZGML.js";
|
|
28
28
|
import {
|
|
29
29
|
trapFocus
|
|
30
30
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -170,4 +170,4 @@ export {
|
|
|
170
170
|
ConfirmModal,
|
|
171
171
|
useConfirmModal
|
|
172
172
|
};
|
|
173
|
-
//# sourceMappingURL=chunk-
|
|
173
|
+
//# sourceMappingURL=chunk-FHS7VVGN.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/hooks/useRootColors.ts
|
|
2
|
+
import { useCallback, useEffect, useMemo, useReducer } from "react";
|
|
3
|
+
function useRootColors(colors = []) {
|
|
4
|
+
const [state, dispatch] = useReducer(rootColorsReducer, {});
|
|
5
|
+
const handleRefetch = useCallback(() => {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
dispatch(formatColors(colors));
|
|
8
|
+
resolve();
|
|
9
|
+
});
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (Object.keys(state).length === colors.length) return;
|
|
13
|
+
dispatch(formatColors(colors));
|
|
14
|
+
console.log("updating colors in root hook");
|
|
15
|
+
}, [colors]);
|
|
16
|
+
return useMemo(
|
|
17
|
+
() => ({ colors: state, refetch: handleRefetch }),
|
|
18
|
+
[state, handleRefetch]
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function formatColors(colors) {
|
|
22
|
+
const rootStyles = getComputedStyle(document.body);
|
|
23
|
+
return colors.reduce(
|
|
24
|
+
(acc, color) => {
|
|
25
|
+
const formattedColor = color.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase().replaceAll(".", "-");
|
|
26
|
+
acc[color] = rootStyles.getPropertyValue(`--cerberus-colors-${formattedColor}`).trim();
|
|
27
|
+
return acc;
|
|
28
|
+
},
|
|
29
|
+
{}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function rootColorsReducer(state, action) {
|
|
33
|
+
return { ...state, ...action };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
useRootColors
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=chunk-RMVJK26W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useRootColors.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useEffect, useMemo, useReducer } from 'react'\n\n/**\n * This module provides a hook to get Cerberus colors from the document root.\n * @module useRootColors\n */\n\nexport interface RootColorsResult {\n /**\n * A record of Cerberus colors where the key is the token name provided and the value is the color hex.\n */\n colors: Record<string, string>\n /**\n * A function to refetch the Cerberus colors from the document root. Useful when you need the latest colors after a theme/mode change.\n */\n refetch: () => Promise<void>\n}\n\n/**\n * This hook returns a record of Cerberus colors from the document root.\n * This is useful when you are working with a component that uses the `<canvas>`\n * element.\n * @param colors - An array of Cerberus tokens to get from the document root (i.e. `['dataViz.diverging.50', 'dataViz.diverging.200']`).\n * @returns A record of Cerberus colors where the key is the token name provided and the value is the color hex.\n */\nexport function useRootColors(colors: string[] = []): RootColorsResult {\n const [state, dispatch] = useReducer(rootColorsReducer, {})\n\n const handleRefetch = useCallback(() => {\n return new Promise<void>((resolve) => {\n dispatch(formatColors(colors))\n resolve()\n })\n }, [])\n\n useEffect(() => {\n if (Object.keys(state).length === colors.length) return\n dispatch(formatColors(colors))\n console.log('updating colors in root hook')\n }, [colors])\n\n // reducer is already memoized\n return useMemo(\n () => ({ colors: state, refetch: handleRefetch }),\n [state, handleRefetch],\n )\n}\n\nfunction formatColors(colors: string[]): Record<string, string> {\n const rootStyles = getComputedStyle(document.body)\n return colors.reduce(\n (acc, color) => {\n const formattedColor = color\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase()\n .replaceAll('.', '-')\n acc[color] = rootStyles\n .getPropertyValue(`--cerberus-colors-${formattedColor}`)\n .trim()\n return acc\n },\n {} as Record<string, string>,\n )\n}\n\nfunction rootColorsReducer(\n state: Record<string, string>,\n action: Record<string, string>,\n): Record<string, string> {\n return { ...state, ...action }\n}\n"],"mappings":";AAEA,SAAS,aAAa,WAAW,SAAS,kBAAkB;AAyBrD,SAAS,cAAc,SAAmB,CAAC,GAAqB;AACrE,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,mBAAmB,CAAC,CAAC;AAE1D,QAAM,gBAAgB,YAAY,MAAM;AACtC,WAAO,IAAI,QAAc,CAAC,YAAY;AACpC,eAAS,aAAa,MAAM,CAAC;AAC7B,cAAQ;AAAA,IACV,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,QAAI,OAAO,KAAK,KAAK,EAAE,WAAW,OAAO,OAAQ;AACjD,aAAS,aAAa,MAAM,CAAC;AAC7B,YAAQ,IAAI,8BAA8B;AAAA,EAC5C,GAAG,CAAC,MAAM,CAAC;AAGX,SAAO;AAAA,IACL,OAAO,EAAE,QAAQ,OAAO,SAAS,cAAc;AAAA,IAC/C,CAAC,OAAO,aAAa;AAAA,EACvB;AACF;AAEA,SAAS,aAAa,QAA0C;AAC9D,QAAM,aAAa,iBAAiB,SAAS,IAAI;AACjD,SAAO,OAAO;AAAA,IACZ,CAAC,KAAK,UAAU;AACd,YAAM,iBAAiB,MACpB,QAAQ,mBAAmB,OAAO,EAClC,YAAY,EACZ,WAAW,KAAK,GAAG;AACtB,UAAI,KAAK,IAAI,WACV,iBAAiB,qBAAqB,cAAc,EAAE,EACtD,KAAK;AACR,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAEA,SAAS,kBACP,OACA,QACwB;AACxB,SAAO,EAAE,GAAG,OAAO,GAAG,OAAO;AAC/B;","names":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Portal
|
|
3
3
|
} from "./chunk-K2PSHGS7.js";
|
|
4
|
+
import {
|
|
5
|
+
ModalDescription
|
|
6
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
4
7
|
import {
|
|
5
8
|
ModalHeader
|
|
6
9
|
} from "./chunk-XY6WL55R.js";
|
|
@@ -17,8 +20,8 @@ import {
|
|
|
17
20
|
Modal
|
|
18
21
|
} from "./chunk-BE4EOU2P.js";
|
|
19
22
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
Button
|
|
24
|
+
} from "./chunk-EXGKZGML.js";
|
|
22
25
|
import {
|
|
23
26
|
Field
|
|
24
27
|
} from "./chunk-UZDVOIW5.js";
|
|
@@ -31,9 +34,6 @@ import {
|
|
|
31
34
|
import {
|
|
32
35
|
Show
|
|
33
36
|
} from "./chunk-BUVVRQLZ.js";
|
|
34
|
-
import {
|
|
35
|
-
Button
|
|
36
|
-
} from "./chunk-EXGKZGML.js";
|
|
37
37
|
import {
|
|
38
38
|
trapFocus
|
|
39
39
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -240,4 +240,4 @@ export {
|
|
|
240
240
|
PromptModal,
|
|
241
241
|
usePromptModal
|
|
242
242
|
};
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-S6JWPDB4.js.map
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Portal
|
|
3
3
|
} from "./chunk-K2PSHGS7.js";
|
|
4
|
+
import {
|
|
5
|
+
ModalDescription
|
|
6
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
4
7
|
import {
|
|
5
8
|
ModalHeader
|
|
6
9
|
} from "./chunk-XY6WL55R.js";
|
|
7
10
|
import {
|
|
8
11
|
ModalHeading
|
|
9
12
|
} from "./chunk-2UXE5PDG.js";
|
|
13
|
+
import {
|
|
14
|
+
IconButton
|
|
15
|
+
} from "./chunk-APD6IX5R.js";
|
|
10
16
|
import {
|
|
11
17
|
Modal
|
|
12
18
|
} from "./chunk-BE4EOU2P.js";
|
|
13
19
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
IconButton
|
|
18
|
-
} from "./chunk-APD6IX5R.js";
|
|
20
|
+
Button
|
|
21
|
+
} from "./chunk-EXGKZGML.js";
|
|
19
22
|
import {
|
|
20
23
|
useModal
|
|
21
24
|
} from "./chunk-KGQG5JGW.js";
|
|
@@ -25,9 +28,6 @@ import {
|
|
|
25
28
|
import {
|
|
26
29
|
Show
|
|
27
30
|
} from "./chunk-BUVVRQLZ.js";
|
|
28
|
-
import {
|
|
29
|
-
Button
|
|
30
|
-
} from "./chunk-EXGKZGML.js";
|
|
31
31
|
import {
|
|
32
32
|
trapFocus
|
|
33
33
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -152,4 +152,4 @@ export {
|
|
|
152
152
|
CTAModal,
|
|
153
153
|
useCTAModal
|
|
154
154
|
};
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-SRPSJGNI.js.map
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConfirmModal,
|
|
4
4
|
useConfirmModal
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-FHS7VVGN.js";
|
|
6
6
|
import "../chunk-K2PSHGS7.js";
|
|
7
|
+
import "../chunk-Q7BRMIBR.js";
|
|
7
8
|
import "../chunk-XY6WL55R.js";
|
|
8
9
|
import "../chunk-2UXE5PDG.js";
|
|
9
10
|
import "../chunk-BE4EOU2P.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-EXGKZGML.js";
|
|
11
12
|
import "../chunk-KGQG5JGW.js";
|
|
12
13
|
import "../chunk-SPZYPRZ6.js";
|
|
13
14
|
import "../chunk-BUVVRQLZ.js";
|
|
14
|
-
import "../chunk-EXGKZGML.js";
|
|
15
15
|
import "../chunk-JIZQFTW6.js";
|
|
16
16
|
import "../chunk-VERRHMW4.js";
|
|
17
17
|
import "../chunk-F27AAKQ3.js";
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CTAModal,
|
|
4
4
|
useCTAModal
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-SRPSJGNI.js";
|
|
6
6
|
import "../chunk-K2PSHGS7.js";
|
|
7
|
+
import "../chunk-Q7BRMIBR.js";
|
|
7
8
|
import "../chunk-XY6WL55R.js";
|
|
8
9
|
import "../chunk-2UXE5PDG.js";
|
|
9
|
-
import "../chunk-BE4EOU2P.js";
|
|
10
|
-
import "../chunk-Q7BRMIBR.js";
|
|
11
10
|
import "../chunk-APD6IX5R.js";
|
|
11
|
+
import "../chunk-BE4EOU2P.js";
|
|
12
|
+
import "../chunk-EXGKZGML.js";
|
|
12
13
|
import "../chunk-KGQG5JGW.js";
|
|
13
14
|
import "../chunk-SPZYPRZ6.js";
|
|
14
15
|
import "../chunk-BUVVRQLZ.js";
|
|
15
|
-
import "../chunk-EXGKZGML.js";
|
|
16
16
|
import "../chunk-JIZQFTW6.js";
|
|
17
17
|
import "../chunk-VERRHMW4.js";
|
|
18
18
|
import "../chunk-F27AAKQ3.js";
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
NotificationCenter,
|
|
4
4
|
useNotificationCenter
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-B3LRHIEG.js";
|
|
6
|
+
import "../chunk-SXIXDXG3.js";
|
|
6
7
|
import "../chunk-K2PSHGS7.js";
|
|
7
8
|
import "../chunk-7SGPJM66.js";
|
|
8
9
|
import "../chunk-XEW6TJJ4.js";
|
|
9
|
-
import "../chunk-SXIXDXG3.js";
|
|
10
|
-
import "../chunk-BUVVRQLZ.js";
|
|
11
10
|
import "../chunk-EXGKZGML.js";
|
|
11
|
+
import "../chunk-BUVVRQLZ.js";
|
|
12
12
|
import "../chunk-JIZQFTW6.js";
|
|
13
13
|
import "../chunk-VERRHMW4.js";
|
|
14
14
|
import "../chunk-F27AAKQ3.js";
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
PromptModal,
|
|
4
4
|
usePromptModal
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-S6JWPDB4.js";
|
|
6
6
|
import "../chunk-K2PSHGS7.js";
|
|
7
|
+
import "../chunk-Q7BRMIBR.js";
|
|
7
8
|
import "../chunk-XY6WL55R.js";
|
|
8
9
|
import "../chunk-2UXE5PDG.js";
|
|
9
10
|
import "../chunk-NKM6PISB.js";
|
|
10
11
|
import "../chunk-NMF2HYWO.js";
|
|
11
12
|
import "../chunk-BE4EOU2P.js";
|
|
12
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-EXGKZGML.js";
|
|
13
14
|
import "../chunk-UZDVOIW5.js";
|
|
14
15
|
import "../chunk-KGQG5JGW.js";
|
|
15
16
|
import "../chunk-SPZYPRZ6.js";
|
|
16
17
|
import "../chunk-BUVVRQLZ.js";
|
|
17
|
-
import "../chunk-EXGKZGML.js";
|
|
18
18
|
import "../chunk-JIZQFTW6.js";
|
|
19
19
|
import "../chunk-VERRHMW4.js";
|
|
20
20
|
import "../chunk-F27AAKQ3.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/modern/index.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NotificationCenter,
|
|
3
|
+
useNotificationCenter
|
|
4
|
+
} from "./chunk-B3LRHIEG.js";
|
|
1
5
|
import {
|
|
2
6
|
PromptModal,
|
|
3
7
|
usePromptModal
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S6JWPDB4.js";
|
|
5
9
|
import {
|
|
6
10
|
ThemeProvider,
|
|
7
11
|
useThemeContext
|
|
8
12
|
} from "./chunk-EB37HRCN.js";
|
|
13
|
+
import {
|
|
14
|
+
Thead
|
|
15
|
+
} from "./chunk-Y6QQCRQV.js";
|
|
9
16
|
import {
|
|
10
17
|
Toggle
|
|
11
18
|
} from "./chunk-NMNONSHU.js";
|
|
@@ -15,15 +22,14 @@ import {
|
|
|
15
22
|
import {
|
|
16
23
|
ConfirmModal,
|
|
17
24
|
useConfirmModal
|
|
18
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FHS7VVGN.js";
|
|
19
26
|
import {
|
|
20
27
|
CTAModal,
|
|
21
28
|
useCTAModal
|
|
22
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-SRPSJGNI.js";
|
|
23
30
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from "./chunk-5KHGTLFM.js";
|
|
31
|
+
TabList
|
|
32
|
+
} from "./chunk-UKPF7JOB.js";
|
|
27
33
|
import {
|
|
28
34
|
TabPanel
|
|
29
35
|
} from "./chunk-AYIRV5CL.js";
|
|
@@ -47,8 +53,8 @@ import {
|
|
|
47
53
|
Th
|
|
48
54
|
} from "./chunk-SGKHA4EB.js";
|
|
49
55
|
import {
|
|
50
|
-
|
|
51
|
-
} from "./chunk-
|
|
56
|
+
NotificationHeading
|
|
57
|
+
} from "./chunk-SXIXDXG3.js";
|
|
52
58
|
import {
|
|
53
59
|
Portal
|
|
54
60
|
} from "./chunk-K2PSHGS7.js";
|
|
@@ -66,8 +72,8 @@ import {
|
|
|
66
72
|
Tab
|
|
67
73
|
} from "./chunk-SLF6SIPB.js";
|
|
68
74
|
import {
|
|
69
|
-
|
|
70
|
-
} from "./chunk-
|
|
75
|
+
ModalDescription
|
|
76
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
71
77
|
import {
|
|
72
78
|
ModalHeader
|
|
73
79
|
} from "./chunk-XY6WL55R.js";
|
|
@@ -95,11 +101,18 @@ import {
|
|
|
95
101
|
NotificationDescription
|
|
96
102
|
} from "./chunk-XEW6TJJ4.js";
|
|
97
103
|
import {
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
FileStatus,
|
|
105
|
+
processStatus
|
|
106
|
+
} from "./chunk-7MM5KYEX.js";
|
|
107
|
+
import {
|
|
108
|
+
ProgressBar
|
|
109
|
+
} from "./chunk-KCANMM64.js";
|
|
100
110
|
import {
|
|
101
111
|
FileUploader
|
|
102
112
|
} from "./chunk-W4DXACNV.js";
|
|
113
|
+
import {
|
|
114
|
+
IconButton
|
|
115
|
+
} from "./chunk-APD6IX5R.js";
|
|
103
116
|
import {
|
|
104
117
|
Input
|
|
105
118
|
} from "./chunk-NKM6PISB.js";
|
|
@@ -122,8 +135,8 @@ import {
|
|
|
122
135
|
Modal
|
|
123
136
|
} from "./chunk-BE4EOU2P.js";
|
|
124
137
|
import {
|
|
125
|
-
|
|
126
|
-
} from "./chunk-
|
|
138
|
+
Button
|
|
139
|
+
} from "./chunk-EXGKZGML.js";
|
|
127
140
|
import {
|
|
128
141
|
Checkbox
|
|
129
142
|
} from "./chunk-NB6DV4VA.js";
|
|
@@ -140,32 +153,25 @@ import {
|
|
|
140
153
|
FeatureFlags,
|
|
141
154
|
useFeatureFlags
|
|
142
155
|
} from "./chunk-CJFW36DZ.js";
|
|
143
|
-
import {
|
|
144
|
-
Fieldset
|
|
145
|
-
} from "./chunk-3ZDFQO25.js";
|
|
146
|
-
import {
|
|
147
|
-
FieldsetLabel
|
|
148
|
-
} from "./chunk-PZAZKQMO.js";
|
|
149
|
-
import {
|
|
150
|
-
FileStatus,
|
|
151
|
-
processStatus
|
|
152
|
-
} from "./chunk-7MM5KYEX.js";
|
|
153
|
-
import {
|
|
154
|
-
ProgressBar
|
|
155
|
-
} from "./chunk-KCANMM64.js";
|
|
156
|
-
import {
|
|
157
|
-
IconButton
|
|
158
|
-
} from "./chunk-APD6IX5R.js";
|
|
159
156
|
import {
|
|
160
157
|
FieldMessage
|
|
161
158
|
} from "./chunk-JWIJHSI6.js";
|
|
159
|
+
import {
|
|
160
|
+
Fieldset
|
|
161
|
+
} from "./chunk-3ZDFQO25.js";
|
|
162
162
|
import {
|
|
163
163
|
Field,
|
|
164
164
|
useFieldContext
|
|
165
165
|
} from "./chunk-UZDVOIW5.js";
|
|
166
|
+
import {
|
|
167
|
+
FieldsetLabel
|
|
168
|
+
} from "./chunk-PZAZKQMO.js";
|
|
166
169
|
import {
|
|
167
170
|
useModal
|
|
168
171
|
} from "./chunk-KGQG5JGW.js";
|
|
172
|
+
import {
|
|
173
|
+
useRootColors
|
|
174
|
+
} from "./chunk-RMVJK26W.js";
|
|
169
175
|
import {
|
|
170
176
|
MODE_KEY,
|
|
171
177
|
THEME_KEY,
|
|
@@ -188,9 +194,6 @@ import {
|
|
|
188
194
|
import {
|
|
189
195
|
Show
|
|
190
196
|
} from "./chunk-BUVVRQLZ.js";
|
|
191
|
-
import {
|
|
192
|
-
Button
|
|
193
|
-
} from "./chunk-EXGKZGML.js";
|
|
194
197
|
import "./chunk-55J6XMHW.js";
|
|
195
198
|
import {
|
|
196
199
|
createNavTriggerProps
|
|
@@ -309,6 +312,7 @@ export {
|
|
|
309
312
|
useNavMenuContext,
|
|
310
313
|
useNotificationCenter,
|
|
311
314
|
usePromptModal,
|
|
315
|
+
useRootColors,
|
|
312
316
|
useTabsContext,
|
|
313
317
|
useTabsKeyboardNavigation,
|
|
314
318
|
useTheme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Spinner'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\nexport * from './hooks/useRootColors'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.13.1-next-
|
|
3
|
+
"version": "0.13.1-next-b2ca1e0",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"react-dom": "^18",
|
|
28
28
|
"tsup": "^8.1.0",
|
|
29
29
|
"@cerberus-design/configs": "0.0.0",
|
|
30
|
-
"@cerberus-design/styled-system": "0.13.1-next-
|
|
30
|
+
"@cerberus-design/styled-system": "0.13.1-next-b2ca1e0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useReducer } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This module provides a hook to get Cerberus colors from the document root.
|
|
7
|
+
* @module useRootColors
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface RootColorsResult {
|
|
11
|
+
/**
|
|
12
|
+
* A record of Cerberus colors where the key is the token name provided and the value is the color hex.
|
|
13
|
+
*/
|
|
14
|
+
colors: Record<string, string>
|
|
15
|
+
/**
|
|
16
|
+
* A function to refetch the Cerberus colors from the document root. Useful when you need the latest colors after a theme/mode change.
|
|
17
|
+
*/
|
|
18
|
+
refetch: () => Promise<void>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This hook returns a record of Cerberus colors from the document root.
|
|
23
|
+
* This is useful when you are working with a component that uses the `<canvas>`
|
|
24
|
+
* element.
|
|
25
|
+
* @param colors - An array of Cerberus tokens to get from the document root (i.e. `['dataViz.diverging.50', 'dataViz.diverging.200']`).
|
|
26
|
+
* @returns A record of Cerberus colors where the key is the token name provided and the value is the color hex.
|
|
27
|
+
*/
|
|
28
|
+
export function useRootColors(colors: string[] = []): RootColorsResult {
|
|
29
|
+
const [state, dispatch] = useReducer(rootColorsReducer, {})
|
|
30
|
+
|
|
31
|
+
const handleRefetch = useCallback(() => {
|
|
32
|
+
return new Promise<void>((resolve) => {
|
|
33
|
+
dispatch(formatColors(colors))
|
|
34
|
+
resolve()
|
|
35
|
+
})
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (Object.keys(state).length === colors.length) return
|
|
40
|
+
dispatch(formatColors(colors))
|
|
41
|
+
console.log('updating colors in root hook')
|
|
42
|
+
}, [colors])
|
|
43
|
+
|
|
44
|
+
// reducer is already memoized
|
|
45
|
+
return useMemo(
|
|
46
|
+
() => ({ colors: state, refetch: handleRefetch }),
|
|
47
|
+
[state, handleRefetch],
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function formatColors(colors: string[]): Record<string, string> {
|
|
52
|
+
const rootStyles = getComputedStyle(document.body)
|
|
53
|
+
return colors.reduce(
|
|
54
|
+
(acc, color) => {
|
|
55
|
+
const formattedColor = color
|
|
56
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
57
|
+
.toLowerCase()
|
|
58
|
+
.replaceAll('.', '-')
|
|
59
|
+
acc[color] = rootStyles
|
|
60
|
+
.getPropertyValue(`--cerberus-colors-${formattedColor}`)
|
|
61
|
+
.trim()
|
|
62
|
+
return acc
|
|
63
|
+
},
|
|
64
|
+
{} as Record<string, string>,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function rootColorsReducer(
|
|
69
|
+
state: Record<string, string>,
|
|
70
|
+
action: Record<string, string>,
|
|
71
|
+
): Record<string, string> {
|
|
72
|
+
return { ...state, ...action }
|
|
73
|
+
}
|
package/src/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|