@cerberus-design/react 0.1.0 → 0.1.1-next-3a4c6c1
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/aria-helpers/nav-menu.aria.js +3 -7
- package/build/legacy/aria-helpers/nav-menu.aria.js.map +1 -1
- package/build/legacy/chunk-55J6XMHW.js +1 -0
- package/build/legacy/chunk-6YEAMVRY.js +82 -0
- package/build/legacy/chunk-6YEAMVRY.js.map +1 -0
- package/build/legacy/chunk-BPIYUAYS.js +26 -0
- package/build/legacy/chunk-BPIYUAYS.js.map +1 -0
- package/build/legacy/chunk-JA4IX7GN.js +48 -0
- package/build/legacy/chunk-JA4IX7GN.js.map +1 -0
- package/build/legacy/chunk-JF76VIL3.js +12 -0
- package/build/legacy/chunk-JF76VIL3.js.map +1 -0
- package/build/legacy/chunk-KETL4ZJK.js +33 -0
- package/build/legacy/chunk-KETL4ZJK.js.map +1 -0
- package/build/legacy/chunk-KJUCHZHV.js +51 -0
- package/build/legacy/chunk-KJUCHZHV.js.map +1 -0
- package/build/legacy/chunk-R4H3352X.js +16 -0
- package/build/legacy/chunk-R4H3352X.js.map +1 -0
- package/build/legacy/chunk-SXXWC6UD.js +83 -0
- package/build/legacy/chunk-SXXWC6UD.js.map +1 -0
- package/build/legacy/chunk-WSQTX34C.js +86 -0
- package/build/legacy/chunk-WSQTX34C.js.map +1 -0
- package/build/legacy/chunk-XFWARXLU.js +26 -0
- package/build/legacy/chunk-XFWARXLU.js.map +1 -0
- package/build/legacy/components/Button.js +3 -21
- package/build/legacy/components/Button.js.map +1 -1
- package/build/legacy/components/IconButton.js +3 -21
- package/build/legacy/components/IconButton.js.map +1 -1
- package/build/legacy/components/NavMenuLink.js +4 -40
- package/build/legacy/components/NavMenuLink.js.map +1 -1
- package/build/legacy/components/NavMenuList.js +6 -76
- package/build/legacy/components/NavMenuList.js.map +1 -1
- package/build/legacy/components/NavMenuTrigger.js +5 -72
- package/build/legacy/components/NavMenuTrigger.js.map +1 -1
- package/build/legacy/components/Show.js +3 -12
- package/build/legacy/components/Show.js.map +1 -1
- package/build/legacy/context/field.js +3 -27
- package/build/legacy/context/field.js.map +1 -1
- package/build/legacy/context/navMenu.js +3 -45
- package/build/legacy/context/navMenu.js.map +1 -1
- package/build/legacy/context/theme.js +6 -21
- package/build/legacy/context/theme.js.map +1 -1
- package/build/legacy/hooks/useTheme.js +2 -56
- package/build/legacy/hooks/useTheme.js.map +1 -1
- package/build/legacy/index.js +57 -13
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/types.js +1 -0
- package/build/modern/aria-helpers/nav-menu.aria.js +3 -7
- package/build/modern/aria-helpers/nav-menu.aria.js.map +1 -1
- package/build/modern/chunk-55J6XMHW.js +1 -0
- package/build/modern/chunk-6YEAMVRY.js +82 -0
- package/build/modern/chunk-6YEAMVRY.js.map +1 -0
- package/build/modern/chunk-BPIYUAYS.js +26 -0
- package/build/modern/chunk-BPIYUAYS.js.map +1 -0
- package/build/modern/chunk-JA4IX7GN.js +48 -0
- package/build/modern/chunk-JA4IX7GN.js.map +1 -0
- package/build/modern/chunk-JF76VIL3.js +12 -0
- package/build/modern/chunk-JF76VIL3.js.map +1 -0
- package/build/modern/chunk-KETL4ZJK.js +33 -0
- package/build/modern/chunk-KETL4ZJK.js.map +1 -0
- package/build/modern/chunk-KJUCHZHV.js +51 -0
- package/build/modern/chunk-KJUCHZHV.js.map +1 -0
- package/build/modern/chunk-R4H3352X.js +16 -0
- package/build/modern/chunk-R4H3352X.js.map +1 -0
- package/build/modern/chunk-SXXWC6UD.js +83 -0
- package/build/modern/chunk-SXXWC6UD.js.map +1 -0
- package/build/modern/chunk-WSQTX34C.js +86 -0
- package/build/modern/chunk-WSQTX34C.js.map +1 -0
- package/build/modern/chunk-XFWARXLU.js +26 -0
- package/build/modern/chunk-XFWARXLU.js.map +1 -0
- package/build/modern/components/Button.js +3 -21
- package/build/modern/components/Button.js.map +1 -1
- package/build/modern/components/IconButton.js +3 -21
- package/build/modern/components/IconButton.js.map +1 -1
- package/build/modern/components/NavMenuLink.js +4 -40
- package/build/modern/components/NavMenuLink.js.map +1 -1
- package/build/modern/components/NavMenuList.js +6 -76
- package/build/modern/components/NavMenuList.js.map +1 -1
- package/build/modern/components/NavMenuTrigger.js +5 -72
- package/build/modern/components/NavMenuTrigger.js.map +1 -1
- package/build/modern/components/Show.js +3 -12
- package/build/modern/components/Show.js.map +1 -1
- package/build/modern/context/field.js +3 -27
- package/build/modern/context/field.js.map +1 -1
- package/build/modern/context/navMenu.js +3 -45
- package/build/modern/context/navMenu.js.map +1 -1
- package/build/modern/context/theme.js +6 -21
- package/build/modern/context/theme.js.map +1 -1
- package/build/modern/hooks/useTheme.js +2 -56
- package/build/modern/hooks/useTheme.js.map +1 -1
- package/build/modern/index.js +57 -13
- package/build/modern/index.js.map +1 -1
- package/build/modern/types.js +1 -0
- package/package.json +5 -12
- package/src/components/NavMenuLink.tsx +1 -1
- package/src/components/NavMenuList.tsx +3 -3
- package/src/components/NavMenuTrigger.tsx +2 -2
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -254
- package/build/legacy/aria-helpers/nav-menu.aria.cjs +0 -36
- package/build/legacy/aria-helpers/nav-menu.aria.cjs.map +0 -1
- package/build/legacy/aria-helpers/nav-menu.aria.d.cts +0 -2
- package/build/legacy/components/Button.cjs +0 -50
- package/build/legacy/components/Button.cjs.map +0 -1
- package/build/legacy/components/Button.d.cts +0 -2
- package/build/legacy/components/IconButton.cjs +0 -50
- package/build/legacy/components/IconButton.cjs.map +0 -1
- package/build/legacy/components/IconButton.d.cts +0 -3
- package/build/legacy/components/NavMenuLink.cjs +0 -69
- package/build/legacy/components/NavMenuLink.cjs.map +0 -1
- package/build/legacy/components/NavMenuLink.d.cts +0 -2
- package/build/legacy/components/NavMenuList.cjs +0 -107
- package/build/legacy/components/NavMenuList.cjs.map +0 -1
- package/build/legacy/components/NavMenuList.d.cts +0 -3
- package/build/legacy/components/NavMenuTrigger.cjs +0 -98
- package/build/legacy/components/NavMenuTrigger.cjs.map +0 -1
- package/build/legacy/components/NavMenuTrigger.d.cts +0 -2
- package/build/legacy/components/Show.cjs +0 -41
- package/build/legacy/components/Show.cjs.map +0 -1
- package/build/legacy/components/Show.d.cts +0 -2
- package/build/legacy/context/field.cjs +0 -55
- package/build/legacy/context/field.cjs.map +0 -1
- package/build/legacy/context/field.d.cts +0 -3
- package/build/legacy/context/navMenu.cjs +0 -70
- package/build/legacy/context/navMenu.cjs.map +0 -1
- package/build/legacy/context/navMenu.d.cts +0 -5
- package/build/legacy/context/theme.cjs +0 -56
- package/build/legacy/context/theme.cjs.map +0 -1
- package/build/legacy/context/theme.d.cts +0 -8
- package/build/legacy/global.d.cjs +0 -2
- package/build/legacy/global.d.d.cts +0 -1
- package/build/legacy/global.d.d.ts +0 -1
- package/build/legacy/global.d.js +0 -1
- package/build/legacy/hooks/useTheme.cjs +0 -77
- package/build/legacy/hooks/useTheme.cjs.map +0 -1
- package/build/legacy/hooks/useTheme.d.cts +0 -1
- package/build/legacy/index.cjs +0 -47
- package/build/legacy/index.cjs.map +0 -1
- package/build/legacy/index.d.cts +0 -34
- package/build/legacy/types.cjs +0 -19
- package/build/legacy/types.cjs.map +0 -1
- package/build/legacy/types.d.cts +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -254
- package/build/modern/aria-helpers/nav-menu.aria.cjs +0 -36
- package/build/modern/aria-helpers/nav-menu.aria.cjs.map +0 -1
- package/build/modern/aria-helpers/nav-menu.aria.d.cts +0 -2
- package/build/modern/components/Button.cjs +0 -50
- package/build/modern/components/Button.cjs.map +0 -1
- package/build/modern/components/Button.d.cts +0 -2
- package/build/modern/components/IconButton.cjs +0 -50
- package/build/modern/components/IconButton.cjs.map +0 -1
- package/build/modern/components/IconButton.d.cts +0 -3
- package/build/modern/components/NavMenuLink.cjs +0 -69
- package/build/modern/components/NavMenuLink.cjs.map +0 -1
- package/build/modern/components/NavMenuLink.d.cts +0 -2
- package/build/modern/components/NavMenuList.cjs +0 -107
- package/build/modern/components/NavMenuList.cjs.map +0 -1
- package/build/modern/components/NavMenuList.d.cts +0 -3
- package/build/modern/components/NavMenuTrigger.cjs +0 -98
- package/build/modern/components/NavMenuTrigger.cjs.map +0 -1
- package/build/modern/components/NavMenuTrigger.d.cts +0 -2
- package/build/modern/components/Show.cjs +0 -41
- package/build/modern/components/Show.cjs.map +0 -1
- package/build/modern/components/Show.d.cts +0 -2
- package/build/modern/context/field.cjs +0 -55
- package/build/modern/context/field.cjs.map +0 -1
- package/build/modern/context/field.d.cts +0 -3
- package/build/modern/context/navMenu.cjs +0 -70
- package/build/modern/context/navMenu.cjs.map +0 -1
- package/build/modern/context/navMenu.d.cts +0 -5
- package/build/modern/context/theme.cjs +0 -56
- package/build/modern/context/theme.cjs.map +0 -1
- package/build/modern/context/theme.d.cts +0 -8
- package/build/modern/global.d.cjs +0 -2
- package/build/modern/global.d.cjs.map +0 -1
- package/build/modern/global.d.d.cts +0 -1
- package/build/modern/global.d.d.ts +0 -1
- package/build/modern/global.d.js +0 -1
- package/build/modern/global.d.js.map +0 -1
- package/build/modern/hooks/useTheme.cjs +0 -77
- package/build/modern/hooks/useTheme.cjs.map +0 -1
- package/build/modern/hooks/useTheme.d.cts +0 -1
- package/build/modern/index.cjs +0 -47
- package/build/modern/index.cjs.map +0 -1
- package/build/modern/index.d.cts +0 -34
- package/build/modern/types.cjs +0 -19
- package/build/modern/types.cjs.map +0 -1
- package/build/modern/types.d.cts +0 -1
- package/src/global.d.ts +0 -19
- /package/build/legacy/{global.d.cjs.map → chunk-55J6XMHW.js.map} +0 -0
- /package/build/{legacy/global.d.js.map → modern/chunk-55J6XMHW.js.map} +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/components/NavMenuTrigger.tsx
|
|
22
|
-
var NavMenuTrigger_exports = {};
|
|
23
|
-
__export(NavMenuTrigger_exports, {
|
|
24
|
-
NavMenuTrigger: () => NavMenuTrigger
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(NavMenuTrigger_exports);
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
var import_css = require("@cerberus/styled-system/css.cjs");
|
|
29
|
-
var import_recipes = require("@cerberus/styled-system/recipes.cjs");
|
|
30
|
-
var import_nav_menu = require("../aria-helpers/nav-menu.aria.cjs");
|
|
31
|
-
var import_Show = require("./Show.cjs");
|
|
32
|
-
var import_navMenu = require("../context/navMenu.cjs");
|
|
33
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
-
function NavMenuTrigger(props) {
|
|
35
|
-
const {
|
|
36
|
-
as,
|
|
37
|
-
palette,
|
|
38
|
-
usage,
|
|
39
|
-
shape,
|
|
40
|
-
controls,
|
|
41
|
-
expanded: propsExpanded,
|
|
42
|
-
onClick,
|
|
43
|
-
...nativeProps
|
|
44
|
-
} = props;
|
|
45
|
-
const { triggerRef, onToggle, expanded } = (0, import_navMenu.useNavMenuContext)();
|
|
46
|
-
const ariaProps = (0, import_nav_menu.createNavTriggerProps)({
|
|
47
|
-
controls,
|
|
48
|
-
expanded: propsExpanded ?? expanded
|
|
49
|
-
});
|
|
50
|
-
const hasAs = Boolean(as);
|
|
51
|
-
const AsSub = as;
|
|
52
|
-
const handleClick = (0, import_react.useCallback)(
|
|
53
|
-
(e) => {
|
|
54
|
-
if (onClick)
|
|
55
|
-
return onClick(e);
|
|
56
|
-
onToggle();
|
|
57
|
-
},
|
|
58
|
-
[onClick, onToggle]
|
|
59
|
-
);
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
-
import_Show.Show,
|
|
62
|
-
{
|
|
63
|
-
when: hasAs,
|
|
64
|
-
fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
|
-
"button",
|
|
66
|
-
{
|
|
67
|
-
...nativeProps,
|
|
68
|
-
...ariaProps,
|
|
69
|
-
className: (0, import_css.cx)(
|
|
70
|
-
nativeProps.className,
|
|
71
|
-
(0, import_recipes.button)({
|
|
72
|
-
palette,
|
|
73
|
-
usage,
|
|
74
|
-
shape
|
|
75
|
-
})
|
|
76
|
-
),
|
|
77
|
-
onClick: handleClick,
|
|
78
|
-
ref: triggerRef,
|
|
79
|
-
children: props.children
|
|
80
|
-
}
|
|
81
|
-
),
|
|
82
|
-
children: hasAs && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
83
|
-
AsSub,
|
|
84
|
-
{
|
|
85
|
-
...nativeProps,
|
|
86
|
-
...ariaProps,
|
|
87
|
-
onClick: handleClick,
|
|
88
|
-
ref: triggerRef
|
|
89
|
-
}
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
-
0 && (module.exports = {
|
|
96
|
-
NavMenuTrigger
|
|
97
|
-
});
|
|
98
|
-
//# sourceMappingURL=NavMenuTrigger.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/NavMenuTrigger.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n type ButtonHTMLAttributes,\n type ElementType,\n type MouseEvent,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { button } from '@cerberus/styled-system/recipes'\nimport {\n createNavTriggerProps,\n type NavTriggerAriaValues,\n} from '../aria-helpers/nav-menu.aria'\nimport { Show } from './Show'\nimport type { ButtonProps } from './Button'\nimport { useNavMenuContext } from '../context/navMenu'\n\nexport interface NavMenuTriggerProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n ButtonProps,\n NavTriggerAriaValues {\n as?: ElementType\n}\n\n/**\n * A component that allows the user to trigger a navigation menu.\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n * @example\n * ```tsx\n * <NavMenu>\n * <NavMenuTrigger controls=\"nav-menu-list\">\n * Menu\n * </NavMenuTrigger>\n * </NavMenu>\n * ```\n */\nexport function NavMenuTrigger(props: NavMenuTriggerProps): JSX.Element {\n const {\n as,\n palette,\n usage,\n shape,\n controls,\n expanded: propsExpanded,\n onClick,\n ...nativeProps\n } = props\n const { triggerRef, onToggle, expanded } = useNavMenuContext()\n const ariaProps = createNavTriggerProps({\n controls,\n expanded: propsExpanded ?? expanded,\n })\n const hasAs = Boolean(as)\n const AsSub: ElementType = as!\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n if (onClick) return onClick(e)\n onToggle()\n },\n [onClick, onToggle],\n )\n\n return (\n <Show\n when={hasAs}\n fallback={\n <button\n {...nativeProps}\n {...ariaProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n onClick={handleClick}\n ref={triggerRef}\n >\n {props.children}\n </button>\n }\n >\n {hasAs && (\n <AsSub\n {...nativeProps}\n {...ariaProps}\n onClick={handleClick}\n ref={triggerRef}\n />\n )}\n </Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAKO;AACP,iBAAmB;AACnB,qBAAuB;AACvB,sBAGO;AACP,kBAAqB;AAErB,qBAAkC;AAoD1B;AA/BD,SAAS,eAAe,OAAyC;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,EAAE,YAAY,UAAU,SAAS,QAAI,kCAAkB;AAC7D,QAAM,gBAAY,uCAAsB;AAAA,IACtC;AAAA,IACA,UAAU,iBAAiB;AAAA,EAC7B,CAAC;AACD,QAAM,QAAQ,QAAQ,EAAE;AACxB,QAAM,QAAqB;AAE3B,QAAM,kBAAc;AAAA,IAClB,CAAC,MAAqC;AACpC,UAAI;AAAS,eAAO,QAAQ,CAAC;AAC7B,eAAS;AAAA,IACX;AAAA,IACA,CAAC,SAAS,QAAQ;AAAA,EACpB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN,UACE;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,eAAW;AAAA,YACT,YAAY;AAAA,gBACZ,uBAAO;AAAA,cACL;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH;AAAA,UACA,SAAS;AAAA,UACT,KAAK;AAAA,UAEJ,gBAAM;AAAA;AAAA,MACT;AAAA,MAGD,mBACC;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,KAAK;AAAA;AAAA,MACP;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/components/Show.tsx
|
|
22
|
-
var Show_exports = {};
|
|
23
|
-
__export(Show_exports, {
|
|
24
|
-
Show: () => Show
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(Show_exports);
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
function Show(props) {
|
|
29
|
-
const { when, children, fallback } = props;
|
|
30
|
-
const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
|
|
31
|
-
return (0, import_react.useMemo)(() => {
|
|
32
|
-
if (condition)
|
|
33
|
-
return children;
|
|
34
|
-
return fallback ?? null;
|
|
35
|
-
}, [condition, children, fallback]);
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
Show
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=Show.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\nexport interface ShowProps {\n when: boolean | null | undefined\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render its children or an optional fallback component\n * based on the SolidJS component.\n * @definition [Show docs](https://cerberus.digitalu.design/react/show)\n * @example\n * ```tsx\n * <Show when={condition}>\n * <div>Content</div>\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAgE;AAiBzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI;AAAW,aAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;","names":[]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/context/field.tsx
|
|
22
|
-
var field_exports = {};
|
|
23
|
-
__export(field_exports, {
|
|
24
|
-
Field: () => Field,
|
|
25
|
-
useFieldContext: () => useFieldContext
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(field_exports);
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
var FieldContext = (0, import_react.createContext)(null);
|
|
31
|
-
function Field(props) {
|
|
32
|
-
const value = (0, import_react.useMemo)(
|
|
33
|
-
() => ({
|
|
34
|
-
disabled: props.disabled,
|
|
35
|
-
readonly: props.readonly,
|
|
36
|
-
required: props.required,
|
|
37
|
-
invalid: props.invalid
|
|
38
|
-
}),
|
|
39
|
-
[props.disabled, props.readonly, props.required, props.invalid]
|
|
40
|
-
);
|
|
41
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldContext.Provider, { value, children: props.children });
|
|
42
|
-
}
|
|
43
|
-
function useFieldContext() {
|
|
44
|
-
const context = (0, import_react.useContext)(FieldContext);
|
|
45
|
-
if (!context) {
|
|
46
|
-
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
47
|
-
}
|
|
48
|
-
return context;
|
|
49
|
-
}
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
Field,
|
|
53
|
-
useFieldContext
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=field.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/field.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useMemo,\n type PropsWithChildren,\n} from 'react'\n\nexport interface FieldContextValue {\n disabled?: boolean\n readonly?: boolean\n required?: boolean\n invalid?: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nexport function Field(\n props: PropsWithChildren<FieldContextValue>,\n): JSX.Element {\n const value = useMemo(\n () => ({\n disabled: props.disabled,\n readonly: props.readonly,\n required: props.required,\n invalid: props.invalid,\n }),\n [props.disabled, props.readonly, props.required, props.invalid],\n )\n\n return (\n <FieldContext.Provider value={value}>\n {props.children}\n </FieldContext.Provider>\n )\n}\n\nexport function useFieldContext(): FieldContextValue {\n const context = useContext(FieldContext)\n if (!context) {\n throw new Error('useFieldContext must be used within a Field Provider.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAKO;AAyBH;AAhBJ,IAAM,mBAAe,4BAAwC,IAAI;AAE1D,SAAS,MACd,OACa;AACb,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,CAAC,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,OAAO;AAAA,EAChE;AAEA,SACE,4CAAC,aAAa,UAAb,EAAsB,OACpB,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/context/navMenu.tsx
|
|
22
|
-
var navMenu_exports = {};
|
|
23
|
-
__export(navMenu_exports, {
|
|
24
|
-
NavMenu: () => NavMenu,
|
|
25
|
-
useNavMenuContext: () => useNavMenuContext
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(navMenu_exports);
|
|
28
|
-
var import_css = require("@cerberus/styled-system/css.cjs");
|
|
29
|
-
var import_react = require("react");
|
|
30
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
var NavMenuContext = (0, import_react.createContext)(null);
|
|
32
|
-
function NavMenu(props) {
|
|
33
|
-
const triggerRef = (0, import_react.useRef)(null);
|
|
34
|
-
const menuRef = (0, import_react.useRef)(null);
|
|
35
|
-
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
36
|
-
const handleToggle = (0, import_react.useCallback)(() => {
|
|
37
|
-
setExpanded((prev) => !prev);
|
|
38
|
-
}, []);
|
|
39
|
-
const value = (0, import_react.useMemo)(
|
|
40
|
-
() => ({
|
|
41
|
-
triggerRef,
|
|
42
|
-
menuRef,
|
|
43
|
-
expanded,
|
|
44
|
-
onToggle: handleToggle
|
|
45
|
-
}),
|
|
46
|
-
[expanded, handleToggle]
|
|
47
|
-
);
|
|
48
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavMenuContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
|
-
"nav",
|
|
50
|
-
{
|
|
51
|
-
className: (0, import_css.css)({
|
|
52
|
-
position: "relative"
|
|
53
|
-
}),
|
|
54
|
-
children: props.children
|
|
55
|
-
}
|
|
56
|
-
) });
|
|
57
|
-
}
|
|
58
|
-
function useNavMenuContext() {
|
|
59
|
-
const context = (0, import_react.useContext)(NavMenuContext);
|
|
60
|
-
if (!context) {
|
|
61
|
-
throw new Error("useNavMenuContext must be used within a NavMenu.");
|
|
62
|
-
}
|
|
63
|
-
return context;
|
|
64
|
-
}
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
NavMenu,
|
|
68
|
-
useNavMenuContext
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=navMenu.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/navMenu.tsx"],"sourcesContent":["'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n triggerRef: NavTriggerRef | null\n menuRef: NavMenuRef | null\n expanded: boolean\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AACpB,mBASO;AAmCD;AAvBN,IAAM,qBAAiB,4BAA0C,IAAI;AAE9D,SAAS,QAAQ,OAAuC;AAC7D,QAAM,iBAAa,qBAA0B,IAAI;AACjD,QAAM,cAAU,qBAAyB,IAAI;AAC7C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,mBAAe,0BAAY,MAAM;AACrC,gBAAY,CAAC,SAAS,CAAC,IAAI;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,IACA,CAAC,UAAU,YAAY;AAAA,EACzB;AAEA,SACE,4CAAC,eAAe,UAAf,EAAwB,OACvB;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,gBAAI;AAAA,QACb,UAAU;AAAA,MACZ,CAAC;AAAA,MAEA,gBAAM;AAAA;AAAA,EACT,GACF;AAEJ;AAEO,SAAS,oBAAyC;AACvD,QAAM,cAAU,yBAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { NavMenu_alias_1 as NavMenu } from '../_tsup-dts-rollup';
|
|
2
|
-
export { useNavMenuContext_alias_1 as useNavMenuContext } from '../_tsup-dts-rollup';
|
|
3
|
-
export { NavTriggerRef_alias_1 as NavTriggerRef } from '../_tsup-dts-rollup';
|
|
4
|
-
export { NavMenuRef_alias_1 as NavMenuRef } from '../_tsup-dts-rollup';
|
|
5
|
-
export { NavMenuContextValue_alias_1 as NavMenuContextValue } from '../_tsup-dts-rollup';
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/context/theme.tsx
|
|
22
|
-
var theme_exports = {};
|
|
23
|
-
__export(theme_exports, {
|
|
24
|
-
MODE_KEY: () => MODE_KEY,
|
|
25
|
-
THEME_KEY: () => THEME_KEY,
|
|
26
|
-
ThemeProvider: () => ThemeProvider,
|
|
27
|
-
useThemeContext: () => useThemeContext
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(theme_exports);
|
|
30
|
-
var import_react = require("react");
|
|
31
|
-
var import_useTheme = require("../hooks/useTheme.cjs");
|
|
32
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var THEME_KEY = "cerberus-theme";
|
|
34
|
-
var MODE_KEY = "cerberus-mode";
|
|
35
|
-
var ThemeContext = (0, import_react.createContext)(
|
|
36
|
-
null
|
|
37
|
-
);
|
|
38
|
-
function ThemeProvider(props) {
|
|
39
|
-
const state = (0, import_useTheme.useTheme)();
|
|
40
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
41
|
-
}
|
|
42
|
-
function useThemeContext() {
|
|
43
|
-
const context = (0, import_react.useContext)(ThemeContext);
|
|
44
|
-
if (!context) {
|
|
45
|
-
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
46
|
-
}
|
|
47
|
-
return context;
|
|
48
|
-
}
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
MODE_KEY,
|
|
52
|
-
THEME_KEY,
|
|
53
|
-
ThemeProvider,
|
|
54
|
-
useThemeContext
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=theme.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/theme.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\nimport { useTheme } from '../hooks/useTheme'\n\nexport type DefaultThemes = 'cerberus'\nexport type CustomThemes<K extends string = DefaultThemes> = 'cerberus' | K\nexport type ColorModes = 'light' | 'dark'\n\nexport interface ThemeContextValue<T extends string = DefaultThemes> {\n theme: CustomThemes<T>\n mode: ColorModes\n updateTheme: (theme: T) => void\n updateMode: () => void\n}\n\nexport const THEME_KEY = 'cerberus-theme'\nexport const MODE_KEY = 'cerberus-mode'\n\nconst ThemeContext = createContext<ThemeContextValue<DefaultThemes> | null>(\n null,\n)\n\n/**\n * A context provider that allows the user to set the theme and mode of the application.\n * @example\n * ```tsx\n * <ThemeProvider>\n * <App />\n * </ThemeProvider>\n * ```\n */\nexport function ThemeProvider(props: PropsWithChildren<unknown>): JSX.Element {\n const state = useTheme()\n return (\n <ThemeContext.Provider value={state}>\n {props.children}\n </ThemeContext.Provider>\n )\n}\n\nexport function useThemeContext(): ThemeContextValue<DefaultThemes> {\n const context = useContext(ThemeContext)\n if (!context) {\n throw new Error('useThemeContext must be used within a ThemeProvider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkE;AAClE,sBAAyB;AAgCrB;AAnBG,IAAM,YAAY;AAClB,IAAM,WAAW;AAExB,IAAM,mBAAe;AAAA,EACnB;AACF;AAWO,SAAS,cAAc,OAAgD;AAC5E,QAAM,YAAQ,0BAAS;AACvB,SACE,4CAAC,aAAa,UAAb,EAAsB,OAAO,OAC3B,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAoD;AAClE,QAAM,cAAU,yBAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { ThemeProvider_alias_1 as ThemeProvider } from '../_tsup-dts-rollup';
|
|
2
|
-
export { useThemeContext_alias_1 as useThemeContext } from '../_tsup-dts-rollup';
|
|
3
|
-
export { DefaultThemes_alias_1 as DefaultThemes } from '../_tsup-dts-rollup';
|
|
4
|
-
export { CustomThemes_alias_1 as CustomThemes } from '../_tsup-dts-rollup';
|
|
5
|
-
export { ColorModes_alias_1 as ColorModes } from '../_tsup-dts-rollup';
|
|
6
|
-
export { ThemeContextValue_alias_1 as ThemeContextValue } from '../_tsup-dts-rollup';
|
|
7
|
-
export { THEME_KEY_alias_1 as THEME_KEY } from '../_tsup-dts-rollup';
|
|
8
|
-
export { MODE_KEY_alias_1 as MODE_KEY } from '../_tsup-dts-rollup';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/build/legacy/global.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=global.d.js.map
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useTheme.ts
|
|
22
|
-
var useTheme_exports = {};
|
|
23
|
-
__export(useTheme_exports, {
|
|
24
|
-
useTheme: () => useTheme
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useTheme_exports);
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
var import_theme = require("../context/theme.cjs");
|
|
29
|
-
function useTheme(defaultTheme = "cerberus", defaultColorMode = "light") {
|
|
30
|
-
const [theme, setTheme] = (0, import_react.useState)(defaultTheme);
|
|
31
|
-
const [colorMode, setColorMode] = (0, import_react.useState)(defaultColorMode);
|
|
32
|
-
const handleThemeChange = (0, import_react.useCallback)((newTheme) => {
|
|
33
|
-
setTheme(newTheme);
|
|
34
|
-
localStorage.setItem(import_theme.THEME_KEY, newTheme);
|
|
35
|
-
}, []);
|
|
36
|
-
const handleColorModeChange = (0, import_react.useCallback)(() => {
|
|
37
|
-
setColorMode((prev) => {
|
|
38
|
-
const newMode = prev === "light" ? "dark" : "light";
|
|
39
|
-
localStorage.setItem(import_theme.MODE_KEY, newMode);
|
|
40
|
-
return newMode;
|
|
41
|
-
});
|
|
42
|
-
}, []);
|
|
43
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
44
|
-
const theme2 = localStorage.getItem(import_theme.THEME_KEY);
|
|
45
|
-
if (theme2) {
|
|
46
|
-
setTheme(theme2);
|
|
47
|
-
}
|
|
48
|
-
}, []);
|
|
49
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
50
|
-
const mode = localStorage.getItem(import_theme.MODE_KEY);
|
|
51
|
-
if (mode) {
|
|
52
|
-
setColorMode(mode);
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
(0, import_react.useEffect)(() => {
|
|
56
|
-
const root = document.documentElement;
|
|
57
|
-
root.dataset.theme = theme;
|
|
58
|
-
}, [theme]);
|
|
59
|
-
(0, import_react.useEffect)(() => {
|
|
60
|
-
const root = document.documentElement;
|
|
61
|
-
root.dataset.colorMode = colorMode;
|
|
62
|
-
}, [colorMode]);
|
|
63
|
-
return (0, import_react.useMemo)(
|
|
64
|
-
() => ({
|
|
65
|
-
theme,
|
|
66
|
-
mode: colorMode,
|
|
67
|
-
updateTheme: handleThemeChange,
|
|
68
|
-
updateMode: handleColorModeChange
|
|
69
|
-
}),
|
|
70
|
-
[theme, colorMode, handleThemeChange, handleColorModeChange]
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
useTheme
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=useTheme.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useTheme.ts"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n MODE_KEY,\n THEME_KEY,\n type ColorModes,\n type CustomThemes,\n type DefaultThemes,\n type ThemeContextValue,\n} from '../context/theme'\n\nexport function useTheme<C extends string = DefaultThemes>(\n defaultTheme: CustomThemes<C> = 'cerberus',\n defaultColorMode: ColorModes = 'light',\n): ThemeContextValue<C> {\n const [theme, setTheme] = useState<CustomThemes<C>>(defaultTheme)\n const [colorMode, setColorMode] = useState<ColorModes>(defaultColorMode)\n\n const handleThemeChange = useCallback((newTheme: CustomThemes<C>) => {\n setTheme(newTheme)\n localStorage.setItem(THEME_KEY, newTheme)\n }, [])\n\n const handleColorModeChange = useCallback(() => {\n setColorMode((prev) => {\n const newMode = prev === 'light' ? 'dark' : 'light'\n localStorage.setItem(MODE_KEY, newMode)\n return newMode\n })\n }, [])\n\n useLayoutEffect(() => {\n const theme = localStorage.getItem(THEME_KEY)\n if (theme) {\n setTheme(theme as CustomThemes<C>)\n }\n }, [])\n\n useLayoutEffect(() => {\n const mode = localStorage.getItem(MODE_KEY)\n if (mode) {\n setColorMode(mode as ColorModes)\n }\n }, [])\n\n useEffect(() => {\n const root = document.documentElement\n root.dataset.theme = theme\n }, [theme])\n\n useEffect(() => {\n const root = document.documentElement\n root.dataset.colorMode = colorMode\n }, [colorMode])\n\n return useMemo(\n () => ({\n theme,\n mode: colorMode,\n updateTheme: handleThemeChange,\n updateMode: handleColorModeChange,\n }),\n [theme, colorMode, handleThemeChange, handleColorModeChange],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAMO;AACP,mBAOO;AAEA,SAAS,SACd,eAAgC,YAChC,mBAA+B,SACT;AACtB,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA0B,YAAY;AAChE,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAqB,gBAAgB;AAEvE,QAAM,wBAAoB,0BAAY,CAAC,aAA8B;AACnE,aAAS,QAAQ;AACjB,iBAAa,QAAQ,wBAAW,QAAQ;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,QAAM,4BAAwB,0BAAY,MAAM;AAC9C,iBAAa,CAAC,SAAS;AACrB,YAAM,UAAU,SAAS,UAAU,SAAS;AAC5C,mBAAa,QAAQ,uBAAU,OAAO;AACtC,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,oCAAgB,MAAM;AACpB,UAAMA,SAAQ,aAAa,QAAQ,sBAAS;AAC5C,QAAIA,QAAO;AACT,eAASA,MAAwB;AAAA,IACnC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,oCAAgB,MAAM;AACpB,UAAM,OAAO,aAAa,QAAQ,qBAAQ;AAC1C,QAAI,MAAM;AACR,mBAAa,IAAkB;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,8BAAU,MAAM;AACd,UAAM,OAAO,SAAS;AACtB,SAAK,QAAQ,QAAQ;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAEV,8BAAU,MAAM;AACd,UAAM,OAAO,SAAS;AACtB,SAAK,QAAQ,YAAY;AAAA,EAC3B,GAAG,CAAC,SAAS,CAAC;AAEd,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AAAA,IACA,CAAC,OAAO,WAAW,mBAAmB,qBAAqB;AAAA,EAC7D;AACF;","names":["theme"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useTheme_alias_1 as useTheme } from '../_tsup-dts-rollup';
|
package/build/legacy/index.cjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
|
|
17
|
-
// src/index.ts
|
|
18
|
-
var src_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(src_exports);
|
|
20
|
-
__reExport(src_exports, require("./components/Button.cjs"), module.exports);
|
|
21
|
-
__reExport(src_exports, require("./components/IconButton.cjs"), module.exports);
|
|
22
|
-
__reExport(src_exports, require("./components/NavMenuTrigger.cjs"), module.exports);
|
|
23
|
-
__reExport(src_exports, require("./components/NavMenuList.cjs"), module.exports);
|
|
24
|
-
__reExport(src_exports, require("./components/NavMenuLink.cjs"), module.exports);
|
|
25
|
-
__reExport(src_exports, require("./components/Show.cjs"), module.exports);
|
|
26
|
-
__reExport(src_exports, require("./context/field.cjs"), module.exports);
|
|
27
|
-
__reExport(src_exports, require("./context/navMenu.cjs"), module.exports);
|
|
28
|
-
__reExport(src_exports, require("./context/theme.cjs"), module.exports);
|
|
29
|
-
__reExport(src_exports, require("./hooks/useTheme.cjs"), module.exports);
|
|
30
|
-
__reExport(src_exports, require("./aria-helpers/nav-menu.aria.cjs"), module.exports);
|
|
31
|
-
__reExport(src_exports, require("./types.cjs"), module.exports);
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
...require("./components/Button.cjs"),
|
|
35
|
-
...require("./components/IconButton.cjs"),
|
|
36
|
-
...require("./components/NavMenuTrigger.cjs"),
|
|
37
|
-
...require("./components/NavMenuList.cjs"),
|
|
38
|
-
...require("./components/NavMenuLink.cjs"),
|
|
39
|
-
...require("./components/Show.cjs"),
|
|
40
|
-
...require("./context/field.cjs"),
|
|
41
|
-
...require("./context/navMenu.cjs"),
|
|
42
|
-
...require("./context/theme.cjs"),
|
|
43
|
-
...require("./hooks/useTheme.cjs"),
|
|
44
|
-
...require("./aria-helpers/nav-menu.aria.cjs"),
|
|
45
|
-
...require("./types.cjs")
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/Button'\nexport * from './components/IconButton'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\n\n// shared types\n\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAOA,wBAAc,oCAPd;AAQA,wBAAc,wCARd;AASA,wBAAc,4CATd;AAUA,wBAAc,yCAVd;AAWA,wBAAc,yCAXd;AAYA,wBAAc,kCAZd;AAgBA,wBAAc,gCAhBd;AAiBA,wBAAc,kCAjBd;AAkBA,wBAAc,gCAlBd;AAsBA,wBAAc,iCAtBd;AA0BA,wBAAc,6CA1Bd;AA8BA,wBAAc,wBA9Bd;","names":[]}
|
package/build/legacy/index.d.cts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export { Button } from './_tsup-dts-rollup';
|
|
2
|
-
export { ButtonProps } from './_tsup-dts-rollup';
|
|
3
|
-
export { IconButton } from './_tsup-dts-rollup';
|
|
4
|
-
export { IconButtonUsage } from './_tsup-dts-rollup';
|
|
5
|
-
export { IconButtonProps } from './_tsup-dts-rollup';
|
|
6
|
-
export { NavMenuTrigger } from './_tsup-dts-rollup';
|
|
7
|
-
export { NavMenuTriggerProps } from './_tsup-dts-rollup';
|
|
8
|
-
export { getPosition } from './_tsup-dts-rollup';
|
|
9
|
-
export { NavMenuList } from './_tsup-dts-rollup';
|
|
10
|
-
export { NavMenuListProps } from './_tsup-dts-rollup';
|
|
11
|
-
export { NavMenuLink } from './_tsup-dts-rollup';
|
|
12
|
-
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
13
|
-
export { Show } from './_tsup-dts-rollup';
|
|
14
|
-
export { ShowProps } from './_tsup-dts-rollup';
|
|
15
|
-
export { Field } from './_tsup-dts-rollup';
|
|
16
|
-
export { useFieldContext } from './_tsup-dts-rollup';
|
|
17
|
-
export { FieldContextValue } from './_tsup-dts-rollup';
|
|
18
|
-
export { NavMenu } from './_tsup-dts-rollup';
|
|
19
|
-
export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
20
|
-
export { NavTriggerRef } from './_tsup-dts-rollup';
|
|
21
|
-
export { NavMenuRef } from './_tsup-dts-rollup';
|
|
22
|
-
export { NavMenuContextValue } from './_tsup-dts-rollup';
|
|
23
|
-
export { ThemeProvider } from './_tsup-dts-rollup';
|
|
24
|
-
export { useThemeContext } from './_tsup-dts-rollup';
|
|
25
|
-
export { DefaultThemes } from './_tsup-dts-rollup';
|
|
26
|
-
export { CustomThemes } from './_tsup-dts-rollup';
|
|
27
|
-
export { ColorModes } from './_tsup-dts-rollup';
|
|
28
|
-
export { ThemeContextValue } from './_tsup-dts-rollup';
|
|
29
|
-
export { THEME_KEY } from './_tsup-dts-rollup';
|
|
30
|
-
export { MODE_KEY } from './_tsup-dts-rollup';
|
|
31
|
-
export { useTheme } from './_tsup-dts-rollup';
|
|
32
|
-
export { createNavTriggerProps } from './_tsup-dts-rollup';
|
|
33
|
-
export { NavTriggerAriaValues } from './_tsup-dts-rollup';
|
|
34
|
-
export { Positions } from './_tsup-dts-rollup';
|
package/build/legacy/types.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
19
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export type Positions = 'top' | 'right' | 'bottom' | 'left'\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/build/legacy/types.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Positions_alias_1 as Positions } from './_tsup-dts-rollup';
|