Files
sigpro-ui/dist/sigpro-ui.js
natxocc 971133d430
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
small changes
2026-04-26 21:05:58 +02:00

1533 lines
60 KiB
JavaScript

(() => {
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __hasOwnProp = Object.prototype.hasOwnProperty;
function __accessProp(key) {
return this[key];
}
var __toCommonJS = (from) => {
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
if (entry)
return entry;
entry = __defProp({}, "__esModule", { value: true });
if (from && typeof from === "object" || typeof from === "function") {
for (var key of __getOwnPropNames(from))
if (!__hasOwnProp.call(entry, key))
__defProp(entry, key, {
get: __accessProp.bind(from, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
__moduleCache.set(from, entry);
return entry;
};
var __moduleCache;
var __returnValue = (v) => v;
function __exportSetter(name, newValue) {
this[name] = __returnValue.bind(null, newValue);
}
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
enumerable: true,
configurable: true,
set: __exportSetter.bind(all, name)
});
};
// index.js
var exports_sigpro_ui = {};
__export(exports_sigpro_ui, {
Utils: () => Utils,
Components: () => Components
});
// components/All.js
var exports_All = {};
__export(exports_All, {
rand: () => rand,
listKey: () => listKey,
isFn: () => isFn,
getBy: () => getBy,
get: () => get,
filterBy: () => filterBy,
cls: () => cls,
close: () => close,
Tooltip: () => Tooltip,
Toggle: () => Toggle,
Toast: () => Toast,
Timeline: () => Timeline,
Textarea: () => Textarea,
TextRotate: () => TextRotate,
Tabs: () => Tabs,
Table: () => Table,
Swap: () => Swap,
Steps: () => Steps,
Step: () => Step,
Stack: () => Stack,
SkeletonText: () => SkeletonText,
Skeleton: () => Skeleton,
Select: () => Select,
Rating: () => Rating,
Range: () => Range,
Radio: () => Radio,
Radial: () => Radial,
Progress: () => Progress,
Navbar: () => Navbar,
Modal: () => Modal,
Menu: () => Menu,
Loading: () => Loading,
List: () => List,
Kbd: () => Kbd,
Input: () => Input,
Indicator: () => Indicator,
Icon: () => Icon,
Fileinput: () => Fileinput,
Fieldset: () => Fieldset,
Fab: () => Fab,
Dropdown: () => Dropdown,
Drawer: () => Drawer,
Divider: () => Divider,
Datepicker: () => Datepicker,
Colorpicker: () => Colorpicker,
Checkbox: () => Checkbox,
ChatImage: () => ChatImage,
ChatHeader: () => ChatHeader,
ChatFooter: () => ChatFooter,
ChatBubble: () => ChatBubble,
Chat: () => Chat,
CarouselItem: () => CarouselItem,
Carousel: () => Carousel,
Card: () => Card,
Calendar: () => Calendar,
Button: () => Button,
Badge: () => Badge,
Autocomplete: () => Autocomplete,
Alert: () => Alert,
Accordion: () => Accordion
});
// node_modules/sigpro/dist/sigpro.esm.min.js
var y = (e) => typeof e === "function";
var P = (e) => e && typeof e === "object";
var b = Array.isArray;
var g = typeof document < "u" ? document : null;
var k = (e) => e?._isRuntime ? e.container : e instanceof Node ? e : g.createTextNode(e == null ? "" : String(e));
var p = null;
var _ = null;
var x = false;
var A = 0;
var C = new Set;
var D = new WeakMap;
var $ = Symbol("iter");
var B = new WeakMap;
var E = (e) => {
if (!e || e._disposed)
return;
e._disposed = true;
let o = [e];
while (o.length) {
let n = o.pop();
if (n._cleanups)
n._cleanups.forEach((i) => i()), n._cleanups.clear();
if (n._children)
n._children.forEach((i) => o.push(i)), n._children.clear();
if (n._deps)
n._deps.forEach((i) => i.delete(n)), n._deps.clear();
}
};
var N = (e) => {
if (_)
(_._cleanups ||= new Set).add(e);
};
var V = (e) => {
let o = p;
p = null;
try {
return e();
} finally {
p = o;
}
};
var T = (e, o = false) => {
let n = () => {
if (n._disposed)
return;
if (n._deps)
n._deps.forEach((c) => c.delete(n));
if (n._cleanups)
n._cleanups.forEach((c) => c()), n._cleanups.clear();
let i = p, s = _;
p = _ = n;
try {
return n._result = e();
} catch (c) {
console.error("[SigPro]", c);
} finally {
p = i, _ = s;
}
};
if (n._deps = n._cleanups = n._children = null, n._disposed = false, n._isComputed = o, n._depth = p ? p._depth + 1 : 0, n._mounts = [], n._parent = _, _)
(_._children ||= new Set).add(n);
return n;
};
var q = () => {
if (x)
return;
x = true;
let e = Array.from(C).sort((o, n) => o._depth - n._depth);
C.clear();
for (let o of e)
if (!o._disposed)
o();
x = false;
};
var W = (e) => {
A++;
try {
return e();
} finally {
if (A--, A === 0 && C.size > 0 && !x)
q();
}
};
var w = (e, o = false) => {
if (!o && p && !p._disposed)
e.add(p), (p._deps ||= new Set).add(e);
else if (o && e.size > 0) {
let n = false;
for (let i of e) {
if (i === p || i._disposed)
continue;
if (i._isComputed) {
if (i._dirty = true, i._subs)
w(i._subs, true);
} else
C.add(i), n = true;
}
if (n && !x && A === 0)
queueMicrotask(q);
}
};
var S = (e, o = null) => {
let n = new Set;
if (y(e)) {
let i, s = () => {
if (s._dirty) {
let c = p;
p = s;
try {
let t = e();
if (!Object.is(i, t))
i = t, w(n, true);
} finally {
p = c;
}
s._dirty = false;
}
return w(n), i;
};
if (s._isComputed = true, s._subs = n, s._dirty = true, s._deps = null, s._disposed = false, s.stop = () => {}, _)
N(s.stop);
return s;
}
if (o)
try {
e = JSON.parse(localStorage.getItem(o)) ?? e;
} catch (i) {}
return (...i) => {
if (i.length) {
let s = y(i[0]) ? i[0](e) : i[0];
if (!Object.is(e, s)) {
if (e = s, o)
localStorage.setItem(o, JSON.stringify(e));
w(n, true);
}
}
return w(n), e;
};
};
var I = (e) => {
if (!P(e))
return e;
let o = D.get(e);
if (o)
return o;
let n = new Map, i = (c) => {
let t = n.get(c);
if (!t)
n.set(c, t = new Set);
return t;
}, s = new Proxy(e, { get(c, t, r) {
if (typeof t !== "symbol")
w(i(t));
return I(Reflect.get(c, t, r));
}, set(c, t, r, l) {
let u = Reflect.has(c, t), a = Reflect.get(c, t, l), f = Reflect.set(c, t, r, l);
if (f && !Object.is(a, r)) {
if (w(i(t), true), !u)
w(i($), true);
}
return f;
}, deleteProperty(c, t) {
let r = Reflect.deleteProperty(c, t);
if (r)
w(i(t), true), w(i($), true);
return r;
}, ownKeys(c) {
return w(i($)), Reflect.ownKeys(c);
} });
return D.set(e, s), s;
};
var R = (e, o) => {
if (o === undefined) {
let i = T(e);
return i(), () => E(i);
}
let n = T(() => {
let i = Array.isArray(e) ? e.map((s) => s()) : e();
V(() => o(i));
});
return n(), () => E(n);
};
var L = (e) => {
if (!e)
return;
if (e._cleanups)
e._cleanups.forEach((o) => o()), e._cleanups.clear();
if (e._ownerEffect)
E(e._ownerEffect);
if (e.childNodes)
e.childNodes.forEach((o) => L(o));
};
var F = /^\s*(javascript|data|vbscript):/i;
var J = (e) => e === "src" || e === "href" || e.startsWith("on");
var M = (e, o) => {
if (o == null || o === false)
return null;
if (J(e)) {
let n = String(o);
if (F.test(n))
return console.warn(`[SigPro] Bloqueado protocolo peligroso en ${e}`), "#";
}
return o;
};
var O = (e, o = {}, n = []) => {
if (o instanceof Node || b(o) || !P(o))
n = o, o = {};
if (y(e)) {
let t = T(() => {
let a = e(o, { children: n, emit: (f, ...h) => o[`on${f[0].toUpperCase()}${f.slice(1)}`]?.(...h) });
return t._result = a, a;
});
t();
let r = t._result;
if (r == null)
return null;
let l = r instanceof Node || b(r) && r.every((a) => a instanceof Node) ? r : g.createTextNode(String(r)), u = (a) => {
if (P(a) && !a._isRuntime)
a._mounts = t._mounts || [], a._cleanups = t._cleanups || new Set, a._ownerEffect = t;
};
return b(l) ? l.forEach(u) : u(l), l;
}
let i = /^(svg|path|circle|rect|line|poly(line|gon)|g|defs|text(path)?|tspan|use|symbol|image|marker|ellipse)$/i.test(e), s = i ? g.createElementNS("http://www.w3.org/2000/svg", e) : g.createElement(e);
s._cleanups = new Set;
for (let t in o) {
if (!o.hasOwnProperty(t))
continue;
let r = o[t];
if (t === "ref") {
y(r) ? r(s) : r.current = s;
continue;
}
if (i && t.startsWith("xlink:")) {
r == null ? s.removeAttributeNS("http://www.w3.org/1999/xlink", t.slice(6)) : s.setAttributeNS("http://www.w3.org/1999/xlink", t.slice(6), r);
continue;
}
if (t.startsWith("on")) {
let l = t.slice(2).toLowerCase();
s.addEventListener(l, r);
let u = () => s.removeEventListener(l, r);
s._cleanups.add(u), N(u);
} else if (y(r)) {
let l = T(() => {
let u = M(t, r());
if (t === "class")
s.className = u || "";
else if (u == null)
s.removeAttribute(t);
else if (t in s && !i)
s[t] = u;
else
s.setAttribute(t, u === true ? "" : u);
});
if (l(), s._cleanups.add(() => E(l)), N(() => E(l)), /^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName) && (t === "value" || t === "checked")) {
let u = t === "checked" ? "change" : "input";
s.addEventListener(u, (a) => r(a.target[t]));
}
} else {
let l = M(t, r);
if (l != null)
if (t in s && !i)
s[t] = l;
else
s.setAttribute(t, l === true ? "" : l);
}
}
let c = (t) => {
if (b(t))
return t.forEach(c);
if (y(t)) {
let r = g.createTextNode("");
s.appendChild(r);
let l = [], u = T(() => {
let a = t(), f = (b(a) ? a : [a]).map(k);
l.forEach((d) => {
if (d._isRuntime)
d.destroy();
else
L(d);
if (d.parentNode)
d.remove();
});
let h = r;
for (let d = f.length - 1;d >= 0; d--) {
let m = f[d];
if (m.parentNode !== h.parentNode)
h.parentNode?.insertBefore(m, h);
if (m._mounts)
m._mounts.forEach((U) => U());
h = m;
}
l = f;
});
u(), s._cleanups.add(() => E(u)), N(() => E(u));
} else {
let r = k(t);
if (s.appendChild(r), r._mounts)
r._mounts.forEach((l) => l());
}
};
return c(n), s;
};
var j = (e) => {
let o = new Set, n = _, i = p, s = g.createElement("div");
s.style.display = "contents", s.setAttribute("role", "presentation"), _ = { _cleanups: o }, p = null;
let c = (t) => {
if (!t)
return;
if (t._isRuntime)
o.add(t.destroy), s.appendChild(t.container);
else if (b(t))
t.forEach(c);
else
s.appendChild(t instanceof Node ? t : g.createTextNode(String(t == null ? "" : t)));
};
try {
c(e({ onCleanup: (t) => o.add(t) }));
} finally {
_ = n, p = i;
}
return { _isRuntime: true, container: s, destroy: () => {
o.forEach((t) => t()), L(s), s.remove();
} };
};
var z = (e, o, n = null) => {
let i = g.createTextNode(""), s = O("div", { style: "display:contents" }, [i]), c = null;
return R(() => !!(y(e) ? e() : e), (t) => {
if (c)
c.destroy(), c = null;
let r = t ? o : n;
if (r)
c = j(() => y(r) ? r() : r), s.insertBefore(c.container, i);
}), N(() => c?.destroy()), s;
};
var G = ({ name: e, duration: o = 200, scale: n, slide: i, rotate: s, blur: c }, t) => {
let r = typeof t === "function" ? t() : t;
if (!(r instanceof Node))
return r;
if (e)
return r.style.animation = `${e}-in ${o}ms`, r;
let l = n || i || s || c, u = [n ? "scale(0.95)" : "", i ? "translateY(-10px)" : "", s ? "rotate(-2deg)" : ""].filter(Boolean).join(" ");
if (r.style.transition = `all ${o}ms ease`, r.style.opacity = "0", l)
r.style.transform = u;
if (c)
r.style.filter = "blur(4px)";
return requestAnimationFrame(() => {
if (r.style.opacity = "1", l)
r.style.transform = "none";
if (c)
r.style.filter = "none";
}), r;
};
var K = (e, o, n) => {
let i = g.createTextNode(""), s = O("div", { style: "display:contents" }, [i]), c = new Map;
return R(() => (y(e) ? e() : e) || [], (t) => {
let r = new Map, l = [], u = t || [];
for (let f = 0;f < u.length; f++) {
let h = u[f], d = n ? h?.[n] ?? f : h?.id ?? f, m = c.get(d);
if (!m)
m = j(() => o(h, f));
else
c.delete(d);
r.set(d, m), l.push(m);
}
c.forEach((f) => f.destroy());
let a = i;
for (let f = l.length - 1;f >= 0; f--) {
let d = l[f].container;
if (d.nextSibling !== a)
s.insertBefore(d, a);
a = d;
}
c = r;
}), s;
};
var v = (e) => {
let o = () => window.location.hash.slice(1) || "/", n = S(o()), i = () => n(o());
window.addEventListener("hashchange", i), N(() => window.removeEventListener("hashchange", i));
let s = O("div", { class: "router-hook" }), c = null;
return R([n], () => {
let t = n(), r = e.find((l) => {
let u = l.path.split("/").filter(Boolean), a = t.split("/").filter(Boolean);
return u.length === a.length && u.every((f, h) => f[0] === ":" || f === a[h]);
}) || e.find((l) => l.path === "*");
if (r) {
c?.destroy();
let l = {};
r.path.split("/").filter(Boolean).forEach((u, a) => {
if (u[0] === ":")
l[u.slice(1)] = t.split("/").filter(Boolean)[a];
}), v.params(l), c = j(() => y(r.component) ? r.component(l) : r.component), s.replaceChildren(c.container);
}
}), s;
};
v.params = S({});
v.to = (e) => window.location.hash = e.replace(/^#?\/?/, "#/");
v.back = () => window.history.back();
v.path = () => window.location.hash.replace(/^#/, "") || "/";
var Q = ({ url: e, method: o = "GET", headers: n = {} }) => {
let i = S(false), s = S(null), c = S(null), t = null, r = null;
return { run: async (a = null) => {
t?.abort(), clearTimeout(r), t = new AbortController, r = setTimeout(() => t.abort(), 1e4), i(true), s(null);
try {
let f = a instanceof FormData, h = await fetch(e, { method: o, headers: f ? n : { "Content-Type": "application/json", ...n }, body: f ? a : a ? JSON.stringify(a) : undefined, signal: t.signal }), d = await h.text(), m = d ? JSON.parse(d) : null;
if (!h.ok)
throw Error(m?.message || h.statusText);
return c(m), m;
} catch (f) {
if (f.name !== "AbortError")
s(f.message);
throw f;
} finally {
i(false), clearTimeout(r), t = null, r = null;
}
}, abort: () => t?.abort(), loading: i, error: s, data: c };
};
var H = (e, o) => {
let n = typeof o === "string" ? g.querySelector(o) : o;
if (!n)
return;
if (B.has(n))
B.get(n).destroy();
let i = j(y(e) ? e : () => e);
return n.replaceChildren(i.container), B.set(n, i), i;
};
var X = Object.freeze({ $: S, $$: I, watch: R, h: O, when: z, each: K, fx: G, router: v, req: Q, mount: H, batch: W });
if (typeof window < "u")
Object.assign(window, X), "a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video".split(" ").forEach((e) => {
window[e] = (o, n) => O(e, o, n);
});
// components/All.js
var get = (val) => typeof val === "function" ? val() : val;
var getBy = (item, field = "label") => item && typeof item === "object" ? item[field] : item;
var cls = (...classes) => classes.filter(Boolean).join(" ").trim();
var isFn = (f) => typeof f === "function";
var filterBy = (items, query, field = "label", q2 = String(query).toLowerCase()) => !query ? get(items) : get(items).filter((item) => String(item && typeof item === "object" ? item[field] : item).toLowerCase().includes(q2));
var rand = (r) => `${r}-${Math.random().toString(36).slice(2, 9)}`;
var close = () => document.activeElement?.blur();
var listKey = (items, isOpen) => {
const cursor = S(-1);
R(() => {
if (!get(isOpen))
cursor(-1);
});
const onKey = (e, select) => {
const list = get(items), i = cursor(), len = list.length;
if (!len)
return;
const k2 = e.key;
k2 === "ArrowDown" ? (e.preventDefault(), isOpen(true), cursor(Math.min(i + 1, len - 1))) : k2 === "ArrowUp" ? (e.preventDefault(), cursor(Math.max(i - 1, 0))) : k2 === "Enter" ? i >= 0 && (e.preventDefault(), select(list[i])) : k2 === "Escape" && isOpen(false);
};
return { cursor, onKey };
};
var Accordion = (p2) => {
const name = p2.name || rand("acc");
return K(p2.items, (it) => {
return O("div", { class: cls("collapse", p2.class) }, [
O("input", { type: "radio", name, checked: it.open || undefined }),
it.title ? O("div", { class: cls("collapse-title", `${it.classTitle ?? " font-semibold"}`) }, it.title) : null,
it.content ? O("div", { class: cls("collapse-content text-sm", `${it.classContent ?? " font-semibold"}`) }, it.content) : null
]);
});
};
var Alert = (p2, c) => O("div", { ...p2, class: cls("alert", p2.class) }, c);
var Autocomplete = ({ items, value, onselect, placeholder = "Buscar...", ...props }) => {
const query = S(get(value) || "");
const isOpen = S(false);
const filtered = S(() => filterBy(items, query()));
const { cursor, onKey } = listKey(filtered, isOpen);
const pick = (item) => {
const display = getBy(item);
const actual = typeof item === "string" ? item : item.value;
query(display);
if (isFn(value))
value(actual);
onselect?.(item);
isOpen(false);
};
return O("div", { class: "relative w-full" }, [
Input({
...props,
type: "text",
placeholder,
value: query,
left: O("span", { class: "icon-[lucide--search]" }),
oninput: (e) => {
query(e.target.value);
if (isFn(value))
value(e.target.value);
isOpen(true);
},
onfocus: () => isOpen(true),
onblur: () => setTimeout(() => isOpen(false), 150),
onkeydown: (e) => onKey(e, pick)
}),
z(isOpen, () => G({ duration: 200, slide: true }, O("ul", {
class: "absolute left-0 w-full menu bg-base-100 rounded-box mt-1 p-2 shadow-xl max-h-60 overflow-y-auto border border-base-300 z-50 flex-col flex-nowrap"
}, [
K(filtered, (item, idx) => O("li", {}, [
O("a", {
class: () => cursor() === idx ? "active bg-primary text-primary-content" : "",
onmousedown: (e) => e.preventDefault(),
onclick: () => pick(item),
onmouseenter: () => cursor(idx)
}, getBy(item))
]), (item, idx) => getBy(item) + idx),
() => filtered().length === 0 ? O("li", { class: "p-4 opacity-50 text-center" }, "Sin resultados") : null
])))
]);
};
var Badge = (p2, c) => O("span", { ...p2, class: cls("badge", p2.class) }, c);
var Button = (p2, c) => O("button", { ...p2, class: cls("btn", p2.class) }, c);
var Calendar = (p2) => {
const internalDate = S(new Date);
const hoverDate = S(null);
const startHour = S(0);
const endHour = S(0);
const now = new Date;
const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
const fmt = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
const rangeMode = () => get(p2.range) === true;
const current = () => get(p2.value);
const selectDate = (date) => {
const s = fmt(date);
const v2 = current();
if (rangeMode()) {
if (!v2?.start || v2.start && v2.end) {
p2.onChange?.({ start: s, end: null, ...p2.hour && { startHour: startHour() } });
} else {
const start = v2.start;
const nv = s < start ? { start: s, end: start } : { start, end: s };
if (p2.hour) {
nv.startHour = v2.startHour ?? startHour();
nv.endHour = endHour();
}
p2.onChange?.(nv);
}
} else {
p2.onChange?.(p2.hour ? `${s}T${String(startHour()).padStart(2, "0")}:00:00` : s);
}
};
const move = (m) => {
const d = internalDate();
internalDate(new Date(d.getFullYear(), d.getMonth() + m, 1));
};
const moveYear = (y2) => {
const d = internalDate();
internalDate(new Date(d.getFullYear() + y2, d.getMonth(), 1));
};
const HourSlider = ({ value: hVal, onChange: onH }) => O("div", { class: "flex-1" }, [
O("div", { class: "flex gap-2 items-center" }, [
O("input", { type: "range", min: 0, max: 23, value: hVal, class: "range range-xs flex-1", oninput: (e) => onH(+e.target.value) }),
O("span", { class: "text-sm font-mono min-w-[48px] text-center" }, () => String(get(hVal)).padStart(2, "0") + ":00")
])
]);
return O("div", { class: cls("p-4 bg-base-100 border border-base-300 shadow-2xl rounded-box w-80 select-none", p2.class) }, [
O("div", { class: "flex justify-between items-center mb-4 gap-1" }, [
O("div", { class: "flex gap-0.5" }, [
O("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(-1) }, O("span", { class: "icon-[lucide--chevrons-left]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(-1) }, O("span", { class: "icon-[lucide--chevron-left]" }))
]),
O("span", { class: "font-bold uppercase flex-1 text-center" }, () => internalDate().toLocaleString("es-ES", { month: "short", year: "numeric" })),
O("div", { class: "flex gap-0.5" }, [
O("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(1) }, O("span", { class: "icon-[lucide--chevron-right]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(1) }, O("span", { class: "icon-[lucide--chevrons-right]" }))
])
]),
O("div", { class: "grid grid-cols-7 gap-1", onmouseleave: () => hoverDate(null) }, [
...["L", "M", "X", "J", "V", "S", "D"].map((d) => O("div", { class: "text-[10px] opacity-40 font-bold text-center" }, d)),
() => {
const d = internalDate(), y2 = d.getFullYear(), m = d.getMonth();
const firstDay = new Date(y2, m, 1).getDay();
const offset = firstDay === 0 ? 6 : firstDay - 1;
const dim = new Date(y2, m + 1, 0).getDate();
const cells = [];
for (let i = 0;i < offset; i++)
cells.push(O("div"));
for (let i = 1;i <= dim; i++) {
const date = new Date(y2, m, i), ds = fmt(date);
cells.push(O("button", {
type: "button",
class: () => {
const v2 = current(), h = hoverDate();
const isStart = typeof v2 === "string" ? v2.split("T")[0] === ds : v2?.start === ds;
const isEnd = v2?.end === ds;
let inRange = false;
if (rangeMode() && v2?.start) {
const start = v2.start;
if (!v2.end && h)
inRange = ds > start && ds <= h || ds < start && ds >= h;
else if (v2.end)
inRange = ds > start && ds < v2.end;
}
const base = "btn btn-xs p-0 aspect-square min-h-0 h-auto font-normal relative";
const st = isStart || isEnd ? "btn-primary z-10" : inRange ? "bg-primary/20 border-none rounded-none" : "btn-ghost";
const today = ds === todayStr ? "ring-1 ring-primary ring-inset font-black text-primary" : "";
return cls(base, st, today);
},
onmouseenter: () => rangeMode() && hoverDate(ds),
onclick: () => selectDate(date)
}, i.toString()));
}
return cells;
}
]),
p2.hour ? O("div", { class: "mt-3 pt-2 border-t border-base-300" }, rangeMode() ? O("div", { class: "flex gap-4" }, [HourSlider({ value: startHour, onChange: (h) => startHour(h) }), HourSlider({ value: endHour, onChange: (h) => endHour(h) })]) : HourSlider({ value: startHour, onChange: (h) => startHour(h) })) : null
]);
};
var Card = (p2, c) => {
if (!p2.title && !p2.body && !p2.actions && !c)
return O("div", { ...p2, class: cls("card", p2.class) }, c);
return O("div", { ...p2, class: cls("card", p2.class) }, [
p2.title && O("div", { class: cls("card-title", p2.titleClass) }, p2.title),
(p2.body || c) && O("div", { class: cls("card-body", p2.bodyClass) }, p2.body || c),
p2.actions && O("div", { class: cls("card-actions", p2.actionsClass) }, p2.actions)
].filter(Boolean));
};
var Carousel = (p2, c) => O("div", { ...p2, class: cls("carousel", p2.class) }, c);
var CarouselItem = (p2, c) => O("div", { ...p2, class: cls("carousel-item", p2.class) }, c);
var Chat = (p2, c) => O("div", { ...p2, class: cls("chat", p2.class) }, c);
var ChatBubble = (p2, c) => O("div", { ...p2, class: cls("chat-bubble", p2.class) }, c);
var ChatFooter = (p2, c) => O("div", { ...p2, class: cls("chat-footer", p2.class) }, c);
var ChatHeader = (p2, c) => O("div", { ...p2, class: cls("chat-header", p2.class) }, c);
var ChatImage = (p2, c) => O("div", { ...p2, class: cls("chat-image avatar", p2.class) }, O("div", { class: "w-10 rounded-full" }, typeof c === "string" ? O("img", { src: c, alt: "avatar" }) : c));
var Checkbox = (p2) => O("input", { ...p2, type: "checkbox", class: cls("checkbox", p2.class) });
var Colorpicker = (p2) => {
const isOpen = S(false);
const current = () => get(p2.value) || "#000000";
const palette = [
"#000",
"#1A1A1A",
"#333",
"#4D4D4D",
"#666",
"#808080",
"#B3B3B3",
"#FFF",
"#450a0a",
"#7f1d1d",
"#991b1b",
"#b91c1c",
"#dc2626",
"#ef4444",
"#f87171",
"#fca5a5",
"#431407",
"#7c2d12",
"#9a3412",
"#c2410c",
"#ea580c",
"#f97316",
"#fb923c",
"#ffedd5",
"#713f12",
"#a16207",
"#ca8a04",
"#eab308",
"#facc15",
"#fde047",
"#fef08a",
"#fff9c4",
"#064e3b",
"#065f46",
"#059669",
"#10b981",
"#34d399",
"#4ade80",
"#84cc16",
"#d9f99d",
"#082f49",
"#075985",
"#0284c7",
"#0ea5e9",
"#38bdf8",
"#7dd3fc",
"#22d3ee",
"#cffafe",
"#1e1b4b",
"#312e81",
"#4338ca",
"#4f46e5",
"#6366f1",
"#818cf8",
"#a5b4fc",
"#e0e7ff",
"#2e1065",
"#4c1d95",
"#6d28d9",
"#7c3aed",
"#8b5cf6",
"#a855f7",
"#d946ef",
"#fae8ff"
];
const pick = (c) => {
isFn(p2.value) ? p2.value(c) : p2.onchange?.(c);
isOpen(false);
};
return O("div", { class: cls("relative w-fit", p2.class) }, [
O("button", {
type: "button",
class: "btn px-3 bg-base-100 border-base-300 hover:border-primary/50 flex items-center gap-2 shadow-sm font-normal normal-case",
onclick: (e) => {
e.stopPropagation();
isOpen(!isOpen());
}
}, [
O("div", { class: "size-5 rounded-sm shadow-inner border border-black/10 shrink-0", style: () => `background-color: ${current()}` }),
p2.label && O("span", { class: "opacity-80" }, p2.label)
]),
z(isOpen, () => [
O("div", {
class: "fixed inset-0 z-[100]",
onclick: () => isOpen(false)
}),
O("div", { class: "absolute left-0 mt-2 p-3 bg-base-100 border border-base-300 shadow-2xl rounded-box z-[110] w-64 select-none" }, O("div", { class: "grid grid-cols-8 gap-1" }, palette.map((c) => O("button", {
type: "button",
style: `background-color: ${c}`,
class: () => {
const act = current().toLowerCase() === c.toLowerCase();
return `size-6 rounded-sm cursor-pointer transition-all hover:scale-125 hover:z-10 active:scale-95 outline-none border border-black/5 p-0 min-h-0 ${act ? "ring-2 ring-offset-1 ring-primary z-10 scale-110" : ""}`;
},
onclick: () => pick(c)
}))))
])
]);
};
var Datepicker = (p2) => {
const isOpen = S(false);
const displayValue = S("");
const rangeMode = () => get(p2.range) === true;
R(() => {
const v2 = get(p2.value);
if (!v2)
return displayValue("");
let text = "";
if (typeof v2 === "string") {
text = p2.hour && v2.includes("T") ? v2.replace("T", " ") : v2;
} else if (v2.start && v2.end) {
const startStr = p2.hour && v2.startHour != null ? `${v2.start} ${String(v2.startHour).padStart(2, "0")}:00` : v2.start;
const endStr = p2.hour && v2.endHour != null ? `${v2.end} ${String(v2.endHour).padStart(2, "0")}:00` : v2.end;
text = `${startStr} - ${endStr}`;
} else if (v2.start) {
const startStr = p2.hour && v2.startHour != null ? `${v2.start} ${String(v2.startHour).padStart(2, "0")}:00` : v2.start;
text = `${startStr}...`;
}
displayValue(text);
});
const handleChange = (val) => {
if (isFn(p2.value))
p2.value(val);
else
p2.onChange?.(val);
if (!rangeMode() || val?.end != null)
isOpen(false);
};
return O("div", { class: cls("relative w-full", p2.class) }, [
O("label", { class: "input input-bordered w-full", onclick: (e) => {
e.stopPropagation();
isOpen(!isOpen());
} }, [
O("span", { class: "icon-[lucide--calendar]" }),
O("input", {
...p2,
type: "text",
class: "grow",
value: displayValue,
readonly: true,
placeholder: p2.placeholder || (rangeMode() ? "Seleccionar rango..." : "Seleccionar fecha...")
})
]),
z(isOpen, () => [
O("div", { class: "fixed inset-0 z-[90]", onclick: () => isOpen(false) }),
O("div", { class: "absolute left-0 mt-2 z-[100]", onclick: (e) => e.stopPropagation() }, Calendar({ value: p2.value, range: rangeMode(), hour: p2.hour, onChange: handleChange }))
])
]);
};
var Drawer = (p2, c) => {
const id = p2.id || rand("drawer");
return O("div", { class: cls("drawer", p2.class) }, [
O("input", { id, type: "checkbox", class: "drawer-toggle", checked: () => get(p2.open), onchange: (e) => isFn(p2.open) && p2.open(e.target.checked) }),
O("div", { class: "drawer-side" }, [O("label", { for: id, class: "drawer-overlay", onclick: () => isFn(p2.open) && p2.open(false) }), O("div", { class: "min-h-full bg-base-200 w-80 p-4" }, () => get(p2.side))]),
O("div", { class: "drawer-content" }, c)
]);
};
var Divider = (p2) => O("div", { ...p2, class: cls("divider", p2.class) });
var Dropdown = (p2, c) => {
return O("div", { ...p2, class: cls("dropdown", p2.class) }, [
O("div", { tabindex: "0", role: "button", class: cls("btn", p2.buttonClass) }, p2.label),
O("div", { tabindex: "-1", class: "dropdown-content" }, c)
]);
};
var Fab = (p2, c) => O("div", { class: "fab" }, [O("div", { tabindex: "0", role: "button", class: cls("btn", p2.class) }, Icon(p2.icon)), c]);
var Fieldset = (p2, c) => O("fieldset", { class: cls("fieldset", p2.class) }, [O("legend", { class: "fieldset-legend" }, p2.label), c]);
var Fileinput = (p2) => {
const files = S([]);
const drag = S(false);
const error = S(null);
const maxBytes = (p2.max || 2) * 1024 * 1024;
const process = (fileList) => {
const arr = Array.from(fileList);
error(null);
if (arr.some((f) => f.size > maxBytes)) {
error(`Máx ${p2.max || 2}MB`);
return;
}
const updated = [...files(), ...arr];
files(updated);
if (isFn(p2.onselect))
p2.onselect(updated);
else if (isFn(p2.value))
p2.value(updated);
};
const remove = (idx) => {
const updated = files().filter((_2, i) => i !== idx);
files(updated);
if (isFn(p2.onselect))
p2.onselect(updated);
else if (isFn(p2.value))
p2.value(updated);
};
return O("div", { class: cls("fieldset w-full p-0", p2.class) }, [
O("label", {
class: () => `relative flex items-center justify-between w-full h-12 px-4 border-2 border-dashed rounded-lg cursor-pointer transition-all duration-200 ${drag() ? "border-primary bg-primary/10" : "border-base-content/20 bg-base-100 hover:bg-base-200"}`,
ondragover: (e) => {
e.preventDefault();
drag(true);
},
ondragleave: () => drag(false),
ondrop: (e) => {
e.preventDefault();
drag(false);
process(e.dataTransfer.files);
}
}, [
O("div", { class: "flex items-center gap-3 w-full" }, [
O("span", { class: "icon-[lucide--upload]" }),
O("span", { class: "text-sm opacity-70 truncate grow text-left" }, "Arrastra o selecciona archivos..."),
O("span", { class: "text-[10px] opacity-40 shrink-0" }, `Máx ${p2.max || 2}MB`)
]),
O("input", {
type: "file",
multiple: true,
accept: p2.accept || "*",
class: "hidden",
onchange: (e) => process(e.target.files)
})
]),
() => error() && O("span", { class: "text-[10px] text-error mt-1 px-1 font-medium" }, error()),
z(() => files().length > 0, () => O("ul", { class: "mt-2 space-y-1" }, K(files, (file, idx) => O("li", { class: "flex items-center justify-between p-1.5 pl-3 text-xs bg-base-200/50 rounded-md border border-base-300" }, [
O("div", { class: "flex items-center gap-2 truncate" }, [
O("span", { class: "opacity-50" }, "\uD83D\uDCC4"),
O("span", { class: "truncate font-medium max-w-[200px]" }, file.name),
O("span", { class: "text-[9px] opacity-40" }, `(${(file.size / 1024).toFixed(0)} KB)`)
]),
O("button", {
type: "button",
class: "btn btn-ghost btn-xs btn-circle",
onclick: (e) => {
e.preventDefault();
remove(idx);
}
}, O("span", { class: "icon-[lucide--x]" }))
]))))
]);
};
var Icon = (p2) => O("span", { class: p2.startsWith("icon-") ? p2 : "" }, p2.startsWith("icon-") ? null : p2);
var Indicator = (p2, c) => O("div", { ...p2, class: cls("indicator", p2.class) }, [p2.value && O("span", { class: cls("indicator-item badge", p2.class) }, p2.value), c]);
var Input = (p2) => {
const { label, icon, float, placeholder, value, left, right, rule, hint, content, ...rest } = p2;
const showPassword = S(false);
const isFocused = S(false);
const isPassword = p2.type === "password";
const pattern = rule ?? null;
const inputType = () => isPassword ? get(showPassword) ? "text" : "password" : p2.type || "text";
return O("div", {
class: "input-container",
onfocusin: () => isFocused(true),
onfocusout: (e) => {
if (!e.currentTarget.contains(e.relatedTarget)) {
isFocused(false);
}
}
}, [
O("label", { class: float ? "floating-label" : "" }, [
float ? O("span", {}, label) : null,
O("label", { pattern, class: () => cls("input validator", p2.class) }, [
label && !float ? O("span", { class: "label" }, label) : null,
left ?? null,
O("input", { ...rest, type: inputType, class: "grow", pattern, placeholder: placeholder || label || " ", value }),
right ?? null,
isPassword ? O("label", { class: "swap swap-rotate ml-2" }, [
O("input", { type: "checkbox", onchange: (e) => showPassword(e.target.checked) }),
O("span", { class: "swap-on icon-[lucide--eye]" }),
O("span", { class: "swap-off icon-[lucide--eye-off]" })
]) : null
]),
hint ? O("div", { class: "validator-hint" }, hint) : null,
z(isFocused, () => G({ duration: 300, slide: true }, O("div", { class: "input-content", onmousedown: (e) => e.preventDefault() }, [
isFn(content) ? content(isFocused) : content
])))
])
]);
};
var Kbd = (p2, c) => O("kbd", { ...p2, class: cls("kbd", p2.class) }, c);
var List = (p2, c) => {
if (!p2.items)
return O("ul", { ...p2, class: cls("list", p2.class) }, c);
return O("ul", { ...p2, class: cls("list", p2.class) }, [
K(p2.items, (item, i) => O("li", { class: cls("list-row", item.class) }, typeof p2.render === "function" ? p2.render(item, i) : item), p2.key)
]);
};
var Loading = (p2, c) => O("span", { ...p2, class: cls("loading loading-spinner", p2.class) }, c);
var Menu = (p2) => {
if (p2.children !== undefined)
return O("ul", { class: cls("menu", p2.class), ...p2 }, p2.children);
const { items } = p2;
const render = (item) => item.children ? O("li", {}, O("details", { open: item.open || undefined }, [
O("summary", {}, getBy(item)),
O("ul", {}, K(() => get(item.children) || [], render))
])) : O("li", {}, O("a", {
href: item.href,
onclick: item.onclick ? (e) => {
if (!item.href)
e.preventDefault();
item.onclick(e);
} : null
}, getBy(item)));
return O("ul", { class: cls("menu", p2.class) }, K(() => get(items) || [], render));
};
var Modal = (p2) => {
let dialogRef = null;
R(() => {
const isOpen = get(p2.open);
if (!dialogRef)
return;
isOpen ? dialogRef.showModal() : dialogRef.close();
});
const close2 = () => isFn(p2.open) && p2.open(false);
return O("dialog", {
...p2,
ref: (el) => dialogRef = el,
class: cls("modal", p2.class),
onclose: close2,
oncancel: close2
}, [
O("div", { class: "modal-box" }, [
p2.title && O("h3", { class: "text-lg font-bold" }, p2.title),
p2.children,
O("div", { class: "modal-action" }, [
p2.actions || Button({ class: "btn", onclick: close2 }, "Cerrar")
])
]),
O("form", { method: "dialog", class: "modal-backdrop" }, [
O("button", {}, "close")
])
]);
};
var Navbar = (p2, c) => O("div", { ...p2, class: cls("navbar", p2.class) }, c);
var Progress = (p2) => O("progress", { ...p2, class: cls("progress", p2.class) });
var Radial = (p2, c) => O("div", { ...p2, class: cls("radial-progress", p2.class), style: `--value:${p2.value ?? 0};${p2.style ?? ""}`, role: "progressbar", "aria-valuenow": p2.value ?? 0 }, c ?? `${p2.value ?? 0}%`);
var Radio = (p2) => O("input", { ...p2, type: "radio", class: cls("radio", p2.class) });
var Range = (p2) => O("input", { ...p2, type: "range", class: cls("range", p2.class) });
var Rating = (p2) => {
const name = rand("rating");
const stars = p2.children ?? Array.from({ length: p2.count || 5 }, (_2, i) => {
const v2 = i + 1;
return O("input", {
type: "radio",
name,
class: cls("mask", p2.mask || "mask-star"),
checked: () => get(p2.value) === v2,
onchange: () => isFn(p2.value) ? p2.value(v2) : p2.onchange?.(v2)
});
});
return O("div", { class: cls("rating", p2.class), ...p2 }, stars);
};
var Select = (p2, c) => {
if (c !== undefined)
return O("select", { class: cls("select", p2.class), ...p2 }, c);
const { label, float, placeholder, placeholderDisabled = true, value, left, right, hint, items, keyFn, ...rest } = p2;
const opts = () => {
const raw = get(items) || [];
const ph = placeholder ? [{ disabled: placeholderDisabled, label: placeholder, value: "" }] : [];
return [...ph, ...raw];
};
return O("label", { class: float ? "floating-label" : "" }, [
float ? O("span", {}, label) : null,
O("label", { class: cls("select", rest.class) }, [
!float && label ? O("span", { class: "label" }, label) : null,
left ?? null,
O("select", {
value: () => get(value),
onchange: (e) => isFn(value) ? value(e.target.value) : rest.onchange?.(e)
}, K(opts, (item) => {
const val = getBy(item, item.value !== undefined ? "value" : undefined);
const lab = getBy(item, "label");
return O("option", { value: val, disabled: item.disabled || undefined }, lab);
})),
right ?? null
]),
hint ? O("div", { class: "validator-hint" }, hint) : null
]);
};
var Skeleton = (p2) => O("div", { ...p2, class: cls("skeleton", p2.class) });
var SkeletonText = (p2) => O("span", { ...p2, class: cls("skeleton skeleton-text", p2.class) });
var Stack = (p2, c) => O("div", { ...p2, class: cls("stack", p2.class) }, c);
var Steps = (p2, c) => O("ul", { ...p2, class: cls("steps", p2.class) }, c);
var Step = (p2, c) => O("li", { ...p2, class: cls("step", p2.class), "data-content": p2.dataContent }, c);
var Swap = (p2) => O("label", { ...p2, class: cls("swap", p2.class) }, [
O("input", { type: "checkbox", checked: () => get(p2.value), onchange: (e) => isFn(p2.value) && p2.value(e.target.checked) }),
O("div", { class: "swap-on" }, p2.on),
O("div", { class: "swap-off" }, p2.off)
]);
var Table = (p2) => {
if (p2.children !== undefined)
return O("table", { class: cls("table", p2.class), ...p2 }, p2.children);
const { items, columns = [], header = true, keyFn, ...rest } = p2;
const hd = header !== false && columns.some((c) => c.label) ? O("thead", {}, O("tr", {}, columns.map((c) => O("th", { class: c.class }, c.label)))) : null;
const bd = O("tbody", {}, K(() => get(items) || [], (it, idx) => O("tr", {}, columns.map((c) => {
const v2 = c.render ? c.render(it, idx) : it[c.key];
return O("td", { class: c.class }, v2);
}))));
return O("table", { class: cls("table", rest.class), ...rest }, [hd, bd]);
};
var Tabs = (p2, c) => {
if (!p2.items) {
const { class: className2, ...rest2 } = p2;
return O("div", { ...rest2, class: cls("tabs", className2) }, c);
}
const { items, activeIndex, onClose, class: className, ...rest } = p2;
const get2 = (x2) => isFn(x2) ? x2() : x2;
const closeH = onClose || (isFn(items) ? (idx, item) => {
const arr = get2(items);
const newArr = arr.filter((_2, i) => i !== idx);
items(newArr);
if (activeIndex() >= newArr.length)
activeIndex(Math.max(0, newArr.length - 1));
} : null);
return O("div", { ...rest, class: cls("tabs", className) }, () => {
const list = get2(items) || [];
return list.flatMap((it, idx) => {
const isActive = () => activeIndex() === idx;
const button = O("button", {
class: () => `tab ${isActive() ? "tab-active" : ""} ${it.class || ""}`,
onclick: (e) => {
e.preventDefault();
activeIndex(idx);
it.onclick?.(e);
}
}, [
getBy(it),
it.closable ? O("span", {
class: "ml-1 inline-flex items-center justify-center w-4 h-4 rounded-full hover:bg-base-300 text-base-content/60 hover:text-base-content cursor-pointer",
onclick: (e) => {
e.stopPropagation();
closeH?.(idx, it);
}
}, O("span", { class: "icon-[lucide--x] w-3 h-3" })) : null
]);
const contentDiv = O("div", {
class: "tab-content bg-base-100 border-base-300 p-6",
style: () => `display: ${isActive() ? "block" : "none"};`
}, isFn(it.content) ? it.content() : it.content);
return [button, contentDiv];
});
});
};
var Textarea = (p2) => O("textarea", { ...p2, class: cls("textarea", p2.class) });
var TextRotate = (p2) => {
const words = Array.isArray(p2.words) ? p2.words : typeof p2.words === "string" ? p2.words.split(",") : [];
return O("span", { ...p2, class: cls("text-rotate", p2.class) }, O("span", {}, words.map((w2) => O("span", {}, w2))));
};
var Timeline = (p2, c) => O("ul", { ...p2, class: cls("timeline", p2.class) }, c);
var Toast = (message, type = "alert-success", duration = 3500) => {
let container = document.getElementById("sigpro-toast-container");
if (!container) {
container = O("div", {
id: "sigpro-toast-container",
class: "fixed top-0 right-0 z-[9999] p-4 flex flex-col gap-2 pointer-events-none"
});
document.body.appendChild(container);
}
const host = O("div", { style: "display: contents" });
container.appendChild(host);
let closeFn, timer, enterTimer;
const ToastComponent = () => {
const visible = S(false);
const leaving = S(false);
closeFn = () => {
if (leaving())
return;
clearTimeout(timer);
clearTimeout(enterTimer);
leaving(true);
setTimeout(() => {
instance.destroy();
host.remove();
if (!container.hasChildNodes())
container.remove();
}, 300);
};
enterTimer = setTimeout(() => visible(true), 0);
const content = typeof message === "function" ? get(message) : message;
const msgNode = typeof content === "string" ? O("span", {}, content) : content;
return O("div", {
class: () => {
if (leaving())
return `alert alert-soft ${type} shadow-lg transition-all duration-300 translate-x-full opacity-0 pointer-events-auto`;
if (visible())
return `alert alert-soft ${type} shadow-lg transition-all duration-300 translate-x-0 opacity-100 pointer-events-auto`;
return `alert alert-soft ${type} shadow-lg transition-all duration-300 translate-x-10 opacity-0 pointer-events-auto`;
}
}, [
msgNode,
O("button", {
class: "btn btn-xs btn-circle btn-ghost",
onclick: closeFn
}, O("span", { class: "icon-[lucide--x]" }))
]);
};
const instance = H(ToastComponent, host);
if (duration > 0)
timer = setTimeout(closeFn, duration);
return closeFn;
};
var Toggle = (p2) => O("input", { ...p2, type: "checkbox", class: cls("toggle", p2.class) });
var Tooltip = (p2, c) => O("div", { ...p2, class: cls("tooltip", p2.class), "data-tip": p2.tip }, c);
// components/Editor.js
var exports_Editor = {};
__export(exports_Editor, {
Editor: () => Editor
});
var Editor = (p2) => {
const { value, class: extraClass } = p2;
let editorRef = null;
let savedRange = null;
const isSource = S(false);
const source = S("");
const count = S(0);
const refreshTick = S(0);
const showEmojis = S(false);
const emojis = ["\uD83D\uDE00", "\uD83D\uDE0A", "\uD83D\uDE09", "\uD83E\uDDD0", "\uD83D\uDE2E", "\uD83E\uDD14", "\uD83D\uDE05", "\uD83D\uDE02", "\uD83D\uDE0D", "\uD83D\uDE18", "\uD83E\uDD70", "\uD83D\uDC4D", "\uD83D\uDC4E", "\uD83D\uDC4C", "\uD83E\uDD1D", "\uD83E\uDD1E", "\uD83D\uDC4B", "\uD83D\uDC4F", "\uD83D\uDE4C", "\uD83D\uDE4F", "\uD83D\uDCAA", "☝️", "\uD83D\uDC47", "\uD83D\uDC48", "\uD83D\uDC49", "\uD83D\uDD95", "✅", "⚠️", "\uD83D\uDE80", "\uD83D\uDCE2", "✉️", "❤️"];
const saveSelection = () => {
const sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount)
savedRange = sel.getRangeAt(0);
};
const restoreSelection = () => {
if (savedRange) {
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(savedRange);
}
};
const triggerRefresh = () => {
refreshTick(refreshTick() + 1);
if (editorRef)
count(editorRef.innerText.length);
};
const notify = () => {
if (!editorRef)
return;
const html = editorRef.innerHTML;
if (isFn(value))
value(html);
else
p2.onchange?.(html);
triggerRefresh();
};
const exec = (cmd, val = null) => {
if (!editorRef)
return;
editorRef.focus();
if (savedRange)
restoreSelection();
document.execCommand(cmd, false, val);
savedRange = null;
notify();
};
const openLightbox = (src) => {
const overlay = document.createElement("div");
overlay.style = `position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);z-index:9999;display:flex;align-items:center;justify-content:center;cursor:zoom-out;`;
const img = document.createElement("img");
img.src = src;
img.style = `max-width:95%;max-height:95%;box-shadow:0 0 30px rgba(0,0,0,0.5);border-radius:4px;`;
overlay.onclick = () => document.body.removeChild(overlay);
overlay.appendChild(img);
document.body.appendChild(overlay);
};
const handleUpload = (file) => {
if (!file)
return;
const reader = new FileReader;
reader.onload = (re) => {
if (file.type.startsWith("image/")) {
const imgHtml = `<div style="display:inline-block; resize:both; overflow:hidden; vertical-align:bottom; line-height:0; width:200px; height:auto; border:1px dashed #ccc; padding:2px; cursor:pointer;" class="resizable-img-container"><img src="${re.target.result}" style="width:100%; height:100%; object-fit:contain; pointer-events:none;"></div>&nbsp;`;
exec("insertHTML", imgHtml);
} else {
const linkHtml = `<a href="${re.target.result}" download="${file.name}" contenteditable="false" style="display:inline-flex; align-items:center; gap:5px; padding:4px 8px; border:1px solid #ccc; border-radius:4px; background:#f9f9f9; text-decoration:none; color:#333; font-size:12px; margin:2px; cursor:pointer;"><span class="icon-[lucide--paperclip] w-3 h-3"></span>${file.name}</a>&nbsp;`;
exec("insertHTML", linkHtml);
}
};
reader.readAsDataURL(file);
};
const queryState = (cmd, val = null) => {
refreshTick();
if (!editorRef || isSource())
return false;
try {
if (cmd === "formatBlock") {
let node = window.getSelection().getRangeAt(0).commonAncestorContainer;
while (node && node !== editorRef) {
if (node.nodeType === 1 && node.tagName === val)
return true;
node = node.parentNode;
}
return false;
}
return document.queryCommandState(cmd);
} catch (e) {
return false;
}
};
const toolbar = O("div", { class: "flex flex-wrap items-center gap-1 p-2 border-b border-base-300 bg-base-200 sticky top-0 z-20" }, [
O("div", { class: "flex flex-wrap gap-1 flex-1 items-center" }, [
O("button", { type: "button", class: () => `btn btn-ghost btn-xs ${queryState("bold") ? "btn-active bg-primary/20" : ""}`, onclick: () => exec("bold") }, O("span", { class: "icon-[lucide--bold]" })),
O("button", { type: "button", class: () => `btn btn-ghost btn-xs ${queryState("italic") ? "btn-active bg-primary/20" : ""}`, onclick: () => exec("italic") }, O("span", { class: "icon-[lucide--italic]" })),
O("button", { type: "button", class: () => `btn btn-ghost btn-xs ${queryState("underline") ? "btn-active bg-primary/20" : ""}`, onclick: () => exec("underline") }, O("span", { class: "icon-[lucide--underline]" })),
O("input", { type: "color", class: "w-5 h-5 p-0 border-0 bg-transparent cursor-pointer", oninput: (e) => exec("foreColor", e.target.value) }),
O("span", { class: "w-px h-5 bg-base-300 mx-1" }),
O("button", {
type: "button",
class: "btn btn-ghost btn-xs",
onclick: () => exec("justifyLeft")
}, O("span", { class: "icon-[lucide--align-left]" })),
O("button", {
type: "button",
class: "btn btn-ghost btn-xs",
onclick: () => exec("justifyCenter")
}, O("span", { class: "icon-[lucide--align-center]" })),
O("button", {
type: "button",
class: "btn btn-ghost btn-xs",
onclick: () => exec("justifyRight")
}, O("span", { class: "icon-[lucide--align-right]" })),
O("span", { class: "w-px h-5 bg-base-300 mx-1" }),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("insertUnorderedList") }, O("span", { class: "icon-[lucide--list]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("insertOrderedList") }, O("span", { class: "icon-[lucide--list-ordered]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("outdent"), title: "Mover izquierda" }, O("span", { class: "icon-[lucide--indent-decrease]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("indent"), title: "Mover derecha (Tab)" }, O("span", { class: "icon-[lucide--indent-increase]" })),
O("button", { type: "button", class: () => `btn btn-ghost btn-xs ${queryState("formatBlock", "BLOCKQUOTE") ? "btn-active" : ""}`, onclick: () => exec("formatBlock", queryState("formatBlock", "BLOCKQUOTE") ? "P" : "BLOCKQUOTE") }, O("span", { class: "icon-[lucide--quote]" })),
O("span", { class: "w-px h-5 bg-base-300 mx-1" }),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => {
const url = window.prompt("URL:");
if (url)
exec("createLink", url);
} }, O("span", { class: "icon-[lucide--link]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => {
const input = document.createElement("input");
input.type = "file";
input.onchange = (e) => handleUpload(e.target.files[0]);
input.click();
} }, O("span", { class: "icon-[lucide--paperclip]" })),
O("div", { class: "relative" }, [
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: (e) => {
e.stopPropagation();
saveSelection();
showEmojis(!showEmojis());
} }, O("span", { class: "icon-[lucide--smile]" })),
O("div", { class: "absolute top-full left-0 mt-1 p-2 bg-base-100 border border-base-300 shadow-xl rounded-box w-52 z-50 flex flex-wrap gap-1", style: () => showEmojis() ? "display:flex" : "display:none" }, emojis.map((emo) => O("span", { class: "cursor-pointer hover:bg-base-200 p-1 rounded text-lg", onclick: (e) => {
e.stopPropagation();
exec("insertText", emo);
showEmojis(false);
} }, emo)))
]),
O("span", { class: "w-px h-5 bg-base-300 mx-1" }),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("removeFormat") }, O("span", { class: "icon-[lucide--eraser]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("undo"), title: "Deshacer" }, O("span", { class: "icon-[lucide--undo-2]" })),
O("button", { type: "button", class: "btn btn-ghost btn-xs", onclick: () => exec("redo"), title: "Rehacer" }, O("span", { class: "icon-[lucide--redo-2]" }))
]),
O("button", { type: "button", class: () => `btn btn-ghost btn-xs ${isSource() ? "btn-active" : ""}`, onclick: () => {
if (!isSource())
source(editorRef?.innerHTML || "");
else if (editorRef) {
editorRef.innerHTML = source();
notify();
}
isSource(!isSource());
} }, O("span", { class: "icon-[lucide--code-2]" }))
]);
if (typeof document !== "undefined" && !document.getElementById("editor-styles")) {
const style = document.createElement("style");
style.id = "editor-styles";
style.textContent = `
[contenteditable="true"] div,
[contenteditable="true"] p {
margin: 0;
padding: 0;
}
`;
document.head.appendChild(style);
}
return O("div", { class: cls("border border-base-300 rounded-box bg-base-100 overflow-hidden shadow-sm flex flex-col", extraClass) }, [
toolbar,
O("div", { class: "relative flex-1 flex flex-col", onclick: () => showEmojis(false) }, [
O("div", {
ref: (el) => {
if (!editorRef && el) {
editorRef = el;
el.innerHTML = get(value) || "";
document.execCommand("defaultParagraphSeparator", false, "br");
el.addEventListener("click", (e) => {
const container = e.target.closest(".resizable-img-container");
if (container) {
const img = container.querySelector("img");
if (img)
openLightbox(img.src);
}
});
}
},
style: () => `min-height:22rem;${isSource() ? "display:none" : ""}`,
class: "p-4 outline-none text-base-content leading-relaxed [&>div]:m-0 [&>p]:m-0 [&>div]:min-h-[1em] [&_.resizable-img-container]:hover:border-primary [&_blockquote]:border-l-4 [&_blockquote]:border-base-300 [&_blockquote]:pl-4 [&_blockquote]:italic [&_ul]:list-disc [&_ul]:pl-8 [&_ol]:list-decimal [&_ol]:pl-8",
contenteditable: "true",
oninput: notify,
onkeydown: (e) => {
if (e.key === "Tab") {
e.preventDefault();
exec("indent");
}
},
onkeyup: () => {
triggerRefresh();
saveSelection();
},
onclick: (e) => {
triggerRefresh();
saveSelection();
e.stopPropagation();
},
onmouseup: () => {
notify();
saveSelection();
},
onpaste: (e) => {
e.preventDefault();
const text = e.clipboardData.getData("text/plain");
exec("insertText", text);
},
ondragover: (e) => e.preventDefault(),
ondrop: (e) => {
e.preventDefault();
handleUpload(e.dataTransfer.files[0]);
}
}),
O("textarea", {
class: "w-full flex-1 min-h-[22rem] p-4 outline-none font-mono text-sm bg-base-200 border-0",
style: () => isSource() ? "" : "display:none",
value: source,
oninput: (e) => {
source(e.target.value);
if (editorRef)
editorRef.innerHTML = e.target.value;
p2.onchange?.(e.target.value);
}
})
]),
O("div", { class: "px-3 py-1 border-t border-base-300 bg-base-100/50 text-[10px] text-right text-base-content/60 italic" }, [
O("span", () => `${count()} caracteres`)
])
]);
};
// utils.js
var i18n = {
es: {
close: "Cerrar",
confirm: "Confirmar",
cancel: "Cancelar",
search: "Buscar...",
loading: "Cargando...",
nodata: "Sin datos"
},
en: {
close: "Close",
confirm: "Confirm",
cancel: "Cancel",
search: "Search...",
loading: "Loading...",
nodata: "No data"
}
};
var currentLocale = S("es");
var Locale = (t) => currentLocale(t);
var tt = (t) => () => i18n[currentLocale()][t] || t;
// index.js
var Components = {
...exports_All,
...exports_Editor
};
var Utils = {
Locale,
tt
};
if (typeof window !== "undefined") {
Object.entries({ ...Components, ...Utils }).forEach(([name, value]) => {
Object.defineProperty(window, name, {
value,
writable: false,
configurable: true,
enumerable: true
});
});
console.log("SigProUI DX installed");
}
})();