framepexls-ui-lib 0.2.14 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dropdown.js +1 -1
- package/dist/Dropdown.mjs +1 -1
- package/dist/Select.js +1 -1
- package/dist/Select.mjs +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.mjs +7 -0
- package/dist/theme/ThemeProvider.d.mts +18 -0
- package/dist/theme/ThemeProvider.d.ts +18 -0
- package/dist/theme/ThemeProvider.js +109 -0
- package/dist/theme/ThemeProvider.mjs +84 -0
- package/dist/theme/ThemeScript.d.mts +7 -0
- package/dist/theme/ThemeScript.d.ts +7 -0
- package/dist/theme/ThemeScript.js +34 -0
- package/dist/theme/ThemeScript.mjs +10 -0
- package/dist/theme/ThemeToggle.d.mts +10 -0
- package/dist/theme/ThemeToggle.d.ts +10 -0
- package/dist/theme/ThemeToggle.js +56 -0
- package/dist/theme/ThemeToggle.mjs +36 -0
- package/dist/theme.css +126 -0
- package/package.json +4 -3
package/dist/Dropdown.js
CHANGED
package/dist/Dropdown.mjs
CHANGED
package/dist/Select.js
CHANGED
|
@@ -175,7 +175,7 @@ function ModernSelect({
|
|
|
175
175
|
disabled,
|
|
176
176
|
"aria-haspopup": "listbox",
|
|
177
177
|
"aria-expanded": open,
|
|
178
|
-
"aria-controls": `${selectId}-listbox
|
|
178
|
+
"aria-controls": open ? `${selectId}-listbox` : void 0,
|
|
179
179
|
"aria-describedby": hintId != null ? hintId : hasError ? errorId : void 0,
|
|
180
180
|
onClick: () => !disabled && setOpen((o) => !o),
|
|
181
181
|
onKeyDown: onKeyBtn,
|
package/dist/Select.mjs
CHANGED
|
@@ -142,7 +142,7 @@ function ModernSelect({
|
|
|
142
142
|
disabled,
|
|
143
143
|
"aria-haspopup": "listbox",
|
|
144
144
|
"aria-expanded": open,
|
|
145
|
-
"aria-controls": `${selectId}-listbox
|
|
145
|
+
"aria-controls": open ? `${selectId}-listbox` : void 0,
|
|
146
146
|
"aria-describedby": hintId != null ? hintId : hasError ? errorId : void 0,
|
|
147
147
|
onClick: () => !disabled && setOpen((o) => !o),
|
|
148
148
|
onKeyDown: onKeyBtn,
|
package/dist/index.d.mts
CHANGED
|
@@ -50,6 +50,9 @@ export { TimeRange, default as TimeRangeField, TimeRangeFieldProps } from './Tim
|
|
|
50
50
|
export { StepDef, default as Steps, StepsNav } from './Steps.mjs';
|
|
51
51
|
export { Aficionados, AuditarDocumento, Borrar, CajaDeMano, Cajas, Calendario, ChevronLeftRightIcon, CirculoAdvertencia, CirculoExito, CirculoPeligro, CirculoPorDefecto, ClientsIcon, CloseIcon, ContraseniaDeEmailIcon, Cotizaciones, DashboardIcon, Directorio, Edificio, Editar, Empresa, EscaneoFacial, EyeIcon, FlechaAbajo, FlechaArriba, Imagenes, LlamadaTelefonica, LogoutIcon, MarketingDigital, MediosDeComunicacionSocial, MenuIcon, MenuPuntosVerticalIcon, Nota, Ojo, OrdersIcon, PencilIcon, PermsIcon, ProductsIcon, PromoIcon, Retroalimentacion, RolesIcon, Sobre, Tablero, Tarea, Tickets, TrabajoEnEquipo, TrashIcon, UserIcon, UsersIcon, UsuarioProhibidoIcon, Usuarios } from './iconos/index.mjs';
|
|
52
52
|
export { default as ColorPicker, ColorPickerProps } from './ColorPicker.mjs';
|
|
53
|
+
export { default as ThemeProvider, useTheme } from './theme/ThemeProvider.mjs';
|
|
54
|
+
export { default as ThemeScript } from './theme/ThemeScript.mjs';
|
|
55
|
+
export { default as ThemeToggle } from './theme/ThemeToggle.mjs';
|
|
53
56
|
import 'react';
|
|
54
57
|
import 'react/jsx-runtime';
|
|
55
58
|
import 'framer-motion';
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export { TimeRange, default as TimeRangeField, TimeRangeFieldProps } from './Tim
|
|
|
50
50
|
export { StepDef, default as Steps, StepsNav } from './Steps.js';
|
|
51
51
|
export { Aficionados, AuditarDocumento, Borrar, CajaDeMano, Cajas, Calendario, ChevronLeftRightIcon, CirculoAdvertencia, CirculoExito, CirculoPeligro, CirculoPorDefecto, ClientsIcon, CloseIcon, ContraseniaDeEmailIcon, Cotizaciones, DashboardIcon, Directorio, Edificio, Editar, Empresa, EscaneoFacial, EyeIcon, FlechaAbajo, FlechaArriba, Imagenes, LlamadaTelefonica, LogoutIcon, MarketingDigital, MediosDeComunicacionSocial, MenuIcon, MenuPuntosVerticalIcon, Nota, Ojo, OrdersIcon, PencilIcon, PermsIcon, ProductsIcon, PromoIcon, Retroalimentacion, RolesIcon, Sobre, Tablero, Tarea, Tickets, TrabajoEnEquipo, TrashIcon, UserIcon, UsersIcon, UsuarioProhibidoIcon, Usuarios } from './iconos/index.js';
|
|
52
52
|
export { default as ColorPicker, ColorPickerProps } from './ColorPicker.js';
|
|
53
|
+
export { default as ThemeProvider, useTheme } from './theme/ThemeProvider.js';
|
|
54
|
+
export { default as ThemeScript } from './theme/ThemeScript.js';
|
|
55
|
+
export { default as ThemeToggle } from './theme/ThemeToggle.js';
|
|
53
56
|
import 'react';
|
|
54
57
|
import 'react/jsx-runtime';
|
|
55
58
|
import 'framer-motion';
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,9 @@ __export(index_exports, {
|
|
|
80
80
|
Td: () => import_Table.Td,
|
|
81
81
|
Textarea: () => import_Textarea.default,
|
|
82
82
|
Th: () => import_Table.Th,
|
|
83
|
+
ThemeProvider: () => import_ThemeProvider.default,
|
|
84
|
+
ThemeScript: () => import_ThemeScript.default,
|
|
85
|
+
ThemeToggle: () => import_ThemeToggle.default,
|
|
83
86
|
TimeAgo: () => import_TimeAgo.default,
|
|
84
87
|
TimePanel: () => import_TimePanel.default,
|
|
85
88
|
TimePopover: () => import_TimePopover.default,
|
|
@@ -89,6 +92,7 @@ __export(index_exports, {
|
|
|
89
92
|
TopImpresionesBar: () => import_AnalyticsCharts.TopImpresionesBar,
|
|
90
93
|
UploadCard: () => import_UploadCard.default,
|
|
91
94
|
WeekPopover: () => import_TimePopover2.WeekPopover,
|
|
95
|
+
useTheme: () => import_ThemeProvider.useTheme,
|
|
92
96
|
useToast: () => import_Toast.useToast
|
|
93
97
|
});
|
|
94
98
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -149,6 +153,9 @@ var import_Steps = __toESM(require("./Steps"));
|
|
|
149
153
|
var import_Steps2 = require("./Steps");
|
|
150
154
|
__reExport(index_exports, require("./iconos"), module.exports);
|
|
151
155
|
var import_ColorPicker = __toESM(require("./ColorPicker"));
|
|
156
|
+
var import_ThemeProvider = __toESM(require("./theme/ThemeProvider"));
|
|
157
|
+
var import_ThemeScript = __toESM(require("./theme/ThemeScript"));
|
|
158
|
+
var import_ThemeToggle = __toESM(require("./theme/ThemeToggle"));
|
|
152
159
|
// Annotate the CommonJS export names for ESM import in node:
|
|
153
160
|
0 && (module.exports = {
|
|
154
161
|
ActionIconButton,
|
|
@@ -202,6 +209,9 @@ var import_ColorPicker = __toESM(require("./ColorPicker"));
|
|
|
202
209
|
Td,
|
|
203
210
|
Textarea,
|
|
204
211
|
Th,
|
|
212
|
+
ThemeProvider,
|
|
213
|
+
ThemeScript,
|
|
214
|
+
ThemeToggle,
|
|
205
215
|
TimeAgo,
|
|
206
216
|
TimePanel,
|
|
207
217
|
TimePopover,
|
|
@@ -211,6 +221,7 @@ var import_ColorPicker = __toESM(require("./ColorPicker"));
|
|
|
211
221
|
TopImpresionesBar,
|
|
212
222
|
UploadCard,
|
|
213
223
|
WeekPopover,
|
|
224
|
+
useTheme,
|
|
214
225
|
useToast,
|
|
215
226
|
...require("./Dialog"),
|
|
216
227
|
...require("./Dropdown"),
|
package/dist/index.mjs
CHANGED
|
@@ -55,6 +55,9 @@ import { default as default47 } from "./Steps";
|
|
|
55
55
|
import { StepsNav } from "./Steps";
|
|
56
56
|
export * from "./iconos";
|
|
57
57
|
import { default as default48 } from "./ColorPicker";
|
|
58
|
+
import { default as default49, useTheme } from "./theme/ThemeProvider";
|
|
59
|
+
import { default as default50 } from "./theme/ThemeScript";
|
|
60
|
+
import { default as default51 } from "./theme/ThemeToggle";
|
|
58
61
|
export {
|
|
59
62
|
default3 as ActionIconButton,
|
|
60
63
|
AnimatedBody,
|
|
@@ -107,6 +110,9 @@ export {
|
|
|
107
110
|
Td,
|
|
108
111
|
default5 as Textarea,
|
|
109
112
|
Th,
|
|
113
|
+
default49 as ThemeProvider,
|
|
114
|
+
default50 as ThemeScript,
|
|
115
|
+
default51 as ThemeToggle,
|
|
110
116
|
default28 as TimeAgo,
|
|
111
117
|
default45 as TimePanel,
|
|
112
118
|
default44 as TimePopover,
|
|
@@ -116,5 +122,6 @@ export {
|
|
|
116
122
|
TopImpresionesBar,
|
|
117
123
|
default18 as UploadCard,
|
|
118
124
|
WeekPopover,
|
|
125
|
+
useTheme,
|
|
119
126
|
useToast
|
|
120
127
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
type Theme = "light" | "dark" | "system";
|
|
5
|
+
type ThemeContextValue = {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
isDark: boolean;
|
|
8
|
+
setTheme: (next: Theme) => void;
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare function ThemeProvider({ children, defaultTheme, storageKey, }: {
|
|
12
|
+
children: React__default.ReactNode;
|
|
13
|
+
defaultTheme?: Theme;
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
}): react_jsx_runtime.JSX.Element;
|
|
16
|
+
declare function useTheme(): ThemeContextValue;
|
|
17
|
+
|
|
18
|
+
export { type Theme, ThemeProvider, ThemeProvider as default, useTheme };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
type Theme = "light" | "dark" | "system";
|
|
5
|
+
type ThemeContextValue = {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
isDark: boolean;
|
|
8
|
+
setTheme: (next: Theme) => void;
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare function ThemeProvider({ children, defaultTheme, storageKey, }: {
|
|
12
|
+
children: React__default.ReactNode;
|
|
13
|
+
defaultTheme?: Theme;
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
}): react_jsx_runtime.JSX.Element;
|
|
16
|
+
declare function useTheme(): ThemeContextValue;
|
|
17
|
+
|
|
18
|
+
export { type Theme, ThemeProvider, ThemeProvider as default, useTheme };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var ThemeProvider_exports = {};
|
|
21
|
+
__export(ThemeProvider_exports, {
|
|
22
|
+
ThemeProvider: () => ThemeProvider,
|
|
23
|
+
default: () => ThemeProvider_default,
|
|
24
|
+
useTheme: () => useTheme
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(ThemeProvider_exports);
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
const ThemeContext = (0, import_react.createContext)(null);
|
|
30
|
+
const STORAGE_KEY = "theme";
|
|
31
|
+
function computeIsDark(pref) {
|
|
32
|
+
if (pref === "dark") return true;
|
|
33
|
+
if (pref === "light") return false;
|
|
34
|
+
return typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
35
|
+
}
|
|
36
|
+
function applyThemeToDocument(pref) {
|
|
37
|
+
if (typeof document === "undefined") return;
|
|
38
|
+
const doc = document.documentElement;
|
|
39
|
+
doc.dataset.theme = pref;
|
|
40
|
+
const isDark = computeIsDark(pref);
|
|
41
|
+
doc.classList.toggle("dark", isDark);
|
|
42
|
+
doc.style.colorScheme = isDark ? "dark" : "light";
|
|
43
|
+
}
|
|
44
|
+
function ThemeProvider({
|
|
45
|
+
children,
|
|
46
|
+
defaultTheme = "system",
|
|
47
|
+
storageKey = STORAGE_KEY
|
|
48
|
+
}) {
|
|
49
|
+
const [theme, setThemeState] = (0, import_react.useState)(() => {
|
|
50
|
+
var _a;
|
|
51
|
+
if (typeof window === "undefined") return defaultTheme;
|
|
52
|
+
const stored = (_a = window.localStorage.getItem(storageKey)) != null ? _a : null;
|
|
53
|
+
return stored != null ? stored : defaultTheme;
|
|
54
|
+
});
|
|
55
|
+
const [isDark, setIsDark] = (0, import_react.useState)(() => computeIsDark(theme));
|
|
56
|
+
(0, import_react.useEffect)(() => {
|
|
57
|
+
applyThemeToDocument(theme);
|
|
58
|
+
setIsDark(computeIsDark(theme));
|
|
59
|
+
try {
|
|
60
|
+
window.localStorage.setItem(storageKey, theme);
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}, [theme, storageKey]);
|
|
64
|
+
(0, import_react.useEffect)(() => {
|
|
65
|
+
var _a;
|
|
66
|
+
if (typeof window === "undefined") return;
|
|
67
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
68
|
+
const handler = () => {
|
|
69
|
+
if (theme === "system") {
|
|
70
|
+
applyThemeToDocument("system");
|
|
71
|
+
setIsDark(computeIsDark("system"));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
(_a = mql.addEventListener) == null ? void 0 : _a.call(mql, "change", handler);
|
|
75
|
+
return () => {
|
|
76
|
+
var _a2;
|
|
77
|
+
return (_a2 = mql.removeEventListener) == null ? void 0 : _a2.call(mql, "change", handler);
|
|
78
|
+
};
|
|
79
|
+
}, [theme]);
|
|
80
|
+
const setTheme = (0, import_react.useCallback)((next) => {
|
|
81
|
+
setThemeState(next);
|
|
82
|
+
}, []);
|
|
83
|
+
const toggle = (0, import_react.useCallback)(() => {
|
|
84
|
+
setThemeState((prev) => computeIsDark(prev) ? "light" : "dark");
|
|
85
|
+
}, []);
|
|
86
|
+
const value = (0, import_react.useMemo)(() => ({ theme, isDark, setTheme, toggle }), [theme, isDark, setTheme, toggle]);
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value, children });
|
|
88
|
+
}
|
|
89
|
+
function useTheme() {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const ctx = (0, import_react.useContext)(ThemeContext);
|
|
92
|
+
if (!ctx) {
|
|
93
|
+
const doc = typeof document !== "undefined" ? document.documentElement : null;
|
|
94
|
+
const attr = (_b = (_a = doc == null ? void 0 : doc.dataset) == null ? void 0 : _a.theme) != null ? _b : "system";
|
|
95
|
+
return {
|
|
96
|
+
theme: attr,
|
|
97
|
+
isDark: doc ? doc.classList.contains("dark") : false,
|
|
98
|
+
setTheme: (t) => applyThemeToDocument(t),
|
|
99
|
+
toggle: () => applyThemeToDocument(attr === "dark" ? "light" : "dark")
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return ctx;
|
|
103
|
+
}
|
|
104
|
+
var ThemeProvider_default = ThemeProvider;
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
ThemeProvider,
|
|
108
|
+
useTheme
|
|
109
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
4
|
+
const ThemeContext = createContext(null);
|
|
5
|
+
const STORAGE_KEY = "theme";
|
|
6
|
+
function computeIsDark(pref) {
|
|
7
|
+
if (pref === "dark") return true;
|
|
8
|
+
if (pref === "light") return false;
|
|
9
|
+
return typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
10
|
+
}
|
|
11
|
+
function applyThemeToDocument(pref) {
|
|
12
|
+
if (typeof document === "undefined") return;
|
|
13
|
+
const doc = document.documentElement;
|
|
14
|
+
doc.dataset.theme = pref;
|
|
15
|
+
const isDark = computeIsDark(pref);
|
|
16
|
+
doc.classList.toggle("dark", isDark);
|
|
17
|
+
doc.style.colorScheme = isDark ? "dark" : "light";
|
|
18
|
+
}
|
|
19
|
+
function ThemeProvider({
|
|
20
|
+
children,
|
|
21
|
+
defaultTheme = "system",
|
|
22
|
+
storageKey = STORAGE_KEY
|
|
23
|
+
}) {
|
|
24
|
+
const [theme, setThemeState] = useState(() => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (typeof window === "undefined") return defaultTheme;
|
|
27
|
+
const stored = (_a = window.localStorage.getItem(storageKey)) != null ? _a : null;
|
|
28
|
+
return stored != null ? stored : defaultTheme;
|
|
29
|
+
});
|
|
30
|
+
const [isDark, setIsDark] = useState(() => computeIsDark(theme));
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
applyThemeToDocument(theme);
|
|
33
|
+
setIsDark(computeIsDark(theme));
|
|
34
|
+
try {
|
|
35
|
+
window.localStorage.setItem(storageKey, theme);
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}, [theme, storageKey]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
var _a;
|
|
41
|
+
if (typeof window === "undefined") return;
|
|
42
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
43
|
+
const handler = () => {
|
|
44
|
+
if (theme === "system") {
|
|
45
|
+
applyThemeToDocument("system");
|
|
46
|
+
setIsDark(computeIsDark("system"));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
(_a = mql.addEventListener) == null ? void 0 : _a.call(mql, "change", handler);
|
|
50
|
+
return () => {
|
|
51
|
+
var _a2;
|
|
52
|
+
return (_a2 = mql.removeEventListener) == null ? void 0 : _a2.call(mql, "change", handler);
|
|
53
|
+
};
|
|
54
|
+
}, [theme]);
|
|
55
|
+
const setTheme = useCallback((next) => {
|
|
56
|
+
setThemeState(next);
|
|
57
|
+
}, []);
|
|
58
|
+
const toggle = useCallback(() => {
|
|
59
|
+
setThemeState((prev) => computeIsDark(prev) ? "light" : "dark");
|
|
60
|
+
}, []);
|
|
61
|
+
const value = useMemo(() => ({ theme, isDark, setTheme, toggle }), [theme, isDark, setTheme, toggle]);
|
|
62
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
63
|
+
}
|
|
64
|
+
function useTheme() {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const ctx = useContext(ThemeContext);
|
|
67
|
+
if (!ctx) {
|
|
68
|
+
const doc = typeof document !== "undefined" ? document.documentElement : null;
|
|
69
|
+
const attr = (_b = (_a = doc == null ? void 0 : doc.dataset) == null ? void 0 : _a.theme) != null ? _b : "system";
|
|
70
|
+
return {
|
|
71
|
+
theme: attr,
|
|
72
|
+
isDark: doc ? doc.classList.contains("dark") : false,
|
|
73
|
+
setTheme: (t) => applyThemeToDocument(t),
|
|
74
|
+
toggle: () => applyThemeToDocument(attr === "dark" ? "light" : "dark")
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return ctx;
|
|
78
|
+
}
|
|
79
|
+
var ThemeProvider_default = ThemeProvider;
|
|
80
|
+
export {
|
|
81
|
+
ThemeProvider,
|
|
82
|
+
ThemeProvider_default as default,
|
|
83
|
+
useTheme
|
|
84
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ThemeScript_exports = {};
|
|
20
|
+
__export(ThemeScript_exports, {
|
|
21
|
+
ThemeScript: () => ThemeScript,
|
|
22
|
+
default: () => ThemeScript_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ThemeScript_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
const INIT_SNIPPET = `!function(){try{var d=document.documentElement;var pref=localStorage.getItem('theme')||'system';d.dataset.theme=pref;var m=window.matchMedia('(prefers-color-scheme: dark)');var isDark=(pref==='dark')||(pref==='system'&&m.matches);d.classList.toggle('dark',isDark);d.style.colorScheme=isDark?'dark':'light'}catch(e){}}();`;
|
|
27
|
+
function ThemeScript({ id = "ui-lib-theme-init" }) {
|
|
28
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("script", { id, dangerouslySetInnerHTML: { __html: INIT_SNIPPET } });
|
|
29
|
+
}
|
|
30
|
+
var ThemeScript_default = ThemeScript;
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
ThemeScript
|
|
34
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const INIT_SNIPPET = `!function(){try{var d=document.documentElement;var pref=localStorage.getItem('theme')||'system';d.dataset.theme=pref;var m=window.matchMedia('(prefers-color-scheme: dark)');var isDark=(pref==='dark')||(pref==='system'&&m.matches);d.classList.toggle('dark',isDark);d.style.colorScheme=isDark?'dark':'light'}catch(e){}}();`;
|
|
3
|
+
function ThemeScript({ id = "ui-lib-theme-init" }) {
|
|
4
|
+
return /* @__PURE__ */ jsx("script", { id, dangerouslySetInnerHTML: { __html: INIT_SNIPPET } });
|
|
5
|
+
}
|
|
6
|
+
var ThemeScript_default = ThemeScript;
|
|
7
|
+
export {
|
|
8
|
+
ThemeScript,
|
|
9
|
+
ThemeScript_default as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type ThemeToggleProps = {
|
|
4
|
+
cycle?: ("light" | "dark" | "system")[];
|
|
5
|
+
className?: string;
|
|
6
|
+
labels?: Partial<Record<"light" | "dark" | "system", string>>;
|
|
7
|
+
};
|
|
8
|
+
declare function ThemeToggle({ cycle, className, labels }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { type ThemeToggleProps, ThemeToggle as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type ThemeToggleProps = {
|
|
4
|
+
cycle?: ("light" | "dark" | "system")[];
|
|
5
|
+
className?: string;
|
|
6
|
+
labels?: Partial<Record<"light" | "dark" | "system", string>>;
|
|
7
|
+
};
|
|
8
|
+
declare function ThemeToggle({ cycle, className, labels }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { type ThemeToggleProps, ThemeToggle as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var ThemeToggle_exports = {};
|
|
21
|
+
__export(ThemeToggle_exports, {
|
|
22
|
+
default: () => ThemeToggle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ThemeToggle_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_ThemeProvider = require("./ThemeProvider");
|
|
27
|
+
const defaultCycle = ["light", "dark", "system"];
|
|
28
|
+
function ThemeToggle({ cycle = defaultCycle, className, labels }) {
|
|
29
|
+
var _a;
|
|
30
|
+
const { theme, setTheme, isDark } = (0, import_ThemeProvider.useTheme)();
|
|
31
|
+
const handleClick = () => {
|
|
32
|
+
const idx = cycle.indexOf(theme);
|
|
33
|
+
const next = cycle[(idx + 1) % cycle.length];
|
|
34
|
+
setTheme(next);
|
|
35
|
+
};
|
|
36
|
+
const text = (_a = labels == null ? void 0 : labels[theme]) != null ? _a : theme === "system" ? "Sistema" : theme === "dark" ? "Oscuro" : "Claro";
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
38
|
+
"button",
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
onClick: handleClick,
|
|
42
|
+
"aria-label": `Cambiar tema (actual: ${text})`,
|
|
43
|
+
title: `Cambiar tema (actual: ${text})`,
|
|
44
|
+
className: [
|
|
45
|
+
"inline-flex items-center gap-2 rounded-xl px-3 py-1.5 text-sm font-medium",
|
|
46
|
+
"border border-slate-200 bg-white shadow-sm transition hover:bg-slate-50",
|
|
47
|
+
"dark:border-white/10 dark:bg-white/10 dark:hover:bg-white/15",
|
|
48
|
+
className != null ? className : ""
|
|
49
|
+
].join(" "),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "h-4 w-4 rounded-full " + (isDark ? "bg-slate-100" : "bg-slate-900") }),
|
|
52
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-slate-700 dark:text-slate-200", children: text })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useTheme } from "./ThemeProvider";
|
|
4
|
+
const defaultCycle = ["light", "dark", "system"];
|
|
5
|
+
function ThemeToggle({ cycle = defaultCycle, className, labels }) {
|
|
6
|
+
var _a;
|
|
7
|
+
const { theme, setTheme, isDark } = useTheme();
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
const idx = cycle.indexOf(theme);
|
|
10
|
+
const next = cycle[(idx + 1) % cycle.length];
|
|
11
|
+
setTheme(next);
|
|
12
|
+
};
|
|
13
|
+
const text = (_a = labels == null ? void 0 : labels[theme]) != null ? _a : theme === "system" ? "Sistema" : theme === "dark" ? "Oscuro" : "Claro";
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
type: "button",
|
|
18
|
+
onClick: handleClick,
|
|
19
|
+
"aria-label": `Cambiar tema (actual: ${text})`,
|
|
20
|
+
title: `Cambiar tema (actual: ${text})`,
|
|
21
|
+
className: [
|
|
22
|
+
"inline-flex items-center gap-2 rounded-xl px-3 py-1.5 text-sm font-medium",
|
|
23
|
+
"border border-slate-200 bg-white shadow-sm transition hover:bg-slate-50",
|
|
24
|
+
"dark:border-white/10 dark:bg-white/10 dark:hover:bg-white/15",
|
|
25
|
+
className != null ? className : ""
|
|
26
|
+
].join(" "),
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsx("span", { className: "h-4 w-4 rounded-full " + (isDark ? "bg-slate-100" : "bg-slate-900") }),
|
|
29
|
+
/* @__PURE__ */ jsx("span", { className: "text-slate-700 dark:text-slate-200", children: text })
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
ThemeToggle as default
|
|
36
|
+
};
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
@source "./dist/**/*.{js,mjs,jsx,ts,tsx}";
|
|
2
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
color-scheme: light;
|
|
6
|
+
--background: #f6f8fb;
|
|
7
|
+
--surface: #eef2f7;
|
|
8
|
+
--card: #ffffff;
|
|
9
|
+
--foreground: #0f172a;
|
|
10
|
+
--muted: #6b7280;
|
|
11
|
+
--border: #e5e7eb;
|
|
12
|
+
--primary: #111827;
|
|
13
|
+
--primary-foreground: #ffffff;
|
|
14
|
+
--ring: #60a5fa;
|
|
15
|
+
--fx-surface: #ffffff;
|
|
16
|
+
--fg: var(--foreground);
|
|
17
|
+
--card-bg: var(--card);
|
|
18
|
+
--card-border: var(--border);
|
|
19
|
+
--grid: rgba(148, 163, 184, .18);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@theme inline {
|
|
23
|
+
--color-background: var(--background);
|
|
24
|
+
--color-surface: var(--surface);
|
|
25
|
+
--color-card: var(--card);
|
|
26
|
+
--color-foreground: var(--foreground);
|
|
27
|
+
--color-muted: var(--muted);
|
|
28
|
+
--color-border: var(--border);
|
|
29
|
+
--color-primary: var(--primary);
|
|
30
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
31
|
+
--color-ring: var(--ring);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:root[data-theme="dark"],
|
|
35
|
+
html.dark {
|
|
36
|
+
color-scheme: dark;
|
|
37
|
+
--background: #0b0f14;
|
|
38
|
+
--surface: #0f131a;
|
|
39
|
+
--card: #151a22;
|
|
40
|
+
--foreground: #e6edf3;
|
|
41
|
+
--muted: #9aa4b2;
|
|
42
|
+
--border: #242b35;
|
|
43
|
+
--primary: #0f172a;
|
|
44
|
+
--primary-foreground: #ffffff;
|
|
45
|
+
--ring: #60a5fa;
|
|
46
|
+
--fx-surface: #0f131a;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media (prefers-color-scheme: dark) {
|
|
50
|
+
:root[data-theme="system"] {
|
|
51
|
+
color-scheme: dark;
|
|
52
|
+
--background: #0b0f14;
|
|
53
|
+
--surface: #0f131a;
|
|
54
|
+
--card: #151a22;
|
|
55
|
+
--foreground: #e6edf3;
|
|
56
|
+
--muted: #9aa4b2;
|
|
57
|
+
--border: #242b35;
|
|
58
|
+
--primary: #0f172a;
|
|
59
|
+
--primary-foreground: #ffffff;
|
|
60
|
+
--ring: #60a5fa;
|
|
61
|
+
--fx-surface: #0f131a;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
body {
|
|
66
|
+
background: var(--background);
|
|
67
|
+
color: var(--foreground);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
* {
|
|
71
|
+
outline-color: var(--ring);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
::selection {
|
|
75
|
+
background: color-mix(in oklab, var(--ring) 30%, transparent);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media print {
|
|
79
|
+
.no-print {
|
|
80
|
+
display: none !important;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
html,
|
|
84
|
+
body {
|
|
85
|
+
background: var(--background);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.print-snapshot *,
|
|
90
|
+
.print-snapshot *::before,
|
|
91
|
+
.print-snapshot *::after {
|
|
92
|
+
-webkit-font-smoothing: antialiased;
|
|
93
|
+
-moz-osx-font-smoothing: grayscale;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.print-snapshot .sticky {
|
|
97
|
+
position: static !important;
|
|
98
|
+
top: auto !important;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.print-snapshot .shadow,
|
|
102
|
+
.print-snapshot .shadow-sm,
|
|
103
|
+
.print-snapshot .shadow-md,
|
|
104
|
+
.print-snapshot .shadow-lg {
|
|
105
|
+
box-shadow: none !important;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.print-snapshot .overflow-auto,
|
|
109
|
+
.print-snapshot .overflow-x-auto,
|
|
110
|
+
.print-snapshot .overflow-y-auto {
|
|
111
|
+
overflow: visible !important;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.print-snapshot .pointer-events-none {
|
|
115
|
+
pointer-events: auto;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.print-snapshot .group:hover .group-hover\:opacity-100 {
|
|
119
|
+
opacity: 1 !important;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.print-snapshot .transition-opacity,
|
|
123
|
+
.print-snapshot .transition-colors,
|
|
124
|
+
.print-snapshot .transition {
|
|
125
|
+
transition: none !important;
|
|
126
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framepexls-ui-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Componentes UI de Framepexls para React/Next.",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.mjs",
|
|
14
14
|
"require": "./dist/index.js"
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
|
+
"./theme.css": "./dist/theme.css"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
19
|
"dist",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"typescript": "^5.9.3"
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
|
-
"build": "tsup",
|
|
52
|
+
"build": "tsup && node scripts/copy-css.mjs",
|
|
52
53
|
"dev": "tsup --watch",
|
|
53
54
|
"prepare": "npm run build"
|
|
54
55
|
},
|