@codeplex-sac/theme 0.0.1 → 0.0.3
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/index.cjs +1 -1
- package/index.d.ts +4 -3
- package/index.js +30 -23
- package/lib/ganchos.d.ts +3 -0
- package/lib/proveedor.d.ts +10 -0
- package/lib/tema.d.ts +1 -0
- package/lib/tipos.d.ts +6 -0
- package/package.json +1 -1
- package/lib/hooks.d.ts +0 -2
- package/lib/provider.d.ts +0 -8
- package/lib/theme.d.ts +0 -1
- package/lib/types.d.ts +0 -6
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),r=t.createContext(void 0),m="codeplex-theme",u=({children:o,temaPorDefecto:a="light"})=>{const[s,n]=t.useState(()=>{if(typeof window<"u"){const e=localStorage.getItem(m);if(e==="light"||e==="dark")return e;if(window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}return a}),c=t.useCallback(e=>{const d=document.documentElement;d.classList.remove("light","dark"),d.classList.add(e),localStorage.setItem(m,e)},[]);t.useEffect(()=>{c(s)},[s,c]);const T=t.useCallback(e=>{n(e)},[]),h=t.useCallback(()=>{n(e=>e==="light"?"dark":"light")},[]);return l.jsx(r.Provider,{value:{tema:s,alternarTema:h,establecerTema:T},children:o})},x=({defaultTheme:o,...a})=>l.jsx(u,{temaPorDefecto:o,...a}),C=r,i=()=>{const o=t.useContext(r);if(!o)throw new Error("usarTema debe ser usado dentro de un CodeplexProveedorTema");return o},f=i;function g(){return"tema"}exports.CodeplexProveedorTema=u;exports.CodeplexThemeProvider=x;exports.ContextoTema=r;exports.ThemeContext=C;exports.tema=g;exports.usarTema=i;exports.useTheme=f;
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './lib/
|
|
2
|
-
export * from './lib/
|
|
3
|
-
export * from './lib/
|
|
1
|
+
export * from './lib/tipos';
|
|
2
|
+
export * from './lib/proveedor';
|
|
3
|
+
export * from './lib/ganchos';
|
|
4
|
+
export * from './lib/tema';
|
package/index.js
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as f, useState as h, useCallback as a, useEffect as T, useContext as x } from "react";
|
|
3
|
+
const n = f(void 0), m = "codeplex-theme", p = ({
|
|
4
4
|
children: t,
|
|
5
|
-
|
|
5
|
+
temaPorDefecto: o = "light"
|
|
6
6
|
}) => {
|
|
7
|
-
const [
|
|
7
|
+
const [r, s] = h(() => {
|
|
8
8
|
if (typeof window < "u") {
|
|
9
|
-
const e = localStorage.getItem(
|
|
9
|
+
const e = localStorage.getItem(m);
|
|
10
10
|
if (e === "light" || e === "dark")
|
|
11
11
|
return e;
|
|
12
12
|
if (window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
13
13
|
return "dark";
|
|
14
14
|
}
|
|
15
|
-
return
|
|
16
|
-
}),
|
|
17
|
-
const
|
|
18
|
-
|
|
15
|
+
return o;
|
|
16
|
+
}), c = a((e) => {
|
|
17
|
+
const d = document.documentElement;
|
|
18
|
+
d.classList.remove("light", "dark"), d.classList.add(e), localStorage.setItem(m, e);
|
|
19
19
|
}, []);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
const i =
|
|
20
|
+
T(() => {
|
|
21
|
+
c(r);
|
|
22
|
+
}, [r, c]);
|
|
23
|
+
const i = a((e) => {
|
|
24
24
|
s(e);
|
|
25
|
-
}, []),
|
|
25
|
+
}, []), u = a(() => {
|
|
26
26
|
s((e) => e === "light" ? "dark" : "light");
|
|
27
27
|
}, []);
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
},
|
|
30
|
-
const t =
|
|
28
|
+
return /* @__PURE__ */ l(n.Provider, { value: { tema: r, alternarTema: u, establecerTema: i }, children: t });
|
|
29
|
+
}, k = ({ defaultTheme: t, ...o }) => /* @__PURE__ */ l(p, { temaPorDefecto: t, ...o }), v = n, C = () => {
|
|
30
|
+
const t = x(n);
|
|
31
31
|
if (!t)
|
|
32
|
-
throw new Error("
|
|
32
|
+
throw new Error("usarTema debe ser usado dentro de un CodeplexProveedorTema");
|
|
33
33
|
return t;
|
|
34
|
-
};
|
|
34
|
+
}, w = C;
|
|
35
|
+
function A() {
|
|
36
|
+
return "tema";
|
|
37
|
+
}
|
|
35
38
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
p as CodeplexProveedorTema,
|
|
40
|
+
k as CodeplexThemeProvider,
|
|
41
|
+
n as ContextoTema,
|
|
42
|
+
v as ThemeContext,
|
|
43
|
+
A as tema,
|
|
44
|
+
C as usarTema,
|
|
45
|
+
w as useTheme
|
|
39
46
|
};
|
package/lib/ganchos.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { CodeplexTema, ContextoTemaTipo } from './tipos';
|
|
3
|
+
export declare const ContextoTema: React.Context<ContextoTemaTipo | undefined>;
|
|
4
|
+
export interface CodeplexProveedorTemaProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
temaPorDefecto?: CodeplexTema;
|
|
7
|
+
}
|
|
8
|
+
export declare const CodeplexProveedorTema: React.FC<CodeplexProveedorTemaProps>;
|
|
9
|
+
export declare const CodeplexThemeProvider: ({ defaultTheme, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const ThemeContext: React.Context<ContextoTemaTipo | undefined>;
|
package/lib/tema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tema(): string;
|
package/lib/tipos.d.ts
ADDED
package/package.json
CHANGED
package/lib/hooks.d.ts
DELETED
package/lib/provider.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { default as React, ReactNode } from 'react';
|
|
2
|
-
import { CodeplexTheme, ThemeContextType } from './types';
|
|
3
|
-
export declare const ThemeContext: React.Context<ThemeContextType | undefined>;
|
|
4
|
-
export interface CodeplexThemeProviderProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
defaultTheme?: CodeplexTheme;
|
|
7
|
-
}
|
|
8
|
-
export declare const CodeplexThemeProvider: React.FC<CodeplexThemeProviderProps>;
|
package/lib/theme.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function theme(): string;
|