uitheme-web 1.0.1 → 1.2.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/README.md +167 -36
- package/dist/chunk-DFJEYTIW.js +12 -0
- package/dist/chunk-V3LMT5IJ.cjs +12 -0
- package/dist/chunk-W4YFUPGE.cjs +18 -0
- package/dist/chunk-WFG34KG5.js +18 -0
- package/dist/cli/index.js +39 -0
- package/dist/constants-DmZ7yAIL.d.cts +145 -0
- package/dist/constants-DmZ7yAIL.d.ts +145 -0
- package/dist/core/index.cjs +1 -270
- package/dist/core/index.d.cts +7 -3
- package/dist/core/index.d.ts +7 -3
- package/dist/core/index.js +1 -246
- package/dist/logo-DtwtRv4y.d.cts +4 -0
- package/dist/logo-DtwtRv4y.d.ts +4 -0
- package/dist/react/index.cjs +33 -1701
- package/dist/react/index.d.cts +78 -182
- package/dist/react/index.d.ts +78 -182
- package/dist/react/index.js +33 -1640
- package/dist/tanstack/index.cjs +1 -30
- package/dist/tanstack/index.d.cts +2 -2
- package/dist/tanstack/index.d.ts +2 -2
- package/dist/tanstack/index.js +1 -25
- package/package.json +22 -14
- package/dist/constants-n21pnuRC.d.cts +0 -106
- package/dist/constants-n21pnuRC.d.ts +0 -106
package/dist/react/index.cjs
CHANGED
|
@@ -1,773 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var reactDom = require('react-dom');
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var SelectPrimitive = require('@radix-ui/react-select');
|
|
7
|
-
|
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n.default = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
29
|
-
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
30
|
-
|
|
31
|
-
// src/core/types.ts
|
|
32
|
-
var ThemeAnimationType = /* @__PURE__ */ ((ThemeAnimationType2) => {
|
|
33
|
-
ThemeAnimationType2["CIRCLE"] = "circle";
|
|
34
|
-
ThemeAnimationType2["BLUR_CIRCLE"] = "blur-circle";
|
|
35
|
-
ThemeAnimationType2["SLIDE"] = "slide";
|
|
36
|
-
return ThemeAnimationType2;
|
|
37
|
-
})(ThemeAnimationType || {});
|
|
38
|
-
|
|
39
|
-
// src/core/constants.ts
|
|
40
|
-
var STORAGE_KEY = "theme";
|
|
41
|
-
var COLOR_STORAGE_KEY = "color-theme";
|
|
42
|
-
var GLOBAL_CLASS_NAME = "dark";
|
|
43
|
-
var COLOR_THEME_PREFIX = "theme-";
|
|
44
|
-
var DEFAULT_DURATION = 750;
|
|
45
|
-
var DEFAULT_EASING = "ease-in-out";
|
|
46
|
-
var DEFAULT_BLUR_AMOUNT = 2;
|
|
47
|
-
var DEFAULT_STYLE_ID = "ui-theme-style";
|
|
48
|
-
|
|
49
|
-
// src/core/animations.ts
|
|
50
|
-
var isBrowser = typeof window !== "undefined";
|
|
51
|
-
var getIsHighResolution = () => {
|
|
52
|
-
if (!isBrowser) return false;
|
|
53
|
-
return window.innerWidth >= 3e3 || window.innerHeight >= 2e3;
|
|
54
|
-
};
|
|
55
|
-
var injectBaseStyles = () => {
|
|
56
|
-
if (!isBrowser) return;
|
|
57
|
-
const styleId = "ui-theme-base-style";
|
|
58
|
-
if (document.getElementById(styleId)) return;
|
|
59
|
-
const style = document.createElement("style");
|
|
60
|
-
style.id = styleId;
|
|
61
|
-
const isHighResolution = getIsHighResolution();
|
|
62
|
-
style.textContent = `
|
|
63
|
-
::view-transition-old(root),
|
|
64
|
-
::view-transition-new(root) {
|
|
65
|
-
animation: none;
|
|
66
|
-
mix-blend-mode: normal;
|
|
67
|
-
${isHighResolution ? "transform: translateZ(0);" : ""}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
${isHighResolution ? `
|
|
71
|
-
::view-transition-group(root),
|
|
72
|
-
::view-transition-image-pair(root),
|
|
73
|
-
::view-transition-old(root),
|
|
74
|
-
::view-transition-new(root) {
|
|
75
|
-
backface-visibility: hidden;
|
|
76
|
-
perspective: 1000px;
|
|
77
|
-
transform: translate3d(0, 0, 0);
|
|
78
|
-
}
|
|
79
|
-
` : ""}
|
|
80
|
-
`;
|
|
81
|
-
document.head.appendChild(style);
|
|
82
|
-
};
|
|
83
|
-
var createBlurCircleMask = (blur) => {
|
|
84
|
-
const isHighResolution = getIsHighResolution();
|
|
85
|
-
const blurFilter = `<filter id="blur"><feGaussianBlur stdDeviation="${blur}" /></filter>`;
|
|
86
|
-
const circleRadius = isHighResolution ? 20 : 25;
|
|
87
|
-
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${blurFilter}</defs><circle cx="0" cy="0" r="${circleRadius}" fill="white" filter="url(%23blur)"/></svg>')`;
|
|
88
|
-
};
|
|
89
|
-
var getSystemTheme = () => {
|
|
90
|
-
if (!isBrowser) return "light";
|
|
91
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
92
|
-
};
|
|
93
|
-
var resolveTheme = (theme) => {
|
|
94
|
-
if (theme === "system") {
|
|
95
|
-
return getSystemTheme();
|
|
96
|
-
}
|
|
97
|
-
return theme === "dark" ? "dark" : "light";
|
|
98
|
-
};
|
|
99
|
-
var resolveThemeForServer = (theme) => {
|
|
100
|
-
if (theme === "system") {
|
|
101
|
-
return "system";
|
|
102
|
-
}
|
|
103
|
-
return theme === "dark" ? "dark" : "light";
|
|
104
|
-
};
|
|
105
|
-
var supportsViewTransitions = () => {
|
|
106
|
-
return isBrowser && "startViewTransition" in document;
|
|
107
|
-
};
|
|
108
|
-
var prefersReducedMotion = () => {
|
|
109
|
-
return isBrowser && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
110
|
-
};
|
|
111
|
-
var getSlideFromCoords = (direction) => {
|
|
112
|
-
switch (direction) {
|
|
113
|
-
case "left":
|
|
114
|
-
return { a: -100, b: 0 };
|
|
115
|
-
case "right":
|
|
116
|
-
return { a: 100, b: 0 };
|
|
117
|
-
case "top":
|
|
118
|
-
return { a: 0, b: -100 };
|
|
119
|
-
case "bottom":
|
|
120
|
-
return { a: 0, b: 100 };
|
|
121
|
-
case "top-left":
|
|
122
|
-
return { a: -100, b: -100 };
|
|
123
|
-
case "top-right":
|
|
124
|
-
return { a: 100, b: -100 };
|
|
125
|
-
case "bottom-left":
|
|
126
|
-
return { a: -100, b: 100 };
|
|
127
|
-
case "bottom-right":
|
|
128
|
-
return { a: 100, b: 100 };
|
|
129
|
-
default:
|
|
130
|
-
return { a: -100, b: 0 };
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var createCircleAnimation = (config) => {
|
|
134
|
-
const { x, y, duration, easing } = config;
|
|
135
|
-
const topLeft = Math.hypot(x, y);
|
|
136
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
137
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
138
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
139
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
140
|
-
document.documentElement.animate(
|
|
141
|
-
{
|
|
142
|
-
clipPath: [
|
|
143
|
-
`circle(0px at ${x}px ${y}px)`,
|
|
144
|
-
`circle(${maxRadius}px at ${x}px ${y}px)`
|
|
145
|
-
]
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
duration,
|
|
149
|
-
easing,
|
|
150
|
-
pseudoElement: "::view-transition-new(root)"
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
};
|
|
154
|
-
var createSlideAnimation = (config) => {
|
|
155
|
-
const {
|
|
156
|
-
a = -100,
|
|
157
|
-
b = 0,
|
|
158
|
-
x = 0,
|
|
159
|
-
y = 0,
|
|
160
|
-
duration,
|
|
161
|
-
styleId = DEFAULT_STYLE_ID
|
|
162
|
-
} = config;
|
|
163
|
-
const styleElement = document.createElement("style");
|
|
164
|
-
styleElement.id = styleId;
|
|
165
|
-
styleElement.textContent = `
|
|
166
|
-
::view-transition-old(root) {
|
|
167
|
-
animation-delay: ${duration}ms;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
::view-transition-new(root) {
|
|
171
|
-
animation: move-in ${duration}ms;
|
|
172
|
-
animation-timing-function: cubic-bezier(0.66, 0, 0.34, 1);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@keyframes move-in {
|
|
176
|
-
from {
|
|
177
|
-
translate: ${a}% ${b}%;
|
|
178
|
-
}
|
|
179
|
-
to {
|
|
180
|
-
translate: ${x}% ${y}%;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
`;
|
|
184
|
-
document.head.appendChild(styleElement);
|
|
185
|
-
setTimeout(() => {
|
|
186
|
-
const el = document.getElementById(styleId);
|
|
187
|
-
if (el) {
|
|
188
|
-
el.remove();
|
|
189
|
-
}
|
|
190
|
-
}, duration);
|
|
191
|
-
};
|
|
192
|
-
var createBlurCircleAnimation = (config) => {
|
|
193
|
-
const {
|
|
194
|
-
x,
|
|
195
|
-
y,
|
|
196
|
-
duration,
|
|
197
|
-
easing,
|
|
198
|
-
blurAmount,
|
|
199
|
-
styleId = DEFAULT_STYLE_ID
|
|
200
|
-
} = config;
|
|
201
|
-
const existingStyle = document.getElementById(styleId);
|
|
202
|
-
if (existingStyle) {
|
|
203
|
-
existingStyle.remove();
|
|
204
|
-
}
|
|
205
|
-
const isHighResolution = getIsHighResolution();
|
|
206
|
-
const viewportSize = Math.max(window.innerWidth, window.innerHeight) + 200;
|
|
207
|
-
const scaleFactor = isHighResolution ? 2.5 : 4;
|
|
208
|
-
const optimalMaskSize = isHighResolution ? Math.min(viewportSize * scaleFactor, 5e3) : viewportSize * scaleFactor;
|
|
209
|
-
const topLeft = Math.hypot(x, y);
|
|
210
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
211
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
212
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
213
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
214
|
-
const styleElement = document.createElement("style");
|
|
215
|
-
styleElement.id = styleId;
|
|
216
|
-
const blurFactor = isHighResolution ? 1.5 : 1.2;
|
|
217
|
-
const finalMaskSize = Math.max(optimalMaskSize, maxRadius * 2.5);
|
|
218
|
-
styleElement.textContent = `
|
|
219
|
-
::view-transition-group(root) {
|
|
220
|
-
animation-duration: ${duration}ms;
|
|
221
|
-
animation-timing-function: ${isHighResolution ? "cubic-bezier(0.2, 0, 0.2, 1)" : "linear(0 0%, 0.2342 12.49%, 0.4374 24.99%,0.6093 37.49%, 0.6835 43.74%,0.7499 49.99%, 0.8086 56.25%,0.8593 62.5%, 0.9023 68.75%, 0.9375 75%,0.9648 81.25%, 0.9844 87.5%,0.9961 93.75%, 1 100%)"};
|
|
222
|
-
will-change: transform;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
::view-transition-new(root) {
|
|
226
|
-
mask: ${createBlurCircleMask(blurAmount * blurFactor)} 0 0 / 100% 100% no-repeat;
|
|
227
|
-
mask-position: ${x}px ${y}px;
|
|
228
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
229
|
-
transform-origin: ${x}px ${y}px;
|
|
230
|
-
will-change: mask-size, mask-position;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
::view-transition-old(root),
|
|
234
|
-
.dark::view-transition-old(root) {
|
|
235
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
236
|
-
transform-origin: ${x}px ${y}px;
|
|
237
|
-
z-index: -1;
|
|
238
|
-
will-change: mask-size, mask-position;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
@keyframes ui-theme-mask-scale {
|
|
242
|
-
0% {
|
|
243
|
-
mask-size: 0px;
|
|
244
|
-
mask-position: ${x}px ${y}px;
|
|
245
|
-
}
|
|
246
|
-
100% {
|
|
247
|
-
mask-size: ${finalMaskSize}px;
|
|
248
|
-
mask-position: ${x - finalMaskSize / 2}px ${y - finalMaskSize / 2}px;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
`;
|
|
252
|
-
document.head.appendChild(styleElement);
|
|
253
|
-
setTimeout(() => {
|
|
254
|
-
const el = document.getElementById(styleId);
|
|
255
|
-
if (el) {
|
|
256
|
-
el.remove();
|
|
257
|
-
}
|
|
258
|
-
}, duration);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// src/core/storage.ts
|
|
262
|
-
var isBrowser2 = typeof window !== "undefined";
|
|
263
|
-
var getStoredTheme = (key = STORAGE_KEY, validThemes = ["light", "dark", "system"], defaultTheme = "system") => {
|
|
264
|
-
if (!isBrowser2) return defaultTheme;
|
|
265
|
-
const saved = localStorage.getItem(key);
|
|
266
|
-
return saved && validThemes.includes(saved) ? saved : defaultTheme;
|
|
267
|
-
};
|
|
268
|
-
var setStoredTheme = (theme, key = STORAGE_KEY) => {
|
|
269
|
-
if (!isBrowser2) return;
|
|
270
|
-
localStorage.setItem(key, theme);
|
|
271
|
-
};
|
|
272
|
-
var getStoredColorTheme = (key = COLOR_STORAGE_KEY, validColorThemes = ["default"], defaultColorTheme = "default") => {
|
|
273
|
-
if (!isBrowser2) return defaultColorTheme;
|
|
274
|
-
const saved = localStorage.getItem(key);
|
|
275
|
-
return saved && validColorThemes.includes(saved) ? saved : defaultColorTheme;
|
|
276
|
-
};
|
|
277
|
-
var setStoredColorTheme = (colorTheme, key = COLOR_STORAGE_KEY) => {
|
|
278
|
-
if (!isBrowser2) return;
|
|
279
|
-
localStorage.setItem(key, colorTheme);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
// src/react/hooks/use-theme.ts
|
|
283
|
-
var isBrowser3 = typeof window !== "undefined";
|
|
284
|
-
var useTheme = (props = {}) => {
|
|
285
|
-
const {
|
|
286
|
-
duration: propsDuration = DEFAULT_DURATION,
|
|
287
|
-
easing = DEFAULT_EASING,
|
|
288
|
-
animationType = "circle" /* CIRCLE */,
|
|
289
|
-
blurAmount = DEFAULT_BLUR_AMOUNT,
|
|
290
|
-
styleId = DEFAULT_STYLE_ID,
|
|
291
|
-
themes = ["light", "dark", "system"],
|
|
292
|
-
colorThemes = ["default"],
|
|
293
|
-
defaultTheme = "system",
|
|
294
|
-
defaultColorTheme = "default",
|
|
295
|
-
globalClassName = GLOBAL_CLASS_NAME,
|
|
296
|
-
colorThemePrefix = COLOR_THEME_PREFIX,
|
|
297
|
-
storageKey = STORAGE_KEY,
|
|
298
|
-
colorStorageKey = COLOR_STORAGE_KEY,
|
|
299
|
-
theme: externalTheme,
|
|
300
|
-
colorTheme: externalColorTheme,
|
|
301
|
-
onThemeChange,
|
|
302
|
-
onColorThemeChange,
|
|
303
|
-
slideDirection = "left",
|
|
304
|
-
slideFromX,
|
|
305
|
-
slideFromY,
|
|
306
|
-
slideToX = 0,
|
|
307
|
-
slideToY = 0,
|
|
308
|
-
initialTheme,
|
|
309
|
-
initialColorTheme,
|
|
310
|
-
systemThemeMode = "js"
|
|
311
|
-
} = props;
|
|
312
|
-
const isHighResolution = isBrowser3 && (window.innerWidth >= 3e3 || window.innerHeight >= 2e3);
|
|
313
|
-
const duration = isHighResolution ? Math.max(propsDuration * 0.8, 500) : propsDuration;
|
|
314
|
-
const [mounted, setMounted] = React.useState(false);
|
|
315
|
-
React.useEffect(() => {
|
|
316
|
-
injectBaseStyles();
|
|
317
|
-
setMounted(true);
|
|
318
|
-
}, []);
|
|
319
|
-
const [internalTheme, setInternalTheme] = React.useState(() => {
|
|
320
|
-
if (initialTheme !== void 0) return initialTheme;
|
|
321
|
-
return getStoredTheme(storageKey, themes, defaultTheme);
|
|
322
|
-
});
|
|
323
|
-
const [internalColorTheme, setInternalColorTheme] = React.useState(() => {
|
|
324
|
-
if (initialColorTheme !== void 0) return initialColorTheme;
|
|
325
|
-
return getStoredColorTheme(colorStorageKey, colorThemes, defaultColorTheme);
|
|
326
|
-
});
|
|
327
|
-
const currentTheme = externalTheme ?? internalTheme;
|
|
328
|
-
const currentColorTheme = externalColorTheme ?? internalColorTheme;
|
|
329
|
-
const [, setSystemTheme] = React.useState(() => getSystemTheme());
|
|
330
|
-
const resolvedTheme = resolveTheme(currentTheme);
|
|
331
|
-
React.useEffect(() => {
|
|
332
|
-
if (!isBrowser3) return;
|
|
333
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
334
|
-
const handleChange = () => setSystemTheme(getSystemTheme());
|
|
335
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
336
|
-
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
337
|
-
}, []);
|
|
338
|
-
React.useEffect(() => {
|
|
339
|
-
if (!isBrowser3 || !mounted) return;
|
|
340
|
-
const el = document.documentElement;
|
|
341
|
-
if (systemThemeMode === "css" && currentTheme === "system") {
|
|
342
|
-
el.classList.remove(globalClassName);
|
|
343
|
-
el.classList.remove("auto");
|
|
344
|
-
el.classList.remove("system");
|
|
345
|
-
el.classList.add("system");
|
|
346
|
-
el.style.colorScheme = "";
|
|
347
|
-
} else {
|
|
348
|
-
el.classList.remove("system");
|
|
349
|
-
el.classList.remove("auto");
|
|
350
|
-
if (resolvedTheme === "dark") {
|
|
351
|
-
el.classList.add(globalClassName);
|
|
352
|
-
} else {
|
|
353
|
-
el.classList.remove(globalClassName);
|
|
354
|
-
}
|
|
355
|
-
el.style.colorScheme = resolvedTheme;
|
|
356
|
-
}
|
|
357
|
-
colorThemes.forEach((theme) => {
|
|
358
|
-
el.classList.remove(`${colorThemePrefix}${theme}`);
|
|
359
|
-
});
|
|
360
|
-
el.classList.add(`${colorThemePrefix}${currentColorTheme}`);
|
|
361
|
-
}, [
|
|
362
|
-
resolvedTheme,
|
|
363
|
-
currentTheme,
|
|
364
|
-
currentColorTheme,
|
|
365
|
-
globalClassName,
|
|
366
|
-
colorThemePrefix,
|
|
367
|
-
colorThemes,
|
|
368
|
-
mounted,
|
|
369
|
-
systemThemeMode
|
|
370
|
-
]);
|
|
371
|
-
const ref = React.useRef(null);
|
|
372
|
-
const setTheme = React.useCallback(
|
|
373
|
-
(newTheme) => {
|
|
374
|
-
setStoredTheme(newTheme, storageKey);
|
|
375
|
-
if (externalTheme === void 0) {
|
|
376
|
-
setInternalTheme(newTheme);
|
|
377
|
-
}
|
|
378
|
-
if (onThemeChange) {
|
|
379
|
-
onThemeChange(newTheme);
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
[onThemeChange, externalTheme, storageKey]
|
|
383
|
-
);
|
|
384
|
-
const setColorTheme = React.useCallback(
|
|
385
|
-
(newColorTheme) => {
|
|
386
|
-
setStoredColorTheme(newColorTheme, colorStorageKey);
|
|
387
|
-
if (externalColorTheme === void 0) {
|
|
388
|
-
setInternalColorTheme(newColorTheme);
|
|
389
|
-
}
|
|
390
|
-
if (onColorThemeChange) {
|
|
391
|
-
onColorThemeChange(newColorTheme);
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
[onColorThemeChange, externalColorTheme, colorStorageKey]
|
|
395
|
-
);
|
|
396
|
-
const switchTheme = React.useCallback(
|
|
397
|
-
async (newTheme, animationOff = false) => {
|
|
398
|
-
if (!ref.current || !supportsViewTransitions() || prefersReducedMotion() || animationOff) {
|
|
399
|
-
setTheme(newTheme);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
let animationConfig;
|
|
403
|
-
if (animationType === "slide" /* SLIDE */) {
|
|
404
|
-
const fromCoords = slideFromX !== void 0 && slideFromY !== void 0 ? { a: slideFromX, b: slideFromY } : getSlideFromCoords(slideDirection);
|
|
405
|
-
animationConfig = {
|
|
406
|
-
a: fromCoords.a,
|
|
407
|
-
b: fromCoords.b,
|
|
408
|
-
x: slideToX,
|
|
409
|
-
y: slideToY,
|
|
410
|
-
duration,
|
|
411
|
-
easing,
|
|
412
|
-
animationType,
|
|
413
|
-
blurAmount,
|
|
414
|
-
styleId
|
|
415
|
-
};
|
|
416
|
-
} else {
|
|
417
|
-
const { top, left, width, height } = ref.current.getBoundingClientRect();
|
|
418
|
-
const x = left + width / 2;
|
|
419
|
-
const y = top + height / 2;
|
|
420
|
-
animationConfig = {
|
|
421
|
-
x,
|
|
422
|
-
y,
|
|
423
|
-
duration,
|
|
424
|
-
easing,
|
|
425
|
-
animationType,
|
|
426
|
-
blurAmount,
|
|
427
|
-
styleId
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
if (animationType === "blur-circle" /* BLUR_CIRCLE */) {
|
|
431
|
-
createBlurCircleAnimation(animationConfig);
|
|
432
|
-
}
|
|
433
|
-
if (animationType === "slide" /* SLIDE */) {
|
|
434
|
-
createSlideAnimation(animationConfig);
|
|
435
|
-
}
|
|
436
|
-
await document.startViewTransition(() => {
|
|
437
|
-
reactDom.flushSync(() => {
|
|
438
|
-
setTheme(newTheme);
|
|
439
|
-
});
|
|
440
|
-
}).ready;
|
|
441
|
-
if (animationType === "circle" /* CIRCLE */) {
|
|
442
|
-
createCircleAnimation(animationConfig);
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
[
|
|
446
|
-
setTheme,
|
|
447
|
-
duration,
|
|
448
|
-
easing,
|
|
449
|
-
animationType,
|
|
450
|
-
blurAmount,
|
|
451
|
-
styleId,
|
|
452
|
-
slideDirection,
|
|
453
|
-
slideFromX,
|
|
454
|
-
slideFromY,
|
|
455
|
-
slideToX,
|
|
456
|
-
slideToY
|
|
457
|
-
]
|
|
458
|
-
);
|
|
459
|
-
const switchColorTheme = React.useCallback(
|
|
460
|
-
(newColorTheme) => {
|
|
461
|
-
if (colorThemes.indexOf(newColorTheme) === -1) {
|
|
462
|
-
console.warn(
|
|
463
|
-
`Color theme "${newColorTheme}" not found in available themes`
|
|
464
|
-
);
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
setColorTheme(newColorTheme);
|
|
468
|
-
},
|
|
469
|
-
[colorThemes, setColorTheme]
|
|
470
|
-
);
|
|
471
|
-
const toggleTheme = React.useCallback(
|
|
472
|
-
async (animationOff = false) => {
|
|
473
|
-
const newTheme = resolvedTheme === "dark" ? "light" : "dark";
|
|
474
|
-
await switchTheme(newTheme, animationOff);
|
|
475
|
-
},
|
|
476
|
-
[resolvedTheme, switchTheme]
|
|
477
|
-
);
|
|
478
|
-
const toggleLightTheme = React.useCallback(
|
|
479
|
-
async (animationOff = false) => {
|
|
480
|
-
if (resolvedTheme === "light") return;
|
|
481
|
-
await switchTheme("light", animationOff);
|
|
482
|
-
},
|
|
483
|
-
[resolvedTheme, switchTheme]
|
|
484
|
-
);
|
|
485
|
-
const toggleDarkTheme = React.useCallback(
|
|
486
|
-
async (animationOff = false) => {
|
|
487
|
-
if (resolvedTheme === "dark") return;
|
|
488
|
-
await switchTheme("dark", animationOff);
|
|
489
|
-
},
|
|
490
|
-
[resolvedTheme, switchTheme]
|
|
491
|
-
);
|
|
492
|
-
const toggleColorTheme = React.useCallback(() => {
|
|
493
|
-
const currentIndex = colorThemes.indexOf(currentColorTheme);
|
|
494
|
-
const nextIndex = (currentIndex + 1) % colorThemes.length;
|
|
495
|
-
const nextColorTheme = colorThemes[nextIndex];
|
|
496
|
-
setColorTheme(nextColorTheme);
|
|
497
|
-
}, [currentColorTheme, colorThemes, setColorTheme]);
|
|
498
|
-
const createColorThemeToggle = React.useCallback(
|
|
499
|
-
(targetColorTheme) => {
|
|
500
|
-
return () => {
|
|
501
|
-
if (colorThemes.indexOf(targetColorTheme) === -1) {
|
|
502
|
-
console.warn(
|
|
503
|
-
`Color theme "${targetColorTheme}" not found in available themes`
|
|
504
|
-
);
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
setColorTheme(targetColorTheme);
|
|
508
|
-
};
|
|
509
|
-
},
|
|
510
|
-
[colorThemes, setColorTheme]
|
|
511
|
-
);
|
|
512
|
-
const isColorThemeActive = React.useCallback(
|
|
513
|
-
(targetColorTheme) => {
|
|
514
|
-
return currentColorTheme === targetColorTheme;
|
|
515
|
-
},
|
|
516
|
-
[currentColorTheme]
|
|
517
|
-
);
|
|
518
|
-
return {
|
|
519
|
-
ref,
|
|
520
|
-
theme: currentTheme,
|
|
521
|
-
colorTheme: currentColorTheme,
|
|
522
|
-
resolvedTheme,
|
|
523
|
-
setTheme,
|
|
524
|
-
setColorTheme,
|
|
525
|
-
switchTheme,
|
|
526
|
-
switchColorTheme,
|
|
527
|
-
toggleTheme,
|
|
528
|
-
toggleLightTheme,
|
|
529
|
-
toggleDarkTheme,
|
|
530
|
-
toggleColorTheme,
|
|
531
|
-
createColorThemeToggle,
|
|
532
|
-
isColorThemeActive
|
|
533
|
-
};
|
|
534
|
-
};
|
|
535
|
-
var NextUIThemeContext = React.createContext(
|
|
536
|
-
void 0
|
|
537
|
-
);
|
|
538
|
-
var generatePreHydrationScript = (storageKey, colorStorageKey, defaultTheme, defaultColorTheme, attribute, globalClassName, colorThemePrefix) => {
|
|
539
|
-
return `
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunkV3LMT5IJ_cjs=require('../chunk-V3LMT5IJ.cjs'),chunkW4YFUPGE_cjs=require('../chunk-W4YFUPGE.cjs'),_t=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),m=require('@radix-ui/react-select');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var _t__namespace=/*#__PURE__*/_interopNamespace(_t);var m__namespace=/*#__PURE__*/_interopNamespace(m);var Et=()=>()=>{},Rt=()=>true,bt=()=>false,W=()=>_t.useSyncExternalStore(Et,Rt,bt);var ot=typeof window<"u",rt=e=>e&&e!==true&&"currentTarget"in e?{element:e.currentTarget,animationOff:e.detail===0}:e,F=(e={})=>{let{duration:o=400,easing:n=chunkW4YFUPGE_cjs.v,animationType:r="circle",blurAmount:i=2,clipPathDirection:a="top-left",animationPosition:l,logo:g,logoLight:u,logoDark:y,logoWidth:b,logoHeight:U,gradientWidth:V,styleId:p=chunkW4YFUPGE_cjs.x,themes:R=["light","dark","system"],colorThemes:v=["default"],defaultTheme:N="system",defaultColorTheme:G="default",globalClassName:c=chunkW4YFUPGE_cjs.s,colorThemePrefix:w=chunkW4YFUPGE_cjs.t,storageKey:k=chunkW4YFUPGE_cjs.q,colorStorageKey:s=chunkW4YFUPGE_cjs.r,theme:C,colorTheme:z,onThemeChange:T,onColorThemeChange:_,slideDirection:K="left",slideFromX:M,slideFromY:d,slideToX:A=0,slideToY:L=0,initialTheme:S,initialColorTheme:x,systemThemeMode:oe="js"}=e;chunkV3LMT5IJ_cjs.c({logo:g,logoLight:u,logoDark:y});let se=o;_t.useEffect(()=>{if(r==="svg-logo")for(let t of [g,u,y])t&&chunkV3LMT5IJ_cjs.d(t);},[r,g,u,y]);let pe=W();_t.useEffect(()=>{chunkW4YFUPGE_cjs.a();},[]);let[Le,ge]=_t.useState(()=>S!==void 0?S:chunkV3LMT5IJ_cjs.f(k,R,N)),[Ee,fe]=_t.useState(()=>x!==void 0?x:chunkV3LMT5IJ_cjs.h(s,v,G)),$=C??Le,D=z??Ee,[,h]=_t.useState(()=>chunkW4YFUPGE_cjs.c()),O=chunkW4YFUPGE_cjs.d($);_t.useEffect(()=>{if(!ot)return;let t=window.matchMedia("(prefers-color-scheme: dark)"),E=()=>h(chunkW4YFUPGE_cjs.c());return t.addEventListener("change",E),()=>t.removeEventListener("change",E)},[]),_t.useEffect(()=>{if(!ot||!pe)return;let t=document.documentElement;oe==="css"&&$==="system"?(t.classList.remove(c),t.classList.remove("auto"),t.classList.remove("system"),t.classList.add("system"),t.style.colorScheme=""):(t.classList.remove("system"),t.classList.remove("auto"),O==="dark"?t.classList.add(c):t.classList.remove(c),t.style.colorScheme=O),v.forEach(E=>{t.classList.remove(`${w}${E}`);}),t.classList.add(`${w}${D}`);},[O,$,D,c,w,v,pe,oe]);let Je=_t.useRef(null),ve=_t.useRef($),Re=_t.useRef(D),j=_t.useRef($),re=_t.useRef(D),be=_t.useRef(0);_t.useEffect(()=>{be.current===0&&(ve.current=$,Re.current=D,j.current=$,re.current=D);},[$,D]);let ye=_t.useCallback(t=>{chunkV3LMT5IJ_cjs.g(t,k),ve.current=t,C===void 0&&ge(t),T&&T(t);},[T,C,k]),Ce=_t.useCallback(t=>{chunkV3LMT5IJ_cjs.i(t,s),Re.current=t,z===void 0&&fe(t),_&&_(t);},[_,z,s]),pt=_t.useCallback(t=>{ye(t),j.current=t;},[ye]),gt=_t.useCallback(t=>{Ce(t),re.current=t;},[Ce]),Se=_t.useCallback(async(t,E=false)=>{let J=E===true||E===false?{animationOff:E}:E,Ae=null;if(!J.animationOff&&se>0)if(r==="slide")Ae={...M!==void 0&&d!==void 0?{a:M,b:d}:chunkW4YFUPGE_cjs.h(K),x:A,y:L,duration:se,easing:n,animationType:r,blurAmount:i,styleId:p};else {let qe=J.element??Je.current,he=J.origin?null:qe?.getBoundingClientRect(),Ie=(r==="svg-logo"?chunkW4YFUPGE_cjs.i("center"):null)??J.origin??(l&&l!=="trigger"?chunkW4YFUPGE_cjs.i(l):null)??(he?{x:he.left+he.width/2,y:he.top+he.height/2}:r==="circle"||r==="blur-circle"?null:chunkW4YFUPGE_cjs.i("center"));Ie&&Number.isFinite(Ie.x)&&Number.isFinite(Ie.y)&&(Ae={...Ie,duration:se,easing:n,animationType:r,blurAmount:i,styleId:p,clipPathDirection:a,animationPosition:l,logo:u!==void 0?chunkW4YFUPGE_cjs.d(ve.current)==="light"?u:y:g,logoWidth:b,logoHeight:U,gradientWidth:V});}be.current++;try{await chunkV3LMT5IJ_cjs.e(()=>reactDom.flushSync(t),Ae);}finally{be.current--;}},[se,n,r,i,p,K,M,d,A,L,a,l,g,u,y,b,U,V]),ne=_t.useCallback(async(t,E)=>{if(t!==j.current){j.current=t;try{await Se(()=>ye(t),E);}catch(J){throw j.current===t&&(j.current=ve.current),J}}},[Se,ye]),ce=_t.useCallback(async(t,E)=>{if(!v.includes(t)){console.warn(`Color theme "${t}" not found in available themes`);return}if(t!==re.current){re.current=t;try{await Se(()=>Ce(t),E);}catch(J){throw re.current===t&&(re.current=Re.current),J}}},[v,Se,Ce]),ft=_t.useCallback(async t=>{await ne(chunkW4YFUPGE_cjs.d(j.current)==="dark"?"light":"dark",t);},[ne]),vt=_t.useCallback(async t=>{chunkW4YFUPGE_cjs.d(j.current)!=="light"&&await ne("light",t);},[ne]),yt=_t.useCallback(async t=>{chunkW4YFUPGE_cjs.d(j.current)!=="dark"&&await ne("dark",t);},[ne]),Ct=_t.useCallback(async t=>{if(v.length===0)return;let E=v.indexOf(re.current);await ce(v[(E+1)%v.length],rt(t));},[v,ce]),St=_t.useCallback(t=>E=>ce(t,rt(E)),[ce]),It=_t.useCallback(t=>D===t,[D]);return {ref:Je,theme:$,colorTheme:D,resolvedTheme:O,setTheme:pt,setColorTheme:gt,switchTheme:ne,switchColorTheme:ce,toggleTheme:ft,toggleLightTheme:vt,toggleDarkTheme:yt,toggleColorTheme:Ct,createColorThemeToggle:St,isColorThemeActive:It}};function I(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var B=_t.createContext(null),we=()=>_t.useContext(B);var Fe=_t.createContext(void 0),Ht=(e,o,n,r,i,a,l)=>`
|
|
540
3
|
(function() {
|
|
541
4
|
try {
|
|
542
|
-
var theme = localStorage.getItem(
|
|
543
|
-
var colorTheme = localStorage.getItem(
|
|
5
|
+
var theme = localStorage.getItem(${I(e)}) || ${I(n)};
|
|
6
|
+
var colorTheme = localStorage.getItem(${I(o)}) || ${I(r)};
|
|
544
7
|
var resolved = theme === 'system'
|
|
545
8
|
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
546
9
|
: theme;
|
|
547
10
|
|
|
548
|
-
if (
|
|
11
|
+
if (${I(i)} === 'class') {
|
|
549
12
|
if (resolved === 'dark') {
|
|
550
|
-
document.documentElement.classList.add(
|
|
13
|
+
document.documentElement.classList.add(${I(a)});
|
|
551
14
|
} else {
|
|
552
|
-
document.documentElement.classList.remove(
|
|
15
|
+
document.documentElement.classList.remove(${I(a)});
|
|
553
16
|
}
|
|
554
17
|
} else {
|
|
555
18
|
document.documentElement.setAttribute('data-theme', resolved);
|
|
556
19
|
}
|
|
557
20
|
|
|
558
21
|
document.documentElement.style.colorScheme = resolved;
|
|
559
|
-
document.documentElement.classList.add(
|
|
22
|
+
document.documentElement.classList.add(${I(l)} + colorTheme);
|
|
560
23
|
} catch (e) {
|
|
561
24
|
console.warn('Theme pre-hydration script failed:', e);
|
|
562
25
|
}
|
|
563
26
|
})();
|
|
564
|
-
|
|
565
|
-
};
|
|
566
|
-
var ThemePreHydrationScript = React__default.default.memo(
|
|
567
|
-
({
|
|
568
|
-
storageKey,
|
|
569
|
-
colorStorageKey,
|
|
570
|
-
defaultTheme,
|
|
571
|
-
defaultColorTheme,
|
|
572
|
-
attribute,
|
|
573
|
-
globalClassName,
|
|
574
|
-
colorThemePrefix,
|
|
575
|
-
nonce
|
|
576
|
-
}) => {
|
|
577
|
-
const scriptContent = generatePreHydrationScript(
|
|
578
|
-
storageKey,
|
|
579
|
-
colorStorageKey,
|
|
580
|
-
defaultTheme,
|
|
581
|
-
defaultColorTheme,
|
|
582
|
-
attribute,
|
|
583
|
-
globalClassName,
|
|
584
|
-
colorThemePrefix
|
|
585
|
-
);
|
|
586
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
587
|
-
"script",
|
|
588
|
-
{
|
|
589
|
-
nonce,
|
|
590
|
-
suppressHydrationWarning: true,
|
|
591
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
);
|
|
596
|
-
ThemePreHydrationScript.displayName = "ThemePreHydrationScript";
|
|
597
|
-
var NextUIThemeProvider = ({
|
|
598
|
-
children,
|
|
599
|
-
themes = ["light", "dark", "system"],
|
|
600
|
-
colorThemes = ["default"],
|
|
601
|
-
defaultTheme = "system",
|
|
602
|
-
defaultColorTheme = "default",
|
|
603
|
-
animationType = "circle" /* CIRCLE */,
|
|
604
|
-
duration = 750,
|
|
605
|
-
storageKey = STORAGE_KEY,
|
|
606
|
-
colorStorageKey = COLOR_STORAGE_KEY,
|
|
607
|
-
attribute = "class",
|
|
608
|
-
globalClassName = GLOBAL_CLASS_NAME,
|
|
609
|
-
colorThemePrefix = COLOR_THEME_PREFIX,
|
|
610
|
-
nonce,
|
|
611
|
-
disableAnimationOnInit = true,
|
|
612
|
-
disablePreHydrationScript = false
|
|
613
|
-
}) => {
|
|
614
|
-
const [mounted, setMounted] = React.useState(false);
|
|
615
|
-
const themeState = useTheme({
|
|
616
|
-
themes,
|
|
617
|
-
colorThemes,
|
|
618
|
-
defaultTheme,
|
|
619
|
-
defaultColorTheme,
|
|
620
|
-
animationType,
|
|
621
|
-
duration,
|
|
622
|
-
storageKey,
|
|
623
|
-
colorStorageKey,
|
|
624
|
-
globalClassName: attribute === "class" ? globalClassName : void 0,
|
|
625
|
-
colorThemePrefix
|
|
626
|
-
});
|
|
627
|
-
React.useEffect(() => {
|
|
628
|
-
setMounted(true);
|
|
629
|
-
}, []);
|
|
630
|
-
const switchThemeWithHydrationAwareness = React.useCallback(
|
|
631
|
-
async (theme, animationOff = false) => {
|
|
632
|
-
if (!mounted && disableAnimationOnInit) {
|
|
633
|
-
themeState.setTheme(theme);
|
|
634
|
-
} else {
|
|
635
|
-
await themeState.switchTheme(theme, animationOff);
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
[mounted, disableAnimationOnInit, themeState]
|
|
639
|
-
);
|
|
640
|
-
const switchThemeFromElement = React.useCallback(
|
|
641
|
-
async (theme, element) => {
|
|
642
|
-
if (!mounted && disableAnimationOnInit) {
|
|
643
|
-
themeState.setTheme(theme);
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
if (themeState.ref.current) {
|
|
647
|
-
const originalRef = themeState.ref.current;
|
|
648
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
649
|
-
value: element,
|
|
650
|
-
writable: true,
|
|
651
|
-
configurable: true
|
|
652
|
-
});
|
|
653
|
-
await themeState.switchTheme(theme);
|
|
654
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
655
|
-
value: originalRef,
|
|
656
|
-
writable: true,
|
|
657
|
-
configurable: true
|
|
658
|
-
});
|
|
659
|
-
} else {
|
|
660
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
661
|
-
value: element,
|
|
662
|
-
writable: true,
|
|
663
|
-
configurable: true
|
|
664
|
-
});
|
|
665
|
-
await themeState.switchTheme(theme);
|
|
666
|
-
}
|
|
667
|
-
},
|
|
668
|
-
[mounted, disableAnimationOnInit, themeState]
|
|
669
|
-
);
|
|
670
|
-
const systemTheme = typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
671
|
-
if (!mounted) {
|
|
672
|
-
const loadingContextValue = {
|
|
673
|
-
ref: { current: null },
|
|
674
|
-
theme: defaultTheme,
|
|
675
|
-
colorTheme: defaultColorTheme,
|
|
676
|
-
resolvedTheme: defaultTheme === "dark" ? "dark" : "light",
|
|
677
|
-
systemTheme: "light",
|
|
678
|
-
setTheme: () => {
|
|
679
|
-
},
|
|
680
|
-
setColorTheme: () => {
|
|
681
|
-
},
|
|
682
|
-
switchTheme: async () => {
|
|
683
|
-
},
|
|
684
|
-
switchThemeFromElement: async () => {
|
|
685
|
-
},
|
|
686
|
-
switchColorTheme: () => {
|
|
687
|
-
},
|
|
688
|
-
toggleTheme: async () => {
|
|
689
|
-
},
|
|
690
|
-
toggleLightTheme: async () => {
|
|
691
|
-
},
|
|
692
|
-
toggleDarkTheme: async () => {
|
|
693
|
-
},
|
|
694
|
-
toggleColorTheme: () => {
|
|
695
|
-
},
|
|
696
|
-
createColorThemeToggle: () => () => {
|
|
697
|
-
},
|
|
698
|
-
isColorThemeActive: () => false
|
|
699
|
-
};
|
|
700
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(NextUIThemeContext.Provider, { value: loadingContextValue, children: [
|
|
701
|
-
!disablePreHydrationScript && /* @__PURE__ */ jsxRuntime.jsx(
|
|
702
|
-
ThemePreHydrationScript,
|
|
703
|
-
{
|
|
704
|
-
storageKey,
|
|
705
|
-
colorStorageKey,
|
|
706
|
-
defaultTheme,
|
|
707
|
-
defaultColorTheme,
|
|
708
|
-
attribute,
|
|
709
|
-
globalClassName,
|
|
710
|
-
colorThemePrefix,
|
|
711
|
-
nonce
|
|
712
|
-
}
|
|
713
|
-
),
|
|
714
|
-
children
|
|
715
|
-
] });
|
|
716
|
-
}
|
|
717
|
-
const contextValue = {
|
|
718
|
-
ref: themeState.ref,
|
|
719
|
-
theme: themeState.theme,
|
|
720
|
-
colorTheme: themeState.colorTheme,
|
|
721
|
-
resolvedTheme: themeState.resolvedTheme,
|
|
722
|
-
systemTheme,
|
|
723
|
-
setTheme: themeState.setTheme,
|
|
724
|
-
setColorTheme: themeState.setColorTheme,
|
|
725
|
-
switchTheme: switchThemeWithHydrationAwareness,
|
|
726
|
-
switchThemeFromElement,
|
|
727
|
-
switchColorTheme: themeState.switchColorTheme,
|
|
728
|
-
toggleTheme: themeState.toggleTheme,
|
|
729
|
-
toggleLightTheme: themeState.toggleLightTheme,
|
|
730
|
-
toggleDarkTheme: themeState.toggleDarkTheme,
|
|
731
|
-
toggleColorTheme: themeState.toggleColorTheme,
|
|
732
|
-
createColorThemeToggle: themeState.createColorThemeToggle,
|
|
733
|
-
isColorThemeActive: themeState.isColorThemeActive
|
|
734
|
-
};
|
|
735
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(NextUIThemeContext.Provider, { value: contextValue, children: [
|
|
736
|
-
!disablePreHydrationScript && /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
|
-
ThemePreHydrationScript,
|
|
738
|
-
{
|
|
739
|
-
storageKey,
|
|
740
|
-
colorStorageKey,
|
|
741
|
-
defaultTheme,
|
|
742
|
-
defaultColorTheme,
|
|
743
|
-
attribute,
|
|
744
|
-
globalClassName,
|
|
745
|
-
colorThemePrefix,
|
|
746
|
-
nonce
|
|
747
|
-
}
|
|
748
|
-
),
|
|
749
|
-
children
|
|
750
|
-
] });
|
|
751
|
-
};
|
|
752
|
-
var useNextUITheme = () => {
|
|
753
|
-
const context = React.useContext(NextUIThemeContext);
|
|
754
|
-
if (context === void 0) {
|
|
755
|
-
throw new Error("useNextUITheme must be used within a NextUIThemeProvider");
|
|
756
|
-
}
|
|
757
|
-
return context;
|
|
758
|
-
};
|
|
759
|
-
var TanStackUIThemeContext = React.createContext(void 0);
|
|
760
|
-
var generateTanStackPreHydrationScript = (storageKey, colorStorageKey, defaultTheme, defaultColorTheme, globalClassName, colorThemePrefix, systemThemeMode) => {
|
|
761
|
-
return `
|
|
27
|
+
`,Ve=_t__namespace.default.memo(({storageKey:e,colorStorageKey:o,defaultTheme:n,defaultColorTheme:r,attribute:i,globalClassName:a,colorThemePrefix:l,nonce:g})=>{let u=Ht(e,o,n,r,i,a,l);return jsxRuntime.jsx("script",{nonce:g,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:u}})});Ve.displayName="ThemePreHydrationScript";var Ft=({children:e,themes:o=["light","dark","system"],colorThemes:n=["default"],defaultTheme:r="system",defaultColorTheme:i="default",animationType:a="circle",clipPathDirection:l,animationPosition:g,logo:u,logoLight:y,logoDark:b,logoWidth:U,logoHeight:V,gradientWidth:p,duration:R=400,storageKey:v=chunkW4YFUPGE_cjs.q,colorStorageKey:N=chunkW4YFUPGE_cjs.r,attribute:G="class",globalClassName:c=chunkW4YFUPGE_cjs.s,colorThemePrefix:w=chunkW4YFUPGE_cjs.t,nonce:k,disableAnimationOnInit:s=true,disablePreHydrationScript:C=false})=>{let z=W(),T=F({themes:o,colorThemes:n,defaultTheme:r,defaultColorTheme:i,animationType:a,clipPathDirection:l,animationPosition:g,...chunkV3LMT5IJ_cjs.c({logo:u,logoLight:y,logoDark:b}),logoWidth:U,logoHeight:V,gradientWidth:p,duration:R,storageKey:v,colorStorageKey:N,globalClassName:G==="class"?c:void 0,colorThemePrefix:w}),_=_t.useCallback(async(A,L=false)=>{!z&&s?T.setTheme(A):await T.switchTheme(A,L);},[z,s,T]),K=_t.useCallback((A,L)=>_(A,{element:L}),[_]),M=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(!z){let A={ref:{current:null},theme:r,colorTheme:i,resolvedTheme:r==="dark"?"dark":"light",systemTheme:"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsxRuntime.jsx(Fe.Provider,{value:A,children:jsxRuntime.jsxs(B.Provider,{value:A,children:[!C&&jsxRuntime.jsx(Ve,{storageKey:v,colorStorageKey:N,defaultTheme:r,defaultColorTheme:i,attribute:G,globalClassName:c,colorThemePrefix:w,nonce:k}),e]})})}let d={ref:T.ref,theme:T.theme,colorTheme:T.colorTheme,resolvedTheme:T.resolvedTheme,systemTheme:M,setTheme:T.setTheme,setColorTheme:T.setColorTheme,switchTheme:_,switchThemeFromElement:K,switchColorTheme:T.switchColorTheme,toggleTheme:T.toggleTheme,toggleLightTheme:T.toggleLightTheme,toggleDarkTheme:T.toggleDarkTheme,toggleColorTheme:T.toggleColorTheme,createColorThemeToggle:T.createColorThemeToggle,isColorThemeActive:T.isColorThemeActive};return jsxRuntime.jsx(Fe.Provider,{value:d,children:jsxRuntime.jsxs(B.Provider,{value:d,children:[!C&&jsxRuntime.jsx(Ve,{storageKey:v,colorStorageKey:N,defaultTheme:r,defaultColorTheme:i,attribute:G,globalClassName:c,colorThemePrefix:w,nonce:k}),e]})})},Vt=()=>{let e=_t.useContext(Fe);if(e===void 0)throw new Error("useNextUITheme must be used within a NextUIThemeProvider");return e};var $e=async(e,o,n)=>{try{await e?.(o);}catch(r){let i=r instanceof Error?r:new Error(String(r));try{n?n(i):console.error("Theme server notification failed:",i);}catch(a){console.error("Theme server error handler failed:",a);}}};var Be=_t.createContext(void 0),Wt=(e,o,n,r,i,a,l)=>`
|
|
762
28
|
(function() {
|
|
763
29
|
try {
|
|
764
|
-
var theme = localStorage.getItem(
|
|
765
|
-
var colorTheme = localStorage.getItem(
|
|
30
|
+
var theme = localStorage.getItem(${I(e)}) || ${I(n)};
|
|
31
|
+
var colorTheme = localStorage.getItem(${I(o)}) || ${I(r)};
|
|
766
32
|
var el = document.documentElement;
|
|
767
33
|
var resolved;
|
|
768
34
|
if (theme === 'system') {
|
|
769
|
-
if (
|
|
770
|
-
el.classList.remove(
|
|
35
|
+
if (${I(l)} === 'css') {
|
|
36
|
+
el.classList.remove(${I(i)});
|
|
771
37
|
el.classList.remove('auto');
|
|
772
38
|
el.classList.remove('system');
|
|
773
39
|
el.classList.add('system');
|
|
@@ -775,9 +41,9 @@ var generateTanStackPreHydrationScript = (storageKey, colorStorageKey, defaultTh
|
|
|
775
41
|
} else {
|
|
776
42
|
resolved = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
777
43
|
if (resolved === 'dark') {
|
|
778
|
-
el.classList.add(
|
|
44
|
+
el.classList.add(${I(i)});
|
|
779
45
|
} else {
|
|
780
|
-
el.classList.remove(
|
|
46
|
+
el.classList.remove(${I(i)});
|
|
781
47
|
}
|
|
782
48
|
el.classList.remove('system');
|
|
783
49
|
el.classList.remove('auto');
|
|
@@ -788,779 +54,28 @@ var generateTanStackPreHydrationScript = (storageKey, colorStorageKey, defaultTh
|
|
|
788
54
|
el.classList.remove('system');
|
|
789
55
|
el.classList.remove('auto');
|
|
790
56
|
if (resolved === 'dark') {
|
|
791
|
-
el.classList.add(
|
|
57
|
+
el.classList.add(${I(i)});
|
|
792
58
|
} else {
|
|
793
|
-
el.classList.remove(
|
|
59
|
+
el.classList.remove(${I(i)});
|
|
794
60
|
}
|
|
795
61
|
el.style.colorScheme = resolved;
|
|
796
62
|
}
|
|
797
63
|
if (colorTheme && colorTheme !== 'default') {
|
|
798
|
-
el.classList.add(
|
|
64
|
+
el.classList.add(${I(a)} + colorTheme);
|
|
799
65
|
}
|
|
800
66
|
} catch (e) {
|
|
801
67
|
console.warn('Theme pre-hydration script failed:', e);
|
|
802
68
|
}
|
|
803
69
|
})();
|
|
804
|
-
|
|
805
|
-
};
|
|
806
|
-
var TanStackStartThemeScript = React__default.default.memo(
|
|
807
|
-
({
|
|
808
|
-
storageKey = STORAGE_KEY,
|
|
809
|
-
colorStorageKey = COLOR_STORAGE_KEY,
|
|
810
|
-
defaultTheme = "system",
|
|
811
|
-
defaultColorTheme = "default",
|
|
812
|
-
globalClassName = GLOBAL_CLASS_NAME,
|
|
813
|
-
colorThemePrefix = COLOR_THEME_PREFIX,
|
|
814
|
-
nonce,
|
|
815
|
-
systemThemeMode = "js"
|
|
816
|
-
}) => {
|
|
817
|
-
const scriptContent = generateTanStackPreHydrationScript(
|
|
818
|
-
storageKey,
|
|
819
|
-
colorStorageKey,
|
|
820
|
-
defaultTheme,
|
|
821
|
-
defaultColorTheme,
|
|
822
|
-
globalClassName,
|
|
823
|
-
colorThemePrefix,
|
|
824
|
-
systemThemeMode
|
|
825
|
-
);
|
|
826
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
-
"script",
|
|
828
|
-
{
|
|
829
|
-
nonce,
|
|
830
|
-
suppressHydrationWarning: true,
|
|
831
|
-
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
832
|
-
}
|
|
833
|
-
);
|
|
834
|
-
}
|
|
835
|
-
);
|
|
836
|
-
TanStackStartThemeScript.displayName = "TanStackStartThemeScript";
|
|
837
|
-
var useHydrated = () => {
|
|
838
|
-
return React.useSyncExternalStore(
|
|
839
|
-
() => () => {
|
|
840
|
-
},
|
|
841
|
-
() => true,
|
|
842
|
-
() => false
|
|
843
|
-
);
|
|
844
|
-
};
|
|
845
|
-
var TanStackUIThemeProvider = ({
|
|
846
|
-
children,
|
|
847
|
-
themes = ["light", "dark", "system"],
|
|
848
|
-
colorThemes = ["default"],
|
|
849
|
-
defaultTheme = "system",
|
|
850
|
-
defaultColorTheme = "default",
|
|
851
|
-
animationType = "circle" /* CIRCLE */,
|
|
852
|
-
duration = 750,
|
|
853
|
-
storageKey = STORAGE_KEY,
|
|
854
|
-
colorStorageKey = COLOR_STORAGE_KEY,
|
|
855
|
-
globalClassName = GLOBAL_CLASS_NAME,
|
|
856
|
-
colorThemePrefix = COLOR_THEME_PREFIX,
|
|
857
|
-
serverTheme,
|
|
858
|
-
serverColorTheme,
|
|
859
|
-
systemThemeMode = "css",
|
|
860
|
-
onServerThemeChange,
|
|
861
|
-
onServerColorThemeChange
|
|
862
|
-
}) => {
|
|
863
|
-
const isHydrated = useHydrated();
|
|
864
|
-
const hasServerTheme = serverTheme !== void 0;
|
|
865
|
-
const initialTheme = hasServerTheme ? serverTheme === "system" ? "system" : serverTheme : void 0;
|
|
866
|
-
const themeState = useTheme({
|
|
867
|
-
themes,
|
|
868
|
-
colorThemes,
|
|
869
|
-
defaultTheme,
|
|
870
|
-
defaultColorTheme,
|
|
871
|
-
animationType,
|
|
872
|
-
duration,
|
|
873
|
-
storageKey,
|
|
874
|
-
colorStorageKey,
|
|
875
|
-
globalClassName,
|
|
876
|
-
colorThemePrefix,
|
|
877
|
-
systemThemeMode,
|
|
878
|
-
initialTheme,
|
|
879
|
-
initialColorTheme: serverColorTheme
|
|
880
|
-
});
|
|
881
|
-
React.useEffect(() => {
|
|
882
|
-
if (!hasServerTheme) return;
|
|
883
|
-
if (initialTheme) {
|
|
884
|
-
setStoredTheme(initialTheme, storageKey);
|
|
885
|
-
}
|
|
886
|
-
if (serverColorTheme) {
|
|
887
|
-
setStoredColorTheme(serverColorTheme, colorStorageKey);
|
|
888
|
-
}
|
|
889
|
-
}, []);
|
|
890
|
-
const setThemeWithServer = React.useCallback(
|
|
891
|
-
(newTheme) => {
|
|
892
|
-
themeState.setTheme(newTheme);
|
|
893
|
-
if (onServerThemeChange) {
|
|
894
|
-
onServerThemeChange(newTheme);
|
|
895
|
-
}
|
|
896
|
-
},
|
|
897
|
-
[themeState, onServerThemeChange]
|
|
898
|
-
);
|
|
899
|
-
const setColorThemeWithServer = React.useCallback(
|
|
900
|
-
(newColorTheme) => {
|
|
901
|
-
themeState.setColorTheme(newColorTheme);
|
|
902
|
-
if (onServerColorThemeChange) {
|
|
903
|
-
onServerColorThemeChange(newColorTheme);
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
[themeState, onServerColorThemeChange]
|
|
907
|
-
);
|
|
908
|
-
const switchThemeWithHydrationAwareness = React.useCallback(
|
|
909
|
-
async (theme, animationOff = false) => {
|
|
910
|
-
if (!isHydrated) {
|
|
911
|
-
setThemeWithServer(theme);
|
|
912
|
-
} else {
|
|
913
|
-
await themeState.switchTheme(theme, animationOff);
|
|
914
|
-
if (onServerThemeChange) {
|
|
915
|
-
onServerThemeChange(theme);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
},
|
|
919
|
-
[isHydrated, themeState, setThemeWithServer, onServerThemeChange]
|
|
920
|
-
);
|
|
921
|
-
const toggleThemeWithHydrationAwareness = React.useCallback(
|
|
922
|
-
async (animationOff = false) => {
|
|
923
|
-
if (!isHydrated) {
|
|
924
|
-
const nextTheme = themeState.resolvedTheme === "dark" ? "light" : "dark";
|
|
925
|
-
setThemeWithServer(nextTheme);
|
|
926
|
-
} else {
|
|
927
|
-
await themeState.toggleTheme(animationOff);
|
|
928
|
-
const nextTheme = themeState.resolvedTheme === "dark" ? "light" : "dark";
|
|
929
|
-
if (onServerThemeChange) {
|
|
930
|
-
onServerThemeChange(nextTheme);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
},
|
|
934
|
-
[isHydrated, themeState, setThemeWithServer, onServerThemeChange]
|
|
935
|
-
);
|
|
936
|
-
const toggleLightThemeWithHydrationAwareness = React.useCallback(
|
|
937
|
-
async (animationOff = false) => {
|
|
938
|
-
if (!isHydrated) {
|
|
939
|
-
setThemeWithServer("light");
|
|
940
|
-
} else {
|
|
941
|
-
await themeState.toggleLightTheme(animationOff);
|
|
942
|
-
if (onServerThemeChange) {
|
|
943
|
-
onServerThemeChange("light");
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
},
|
|
947
|
-
[isHydrated, themeState, setThemeWithServer, onServerThemeChange]
|
|
948
|
-
);
|
|
949
|
-
const toggleDarkThemeWithHydrationAwareness = React.useCallback(
|
|
950
|
-
async (animationOff = false) => {
|
|
951
|
-
if (!isHydrated) {
|
|
952
|
-
setThemeWithServer("dark");
|
|
953
|
-
} else {
|
|
954
|
-
await themeState.toggleDarkTheme(animationOff);
|
|
955
|
-
if (onServerThemeChange) {
|
|
956
|
-
onServerThemeChange("dark");
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
},
|
|
960
|
-
[isHydrated, themeState, setThemeWithServer, onServerThemeChange]
|
|
961
|
-
);
|
|
962
|
-
const switchColorThemeWithServer = React.useCallback(
|
|
963
|
-
(newColorTheme) => {
|
|
964
|
-
themeState.switchColorTheme(newColorTheme);
|
|
965
|
-
if (onServerColorThemeChange) {
|
|
966
|
-
onServerColorThemeChange(newColorTheme);
|
|
967
|
-
}
|
|
968
|
-
},
|
|
969
|
-
[themeState, onServerColorThemeChange]
|
|
970
|
-
);
|
|
971
|
-
const switchThemeFromElement = React.useCallback(
|
|
972
|
-
async (theme, element) => {
|
|
973
|
-
if (!isHydrated) {
|
|
974
|
-
setThemeWithServer(theme);
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
if (themeState.ref.current) {
|
|
978
|
-
const originalRef = themeState.ref.current;
|
|
979
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
980
|
-
value: element,
|
|
981
|
-
writable: true,
|
|
982
|
-
configurable: true
|
|
983
|
-
});
|
|
984
|
-
await themeState.switchTheme(theme);
|
|
985
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
986
|
-
value: originalRef,
|
|
987
|
-
writable: true,
|
|
988
|
-
configurable: true
|
|
989
|
-
});
|
|
990
|
-
} else {
|
|
991
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
992
|
-
value: element,
|
|
993
|
-
writable: true,
|
|
994
|
-
configurable: true
|
|
995
|
-
});
|
|
996
|
-
await themeState.switchTheme(theme);
|
|
997
|
-
}
|
|
998
|
-
if (onServerThemeChange) {
|
|
999
|
-
onServerThemeChange(theme);
|
|
1000
|
-
}
|
|
1001
|
-
},
|
|
1002
|
-
[isHydrated, themeState, setThemeWithServer, onServerThemeChange]
|
|
1003
|
-
);
|
|
1004
|
-
const systemTheme = typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1005
|
-
const serverResolvedTheme = (() => {
|
|
1006
|
-
if (hasServerTheme) {
|
|
1007
|
-
if (serverTheme === "dark") return "dark";
|
|
1008
|
-
if (serverTheme === "system") return systemTheme;
|
|
1009
|
-
return "light";
|
|
1010
|
-
}
|
|
1011
|
-
return defaultTheme === "dark" ? "dark" : "light";
|
|
1012
|
-
})();
|
|
1013
|
-
if (!isHydrated) {
|
|
1014
|
-
const loadingContextValue = {
|
|
1015
|
-
ref: { current: null },
|
|
1016
|
-
theme: initialTheme ?? defaultTheme,
|
|
1017
|
-
colorTheme: serverColorTheme ?? defaultColorTheme,
|
|
1018
|
-
resolvedTheme: serverResolvedTheme,
|
|
1019
|
-
systemTheme: "light",
|
|
1020
|
-
isHydrated: false,
|
|
1021
|
-
setTheme: setThemeWithServer,
|
|
1022
|
-
setColorTheme: setColorThemeWithServer,
|
|
1023
|
-
switchTheme: async (theme) => setThemeWithServer(theme),
|
|
1024
|
-
switchThemeFromElement: async (theme) => setThemeWithServer(theme),
|
|
1025
|
-
switchColorTheme: switchColorThemeWithServer,
|
|
1026
|
-
toggleTheme: async () => {
|
|
1027
|
-
const nextTheme = serverResolvedTheme === "dark" ? "light" : "dark";
|
|
1028
|
-
setThemeWithServer(nextTheme);
|
|
1029
|
-
},
|
|
1030
|
-
toggleLightTheme: async () => setThemeWithServer("light"),
|
|
1031
|
-
toggleDarkTheme: async () => setThemeWithServer("dark"),
|
|
1032
|
-
toggleColorTheme: themeState.toggleColorTheme,
|
|
1033
|
-
createColorThemeToggle: themeState.createColorThemeToggle,
|
|
1034
|
-
isColorThemeActive: themeState.isColorThemeActive
|
|
1035
|
-
};
|
|
1036
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TanStackUIThemeContext.Provider, { value: loadingContextValue, children });
|
|
1037
|
-
}
|
|
1038
|
-
const contextValue = {
|
|
1039
|
-
ref: themeState.ref,
|
|
1040
|
-
theme: themeState.theme,
|
|
1041
|
-
colorTheme: themeState.colorTheme,
|
|
1042
|
-
resolvedTheme: themeState.resolvedTheme,
|
|
1043
|
-
systemTheme,
|
|
1044
|
-
isHydrated: true,
|
|
1045
|
-
setTheme: setThemeWithServer,
|
|
1046
|
-
setColorTheme: setColorThemeWithServer,
|
|
1047
|
-
switchTheme: switchThemeWithHydrationAwareness,
|
|
1048
|
-
switchThemeFromElement,
|
|
1049
|
-
switchColorTheme: switchColorThemeWithServer,
|
|
1050
|
-
toggleTheme: toggleThemeWithHydrationAwareness,
|
|
1051
|
-
toggleLightTheme: toggleLightThemeWithHydrationAwareness,
|
|
1052
|
-
toggleDarkTheme: toggleDarkThemeWithHydrationAwareness,
|
|
1053
|
-
toggleColorTheme: themeState.toggleColorTheme,
|
|
1054
|
-
createColorThemeToggle: themeState.createColorThemeToggle,
|
|
1055
|
-
isColorThemeActive: themeState.isColorThemeActive
|
|
1056
|
-
};
|
|
1057
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TanStackUIThemeContext.Provider, { value: contextValue, children });
|
|
1058
|
-
};
|
|
1059
|
-
var useTanStackUITheme = () => {
|
|
1060
|
-
const context = React.useContext(TanStackUIThemeContext);
|
|
1061
|
-
if (context === void 0) {
|
|
1062
|
-
throw new Error(
|
|
1063
|
-
"useTanStackUITheme must be used within a TanStackUIThemeProvider"
|
|
1064
|
-
);
|
|
1065
|
-
}
|
|
1066
|
-
return context;
|
|
1067
|
-
};
|
|
1068
|
-
var ViteUIThemeContext = React.createContext(
|
|
1069
|
-
void 0
|
|
1070
|
-
);
|
|
1071
|
-
var ViteUIThemeProvider = ({
|
|
1072
|
-
children,
|
|
1073
|
-
themes = ["light", "dark", "system"],
|
|
1074
|
-
colorThemes = ["default"],
|
|
1075
|
-
defaultTheme = "system",
|
|
1076
|
-
defaultColorTheme = "default",
|
|
1077
|
-
animationType = "circle" /* CIRCLE */,
|
|
1078
|
-
duration = 750,
|
|
1079
|
-
attribute = "class",
|
|
1080
|
-
disableTransitionOnChange = false,
|
|
1081
|
-
storageKey = "ui-theme",
|
|
1082
|
-
colorStorageKey = "ui-color-theme",
|
|
1083
|
-
globalClassName = "dark",
|
|
1084
|
-
colorThemePrefix = "theme-"
|
|
1085
|
-
}) => {
|
|
1086
|
-
const themeState = useTheme({
|
|
1087
|
-
themes,
|
|
1088
|
-
colorThemes,
|
|
1089
|
-
defaultTheme,
|
|
1090
|
-
defaultColorTheme,
|
|
1091
|
-
animationType,
|
|
1092
|
-
duration,
|
|
1093
|
-
storageKey,
|
|
1094
|
-
colorStorageKey,
|
|
1095
|
-
globalClassName: attribute === "class" ? globalClassName : void 0,
|
|
1096
|
-
colorThemePrefix
|
|
1097
|
-
});
|
|
1098
|
-
const applyTransitionDisable = React.useCallback(() => {
|
|
1099
|
-
if (!disableTransitionOnChange) return () => {
|
|
1100
|
-
};
|
|
1101
|
-
const css = document.createElement("style");
|
|
1102
|
-
css.textContent = `*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;
|
|
1103
|
-
document.head.appendChild(css);
|
|
1104
|
-
window.getComputedStyle(document.body);
|
|
1105
|
-
return () => {
|
|
1106
|
-
setTimeout(() => {
|
|
1107
|
-
document.head.removeChild(css);
|
|
1108
|
-
}, 1);
|
|
1109
|
-
};
|
|
1110
|
-
}, [disableTransitionOnChange]);
|
|
1111
|
-
const wrappedSetTheme = React.useCallback(
|
|
1112
|
-
(theme) => {
|
|
1113
|
-
const cleanup = applyTransitionDisable();
|
|
1114
|
-
themeState.setTheme(theme);
|
|
1115
|
-
cleanup();
|
|
1116
|
-
},
|
|
1117
|
-
[themeState.setTheme, applyTransitionDisable]
|
|
1118
|
-
);
|
|
1119
|
-
const wrappedSwitchTheme = React.useCallback(
|
|
1120
|
-
async (theme, animationOff = false) => {
|
|
1121
|
-
const cleanup = applyTransitionDisable();
|
|
1122
|
-
await themeState.switchTheme(theme, animationOff);
|
|
1123
|
-
cleanup();
|
|
1124
|
-
},
|
|
1125
|
-
[themeState.switchTheme, applyTransitionDisable]
|
|
1126
|
-
);
|
|
1127
|
-
const wrappedToggleTheme = React.useCallback(
|
|
1128
|
-
async (animationOff = false) => {
|
|
1129
|
-
const cleanup = applyTransitionDisable();
|
|
1130
|
-
await themeState.toggleTheme(animationOff);
|
|
1131
|
-
cleanup();
|
|
1132
|
-
},
|
|
1133
|
-
[themeState.toggleTheme, applyTransitionDisable]
|
|
1134
|
-
);
|
|
1135
|
-
const wrappedToggleLightTheme = React.useCallback(
|
|
1136
|
-
async (animationOff = false) => {
|
|
1137
|
-
const cleanup = applyTransitionDisable();
|
|
1138
|
-
await themeState.toggleLightTheme(animationOff);
|
|
1139
|
-
cleanup();
|
|
1140
|
-
},
|
|
1141
|
-
[themeState.toggleLightTheme, applyTransitionDisable]
|
|
1142
|
-
);
|
|
1143
|
-
const wrappedToggleDarkTheme = React.useCallback(
|
|
1144
|
-
async (animationOff = false) => {
|
|
1145
|
-
const cleanup = applyTransitionDisable();
|
|
1146
|
-
await themeState.toggleDarkTheme(animationOff);
|
|
1147
|
-
cleanup();
|
|
1148
|
-
},
|
|
1149
|
-
[themeState.toggleDarkTheme, applyTransitionDisable]
|
|
1150
|
-
);
|
|
1151
|
-
const switchThemeFromElement = async (theme, element) => {
|
|
1152
|
-
const cleanup = applyTransitionDisable();
|
|
1153
|
-
if (themeState.ref.current) {
|
|
1154
|
-
const originalRef = themeState.ref.current;
|
|
1155
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1156
|
-
value: element,
|
|
1157
|
-
writable: true,
|
|
1158
|
-
configurable: true
|
|
1159
|
-
});
|
|
1160
|
-
await themeState.switchTheme(theme);
|
|
1161
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1162
|
-
value: originalRef,
|
|
1163
|
-
writable: true,
|
|
1164
|
-
configurable: true
|
|
1165
|
-
});
|
|
1166
|
-
} else {
|
|
1167
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1168
|
-
value: element,
|
|
1169
|
-
writable: true,
|
|
1170
|
-
configurable: true
|
|
1171
|
-
});
|
|
1172
|
-
await themeState.switchTheme(theme);
|
|
1173
|
-
}
|
|
1174
|
-
cleanup();
|
|
1175
|
-
};
|
|
1176
|
-
const systemTheme = getSystemTheme();
|
|
1177
|
-
const contextValue = {
|
|
1178
|
-
ref: themeState.ref,
|
|
1179
|
-
theme: themeState.theme,
|
|
1180
|
-
colorTheme: themeState.colorTheme,
|
|
1181
|
-
resolvedTheme: themeState.resolvedTheme,
|
|
1182
|
-
systemTheme,
|
|
1183
|
-
setTheme: wrappedSetTheme,
|
|
1184
|
-
setColorTheme: themeState.setColorTheme,
|
|
1185
|
-
switchTheme: wrappedSwitchTheme,
|
|
1186
|
-
switchThemeFromElement,
|
|
1187
|
-
switchColorTheme: themeState.switchColorTheme,
|
|
1188
|
-
toggleTheme: wrappedToggleTheme,
|
|
1189
|
-
toggleLightTheme: wrappedToggleLightTheme,
|
|
1190
|
-
toggleDarkTheme: wrappedToggleDarkTheme,
|
|
1191
|
-
toggleColorTheme: themeState.toggleColorTheme,
|
|
1192
|
-
createColorThemeToggle: themeState.createColorThemeToggle,
|
|
1193
|
-
isColorThemeActive: themeState.isColorThemeActive
|
|
1194
|
-
};
|
|
1195
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ViteUIThemeContext.Provider, { value: contextValue, children });
|
|
1196
|
-
};
|
|
1197
|
-
var useViteUITheme = () => {
|
|
1198
|
-
const context = React.useContext(ViteUIThemeContext);
|
|
1199
|
-
if (context === void 0) {
|
|
1200
|
-
throw new Error("useViteUITheme must be used within a ViteUIThemeProvider");
|
|
1201
|
-
}
|
|
1202
|
-
return context;
|
|
1203
|
-
};
|
|
1204
|
-
var UIThemeContext = React.createContext(void 0);
|
|
1205
|
-
var UIThemeProvider = ({
|
|
1206
|
-
children,
|
|
1207
|
-
themes = ["light", "dark", "system"],
|
|
1208
|
-
colorThemes = ["default"],
|
|
1209
|
-
defaultTheme = "system",
|
|
1210
|
-
defaultColorTheme = "default",
|
|
1211
|
-
animationType = "circle" /* CIRCLE */,
|
|
1212
|
-
duration = 750,
|
|
1213
|
-
storageKey,
|
|
1214
|
-
colorStorageKey
|
|
1215
|
-
}) => {
|
|
1216
|
-
const [mounted, setMounted] = React.useState(false);
|
|
1217
|
-
const themeState = useTheme({
|
|
1218
|
-
themes,
|
|
1219
|
-
colorThemes,
|
|
1220
|
-
defaultTheme,
|
|
1221
|
-
defaultColorTheme,
|
|
1222
|
-
animationType,
|
|
1223
|
-
duration,
|
|
1224
|
-
storageKey,
|
|
1225
|
-
colorStorageKey
|
|
1226
|
-
});
|
|
1227
|
-
React.useEffect(() => {
|
|
1228
|
-
setMounted(true);
|
|
1229
|
-
}, []);
|
|
1230
|
-
const switchThemeFromElement = async (theme, element) => {
|
|
1231
|
-
if (themeState.ref.current) {
|
|
1232
|
-
const originalRef = themeState.ref.current;
|
|
1233
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1234
|
-
value: element,
|
|
1235
|
-
writable: true,
|
|
1236
|
-
configurable: true
|
|
1237
|
-
});
|
|
1238
|
-
await themeState.switchTheme(theme);
|
|
1239
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1240
|
-
value: originalRef,
|
|
1241
|
-
writable: true,
|
|
1242
|
-
configurable: true
|
|
1243
|
-
});
|
|
1244
|
-
} else {
|
|
1245
|
-
Object.defineProperty(themeState.ref, "current", {
|
|
1246
|
-
value: element,
|
|
1247
|
-
writable: true,
|
|
1248
|
-
configurable: true
|
|
1249
|
-
});
|
|
1250
|
-
await themeState.switchTheme(theme);
|
|
1251
|
-
}
|
|
1252
|
-
};
|
|
1253
|
-
if (!mounted) {
|
|
1254
|
-
const loadingContextValue = {
|
|
1255
|
-
ref: { current: null },
|
|
1256
|
-
theme: defaultTheme,
|
|
1257
|
-
colorTheme: defaultColorTheme,
|
|
1258
|
-
resolvedTheme: defaultTheme === "dark" ? "dark" : "light",
|
|
1259
|
-
setTheme: () => {
|
|
1260
|
-
},
|
|
1261
|
-
setColorTheme: () => {
|
|
1262
|
-
},
|
|
1263
|
-
switchTheme: async () => {
|
|
1264
|
-
},
|
|
1265
|
-
switchThemeFromElement: async () => {
|
|
1266
|
-
},
|
|
1267
|
-
switchColorTheme: () => {
|
|
1268
|
-
},
|
|
1269
|
-
toggleTheme: async () => {
|
|
1270
|
-
},
|
|
1271
|
-
toggleLightTheme: async () => {
|
|
1272
|
-
},
|
|
1273
|
-
toggleDarkTheme: async () => {
|
|
1274
|
-
},
|
|
1275
|
-
toggleColorTheme: () => {
|
|
1276
|
-
},
|
|
1277
|
-
createColorThemeToggle: () => () => {
|
|
1278
|
-
},
|
|
1279
|
-
isColorThemeActive: () => false
|
|
1280
|
-
};
|
|
1281
|
-
return /* @__PURE__ */ jsxRuntime.jsx(UIThemeContext.Provider, { value: loadingContextValue, children });
|
|
1282
|
-
}
|
|
1283
|
-
const contextValue = {
|
|
1284
|
-
ref: themeState.ref,
|
|
1285
|
-
theme: themeState.theme,
|
|
1286
|
-
colorTheme: themeState.colorTheme,
|
|
1287
|
-
resolvedTheme: themeState.resolvedTheme,
|
|
1288
|
-
setTheme: themeState.setTheme,
|
|
1289
|
-
setColorTheme: themeState.setColorTheme,
|
|
1290
|
-
switchTheme: themeState.switchTheme,
|
|
1291
|
-
switchThemeFromElement,
|
|
1292
|
-
switchColorTheme: themeState.switchColorTheme,
|
|
1293
|
-
toggleTheme: themeState.toggleTheme,
|
|
1294
|
-
toggleLightTheme: themeState.toggleLightTheme,
|
|
1295
|
-
toggleDarkTheme: themeState.toggleDarkTheme,
|
|
1296
|
-
toggleColorTheme: themeState.toggleColorTheme,
|
|
1297
|
-
createColorThemeToggle: themeState.createColorThemeToggle,
|
|
1298
|
-
isColorThemeActive: themeState.isColorThemeActive
|
|
1299
|
-
};
|
|
1300
|
-
return /* @__PURE__ */ jsxRuntime.jsx(UIThemeContext.Provider, { value: contextValue, children });
|
|
1301
|
-
};
|
|
1302
|
-
var useUITheme = () => {
|
|
1303
|
-
const context = React.useContext(UIThemeContext);
|
|
1304
|
-
if (context === void 0) {
|
|
1305
|
-
throw new Error("useUITheme must be used within a UIThemeProvider");
|
|
1306
|
-
}
|
|
1307
|
-
return context;
|
|
1308
|
-
};
|
|
1309
|
-
var SunIcon = () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1310
|
-
"svg",
|
|
1311
|
-
{
|
|
1312
|
-
width: "16",
|
|
1313
|
-
height: "16",
|
|
1314
|
-
viewBox: "0 0 24 24",
|
|
1315
|
-
fill: "none",
|
|
1316
|
-
stroke: "currentColor",
|
|
1317
|
-
strokeWidth: "2",
|
|
1318
|
-
strokeLinecap: "round",
|
|
1319
|
-
strokeLinejoin: "round",
|
|
1320
|
-
children: [
|
|
1321
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "5" }),
|
|
1322
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" })
|
|
1323
|
-
]
|
|
1324
|
-
}
|
|
1325
|
-
);
|
|
1326
|
-
var MoonIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1327
|
-
"svg",
|
|
1328
|
-
{
|
|
1329
|
-
width: "16",
|
|
1330
|
-
height: "16",
|
|
1331
|
-
viewBox: "0 0 24 24",
|
|
1332
|
-
fill: "none",
|
|
1333
|
-
stroke: "currentColor",
|
|
1334
|
-
strokeWidth: "2",
|
|
1335
|
-
strokeLinecap: "round",
|
|
1336
|
-
strokeLinejoin: "round",
|
|
1337
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" })
|
|
1338
|
-
}
|
|
1339
|
-
);
|
|
1340
|
-
var MonitorIcon = () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1341
|
-
"svg",
|
|
1342
|
-
{
|
|
1343
|
-
width: "16",
|
|
1344
|
-
height: "16",
|
|
1345
|
-
viewBox: "0 0 24 24",
|
|
1346
|
-
fill: "none",
|
|
1347
|
-
stroke: "currentColor",
|
|
1348
|
-
strokeWidth: "2",
|
|
1349
|
-
strokeLinecap: "round",
|
|
1350
|
-
strokeLinejoin: "round",
|
|
1351
|
-
children: [
|
|
1352
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "20", height: "14", x: "2", y: "3", rx: "2" }),
|
|
1353
|
-
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", x2: "16", y1: "21", y2: "21" }),
|
|
1354
|
-
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", x2: "12", y1: "17", y2: "21" })
|
|
1355
|
-
]
|
|
1356
|
-
}
|
|
1357
|
-
);
|
|
1358
|
-
var ThemeOption = ({
|
|
1359
|
-
icon,
|
|
1360
|
-
value,
|
|
1361
|
-
isActive,
|
|
1362
|
-
isHovered,
|
|
1363
|
-
onClick,
|
|
1364
|
-
onMouseEnter,
|
|
1365
|
-
onMouseLeave,
|
|
1366
|
-
buttonRef
|
|
1367
|
-
}) => {
|
|
1368
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1369
|
-
"button",
|
|
1370
|
-
{
|
|
1371
|
-
ref: isActive ? buttonRef : void 0,
|
|
1372
|
-
className: `
|
|
70
|
+
`,st=_t__namespace.default.memo(({storageKey:e=chunkW4YFUPGE_cjs.q,colorStorageKey:o=chunkW4YFUPGE_cjs.r,defaultTheme:n="system",defaultColorTheme:r="default",globalClassName:i=chunkW4YFUPGE_cjs.s,colorThemePrefix:a=chunkW4YFUPGE_cjs.t,nonce:l,systemThemeMode:g="js"})=>{let u=Wt(e,o,n,r,i,a,g);return jsxRuntime.jsx("script",{nonce:l,suppressHydrationWarning:true,dangerouslySetInnerHTML:{__html:u}})});st.displayName="TanStackStartThemeScript";var Yt=({children:e,themes:o=["light","dark","system"],colorThemes:n=["default"],defaultTheme:r="system",defaultColorTheme:i="default",animationType:a="circle",clipPathDirection:l,animationPosition:g,logo:u,logoLight:y,logoDark:b,logoWidth:U,logoHeight:V,gradientWidth:p,duration:R=400,storageKey:v=chunkW4YFUPGE_cjs.q,colorStorageKey:N=chunkW4YFUPGE_cjs.r,globalClassName:G=chunkW4YFUPGE_cjs.s,colorThemePrefix:c=chunkW4YFUPGE_cjs.t,serverTheme:w,serverColorTheme:k,systemThemeMode:s="css",onServerThemeChange:C,onServerColorThemeChange:z,onServerError:T})=>{let _=W(),K=w!==void 0,M=K?w==="system"?"system":w:void 0,d=F({themes:o,colorThemes:n,defaultTheme:r,defaultColorTheme:i,animationType:a,clipPathDirection:l,animationPosition:g,...chunkV3LMT5IJ_cjs.c({logo:u,logoLight:y,logoDark:b}),logoWidth:U,logoHeight:V,gradientWidth:p,duration:R,storageKey:v,colorStorageKey:N,globalClassName:G,colorThemePrefix:c,systemThemeMode:s,initialTheme:M,initialColorTheme:k,onThemeChange:h=>{$e(C,h,T);},onColorThemeChange:h=>{$e(z,h,T);}}),A=_t.useRef(false);_t.useEffect(()=>{if(!(!K||!_||A.current)){A.current=true;try{M&&chunkV3LMT5IJ_cjs.g(M,v),k&&chunkV3LMT5IJ_cjs.i(k,N);}catch(h){console.warn("Unable to persist the initial server theme:",h);}}},[K,_,M,k,v,N]);let L=d.setTheme,S=d.setColorTheme,x=(h=false)=>_?h:h===true||h===false?true:{...h,animationOff:true},oe=(h,O)=>d.switchTheme(h,x(O)),se=h=>d.toggleTheme(x(h)),pe=h=>d.toggleLightTheme(x(h)),Le=h=>d.toggleDarkTheme(x(h)),ge=(h,O)=>d.switchColorTheme(h,x(O)),Ee=(h,O)=>oe(h,{element:O}),fe=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",$=K?w==="dark"?"dark":w==="system"?fe:"light":r==="dark"?"dark":"light";if(!_){let h={ref:{current:null},theme:M??r,colorTheme:k??i,resolvedTheme:$,systemTheme:"light",isHydrated:false,setTheme:L,setColorTheme:S,switchTheme:async O=>L(O),switchThemeFromElement:async O=>L(O),switchColorTheme:ge,toggleTheme:async()=>{L($==="dark"?"light":"dark");},toggleLightTheme:async()=>L("light"),toggleDarkTheme:async()=>L("dark"),toggleColorTheme:d.toggleColorTheme,createColorThemeToggle:d.createColorThemeToggle,isColorThemeActive:d.isColorThemeActive};return jsxRuntime.jsx(Be.Provider,{value:h,children:jsxRuntime.jsx(B.Provider,{value:h,children:e})})}let D={ref:d.ref,theme:d.theme,colorTheme:d.colorTheme,resolvedTheme:d.resolvedTheme,systemTheme:fe,isHydrated:true,setTheme:L,setColorTheme:S,switchTheme:oe,switchThemeFromElement:Ee,switchColorTheme:ge,toggleTheme:se,toggleLightTheme:pe,toggleDarkTheme:Le,toggleColorTheme:d.toggleColorTheme,createColorThemeToggle:d.createColorThemeToggle,isColorThemeActive:d.isColorThemeActive};return jsxRuntime.jsx(Be.Provider,{value:D,children:jsxRuntime.jsx(B.Provider,{value:D,children:e})})},jt=()=>{let e=_t.useContext(Be);if(e===void 0)throw new Error("useTanStackUITheme must be used within a TanStackUIThemeProvider");return e};var at=_t.createContext(void 0),qt=({children:e,themes:o=["light","dark","system"],colorThemes:n=["default"],defaultTheme:r="system",defaultColorTheme:i="default",animationType:a="circle",clipPathDirection:l,animationPosition:g,logo:u,logoLight:y,logoDark:b,logoWidth:U,logoHeight:V,gradientWidth:p,duration:R=400,attribute:v="class",disableTransitionOnChange:N=false,storageKey:G="ui-theme",colorStorageKey:c="ui-color-theme",globalClassName:w="dark",colorThemePrefix:k="theme-"})=>{let s=F({themes:o,colorThemes:n,defaultTheme:r,defaultColorTheme:i,animationType:a,clipPathDirection:l,animationPosition:g,...chunkV3LMT5IJ_cjs.c({logo:u,logoLight:y,logoDark:b}),logoWidth:U,logoHeight:V,gradientWidth:p,duration:R,storageKey:G,colorStorageKey:c,globalClassName:v==="class"?w:void 0,colorThemePrefix:k}),C=_t.useCallback(()=>{if(!N)return ()=>{};let S=document.createElement("style");return S.textContent="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}",document.head.appendChild(S),window.getComputedStyle(document.body),()=>{setTimeout(()=>{document.head.removeChild(S);},1);}},[N]),z=_t.useCallback(S=>{let x=C();s.setTheme(S),x();},[s,C]),T=_t.useCallback(async(S,x=false)=>{let oe=C();try{await s.switchTheme(S,x);}finally{oe();}},[s,C]),_=_t.useCallback(async(S=false)=>{let x=C();try{await s.toggleTheme(S);}finally{x();}},[s,C]),K=_t.useCallback(async(S=false)=>{let x=C();try{await s.toggleLightTheme(S);}finally{x();}},[s,C]),M=_t.useCallback(async(S=false)=>{let x=C();try{await s.toggleDarkTheme(S);}finally{x();}},[s,C]),d=(S,x)=>T(S,{element:x}),A=chunkW4YFUPGE_cjs.c(),L={ref:s.ref,theme:s.theme,colorTheme:s.colorTheme,resolvedTheme:s.resolvedTheme,systemTheme:A,setTheme:z,setColorTheme:s.setColorTheme,switchTheme:T,switchThemeFromElement:d,switchColorTheme:s.switchColorTheme,toggleTheme:_,toggleLightTheme:K,toggleDarkTheme:M,toggleColorTheme:s.toggleColorTheme,createColorThemeToggle:s.createColorThemeToggle,isColorThemeActive:s.isColorThemeActive};return jsxRuntime.jsx(at.Provider,{value:L,children:jsxRuntime.jsx(B.Provider,{value:L,children:e})})},Qt=()=>{let e=_t.useContext(at);if(e===void 0)throw new Error("useViteUITheme must be used within a ViteUIThemeProvider");return e};var Ge=_t.createContext(void 0),to=({children:e,themes:o=["light","dark","system"],colorThemes:n=["default"],defaultTheme:r="system",defaultColorTheme:i="default",animationType:a="circle",clipPathDirection:l,animationPosition:g,logo:u,logoLight:y,logoDark:b,logoWidth:U,logoHeight:V,gradientWidth:p,duration:R=400,storageKey:v,colorStorageKey:N})=>{let G=W(),c=F({themes:o,colorThemes:n,defaultTheme:r,defaultColorTheme:i,animationType:a,clipPathDirection:l,animationPosition:g,...chunkV3LMT5IJ_cjs.c({logo:u,logoLight:y,logoDark:b}),logoWidth:U,logoHeight:V,gradientWidth:p,duration:R,storageKey:v,colorStorageKey:N}),w=(s,C)=>c.switchTheme(s,{element:C});if(!G){let s={ref:{current:null},theme:r,colorTheme:i,resolvedTheme:r==="dark"?"dark":"light",setTheme:()=>{},setColorTheme:()=>{},switchTheme:async()=>{},switchThemeFromElement:async()=>{},switchColorTheme:async()=>{},toggleTheme:async()=>{},toggleLightTheme:async()=>{},toggleDarkTheme:async()=>{},toggleColorTheme:async()=>{},createColorThemeToggle:()=>async()=>{},isColorThemeActive:()=>false};return jsxRuntime.jsx(Ge.Provider,{value:s,children:jsxRuntime.jsx(B.Provider,{value:s,children:e})})}let k={ref:c.ref,theme:c.theme,colorTheme:c.colorTheme,resolvedTheme:c.resolvedTheme,setTheme:c.setTheme,setColorTheme:c.setColorTheme,switchTheme:c.switchTheme,switchThemeFromElement:w,switchColorTheme:c.switchColorTheme,toggleTheme:c.toggleTheme,toggleLightTheme:c.toggleLightTheme,toggleDarkTheme:c.toggleDarkTheme,toggleColorTheme:c.toggleColorTheme,createColorThemeToggle:c.createColorThemeToggle,isColorThemeActive:c.isColorThemeActive};return jsxRuntime.jsx(Ge.Provider,{value:k,children:jsxRuntime.jsx(B.Provider,{value:k,children:e})})},oo=()=>{let e=_t.useContext(Ge);if(e===void 0)throw new Error("useUITheme must be used within a UIThemeProvider");return e};var no=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5"}),jsxRuntime.jsx("path",{d:"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"})]}),io=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),so=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),jsxRuntime.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),jsxRuntime.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),mo=({icon:e,value:o,isActive:n,isHovered:r,onClick:i,onMouseEnter:a,onMouseLeave:l,buttonRef:g})=>jsxRuntime.jsxs("button",{ref:n?g:void 0,className:`
|
|
1373
71
|
relative flex h-9 w-12 cursor-pointer items-center justify-center
|
|
1374
72
|
text-muted-foreground hover:text-foreground
|
|
1375
|
-
${
|
|
1376
|
-
`,
|
|
1377
|
-
role: "radio",
|
|
1378
|
-
"aria-checked": isActive,
|
|
1379
|
-
"aria-label": `Switch to ${value} theme`,
|
|
1380
|
-
onClick: (event) => onClick(value, event),
|
|
1381
|
-
onMouseEnter,
|
|
1382
|
-
onMouseLeave,
|
|
1383
|
-
style: {
|
|
1384
|
-
borderRadius: "var(--radius)"
|
|
1385
|
-
},
|
|
1386
|
-
children: [
|
|
1387
|
-
isHovered && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1388
|
-
"div",
|
|
1389
|
-
{
|
|
1390
|
-
className: "absolute inset-0 bg-muted",
|
|
1391
|
-
style: {
|
|
1392
|
-
borderRadius: "var(--radius)",
|
|
1393
|
-
transition: "all 0.2s ease"
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
),
|
|
1397
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative z-10 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "[&_svg]:size-4", children: icon }) }),
|
|
1398
|
-
isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1399
|
-
"div",
|
|
1400
|
-
{
|
|
1401
|
-
className: "absolute bottom-0 left-1/2 h-0.5 w-6 -translate-x-1/2 rounded-full",
|
|
1402
|
-
style: {
|
|
1403
|
-
backgroundColor: "hsl(var(--primary))"
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
)
|
|
1407
|
-
]
|
|
1408
|
-
}
|
|
1409
|
-
);
|
|
1410
|
-
};
|
|
1411
|
-
var THEME_OPTIONS = [
|
|
1412
|
-
{ icon: /* @__PURE__ */ jsxRuntime.jsx(MonitorIcon, {}), value: "system" },
|
|
1413
|
-
{ icon: /* @__PURE__ */ jsxRuntime.jsx(SunIcon, {}), value: "light" },
|
|
1414
|
-
{ icon: /* @__PURE__ */ jsxRuntime.jsx(MoonIcon, {}), value: "dark" }
|
|
1415
|
-
];
|
|
1416
|
-
var UIThemeSwitcher = ({
|
|
1417
|
-
themes = ["light", "dark", "system"],
|
|
1418
|
-
currentTheme,
|
|
1419
|
-
onThemeChange,
|
|
1420
|
-
animationType,
|
|
1421
|
-
duration,
|
|
1422
|
-
className
|
|
1423
|
-
}) => {
|
|
1424
|
-
let contextTheme = null;
|
|
1425
|
-
try {
|
|
1426
|
-
contextTheme = useUITheme();
|
|
1427
|
-
} catch {
|
|
1428
|
-
}
|
|
1429
|
-
const standaloneHook = useTheme({
|
|
1430
|
-
animationType,
|
|
1431
|
-
duration,
|
|
1432
|
-
themes,
|
|
1433
|
-
...currentTheme !== void 0 && { theme: currentTheme },
|
|
1434
|
-
onThemeChange
|
|
1435
|
-
});
|
|
1436
|
-
const isControlled = contextTheme !== null;
|
|
1437
|
-
const { ref, theme, switchTheme } = isControlled && contextTheme ? {
|
|
1438
|
-
ref: contextTheme.ref,
|
|
1439
|
-
theme: contextTheme.theme,
|
|
1440
|
-
switchTheme: contextTheme.switchTheme
|
|
1441
|
-
} : standaloneHook;
|
|
1442
|
-
const [isMounted, setIsMounted] = React.useState(false);
|
|
1443
|
-
const [hoveredTheme, setHoveredTheme] = React.useState(null);
|
|
1444
|
-
React.useEffect(() => {
|
|
1445
|
-
setIsMounted(true);
|
|
1446
|
-
}, []);
|
|
1447
|
-
const handleThemeChange = async (newTheme, event) => {
|
|
1448
|
-
if (isControlled && contextTheme?.switchThemeFromElement && event) {
|
|
1449
|
-
await contextTheme.switchThemeFromElement(
|
|
1450
|
-
newTheme,
|
|
1451
|
-
event.currentTarget
|
|
1452
|
-
);
|
|
1453
|
-
if (onThemeChange) {
|
|
1454
|
-
onThemeChange(newTheme);
|
|
1455
|
-
}
|
|
1456
|
-
} else {
|
|
1457
|
-
await switchTheme(newTheme);
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
const filteredOptions = THEME_OPTIONS.filter(
|
|
1461
|
-
(option) => themes.includes(option.value)
|
|
1462
|
-
);
|
|
1463
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1464
|
-
"div",
|
|
1465
|
-
{
|
|
1466
|
-
className: `
|
|
73
|
+
${n?"text-foreground font-medium":""}
|
|
74
|
+
`,role:"radio","aria-checked":n,"aria-label":`Switch to ${o} theme`,onClick:u=>i(o,u),onMouseEnter:a,onMouseLeave:l,style:{borderRadius:"var(--radius)"},children:[r&&jsxRuntime.jsx("div",{className:"absolute inset-0 bg-muted",style:{borderRadius:"var(--radius)"}}),jsxRuntime.jsx("div",{className:"relative z-10 flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"[&_svg]:size-4",children:e})}),n&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-1/2 h-0.5 w-6 -translate-x-1/2 rounded-full",style:{backgroundColor:"hsl(var(--primary))"}})]}),ao=[{icon:jsxRuntime.jsx(so,{}),value:"system"},{icon:jsxRuntime.jsx(no,{}),value:"light"},{icon:jsxRuntime.jsx(io,{}),value:"dark"}],lt=({state:e,isControlled:o,themes:n=["light","dark","system"],onThemeChange:r,className:i})=>{let{ref:a,theme:l,switchTheme:g}=e,u=W(),[y,b]=_t.useState(null),U=async(p,R)=>{o&&R?(await g(p,{element:R.currentTarget,animationOff:R.detail===0}),r&&r(p)):await g(p,R?{element:R.currentTarget,animationOff:R.detail===0}:void 0);},V=ao.filter(p=>n.includes(p.value));return jsxRuntime.jsx("div",{className:`
|
|
1467
75
|
inline-flex h-9 items-center overflow-hidden bg-background shadow-sm border border-border
|
|
1468
|
-
${
|
|
1469
|
-
${
|
|
1470
|
-
`,
|
|
1471
|
-
style: {
|
|
1472
|
-
borderRadius: "var(--radius)",
|
|
1473
|
-
backgroundColor: "hsl(var(--background))"
|
|
1474
|
-
},
|
|
1475
|
-
role: "radiogroup",
|
|
1476
|
-
onMouseLeave: () => setHoveredTheme(null),
|
|
1477
|
-
children: filteredOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1478
|
-
ThemeOption,
|
|
1479
|
-
{
|
|
1480
|
-
icon: option.icon,
|
|
1481
|
-
value: option.value,
|
|
1482
|
-
isActive: theme === option.value,
|
|
1483
|
-
isHovered: hoveredTheme === option.value,
|
|
1484
|
-
onClick: handleThemeChange,
|
|
1485
|
-
onMouseEnter: () => setHoveredTheme(option.value),
|
|
1486
|
-
onMouseLeave: () => {
|
|
1487
|
-
},
|
|
1488
|
-
buttonRef: theme === option.value ? ref : void 0
|
|
1489
|
-
},
|
|
1490
|
-
option.value
|
|
1491
|
-
))
|
|
1492
|
-
}
|
|
1493
|
-
);
|
|
1494
|
-
};
|
|
1495
|
-
var ChevronDownIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1496
|
-
"svg",
|
|
1497
|
-
{
|
|
1498
|
-
width: "16",
|
|
1499
|
-
height: "16",
|
|
1500
|
-
viewBox: "0 0 24 24",
|
|
1501
|
-
fill: "none",
|
|
1502
|
-
stroke: "currentColor",
|
|
1503
|
-
strokeWidth: "2",
|
|
1504
|
-
strokeLinecap: "round",
|
|
1505
|
-
strokeLinejoin: "round",
|
|
1506
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6" })
|
|
1507
|
-
}
|
|
1508
|
-
);
|
|
1509
|
-
var ChevronUpIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1510
|
-
"svg",
|
|
1511
|
-
{
|
|
1512
|
-
width: "16",
|
|
1513
|
-
height: "16",
|
|
1514
|
-
viewBox: "0 0 24 24",
|
|
1515
|
-
fill: "none",
|
|
1516
|
-
stroke: "currentColor",
|
|
1517
|
-
strokeWidth: "2",
|
|
1518
|
-
strokeLinecap: "round",
|
|
1519
|
-
strokeLinejoin: "round",
|
|
1520
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m18 15-6-6-6 6" })
|
|
1521
|
-
}
|
|
1522
|
-
);
|
|
1523
|
-
var CheckIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1524
|
-
"svg",
|
|
1525
|
-
{
|
|
1526
|
-
width: "16",
|
|
1527
|
-
height: "16",
|
|
1528
|
-
viewBox: "0 0 24 24",
|
|
1529
|
-
fill: "none",
|
|
1530
|
-
stroke: "currentColor",
|
|
1531
|
-
strokeWidth: "2",
|
|
1532
|
-
strokeLinecap: "round",
|
|
1533
|
-
strokeLinejoin: "round",
|
|
1534
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 6 9 17l-5-5" })
|
|
1535
|
-
}
|
|
1536
|
-
);
|
|
1537
|
-
function UISelect({
|
|
1538
|
-
...props
|
|
1539
|
-
}) {
|
|
1540
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Root, { "data-slot": "ui-select", ...props });
|
|
1541
|
-
}
|
|
1542
|
-
function UISelectGroup({
|
|
1543
|
-
...props
|
|
1544
|
-
}) {
|
|
1545
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Group, { "data-slot": "ui-select-group", ...props });
|
|
1546
|
-
}
|
|
1547
|
-
function UISelectValue({
|
|
1548
|
-
...props
|
|
1549
|
-
}) {
|
|
1550
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Value, { "data-slot": "ui-select-value", ...props });
|
|
1551
|
-
}
|
|
1552
|
-
function UISelectTrigger({
|
|
1553
|
-
className,
|
|
1554
|
-
size = "default",
|
|
1555
|
-
children,
|
|
1556
|
-
...props
|
|
1557
|
-
}) {
|
|
1558
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1559
|
-
SelectPrimitive__namespace.Trigger,
|
|
1560
|
-
{
|
|
1561
|
-
"data-slot": "ui-select-trigger",
|
|
1562
|
-
"data-size": size,
|
|
1563
|
-
className: `
|
|
76
|
+
${u?"opacity-100":"opacity-0"}
|
|
77
|
+
${i||""}
|
|
78
|
+
`,style:{borderRadius:"var(--radius)",backgroundColor:"hsl(var(--background))"},role:"radiogroup",onMouseLeave:()=>b(null),children:V.map(p=>jsxRuntime.jsx(mo,{icon:p.icon,value:p.value,isActive:l===p.value,isHovered:y===p.value,onClick:U,onMouseEnter:()=>b(p.value),onMouseLeave:()=>{},buttonRef:l===p.value?a:void 0},p.value))})},lo=e=>{let o=F({...e,theme:e.currentTheme});return jsxRuntime.jsx(lt,{...e,state:o,isControlled:false})},co=e=>{let o=we();return o?jsxRuntime.jsx(lt,{...e,state:o,isControlled:true}):jsxRuntime.jsx(lo,{...e})};var ht=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})}),ho=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m18 15-6-6-6 6"})}),To=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M20 6 9 17l-5-5"})});function Ke({...e}){return jsxRuntime.jsx(m__namespace.Root,{"data-slot":"ui-select",...e})}function uo({...e}){return jsxRuntime.jsx(m__namespace.Group,{"data-slot":"ui-select-group",...e})}function We({...e}){return jsxRuntime.jsx(m__namespace.Value,{"data-slot":"ui-select-value",...e})}var Ye=_t__namespace.forwardRef(function({className:o,size:n="default",children:r,...i},a){return jsxRuntime.jsxs(m__namespace.Trigger,{ref:a,"data-slot":"ui-select-trigger","data-size":n,className:`
|
|
1564
79
|
border-input data-[placeholder]:text-muted-foreground
|
|
1565
80
|
[&_svg:not([class*='text-'])]:text-muted-foreground
|
|
1566
81
|
focus-visible:border-ring focus-visible:ring-ring/50
|
|
@@ -1577,27 +92,8 @@ function UISelectTrigger({
|
|
|
1577
92
|
*:data-[slot=ui-select-value]:gap-2
|
|
1578
93
|
[&_svg]:pointer-events-none [&_svg]:shrink-0
|
|
1579
94
|
[&_svg:not([class*='size-'])]:size-4
|
|
1580
|
-
${
|
|
1581
|
-
|
|
1582
|
-
...props,
|
|
1583
|
-
children: [
|
|
1584
|
-
children,
|
|
1585
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, {}) })
|
|
1586
|
-
]
|
|
1587
|
-
}
|
|
1588
|
-
);
|
|
1589
|
-
}
|
|
1590
|
-
function UISelectContent({
|
|
1591
|
-
className,
|
|
1592
|
-
children,
|
|
1593
|
-
position = "popper",
|
|
1594
|
-
...props
|
|
1595
|
-
}) {
|
|
1596
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1597
|
-
SelectPrimitive__namespace.Content,
|
|
1598
|
-
{
|
|
1599
|
-
"data-slot": "ui-select-content",
|
|
1600
|
-
className: `
|
|
95
|
+
${o||""}
|
|
96
|
+
`,...i,children:[r,jsxRuntime.jsx(m__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(ht,{})})]})});function je({className:e,children:o,position:n="popper",...r}){return jsxRuntime.jsx(m__namespace.Portal,{children:jsxRuntime.jsx(m__namespace.Content,{"data-slot":"ui-select-content",className:`
|
|
1601
97
|
bg-popover text-popover-foreground
|
|
1602
98
|
data-[state=open]:animate-in data-[state=closed]:animate-out
|
|
1603
99
|
data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0
|
|
@@ -1609,47 +105,12 @@ function UISelectContent({
|
|
|
1609
105
|
relative z-50 max-h-[var(--radix-select-content-available-height)]
|
|
1610
106
|
min-w-[8rem] origin-[var(--radix-select-content-transform-origin)]
|
|
1611
107
|
overflow-x-hidden overflow-y-auto rounded-md border shadow-md
|
|
1612
|
-
${
|
|
1613
|
-
${
|
|
1614
|
-
`,
|
|
1615
|
-
position,
|
|
1616
|
-
...props,
|
|
1617
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1618
|
-
SelectPrimitive__namespace.Viewport,
|
|
1619
|
-
{
|
|
1620
|
-
className: `
|
|
108
|
+
${n==="popper"?"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1":""}
|
|
109
|
+
${e||""}
|
|
110
|
+
`,position:n,...r,children:jsxRuntime.jsx(m__namespace.Viewport,{className:`
|
|
1621
111
|
p-1
|
|
1622
|
-
${
|
|
1623
|
-
`,
|
|
1624
|
-
children
|
|
1625
|
-
}
|
|
1626
|
-
)
|
|
1627
|
-
}
|
|
1628
|
-
) });
|
|
1629
|
-
}
|
|
1630
|
-
function UISelectLabel({
|
|
1631
|
-
className,
|
|
1632
|
-
...props
|
|
1633
|
-
}) {
|
|
1634
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1635
|
-
SelectPrimitive__namespace.Label,
|
|
1636
|
-
{
|
|
1637
|
-
"data-slot": "ui-select-label",
|
|
1638
|
-
className: `py-1.5 pl-8 pr-2 text-sm font-semibold ${className || ""}`,
|
|
1639
|
-
...props
|
|
1640
|
-
}
|
|
1641
|
-
);
|
|
1642
|
-
}
|
|
1643
|
-
function UISelectItem({
|
|
1644
|
-
className,
|
|
1645
|
-
children,
|
|
1646
|
-
...props
|
|
1647
|
-
}) {
|
|
1648
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1649
|
-
SelectPrimitive__namespace.Item,
|
|
1650
|
-
{
|
|
1651
|
-
"data-slot": "ui-select-item",
|
|
1652
|
-
className: `
|
|
112
|
+
${n==="popper"?"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]":""}
|
|
113
|
+
`,children:o})})})}function po({className:e,...o}){return jsxRuntime.jsx(m__namespace.Label,{"data-slot":"ui-select-label",className:`py-1.5 pl-8 pr-2 text-sm font-semibold ${e||""}`,...o})}function Xe({className:e,children:o,...n}){return jsxRuntime.jsxs(m__namespace.Item,{"data-slot":"ui-select-item",className:`
|
|
1653
114
|
focus:bg-accent focus:text-accent-foreground
|
|
1654
115
|
[&_svg:not([class*='text-'])]:text-muted-foreground
|
|
1655
116
|
relative flex w-full cursor-default items-center gap-2
|
|
@@ -1658,134 +119,5 @@ function UISelectItem({
|
|
|
1658
119
|
[&_svg]:pointer-events-none [&_svg]:shrink-0
|
|
1659
120
|
[&_svg:not([class*='size-'])]:size-4
|
|
1660
121
|
*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2
|
|
1661
|
-
${
|
|
1662
|
-
`,
|
|
1663
|
-
...props,
|
|
1664
|
-
children: [
|
|
1665
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) }) }),
|
|
1666
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children })
|
|
1667
|
-
]
|
|
1668
|
-
}
|
|
1669
|
-
);
|
|
1670
|
-
}
|
|
1671
|
-
function UISelectSeparator({
|
|
1672
|
-
className,
|
|
1673
|
-
...props
|
|
1674
|
-
}) {
|
|
1675
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1676
|
-
SelectPrimitive__namespace.Separator,
|
|
1677
|
-
{
|
|
1678
|
-
"data-slot": "ui-select-separator",
|
|
1679
|
-
className: `-mx-1 my-1 h-px bg-muted ${className || ""}`,
|
|
1680
|
-
...props
|
|
1681
|
-
}
|
|
1682
|
-
);
|
|
1683
|
-
}
|
|
1684
|
-
function UISelectScrollUpButton({
|
|
1685
|
-
className,
|
|
1686
|
-
...props
|
|
1687
|
-
}) {
|
|
1688
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1689
|
-
SelectPrimitive__namespace.ScrollUpButton,
|
|
1690
|
-
{
|
|
1691
|
-
"data-slot": "ui-select-scroll-up-button",
|
|
1692
|
-
className: `flex cursor-default items-center justify-center py-1 ${className || ""}`,
|
|
1693
|
-
...props,
|
|
1694
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronUpIcon, {})
|
|
1695
|
-
}
|
|
1696
|
-
);
|
|
1697
|
-
}
|
|
1698
|
-
function UISelectScrollDownButton({
|
|
1699
|
-
className,
|
|
1700
|
-
...props
|
|
1701
|
-
}) {
|
|
1702
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1703
|
-
SelectPrimitive__namespace.ScrollDownButton,
|
|
1704
|
-
{
|
|
1705
|
-
"data-slot": "ui-select-scroll-down-button",
|
|
1706
|
-
className: `flex cursor-default items-center justify-center py-1 ${className || ""}`,
|
|
1707
|
-
...props,
|
|
1708
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, {})
|
|
1709
|
-
}
|
|
1710
|
-
);
|
|
1711
|
-
}
|
|
1712
|
-
var UIThemeSelector = ({
|
|
1713
|
-
themes = ["light", "dark", "system"],
|
|
1714
|
-
colorThemes = ["default"],
|
|
1715
|
-
currentColorTheme,
|
|
1716
|
-
onColorThemeChange,
|
|
1717
|
-
animationType,
|
|
1718
|
-
duration,
|
|
1719
|
-
className,
|
|
1720
|
-
placeholder = "Choose a color theme"
|
|
1721
|
-
}) => {
|
|
1722
|
-
let contextTheme = null;
|
|
1723
|
-
try {
|
|
1724
|
-
contextTheme = useUITheme();
|
|
1725
|
-
} catch {
|
|
1726
|
-
}
|
|
1727
|
-
const standaloneHook = useTheme({
|
|
1728
|
-
animationType,
|
|
1729
|
-
duration,
|
|
1730
|
-
themes,
|
|
1731
|
-
colorThemes,
|
|
1732
|
-
...currentColorTheme !== void 0 && { colorTheme: currentColorTheme },
|
|
1733
|
-
onColorThemeChange
|
|
1734
|
-
});
|
|
1735
|
-
const isControlled = contextTheme !== null;
|
|
1736
|
-
const { colorTheme, setColorTheme } = isControlled && contextTheme ? {
|
|
1737
|
-
colorTheme: contextTheme.colorTheme,
|
|
1738
|
-
setColorTheme: contextTheme.setColorTheme
|
|
1739
|
-
} : standaloneHook;
|
|
1740
|
-
const handleColorThemeChange = (newColorTheme) => {
|
|
1741
|
-
setColorTheme(newColorTheme);
|
|
1742
|
-
if (onColorThemeChange) {
|
|
1743
|
-
onColorThemeChange(newColorTheme);
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
if (colorThemes.length <= 1) {
|
|
1747
|
-
return null;
|
|
1748
|
-
}
|
|
1749
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex flex-col gap-2 ${className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs(UISelect, { value: colorTheme, onValueChange: handleColorThemeChange, children: [
|
|
1750
|
-
/* @__PURE__ */ jsxRuntime.jsx(UISelectTrigger, { className: "capitalize", children: /* @__PURE__ */ jsxRuntime.jsx(UISelectValue, { placeholder }) }),
|
|
1751
|
-
/* @__PURE__ */ jsxRuntime.jsx(UISelectContent, { children: colorThemes.map((theme) => /* @__PURE__ */ jsxRuntime.jsx(UISelectItem, { className: "capitalize", value: theme, children: theme }, theme)) })
|
|
1752
|
-
] }) });
|
|
1753
|
-
};
|
|
1754
|
-
|
|
1755
|
-
exports.COLOR_STORAGE_KEY = COLOR_STORAGE_KEY;
|
|
1756
|
-
exports.COLOR_THEME_PREFIX = COLOR_THEME_PREFIX;
|
|
1757
|
-
exports.DEFAULT_BLUR_AMOUNT = DEFAULT_BLUR_AMOUNT;
|
|
1758
|
-
exports.DEFAULT_DURATION = DEFAULT_DURATION;
|
|
1759
|
-
exports.DEFAULT_EASING = DEFAULT_EASING;
|
|
1760
|
-
exports.DEFAULT_STYLE_ID = DEFAULT_STYLE_ID;
|
|
1761
|
-
exports.GLOBAL_CLASS_NAME = GLOBAL_CLASS_NAME;
|
|
1762
|
-
exports.NextUIThemeProvider = NextUIThemeProvider;
|
|
1763
|
-
exports.STORAGE_KEY = STORAGE_KEY;
|
|
1764
|
-
exports.TanStackStartThemeScript = TanStackStartThemeScript;
|
|
1765
|
-
exports.TanStackUIThemeProvider = TanStackUIThemeProvider;
|
|
1766
|
-
exports.ThemeAnimationType = ThemeAnimationType;
|
|
1767
|
-
exports.UISelect = UISelect;
|
|
1768
|
-
exports.UISelectContent = UISelectContent;
|
|
1769
|
-
exports.UISelectGroup = UISelectGroup;
|
|
1770
|
-
exports.UISelectItem = UISelectItem;
|
|
1771
|
-
exports.UISelectLabel = UISelectLabel;
|
|
1772
|
-
exports.UISelectScrollDownButton = UISelectScrollDownButton;
|
|
1773
|
-
exports.UISelectScrollUpButton = UISelectScrollUpButton;
|
|
1774
|
-
exports.UISelectSeparator = UISelectSeparator;
|
|
1775
|
-
exports.UISelectTrigger = UISelectTrigger;
|
|
1776
|
-
exports.UISelectValue = UISelectValue;
|
|
1777
|
-
exports.UIThemeProvider = UIThemeProvider;
|
|
1778
|
-
exports.UIThemeSelector = UIThemeSelector;
|
|
1779
|
-
exports.UIThemeSwitcher = UIThemeSwitcher;
|
|
1780
|
-
exports.ViteUIThemeProvider = ViteUIThemeProvider;
|
|
1781
|
-
exports.getSystemTheme = getSystemTheme;
|
|
1782
|
-
exports.injectBaseStyles = injectBaseStyles;
|
|
1783
|
-
exports.prefersReducedMotion = prefersReducedMotion;
|
|
1784
|
-
exports.resolveTheme = resolveTheme;
|
|
1785
|
-
exports.resolveThemeForServer = resolveThemeForServer;
|
|
1786
|
-
exports.supportsViewTransitions = supportsViewTransitions;
|
|
1787
|
-
exports.useNextUITheme = useNextUITheme;
|
|
1788
|
-
exports.useTanStackUITheme = useTanStackUITheme;
|
|
1789
|
-
exports.useTheme = useTheme;
|
|
1790
|
-
exports.useUITheme = useUITheme;
|
|
1791
|
-
exports.useViteUITheme = useViteUITheme;
|
|
122
|
+
${e||""}
|
|
123
|
+
`,...n,children:[jsxRuntime.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(m__namespace.ItemIndicator,{children:jsxRuntime.jsx(To,{})})}),jsxRuntime.jsx(m__namespace.ItemText,{children:o})]})}function go({className:e,...o}){return jsxRuntime.jsx(m__namespace.Separator,{"data-slot":"ui-select-separator",className:`-mx-1 my-1 h-px bg-muted ${e||""}`,...o})}function fo({className:e,...o}){return jsxRuntime.jsx(m__namespace.ScrollUpButton,{"data-slot":"ui-select-scroll-up-button",className:`flex cursor-default items-center justify-center py-1 ${e||""}`,...o,children:jsxRuntime.jsx(ho,{})})}function vo({className:e,...o}){return jsxRuntime.jsx(m__namespace.ScrollDownButton,{"data-slot":"ui-select-scroll-down-button",className:`flex cursor-default items-center justify-center py-1 ${e||""}`,...o,children:jsxRuntime.jsx(ht,{})})}var ut=({state:e,isControlled:o,colorThemes:n=["default"],onColorThemeChange:r,className:i,placeholder:a="Choose a color theme"})=>{let{colorTheme:l,switchColorTheme:g}=e,u=_t.useRef(null),y=_t.useRef(false),b=U=>{g(U,{element:u.current,animationOff:y.current}),o&&r?.(U);};return n.length<=1?null:jsxRuntime.jsx("div",{className:`flex flex-col gap-2 ${i||""}`,onKeyDownCapture:()=>{y.current=true;},onPointerDownCapture:()=>{y.current=false;},children:jsxRuntime.jsxs(Ke,{value:l,onValueChange:b,children:[jsxRuntime.jsx(Ye,{ref:u,className:"capitalize",children:jsxRuntime.jsx(We,{placeholder:a})}),jsxRuntime.jsx(je,{onKeyDownCapture:()=>{y.current=true;},onPointerDownCapture:()=>{y.current=false;},children:n.map(U=>jsxRuntime.jsx(Xe,{className:"capitalize",value:U,children:U},U))})]})})},yo=e=>{let o=F({...e,colorTheme:e.currentColorTheme});return jsxRuntime.jsx(ut,{...e,state:o,isControlled:false})},Co=e=>{let o=we();return o?jsxRuntime.jsx(ut,{...e,state:o,isControlled:true}):jsxRuntime.jsx(yo,{...e})};Object.defineProperty(exports,"TRANSITION_DIRECTIONS",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.b}});Object.defineProperty(exports,"ThemeAnimationType",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.a}});Object.defineProperty(exports,"preloadThemeLogo",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.d}});Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.r}});Object.defineProperty(exports,"COLOR_THEME_PREFIX",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.t}});Object.defineProperty(exports,"DEFAULT_BLUR_AMOUNT",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.w}});Object.defineProperty(exports,"DEFAULT_DURATION",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.u}});Object.defineProperty(exports,"DEFAULT_EASING",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.v}});Object.defineProperty(exports,"DEFAULT_STYLE_ID",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.x}});Object.defineProperty(exports,"GLOBAL_CLASS_NAME",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.s}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.q}});Object.defineProperty(exports,"getSystemTheme",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.c}});Object.defineProperty(exports,"injectBaseStyles",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.a}});Object.defineProperty(exports,"prefersReducedMotion",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.g}});Object.defineProperty(exports,"resolveTheme",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.d}});Object.defineProperty(exports,"resolveThemeForServer",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.e}});Object.defineProperty(exports,"supportsViewTransitions",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.f}});exports.NextUIThemeProvider=Ft;exports.TanStackStartThemeScript=st;exports.TanStackUIThemeProvider=Yt;exports.UISelect=Ke;exports.UISelectContent=je;exports.UISelectGroup=uo;exports.UISelectItem=Xe;exports.UISelectLabel=po;exports.UISelectScrollDownButton=vo;exports.UISelectScrollUpButton=fo;exports.UISelectSeparator=go;exports.UISelectTrigger=Ye;exports.UISelectValue=We;exports.UIThemeProvider=to;exports.UIThemeSelector=Co;exports.UIThemeSwitcher=co;exports.ViteUIThemeProvider=qt;exports.useHydrated=W;exports.useNextUITheme=Vt;exports.useTanStackUITheme=jt;exports.useTheme=F;exports.useUITheme=oo;exports.useViteUITheme=Qt;
|