@clayer/theme 1.0.0

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.
@@ -0,0 +1,56 @@
1
+ // src/tailwind-preset.ts
2
+ var tailwindPreset = {
3
+ content: [],
4
+ theme: {
5
+ extend: {
6
+ colors: {
7
+ background: "hsl(var(--cx-background))",
8
+ foreground: "hsl(var(--cx-foreground))",
9
+ primary: {
10
+ DEFAULT: "hsl(var(--cx-primary))",
11
+ foreground: "hsl(var(--cx-primary-foreground))"
12
+ },
13
+ card: {
14
+ DEFAULT: "hsl(var(--cx-card))",
15
+ foreground: "hsl(var(--cx-card-foreground))"
16
+ },
17
+ border: "hsl(var(--cx-border))",
18
+ input: "hsl(var(--cx-input))",
19
+ ring: "hsl(var(--cx-ring))",
20
+ muted: {
21
+ DEFAULT: "hsl(var(--cx-muted))",
22
+ foreground: "hsl(var(--cx-muted-foreground))"
23
+ },
24
+ success: "hsl(var(--cx-success))",
25
+ warning: "hsl(var(--cx-warning))",
26
+ danger: "hsl(var(--cx-danger))",
27
+ info: "hsl(var(--cx-info))",
28
+ sidebar: {
29
+ DEFAULT: "hsl(var(--cx-sidebar))",
30
+ foreground: "hsl(var(--cx-sidebar-foreground))",
31
+ active: "hsl(var(--cx-sidebar-active))"
32
+ },
33
+ chart: {
34
+ 1: "hsl(var(--cx-chart-1))",
35
+ 2: "hsl(var(--cx-chart-2))",
36
+ 3: "hsl(var(--cx-chart-3))",
37
+ 4: "hsl(var(--cx-chart-4))",
38
+ 5: "hsl(var(--cx-chart-5))"
39
+ }
40
+ },
41
+ borderRadius: {
42
+ sm: "calc(var(--cx-radius) - 4px)",
43
+ md: "calc(var(--cx-radius) - 2px)",
44
+ lg: "var(--cx-radius)",
45
+ xl: "calc(var(--cx-radius) + 4px)"
46
+ }
47
+ }
48
+ }
49
+ };
50
+ var tailwind_preset_default = tailwindPreset;
51
+
52
+ export {
53
+ tailwindPreset,
54
+ tailwind_preset_default
55
+ };
56
+ //# sourceMappingURL=chunk-LNPBYTUA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tailwind-preset.ts"],"sourcesContent":["import type { Config } from \"tailwindcss\";\n\nexport const tailwindPreset = {\n content: [],\n theme: {\n extend: {\n colors: {\n background: \"hsl(var(--cx-background))\",\n foreground: \"hsl(var(--cx-foreground))\",\n primary: {\n DEFAULT: \"hsl(var(--cx-primary))\",\n foreground: \"hsl(var(--cx-primary-foreground))\"\n },\n card: {\n DEFAULT: \"hsl(var(--cx-card))\",\n foreground: \"hsl(var(--cx-card-foreground))\"\n },\n border: \"hsl(var(--cx-border))\",\n input: \"hsl(var(--cx-input))\",\n ring: \"hsl(var(--cx-ring))\",\n muted: {\n DEFAULT: \"hsl(var(--cx-muted))\",\n foreground: \"hsl(var(--cx-muted-foreground))\"\n },\n success: \"hsl(var(--cx-success))\",\n warning: \"hsl(var(--cx-warning))\",\n danger: \"hsl(var(--cx-danger))\",\n info: \"hsl(var(--cx-info))\",\n sidebar: {\n DEFAULT: \"hsl(var(--cx-sidebar))\",\n foreground: \"hsl(var(--cx-sidebar-foreground))\",\n active: \"hsl(var(--cx-sidebar-active))\"\n },\n chart: {\n 1: \"hsl(var(--cx-chart-1))\",\n 2: \"hsl(var(--cx-chart-2))\",\n 3: \"hsl(var(--cx-chart-3))\",\n 4: \"hsl(var(--cx-chart-4))\",\n 5: \"hsl(var(--cx-chart-5))\"\n }\n },\n borderRadius: {\n sm: \"calc(var(--cx-radius) - 4px)\",\n md: \"calc(var(--cx-radius) - 2px)\",\n lg: \"var(--cx-radius)\",\n xl: \"calc(var(--cx-radius) + 4px)\"\n }\n }\n }\n} satisfies Config;\n\nexport default tailwindPreset;\n"],"mappings":";AAEO,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC;AAAA,EACV,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,SAAS;AAAA,UACP,SAAS;AAAA,UACT,YAAY;AAAA,QACd;AAAA,QACA,MAAM;AAAA,UACJ,SAAS;AAAA,UACT,YAAY;AAAA,QACd;AAAA,QACA,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,UACL,SAAS;AAAA,UACT,YAAY;AAAA,QACd;AAAA,QACA,SAAS;AAAA,QACT,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,UACP,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QACV;AAAA,QACA,OAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,QACL;AAAA,MACF;AAAA,MACA,cAAc;AAAA,QACZ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,0BAAQ;","names":[]}
@@ -0,0 +1,42 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ export { default as tailwindPreset } from './tailwind-preset.js';
4
+
5
+ type ThemeSlotStyles = Record<string, string | undefined>;
6
+ type Theme = {
7
+ components: {
8
+ Button: ThemeSlotStyles;
9
+ Card: ThemeSlotStyles;
10
+ Input: ThemeSlotStyles;
11
+ Modal: ThemeSlotStyles;
12
+ };
13
+ advanced: {
14
+ DataTable: ThemeSlotStyles;
15
+ DynamicForm: ThemeSlotStyles;
16
+ Chart: ThemeSlotStyles;
17
+ Graph: ThemeSlotStyles;
18
+ };
19
+ layout: {
20
+ DashboardLayout: ThemeSlotStyles;
21
+ Sidebar: ThemeSlotStyles;
22
+ Topbar: ThemeSlotStyles;
23
+ PageHeader: ThemeSlotStyles;
24
+ };
25
+ };
26
+ type PartialTheme = {
27
+ components?: Partial<Theme["components"]>;
28
+ advanced?: Partial<Theme["advanced"]>;
29
+ layout?: Partial<Theme["layout"]>;
30
+ };
31
+ declare const defaultTheme: Theme;
32
+
33
+ declare function createTheme(theme?: PartialTheme): Theme;
34
+
35
+ type ThemeProviderProps = {
36
+ theme?: PartialTheme;
37
+ children: ReactNode;
38
+ };
39
+ declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
40
+ declare function useTheme(): Theme;
41
+
42
+ export { type PartialTheme, type Theme, ThemeProvider, type ThemeProviderProps, type ThemeSlotStyles, createTheme, defaultTheme, useTheme };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ import {
2
+ tailwindPreset
3
+ } from "./chunk-LNPBYTUA.js";
4
+
5
+ // src/create-theme.ts
6
+ import { deepMerge } from "@clayer/utils";
7
+
8
+ // src/default-theme.ts
9
+ var defaultTheme = {
10
+ components: {
11
+ Button: {},
12
+ Card: {},
13
+ Input: {},
14
+ Modal: {}
15
+ },
16
+ advanced: {
17
+ DataTable: {},
18
+ DynamicForm: {},
19
+ Chart: {},
20
+ Graph: {}
21
+ },
22
+ layout: {
23
+ DashboardLayout: {},
24
+ Sidebar: {},
25
+ Topbar: {},
26
+ PageHeader: {}
27
+ }
28
+ };
29
+
30
+ // src/create-theme.ts
31
+ function createTheme(theme) {
32
+ return deepMerge(defaultTheme, theme);
33
+ }
34
+
35
+ // src/provider.tsx
36
+ import { createContext, useContext, useMemo } from "react";
37
+ import { deepMerge as deepMerge2 } from "@clayer/utils";
38
+ import { jsx } from "react/jsx-runtime";
39
+ var ThemeContext = createContext(defaultTheme);
40
+ function ThemeProvider({ theme, children }) {
41
+ const parentTheme = useContext(ThemeContext);
42
+ const mergedTheme = useMemo(() => {
43
+ return deepMerge2(parentTheme, theme);
44
+ }, [parentTheme, theme]);
45
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: mergedTheme, children });
46
+ }
47
+ function useTheme() {
48
+ return useContext(ThemeContext);
49
+ }
50
+ export {
51
+ ThemeProvider,
52
+ createTheme,
53
+ defaultTheme,
54
+ tailwindPreset,
55
+ useTheme
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/create-theme.ts","../src/default-theme.ts","../src/provider.tsx"],"sourcesContent":["import { deepMerge } from \"@clayer/utils\";\n\nimport { defaultTheme, type PartialTheme, type Theme } from \"./default-theme\";\n\nexport function createTheme(theme?: PartialTheme): Theme {\n return deepMerge(defaultTheme, theme);\n}\n","export type ThemeSlotStyles = Record<string, string | undefined>;\n\nexport type Theme = {\n components: {\n Button: ThemeSlotStyles;\n Card: ThemeSlotStyles;\n Input: ThemeSlotStyles;\n Modal: ThemeSlotStyles;\n };\n advanced: {\n DataTable: ThemeSlotStyles;\n DynamicForm: ThemeSlotStyles;\n Chart: ThemeSlotStyles;\n Graph: ThemeSlotStyles;\n };\n layout: {\n DashboardLayout: ThemeSlotStyles;\n Sidebar: ThemeSlotStyles;\n Topbar: ThemeSlotStyles;\n PageHeader: ThemeSlotStyles;\n };\n};\n\nexport type PartialTheme = {\n components?: Partial<Theme[\"components\"]>;\n advanced?: Partial<Theme[\"advanced\"]>;\n layout?: Partial<Theme[\"layout\"]>;\n};\n\nexport const defaultTheme: Theme = {\n components: {\n Button: {},\n Card: {},\n Input: {},\n Modal: {}\n },\n advanced: {\n DataTable: {},\n DynamicForm: {},\n Chart: {},\n Graph: {}\n },\n layout: {\n DashboardLayout: {},\n Sidebar: {},\n Topbar: {},\n PageHeader: {}\n }\n};\n","import { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport { deepMerge } from \"@clayer/utils\";\n\nimport { defaultTheme, type PartialTheme, type Theme } from \"./default-theme\";\n\nconst ThemeContext = createContext<Theme>(defaultTheme);\n\nexport type ThemeProviderProps = {\n theme?: PartialTheme;\n children: ReactNode;\n};\n\nexport function ThemeProvider({ theme, children }: ThemeProviderProps) {\n const parentTheme = useContext(ThemeContext);\n\n const mergedTheme = useMemo(() => {\n return deepMerge(parentTheme, theme);\n }, [parentTheme, theme]);\n\n return <ThemeContext.Provider value={mergedTheme}>{children}</ThemeContext.Provider>;\n}\n\nexport function useTheme() {\n return useContext(ThemeContext);\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;;;AC6BnB,IAAM,eAAsB;AAAA,EACjC,YAAY;AAAA,IACV,QAAQ,CAAC;AAAA,IACT,MAAM,CAAC;AAAA,IACP,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,WAAW,CAAC;AAAA,IACZ,aAAa,CAAC;AAAA,IACd,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,EACV;AAAA,EACA,QAAQ;AAAA,IACN,iBAAiB,CAAC;AAAA,IAClB,SAAS,CAAC;AAAA,IACV,QAAQ,CAAC;AAAA,IACT,YAAY,CAAC;AAAA,EACf;AACF;;;AD5CO,SAAS,YAAY,OAA6B;AACvD,SAAO,UAAU,cAAc,KAAK;AACtC;;;AENA,SAAS,eAAe,YAAY,eAA+B;AACnE,SAAS,aAAAA,kBAAiB;AAkBjB;AAdT,IAAM,eAAe,cAAqB,YAAY;AAO/C,SAAS,cAAc,EAAE,OAAO,SAAS,GAAuB;AACrE,QAAM,cAAc,WAAW,YAAY;AAE3C,QAAM,cAAc,QAAQ,MAAM;AAChC,WAAOC,WAAU,aAAa,KAAK;AAAA,EACrC,GAAG,CAAC,aAAa,KAAK,CAAC;AAEvB,SAAO,oBAAC,aAAa,UAAb,EAAsB,OAAO,aAAc,UAAS;AAC9D;AAEO,SAAS,WAAW;AACzB,SAAO,WAAW,YAAY;AAChC;","names":["deepMerge","deepMerge"]}
@@ -0,0 +1,61 @@
1
+ :root {
2
+ --cx-background: 0 0% 100%;
3
+ --cx-foreground: 222 47% 11%;
4
+
5
+ --cx-primary: 222 89% 55%;
6
+ --cx-primary-foreground: 0 0% 100%;
7
+
8
+ --cx-card: 0 0% 100%;
9
+ --cx-card-foreground: 222 47% 11%;
10
+
11
+ --cx-border: 214 32% 91%;
12
+ --cx-input: 214 32% 91%;
13
+ --cx-ring: 222 89% 55%;
14
+
15
+ --cx-muted: 210 40% 96%;
16
+ --cx-muted-foreground: 215 16% 47%;
17
+
18
+ --cx-success: 142 72% 29%;
19
+ --cx-warning: 38 92% 50%;
20
+ --cx-danger: 0 84% 60%;
21
+ --cx-info: 199 89% 48%;
22
+
23
+ --cx-sidebar: 222 47% 8%;
24
+ --cx-sidebar-foreground: 210 40% 98%;
25
+ --cx-sidebar-active: 217 91% 60%;
26
+
27
+ --cx-chart-1: 222 89% 55%;
28
+ --cx-chart-2: 160 84% 39%;
29
+ --cx-chart-3: 38 92% 50%;
30
+ --cx-chart-4: 0 84% 60%;
31
+ --cx-chart-5: 262 83% 58%;
32
+
33
+ --cx-radius: 0.75rem;
34
+ }
35
+
36
+ .dark {
37
+ --cx-background: 222 47% 7%;
38
+ --cx-foreground: 210 40% 98%;
39
+
40
+ --cx-primary: 217 91% 60%;
41
+ --cx-primary-foreground: 222 47% 7%;
42
+
43
+ --cx-card: 222 47% 10%;
44
+ --cx-card-foreground: 210 40% 98%;
45
+
46
+ --cx-border: 217 33% 18%;
47
+ --cx-input: 217 33% 18%;
48
+ --cx-ring: 217 91% 60%;
49
+
50
+ --cx-muted: 217 33% 16%;
51
+ --cx-muted-foreground: 215 20% 70%;
52
+
53
+ --cx-success: 142 70% 45%;
54
+ --cx-warning: 38 92% 58%;
55
+ --cx-danger: 0 84% 66%;
56
+ --cx-info: 199 89% 58%;
57
+
58
+ --cx-sidebar: 222 47% 5%;
59
+ --cx-sidebar-foreground: 210 40% 98%;
60
+ --cx-sidebar-active: 217 91% 60%;
61
+ }
@@ -0,0 +1,50 @@
1
+ declare const tailwindPreset: {
2
+ content: never[];
3
+ theme: {
4
+ extend: {
5
+ colors: {
6
+ background: string;
7
+ foreground: string;
8
+ primary: {
9
+ DEFAULT: string;
10
+ foreground: string;
11
+ };
12
+ card: {
13
+ DEFAULT: string;
14
+ foreground: string;
15
+ };
16
+ border: string;
17
+ input: string;
18
+ ring: string;
19
+ muted: {
20
+ DEFAULT: string;
21
+ foreground: string;
22
+ };
23
+ success: string;
24
+ warning: string;
25
+ danger: string;
26
+ info: string;
27
+ sidebar: {
28
+ DEFAULT: string;
29
+ foreground: string;
30
+ active: string;
31
+ };
32
+ chart: {
33
+ 1: string;
34
+ 2: string;
35
+ 3: string;
36
+ 4: string;
37
+ 5: string;
38
+ };
39
+ };
40
+ borderRadius: {
41
+ sm: string;
42
+ md: string;
43
+ lg: string;
44
+ xl: string;
45
+ };
46
+ };
47
+ };
48
+ };
49
+
50
+ export { tailwindPreset as default, tailwindPreset };
@@ -0,0 +1,9 @@
1
+ import {
2
+ tailwindPreset,
3
+ tailwind_preset_default
4
+ } from "./chunk-LNPBYTUA.js";
5
+ export {
6
+ tailwind_preset_default as default,
7
+ tailwindPreset
8
+ };
9
+ //# sourceMappingURL=tailwind-preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@clayer/theme",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./tailwind-preset": {
15
+ "types": "./dist/tailwind-preset.d.ts",
16
+ "import": "./dist/tailwind-preset.js",
17
+ "default": "./dist/tailwind-preset.js"
18
+ },
19
+ "./styles.css": "./dist/styles.css"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "dependencies": {
28
+ "@clayer/utils": "1.0.0"
29
+ },
30
+ "peerDependencies": {
31
+ "react": ">=18",
32
+ "react-dom": ">=18",
33
+ "tailwindcss": ">=3"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^18.3.12",
37
+ "typescript": "^5.6.3",
38
+ "tsup": "^8.3.5"
39
+ },
40
+ "scripts": {
41
+ "dev": "tsup --watch",
42
+ "build": "tsup",
43
+ "typecheck": "tsc --noEmit",
44
+ "lint": "eslint src --ext .ts,.tsx",
45
+ "clean": "rm -rf dist"
46
+ }
47
+ }