klip-components 0.2.1 → 0.3.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.
- package/dist/index.d.ts +359 -7
- package/dist/klip-components.cjs.js +1 -37
- package/dist/klip-components.css +1 -1
- package/dist/klip-components.es.js +283 -318
- package/dist/klip-components.umd.js +1 -0
- package/package.json +4 -4
- package/dist/components/Button/Button.d.ts +0 -60
- package/dist/components/Button/Button.d.ts.map +0 -1
- package/dist/components/Button/index.d.ts +0 -3
- package/dist/components/Button/index.d.ts.map +0 -1
- package/dist/components/Debug/Debug.d.ts +0 -8
- package/dist/components/Debug/Debug.d.ts.map +0 -1
- package/dist/components/Debug/index.d.ts +0 -2
- package/dist/components/Debug/index.d.ts.map +0 -1
- package/dist/components/SimpleButton/SimpleButton.d.ts +0 -11
- package/dist/components/SimpleButton/SimpleButton.d.ts.map +0 -1
- package/dist/components/SimpleButton/index.d.ts +0 -2
- package/dist/components/SimpleButton/index.d.ts.map +0 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +0 -9
- package/dist/components/ThemeToggle/ThemeToggle.d.ts.map +0 -1
- package/dist/components/ThemeToggle/index.d.ts +0 -3
- package/dist/components/ThemeToggle/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/theme/ThemeProvider.d.ts +0 -37
- package/dist/theme/ThemeProvider.d.ts.map +0 -1
- package/dist/theme/context.d.ts +0 -17
- package/dist/theme/context.d.ts.map +0 -1
- package/dist/theme/cssGenerator.d.ts +0 -14
- package/dist/theme/cssGenerator.d.ts.map +0 -1
- package/dist/theme/defaultThemes.d.ts +0 -11
- package/dist/theme/defaultThemes.d.ts.map +0 -1
- package/dist/theme/hooks.d.ts +0 -68
- package/dist/theme/hooks.d.ts.map +0 -1
- package/dist/theme/index.d.ts +0 -9
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/utils.d.ts +0 -23
- package/dist/theme/utils.d.ts.map +0 -1
- package/dist/types/theme.d.ts +0 -78
- package/dist/types/theme.d.ts.map +0 -1
- package/dist/utils/cn.d.ts +0 -37
- package/dist/utils/cn.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
|
@@ -1,391 +1,356 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { createContext, useContext, useState, useCallback, useEffect, useLayoutEffect } from "react";
|
|
34
|
+
function r(e) {
|
|
35
|
+
var t, f, n = "";
|
|
36
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
37
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
38
|
+
var o = e.length;
|
|
39
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
40
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
41
|
+
return n;
|
|
11
42
|
}
|
|
12
|
-
function
|
|
13
|
-
for (var
|
|
14
|
-
return
|
|
43
|
+
function clsx() {
|
|
44
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
45
|
+
return n;
|
|
15
46
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return [...new Set(
|
|
47
|
+
function mergeClasses(...classes) {
|
|
48
|
+
const allClasses = classes.join(" ").split(" ").filter(Boolean);
|
|
49
|
+
return [...new Set(allClasses)].join(" ");
|
|
19
50
|
}
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
return
|
|
51
|
+
function cn(...inputs) {
|
|
52
|
+
const joinedClasses = clsx(...inputs);
|
|
53
|
+
return mergeClasses(joinedClasses);
|
|
23
54
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"button",
|
|
33
|
-
{
|
|
34
|
-
className: $("btn", `btn-${r}`, o !== "md" && `btn-${o}`, e && "btn-block", s),
|
|
35
|
-
...i,
|
|
36
|
-
children: a
|
|
37
|
-
}
|
|
38
|
-
), w = j(void 0);
|
|
39
|
-
function S() {
|
|
40
|
-
const r = B(w);
|
|
41
|
-
if (r === void 0)
|
|
55
|
+
const Button = (_a) => {
|
|
56
|
+
var _b = _a, { variant = "primary", className = "", children } = _b, props = __objRest(_b, ["variant", "className", "children"]);
|
|
57
|
+
return /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({ className: cn("rounded btn", `btn-${variant}`, className) }, props), { children }));
|
|
58
|
+
};
|
|
59
|
+
const ThemeContext = createContext(void 0);
|
|
60
|
+
function useTheme() {
|
|
61
|
+
const context = useContext(ThemeContext);
|
|
62
|
+
if (context === void 0) {
|
|
42
63
|
throw new Error("useTheme must be used within a ThemeProvider");
|
|
43
|
-
|
|
64
|
+
}
|
|
65
|
+
return context;
|
|
44
66
|
}
|
|
45
|
-
function
|
|
46
|
-
const { theme
|
|
67
|
+
function useThemeVariables() {
|
|
68
|
+
const { theme } = useTheme();
|
|
47
69
|
return {
|
|
48
70
|
// Colors
|
|
49
|
-
primaryColor: `var(--primary-color, ${
|
|
50
|
-
primaryHover: `var(--primary-hover, ${
|
|
51
|
-
secondaryColor: `var(--secondary-color, ${
|
|
52
|
-
secondaryHover: `var(--secondary-hover, ${
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
primaryColor: `var(--primary-color, ${theme.colors.primary.main})`,
|
|
72
|
+
primaryHover: `var(--primary-hover, ${theme.colors.primary.hover})`,
|
|
73
|
+
secondaryColor: `var(--secondary-color, ${theme.colors.secondary.main})`,
|
|
74
|
+
secondaryHover: `var(--secondary-hover, ${theme.colors.secondary.hover})`,
|
|
75
|
+
successColor: `var(--success-color, ${theme.colors.semantic.success})`,
|
|
76
|
+
dangerColor: `var(--danger-color, ${theme.colors.semantic.danger})`,
|
|
77
|
+
warningColor: `var(--warning-color, ${theme.colors.semantic.warning})`,
|
|
78
|
+
infoColor: `var(--info-color, ${theme.colors.semantic.info})`,
|
|
79
|
+
lightColor: `var(--light-color, ${theme.colors.semantic.light})`,
|
|
80
|
+
darkColor: `var(--dark-color, ${theme.colors.semantic.dark})`,
|
|
81
|
+
linkColor: `var(--link-color, ${theme.colors.semantic.link})`,
|
|
59
82
|
// Spacing
|
|
60
|
-
spacingXs: `var(--spacing-xs, ${
|
|
61
|
-
spacingSm: `var(--spacing-sm, ${
|
|
62
|
-
spacingMd: `var(--spacing-md, ${
|
|
63
|
-
spacingLg: `var(--spacing-lg, ${
|
|
64
|
-
spacingXl: `var(--spacing-xl, ${
|
|
83
|
+
spacingXs: `var(--spacing-xs, ${theme.spacing.xs})`,
|
|
84
|
+
spacingSm: `var(--spacing-sm, ${theme.spacing.sm})`,
|
|
85
|
+
spacingMd: `var(--spacing-md, ${theme.spacing.md})`,
|
|
86
|
+
spacingLg: `var(--spacing-lg, ${theme.spacing.lg})`,
|
|
87
|
+
spacingXl: `var(--spacing-xl, ${theme.spacing.xl})`,
|
|
65
88
|
// Border radius
|
|
66
|
-
borderRadiusSm: `var(--border-radius-sm, ${
|
|
67
|
-
borderRadius: `var(--border-radius, ${
|
|
68
|
-
borderRadiusLg: `var(--border-radius-lg, ${
|
|
89
|
+
borderRadiusSm: `var(--border-radius-sm, ${theme.borderRadius.sm})`,
|
|
90
|
+
borderRadius: `var(--border-radius, ${theme.borderRadius.base})`,
|
|
91
|
+
borderRadiusLg: `var(--border-radius-lg, ${theme.borderRadius.lg})`,
|
|
92
|
+
borderRadiusFull: `var(--border-radius-full, ${theme.borderRadius.full})`,
|
|
69
93
|
// Typography
|
|
70
|
-
fontFamily: `var(--font-family, ${
|
|
71
|
-
fontSizeSm: `var(--font-size-sm, ${
|
|
72
|
-
fontSizeBase: `var(--font-size-base, ${
|
|
73
|
-
fontSizeLg: `var(--font-size-lg, ${
|
|
94
|
+
fontFamily: `var(--font-family, ${theme.typography.fontFamily})`,
|
|
95
|
+
fontSizeSm: `var(--font-size-sm, ${theme.typography.fontSize.sm})`,
|
|
96
|
+
fontSizeBase: `var(--font-size-base, ${theme.typography.fontSize.base})`,
|
|
97
|
+
fontSizeLg: `var(--font-size-lg, ${theme.typography.fontSize.lg})`,
|
|
74
98
|
// Shadows
|
|
75
|
-
shadowSm: `var(--shadow-sm, ${
|
|
76
|
-
shadowMd: `var(--shadow-md, ${
|
|
77
|
-
shadowLg: `var(--shadow-lg, ${
|
|
99
|
+
shadowSm: `var(--shadow-sm, ${theme.shadows.sm})`,
|
|
100
|
+
shadowMd: `var(--shadow-md, ${theme.shadows.md})`,
|
|
101
|
+
shadowLg: `var(--shadow-lg, ${theme.shadows.lg})`
|
|
78
102
|
};
|
|
79
103
|
}
|
|
80
|
-
function
|
|
81
|
-
const { mode
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
function ThemeToggle({ className }) {
|
|
105
|
+
const { mode, setMode, isDark } = useTheme();
|
|
106
|
+
const handleToggle = () => {
|
|
107
|
+
if (mode === "auto") {
|
|
108
|
+
setMode("light");
|
|
109
|
+
} else if (mode === "light") {
|
|
110
|
+
setMode("dark");
|
|
111
|
+
} else {
|
|
112
|
+
setMode("auto");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const getButtonText = () => {
|
|
116
|
+
switch (mode) {
|
|
85
117
|
case "light":
|
|
86
118
|
return "☀️ Light";
|
|
87
119
|
case "dark":
|
|
88
120
|
return "🌙 Dark";
|
|
89
121
|
case "auto":
|
|
90
|
-
return `🔄 Auto (${
|
|
122
|
+
return `🔄 Auto (${isDark ? "Dark" : "Light"})`;
|
|
91
123
|
default:
|
|
92
124
|
return "Theme";
|
|
93
125
|
}
|
|
94
126
|
};
|
|
95
|
-
return /* @__PURE__ */
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
96
128
|
"button",
|
|
97
129
|
{
|
|
98
|
-
onClick:
|
|
99
|
-
className:
|
|
130
|
+
onClick: handleToggle,
|
|
131
|
+
className: cn(
|
|
100
132
|
"px-3 py-2 rounded-md text-sm font-medium transition-colors",
|
|
101
133
|
"bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600",
|
|
102
134
|
"text-gray-900 dark:text-gray-100",
|
|
103
|
-
|
|
135
|
+
className
|
|
104
136
|
),
|
|
105
|
-
title: `Current theme: ${
|
|
106
|
-
children:
|
|
137
|
+
title: `Current theme: ${mode}${mode === "auto" ? ` (${isDark ? "dark" : "light"})` : ""}`,
|
|
138
|
+
children: getButtonText()
|
|
107
139
|
}
|
|
108
140
|
);
|
|
109
141
|
}
|
|
110
|
-
|
|
111
|
-
return console.log("React version:", l.version), console.log("React object:", l), /* @__PURE__ */ m("div", { className: r, children: [
|
|
112
|
-
/* @__PURE__ */ m("p", { children: [
|
|
113
|
-
"React Version: ",
|
|
114
|
-
l.version
|
|
115
|
-
] }),
|
|
116
|
-
/* @__PURE__ */ m("p", { children: [
|
|
117
|
-
"React loaded: ",
|
|
118
|
-
l ? "Yes" : "No"
|
|
119
|
-
] })
|
|
120
|
-
] });
|
|
121
|
-
}
|
|
122
|
-
function q({ children: r, onClick: o, className: e }) {
|
|
123
|
-
return /* @__PURE__ */ d(
|
|
124
|
-
"button",
|
|
125
|
-
{
|
|
126
|
-
onClick: o,
|
|
127
|
-
className: e,
|
|
128
|
-
style: {
|
|
129
|
-
padding: "8px 16px",
|
|
130
|
-
backgroundColor: "#007bff",
|
|
131
|
-
color: "white",
|
|
132
|
-
border: "none",
|
|
133
|
-
borderRadius: "4px"
|
|
134
|
-
},
|
|
135
|
-
children: r
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
const b = {
|
|
142
|
+
const defaultTheme = {
|
|
140
143
|
colors: {
|
|
141
|
-
primary: {
|
|
142
|
-
|
|
143
|
-
hover: "#033e52"
|
|
144
|
-
},
|
|
145
|
-
secondary: {
|
|
146
|
-
main: "#189ab4",
|
|
147
|
-
hover: "#0f7a9c"
|
|
148
|
-
},
|
|
149
|
-
tertiary: {
|
|
150
|
-
main: "#75e6da",
|
|
151
|
-
hover: "#5cc6c0"
|
|
152
|
-
},
|
|
144
|
+
primary: { main: "#2d99ff", hover: "#2682d9" },
|
|
145
|
+
secondary: { main: "#f5f7fa", hover: "#e3e5e8" },
|
|
153
146
|
semantic: {
|
|
154
147
|
success: "#18a558",
|
|
155
148
|
danger: "#db1f48",
|
|
156
149
|
warning: "#e9b210",
|
|
157
|
-
info: "#
|
|
150
|
+
info: "#75e6da",
|
|
151
|
+
light: "#ffffff",
|
|
152
|
+
dark: "#1a1926",
|
|
153
|
+
link: "#2d99ff"
|
|
158
154
|
}
|
|
159
155
|
},
|
|
160
|
-
spacing: {
|
|
161
|
-
|
|
162
|
-
sm: "0.5rem",
|
|
163
|
-
md: "1rem",
|
|
164
|
-
lg: "1.5rem",
|
|
165
|
-
xl: "2rem"
|
|
166
|
-
},
|
|
167
|
-
borderRadius: {
|
|
168
|
-
sm: "4px",
|
|
169
|
-
base: "8px",
|
|
170
|
-
lg: "12px"
|
|
171
|
-
},
|
|
156
|
+
spacing: { xs: "0.25rem", sm: "0.5rem", md: "1rem", lg: "1.5rem", xl: "2rem" },
|
|
157
|
+
borderRadius: { sm: "4px", base: "12px", lg: "20px", full: "50%" },
|
|
172
158
|
typography: {
|
|
173
|
-
fontFamily:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
base: "1rem",
|
|
177
|
-
lg: "1.125rem"
|
|
178
|
-
}
|
|
159
|
+
fontFamily: `Nunito, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
160
|
+
Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`,
|
|
161
|
+
fontSize: { sm: "0.875rem", base: "1rem", lg: "1.125rem" }
|
|
179
162
|
},
|
|
180
163
|
shadows: {
|
|
181
164
|
sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
|
|
182
165
|
md: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
|
|
183
166
|
lg: "0 10px 15px -3px rgb(0 0 0 / 0.1)"
|
|
184
167
|
}
|
|
185
|
-
}
|
|
168
|
+
};
|
|
169
|
+
const defaultDarkTheme = {
|
|
186
170
|
colors: {
|
|
187
|
-
primary: {
|
|
188
|
-
|
|
189
|
-
hover: "#0ea5e9"
|
|
190
|
-
},
|
|
191
|
-
secondary: {
|
|
192
|
-
main: "#34d399",
|
|
193
|
-
hover: "#10b981"
|
|
194
|
-
},
|
|
195
|
-
tertiary: {
|
|
196
|
-
main: "#fbbf24",
|
|
197
|
-
hover: "#f59e0b"
|
|
198
|
-
},
|
|
171
|
+
primary: { main: "#2d99ff", hover: "#2682d9" },
|
|
172
|
+
secondary: { main: "#f5f7fa", hover: "#e3e5e8" },
|
|
199
173
|
semantic: {
|
|
200
|
-
success: "#
|
|
201
|
-
danger: "#
|
|
202
|
-
warning: "#
|
|
203
|
-
info: "#
|
|
174
|
+
success: "#18a558",
|
|
175
|
+
danger: "#db1f48",
|
|
176
|
+
warning: "#e9b210",
|
|
177
|
+
info: "#75e6da",
|
|
178
|
+
light: "#ffffff",
|
|
179
|
+
dark: "#1a1926",
|
|
180
|
+
link: "#2d99ff"
|
|
204
181
|
}
|
|
205
182
|
},
|
|
206
|
-
spacing: {
|
|
207
|
-
|
|
208
|
-
sm: "0.5rem",
|
|
209
|
-
md: "1rem",
|
|
210
|
-
lg: "1.5rem",
|
|
211
|
-
xl: "2rem"
|
|
212
|
-
},
|
|
213
|
-
borderRadius: {
|
|
214
|
-
sm: "4px",
|
|
215
|
-
base: "8px",
|
|
216
|
-
lg: "12px"
|
|
217
|
-
},
|
|
183
|
+
spacing: { xs: "0.25rem", sm: "0.5rem", md: "1rem", lg: "1.5rem", xl: "2rem" },
|
|
184
|
+
borderRadius: { sm: "4px", base: "12px", lg: "20px", full: "50%" },
|
|
218
185
|
typography: {
|
|
219
|
-
fontFamily:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
base: "1rem",
|
|
223
|
-
lg: "1.125rem"
|
|
224
|
-
}
|
|
186
|
+
fontFamily: `Nunito, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
187
|
+
Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`,
|
|
188
|
+
fontSize: { sm: "0.875rem", base: "1rem", lg: "1.125rem" }
|
|
225
189
|
},
|
|
226
190
|
shadows: {
|
|
227
|
-
sm: "0 1px 2px 0 rgb(0 0 0 / 0.
|
|
228
|
-
md: "0 4px 6px -1px rgb(0 0 0 / 0.
|
|
229
|
-
lg: "0 10px 15px -3px rgb(0 0 0 / 0.
|
|
191
|
+
sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
|
|
192
|
+
md: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
|
|
193
|
+
lg: "0 10px 15px -3px rgb(0 0 0 / 0.1)"
|
|
230
194
|
}
|
|
231
195
|
};
|
|
232
|
-
function
|
|
196
|
+
function mergeTheme(baseTheme, override) {
|
|
197
|
+
var _a, _b, _c, _d;
|
|
233
198
|
return {
|
|
234
199
|
colors: {
|
|
235
|
-
primary: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
secondary: {
|
|
240
|
-
...r.colors.secondary,
|
|
241
|
-
...o.colors?.secondary
|
|
242
|
-
},
|
|
243
|
-
tertiary: {
|
|
244
|
-
...r.colors.tertiary,
|
|
245
|
-
...o.colors?.tertiary
|
|
246
|
-
},
|
|
247
|
-
semantic: {
|
|
248
|
-
...r.colors.semantic,
|
|
249
|
-
...o.colors?.semantic
|
|
250
|
-
}
|
|
200
|
+
primary: __spreadValues(__spreadValues({}, baseTheme.colors.primary), (_a = override.colors) == null ? void 0 : _a.primary),
|
|
201
|
+
secondary: __spreadValues(__spreadValues({}, baseTheme.colors.secondary), (_b = override.colors) == null ? void 0 : _b.secondary),
|
|
202
|
+
semantic: __spreadValues(__spreadValues({}, baseTheme.colors.semantic), (_c = override.colors) == null ? void 0 : _c.semantic)
|
|
251
203
|
},
|
|
252
|
-
spacing: {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
...o.borderRadius
|
|
259
|
-
},
|
|
260
|
-
typography: {
|
|
261
|
-
...r.typography,
|
|
262
|
-
...o.typography,
|
|
263
|
-
fontSize: {
|
|
264
|
-
...r.typography.fontSize,
|
|
265
|
-
...o.typography?.fontSize
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
shadows: {
|
|
269
|
-
...r.shadows,
|
|
270
|
-
...o.shadows
|
|
271
|
-
}
|
|
204
|
+
spacing: __spreadValues(__spreadValues({}, baseTheme.spacing), override.spacing),
|
|
205
|
+
borderRadius: __spreadValues(__spreadValues({}, baseTheme.borderRadius), override.borderRadius),
|
|
206
|
+
typography: __spreadProps(__spreadValues(__spreadValues({}, baseTheme.typography), override.typography), {
|
|
207
|
+
fontSize: __spreadValues(__spreadValues({}, baseTheme.typography.fontSize), (_d = override.typography) == null ? void 0 : _d.fontSize)
|
|
208
|
+
}),
|
|
209
|
+
shadows: __spreadValues(__spreadValues({}, baseTheme.shadows), override.shadows)
|
|
272
210
|
};
|
|
273
211
|
}
|
|
274
|
-
function
|
|
275
|
-
|
|
212
|
+
function applyThemeToDOM(theme, target = document.documentElement) {
|
|
213
|
+
target.style.setProperty("--primary-color", theme.colors.primary.main);
|
|
214
|
+
target.style.setProperty("--primary-hover", theme.colors.primary.hover);
|
|
215
|
+
target.style.setProperty("--secondary-color", theme.colors.secondary.main);
|
|
216
|
+
target.style.setProperty("--secondary-hover", theme.colors.secondary.hover);
|
|
217
|
+
target.style.setProperty("--success-color", theme.colors.semantic.success);
|
|
218
|
+
target.style.setProperty("--danger-color", theme.colors.semantic.danger);
|
|
219
|
+
target.style.setProperty("--warning-color", theme.colors.semantic.warning);
|
|
220
|
+
target.style.setProperty("--info-color", theme.colors.semantic.info);
|
|
221
|
+
target.style.setProperty("--spacing-xs", theme.spacing.xs);
|
|
222
|
+
target.style.setProperty("--spacing-sm", theme.spacing.sm);
|
|
223
|
+
target.style.setProperty("--spacing-md", theme.spacing.md);
|
|
224
|
+
target.style.setProperty("--spacing-lg", theme.spacing.lg);
|
|
225
|
+
target.style.setProperty("--spacing-xl", theme.spacing.xl);
|
|
226
|
+
target.style.setProperty("--border-radius-sm", theme.borderRadius.sm);
|
|
227
|
+
target.style.setProperty("--border-radius", theme.borderRadius.base);
|
|
228
|
+
target.style.setProperty("--border-radius-lg", theme.borderRadius.lg);
|
|
229
|
+
target.style.setProperty("--font-family", theme.typography.fontFamily);
|
|
230
|
+
target.style.setProperty("--font-size-sm", theme.typography.fontSize.sm);
|
|
231
|
+
target.style.setProperty("--font-size-base", theme.typography.fontSize.base);
|
|
232
|
+
target.style.setProperty("--font-size-lg", theme.typography.fontSize.lg);
|
|
233
|
+
target.style.setProperty("--shadow-sm", theme.shadows.sm);
|
|
234
|
+
target.style.setProperty("--shadow-md", theme.shadows.md);
|
|
235
|
+
target.style.setProperty("--shadow-lg", theme.shadows.lg);
|
|
276
236
|
}
|
|
277
|
-
function
|
|
278
|
-
const
|
|
279
|
-
let
|
|
280
|
-
for (const
|
|
281
|
-
if (typeof
|
|
282
|
-
return;
|
|
283
|
-
|
|
237
|
+
function getThemeValue(theme, path) {
|
|
238
|
+
const pathArray = path.split(".");
|
|
239
|
+
let current = theme;
|
|
240
|
+
for (const key of pathArray) {
|
|
241
|
+
if (typeof current !== "object" || current === null || !(key in current)) {
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
current = current[key];
|
|
284
245
|
}
|
|
285
|
-
return typeof
|
|
246
|
+
return typeof current === "string" ? current : void 0;
|
|
286
247
|
}
|
|
287
|
-
function
|
|
288
|
-
return `--${
|
|
248
|
+
function createCSSVariable(path) {
|
|
249
|
+
return `--${path.replace(/\./g, "-")}`;
|
|
289
250
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
251
|
+
function detectColorScheme() {
|
|
252
|
+
if (typeof window === "undefined") {
|
|
253
|
+
return "light";
|
|
254
|
+
}
|
|
255
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
292
256
|
}
|
|
293
|
-
function
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
/* Shadows */
|
|
327
|
-
--shadow-sm: ${r.shadows.sm};
|
|
328
|
-
--shadow-md: ${r.shadows.md};
|
|
329
|
-
--shadow-lg: ${r.shadows.lg};
|
|
330
|
-
}`;
|
|
257
|
+
function generateThemeCSS(theme, selector = ":root") {
|
|
258
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na;
|
|
259
|
+
const vars = [
|
|
260
|
+
`--color-primary:${(_c = (_b = (_a = theme.colors) == null ? void 0 : _a.primary) == null ? void 0 : _b.main) != null ? _c : ""}`,
|
|
261
|
+
`--hover-primary:${(_f = (_e = (_d = theme.colors) == null ? void 0 : _d.primary) == null ? void 0 : _e.hover) != null ? _f : ""}`,
|
|
262
|
+
`--color-secondary:${(_i = (_h = (_g = theme.colors) == null ? void 0 : _g.secondary) == null ? void 0 : _h.main) != null ? _i : ""}`,
|
|
263
|
+
`--hover-secondary:${(_l = (_k = (_j = theme.colors) == null ? void 0 : _j.secondary) == null ? void 0 : _k.hover) != null ? _l : ""}`,
|
|
264
|
+
`--color-success:${(_o = (_n = (_m = theme.colors) == null ? void 0 : _m.semantic) == null ? void 0 : _n.success) != null ? _o : ""}`,
|
|
265
|
+
`--color-danger:${(_r = (_q = (_p = theme.colors) == null ? void 0 : _p.semantic) == null ? void 0 : _q.danger) != null ? _r : ""}`,
|
|
266
|
+
`--color-warning:${(_u = (_t = (_s = theme.colors) == null ? void 0 : _s.semantic) == null ? void 0 : _t.warning) != null ? _u : ""}`,
|
|
267
|
+
`--color-info:${(_x = (_w = (_v = theme.colors) == null ? void 0 : _v.semantic) == null ? void 0 : _w.info) != null ? _x : ""}`,
|
|
268
|
+
`--color-light:${(_A = (_z = (_y = theme.colors) == null ? void 0 : _y.semantic) == null ? void 0 : _z.light) != null ? _A : ""}`,
|
|
269
|
+
`--color-dark:${(_D = (_C = (_B = theme.colors) == null ? void 0 : _B.semantic) == null ? void 0 : _C.dark) != null ? _D : ""}`,
|
|
270
|
+
`--color-link:${(_G = (_F = (_E = theme.colors) == null ? void 0 : _E.semantic) == null ? void 0 : _F.link) != null ? _G : ""}`,
|
|
271
|
+
`--rounded:${(_I = (_H = theme.borderRadius) == null ? void 0 : _H.base) != null ? _I : ""}`,
|
|
272
|
+
`--rounded-sm:${(_K = (_J = theme.borderRadius) == null ? void 0 : _J.sm) != null ? _K : ""}`,
|
|
273
|
+
`--rounded-lg:${(_M = (_L = theme.borderRadius) == null ? void 0 : _L.lg) != null ? _M : ""}`,
|
|
274
|
+
`--rounded-full:${(_O = (_N = theme.borderRadius) == null ? void 0 : _N.full) != null ? _O : ""}`,
|
|
275
|
+
`--font-family:${(_Q = (_P = theme.typography) == null ? void 0 : _P.fontFamily) != null ? _Q : ""}`,
|
|
276
|
+
`--font-sm:${(_T = (_S = (_R = theme.typography) == null ? void 0 : _R.fontSize) == null ? void 0 : _S.sm) != null ? _T : ""}`,
|
|
277
|
+
`--font-base:${(_W = (_V = (_U = theme.typography) == null ? void 0 : _U.fontSize) == null ? void 0 : _V.base) != null ? _W : ""}`,
|
|
278
|
+
`--font-lg:${(_Z = (_Y = (_X = theme.typography) == null ? void 0 : _X.fontSize) == null ? void 0 : _Y.lg) != null ? _Z : ""}`,
|
|
279
|
+
`--spacing-xs:${(_$ = (__ = theme.spacing) == null ? void 0 : __.xs) != null ? _$ : ""}`,
|
|
280
|
+
`--spacing-sm:${(_ba = (_aa = theme.spacing) == null ? void 0 : _aa.sm) != null ? _ba : ""}`,
|
|
281
|
+
`--spacing-md:${(_da = (_ca = theme.spacing) == null ? void 0 : _ca.md) != null ? _da : ""}`,
|
|
282
|
+
`--spacing-lg:${(_fa = (_ea = theme.spacing) == null ? void 0 : _ea.lg) != null ? _fa : ""}`,
|
|
283
|
+
`--spacing-xl:${(_ha = (_ga = theme.spacing) == null ? void 0 : _ga.xl) != null ? _ha : ""}`,
|
|
284
|
+
`--shadow-sm:${(_ja = (_ia = theme.shadows) == null ? void 0 : _ia.sm) != null ? _ja : ""}`,
|
|
285
|
+
`--shadow-md:${(_la = (_ka = theme.shadows) == null ? void 0 : _ka.md) != null ? _la : ""}`,
|
|
286
|
+
`--shadow-lg:${(_na = (_ma = theme.shadows) == null ? void 0 : _ma.lg) != null ? _na : ""}`
|
|
287
|
+
];
|
|
288
|
+
return `${selector}{${vars.join(";")}}`;
|
|
331
289
|
}
|
|
332
|
-
function
|
|
333
|
-
children
|
|
334
|
-
defaultMode
|
|
335
|
-
theme
|
|
336
|
-
darkTheme
|
|
290
|
+
function ThemeProvider({
|
|
291
|
+
children,
|
|
292
|
+
defaultMode = "auto",
|
|
293
|
+
theme,
|
|
294
|
+
darkTheme = defaultDarkTheme
|
|
337
295
|
}) {
|
|
338
|
-
const [
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
296
|
+
const [mode, setModeState] = useState(defaultMode);
|
|
297
|
+
const [themeOverride, setThemeOverride] = useState(theme || {});
|
|
298
|
+
const [systemDark, setSystemDark] = useState(() => detectColorScheme() === "dark");
|
|
299
|
+
const isDark = mode === "dark" || mode === "auto" && systemDark;
|
|
300
|
+
const baseTheme = isDark ? darkTheme : defaultTheme;
|
|
301
|
+
const mergedTheme = mergeTheme(baseTheme, themeOverride);
|
|
302
|
+
const setMode = useCallback((newMode) => {
|
|
303
|
+
setModeState(newMode);
|
|
344
304
|
}, []);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
305
|
+
const updateTheme = useCallback((override) => {
|
|
306
|
+
setThemeOverride((prev) => mergeTheme(__spreadValues(__spreadValues({}, defaultTheme), prev), override));
|
|
307
|
+
}, []);
|
|
308
|
+
const resetTheme = useCallback(() => {
|
|
309
|
+
setThemeOverride({});
|
|
310
|
+
}, []);
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
if (typeof window === "undefined") return;
|
|
313
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
314
|
+
const handleChange = (e) => {
|
|
315
|
+
setSystemDark(e.matches);
|
|
349
316
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}, [
|
|
362
|
-
const
|
|
363
|
-
theme:
|
|
364
|
-
mode
|
|
365
|
-
setMode
|
|
366
|
-
updateTheme
|
|
367
|
-
resetTheme
|
|
368
|
-
isDark
|
|
317
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
318
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
319
|
+
}, []);
|
|
320
|
+
useLayoutEffect(() => {
|
|
321
|
+
const css = generateThemeCSS(mergedTheme);
|
|
322
|
+
const existingStyle = document.getElementById("klip-custom-theme");
|
|
323
|
+
if (existingStyle) existingStyle.remove();
|
|
324
|
+
const style = document.createElement("style");
|
|
325
|
+
style.id = "klip-custom-theme";
|
|
326
|
+
style.textContent = css;
|
|
327
|
+
document.head.appendChild(style);
|
|
328
|
+
}, [mergedTheme]);
|
|
329
|
+
const contextValue = {
|
|
330
|
+
theme: mergedTheme,
|
|
331
|
+
mode,
|
|
332
|
+
setMode,
|
|
333
|
+
updateTheme,
|
|
334
|
+
resetTheme,
|
|
335
|
+
isDark
|
|
369
336
|
};
|
|
370
|
-
return /* @__PURE__ */
|
|
337
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children });
|
|
371
338
|
}
|
|
372
339
|
export {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
S as useTheme,
|
|
390
|
-
X as useThemeVariables
|
|
340
|
+
Button,
|
|
341
|
+
ThemeContext,
|
|
342
|
+
ThemeProvider,
|
|
343
|
+
ThemeToggle,
|
|
344
|
+
applyThemeToDOM,
|
|
345
|
+
clsx,
|
|
346
|
+
cn,
|
|
347
|
+
createCSSVariable,
|
|
348
|
+
defaultDarkTheme as darkTheme,
|
|
349
|
+
defaultTheme,
|
|
350
|
+
detectColorScheme,
|
|
351
|
+
getThemeValue,
|
|
352
|
+
mergeClasses,
|
|
353
|
+
mergeTheme,
|
|
354
|
+
useTheme,
|
|
355
|
+
useThemeVariables
|
|
391
356
|
};
|