@gv-tech/ui-web 2.15.0 → 2.15.1

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-nZSsnGb7.js"),s=require("./index-CsjrqSSN.js");function i({children:e,...t}){return r.jsxRuntimeExports.jsx(s.J,{attribute:"class",defaultTheme:"system",enableSystem:!0,...t,children:e})}exports.ThemeProvider=i;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-nZSsnGb7.js"),s=require("next-themes");function i({children:e,...t}){return r.jsxRuntimeExports.jsx(s.ThemeProvider,{attribute:"class",defaultTheme:"system",enableSystem:!0,...t,children:e})}exports.ThemeProvider=i;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { j as r } from "./jsx-runtime-tc70JA_2.mjs";
3
- import { J as s } from "./index-DAWHN3cH.mjs";
4
- function i({ children: e, ...t }) {
5
- return /* @__PURE__ */ r.jsx(s, { attribute: "class", defaultTheme: "system", enableSystem: !0, ...t, children: e });
2
+ import { j as t } from "./jsx-runtime-tc70JA_2.mjs";
3
+ import { ThemeProvider as m } from "next-themes";
4
+ function i({ children: e, ...r }) {
5
+ return /* @__PURE__ */ t.jsx(m, { attribute: "class", defaultTheme: "system", enableSystem: !0, ...r, children: e });
6
6
  }
7
7
  export {
8
8
  i as ThemeProvider
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./jsx-runtime-nZSsnGb7.js"),s=require("lucide-react"),j=require("./button.cjs"),t=require("./dropdown-menu.cjs"),d=require("@gv-tech/design-tokens"),T=require("next-themes"),r=require("./utils-IjLH3w2e.js");function p(){const o=T.useTheme(),{resolvedTheme:i}=o,n=i==="dark"?d.theme.dark:d.theme.light;return{...o,tokens:n}}function k({variant:o="binary",onThemeChange:i,customTheme:n,className:c}){const{theme:R,setTheme:E,resolvedTheme:g}=p(),m=n??R,l=(n||g)==="dark",a=m==="system",x=h=>{i?i(h):E(h)},u=()=>e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(s.Sun,{className:r.cn("h-[1.2rem] w-[1.2rem] transition-all",!a&&!l?"scale-100 rotate-0":"scale-0 -rotate-90")}),e.jsxRuntimeExports.jsx(s.Moon,{className:r.cn("absolute h-[1.2rem] w-[1.2rem] transition-all",!a&&l?"scale-100 rotate-0":"scale-0 rotate-90")}),e.jsxRuntimeExports.jsx(s.SunMoon,{className:r.cn("absolute h-[1.2rem] w-[1.2rem] transition-all",a?"scale-100 rotate-0":"scale-0 rotate-90")}),e.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Toggle theme"})]});return o==="ternary"?e.jsxRuntimeExports.jsxs(t.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(j.Button,{variant:"ghost",size:"icon",className:r.cn("relative h-9 w-9",c),children:e.jsxRuntimeExports.jsx(u,{})})}),e.jsxRuntimeExports.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("light"),children:[e.jsxRuntimeExports.jsx(s.Sun,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"Light"})]}),e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("dark"),children:[e.jsxRuntimeExports.jsx(s.Moon,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"Dark"})]}),e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("system"),children:[e.jsxRuntimeExports.jsx(s.SunMoon,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"System"})]})]})]}):e.jsxRuntimeExports.jsx(j.Button,{variant:"ghost",size:"icon",className:r.cn("relative h-9 w-9",c),onClick:()=>x(m==="dark"?"light":"dark"),"aria-label":"Toggle theme",children:e.jsxRuntimeExports.jsx(u,{})})}exports.ThemeToggle=k;exports.useTheme=p;
@@ -0,0 +1,79 @@
1
+ import { j as e } from "./jsx-runtime-tc70JA_2.mjs";
2
+ import { Sun as x, Moon as j, SunMoon as u } from "lucide-react";
3
+ import { Button as g } from "./button.mjs";
4
+ import { DropdownMenu as w, DropdownMenuTrigger as v, DropdownMenuContent as N, DropdownMenuItem as i } from "./dropdown-menu.mjs";
5
+ import { theme as p } from "@gv-tech/design-tokens";
6
+ import { useTheme as y } from "next-themes";
7
+ import { c as r } from "./utils-B6yFEsav.mjs";
8
+ function C() {
9
+ const t = y(), { resolvedTheme: n } = t, s = n === "dark" ? p.dark : p.light;
10
+ return {
11
+ ...t,
12
+ tokens: s
13
+ };
14
+ }
15
+ function F({ variant: t = "binary", onThemeChange: n, customTheme: s, className: l }) {
16
+ const { theme: T, setTheme: f, resolvedTheme: k } = C(), c = s ?? T, m = (s || k) === "dark", o = c === "system", a = (d) => {
17
+ n ? n(d) : f(d);
18
+ }, h = () => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
19
+ /* @__PURE__ */ e.jsx(
20
+ x,
21
+ {
22
+ className: r(
23
+ "h-[1.2rem] w-[1.2rem] transition-all",
24
+ !o && !m ? "scale-100 rotate-0" : "scale-0 -rotate-90"
25
+ )
26
+ }
27
+ ),
28
+ /* @__PURE__ */ e.jsx(
29
+ j,
30
+ {
31
+ className: r(
32
+ "absolute h-[1.2rem] w-[1.2rem] transition-all",
33
+ !o && m ? "scale-100 rotate-0" : "scale-0 rotate-90"
34
+ )
35
+ }
36
+ ),
37
+ /* @__PURE__ */ e.jsx(
38
+ u,
39
+ {
40
+ className: r(
41
+ "absolute h-[1.2rem] w-[1.2rem] transition-all",
42
+ o ? "scale-100 rotate-0" : "scale-0 rotate-90"
43
+ )
44
+ }
45
+ ),
46
+ /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Toggle theme" })
47
+ ] });
48
+ return t === "ternary" ? /* @__PURE__ */ e.jsxs(w, { children: [
49
+ /* @__PURE__ */ e.jsx(v, { asChild: !0, children: /* @__PURE__ */ e.jsx(g, { variant: "ghost", size: "icon", className: r("relative h-9 w-9", l), children: /* @__PURE__ */ e.jsx(h, {}) }) }),
50
+ /* @__PURE__ */ e.jsxs(N, { align: "end", children: [
51
+ /* @__PURE__ */ e.jsxs(i, { onClick: () => a("light"), children: [
52
+ /* @__PURE__ */ e.jsx(x, { className: "mr-2 h-4 w-4" }),
53
+ /* @__PURE__ */ e.jsx("span", { children: "Light" })
54
+ ] }),
55
+ /* @__PURE__ */ e.jsxs(i, { onClick: () => a("dark"), children: [
56
+ /* @__PURE__ */ e.jsx(j, { className: "mr-2 h-4 w-4" }),
57
+ /* @__PURE__ */ e.jsx("span", { children: "Dark" })
58
+ ] }),
59
+ /* @__PURE__ */ e.jsxs(i, { onClick: () => a("system"), children: [
60
+ /* @__PURE__ */ e.jsx(u, { className: "mr-2 h-4 w-4" }),
61
+ /* @__PURE__ */ e.jsx("span", { children: "System" })
62
+ ] })
63
+ ] })
64
+ ] }) : /* @__PURE__ */ e.jsx(
65
+ g,
66
+ {
67
+ variant: "ghost",
68
+ size: "icon",
69
+ className: r("relative h-9 w-9", l),
70
+ onClick: () => a(c === "dark" ? "light" : "dark"),
71
+ "aria-label": "Toggle theme",
72
+ children: /* @__PURE__ */ e.jsx(h, {})
73
+ }
74
+ );
75
+ }
76
+ export {
77
+ F as T,
78
+ C as u
79
+ };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-nZSsnGb7.js"),s=require("lucide-react"),h=require("./button.cjs"),t=require("./dropdown-menu.cjs"),d=require("@gv-tech/design-tokens"),E=require("./index-CsjrqSSN.js"),r=require("./utils-IjLH3w2e.js");function T(){const o=E.z(),{resolvedTheme:i}=o,n=i==="dark"?d.theme.dark:d.theme.light;return{...o,tokens:n}}function k({variant:o="binary",onThemeChange:i,customTheme:n,className:c}){const{theme:p,setTheme:R,resolvedTheme:g}=T(),l=n??p,m=(n||g)==="dark",a=l==="system",x=j=>{i?i(j):R(j)},u=()=>e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(s.Sun,{className:r.cn("h-[1.2rem] w-[1.2rem] transition-all",!a&&!m?"scale-100 rotate-0":"scale-0 -rotate-90")}),e.jsxRuntimeExports.jsx(s.Moon,{className:r.cn("absolute h-[1.2rem] w-[1.2rem] transition-all",!a&&m?"scale-100 rotate-0":"scale-0 rotate-90")}),e.jsxRuntimeExports.jsx(s.SunMoon,{className:r.cn("absolute h-[1.2rem] w-[1.2rem] transition-all",a?"scale-100 rotate-0":"scale-0 rotate-90")}),e.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Toggle theme"})]});return o==="ternary"?e.jsxRuntimeExports.jsxs(t.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(h.Button,{variant:"ghost",size:"icon",className:r.cn("relative h-9 w-9",c),children:e.jsxRuntimeExports.jsx(u,{})})}),e.jsxRuntimeExports.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("light"),children:[e.jsxRuntimeExports.jsx(s.Sun,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"Light"})]}),e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("dark"),children:[e.jsxRuntimeExports.jsx(s.Moon,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"Dark"})]}),e.jsxRuntimeExports.jsxs(t.DropdownMenuItem,{onClick:()=>x("system"),children:[e.jsxRuntimeExports.jsx(s.SunMoon,{className:"mr-2 h-4 w-4"}),e.jsxRuntimeExports.jsx("span",{children:"System"})]})]})]}):e.jsxRuntimeExports.jsx(h.Button,{variant:"ghost",size:"icon",className:r.cn("relative h-9 w-9",c),onClick:()=>x(l==="dark"?"light":"dark"),"aria-label":"Toggle theme",children:e.jsxRuntimeExports.jsx(u,{})})}exports.ThemeToggle=k;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./jsx-runtime-nZSsnGb7.js");require("lucide-react");require("./button.cjs");require("./dropdown-menu.cjs");const e=require("./theme-toggle-B4VZTDpe.js");require("./utils-IjLH3w2e.js");exports.ThemeToggle=e.ThemeToggle;
@@ -1,79 +1,10 @@
1
1
  "use client";
2
- import { j as e } from "./jsx-runtime-tc70JA_2.mjs";
3
- import { Sun as x, Moon as j, SunMoon as g } from "lucide-react";
4
- import { Button as p } from "./button.mjs";
5
- import { DropdownMenu as w, DropdownMenuTrigger as v, DropdownMenuContent as N, DropdownMenuItem as i } from "./dropdown-menu.mjs";
6
- import { theme as u } from "@gv-tech/design-tokens";
7
- import { z as y } from "./index-DAWHN3cH.mjs";
8
- import { c as r } from "./utils-B6yFEsav.mjs";
9
- function C() {
10
- const t = y(), { resolvedTheme: n } = t, s = n === "dark" ? u.dark : u.light;
11
- return {
12
- ...t,
13
- tokens: s
14
- };
15
- }
16
- function F({ variant: t = "binary", onThemeChange: n, customTheme: s, className: l }) {
17
- const { theme: f, setTheme: k, resolvedTheme: T } = C(), c = s ?? f, m = (s || T) === "dark", a = c === "system", o = (d) => {
18
- n ? n(d) : k(d);
19
- }, h = () => /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
20
- /* @__PURE__ */ e.jsx(
21
- x,
22
- {
23
- className: r(
24
- "h-[1.2rem] w-[1.2rem] transition-all",
25
- !a && !m ? "scale-100 rotate-0" : "scale-0 -rotate-90"
26
- )
27
- }
28
- ),
29
- /* @__PURE__ */ e.jsx(
30
- j,
31
- {
32
- className: r(
33
- "absolute h-[1.2rem] w-[1.2rem] transition-all",
34
- !a && m ? "scale-100 rotate-0" : "scale-0 rotate-90"
35
- )
36
- }
37
- ),
38
- /* @__PURE__ */ e.jsx(
39
- g,
40
- {
41
- className: r(
42
- "absolute h-[1.2rem] w-[1.2rem] transition-all",
43
- a ? "scale-100 rotate-0" : "scale-0 rotate-90"
44
- )
45
- }
46
- ),
47
- /* @__PURE__ */ e.jsx("span", { className: "sr-only", children: "Toggle theme" })
48
- ] });
49
- return t === "ternary" ? /* @__PURE__ */ e.jsxs(w, { children: [
50
- /* @__PURE__ */ e.jsx(v, { asChild: !0, children: /* @__PURE__ */ e.jsx(p, { variant: "ghost", size: "icon", className: r("relative h-9 w-9", l), children: /* @__PURE__ */ e.jsx(h, {}) }) }),
51
- /* @__PURE__ */ e.jsxs(N, { align: "end", children: [
52
- /* @__PURE__ */ e.jsxs(i, { onClick: () => o("light"), children: [
53
- /* @__PURE__ */ e.jsx(x, { className: "mr-2 h-4 w-4" }),
54
- /* @__PURE__ */ e.jsx("span", { children: "Light" })
55
- ] }),
56
- /* @__PURE__ */ e.jsxs(i, { onClick: () => o("dark"), children: [
57
- /* @__PURE__ */ e.jsx(j, { className: "mr-2 h-4 w-4" }),
58
- /* @__PURE__ */ e.jsx("span", { children: "Dark" })
59
- ] }),
60
- /* @__PURE__ */ e.jsxs(i, { onClick: () => o("system"), children: [
61
- /* @__PURE__ */ e.jsx(g, { className: "mr-2 h-4 w-4" }),
62
- /* @__PURE__ */ e.jsx("span", { children: "System" })
63
- ] })
64
- ] })
65
- ] }) : /* @__PURE__ */ e.jsx(
66
- p,
67
- {
68
- variant: "ghost",
69
- size: "icon",
70
- className: r("relative h-9 w-9", l),
71
- onClick: () => o(c === "dark" ? "light" : "dark"),
72
- "aria-label": "Toggle theme",
73
- children: /* @__PURE__ */ e.jsx(h, {})
74
- }
75
- );
76
- }
2
+ import "./jsx-runtime-tc70JA_2.mjs";
3
+ import "lucide-react";
4
+ import "./button.mjs";
5
+ import "./dropdown-menu.mjs";
6
+ import { T } from "./theme-toggle-WtPW9UZi.mjs";
7
+ import "./utils-B6yFEsav.mjs";
77
8
  export {
78
- F as ThemeToggle
9
+ T as ThemeToggle
79
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-tech/ui-web",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Web (DOM/Radix) implementations of the GV Tech design system components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -85,6 +85,7 @@
85
85
  "zod": "^4.3.6"
86
86
  },
87
87
  "peerDependencies": {
88
+ "next-themes": ">=0.4.0",
88
89
  "react": ">=18",
89
90
  "react-dom": ">=18"
90
91
  },
package/src/index.ts CHANGED
@@ -469,6 +469,9 @@ export type { ThemeProviderProps } from './theme-provider';
469
469
  export { ThemeToggle } from './theme-toggle';
470
470
  export type { ThemeToggleProps } from './theme-toggle';
471
471
 
472
+ // Theme Hook
473
+ export { useTheme } from './hooks/use-theme';
474
+
472
475
  // Toaster (Radix)
473
476
  export type { ToasterBaseProps as ToasterProps } from '@gv-tech/ui-core';
474
477
  export { toast, useToast } from './hooks/use-toast';
@@ -1 +0,0 @@
1
- "use strict";const I=require("react");function z(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const m=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,m.get?m:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const r=z(I);var N=(e,n,t,m,u,c,d,h)=>{let i=document.documentElement,b=["light","dark"];function f(o){(Array.isArray(e)?e:[e]).forEach(y=>{let S=y==="class",C=S&&c?u.map(g=>c[g]||g):u;S?(i.classList.remove(...C),i.classList.add(c&&c[o]?c[o]:o)):i.setAttribute(y,o)}),k(o)}function k(o){h&&b.includes(o)&&(i.style.colorScheme=o)}function l(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(m)f(m);else try{let o=localStorage.getItem(n)||t,y=d&&o==="system"?l():o;f(y)}catch{}},P=["light","dark"],_="(prefers-color-scheme: dark)",D=typeof window>"u",A=r.createContext(void 0),H={setTheme:e=>{},themes:[]},J=()=>{var e;return(e=r.useContext(A))!=null?e:H},K=e=>r.useContext(A)?r.createElement(r.Fragment,null,e.children):r.createElement(V,{...e}),R=["light","dark"],V=({forcedTheme:e,disableTransitionOnChange:n=!1,enableSystem:t=!0,enableColorScheme:m=!0,storageKey:u="theme",themes:c=R,defaultTheme:d=t?"system":"light",attribute:h="data-theme",value:i,children:b,nonce:f,scriptProps:k})=>{let[l,o]=r.useState(()=>$(u,d)),[y,S]=r.useState(()=>l==="system"?L():l),C=i?Object.values(i):c,g=r.useCallback(a=>{let s=a;if(!s)return;a==="system"&&t&&(s=L());let v=i?i[s]:s,O=n?q(f):null,w=document.documentElement,M=p=>{p==="class"?(w.classList.remove(...C),v&&w.classList.add(v)):p.startsWith("data-")&&(v?w.setAttribute(p,v):w.removeAttribute(p))};if(Array.isArray(h)?h.forEach(M):M(h),m){let p=P.includes(d)?d:null,x=P.includes(s)?s:p;w.style.colorScheme=x}O?.()},[f]),T=r.useCallback(a=>{let s=typeof a=="function"?a(l):a;o(s);try{localStorage.setItem(u,s)}catch{}},[l]),E=r.useCallback(a=>{let s=L(a);S(s),l==="system"&&t&&!e&&g("system")},[l,e]);r.useEffect(()=>{let a=window.matchMedia(_);return a.addListener(E),E(a),()=>a.removeListener(E)},[E]),r.useEffect(()=>{let a=s=>{s.key===u&&(s.newValue?o(s.newValue):T(d))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[T]),r.useEffect(()=>{g(e??l)},[e,l]);let j=r.useMemo(()=>({theme:l,setTheme:T,forcedTheme:e,resolvedTheme:l==="system"?y:l,themes:t?[...c,"system"]:c,systemTheme:t?y:void 0}),[l,T,e,y,t,c]);return r.createElement(A.Provider,{value:j},r.createElement(W,{forcedTheme:e,storageKey:u,attribute:h,enableSystem:t,enableColorScheme:m,defaultTheme:d,value:i,themes:c,nonce:f,scriptProps:k}),b)},W=r.memo(({forcedTheme:e,storageKey:n,attribute:t,enableSystem:m,enableColorScheme:u,defaultTheme:c,value:d,themes:h,nonce:i,scriptProps:b})=>{let f=JSON.stringify([t,n,c,e,h,d,m,u]).slice(1,-1);return r.createElement("script",{...b,suppressHydrationWarning:!0,nonce:typeof window>"u"?i:"",dangerouslySetInnerHTML:{__html:`(${N.toString()})(${f})`}})}),$=(e,n)=>{if(D)return;let t;try{t=localStorage.getItem(e)||void 0}catch{}return t||n},q=e=>{let n=document.createElement("style");return e&&n.setAttribute("nonce",e),n.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(n),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(n)},1)}},L=e=>(e||(e=window.matchMedia(_)),e.matches?"dark":"light");exports.J=K;exports.z=J;
@@ -1,85 +0,0 @@
1
- import * as t from "react";
2
- var K = (e, i, a, u, m, l, d, h) => {
3
- let c = document.documentElement, v = ["light", "dark"];
4
- function f(r) {
5
- (Array.isArray(e) ? e : [e]).forEach((y) => {
6
- let S = y === "class", k = S && l ? m.map((b) => l[b] || b) : m;
7
- S ? (c.classList.remove(...k), c.classList.add(l && l[r] ? l[r] : r)) : c.setAttribute(y, r);
8
- }), C(r);
9
- }
10
- function C(r) {
11
- h && v.includes(r) && (c.style.colorScheme = r);
12
- }
13
- function s() {
14
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
15
- }
16
- if (u) f(u);
17
- else try {
18
- let r = localStorage.getItem(i) || a, y = d && r === "system" ? s() : r;
19
- f(y);
20
- } catch {
21
- }
22
- }, I = ["light", "dark"], P = "(prefers-color-scheme: dark)", N = typeof window > "u", A = t.createContext(void 0), V = { setTheme: (e) => {
23
- }, themes: [] }, $ = () => {
24
- var e;
25
- return (e = t.useContext(A)) != null ? e : V;
26
- }, j = (e) => t.useContext(A) ? t.createElement(t.Fragment, null, e.children) : t.createElement(_, { ...e }), W = ["light", "dark"], _ = ({ forcedTheme: e, disableTransitionOnChange: i = !1, enableSystem: a = !0, enableColorScheme: u = !0, storageKey: m = "theme", themes: l = W, defaultTheme: d = a ? "system" : "light", attribute: h = "data-theme", value: c, children: v, nonce: f, scriptProps: C }) => {
27
- let [s, r] = t.useState(() => J(m, d)), [y, S] = t.useState(() => s === "system" ? L() : s), k = c ? Object.values(c) : l, b = t.useCallback((n) => {
28
- let o = n;
29
- if (!o) return;
30
- n === "system" && a && (o = L());
31
- let g = c ? c[o] : o, x = i ? R(f) : null, w = document.documentElement, M = (p) => {
32
- p === "class" ? (w.classList.remove(...k), g && w.classList.add(g)) : p.startsWith("data-") && (g ? w.setAttribute(p, g) : w.removeAttribute(p));
33
- };
34
- if (Array.isArray(h) ? h.forEach(M) : M(h), u) {
35
- let p = I.includes(d) ? d : null, H = I.includes(o) ? o : p;
36
- w.style.colorScheme = H;
37
- }
38
- x?.();
39
- }, [f]), E = t.useCallback((n) => {
40
- let o = typeof n == "function" ? n(s) : n;
41
- r(o);
42
- try {
43
- localStorage.setItem(m, o);
44
- } catch {
45
- }
46
- }, [s]), T = t.useCallback((n) => {
47
- let o = L(n);
48
- S(o), s === "system" && a && !e && b("system");
49
- }, [s, e]);
50
- t.useEffect(() => {
51
- let n = window.matchMedia(P);
52
- return n.addListener(T), T(n), () => n.removeListener(T);
53
- }, [T]), t.useEffect(() => {
54
- let n = (o) => {
55
- o.key === m && (o.newValue ? r(o.newValue) : E(d));
56
- };
57
- return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
58
- }, [E]), t.useEffect(() => {
59
- b(e ?? s);
60
- }, [e, s]);
61
- let O = t.useMemo(() => ({ theme: s, setTheme: E, forcedTheme: e, resolvedTheme: s === "system" ? y : s, themes: a ? [...l, "system"] : l, systemTheme: a ? y : void 0 }), [s, E, e, y, a, l]);
62
- return t.createElement(A.Provider, { value: O }, t.createElement(z, { forcedTheme: e, storageKey: m, attribute: h, enableSystem: a, enableColorScheme: u, defaultTheme: d, value: c, themes: l, nonce: f, scriptProps: C }), v);
63
- }, z = t.memo(({ forcedTheme: e, storageKey: i, attribute: a, enableSystem: u, enableColorScheme: m, defaultTheme: l, value: d, themes: h, nonce: c, scriptProps: v }) => {
64
- let f = JSON.stringify([a, i, l, e, h, d, u, m]).slice(1, -1);
65
- return t.createElement("script", { ...v, suppressHydrationWarning: !0, nonce: typeof window > "u" ? c : "", dangerouslySetInnerHTML: { __html: `(${K.toString()})(${f})` } });
66
- }), J = (e, i) => {
67
- if (N) return;
68
- let a;
69
- try {
70
- a = localStorage.getItem(e) || void 0;
71
- } catch {
72
- }
73
- return a || i;
74
- }, R = (e) => {
75
- let i = document.createElement("style");
76
- return e && i.setAttribute("nonce", e), i.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")), document.head.appendChild(i), () => {
77
- window.getComputedStyle(document.body), setTimeout(() => {
78
- document.head.removeChild(i);
79
- }, 1);
80
- };
81
- }, L = (e) => (e || (e = window.matchMedia(P)), e.matches ? "dark" : "light");
82
- export {
83
- j as J,
84
- $ as z
85
- };