@cerberus-design/react 0.0.1-next-57d4255 → 0.0.1-next-11f55b0
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 +13 -0
- package/build/legacy/_tsup-dts-rollup.d.ts +13 -0
- package/build/legacy/components/Button.cjs +50 -0
- package/build/legacy/components/Button.cjs.map +1 -0
- package/build/legacy/components/Button.d.cts +2 -0
- package/build/legacy/components/Button.d.ts +2 -0
- package/build/legacy/components/Button.js +25 -0
- package/build/legacy/components/Button.js.map +1 -0
- package/build/legacy/components/Show.cjs +41 -0
- package/build/legacy/components/Show.cjs.map +1 -0
- package/build/legacy/components/Show.d.cts +2 -0
- package/build/legacy/components/Show.d.ts +2 -0
- package/build/legacy/components/Show.js +17 -0
- package/build/legacy/components/Show.js.map +1 -0
- package/build/legacy/context/theme.cjs +62 -0
- package/build/legacy/context/theme.cjs.map +1 -0
- package/build/legacy/context/theme.d.cts +8 -0
- package/build/legacy/context/theme.d.ts +8 -0
- package/build/legacy/context/theme.js +35 -0
- package/build/legacy/context/theme.js.map +1 -0
- package/build/legacy/index.cjs +2 -0
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +2 -0
- package/build/legacy/index.d.ts +2 -0
- package/build/legacy/index.js +1 -0
- package/build/legacy/index.js.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.cts +13 -0
- package/build/modern/_tsup-dts-rollup.d.ts +13 -0
- package/build/modern/components/Button.cjs +50 -0
- package/build/modern/components/Button.cjs.map +1 -0
- package/build/modern/components/Button.d.cts +2 -0
- package/build/modern/components/Button.d.ts +2 -0
- package/build/modern/components/Button.js +25 -0
- package/build/modern/components/Button.js.map +1 -0
- package/build/modern/components/Show.cjs +41 -0
- package/build/modern/components/Show.cjs.map +1 -0
- package/build/modern/components/Show.d.cts +2 -0
- package/build/modern/components/Show.d.ts +2 -0
- package/build/modern/components/Show.js +17 -0
- package/build/modern/components/Show.js.map +1 -0
- package/build/modern/context/theme.cjs +62 -0
- package/build/modern/context/theme.cjs.map +1 -0
- package/build/modern/context/theme.d.cts +8 -0
- package/build/modern/context/theme.d.ts +8 -0
- package/build/modern/context/theme.js +35 -0
- package/build/modern/context/theme.js.map +1 -0
- package/build/modern/index.cjs +2 -0
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +2 -0
- package/build/modern/index.d.ts +2 -0
- package/build/modern/index.js +1 -0
- package/build/modern/index.js.map +1 -1
- package/package.json +10 -4
- package/src/components/Button.tsx +26 -0
- package/src/index.ts +1 -0
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react';
|
|
1
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
3
|
import { PropsWithChildren } from 'react';
|
|
3
4
|
import { ReactNode } from 'react';
|
|
4
5
|
|
|
6
|
+
declare function Button(props: ButtonProps): JSX_2.Element;
|
|
7
|
+
export { Button }
|
|
8
|
+
export { Button as Button_alias_1 }
|
|
9
|
+
|
|
10
|
+
declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
palette?: 'action' | 'danger';
|
|
12
|
+
usage?: 'filled' | 'outline' | 'text';
|
|
13
|
+
shape?: 'sharp' | 'rounded';
|
|
14
|
+
}
|
|
15
|
+
export { ButtonProps }
|
|
16
|
+
export { ButtonProps as ButtonProps_alias_1 }
|
|
17
|
+
|
|
5
18
|
declare type ColorModes = 'light' | 'dark';
|
|
6
19
|
export { ColorModes }
|
|
7
20
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react';
|
|
1
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
3
|
import { PropsWithChildren } from 'react';
|
|
3
4
|
import { ReactNode } from 'react';
|
|
4
5
|
|
|
6
|
+
declare function Button(props: ButtonProps): JSX_2.Element;
|
|
7
|
+
export { Button }
|
|
8
|
+
export { Button as Button_alias_1 }
|
|
9
|
+
|
|
10
|
+
declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
palette?: 'action' | 'danger';
|
|
12
|
+
usage?: 'filled' | 'outline' | 'text';
|
|
13
|
+
shape?: 'sharp' | 'rounded';
|
|
14
|
+
}
|
|
15
|
+
export { ButtonProps }
|
|
16
|
+
export { ButtonProps as ButtonProps_alias_1 }
|
|
17
|
+
|
|
5
18
|
declare type ColorModes = 'light' | 'dark';
|
|
6
19
|
export { ColorModes }
|
|
7
20
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -0,0 +1,50 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Button.tsx
|
|
21
|
+
var Button_exports = {};
|
|
22
|
+
__export(Button_exports, {
|
|
23
|
+
Button: () => Button
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Button_exports);
|
|
26
|
+
var import_css = require("@cerberus-design/styled-system/css");
|
|
27
|
+
var import_recipes = require("@cerberus-design/styled-system/recipes");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
function Button(props) {
|
|
30
|
+
const { palette, usage, shape, ...nativeProps } = props;
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
...nativeProps,
|
|
35
|
+
className: (0, import_css.cx)(
|
|
36
|
+
nativeProps.className,
|
|
37
|
+
(0, import_recipes.button)({
|
|
38
|
+
palette,
|
|
39
|
+
usage,
|
|
40
|
+
shape
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
Button
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=Button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus-design/styled-system/css'\nimport { button } from '@cerberus-design/styled-system/recipes'\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n palette?: 'action' | 'danger'\n usage?: 'filled' | 'outline' | 'text'\n shape?: 'sharp' | 'rounded'\n}\n\nexport function Button(props: ButtonProps) {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAmB;AACnB,qBAAuB;AAWnB;AAHG,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,SAAS,OAAO,OAAO,GAAG,YAAY,IAAI;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/components/Button.tsx
|
|
2
|
+
import { cx } from "@cerberus-design/styled-system/css";
|
|
3
|
+
import { button } from "@cerberus-design/styled-system/recipes";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function Button(props) {
|
|
6
|
+
const { palette, usage, shape, ...nativeProps } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"button",
|
|
9
|
+
{
|
|
10
|
+
...nativeProps,
|
|
11
|
+
className: cx(
|
|
12
|
+
nativeProps.className,
|
|
13
|
+
button({
|
|
14
|
+
palette,
|
|
15
|
+
usage,
|
|
16
|
+
shape
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
Button
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus-design/styled-system/css'\nimport { button } from '@cerberus-design/styled-system/recipes'\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n palette?: 'action' | 'danger'\n usage?: 'filled' | 'outline' | 'text'\n shape?: 'sharp' | 'rounded'\n}\n\nexport function Button(props: ButtonProps) {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,cAAc;AAWnB;AAHG,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,SAAS,OAAO,OAAO,GAAG,YAAY,IAAI;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 * @description https://docs.solidjs.com/reference/components/show\n */\nexport function Show(props: PropsWithChildren<ShowProps>) {\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;AAYzD,SAAS,KAAK,OAAqC;AACxD,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":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/Show.tsx
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
function Show(props) {
|
|
6
|
+
const { when, children, fallback } = props;
|
|
7
|
+
const condition = useMemo(() => when ?? false, [when]);
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
if (condition)
|
|
10
|
+
return children;
|
|
11
|
+
return fallback ?? null;
|
|
12
|
+
}, [condition, children, fallback]);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
Show
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=Show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 * @description https://docs.solidjs.com/reference/components/show\n */\nexport function Show(props: PropsWithChildren<ShowProps>) {\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":";;;AAEA,SAAS,eAAuD;AAYzD,SAAS,KAAK,OAAqC;AACxD,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,YAAY,QAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,SAAO,QAAQ,MAAM;AACnB,QAAI;AAAW,aAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 initialThemeState = {
|
|
36
|
+
theme: "cerberus",
|
|
37
|
+
mode: "light",
|
|
38
|
+
updateTheme: () => {
|
|
39
|
+
},
|
|
40
|
+
updateMode: () => {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var ThemeContext = (0, import_react.createContext)(initialThemeState);
|
|
44
|
+
function ThemeProvider(props) {
|
|
45
|
+
const state = (0, import_useTheme.useTheme)();
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
47
|
+
}
|
|
48
|
+
function useThemeContext() {
|
|
49
|
+
const context = (0, import_react.useContext)(ThemeContext);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
MODE_KEY,
|
|
58
|
+
THEME_KEY,
|
|
59
|
+
ThemeProvider,
|
|
60
|
+
useThemeContext
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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 initialThemeState = {\n theme: 'cerberus' as const,\n mode: 'light' as const,\n updateTheme: () => {},\n updateMode: () => {},\n}\n\nconst ThemeContext =\n createContext<ThemeContextValue<DefaultThemes>>(initialThemeState)\n\nexport function ThemeProvider(props: PropsWithChildren<unknown>) {\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;AA6BrB;AAhBG,IAAM,YAAY;AAClB,IAAM,WAAW;AAExB,IAAM,oBAAoB;AAAA,EACxB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,YAAY,MAAM;AAAA,EAAC;AACrB;AAEA,IAAM,mBACJ,4BAAgD,iBAAiB;AAE5D,SAAS,cAAc,OAAmC;AAC/D,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":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/context/theme.tsx
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
import { useTheme } from "../hooks/useTheme.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var THEME_KEY = "cerberus-theme";
|
|
8
|
+
var MODE_KEY = "cerberus-mode";
|
|
9
|
+
var initialThemeState = {
|
|
10
|
+
theme: "cerberus",
|
|
11
|
+
mode: "light",
|
|
12
|
+
updateTheme: () => {
|
|
13
|
+
},
|
|
14
|
+
updateMode: () => {
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var ThemeContext = createContext(initialThemeState);
|
|
18
|
+
function ThemeProvider(props) {
|
|
19
|
+
const state = useTheme();
|
|
20
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: state, children: props.children });
|
|
21
|
+
}
|
|
22
|
+
function useThemeContext() {
|
|
23
|
+
const context = useContext(ThemeContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
MODE_KEY,
|
|
31
|
+
THEME_KEY,
|
|
32
|
+
ThemeProvider,
|
|
33
|
+
useThemeContext
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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 initialThemeState = {\n theme: 'cerberus' as const,\n mode: 'light' as const,\n updateTheme: () => {},\n updateMode: () => {},\n}\n\nconst ThemeContext =\n createContext<ThemeContextValue<DefaultThemes>>(initialThemeState)\n\nexport function ThemeProvider(props: PropsWithChildren<unknown>) {\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":";;;AAEA,SAAS,eAAe,kBAA0C;AAClE,SAAS,gBAAgB;AA6BrB;AAhBG,IAAM,YAAY;AAClB,IAAM,WAAW;AAExB,IAAM,oBAAoB;AAAA,EACxB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,YAAY,MAAM;AAAA,EAAC;AACrB;AAEA,IAAM,eACJ,cAAgD,iBAAiB;AAE5D,SAAS,cAAc,OAAmC;AAC/D,QAAM,QAAQ,SAAS;AACvB,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAC3B,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAoD;AAClE,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
package/build/legacy/index.cjs
CHANGED
|
@@ -17,11 +17,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var src_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(src_exports);
|
|
20
|
+
__reExport(src_exports, require("./components/Button.cjs"), module.exports);
|
|
20
21
|
__reExport(src_exports, require("./components/Show.cjs"), module.exports);
|
|
21
22
|
__reExport(src_exports, require("./context/theme.cjs"), module.exports);
|
|
22
23
|
__reExport(src_exports, require("./hooks/useTheme.cjs"), module.exports);
|
|
23
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
25
|
0 && (module.exports = {
|
|
26
|
+
...require("./components/Button.cjs"),
|
|
25
27
|
...require("./components/Show.cjs"),
|
|
26
28
|
...require("./context/theme.cjs"),
|
|
27
29
|
...require("./hooks/useTheme.cjs")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,kCAHd;AAOA,wBAAc,gCAPd;AAWA,wBAAc,iCAXd;","names":[]}
|
package/build/legacy/index.d.cts
CHANGED
package/build/legacy/index.d.ts
CHANGED
package/build/legacy/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";AAEA,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react';
|
|
1
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
3
|
import { PropsWithChildren } from 'react';
|
|
3
4
|
import { ReactNode } from 'react';
|
|
4
5
|
|
|
6
|
+
declare function Button(props: ButtonProps): JSX_2.Element;
|
|
7
|
+
export { Button }
|
|
8
|
+
export { Button as Button_alias_1 }
|
|
9
|
+
|
|
10
|
+
declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
palette?: 'action' | 'danger';
|
|
12
|
+
usage?: 'filled' | 'outline' | 'text';
|
|
13
|
+
shape?: 'sharp' | 'rounded';
|
|
14
|
+
}
|
|
15
|
+
export { ButtonProps }
|
|
16
|
+
export { ButtonProps as ButtonProps_alias_1 }
|
|
17
|
+
|
|
5
18
|
declare type ColorModes = 'light' | 'dark';
|
|
6
19
|
export { ColorModes }
|
|
7
20
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react';
|
|
1
2
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
3
|
import { PropsWithChildren } from 'react';
|
|
3
4
|
import { ReactNode } from 'react';
|
|
4
5
|
|
|
6
|
+
declare function Button(props: ButtonProps): JSX_2.Element;
|
|
7
|
+
export { Button }
|
|
8
|
+
export { Button as Button_alias_1 }
|
|
9
|
+
|
|
10
|
+
declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
palette?: 'action' | 'danger';
|
|
12
|
+
usage?: 'filled' | 'outline' | 'text';
|
|
13
|
+
shape?: 'sharp' | 'rounded';
|
|
14
|
+
}
|
|
15
|
+
export { ButtonProps }
|
|
16
|
+
export { ButtonProps as ButtonProps_alias_1 }
|
|
17
|
+
|
|
5
18
|
declare type ColorModes = 'light' | 'dark';
|
|
6
19
|
export { ColorModes }
|
|
7
20
|
export { ColorModes as ColorModes_alias_1 }
|
|
@@ -0,0 +1,50 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Button.tsx
|
|
21
|
+
var Button_exports = {};
|
|
22
|
+
__export(Button_exports, {
|
|
23
|
+
Button: () => Button
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Button_exports);
|
|
26
|
+
var import_css = require("@cerberus-design/styled-system/css");
|
|
27
|
+
var import_recipes = require("@cerberus-design/styled-system/recipes");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
function Button(props) {
|
|
30
|
+
const { palette, usage, shape, ...nativeProps } = props;
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
...nativeProps,
|
|
35
|
+
className: (0, import_css.cx)(
|
|
36
|
+
nativeProps.className,
|
|
37
|
+
(0, import_recipes.button)({
|
|
38
|
+
palette,
|
|
39
|
+
usage,
|
|
40
|
+
shape
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
Button
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=Button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus-design/styled-system/css'\nimport { button } from '@cerberus-design/styled-system/recipes'\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n palette?: 'action' | 'danger'\n usage?: 'filled' | 'outline' | 'text'\n shape?: 'sharp' | 'rounded'\n}\n\nexport function Button(props: ButtonProps) {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAmB;AACnB,qBAAuB;AAWnB;AAHG,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,SAAS,OAAO,OAAO,GAAG,YAAY,IAAI;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/components/Button.tsx
|
|
2
|
+
import { cx } from "@cerberus-design/styled-system/css";
|
|
3
|
+
import { button } from "@cerberus-design/styled-system/recipes";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function Button(props) {
|
|
6
|
+
const { palette, usage, shape, ...nativeProps } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"button",
|
|
9
|
+
{
|
|
10
|
+
...nativeProps,
|
|
11
|
+
className: cx(
|
|
12
|
+
nativeProps.className,
|
|
13
|
+
button({
|
|
14
|
+
palette,
|
|
15
|
+
usage,
|
|
16
|
+
shape
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
Button
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus-design/styled-system/css'\nimport { button } from '@cerberus-design/styled-system/recipes'\n\nexport interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n palette?: 'action' | 'danger'\n usage?: 'filled' | 'outline' | 'text'\n shape?: 'sharp' | 'rounded'\n}\n\nexport function Button(props: ButtonProps) {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n"],"mappings":";AACA,SAAS,UAAU;AACnB,SAAS,cAAc;AAWnB;AAHG,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,SAAS,OAAO,OAAO,GAAG,YAAY,IAAI;AAClD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 * @description https://docs.solidjs.com/reference/components/show\n */\nexport function Show(props: PropsWithChildren<ShowProps>) {\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;AAYzD,SAAS,KAAK,OAAqC;AACxD,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":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/Show.tsx
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
function Show(props) {
|
|
6
|
+
const { when, children, fallback } = props;
|
|
7
|
+
const condition = useMemo(() => when ?? false, [when]);
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
if (condition)
|
|
10
|
+
return children;
|
|
11
|
+
return fallback ?? null;
|
|
12
|
+
}, [condition, children, fallback]);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
Show
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=Show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 * @description https://docs.solidjs.com/reference/components/show\n */\nexport function Show(props: PropsWithChildren<ShowProps>) {\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":";;;AAEA,SAAS,eAAuD;AAYzD,SAAS,KAAK,OAAqC;AACxD,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,YAAY,QAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,SAAO,QAAQ,MAAM;AACnB,QAAI;AAAW,aAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 initialThemeState = {
|
|
36
|
+
theme: "cerberus",
|
|
37
|
+
mode: "light",
|
|
38
|
+
updateTheme: () => {
|
|
39
|
+
},
|
|
40
|
+
updateMode: () => {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var ThemeContext = (0, import_react.createContext)(initialThemeState);
|
|
44
|
+
function ThemeProvider(props) {
|
|
45
|
+
const state = (0, import_useTheme.useTheme)();
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: state, children: props.children });
|
|
47
|
+
}
|
|
48
|
+
function useThemeContext() {
|
|
49
|
+
const context = (0, import_react.useContext)(ThemeContext);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
MODE_KEY,
|
|
58
|
+
THEME_KEY,
|
|
59
|
+
ThemeProvider,
|
|
60
|
+
useThemeContext
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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 initialThemeState = {\n theme: 'cerberus' as const,\n mode: 'light' as const,\n updateTheme: () => {},\n updateMode: () => {},\n}\n\nconst ThemeContext =\n createContext<ThemeContextValue<DefaultThemes>>(initialThemeState)\n\nexport function ThemeProvider(props: PropsWithChildren<unknown>) {\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;AA6BrB;AAhBG,IAAM,YAAY;AAClB,IAAM,WAAW;AAExB,IAAM,oBAAoB;AAAA,EACxB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,YAAY,MAAM;AAAA,EAAC;AACrB;AAEA,IAAM,mBACJ,4BAAgD,iBAAiB;AAE5D,SAAS,cAAc,OAAmC;AAC/D,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":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/context/theme.tsx
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
import { useTheme } from "../hooks/useTheme.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var THEME_KEY = "cerberus-theme";
|
|
8
|
+
var MODE_KEY = "cerberus-mode";
|
|
9
|
+
var initialThemeState = {
|
|
10
|
+
theme: "cerberus",
|
|
11
|
+
mode: "light",
|
|
12
|
+
updateTheme: () => {
|
|
13
|
+
},
|
|
14
|
+
updateMode: () => {
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var ThemeContext = createContext(initialThemeState);
|
|
18
|
+
function ThemeProvider(props) {
|
|
19
|
+
const state = useTheme();
|
|
20
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: state, children: props.children });
|
|
21
|
+
}
|
|
22
|
+
function useThemeContext() {
|
|
23
|
+
const context = useContext(ThemeContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useThemeContext must be used within a ThemeProvider");
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
MODE_KEY,
|
|
31
|
+
THEME_KEY,
|
|
32
|
+
ThemeProvider,
|
|
33
|
+
useThemeContext
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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 initialThemeState = {\n theme: 'cerberus' as const,\n mode: 'light' as const,\n updateTheme: () => {},\n updateMode: () => {},\n}\n\nconst ThemeContext =\n createContext<ThemeContextValue<DefaultThemes>>(initialThemeState)\n\nexport function ThemeProvider(props: PropsWithChildren<unknown>) {\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":";;;AAEA,SAAS,eAAe,kBAA0C;AAClE,SAAS,gBAAgB;AA6BrB;AAhBG,IAAM,YAAY;AAClB,IAAM,WAAW;AAExB,IAAM,oBAAoB;AAAA,EACxB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,YAAY,MAAM;AAAA,EAAC;AACrB;AAEA,IAAM,eACJ,cAAgD,iBAAiB;AAE5D,SAAS,cAAc,OAAmC;AAC/D,QAAM,QAAQ,SAAS;AACvB,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAC3B,gBAAM,UACT;AAEJ;AAEO,SAAS,kBAAoD;AAClE,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
package/build/modern/index.cjs
CHANGED
|
@@ -17,11 +17,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var src_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(src_exports);
|
|
20
|
+
__reExport(src_exports, require("./components/Button.cjs"), module.exports);
|
|
20
21
|
__reExport(src_exports, require("./components/Show.cjs"), module.exports);
|
|
21
22
|
__reExport(src_exports, require("./context/theme.cjs"), module.exports);
|
|
22
23
|
__reExport(src_exports, require("./hooks/useTheme.cjs"), module.exports);
|
|
23
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
25
|
0 && (module.exports = {
|
|
26
|
+
...require("./components/Button.cjs"),
|
|
25
27
|
...require("./components/Show.cjs"),
|
|
26
28
|
...require("./context/theme.cjs"),
|
|
27
29
|
...require("./hooks/useTheme.cjs")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,wBAAc,oCAFd;AAGA,wBAAc,kCAHd;AAOA,wBAAc,gCAPd;AAWA,wBAAc,iCAXd;","names":[]}
|
package/build/modern/index.d.cts
CHANGED
package/build/modern/index.d.ts
CHANGED
package/build/modern/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";AAEA,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// components\n\nexport * from './components/Button'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useTheme'\n"],"mappings":";AAEA,cAAc;AACd,cAAc;AAId,cAAc;AAId,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.0.1-next-
|
|
3
|
+
"version": "0.0.1-next-11f55b0",
|
|
4
4
|
"description": "The Cerberus Design React component library",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"module": "build/legacy/index.js",
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@cerberus-design/panda-preset": "*",
|
|
12
|
+
"@cerberus-design/styled-system": "*",
|
|
12
13
|
"@pandacss/dev": "*",
|
|
13
14
|
"react": "*",
|
|
14
15
|
"react-dom": "*"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@microsoft/api-extractor": "^7.43.4",
|
|
18
|
-
"@pandacss/dev": "^0.39.0",
|
|
19
|
-
"@pandacss/types": "^0.39.1",
|
|
20
19
|
"@types/react": "^18",
|
|
21
20
|
"react": "^18",
|
|
22
21
|
"react-dom": "^18",
|
|
23
22
|
"tsup": "^8.0.2",
|
|
24
|
-
"@cerberus-design/configs": "0.0.0"
|
|
23
|
+
"@cerberus-design/configs": "0.0.0",
|
|
24
|
+
"@cerberus-design/styled-system": "0.0.0"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
@@ -62,6 +62,12 @@
|
|
|
62
62
|
"default": "./build/modern/index.cjs"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
+
"./src": {
|
|
66
|
+
"import": {
|
|
67
|
+
"types": "./src/index.d.ts",
|
|
68
|
+
"default": "./src/index.ts"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
65
71
|
"./package.json": "./package.json"
|
|
66
72
|
},
|
|
67
73
|
"typesVersions": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from 'react'
|
|
2
|
+
import { cx } from '@cerberus-design/styled-system/css'
|
|
3
|
+
import { button } from '@cerberus-design/styled-system/recipes'
|
|
4
|
+
|
|
5
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
palette?: 'action' | 'danger'
|
|
7
|
+
usage?: 'filled' | 'outline' | 'text'
|
|
8
|
+
shape?: 'sharp' | 'rounded'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Button(props: ButtonProps) {
|
|
12
|
+
const { palette, usage, shape, ...nativeProps } = props
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
{...nativeProps}
|
|
16
|
+
className={cx(
|
|
17
|
+
nativeProps.className,
|
|
18
|
+
button({
|
|
19
|
+
palette,
|
|
20
|
+
usage,
|
|
21
|
+
shape,
|
|
22
|
+
}),
|
|
23
|
+
)}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|