@jasonshimmy/custom-elements-runtime 0.1.4 → 0.1.6
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/custom-elements-runtime.cjs.js +2 -2
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +40 -40
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.umd.js +6 -6
- package/dist/custom-elements-runtime.umd.js.map +1 -1
- package/dist/router.d.ts +22 -0
- package/package.json +1 -1
|
@@ -261,15 +261,15 @@ function Se(e, t, r, n, o, s, i, a) {
|
|
|
261
261
|
function _e(e, t, r, n, o) {
|
|
262
262
|
e.onAttributeChanged && e.onAttributeChanged(t, r, n, o);
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function z(e, t) {
|
|
265
265
|
if (t && e instanceof HTMLElement) {
|
|
266
266
|
for (const r in t)
|
|
267
267
|
t[r] === e && delete t[r];
|
|
268
268
|
for (const r of Array.from(e.childNodes))
|
|
269
|
-
|
|
269
|
+
z(r, t);
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function R(e, t) {
|
|
273
273
|
return t.split(".").reduce((r, n) => r?.[n], e);
|
|
274
274
|
}
|
|
275
275
|
function se(e, t, r) {
|
|
@@ -282,7 +282,7 @@ function Ae(e, t, r, n, o, s, i) {
|
|
|
282
282
|
if (!s) return;
|
|
283
283
|
const a = t.includes("lazy"), c = t.includes("trim"), f = t.includes("number"), g = () => {
|
|
284
284
|
const h = s._state || s;
|
|
285
|
-
return
|
|
285
|
+
return R(h, e);
|
|
286
286
|
}, d = g();
|
|
287
287
|
let u = "text";
|
|
288
288
|
const v = n?.type;
|
|
@@ -345,7 +345,7 @@ function Ae(e, t, r, n, o, s, i) {
|
|
|
345
345
|
const S = Number(m);
|
|
346
346
|
isNaN(S) || (m = S);
|
|
347
347
|
}
|
|
348
|
-
const x = s._state || s, k =
|
|
348
|
+
const x = s._state || s, k = R(x, e);
|
|
349
349
|
if (Array.isArray(m) && Array.isArray(k) ? JSON.stringify([...m].sort()) !== JSON.stringify([...k].sort()) : m !== k) {
|
|
350
350
|
const S = h.target;
|
|
351
351
|
S._modelUpdating = !0, se(x, e, m), setTimeout(() => {
|
|
@@ -366,7 +366,7 @@ function Ae(e, t, r, n, o, s, i) {
|
|
|
366
366
|
const _ = Number(x);
|
|
367
367
|
isNaN(_) || (x = _);
|
|
368
368
|
}
|
|
369
|
-
const k = s._state || s, $ =
|
|
369
|
+
const k = s._state || s, $ = R(k, e);
|
|
370
370
|
(Array.isArray(x) && Array.isArray($) ? JSON.stringify([...x].sort()) !== JSON.stringify([...$].sort()) : x !== $) && (m && (m._modelUpdating = !0, setTimeout(() => {
|
|
371
371
|
m._modelUpdating = !1;
|
|
372
372
|
}, 0)), se(k, e, x), s._requestRender && s._requestRender());
|
|
@@ -384,13 +384,13 @@ function Ee(e, t, r, n) {
|
|
|
384
384
|
for (const [s, i] of Object.entries(o))
|
|
385
385
|
t[s] = i;
|
|
386
386
|
} catch {
|
|
387
|
-
const o =
|
|
387
|
+
const o = R(n, e);
|
|
388
388
|
r[e] = o;
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
function Te(e, t, r) {
|
|
392
392
|
if (!r) return;
|
|
393
|
-
const n =
|
|
393
|
+
const n = R(r, e), o = t.style || "", s = n ? "" : "none";
|
|
394
394
|
if (o) {
|
|
395
395
|
const i = o.split(";").filter(Boolean), a = i.findIndex(
|
|
396
396
|
(c) => c.trim().startsWith("display:")
|
|
@@ -401,7 +401,7 @@ function Te(e, t, r) {
|
|
|
401
401
|
}
|
|
402
402
|
function je(e, t, r) {
|
|
403
403
|
if (!r) return;
|
|
404
|
-
const n =
|
|
404
|
+
const n = R(r, e);
|
|
405
405
|
let o = [];
|
|
406
406
|
typeof n == "string" ? o = [n] : Array.isArray(n) ? o = n.filter(Boolean) : typeof n == "object" && (o = Object.entries(n).filter(([, a]) => !!a).map(([a]) => a));
|
|
407
407
|
const s = t.class || "", i = s ? `${s} ${o.join(" ")}`.trim() : o.join(" ");
|
|
@@ -411,7 +411,7 @@ function Le(e, t, r) {
|
|
|
411
411
|
let n;
|
|
412
412
|
if (typeof e == "string") {
|
|
413
413
|
if (!r) return;
|
|
414
|
-
n =
|
|
414
|
+
n = R(r, e);
|
|
415
415
|
} else
|
|
416
416
|
n = e;
|
|
417
417
|
let o = "";
|
|
@@ -700,10 +700,10 @@ function ze(e, t, r, n, o) {
|
|
|
700
700
|
g = y.nextSibling;
|
|
701
701
|
}
|
|
702
702
|
for (const v of s)
|
|
703
|
-
!f.has(v) && e.contains(v) && (
|
|
703
|
+
!f.has(v) && e.contains(v) && (z(v, o), e.removeChild(v));
|
|
704
704
|
}
|
|
705
705
|
function K(e, t, r, n, o) {
|
|
706
|
-
if (t && typeof t != "string" && t.props?.ref && o &&
|
|
706
|
+
if (t && typeof t != "string" && t.props?.ref && o && z(e, o), t === r) return e;
|
|
707
707
|
if (typeof r == "string") {
|
|
708
708
|
if (e.nodeType === Node.TEXT_NODE)
|
|
709
709
|
return e.textContent !== r && (e.textContent = r), e;
|
|
@@ -722,12 +722,12 @@ function K(e, t, r, n, o) {
|
|
|
722
722
|
return g.appendChild(f), e.parentNode?.replaceChild(g, e), c;
|
|
723
723
|
}
|
|
724
724
|
if (!r) {
|
|
725
|
-
|
|
725
|
+
z(e, o);
|
|
726
726
|
const i = document.createComment("removed");
|
|
727
727
|
return e.parentNode?.replaceChild(i, e), i;
|
|
728
728
|
}
|
|
729
729
|
if (!t || typeof t == "string") {
|
|
730
|
-
|
|
730
|
+
z(e, o);
|
|
731
731
|
const i = T(r, n, o);
|
|
732
732
|
return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), e.parentNode?.replaceChild(i, e), i;
|
|
733
733
|
}
|
|
@@ -744,7 +744,7 @@ function K(e, t, r, n, o) {
|
|
|
744
744
|
const i = e;
|
|
745
745
|
return Be(i, t.props || {}, r.props || {}, n), ze(i, t.children, r.children, n, o), typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = i), i;
|
|
746
746
|
}
|
|
747
|
-
|
|
747
|
+
z(e, o);
|
|
748
748
|
const s = T(r, n, o);
|
|
749
749
|
return typeof r != "string" && r.props?.ref && o && (o[r.props.ref] = s), e.parentNode?.replaceChild(s, e), s;
|
|
750
750
|
}
|
|
@@ -757,7 +757,7 @@ function Re(e, t, r, n) {
|
|
|
757
757
|
const c = [];
|
|
758
758
|
for (let f = 0; f < e.childNodes.length; f++) {
|
|
759
759
|
const g = e.childNodes[f];
|
|
760
|
-
g !== a && g.nodeName !== "STYLE" && (
|
|
760
|
+
g !== a && g.nodeName !== "STYLE" && (z(g, n), c.push(g));
|
|
761
761
|
}
|
|
762
762
|
c.forEach((f) => e.removeChild(f)), e._prevVNode = o, e._prevDom = a;
|
|
763
763
|
}
|
|
@@ -1384,25 +1384,25 @@ function Ke(e) {
|
|
|
1384
1384
|
function Ue(e, t, r, n, o, s, i, a) {
|
|
1385
1385
|
if (!e) return;
|
|
1386
1386
|
if (t.loadingTemplate && r.isLoading) {
|
|
1387
|
-
|
|
1387
|
+
N(e, t.loadingTemplate(r), r, n, o);
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
1390
|
if (t.errorTemplate && r.hasError) {
|
|
1391
|
-
r.error instanceof Error &&
|
|
1391
|
+
r.error instanceof Error && N(e, t.errorTemplate(r.error, r), r, n, o);
|
|
1392
1392
|
return;
|
|
1393
1393
|
}
|
|
1394
1394
|
const c = t.render(r);
|
|
1395
1395
|
if (c instanceof Promise) {
|
|
1396
1396
|
s(!0), c.then((f) => {
|
|
1397
|
-
s(!1), i(null),
|
|
1397
|
+
s(!1), i(null), N(e, f, r, n, o), a(e.innerHTML);
|
|
1398
1398
|
}).catch((f) => {
|
|
1399
|
-
s(!1), i(f), t.errorTemplate &&
|
|
1400
|
-
}), t.loadingTemplate &&
|
|
1399
|
+
s(!1), i(f), t.errorTemplate && N(e, t.errorTemplate(f, r), r, n, o);
|
|
1400
|
+
}), t.loadingTemplate && N(e, t.loadingTemplate(r), r, n, o);
|
|
1401
1401
|
return;
|
|
1402
1402
|
}
|
|
1403
|
-
|
|
1403
|
+
N(e, c, r, n, o), a(e.innerHTML);
|
|
1404
1404
|
}
|
|
1405
|
-
function
|
|
1405
|
+
function N(e, t, r, n, o) {
|
|
1406
1406
|
e && (Re(
|
|
1407
1407
|
e,
|
|
1408
1408
|
Array.isArray(t) ? t : [t],
|
|
@@ -1756,7 +1756,7 @@ function F(e, t = {}, r, n) {
|
|
|
1756
1756
|
function V(e) {
|
|
1757
1757
|
return !!e && typeof e == "object" && (e.type === "AnchorBlock" || e.tag === "#anchor");
|
|
1758
1758
|
}
|
|
1759
|
-
function
|
|
1759
|
+
function M(e) {
|
|
1760
1760
|
return typeof e == "object" && e !== null && "tag" in e && !V(e);
|
|
1761
1761
|
}
|
|
1762
1762
|
function Xe(e, t) {
|
|
@@ -1830,7 +1830,7 @@ function Ge(e, t, r) {
|
|
|
1830
1830
|
});
|
|
1831
1831
|
return;
|
|
1832
1832
|
}
|
|
1833
|
-
if (
|
|
1833
|
+
if (M(l)) {
|
|
1834
1834
|
m.push(Xe(l, void 0));
|
|
1835
1835
|
return;
|
|
1836
1836
|
}
|
|
@@ -1838,7 +1838,7 @@ function Ge(e, t, r) {
|
|
|
1838
1838
|
if (l.length === 0) return;
|
|
1839
1839
|
for (let x = 0; x < l.length; x++) {
|
|
1840
1840
|
const k = l[x];
|
|
1841
|
-
V(k) ||
|
|
1841
|
+
V(k) || M(k) || Array.isArray(k) ? h(k, `${p}-${x}`) : k !== null && typeof k == "object" ? b(k) : m.push(n(String(k), `${p}-${x}`));
|
|
1842
1842
|
}
|
|
1843
1843
|
return;
|
|
1844
1844
|
}
|
|
@@ -1941,7 +1941,7 @@ function Ge(e, t, r) {
|
|
|
1941
1941
|
const w = F(
|
|
1942
1942
|
g,
|
|
1943
1943
|
d,
|
|
1944
|
-
f.length === 1 &&
|
|
1944
|
+
f.length === 1 && M(f[0]) && f[0].tag === "#text" ? typeof f[0].children == "string" ? f[0].children : "" : f.length ? f : void 0,
|
|
1945
1945
|
u
|
|
1946
1946
|
), C = i.pop();
|
|
1947
1947
|
C ? (g = C.tag, d = C.props, u = C.key, f = C.children, f.push(w)) : a = w;
|
|
@@ -1969,19 +1969,19 @@ function Ge(e, t, r) {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
}
|
|
1971
1971
|
if (a)
|
|
1972
|
-
return
|
|
1973
|
-
(l) =>
|
|
1972
|
+
return M(a) && Array.isArray(a.children) && (a.children = a.children.filter(
|
|
1973
|
+
(l) => M(l) ? l.tag !== "#text" || typeof l.children == "string" && l.children.trim() !== "" : !0
|
|
1974
1974
|
// keep non-element VNodes (including anchors) as-is
|
|
1975
1975
|
)), a;
|
|
1976
1976
|
if (y.length > 0) {
|
|
1977
1977
|
const l = y.filter(
|
|
1978
|
-
(p) =>
|
|
1978
|
+
(p) => M(p) ? p.tag !== "#text" || typeof p.children == "string" && p.children.trim() !== "" : !0
|
|
1979
1979
|
);
|
|
1980
1980
|
return l.length === 1 ? l[0] : l;
|
|
1981
1981
|
}
|
|
1982
1982
|
return F("div", {}, "", "fallback-root");
|
|
1983
1983
|
}
|
|
1984
|
-
function
|
|
1984
|
+
function P(e, ...t) {
|
|
1985
1985
|
const r = t[t.length - 1], n = typeof r == "object" && r && !Array.isArray(r) ? r : void 0;
|
|
1986
1986
|
return Ge(e, t, n);
|
|
1987
1987
|
}
|
|
@@ -2107,15 +2107,15 @@ function ft(e) {
|
|
|
2107
2107
|
const t = tt(e);
|
|
2108
2108
|
return de("router-view", {
|
|
2109
2109
|
async render() {
|
|
2110
|
-
if (!t) return
|
|
2110
|
+
if (!t) return P`<div>Router not initialized.</div>`;
|
|
2111
2111
|
const r = t.getCurrent(), { path: n } = r, o = t.matchRoute(n);
|
|
2112
|
-
if (!o.route) return
|
|
2112
|
+
if (!o.route) return P`<div>Not found</div>`;
|
|
2113
2113
|
let s = o.route.component;
|
|
2114
2114
|
if (o.route.load) {
|
|
2115
2115
|
const i = await o.route.load();
|
|
2116
2116
|
typeof i.default == "string" && (s = i.default);
|
|
2117
2117
|
}
|
|
2118
|
-
return typeof s == "string" ?
|
|
2118
|
+
return typeof s == "string" ? { tag: s, props: {}, children: [] } : P`<div>Invalid route component</div>`;
|
|
2119
2119
|
},
|
|
2120
2120
|
onConnected(r) {
|
|
2121
2121
|
t && typeof t.subscribe == "function" && t.subscribe(() => {
|
|
@@ -2141,11 +2141,11 @@ function ft(e) {
|
|
|
2141
2141
|
}
|
|
2142
2142
|
` }
|
|
2143
2143
|
},
|
|
2144
|
-
style: (r) => r.
|
|
2144
|
+
style: (r) => r.style,
|
|
2145
2145
|
render: (r) => {
|
|
2146
|
-
const n = t.getCurrent(), o = r.
|
|
2147
|
-
return
|
|
2148
|
-
${ve().when(h,
|
|
2146
|
+
const n = t.getCurrent(), o = r.to, s = r.exact, i = r.exactActiveClass, a = r.activeClass, c = r.ariaCurrentValue, f = r.tag, g = r.disabled, d = r.external, u = n.path === o, v = s ? u : n && typeof n.path == "string" ? n.path.startsWith(o) : !1, y = u ? i : v ? a : "", b = u ? `aria-current="${c}"` : "", h = f === "button", l = g ? h ? 'disabled aria-disabled="true" tabindex="-1"' : 'aria-disabled="true" tabindex="-1"' : "", p = d && (f === "a" || !f) ? 'target="_blank" rel="noopener noreferrer"' : "";
|
|
2147
|
+
return P`
|
|
2148
|
+
${ve().when(h, P`
|
|
2149
2149
|
<button
|
|
2150
2150
|
part="button"
|
|
2151
2151
|
class="${y}"
|
|
@@ -2154,7 +2154,7 @@ function ft(e) {
|
|
|
2154
2154
|
${p}
|
|
2155
2155
|
data-on-click="navigate"
|
|
2156
2156
|
><slot></slot></button>
|
|
2157
|
-
`).otherwise(
|
|
2157
|
+
`).otherwise(P`
|
|
2158
2158
|
<a
|
|
2159
2159
|
part="link"
|
|
2160
2160
|
href="${o}"
|
|
@@ -2185,7 +2185,7 @@ export {
|
|
|
2185
2185
|
nt as each,
|
|
2186
2186
|
ot as emit,
|
|
2187
2187
|
H as eventBus,
|
|
2188
|
-
|
|
2188
|
+
P as html,
|
|
2189
2189
|
ft as initRouter,
|
|
2190
2190
|
lt as listen,
|
|
2191
2191
|
ve as match,
|