This commit is contained in:
349
dist/sigpro-ui.js
vendored
349
dist/sigpro-ui.js
vendored
@@ -40,13 +40,16 @@
|
||||
// index.js
|
||||
var exports_sigpro_ui2 = {};
|
||||
__export(exports_sigpro_ui2, {
|
||||
Utils: () => Utils,
|
||||
Components: () => Components
|
||||
});
|
||||
|
||||
// sigpro-ui.js
|
||||
var exports_sigpro_ui = {};
|
||||
__export(exports_sigpro_ui, {
|
||||
tt: () => tt,
|
||||
i18n: () => i18n,
|
||||
hide: () => hide,
|
||||
currentLocale: () => currentLocale,
|
||||
Tooltip: () => Tooltip,
|
||||
Toggle: () => Toggle,
|
||||
Toast: () => Toast,
|
||||
@@ -77,6 +80,7 @@
|
||||
Navbar: () => Navbar,
|
||||
Modal: () => Modal,
|
||||
Menu: () => Menu,
|
||||
Locale: () => Locale,
|
||||
Loading: () => Loading,
|
||||
ListRows: () => ListRows,
|
||||
List: () => List,
|
||||
@@ -87,6 +91,7 @@
|
||||
Fileinput: () => Fileinput,
|
||||
Fieldset: () => Fieldset,
|
||||
Fab: () => Fab,
|
||||
Editor: () => Editor,
|
||||
DropdownContent: () => DropdownContent,
|
||||
DropdownButton: () => DropdownButton,
|
||||
Dropdown: () => Dropdown,
|
||||
@@ -123,23 +128,23 @@
|
||||
});
|
||||
|
||||
// node_modules/sigpro/dist/sigpro.esm.min.js
|
||||
var w = (e) => typeof e === "function";
|
||||
var B = (e) => e && typeof e === "object";
|
||||
var g = Array.isArray;
|
||||
var _ = (e) => typeof e === "function";
|
||||
var O = (e) => e && typeof e === "object";
|
||||
var b = Array.isArray;
|
||||
var E = typeof document < "u" ? document : null;
|
||||
var V = (e) => e?._isRuntime ? e.container : e instanceof Node ? e : E.createTextNode(e == null ? "" : String(e));
|
||||
var d = null;
|
||||
var _ = null;
|
||||
var N = false;
|
||||
var m = null;
|
||||
var v = false;
|
||||
var R = 0;
|
||||
var O = new Set;
|
||||
var T = new Set;
|
||||
var I = new WeakMap;
|
||||
var j = Symbol("iter");
|
||||
var k = new WeakMap;
|
||||
var k = Symbol("iter");
|
||||
var L = new WeakMap;
|
||||
var W = "http://www.w3.org/2000/svg";
|
||||
var M = "http://www.w3.org/1999/xlink";
|
||||
var q = new Set("svg,path,circle,rect,line,polyline,polygon,g,defs,text,textPath,tspan,use,symbol,image,marker,ellipse".split(","));
|
||||
var b = (e) => {
|
||||
var g = (e) => {
|
||||
if (!e || e._disposed)
|
||||
return;
|
||||
e._disposed = true;
|
||||
@@ -154,9 +159,9 @@
|
||||
n._deps.forEach((r) => r.delete(n)), n._deps.clear();
|
||||
}
|
||||
};
|
||||
var v = (e) => {
|
||||
if (_)
|
||||
(_._cleanups ||= new Set).add(e);
|
||||
var S = (e) => {
|
||||
if (m)
|
||||
(m._cleanups ||= new Set).add(e);
|
||||
};
|
||||
var K = (e) => {
|
||||
let s = d;
|
||||
@@ -175,41 +180,41 @@
|
||||
n._deps.forEach((i) => i.delete(n));
|
||||
if (n._cleanups)
|
||||
n._cleanups.forEach((i) => i()), n._cleanups.clear();
|
||||
let r = d, o = _;
|
||||
d = _ = n;
|
||||
let r = d, o = m;
|
||||
d = m = n;
|
||||
try {
|
||||
return n._result = e();
|
||||
} catch (i) {
|
||||
console.error("[SigPro]", i);
|
||||
} finally {
|
||||
d = r, _ = o;
|
||||
d = r, m = o;
|
||||
}
|
||||
};
|
||||
if (n._deps = n._cleanups = n._children = null, n._disposed = false, n._isComputed = s, n._depth = d ? d._depth + 1 : 0, n._mounts = [], n._parent = _, _)
|
||||
(_._children ||= new Set).add(n);
|
||||
if (n._deps = n._cleanups = n._children = null, n._disposed = false, n._isComputed = s, n._depth = d ? d._depth + 1 : 0, n._mounts = [], n._parent = m, m)
|
||||
(m._children ||= new Set).add(n);
|
||||
return n;
|
||||
};
|
||||
var $ = () => {
|
||||
if (N)
|
||||
if (v)
|
||||
return;
|
||||
N = true;
|
||||
let e = Array.from(O).sort((s, n) => s._depth - n._depth);
|
||||
O.clear();
|
||||
v = true;
|
||||
let e = Array.from(T).sort((s, n) => s._depth - n._depth);
|
||||
T.clear();
|
||||
for (let s of e)
|
||||
if (!s._disposed)
|
||||
s();
|
||||
N = false;
|
||||
v = false;
|
||||
};
|
||||
var z = (e) => {
|
||||
R++;
|
||||
try {
|
||||
return e();
|
||||
} finally {
|
||||
if (R--, R === 0 && O.size > 0 && !N)
|
||||
if (R--, R === 0 && T.size > 0 && !v)
|
||||
$();
|
||||
}
|
||||
};
|
||||
var m = (e, s = false) => {
|
||||
var w = (e, s = false) => {
|
||||
if (!s && d && !d._disposed)
|
||||
e.add(d), (d._deps ||= new Set).add(e);
|
||||
else if (s && e.size > 0) {
|
||||
@@ -219,17 +224,17 @@
|
||||
continue;
|
||||
if (r._isComputed) {
|
||||
if (r._dirty = true, r._subs)
|
||||
m(r._subs, true);
|
||||
w(r._subs, true);
|
||||
} else
|
||||
O.add(r), n = true;
|
||||
T.add(r), n = true;
|
||||
}
|
||||
if (n && !N && R === 0)
|
||||
if (n && !v && R === 0)
|
||||
queueMicrotask($);
|
||||
}
|
||||
};
|
||||
var P = (e, s = null) => {
|
||||
let n = new Set;
|
||||
if (w(e)) {
|
||||
if (_(e)) {
|
||||
let r, o = () => {
|
||||
if (o._dirty) {
|
||||
let i = d;
|
||||
@@ -237,13 +242,13 @@
|
||||
try {
|
||||
let t = e();
|
||||
if (!Object.is(r, t))
|
||||
r = t, m(n, true);
|
||||
r = t, w(n, true);
|
||||
} finally {
|
||||
d = i;
|
||||
}
|
||||
o._dirty = false;
|
||||
}
|
||||
return m(n), r;
|
||||
return w(n), r;
|
||||
};
|
||||
return o._isComputed = true, o._subs = n, o._dirty = true, o._deps = null, o._disposed = false, o;
|
||||
}
|
||||
@@ -253,18 +258,18 @@
|
||||
} catch (r) {}
|
||||
return (...r) => {
|
||||
if (r.length) {
|
||||
let o = w(r[0]) ? r[0](e) : r[0];
|
||||
let o = _(r[0]) ? r[0](e) : r[0];
|
||||
if (!Object.is(e, o)) {
|
||||
if (e = o, s)
|
||||
localStorage.setItem(s, JSON.stringify(e));
|
||||
m(n, true);
|
||||
w(n, true);
|
||||
}
|
||||
}
|
||||
return m(n), e;
|
||||
return w(n), e;
|
||||
};
|
||||
};
|
||||
var D = (e) => {
|
||||
if (!B(e))
|
||||
if (!O(e))
|
||||
return e;
|
||||
let s = I.get(e);
|
||||
if (s)
|
||||
@@ -276,35 +281,35 @@
|
||||
return t;
|
||||
}, o = new Proxy(e, { get(i, t, c) {
|
||||
if (typeof t !== "symbol")
|
||||
m(r(t));
|
||||
w(r(t));
|
||||
return D(Reflect.get(i, t, c));
|
||||
}, set(i, t, c, l) {
|
||||
let a = Reflect.has(i, t), f = Reflect.get(i, t, l), u = Reflect.set(i, t, c, l);
|
||||
if (u && !Object.is(f, c)) {
|
||||
if (m(r(t), true), !a)
|
||||
m(r(j), true);
|
||||
if (w(r(t), true), !a)
|
||||
w(r(k), true);
|
||||
}
|
||||
return u;
|
||||
}, deleteProperty(i, t) {
|
||||
let c = Reflect.deleteProperty(i, t);
|
||||
if (c)
|
||||
m(r(t), true), m(r(j), true);
|
||||
w(r(t), true), w(r(k), true);
|
||||
return c;
|
||||
}, ownKeys(i) {
|
||||
return m(r(j)), Reflect.ownKeys(i);
|
||||
return w(r(k)), Reflect.ownKeys(i);
|
||||
} });
|
||||
return I.set(e, o), o;
|
||||
};
|
||||
var T = (e, s) => {
|
||||
var C = (e, s) => {
|
||||
if (s === undefined) {
|
||||
let r = x(e);
|
||||
return r(), () => b(r);
|
||||
return r(), () => g(r);
|
||||
}
|
||||
let n = x(() => {
|
||||
let r = Array.isArray(e) ? e.map((o) => o()) : e();
|
||||
K(() => s(r));
|
||||
});
|
||||
return n(), () => b(n);
|
||||
return n(), () => g(n);
|
||||
};
|
||||
var U = (e) => {
|
||||
if (!e)
|
||||
@@ -312,14 +317,14 @@
|
||||
if (e._cleanups)
|
||||
e._cleanups.forEach((s) => s()), e._cleanups.clear();
|
||||
if (e._ownerEffect)
|
||||
b(e._ownerEffect);
|
||||
g(e._ownerEffect);
|
||||
if (e.childNodes)
|
||||
e.childNodes.forEach((s) => U(s));
|
||||
};
|
||||
var J = /^\s*(javascript|data|vbscript):/i;
|
||||
var Q = new Set(["src", "href", "formaction", "action", "background", "code", "archive"]);
|
||||
var X = (e) => Q.has(e) || e.startsWith("on");
|
||||
var L = (e, s) => {
|
||||
var B = (e, s) => {
|
||||
if (s == null || s === false)
|
||||
return null;
|
||||
if (X(e)) {
|
||||
@@ -330,9 +335,9 @@
|
||||
return s;
|
||||
};
|
||||
var A = (e, s = {}, n = []) => {
|
||||
if (s instanceof Node || g(s) || !B(s))
|
||||
if (s instanceof Node || b(s) || !O(s))
|
||||
n = s, s = {};
|
||||
if (w(e)) {
|
||||
if (_(e)) {
|
||||
let t = x(() => {
|
||||
let f = e(s, { children: n, emit: (u, ...h) => s[`on${u[0].toUpperCase()}${u.slice(1)}`]?.(...h) });
|
||||
return t._result = f, f;
|
||||
@@ -341,22 +346,22 @@
|
||||
let c = t._result;
|
||||
if (c == null)
|
||||
return null;
|
||||
let l = c instanceof Node || g(c) && c.every((f) => f instanceof Node) ? c : E.createTextNode(String(c)), a = (f) => {
|
||||
if (B(f) && !f._isRuntime)
|
||||
let l = c instanceof Node || b(c) && c.every((f) => f instanceof Node) ? c : E.createTextNode(String(c)), a = (f) => {
|
||||
if (O(f) && !f._isRuntime)
|
||||
f._mounts = t._mounts || [], f._cleanups = t._cleanups || new Set, f._ownerEffect = t;
|
||||
};
|
||||
return g(l) ? l.forEach(a) : a(l), l;
|
||||
return b(l) ? l.forEach(a) : a(l), l;
|
||||
}
|
||||
let r = q.has(e), o = r ? E.createElementNS(W, e) : E.createElement(e);
|
||||
o._cleanups = new Set;
|
||||
for (let t of Object.keys(s)) {
|
||||
let c = s[t];
|
||||
if (t === "ref") {
|
||||
w(c) ? c(o) : c.current = o;
|
||||
_(c) ? c(o) : c.current = o;
|
||||
continue;
|
||||
}
|
||||
if (r && t.startsWith("xlink:")) {
|
||||
let l = L(t.slice(6), c);
|
||||
let l = B(t.slice(6), c);
|
||||
l == null ? o.removeAttributeNS(M, t.slice(6)) : o.setAttributeNS(M, t.slice(6), l);
|
||||
continue;
|
||||
}
|
||||
@@ -364,10 +369,10 @@
|
||||
let l = t.slice(2).toLowerCase();
|
||||
o.addEventListener(l, c);
|
||||
let a = () => o.removeEventListener(l, c);
|
||||
o._cleanups.add(a), v(a);
|
||||
} else if (w(c)) {
|
||||
o._cleanups.add(a), S(a);
|
||||
} else if (_(c)) {
|
||||
let l = x(() => {
|
||||
let a = L(t, c());
|
||||
let a = B(t, c());
|
||||
if (t === "class")
|
||||
o.className = a || "";
|
||||
else if (a == null)
|
||||
@@ -379,12 +384,12 @@
|
||||
else
|
||||
o.setAttribute(t, a === true ? "" : a);
|
||||
});
|
||||
if (l(), o._cleanups.add(() => b(l)), v(() => b(l)), /^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName) && (t === "value" || t === "checked")) {
|
||||
if (l(), o._cleanups.add(() => g(l)), S(() => g(l)), /^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName) && (t === "value" || t === "checked")) {
|
||||
let a = t === "checked" ? "change" : "input";
|
||||
o.addEventListener(a, (f) => c(f.target[t]));
|
||||
}
|
||||
} else {
|
||||
let l = L(t, c);
|
||||
let l = B(t, c);
|
||||
if (l != null)
|
||||
if (t === "style" && typeof l === "string")
|
||||
o.setAttribute("style", l);
|
||||
@@ -395,13 +400,13 @@
|
||||
}
|
||||
}
|
||||
let i = (t) => {
|
||||
if (g(t))
|
||||
if (b(t))
|
||||
return t.forEach(i);
|
||||
if (w(t)) {
|
||||
if (_(t)) {
|
||||
let c = E.createTextNode("");
|
||||
o.appendChild(c);
|
||||
let l = [], a = x(() => {
|
||||
let f = t(), u = (g(f) ? f : [f]).map(V);
|
||||
let f = t(), u = (b(f) ? f : [f]).map(V);
|
||||
l.forEach((p) => {
|
||||
if (p._isRuntime)
|
||||
p.destroy();
|
||||
@@ -421,7 +426,7 @@
|
||||
}
|
||||
l = u;
|
||||
});
|
||||
a(), o._cleanups.add(() => b(a)), v(() => b(a));
|
||||
a(), o._cleanups.add(() => g(a)), S(() => g(a));
|
||||
} else {
|
||||
let c = V(t);
|
||||
if (o.appendChild(c), c._mounts)
|
||||
@@ -430,15 +435,15 @@
|
||||
};
|
||||
return i(n), o;
|
||||
};
|
||||
var C = (e) => {
|
||||
let s = new Set, n = _, r = d, o = E.createElement("div");
|
||||
o.style.display = "contents", o.setAttribute("role", "presentation"), _ = { _cleanups: s }, d = null;
|
||||
var j = (e) => {
|
||||
let s = new Set, n = m, r = d, o = E.createElement("div");
|
||||
o.style.display = "contents", o.setAttribute("role", "presentation"), m = { _cleanups: s }, d = null;
|
||||
let i = (t) => {
|
||||
if (!t)
|
||||
return;
|
||||
if (t._isRuntime)
|
||||
s.add(t.destroy), o.appendChild(t.container);
|
||||
else if (g(t))
|
||||
else if (b(t))
|
||||
t.forEach(i);
|
||||
else
|
||||
o.appendChild(t instanceof Node ? t : E.createTextNode(String(t == null ? "" : t)));
|
||||
@@ -446,7 +451,7 @@
|
||||
try {
|
||||
i(e({ onCleanup: (t) => s.add(t) }));
|
||||
} finally {
|
||||
_ = n, d = r;
|
||||
m = n, d = r;
|
||||
}
|
||||
return { _isRuntime: true, container: o, destroy: () => {
|
||||
s.forEach((t) => t()), U(o), o.remove();
|
||||
@@ -454,22 +459,22 @@
|
||||
};
|
||||
var F = (e, s, n = null) => {
|
||||
let r = E.createTextNode(""), o = A("div", { style: "display:contents" }, [r]), i = null;
|
||||
return T(() => !!(w(e) ? e() : e), (t) => {
|
||||
return C(() => !!(_(e) ? e() : e), (t) => {
|
||||
if (i)
|
||||
i.destroy(), i = null;
|
||||
let c = t ? s : n;
|
||||
if (c)
|
||||
i = C(() => w(c) ? c() : c), o.insertBefore(i.container, r);
|
||||
}), v(() => i?.destroy()), o;
|
||||
i = j(() => _(c) ? c() : c), o.insertBefore(i.container, r);
|
||||
}), S(() => i?.destroy()), o;
|
||||
};
|
||||
var H = (e, s, n) => {
|
||||
let r = E.createTextNode(""), o = A("div", { style: "display:contents" }, [r]), i = new Map;
|
||||
return T(() => (w(e) ? e() : e) || [], (t) => {
|
||||
return C(() => (_(e) ? e() : e) || [], (t) => {
|
||||
let c = new Map, l = [], a = t || [];
|
||||
for (let u = 0;u < a.length; u++) {
|
||||
let h = a[u], p = n ? h?.[n] ?? u : h?.id ?? u, y = i.get(p);
|
||||
if (!y)
|
||||
y = C(() => s(h, u));
|
||||
y = j(() => s(h, u));
|
||||
else
|
||||
i.delete(p);
|
||||
c.set(p, y), l.push(y);
|
||||
@@ -485,11 +490,11 @@
|
||||
i = c;
|
||||
}), o;
|
||||
};
|
||||
var S = (e) => {
|
||||
var N = (e) => {
|
||||
let s = () => window.location.hash.slice(1) || "/", n = P(s()), r = () => n(s());
|
||||
window.addEventListener("hashchange", r), v(() => window.removeEventListener("hashchange", r));
|
||||
window.addEventListener("hashchange", r), S(() => window.removeEventListener("hashchange", r));
|
||||
let o = A("div", { class: "router-hook" }), i = null;
|
||||
return T([n], () => {
|
||||
return C([n], () => {
|
||||
let t = n(), c = e.find((l) => {
|
||||
let a = l.path.split("/").filter(Boolean), f = t.split("/").filter(Boolean);
|
||||
return a.length === f.length && a.every((u, h) => u[0] === ":" || u === f[h]);
|
||||
@@ -500,38 +505,56 @@
|
||||
c.path.split("/").filter(Boolean).forEach((a, f) => {
|
||||
if (a[0] === ":")
|
||||
l[a.slice(1)] = t.split("/").filter(Boolean)[f];
|
||||
}), S.params(l), i = C(() => w(c.component) ? c.component(l) : c.component), o.replaceChildren(i.container);
|
||||
}), N.params(l), i = j(() => _(c.component) ? c.component(l) : c.component), o.replaceChildren(i.container);
|
||||
}
|
||||
}), o;
|
||||
};
|
||||
S.params = P({});
|
||||
S.to = (e) => window.location.hash = e.replace(/^#?\/?/, "#/");
|
||||
S.back = () => window.history.back();
|
||||
S.path = () => window.location.hash.replace(/^#/, "") || "/";
|
||||
N.params = P({});
|
||||
N.to = (e) => window.location.hash = e.replace(/^#?\/?/, "#/");
|
||||
N.back = () => window.history.back();
|
||||
N.path = () => window.location.hash.replace(/^#/, "") || "/";
|
||||
var Y = (e, s) => {
|
||||
let n = typeof s === "string" ? E.querySelector(s) : s;
|
||||
if (!n)
|
||||
return;
|
||||
if (k.has(n))
|
||||
k.get(n).destroy();
|
||||
let r = C(w(e) ? e : () => e);
|
||||
return n.replaceChildren(r.container), k.set(n, r), r;
|
||||
if (L.has(n))
|
||||
L.get(n).destroy();
|
||||
let r = j(_(e) ? e : () => e);
|
||||
return n.replaceChildren(r.container), L.set(n, r), r;
|
||||
};
|
||||
if (typeof window < "u")
|
||||
Object.assign(window, { $: P, $$: D, watch: T, h: A, when: F, each: H, router: S, mount: Y, batch: z }), "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) => {
|
||||
Object.assign(window, { $: P, $$: D, watch: C, h: A, when: F, each: H, router: N, mount: Y, batch: z, onUnmount: S, isArr: b, isFunc: _, isObj: O }), "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] = (s, n) => A(e, s, n);
|
||||
});
|
||||
|
||||
// sigpro-helpers.js
|
||||
var get = (val) => typeof val === "function" ? val() : val;
|
||||
// sigpro-ui.js
|
||||
var val = (val2) => typeof val2 === "function" ? val2() : val2;
|
||||
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 filterBy = (items, query, field = "label", q2 = String(query).toLowerCase()) => !query ? val(items) : val(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 hide = () => document.activeElement?.blur();
|
||||
|
||||
// sigpro-ui.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 = P("en");
|
||||
var Locale = (t) => currentLocale(t);
|
||||
var tt = (t) => () => i18n[currentLocale()][t] || t;
|
||||
var Accordion = (p) => {
|
||||
const name = p.name || rand("acc");
|
||||
return H(p.items, (it) => {
|
||||
@@ -546,13 +569,13 @@
|
||||
var Avatar = (p, c) => A("div", { class: "avatar" }, A("div", { class: p.class }, c));
|
||||
var AvatarGroup = (p, c) => A("div", { ...p, class: cls("avatar-group -space-x-6", p.class) }, c);
|
||||
var Autocomplete = ({ items, value, onselect, placeholder = "...", ...props }) => {
|
||||
const query = P(get(value) || "");
|
||||
const query = P(val(value) || "");
|
||||
const filtered = P(() => filterBy(items, query()));
|
||||
const pick = (item) => {
|
||||
const display = getBy(item);
|
||||
const actual = typeof item === "string" ? item : item.value;
|
||||
query(display);
|
||||
if (isFn(value))
|
||||
if (_(value))
|
||||
value(actual);
|
||||
onselect?.(item);
|
||||
hide();
|
||||
@@ -565,7 +588,7 @@
|
||||
left: A("span", { class: "icon-[lucide--search]" }),
|
||||
oninput: (e) => {
|
||||
query(e.target.value);
|
||||
if (isFn(value))
|
||||
if (_(value))
|
||||
value(e.target.value);
|
||||
}
|
||||
})),
|
||||
@@ -591,8 +614,8 @@
|
||||
const now = new Date;
|
||||
const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
||||
const fmt = (d2) => `${d2.getFullYear()}-${String(d2.getMonth() + 1).padStart(2, "0")}-${String(d2.getDate()).padStart(2, "0")}`;
|
||||
const rangeMode = () => get(p.range) === true;
|
||||
const current = () => get(p.value);
|
||||
const rangeMode = () => val(p.range) === true;
|
||||
const current = () => val(p.value);
|
||||
const selectDate = (date) => {
|
||||
const s = fmt(date);
|
||||
const v2 = current();
|
||||
@@ -623,7 +646,7 @@
|
||||
const HourSlider = ({ value: hVal, onChange: onH }) => A("div", { class: "flex-1" }, [
|
||||
A("div", { class: "flex gap-2 items-center" }, [
|
||||
A("input", { type: "range", min: 0, max: 23, value: hVal, class: "range range-xs flex-1", oninput: (e) => onH(+e.target.value) }),
|
||||
A("span", { class: "text-sm font-mono min-w-[48px] text-center" }, () => String(get(hVal)).padStart(2, "0") + ":00")
|
||||
A("span", { class: "text-sm font-mono min-w-[48px] text-center" }, () => String(val(hVal)).padStart(2, "0") + ":00")
|
||||
])
|
||||
]);
|
||||
return A("div", {
|
||||
@@ -694,7 +717,7 @@
|
||||
var ChatImage = (p, c) => A("div", { ...p, class: cls("chat-image avatar", p.class) }, A("div", { class: "w-10 rounded-full" }, typeof c === "string" ? A("img", { src: c, alt: "avatar" }) : c));
|
||||
var Checkbox = (p) => A("input", { ...p, type: "checkbox", class: cls("checkbox", p.class) });
|
||||
var Colorpicker = (p) => {
|
||||
const current = () => get(p.value) || "#000000";
|
||||
const current = () => val(p.value) || "#000000";
|
||||
return Dropdown({}, [
|
||||
DropdownButton({ class: "btn" }, [
|
||||
A("div", { class: "size-5 rounded-sm", style: () => `background-color: ${current()}` }),
|
||||
@@ -703,13 +726,13 @@
|
||||
DropdownContent({ class: "p-0" }, ColorPalette({
|
||||
value: p.value,
|
||||
onchange: (c) => {
|
||||
isFn(p.value) ? p.value(c) : p.onchange?.(c);
|
||||
_(p.value) ? p.value(c) : p.onchange?.(c);
|
||||
}
|
||||
}))
|
||||
]);
|
||||
};
|
||||
var ColorPalette = (p) => {
|
||||
const current = () => get(p.value) || "#000000";
|
||||
const current = () => val(p.value) || "#000000";
|
||||
const palette = [
|
||||
"#000",
|
||||
"#1A1A1A",
|
||||
@@ -777,7 +800,7 @@
|
||||
"#fae8ff"
|
||||
];
|
||||
const pick = (c) => {
|
||||
isFn(p.value) ? p.value(c) : p.onchange?.(c);
|
||||
_(p.value) ? p.value(c) : p.onchange?.(c);
|
||||
hide();
|
||||
};
|
||||
return A("div", {
|
||||
@@ -796,9 +819,9 @@
|
||||
};
|
||||
var Datepicker = (p) => {
|
||||
const displayValue = P("");
|
||||
const rangeMode = () => get(p.range) === true;
|
||||
T(() => {
|
||||
const v2 = get(p.value);
|
||||
const rangeMode = () => val(p.range) === true;
|
||||
C(() => {
|
||||
const v2 = val(p.value);
|
||||
if (!v2)
|
||||
return displayValue("");
|
||||
let text = "";
|
||||
@@ -814,12 +837,12 @@
|
||||
}
|
||||
displayValue(text);
|
||||
});
|
||||
const handleChange = (val) => {
|
||||
if (isFn(p.value))
|
||||
p.value(val);
|
||||
const handleChange = (val2) => {
|
||||
if (_(p.value))
|
||||
p.value(val2);
|
||||
else
|
||||
p.onChange?.(val);
|
||||
if (!rangeMode() || val?.end != null)
|
||||
p.onChange?.(val2);
|
||||
if (!rangeMode() || val2?.end != null)
|
||||
hide();
|
||||
};
|
||||
return Dropdown({ class: cls("w-full", p.class) }, [
|
||||
@@ -838,7 +861,7 @@
|
||||
onmousedown: (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (isFn(p.value))
|
||||
if (_(p.value))
|
||||
p.value(null);
|
||||
else
|
||||
p.onChange?.(null);
|
||||
@@ -855,7 +878,7 @@
|
||||
]);
|
||||
};
|
||||
var Drawer = (p, c) => div({ ...p, class: cls("drawer", p.class) }, c);
|
||||
var DrawerToggle = (p) => input({ ...p, type: "checkbox", class: "drawer-toggle", checked: () => get(p.checked), onchange: (e) => isFn(p.checked) && p.checked(e.target.checked) });
|
||||
var DrawerToggle = (p) => input({ ...p, type: "checkbox", class: "drawer-toggle", checked: () => val(p.checked), onchange: (e) => _(p.checked) && p.checked(e.target.checked) });
|
||||
var DrawerContent = (p, c) => div({ ...p, class: cls("drawer-content", p.class) }, c);
|
||||
var DrawerSide = (p, c) => div({ ...p, class: cls("drawer-side", p.class) }, c);
|
||||
var DrawerOverlay = (p) => label({ ...p, for: p.for, class: cls("drawer-overlay", p.class) });
|
||||
@@ -879,17 +902,17 @@
|
||||
}
|
||||
const updated = [...files(), ...arr];
|
||||
files(updated);
|
||||
if (isFn(p.onselect))
|
||||
if (_(p.onselect))
|
||||
p.onselect(updated);
|
||||
else if (isFn(p.value))
|
||||
else if (_(p.value))
|
||||
p.value(updated);
|
||||
};
|
||||
const remove = (idx) => {
|
||||
const updated = files().filter((_2, i) => i !== idx);
|
||||
files(updated);
|
||||
if (isFn(p.onselect))
|
||||
if (_(p.onselect))
|
||||
p.onselect(updated);
|
||||
else if (isFn(p.value))
|
||||
else if (_(p.value))
|
||||
p.value(updated);
|
||||
};
|
||||
return A("div", { class: cls("fieldset w-full p-0", p.class) }, [
|
||||
@@ -944,7 +967,7 @@
|
||||
const showPassword = P(false);
|
||||
const isPassword = p.type === "password";
|
||||
const pattern = rule ?? null;
|
||||
const inputType = () => isPassword ? get(showPassword) ? "text" : "password" : p.type || "search";
|
||||
const inputType = () => isPassword ? val(showPassword) ? "text" : "password" : p.type || "search";
|
||||
return A("label", { class: float ? "floating-label" : "" }, [
|
||||
float ? A("span", {}, label2) : null,
|
||||
A("label", { pattern, class: () => cls("input validator", p.class) }, [
|
||||
@@ -963,7 +986,7 @@
|
||||
};
|
||||
var Kbd = (p, c) => A("kbd", { ...p, class: cls("kbd", p.class) }, c);
|
||||
var List = (p, c) => A("ul", { ...p, class: cls("list", p.class) }, c);
|
||||
var ListRows = (p) => () => (get(p.items) || []).map((item, idx) => A("li", { class: cls("list-row", p.class, item?.class) }, typeof p.render === "function" ? p.render(item, idx) : item));
|
||||
var ListRows = (p) => () => (val(p.items) || []).map((item, idx) => A("li", { class: cls("list-row", p.class, item?.class) }, typeof p.render === "function" ? p.render(item, idx) : item));
|
||||
var Loading = (p, c) => A("span", { ...p, class: cls("loading loading-spinner", p.class) }, c);
|
||||
var Menu = (p) => {
|
||||
if (p.children !== undefined)
|
||||
@@ -971,7 +994,7 @@
|
||||
const { items } = p;
|
||||
const render = (item) => item.children ? A("li", {}, A("details", { open: item.open || undefined }, [
|
||||
A("summary", {}, getBy(item)),
|
||||
A("ul", {}, H(() => get(item.children) || [], render))
|
||||
A("ul", {}, H(() => val(item.children) || [], render))
|
||||
])) : A("li", {}, A("a", {
|
||||
href: item.href,
|
||||
onclick: item.onclick ? (e) => {
|
||||
@@ -980,17 +1003,17 @@
|
||||
item.onclick(e);
|
||||
} : null
|
||||
}, getBy(item)));
|
||||
return A("ul", { class: cls("menu", p.class) }, H(() => get(items) || [], render));
|
||||
return A("ul", { class: cls("menu", p.class) }, H(() => val(items) || [], render));
|
||||
};
|
||||
var Modal = (p) => {
|
||||
let dialogRef = null;
|
||||
T(() => {
|
||||
const isOpen = get(p.open);
|
||||
C(() => {
|
||||
const isOpen = val(p.open);
|
||||
if (!dialogRef)
|
||||
return;
|
||||
isOpen ? dialogRef.showModal() : dialogRef.hide();
|
||||
});
|
||||
const close = () => isFn(p.open) && p.open(false);
|
||||
const close = () => _(p.open) && p.open(false);
|
||||
return A("dialog", {
|
||||
...p,
|
||||
ref: (el) => dialogRef = el,
|
||||
@@ -1012,17 +1035,17 @@
|
||||
};
|
||||
var Navbar = (p, c) => A("div", { ...p, class: cls("navbar", p.class) }, c);
|
||||
var Progress = (p) => A("progress", { ...p, class: cls("progress", p.class) });
|
||||
var Radial = (p, c) => A("div", { class: cls("radial-progress", p.class), style: `--value:${get(p.value) ?? 0};`, role: "progressbar", "aria-valuenow": p.value }, c);
|
||||
var Radial = (p, c) => A("div", { class: cls("radial-progress", p.class), style: `--value:${val(p.value) ?? 0};`, role: "progressbar", "aria-valuenow": p.value }, c);
|
||||
var Radio = (p) => A("input", { ...p, type: "radio", class: cls("radio", p.class) });
|
||||
var Range = (p) => A("input", { ...p, type: "range", class: cls("range", p.class) });
|
||||
var Rating = (p, c) => A("div", { ...p, class: "rating" }, c);
|
||||
var RatingItems = (p) => [...Array(p.count)].map((_2, i) => A("input", { class: cls("mask", p.class), name: p.name, type: "radio", checked: () => get(p.value) === i, onchange: () => isFn(p.value) ? p.value(i) : p.onchange?.(i) }));
|
||||
var RatingItems = (p) => [...Array(p.count)].map((_2, i) => A("input", { class: cls("mask", p.class), name: p.name, type: "radio", checked: () => val(p.value) === i, onchange: () => _(p.value) ? p.value(i) : p.onchange?.(i) }));
|
||||
var Select = (p, c) => {
|
||||
if (c !== undefined)
|
||||
return A("select", { class: cls("select", p.class), ...p }, c);
|
||||
const { label: label2, float, placeholder, placeholderDisabled = true, value, left, right, hint, items, keyFn, ...rest } = p;
|
||||
const opts = () => {
|
||||
const raw = get(items) || [];
|
||||
const raw = val(items) || [];
|
||||
const ph = placeholder ? [{ disabled: placeholderDisabled, label: placeholder, value: "" }] : [];
|
||||
return [...ph, ...raw];
|
||||
};
|
||||
@@ -1032,12 +1055,12 @@
|
||||
!float && label2 ? A("span", { class: "label" }, label2) : null,
|
||||
left ?? null,
|
||||
A("select", {
|
||||
value: () => get(value),
|
||||
onchange: (e) => isFn(value) ? value(e.target.value) : rest.onchange?.(e)
|
||||
value: () => val(value),
|
||||
onchange: (e) => _(value) ? value(e.target.value) : rest.onchange?.(e)
|
||||
}, H(opts, (item) => {
|
||||
const val = getBy(item, item.value !== undefined ? "value" : undefined);
|
||||
const val2 = getBy(item, item.value !== undefined ? "value" : undefined);
|
||||
const lab = getBy(item, "label");
|
||||
return A("option", { value: val, disabled: item.disabled || undefined }, lab);
|
||||
return A("option", { value: val2, disabled: item.disabled || undefined }, lab);
|
||||
})),
|
||||
right ?? null
|
||||
]),
|
||||
@@ -1056,14 +1079,14 @@
|
||||
var Steps = (p, c) => A("ul", { ...p, class: cls("steps", p.class) }, c);
|
||||
var Step = (p, c) => A("li", { ...p, class: cls("step", p.class), "data-content": p.dataContent }, c);
|
||||
var Swap = (p, c) => A("label", { ...p, class: cls("swap", p.class) }, c);
|
||||
var SwapToggle = (p) => A("input", { type: "checkbox", checked: () => get(p.value), onchange: (e) => isFn(p.value) && p.value(e.target.checked), class: p.class });
|
||||
var SwapToggle = (p) => A("input", { type: "checkbox", checked: () => val(p.value), onchange: (e) => _(p.value) && p.value(e.target.checked), class: p.class });
|
||||
var SwapOn = (p, c) => A("div", { ...p, class: cls("swap-on", p.class) }, c);
|
||||
var SwapOff = (p, c) => A("div", { ...p, class: cls("swap-off", p.class) }, c);
|
||||
var Table = (p, c) => A("table", { ...p, class: cls("table", p.class) }, c);
|
||||
var TableItems = ({ items, columns = [], header = true }) => {
|
||||
const head = header !== false && columns.some((c) => c.label) ? A("thead", {}, A("tr", {}, columns.map((c) => A("th", { class: c.class }, c.label)))) : null;
|
||||
const body = A("tbody", {}, () => {
|
||||
const list = get(items) || [];
|
||||
const list = val(items) || [];
|
||||
return list.map((it, idx) => A("tr", {}, columns.map((c) => {
|
||||
const v2 = c.render ? c.render(it, idx) : it[c.key];
|
||||
return A("td", { class: c.class }, v2);
|
||||
@@ -1077,16 +1100,16 @@
|
||||
return A("div", { ...rest2, class: cls("tabs", className2) }, c);
|
||||
}
|
||||
const { items, activeIndex, onClose, class: className, ...rest } = p;
|
||||
const get2 = (x2) => isFn(x2) ? x2() : x2;
|
||||
const closeH = onClose || (isFn(items) ? (idx, item) => {
|
||||
const arr = get2(items);
|
||||
const get = (x2) => _(x2) ? x2() : x2;
|
||||
const closeH = onClose || (_(items) ? (idx, item) => {
|
||||
const arr = val(items);
|
||||
const newArr = arr.filter((_2, i) => i !== idx);
|
||||
items(newArr);
|
||||
if (activeIndex() >= newArr.length)
|
||||
activeIndex(Math.max(0, newArr.length - 1));
|
||||
} : null);
|
||||
return A("div", { ...rest, class: cls("tabs", className) }, () => {
|
||||
const list = get2(items) || [];
|
||||
const list = val(items) || [];
|
||||
return list.flatMap((it, idx) => {
|
||||
const isActive = () => activeIndex() === idx;
|
||||
const button = A("button", {
|
||||
@@ -1109,7 +1132,7 @@
|
||||
const contentDiv = A("div", {
|
||||
class: "tab-content bg-base-100 border-base-300 p-6",
|
||||
style: () => `display: ${isActive() ? "block" : "none"};`
|
||||
}, isFn(it.content) ? it.content() : it.content);
|
||||
}, _(it.content) ? it.content() : it.content);
|
||||
return [button, contentDiv];
|
||||
});
|
||||
});
|
||||
@@ -1146,7 +1169,7 @@
|
||||
}, 300);
|
||||
};
|
||||
enterTimer = setTimeout(() => visible(true), 0);
|
||||
const content = typeof message === "function" ? get(message) : message;
|
||||
const content = typeof message === "function" ? val(message) : message;
|
||||
const msgNode = typeof content === "string" ? A("span", {}, content) : content;
|
||||
return A("div", {
|
||||
class: () => {
|
||||
@@ -1172,12 +1195,6 @@
|
||||
};
|
||||
var Toggle = (p) => A("input", { ...p, type: "checkbox", class: cls("toggle", p.class) });
|
||||
var Tooltip = (p, c) => A("div", { ...p, class: cls("tooltip", p.class), "data-tip": p.tip }, c);
|
||||
|
||||
// sigpro-editor.js
|
||||
var exports_sigpro_editor = {};
|
||||
__export(exports_sigpro_editor, {
|
||||
Editor: () => Editor
|
||||
});
|
||||
var Editor = (p) => {
|
||||
const { value, class: extraClass } = p;
|
||||
let editorRef = null;
|
||||
@@ -1209,19 +1226,19 @@
|
||||
if (!editorRef)
|
||||
return;
|
||||
const html = editorRef.innerHTML;
|
||||
if (isFn(value))
|
||||
if (_(value))
|
||||
value(html);
|
||||
else
|
||||
p.onchange?.(html);
|
||||
triggerRefresh();
|
||||
};
|
||||
const exec = (cmd, val = null) => {
|
||||
const exec = (cmd, val2 = null) => {
|
||||
if (!editorRef)
|
||||
return;
|
||||
editorRef.focus();
|
||||
if (savedRange)
|
||||
restoreSelection();
|
||||
document.execCommand(cmd, false, val);
|
||||
document.execCommand(cmd, false, val2);
|
||||
savedRange = null;
|
||||
notify();
|
||||
};
|
||||
@@ -1250,7 +1267,7 @@
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
const queryState = (cmd, val = null) => {
|
||||
const queryState = (cmd, val2 = null) => {
|
||||
refreshTick();
|
||||
if (!editorRef || isSource())
|
||||
return false;
|
||||
@@ -1258,7 +1275,7 @@
|
||||
if (cmd === "formatBlock") {
|
||||
let node = window.getSelection().getRangeAt(0).commonAncestorContainer;
|
||||
while (node && node !== editorRef) {
|
||||
if (node.nodeType === 1 && node.tagName === val)
|
||||
if (node.nodeType === 1 && node.tagName === val2)
|
||||
return true;
|
||||
node = node.parentNode;
|
||||
}
|
||||
@@ -1354,7 +1371,7 @@
|
||||
ref: (el) => {
|
||||
if (!editorRef && el) {
|
||||
editorRef = el;
|
||||
el.innerHTML = get(value) || "";
|
||||
el.innerHTML = val(value) || "";
|
||||
document.execCommand("defaultParagraphSeparator", false, "br");
|
||||
el.addEventListener("click", (e) => {
|
||||
const container = e.target.closest(".resizable-img-container");
|
||||
@@ -1418,42 +1435,10 @@
|
||||
]);
|
||||
};
|
||||
|
||||
// sigpro-locale.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 = P("es");
|
||||
var Locale = (t) => currentLocale(t);
|
||||
var tt = (t) => () => i18n[currentLocale()][t] || t;
|
||||
|
||||
// index.js
|
||||
var Components = {
|
||||
...exports_sigpro_ui,
|
||||
...exports_sigpro_editor
|
||||
};
|
||||
var Utils = {
|
||||
Locale,
|
||||
tt,
|
||||
hide,
|
||||
get
|
||||
};
|
||||
var Components = { ...exports_sigpro_ui };
|
||||
if (typeof window !== "undefined") {
|
||||
Object.entries({ ...Components, ...Utils }).forEach(([name, value]) => {
|
||||
Object.entries({ ...Components }).forEach(([name, value]) => {
|
||||
Object.defineProperty(window, name, {
|
||||
value,
|
||||
writable: false,
|
||||
|
||||
Reference in New Issue
Block a user