@jasonshimmy/custom-elements-runtime 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements-runtime.router.cjs.js +16 -16
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +246 -227
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/namespace-helpers-BsKQl3aH.cjs.map +1 -1
- package/dist/namespace-helpers-Dw1mgQab.js.map +1 -1
- package/dist/router.d.ts +2 -0
- package/dist/runtime/reactive.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,267 +1,273 @@
|
|
|
1
|
-
import { component as
|
|
2
|
-
import { r as
|
|
3
|
-
import { createStore as
|
|
4
|
-
import { d as
|
|
5
|
-
import { match as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
1
|
+
import { component as T, html as P, useOnConnected as U, useOnDisconnected as W, useProps as M, useStyle as V } from "./custom-elements-runtime.es.js";
|
|
2
|
+
import { r as O, c as b } from "./namespace-helpers-Dw1mgQab.js";
|
|
3
|
+
import { createStore as D } from "./custom-elements-runtime.store.es.js";
|
|
4
|
+
import { d as A, a as $ } from "./logger-BuUYv7C_.js";
|
|
5
|
+
import { match as z } from "./custom-elements-runtime.directives.es.js";
|
|
6
|
+
const I = (n) => n ? typeof URLSearchParams > "u" ? {} : Object.fromEntries(new URLSearchParams(n)) : {}, F = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function H(n) {
|
|
8
8
|
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function _(n) {
|
|
11
11
|
if (!n) return "/";
|
|
12
12
|
let r = n.replace(/\/+/g, "/");
|
|
13
13
|
return r.startsWith("/") || (r = "/" + r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const r = n.path || "/", t =
|
|
17
|
-
for (let
|
|
18
|
-
const d =
|
|
15
|
+
function Q(n) {
|
|
16
|
+
const r = n.path || "/", t = _(r), h = t === "/" ? [] : t.split("/").filter(Boolean), o = [], s = [];
|
|
17
|
+
for (let u = 0; u < h.length; u++) {
|
|
18
|
+
const d = h[u];
|
|
19
19
|
if (d === "*") {
|
|
20
|
-
if (
|
|
20
|
+
if (u !== h.length - 1)
|
|
21
21
|
return $(
|
|
22
22
|
`Route '${n.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`
|
|
23
23
|
), { invalid: !0 };
|
|
24
|
-
const p = `splat${
|
|
25
|
-
|
|
24
|
+
const p = `splat${o.length}`;
|
|
25
|
+
o.push(p), s.push("__SPLAT__");
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const p =
|
|
31
|
-
if (
|
|
28
|
+
const y = d.match(/^:([A-Za-z0-9_-]+)(\*)?$/);
|
|
29
|
+
if (y) {
|
|
30
|
+
const p = y[1], w = !!y[2];
|
|
31
|
+
if (w && u !== h.length - 1)
|
|
32
32
|
return $(
|
|
33
33
|
`Route '${n.path}' contains a splat param ':${p}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`
|
|
34
34
|
), { invalid: !0 };
|
|
35
|
-
|
|
35
|
+
o.push(p), s.push(w ? "__SPLAT__" : "([^/]+)");
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
s.push(H(d));
|
|
39
39
|
}
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
else if (
|
|
44
|
-
const d =
|
|
45
|
-
d ?
|
|
40
|
+
let c;
|
|
41
|
+
if (s.length === 0)
|
|
42
|
+
c = "^/$";
|
|
43
|
+
else if (s[s.length - 1] === "__SPLAT__") {
|
|
44
|
+
const d = s.slice(0, -1).join("/");
|
|
45
|
+
d ? c = `^/${d}(?:/(.*))?(?:/)?$` : c = "^(?:/(.*))?(?:/)?$";
|
|
46
46
|
} else
|
|
47
|
-
|
|
47
|
+
c = `^/${s.join("/")}(?:/)?$`;
|
|
48
48
|
try {
|
|
49
|
-
return { regex: new RegExp(
|
|
50
|
-
} catch (
|
|
51
|
-
return $(`Failed to compile route regex for '${n.path}': ${String(
|
|
49
|
+
return { regex: new RegExp(c), paramNames: o };
|
|
50
|
+
} catch (u) {
|
|
51
|
+
return $(`Failed to compile route regex for '${n.path}': ${String(u)}`), { invalid: !0 };
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
const t =
|
|
56
|
-
for (const
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
const { regex:
|
|
60
|
-
if (
|
|
61
|
-
const d = {},
|
|
54
|
+
const C = (n, r) => {
|
|
55
|
+
const t = _(r);
|
|
56
|
+
for (const h of n) {
|
|
57
|
+
let o = F.get(h);
|
|
58
|
+
if (o || (o = Q(h), F.set(h, o)), o.invalid) continue;
|
|
59
|
+
const { regex: s, paramNames: c } = o, u = s.exec(t);
|
|
60
|
+
if (u) {
|
|
61
|
+
const d = {}, y = (p) => {
|
|
62
62
|
try {
|
|
63
63
|
return decodeURIComponent(p);
|
|
64
64
|
} catch {
|
|
65
65
|
return p;
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
for (let p = 0; p <
|
|
69
|
-
const
|
|
70
|
-
d[
|
|
68
|
+
for (let p = 0; p < c.length; p++) {
|
|
69
|
+
const w = u[p + 1] || "";
|
|
70
|
+
d[c[p]] = w ? y(w) : "";
|
|
71
71
|
}
|
|
72
|
-
return { route:
|
|
72
|
+
return { route: h, params: d };
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return { route: null, params: {} };
|
|
76
76
|
};
|
|
77
|
-
function
|
|
77
|
+
function L(n, r) {
|
|
78
78
|
for (const t of n)
|
|
79
|
-
if (
|
|
79
|
+
if (C([t], r).route !== null) return t;
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
async function
|
|
82
|
+
const j = {};
|
|
83
|
+
async function Z(n) {
|
|
84
84
|
if (n.component) return n.component;
|
|
85
85
|
if (n.load) {
|
|
86
|
-
if (
|
|
86
|
+
if (j[n.path]) return j[n.path];
|
|
87
87
|
try {
|
|
88
88
|
const r = await n.load();
|
|
89
|
-
return
|
|
89
|
+
return j[n.path] = r.default, r.default;
|
|
90
90
|
} catch {
|
|
91
91
|
throw new Error(`Failed to load component for route: ${n.path}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
throw new Error(`No component or loader defined for route: ${n.path}`);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
const { routes: r, base: t = "", initialUrl:
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
const e =
|
|
96
|
+
function G(n) {
|
|
97
|
+
const { routes: r, base: t = "", initialUrl: h } = n;
|
|
98
|
+
let o, s, c, u, d, y, p;
|
|
99
|
+
const w = async (f, i) => {
|
|
100
|
+
const e = L(r, f.path);
|
|
101
101
|
if (!e || !e.beforeEnter) return !0;
|
|
102
102
|
try {
|
|
103
|
-
const a = await e.beforeEnter(
|
|
103
|
+
const a = await e.beforeEnter(f, i);
|
|
104
104
|
return typeof a == "string" ? (await R(a, !0), !1) : a !== !1;
|
|
105
105
|
} catch (a) {
|
|
106
|
-
return
|
|
106
|
+
return A("beforeEnter error", a), !1;
|
|
107
107
|
}
|
|
108
|
-
},
|
|
109
|
-
const e =
|
|
108
|
+
}, q = async (f, i) => {
|
|
109
|
+
const e = L(r, f.path);
|
|
110
110
|
if (!e || !e.onEnter) return !0;
|
|
111
111
|
try {
|
|
112
|
-
const a = await e.onEnter(
|
|
112
|
+
const a = await e.onEnter(f, i);
|
|
113
113
|
return typeof a == "string" ? (await R(a, !0), !1) : a !== !1;
|
|
114
114
|
} catch (a) {
|
|
115
|
-
return
|
|
115
|
+
return A("onEnter error", a), !1;
|
|
116
116
|
}
|
|
117
|
-
},
|
|
118
|
-
const e =
|
|
117
|
+
}, N = (f, i) => {
|
|
118
|
+
const e = L(r, f.path);
|
|
119
119
|
if (!(!e || !e.afterEnter))
|
|
120
120
|
try {
|
|
121
|
-
e.afterEnter(
|
|
121
|
+
e.afterEnter(f, i);
|
|
122
122
|
} catch (a) {
|
|
123
|
-
|
|
123
|
+
A("afterEnter error", a);
|
|
124
124
|
}
|
|
125
|
-
}, R = async (
|
|
125
|
+
}, R = async (f, i = !1) => {
|
|
126
126
|
try {
|
|
127
|
-
const e = {
|
|
128
|
-
path:
|
|
129
|
-
query: {}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
const e = f.indexOf("#"), a = e >= 0 ? f.slice(e + 1) : "", l = {
|
|
128
|
+
path: (e >= 0 ? f.slice(0, e) : f).replace(t, "") || "/",
|
|
129
|
+
query: {},
|
|
130
|
+
fragment: a
|
|
131
|
+
}, m = C(r, l.path);
|
|
132
|
+
if (!m.route) throw new Error(`No route found for ${l.path}`);
|
|
133
|
+
const v = c.getState(), E = {
|
|
134
|
+
path: l.path,
|
|
135
|
+
params: m.params,
|
|
136
|
+
query: l.query,
|
|
137
|
+
fragment: l.fragment
|
|
136
138
|
};
|
|
137
|
-
if (!await
|
|
138
|
-
typeof window < "u" && typeof document < "u" && (
|
|
139
|
+
if (!await w(E, v) || !await q(E, v)) return;
|
|
140
|
+
typeof window < "u" && typeof document < "u" && (i ? window.history.replaceState({}, "", t + f) : window.history.pushState({}, "", t + f)), c.setState(E), N(E, v);
|
|
139
141
|
} catch (e) {
|
|
140
|
-
|
|
142
|
+
A("Navigation error:", e);
|
|
141
143
|
}
|
|
142
144
|
};
|
|
143
|
-
if (typeof window < "u" && typeof document < "u" && typeof
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
return { path: e, query: a };
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
path:
|
|
151
|
-
params:
|
|
152
|
-
query:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
if (typeof window < "u" && typeof document < "u" && typeof h > "u") {
|
|
146
|
+
o = () => {
|
|
147
|
+
const i = new URL(window.location.href), e = i.pathname.replace(t, "") || "/", a = I(i.search), g = i.hash && i.hash.length ? i.hash.slice(1) : "";
|
|
148
|
+
return { path: e, query: a, fragment: g };
|
|
149
|
+
}, s = o();
|
|
150
|
+
const f = C(r, s.path);
|
|
151
|
+
c = D({
|
|
152
|
+
path: s.path,
|
|
153
|
+
params: f.params,
|
|
154
|
+
query: s.query,
|
|
155
|
+
fragment: s.fragment
|
|
156
|
+
}), u = async (i = !1) => {
|
|
157
|
+
const e = o();
|
|
158
|
+
await R(e.path, i);
|
|
159
|
+
}, window.addEventListener("popstate", () => u(!0)), d = (i) => R(i, !1), y = (i) => R(i, !0), p = () => window.history.back();
|
|
157
160
|
} else {
|
|
158
|
-
|
|
159
|
-
const e = new URL(
|
|
160
|
-
return { path: a, query:
|
|
161
|
-
},
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
path:
|
|
165
|
-
params:
|
|
166
|
-
query:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
o = () => {
|
|
162
|
+
const e = new URL(h || "/", "http://localhost"), a = e.pathname.replace(t, "") || "/", g = I(e.search), l = e.hash && e.hash.length ? e.hash.slice(1) : "";
|
|
163
|
+
return { path: a, query: g, fragment: l };
|
|
164
|
+
}, s = o();
|
|
165
|
+
const f = C(r, s.path);
|
|
166
|
+
c = D({
|
|
167
|
+
path: s.path,
|
|
168
|
+
params: f.params,
|
|
169
|
+
query: s.query,
|
|
170
|
+
fragment: s.fragment
|
|
171
|
+
}), u = async () => {
|
|
172
|
+
const e = o();
|
|
173
|
+
await i(e.path);
|
|
170
174
|
};
|
|
171
|
-
const
|
|
175
|
+
const i = async (e) => {
|
|
172
176
|
try {
|
|
173
|
-
const a = {
|
|
174
|
-
path: e.replace(t, "") || "/",
|
|
175
|
-
query: {}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
const a = e.indexOf("#"), g = a >= 0 ? e.slice(a + 1) : "", m = {
|
|
178
|
+
path: (a >= 0 ? e.slice(0, a) : e).replace(t, "") || "/",
|
|
179
|
+
query: {},
|
|
180
|
+
fragment: g
|
|
181
|
+
}, v = C(r, m.path);
|
|
182
|
+
if (!v.route) throw new Error(`No route found for ${m.path}`);
|
|
183
|
+
const E = c.getState(), k = {
|
|
184
|
+
path: m.path,
|
|
185
|
+
params: v.params,
|
|
186
|
+
query: m.query,
|
|
187
|
+
fragment: m.fragment
|
|
188
|
+
}, x = L(r, k.path);
|
|
189
|
+
if (x?.beforeEnter) {
|
|
190
|
+
const S = await x.beforeEnter(k, E);
|
|
191
|
+
if (typeof S == "string") {
|
|
192
|
+
await i(S);
|
|
187
193
|
return;
|
|
188
194
|
}
|
|
189
|
-
if (
|
|
195
|
+
if (S === !1) return;
|
|
190
196
|
}
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
if (typeof
|
|
194
|
-
await
|
|
197
|
+
if (x?.onEnter) {
|
|
198
|
+
const S = await x.onEnter(k, E);
|
|
199
|
+
if (typeof S == "string") {
|
|
200
|
+
await i(S);
|
|
195
201
|
return;
|
|
196
202
|
}
|
|
197
|
-
if (
|
|
203
|
+
if (S === !1) return;
|
|
198
204
|
}
|
|
199
|
-
|
|
205
|
+
c.setState(k), x?.afterEnter && x.afterEnter(k, E);
|
|
200
206
|
} catch (a) {
|
|
201
|
-
throw
|
|
207
|
+
throw A("SSR navigation error:", a), a;
|
|
202
208
|
}
|
|
203
209
|
};
|
|
204
|
-
d = async (e) =>
|
|
210
|
+
d = async (e) => i(e), y = async (e) => i(e), p = () => {
|
|
205
211
|
};
|
|
206
212
|
}
|
|
207
213
|
return {
|
|
208
|
-
store:
|
|
214
|
+
store: c,
|
|
209
215
|
push: d,
|
|
210
|
-
replace:
|
|
216
|
+
replace: y,
|
|
211
217
|
back: p,
|
|
212
|
-
subscribe:
|
|
213
|
-
matchRoute: (
|
|
214
|
-
getCurrent: () =>
|
|
215
|
-
resolveRouteComponent:
|
|
218
|
+
subscribe: c.subscribe,
|
|
219
|
+
matchRoute: (f) => C(r, f),
|
|
220
|
+
getCurrent: () => c.getState(),
|
|
221
|
+
resolveRouteComponent: Z
|
|
216
222
|
};
|
|
217
223
|
}
|
|
218
|
-
function
|
|
219
|
-
return
|
|
224
|
+
function et(n, r) {
|
|
225
|
+
return C(n, r);
|
|
220
226
|
}
|
|
221
|
-
let
|
|
222
|
-
function
|
|
223
|
-
const r =
|
|
224
|
-
return
|
|
225
|
-
const t =
|
|
226
|
-
if (!t) return
|
|
227
|
-
const
|
|
228
|
-
let
|
|
229
|
-
|
|
227
|
+
let B = null;
|
|
228
|
+
function rt(n) {
|
|
229
|
+
const r = G(n);
|
|
230
|
+
return B = r, T("router-view", async () => {
|
|
231
|
+
const t = B || r;
|
|
232
|
+
if (!t) return P`<div>Router not initialized.</div>`;
|
|
233
|
+
const h = O(t.getCurrent());
|
|
234
|
+
let o;
|
|
235
|
+
U(() => {
|
|
230
236
|
try {
|
|
231
|
-
t && typeof t.subscribe == "function" && (
|
|
237
|
+
t && typeof t.subscribe == "function" && (o = t.subscribe((c) => {
|
|
232
238
|
try {
|
|
233
|
-
|
|
234
|
-
} catch (
|
|
235
|
-
$("router-view subscription update failed",
|
|
239
|
+
h.value = c;
|
|
240
|
+
} catch (u) {
|
|
241
|
+
$("router-view subscription update failed", u);
|
|
236
242
|
}
|
|
237
243
|
}));
|
|
238
|
-
} catch (
|
|
239
|
-
$("router-view subscribe failed",
|
|
244
|
+
} catch (c) {
|
|
245
|
+
$("router-view subscribe failed", c);
|
|
240
246
|
}
|
|
241
|
-
}),
|
|
242
|
-
if (typeof
|
|
247
|
+
}), W(() => {
|
|
248
|
+
if (typeof o == "function")
|
|
243
249
|
try {
|
|
244
|
-
|
|
245
|
-
} catch (
|
|
246
|
-
$("router-view unsubscribe failed",
|
|
250
|
+
o();
|
|
251
|
+
} catch (c) {
|
|
252
|
+
$("router-view unsubscribe failed", c);
|
|
247
253
|
}
|
|
248
254
|
});
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
255
|
+
const s = t.matchRoute(h.value.path);
|
|
256
|
+
if (!s || !s.route) return P`<div>Not found</div>`;
|
|
251
257
|
try {
|
|
252
|
-
const
|
|
253
|
-
if (typeof
|
|
254
|
-
return { tag:
|
|
255
|
-
if (typeof
|
|
256
|
-
const d =
|
|
258
|
+
const u = await t.resolveRouteComponent(s.route);
|
|
259
|
+
if (typeof u == "string")
|
|
260
|
+
return { tag: u, props: {}, children: [] };
|
|
261
|
+
if (typeof u == "function") {
|
|
262
|
+
const d = u();
|
|
257
263
|
return (d instanceof Promise ? d : Promise.resolve(d)).then((p) => typeof p == "string" ? { tag: p, props: {}, children: [] } : p);
|
|
258
264
|
}
|
|
259
|
-
return
|
|
265
|
+
return P`<div>Invalid route component</div>`;
|
|
260
266
|
} catch {
|
|
261
|
-
return
|
|
267
|
+
return P`<div>Invalid route component</div>`;
|
|
262
268
|
}
|
|
263
|
-
}),
|
|
264
|
-
const t =
|
|
269
|
+
}), T("router-link", () => {
|
|
270
|
+
const t = M({
|
|
265
271
|
to: "",
|
|
266
272
|
tag: "a",
|
|
267
273
|
replace: !1,
|
|
@@ -274,94 +280,106 @@ function Y(n) {
|
|
|
274
280
|
// allow host `class` and `style` attributes to be read via useProps
|
|
275
281
|
class: "",
|
|
276
282
|
style: ""
|
|
277
|
-
}),
|
|
278
|
-
let
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
283
|
+
}), h = B || r, o = O(h.getCurrent());
|
|
284
|
+
let s;
|
|
285
|
+
V(() => "a,button{display:inline-block;}");
|
|
286
|
+
const c = O(t.class || ""), u = O(t.style || "");
|
|
287
|
+
U((g) => {
|
|
282
288
|
try {
|
|
283
|
-
|
|
289
|
+
h && typeof h.subscribe == "function" && (s = h.subscribe((l) => {
|
|
284
290
|
try {
|
|
285
|
-
|
|
286
|
-
} catch (
|
|
287
|
-
$("router-link subscription update failed",
|
|
291
|
+
o.value = l;
|
|
292
|
+
} catch (m) {
|
|
293
|
+
$("router-link subscription update failed", m);
|
|
288
294
|
}
|
|
289
295
|
}));
|
|
290
|
-
} catch (
|
|
291
|
-
$("router-link subscribe failed",
|
|
296
|
+
} catch (l) {
|
|
297
|
+
$("router-link subscribe failed", l);
|
|
292
298
|
}
|
|
293
299
|
try {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
|
|
300
|
+
const l = g?._host;
|
|
301
|
+
if (l instanceof HTMLElement) {
|
|
302
|
+
const m = l.getAttribute("class"), v = l.getAttribute("style");
|
|
303
|
+
m && (c.value = m), v && (u.value = v), m !== null && l.removeAttribute("class"), v !== null && l.removeAttribute("style");
|
|
298
304
|
}
|
|
299
|
-
} catch (
|
|
300
|
-
$("router-link host migration failed",
|
|
305
|
+
} catch (l) {
|
|
306
|
+
$("router-link host migration failed", l);
|
|
301
307
|
}
|
|
302
|
-
}),
|
|
303
|
-
if (typeof
|
|
308
|
+
}), W(() => {
|
|
309
|
+
if (typeof s == "function")
|
|
304
310
|
try {
|
|
305
|
-
|
|
306
|
-
} catch (
|
|
307
|
-
$("router-link unsubscribe failed",
|
|
311
|
+
s();
|
|
312
|
+
} catch (g) {
|
|
313
|
+
$("router-link unsubscribe failed", g);
|
|
308
314
|
}
|
|
309
315
|
});
|
|
310
|
-
const d =
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
const d = b(() => {
|
|
317
|
+
const l = (t.to || "").split("#")[0];
|
|
318
|
+
try {
|
|
319
|
+
return _(o.value.path) === _(l);
|
|
320
|
+
} catch {
|
|
321
|
+
return o.value.path === l;
|
|
322
|
+
}
|
|
323
|
+
}), y = b(() => {
|
|
324
|
+
const l = (t.to || "").split("#")[0];
|
|
325
|
+
if (t.exact) return d.value;
|
|
326
|
+
try {
|
|
327
|
+
const m = _(o.value.path), v = _(l);
|
|
328
|
+
return m.startsWith(v);
|
|
329
|
+
} catch {
|
|
330
|
+
return o.value && typeof o.value.path == "string" && o.value.path.startsWith(l);
|
|
331
|
+
}
|
|
332
|
+
}), p = b(() => {
|
|
333
|
+
const l = (c && c.value || t.class || "").split(/\s+/).filter(Boolean), m = {};
|
|
334
|
+
for (const v of l) m[v] = !0;
|
|
335
|
+
return m;
|
|
336
|
+
}), w = b(() => ({
|
|
319
337
|
...p.value,
|
|
320
|
-
[t.activeClass || "active"]:
|
|
338
|
+
[t.activeClass || "active"]: y.value,
|
|
321
339
|
[t.exactActiveClass || "exact-active"]: d.value
|
|
322
|
-
})),
|
|
323
|
-
() => Object.keys(
|
|
324
|
-
),
|
|
340
|
+
})), q = b(
|
|
341
|
+
() => Object.keys(w.value).filter((g) => w.value[g]).join(" ")
|
|
342
|
+
), N = b(() => t.tag === "button"), R = b(
|
|
325
343
|
() => d.value ? t.ariaCurrentValue : ""
|
|
326
|
-
),
|
|
344
|
+
), f = b(() => !!t.disabled), i = b(
|
|
327
345
|
() => !!t.external && (t.tag === "a" || !t.tag)
|
|
328
|
-
), e =
|
|
329
|
-
() =>
|
|
330
|
-
), a = (
|
|
346
|
+
), e = b(
|
|
347
|
+
() => u && u.value || t.style || ""
|
|
348
|
+
), a = (g) => {
|
|
331
349
|
if (t.disabled) {
|
|
332
|
-
|
|
350
|
+
g.preventDefault();
|
|
333
351
|
return;
|
|
334
352
|
}
|
|
335
|
-
t.external && (t.tag === "a" || !t.tag) || (
|
|
353
|
+
t.external && (t.tag === "a" || !t.tag) || (g.preventDefault(), t.replace ? h.replace(t.to) : h.push(t.to));
|
|
336
354
|
};
|
|
337
|
-
return
|
|
338
|
-
${
|
|
339
|
-
|
|
340
|
-
|
|
355
|
+
return P`
|
|
356
|
+
${z().when(
|
|
357
|
+
N.value,
|
|
358
|
+
P`
|
|
341
359
|
<button
|
|
342
360
|
part="button"
|
|
343
|
-
class="${
|
|
361
|
+
class="${q.value}"
|
|
344
362
|
style="${e.value || null}"
|
|
345
363
|
aria-current="${R.value}"
|
|
346
|
-
disabled="${
|
|
347
|
-
aria-disabled="${
|
|
348
|
-
tabindex="${
|
|
364
|
+
disabled="${f.value ? "" : null}"
|
|
365
|
+
aria-disabled="${f.value ? "true" : null}"
|
|
366
|
+
tabindex="${f.value ? "-1" : null}"
|
|
349
367
|
@click="${a}"
|
|
350
368
|
>
|
|
351
369
|
<slot></slot>
|
|
352
370
|
</button>
|
|
353
371
|
`
|
|
354
|
-
).otherwise(
|
|
372
|
+
).otherwise(P`
|
|
355
373
|
<a
|
|
356
374
|
part="link"
|
|
357
375
|
href="${t.to}"
|
|
358
|
-
class="${
|
|
376
|
+
class="${q.value}"
|
|
359
377
|
style="${e.value || null}"
|
|
360
378
|
aria-current="${R.value}"
|
|
361
|
-
aria-disabled="${
|
|
362
|
-
tabindex="${
|
|
363
|
-
target="${
|
|
364
|
-
rel="${
|
|
379
|
+
aria-disabled="${f.value ? "true" : null}"
|
|
380
|
+
tabindex="${f.value ? "-1" : null}"
|
|
381
|
+
target="${i.value ? "_blank" : null}"
|
|
382
|
+
rel="${i.value ? "noopener noreferrer" : null}"
|
|
365
383
|
@click="${a}"
|
|
366
384
|
><slot></slot
|
|
367
385
|
></a>
|
|
@@ -370,11 +388,12 @@ function Y(n) {
|
|
|
370
388
|
}), r;
|
|
371
389
|
}
|
|
372
390
|
export {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
391
|
+
rt as initRouter,
|
|
392
|
+
C as matchRoute,
|
|
393
|
+
et as matchRouteSSR,
|
|
394
|
+
_ as normalizePathForRoute,
|
|
395
|
+
I as parseQuery,
|
|
396
|
+
Z as resolveRouteComponent,
|
|
397
|
+
G as useRouter
|
|
379
398
|
};
|
|
380
399
|
//# sourceMappingURL=custom-elements-runtime.router.es.js.map
|