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.
Files changed (43) hide show
  1. package/dist/index.d.ts +359 -7
  2. package/dist/klip-components.cjs.js +1 -37
  3. package/dist/klip-components.css +1 -1
  4. package/dist/klip-components.es.js +283 -318
  5. package/dist/klip-components.umd.js +1 -0
  6. package/package.json +4 -4
  7. package/dist/components/Button/Button.d.ts +0 -60
  8. package/dist/components/Button/Button.d.ts.map +0 -1
  9. package/dist/components/Button/index.d.ts +0 -3
  10. package/dist/components/Button/index.d.ts.map +0 -1
  11. package/dist/components/Debug/Debug.d.ts +0 -8
  12. package/dist/components/Debug/Debug.d.ts.map +0 -1
  13. package/dist/components/Debug/index.d.ts +0 -2
  14. package/dist/components/Debug/index.d.ts.map +0 -1
  15. package/dist/components/SimpleButton/SimpleButton.d.ts +0 -11
  16. package/dist/components/SimpleButton/SimpleButton.d.ts.map +0 -1
  17. package/dist/components/SimpleButton/index.d.ts +0 -2
  18. package/dist/components/SimpleButton/index.d.ts.map +0 -1
  19. package/dist/components/ThemeToggle/ThemeToggle.d.ts +0 -9
  20. package/dist/components/ThemeToggle/ThemeToggle.d.ts.map +0 -1
  21. package/dist/components/ThemeToggle/index.d.ts +0 -3
  22. package/dist/components/ThemeToggle/index.d.ts.map +0 -1
  23. package/dist/index.d.ts.map +0 -1
  24. package/dist/theme/ThemeProvider.d.ts +0 -37
  25. package/dist/theme/ThemeProvider.d.ts.map +0 -1
  26. package/dist/theme/context.d.ts +0 -17
  27. package/dist/theme/context.d.ts.map +0 -1
  28. package/dist/theme/cssGenerator.d.ts +0 -14
  29. package/dist/theme/cssGenerator.d.ts.map +0 -1
  30. package/dist/theme/defaultThemes.d.ts +0 -11
  31. package/dist/theme/defaultThemes.d.ts.map +0 -1
  32. package/dist/theme/hooks.d.ts +0 -68
  33. package/dist/theme/hooks.d.ts.map +0 -1
  34. package/dist/theme/index.d.ts +0 -9
  35. package/dist/theme/index.d.ts.map +0 -1
  36. package/dist/theme/utils.d.ts +0 -23
  37. package/dist/theme/utils.d.ts.map +0 -1
  38. package/dist/types/theme.d.ts +0 -78
  39. package/dist/types/theme.d.ts.map +0 -1
  40. package/dist/utils/cn.d.ts +0 -37
  41. package/dist/utils/cn.d.ts.map +0 -1
  42. package/dist/utils/index.d.ts +0 -2
  43. package/dist/utils/index.d.ts.map +0 -1
@@ -1,391 +1,356 @@
1
- import { jsx as d, jsxs as m } from "react/jsx-runtime";
2
- import l, { createContext as j, useContext as B, useState as g, useCallback as u, useEffect as D, useLayoutEffect as E } from "react";
3
- function x(r) {
4
- var o, e, s = "";
5
- if (typeof r == "string" || typeof r == "number") s += r;
6
- else if (typeof r == "object") if (Array.isArray(r)) {
7
- var a = r.length;
8
- for (o = 0; o < a; o++) r[o] && (e = x(r[o])) && (s && (s += " "), s += e);
9
- } else for (e in r) r[e] && (s && (s += " "), s += e);
10
- return s;
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 L() {
13
- for (var r, o, e = 0, s = "", a = arguments.length; e < a; e++) (r = arguments[e]) && (o = x(r)) && (s && (s += " "), s += o);
14
- return s;
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 A(...r) {
17
- const o = r.join(" ").split(" ").filter(Boolean);
18
- return [...new Set(o)].join(" ");
47
+ function mergeClasses(...classes) {
48
+ const allClasses = classes.join(" ").split(" ").filter(Boolean);
49
+ return [...new Set(allClasses)].join(" ");
19
50
  }
20
- function $(...r) {
21
- const o = L(...r);
22
- return A(o);
51
+ function cn(...inputs) {
52
+ const joinedClasses = clsx(...inputs);
53
+ return mergeClasses(joinedClasses);
23
54
  }
24
- const N = ({
25
- variant: r = "primary",
26
- size: o = "md",
27
- block: e = !1,
28
- className: s = "",
29
- children: a,
30
- ...i
31
- }) => /* @__PURE__ */ d(
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
- return r;
64
+ }
65
+ return context;
44
66
  }
45
- function X() {
46
- const { theme: r } = S();
67
+ function useThemeVariables() {
68
+ const { theme } = useTheme();
47
69
  return {
48
70
  // Colors
49
- primaryColor: `var(--primary-color, ${r.colors.primary.main})`,
50
- primaryHover: `var(--primary-hover, ${r.colors.primary.hover})`,
51
- secondaryColor: `var(--secondary-color, ${r.colors.secondary.main})`,
52
- secondaryHover: `var(--secondary-hover, ${r.colors.secondary.hover})`,
53
- tertiaryColor: `var(--tertiary-color, ${r.colors.tertiary.main})`,
54
- tertiaryHover: `var(--tertiary-hover, ${r.colors.tertiary.hover})`,
55
- successColor: `var(--success-color, ${r.colors.semantic.success})`,
56
- dangerColor: `var(--danger-color, ${r.colors.semantic.danger})`,
57
- warningColor: `var(--warning-color, ${r.colors.semantic.warning})`,
58
- infoColor: `var(--info-color, ${r.colors.semantic.info})`,
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, ${r.spacing.xs})`,
61
- spacingSm: `var(--spacing-sm, ${r.spacing.sm})`,
62
- spacingMd: `var(--spacing-md, ${r.spacing.md})`,
63
- spacingLg: `var(--spacing-lg, ${r.spacing.lg})`,
64
- spacingXl: `var(--spacing-xl, ${r.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, ${r.borderRadius.sm})`,
67
- borderRadius: `var(--border-radius, ${r.borderRadius.base})`,
68
- borderRadiusLg: `var(--border-radius-lg, ${r.borderRadius.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, ${r.typography.fontFamily})`,
71
- fontSizeSm: `var(--font-size-sm, ${r.typography.fontSize.sm})`,
72
- fontSizeBase: `var(--font-size-base, ${r.typography.fontSize.base})`,
73
- fontSizeLg: `var(--font-size-lg, ${r.typography.fontSize.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, ${r.shadows.sm})`,
76
- shadowMd: `var(--shadow-md, ${r.shadows.md})`,
77
- shadowLg: `var(--shadow-lg, ${r.shadows.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 Q({ className: r }) {
81
- const { mode: o, setMode: e, isDark: s } = S(), a = () => {
82
- e(o === "auto" ? "light" : o === "light" ? "dark" : "auto");
83
- }, i = () => {
84
- switch (o) {
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 (${s ? "Dark" : "Light"})`;
122
+ return `🔄 Auto (${isDark ? "Dark" : "Light"})`;
91
123
  default:
92
124
  return "Theme";
93
125
  }
94
126
  };
95
- return /* @__PURE__ */ d(
127
+ return /* @__PURE__ */ jsx(
96
128
  "button",
97
129
  {
98
- onClick: a,
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
- r
135
+ className
104
136
  ),
105
- title: `Current theme: ${o}${o === "auto" ? ` (${s ? "dark" : "light"})` : ""}`,
106
- children: i()
137
+ title: `Current theme: ${mode}${mode === "auto" ? ` (${isDark ? "dark" : "light"})` : ""}`,
138
+ children: getButtonText()
107
139
  }
108
140
  );
109
141
  }
110
- function Y({ className: r }) {
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
- main: "#05445e",
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: "#e0e9e0"
150
+ info: "#75e6da",
151
+ light: "#ffffff",
152
+ dark: "#1a1926",
153
+ link: "#2d99ff"
158
154
  }
159
155
  },
160
- spacing: {
161
- xs: "0.25rem",
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: "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",
174
- fontSize: {
175
- sm: "0.875rem",
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
- }, M = {
168
+ };
169
+ const defaultDarkTheme = {
186
170
  colors: {
187
- primary: {
188
- main: "#7dd3fc",
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: "#22c55e",
201
- danger: "#ef4444",
202
- warning: "#f59e0b",
203
- info: "#3b82f6"
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
- xs: "0.25rem",
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: "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif",
220
- fontSize: {
221
- sm: "0.875rem",
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.15)",
228
- md: "0 4px 6px -1px rgb(0 0 0 / 0.2)",
229
- lg: "0 10px 15px -3px rgb(0 0 0 / 0.25)"
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 v(r, o) {
196
+ function mergeTheme(baseTheme, override) {
197
+ var _a, _b, _c, _d;
233
198
  return {
234
199
  colors: {
235
- primary: {
236
- ...r.colors.primary,
237
- ...o.colors?.primary
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
- ...r.spacing,
254
- ...o.spacing
255
- },
256
- borderRadius: {
257
- ...r.borderRadius,
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 G(r, o = document.documentElement) {
275
- o.style.setProperty("--primary-color", r.colors.primary.main), o.style.setProperty("--primary-hover", r.colors.primary.hover), o.style.setProperty("--secondary-color", r.colors.secondary.main), o.style.setProperty("--secondary-hover", r.colors.secondary.hover), o.style.setProperty("--tertiary-color", r.colors.tertiary.main), o.style.setProperty("--tertiary-hover", r.colors.tertiary.hover), o.style.setProperty("--success-color", r.colors.semantic.success), o.style.setProperty("--danger-color", r.colors.semantic.danger), o.style.setProperty("--warning-color", r.colors.semantic.warning), o.style.setProperty("--info-color", r.colors.semantic.info), o.style.setProperty("--spacing-xs", r.spacing.xs), o.style.setProperty("--spacing-sm", r.spacing.sm), o.style.setProperty("--spacing-md", r.spacing.md), o.style.setProperty("--spacing-lg", r.spacing.lg), o.style.setProperty("--spacing-xl", r.spacing.xl), o.style.setProperty("--border-radius-sm", r.borderRadius.sm), o.style.setProperty("--border-radius", r.borderRadius.base), o.style.setProperty("--border-radius-lg", r.borderRadius.lg), o.style.setProperty("--font-family", r.typography.fontFamily), o.style.setProperty("--font-size-sm", r.typography.fontSize.sm), o.style.setProperty("--font-size-base", r.typography.fontSize.base), o.style.setProperty("--font-size-lg", r.typography.fontSize.lg), o.style.setProperty("--shadow-sm", r.shadows.sm), o.style.setProperty("--shadow-md", r.shadows.md), o.style.setProperty("--shadow-lg", r.shadows.lg);
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 J(r, o) {
278
- const e = o.split(".");
279
- let s = r;
280
- for (const a of e) {
281
- if (typeof s != "object" || s === null || !(a in s))
282
- return;
283
- s = s[a];
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 s == "string" ? s : void 0;
246
+ return typeof current === "string" ? current : void 0;
286
247
  }
287
- function K(r) {
288
- return `--${r.replace(/\./g, "-")}`;
248
+ function createCSSVariable(path) {
249
+ return `--${path.replace(/\./g, "-")}`;
289
250
  }
290
- function F() {
291
- return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
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 H(r, o = ":root") {
294
- return `
295
- ${o} {
296
- /* Colors */
297
- --primary-color: ${r.colors.primary.main};
298
- --primary-hover: ${r.colors.primary.hover};
299
- --secondary-color: ${r.colors.secondary.main};
300
- --secondary-hover: ${r.colors.secondary.hover};
301
- --tertiary-color: ${r.colors.tertiary.main};
302
- --tertiary-hover: ${r.colors.tertiary.hover};
303
- --success-color: ${r.colors.semantic.success};
304
- --danger-color: ${r.colors.semantic.danger};
305
- --warning-color: ${r.colors.semantic.warning};
306
- --info-color: ${r.colors.semantic.info};
307
-
308
- /* Spacing */
309
- --spacing-xs: ${r.spacing.xs};
310
- --spacing-sm: ${r.spacing.sm};
311
- --spacing-md: ${r.spacing.md};
312
- --spacing-lg: ${r.spacing.lg};
313
- --spacing-xl: ${r.spacing.xl};
314
-
315
- /* Border Radius */
316
- --border-radius-sm: ${r.borderRadius.sm};
317
- --border-radius: ${r.borderRadius.base};
318
- --border-radius-lg: ${r.borderRadius.lg};
319
-
320
- /* Typography */
321
- --font-family: ${r.typography.fontFamily};
322
- --font-size-sm: ${r.typography.fontSize.sm};
323
- --font-size-base: ${r.typography.fontSize.base};
324
- --font-size-lg: ${r.typography.fontSize.lg};
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 U({
333
- children: r,
334
- defaultMode: o = "auto",
335
- theme: e,
336
- darkTheme: s = M
290
+ function ThemeProvider({
291
+ children,
292
+ defaultMode = "auto",
293
+ theme,
294
+ darkTheme = defaultDarkTheme
337
295
  }) {
338
- const [a, i] = g(o), [y, f] = g(e || {}), [k, P] = g(() => F() === "dark"), h = a === "dark" || a === "auto" && k, p = v(h ? s : b, y), z = u((n) => {
339
- i(n);
340
- }, []), C = u((n) => {
341
- f((t) => v({ ...b, ...t }, n));
342
- }, []), R = u(() => {
343
- f({});
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
- D(() => {
346
- if (typeof window > "u") return;
347
- const n = window.matchMedia("(prefers-color-scheme: dark)"), t = (c) => {
348
- P(c.matches);
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
- return n.addEventListener("change", t), () => n.removeEventListener("change", t);
351
- }, []), E(() => {
352
- if (Object.keys(y).length > 0) {
353
- const n = H(p), t = document.getElementById("klip-custom-theme");
354
- t && t.remove();
355
- const c = document.createElement("style");
356
- c.id = "klip-custom-theme", c.textContent = n, document.head.insertBefore(c, document.head.firstChild);
357
- } else {
358
- const n = document.getElementById("klip-custom-theme");
359
- n && n.remove();
360
- }
361
- }, [p, y]);
362
- const T = {
363
- theme: p,
364
- mode: a,
365
- setMode: z,
366
- updateTheme: C,
367
- resetTheme: R,
368
- isDark: h
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__ */ d(w.Provider, { value: T, children: r });
337
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: contextValue, children });
371
338
  }
372
339
  export {
373
- N as Button,
374
- Y as Debug,
375
- q as SimpleButton,
376
- w as ThemeContext,
377
- U as ThemeProvider,
378
- Q as ThemeToggle,
379
- G as applyThemeToDOM,
380
- L as clsx,
381
- $ as cn,
382
- K as createCSSVariable,
383
- M as darkTheme,
384
- b as defaultTheme,
385
- F as detectColorScheme,
386
- J as getThemeValue,
387
- A as mergeClasses,
388
- v as mergeTheme,
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
  };