wj-elements 0.1.11 → 0.1.13
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/package.json +1 -1
- package/dist/dark.css +0 -1
- package/dist/light.css +0 -1
- package/dist/localize-DVuO3S17.js +0 -43
- package/dist/popup.element-CpEjis9f.js +0 -1068
- package/dist/router-links-FtZbFUto.js +0 -146
- package/dist/styles.css +0 -1
- package/dist/wje-accordion-item.js +0 -88
- package/dist/wje-accordion.js +0 -79
- package/dist/wje-animation.js +0 -121
- package/dist/wje-aside.js +0 -55
- package/dist/wje-avatar.js +0 -74
- package/dist/wje-badge.js +0 -50
- package/dist/wje-breadcrumb.js +0 -148
- package/dist/wje-breadcrumbs.js +0 -67
- package/dist/wje-button-group.js +0 -78
- package/dist/wje-button.js +0 -175
- package/dist/wje-card-content.js +0 -48
- package/dist/wje-card-controls.js +0 -48
- package/dist/wje-card-header.js +0 -47
- package/dist/wje-card-subtitle.js +0 -55
- package/dist/wje-card-title.js +0 -55
- package/dist/wje-card.js +0 -50
- package/dist/wje-carousel-item.js +0 -33
- package/dist/wje-carousel.js +0 -177
- package/dist/wje-checkbox.js +0 -104
- package/dist/wje-chip.js +0 -32
- package/dist/wje-col.js +0 -27
- package/dist/wje-color-picker.js +0 -953
- package/dist/wje-container.js +0 -57
- package/dist/wje-copy-button.js +0 -164
- package/dist/wje-dialog.js +0 -86
- package/dist/wje-divider.js +0 -53
- package/dist/wje-dropdown.js +0 -68
- package/dist/wje-element.js +0 -453
- package/dist/wje-fetchAndParseCSS.js +0 -40
- package/dist/wje-file-upload-item.js +0 -115
- package/dist/wje-file-upload.js +0 -297
- package/dist/wje-footer.js +0 -56
- package/dist/wje-form.js +0 -28
- package/dist/wje-format-digital.js +0 -85
- package/dist/wje-grid.js +0 -28
- package/dist/wje-header.js +0 -58
- package/dist/wje-icon-picker.js +0 -221
- package/dist/wje-icon.js +0 -119
- package/dist/wje-img-comparer.js +0 -111
- package/dist/wje-img.js +0 -58
- package/dist/wje-infinite-scroll.js +0 -193
- package/dist/wje-inline-edit.js +0 -120
- package/dist/wje-input-file.js +0 -85
- package/dist/wje-input.js +0 -240
- package/dist/wje-item.js +0 -45
- package/dist/wje-label.js +0 -67
- package/dist/wje-list.js +0 -53
- package/dist/wje-main.js +0 -56
- package/dist/wje-masonry.js +0 -218
- package/dist/wje-master.js +0 -196
- package/dist/wje-menu-button.js +0 -65
- package/dist/wje-menu-item.js +0 -192
- package/dist/wje-menu-label.js +0 -57
- package/dist/wje-menu.js +0 -74
- package/dist/wje-option.js +0 -99
- package/dist/wje-options.js +0 -63
- package/dist/wje-popup.js +0 -5
- package/dist/wje-progress-bar.js +0 -145
- package/dist/wje-radio-group.js +0 -101
- package/dist/wje-radio.js +0 -46
- package/dist/wje-rate.js +0 -260
- package/dist/wje-relative-time.js +0 -85
- package/dist/wje-reorder-dropzone.js +0 -27
- package/dist/wje-reorder-item.js +0 -32
- package/dist/wje-reorder.js +0 -132
- package/dist/wje-route.js +0 -28
- package/dist/wje-router-link.js +0 -64
- package/dist/wje-router-outlet.js +0 -127
- package/dist/wje-routerx.js +0 -1088
- package/dist/wje-row.js +0 -58
- package/dist/wje-select.js +0 -240
- package/dist/wje-slider.js +0 -177
- package/dist/wje-split-view.js +0 -112
- package/dist/wje-store.js +0 -192
- package/dist/wje-tab-group.js +0 -105
- package/dist/wje-tab-panel.js +0 -52
- package/dist/wje-tab.js +0 -59
- package/dist/wje-textarea.js +0 -116
- package/dist/wje-thumbnail.js +0 -64
- package/dist/wje-toast.js +0 -76
- package/dist/wje-toggle.js +0 -94
- package/dist/wje-toolbar-action.js +0 -63
- package/dist/wje-toolbar.js +0 -61
- package/dist/wje-tooltip.js +0 -105
- package/dist/wje-visually-hidden.js +0 -56
package/dist/wje-routerx.js
DELETED
|
@@ -1,1088 +0,0 @@
|
|
|
1
|
-
var ot = Object.defineProperty;
|
|
2
|
-
var at = (r, t, e) => t in r ? ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var A = (r, t, e) => (at(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
-
import ct from "./wje-element.js";
|
|
5
|
-
import { r as ut } from "./router-links-FtZbFUto.js";
|
|
6
|
-
var J = "/";
|
|
7
|
-
function ht(r, t, e, n) {
|
|
8
|
-
for (var i = 0, s = n; s < e.length; ) {
|
|
9
|
-
if (e[s] === "\\") {
|
|
10
|
-
s += 2;
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
if (e[s] === t && (i--, i === 0))
|
|
14
|
-
return s + 1;
|
|
15
|
-
e[s] === r && i++, s++;
|
|
16
|
-
}
|
|
17
|
-
return -1;
|
|
18
|
-
}
|
|
19
|
-
function lt(r, t) {
|
|
20
|
-
t === void 0 && (t = {});
|
|
21
|
-
for (var e, n, i = [], s = (e = t.delimiter, e ?? J), c = (n = t.whitelist, n ?? void 0), o = 0, u = 0, a = "", h = !1; o < r.length; ) {
|
|
22
|
-
var g = "", m = "", f = "";
|
|
23
|
-
if (r[o] === "\\") {
|
|
24
|
-
o++, a += r[o++], h = !0;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (r[o] === ":") {
|
|
28
|
-
for (; ++o < r.length; ) {
|
|
29
|
-
var d = r.charCodeAt(o);
|
|
30
|
-
if (
|
|
31
|
-
// `0-9`
|
|
32
|
-
d >= 48 && d <= 57 || // `A-Z`
|
|
33
|
-
d >= 65 && d <= 90 || // `a-z`
|
|
34
|
-
d >= 97 && d <= 122 || // `_`
|
|
35
|
-
d === 95
|
|
36
|
-
) {
|
|
37
|
-
m += r[o];
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
m || o--;
|
|
43
|
-
}
|
|
44
|
-
if (r[o] === "(") {
|
|
45
|
-
var w = ht("(", ")", r, o);
|
|
46
|
-
if (w > -1) {
|
|
47
|
-
if (f = r.slice(o + 1, w - 1), o = w, f[0] === "?")
|
|
48
|
-
throw new TypeError("Path pattern must be a capturing group");
|
|
49
|
-
if (/\((?=[^?])/.test(f)) {
|
|
50
|
-
var p = f.replace(/\((?=[^?])/, "(?:");
|
|
51
|
-
throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + p + ")");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (m === "" && f === "") {
|
|
56
|
-
a += r[o++], h = !1;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (a.length && !h) {
|
|
60
|
-
var y = a[a.length - 1], l = c ? c.indexOf(y) > -1 : !0;
|
|
61
|
-
l && (g = y, a = a.slice(0, -1));
|
|
62
|
-
}
|
|
63
|
-
a.length && (i.push(a), a = "");
|
|
64
|
-
var v = r[o] === "+" || r[o] === "*", E = r[o] === "?" || r[o] === "*", b = g || s;
|
|
65
|
-
(v || E) && o++, i.push({
|
|
66
|
-
name: m || u++,
|
|
67
|
-
prefix: g,
|
|
68
|
-
delimiter: b,
|
|
69
|
-
optional: E,
|
|
70
|
-
repeat: v,
|
|
71
|
-
pattern: f || "[^" + R(b === s ? b : b + s) + "]+?"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return a.length && i.push(a), i;
|
|
75
|
-
}
|
|
76
|
-
function R(r) {
|
|
77
|
-
return r.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
78
|
-
}
|
|
79
|
-
function Z(r) {
|
|
80
|
-
return r && r.sensitive ? "" : "i";
|
|
81
|
-
}
|
|
82
|
-
function ft(r, t) {
|
|
83
|
-
if (!t)
|
|
84
|
-
return r;
|
|
85
|
-
var e = r.source.match(/\((?!\?)/g);
|
|
86
|
-
if (e)
|
|
87
|
-
for (var n = 0; n < e.length; n++)
|
|
88
|
-
t.push({
|
|
89
|
-
name: n,
|
|
90
|
-
prefix: "",
|
|
91
|
-
delimiter: "",
|
|
92
|
-
optional: !1,
|
|
93
|
-
repeat: !1,
|
|
94
|
-
pattern: ""
|
|
95
|
-
});
|
|
96
|
-
return r;
|
|
97
|
-
}
|
|
98
|
-
function pt(r, t, e) {
|
|
99
|
-
var n = r.map(function(i) {
|
|
100
|
-
return G(i, t, e).source;
|
|
101
|
-
});
|
|
102
|
-
return new RegExp("(?:" + n.join("|") + ")", Z(e));
|
|
103
|
-
}
|
|
104
|
-
function dt(r, t, e) {
|
|
105
|
-
return mt(lt(r, e), t, e);
|
|
106
|
-
}
|
|
107
|
-
function mt(r, t, e) {
|
|
108
|
-
e === void 0 && (e = {});
|
|
109
|
-
for (var n = e.strict, i = e.start, s = i === void 0 ? !0 : i, c = e.end, o = c === void 0 ? !0 : c, u = e.delimiter, a = u === void 0 ? J : u, h = e.encode, g = h === void 0 ? function(E) {
|
|
110
|
-
return E;
|
|
111
|
-
} : h, m = (typeof e.endsWith == "string" ? e.endsWith.split("") : e.endsWith || []).map(R).concat("$").join("|"), f = s ? "^" : "", d = 0, w = r; d < w.length; d++) {
|
|
112
|
-
var p = w[d];
|
|
113
|
-
if (typeof p == "string")
|
|
114
|
-
f += R(g(p));
|
|
115
|
-
else {
|
|
116
|
-
var y = p.repeat ? "(?:" + p.pattern + ")(?:" + R(p.delimiter) + "(?:" + p.pattern + "))*" : p.pattern;
|
|
117
|
-
t && t.push(p), p.optional ? p.prefix ? f += "(?:" + R(p.prefix) + "(" + y + "))?" : f += "(" + y + ")?" : f += R(p.prefix) + "(" + y + ")";
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (o)
|
|
121
|
-
n || (f += "(?:" + R(a) + ")?"), f += m === "$" ? "$" : "(?=" + m + ")";
|
|
122
|
-
else {
|
|
123
|
-
var l = r[r.length - 1], v = typeof l == "string" ? l[l.length - 1] === a : (
|
|
124
|
-
// tslint:disable-next-line
|
|
125
|
-
l === void 0
|
|
126
|
-
);
|
|
127
|
-
n || (f += "(?:" + R(a) + "(?=" + m + "))?"), v || (f += "(?=" + R(a) + "|" + m + ")");
|
|
128
|
-
}
|
|
129
|
-
return new RegExp(f, Z(e));
|
|
130
|
-
}
|
|
131
|
-
function G(r, t, e) {
|
|
132
|
-
return r instanceof RegExp ? ft(r, t) : Array.isArray(r) ? pt(r, t, e) : dt(r, t, e);
|
|
133
|
-
}
|
|
134
|
-
const gt = (r, t, e) => (r[t] = e, r), vt = Array.isArray, O = Object.keys, L = (r) => r && (vt(r) ? r.slice(0) : C({}, r)), F = (r, t) => t.reduce((e, n) => r[n] === void 0 ? e : gt(e, n, r[n]), {}), H = (r, t) => {
|
|
135
|
-
const e = O(r);
|
|
136
|
-
return e.length === O(t).length && e.every((n) => t[n] === r[n]);
|
|
137
|
-
}, C = Object.assign;
|
|
138
|
-
function q(r, t, ...e) {
|
|
139
|
-
if (!r) {
|
|
140
|
-
let n = 0;
|
|
141
|
-
throw new Error(
|
|
142
|
-
"Invariant Violation: " + t.replace(/%s/g, () => e[n++])
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function wt(r) {
|
|
147
|
-
let t = [];
|
|
148
|
-
const e = {}, n = {};
|
|
149
|
-
r(function(u, a, h) {
|
|
150
|
-
let g;
|
|
151
|
-
if (q(!n[u], 'Route names must be unique, but route "%s" is declared multiple times', u), n[u] = !0, arguments.length === 1 && (a = {}), arguments.length === 2 && typeof a == "function" && (h = a, a = {}), typeof a.path != "string") {
|
|
152
|
-
const m = u.split(".");
|
|
153
|
-
a.path = m[m.length - 1];
|
|
154
|
-
}
|
|
155
|
-
h && (t = t.concat(u), h(), g = i(), t.splice(-1)), s({
|
|
156
|
-
name: u,
|
|
157
|
-
path: a.path,
|
|
158
|
-
routes: g || [],
|
|
159
|
-
options: a
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
function i() {
|
|
163
|
-
return e[c()] || [];
|
|
164
|
-
}
|
|
165
|
-
function s(o) {
|
|
166
|
-
const u = c();
|
|
167
|
-
e[u] = e[u] || [], e[u].push(o);
|
|
168
|
-
}
|
|
169
|
-
function c() {
|
|
170
|
-
return t.join(".");
|
|
171
|
-
}
|
|
172
|
-
return i();
|
|
173
|
-
}
|
|
174
|
-
function X(r) {
|
|
175
|
-
const t = [];
|
|
176
|
-
return r.forEach(({ name: e, children: n, ...i }) => {
|
|
177
|
-
if (typeof i.path != "string") {
|
|
178
|
-
const s = e.split(".");
|
|
179
|
-
i.path = s[s.length - 1];
|
|
180
|
-
}
|
|
181
|
-
t.push(
|
|
182
|
-
{
|
|
183
|
-
name: e,
|
|
184
|
-
path: i.path,
|
|
185
|
-
options: i,
|
|
186
|
-
routes: n ? X(n) : []
|
|
187
|
-
}
|
|
188
|
-
);
|
|
189
|
-
}), t;
|
|
190
|
-
}
|
|
191
|
-
const yt = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g, Et = /[+*?]$/g, Y = /\?(.+)/, D = {};
|
|
192
|
-
function tt(r) {
|
|
193
|
-
if (!(r in D)) {
|
|
194
|
-
const t = [], e = G(r, t);
|
|
195
|
-
D[r] = {
|
|
196
|
-
matcher: e,
|
|
197
|
-
paramNames: t.map((n) => n.name)
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
return D[r];
|
|
201
|
-
}
|
|
202
|
-
function bt(r) {
|
|
203
|
-
return tt(r).paramNames;
|
|
204
|
-
}
|
|
205
|
-
function Rt(r, t) {
|
|
206
|
-
const e = tt(r), n = e.matcher, i = e.paramNames, s = t.match(n);
|
|
207
|
-
if (!s)
|
|
208
|
-
return null;
|
|
209
|
-
const c = {};
|
|
210
|
-
return i.forEach(function(o, u) {
|
|
211
|
-
c[o] = s[u + 1] && decodeURIComponent(s[u + 1]);
|
|
212
|
-
}), c;
|
|
213
|
-
}
|
|
214
|
-
function Tt(r, t) {
|
|
215
|
-
return t = t || {}, r.replace(yt, function(e, n) {
|
|
216
|
-
const i = n.replace(Et, ""), s = n.slice(-1);
|
|
217
|
-
if (s === "?" || s === "*") {
|
|
218
|
-
if (t[i] == null)
|
|
219
|
-
return "";
|
|
220
|
-
} else
|
|
221
|
-
q(
|
|
222
|
-
t[i] != null,
|
|
223
|
-
"Missing '%s' parameter for path '%s'",
|
|
224
|
-
i,
|
|
225
|
-
r
|
|
226
|
-
);
|
|
227
|
-
let c = encodeURIComponent(t[i]);
|
|
228
|
-
return (s === "*" || s === "+") && (c = c.replaceAll("%2F", "/")), c;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
function Lt(r, t) {
|
|
232
|
-
const e = t.match(Y);
|
|
233
|
-
return e && r.parse(e[1]);
|
|
234
|
-
}
|
|
235
|
-
function Ct(r, t, e) {
|
|
236
|
-
const n = r.stringify(e, { indices: !1 });
|
|
237
|
-
return n ? et(t) + "?" + n : t;
|
|
238
|
-
}
|
|
239
|
-
function et(r) {
|
|
240
|
-
return r.replace(Y, "");
|
|
241
|
-
}
|
|
242
|
-
function rt(r, t, e) {
|
|
243
|
-
return r.addEventListener(t, e), e;
|
|
244
|
-
}
|
|
245
|
-
function nt(r, t, e) {
|
|
246
|
-
return r.removeEventListener(t, e), e;
|
|
247
|
-
}
|
|
248
|
-
class $t {
|
|
249
|
-
constructor() {
|
|
250
|
-
this.handlers = [], this.checkUrl = this.checkUrl.bind(this), this.location = window.location, this.history = window.history;
|
|
251
|
-
}
|
|
252
|
-
// Set up all inheritable **Backbone.History** properties and methods.
|
|
253
|
-
// Are we at the app root?
|
|
254
|
-
atRoot() {
|
|
255
|
-
return this.location.pathname.replace(/[^\/]$/, "$&/") === this.root;
|
|
256
|
-
}
|
|
257
|
-
// Gets the true hash value. Cannot use location.hash directly due to bug
|
|
258
|
-
// in Firefox where location.hash will always be decoded.
|
|
259
|
-
getHash() {
|
|
260
|
-
const t = this.location.href.match(/#(.*)$/);
|
|
261
|
-
return t ? t[1] : "";
|
|
262
|
-
}
|
|
263
|
-
// Get the cross-browser normalized URL fragment, either from the URL,
|
|
264
|
-
// the hash, or the override.
|
|
265
|
-
getFragment(t, e) {
|
|
266
|
-
if (t == null)
|
|
267
|
-
if (this._hasPushState || !this._wantsHashChange || e) {
|
|
268
|
-
t = decodeURI(this.location.pathname + this.location.search);
|
|
269
|
-
const n = this.root.replace(Ut, "");
|
|
270
|
-
t.indexOf(n) || (t = t.slice(n.length));
|
|
271
|
-
} else
|
|
272
|
-
t = this.getHash();
|
|
273
|
-
return t.replace(B, "");
|
|
274
|
-
}
|
|
275
|
-
// Start the hash change handling, returning `true` if the current URL matches
|
|
276
|
-
// an existing route, and `false` otherwise.
|
|
277
|
-
start(t = {}) {
|
|
278
|
-
this.started = !0, this.options = C({ root: "/" }, t), this.location = this.options.location || this.location, this.history = this.options.history || this.history, this.root = this.options.root, this._wantsHashChange = this.options.hashChange !== !1, this._wantsPushState = !!this.options.pushState, this._hasPushState = this._wantsPushState;
|
|
279
|
-
const e = this.getFragment();
|
|
280
|
-
this.root = `/${this.root}/`.replace(St, "/"), rt(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.fragment = e;
|
|
281
|
-
const n = this.location;
|
|
282
|
-
if (this._wantsHashChange && this._wantsPushState) {
|
|
283
|
-
if (!this._hasPushState && !this.atRoot())
|
|
284
|
-
return this.fragment = this.getFragment(null, !0), this.location.replace(`${this.root}#${this.fragment}`), !0;
|
|
285
|
-
this._hasPushState && this.atRoot() && n.hash && (this.fragment = this.getHash().replace(B, ""), this.history.replaceState({}, document.title, this.root + this.fragment));
|
|
286
|
-
}
|
|
287
|
-
if (!this.options.silent)
|
|
288
|
-
return this.loadUrl();
|
|
289
|
-
}
|
|
290
|
-
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
|
291
|
-
// but possibly useful for unit testing Routers.
|
|
292
|
-
stop() {
|
|
293
|
-
nt(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.started = !1;
|
|
294
|
-
}
|
|
295
|
-
// Add a route to be tested when the fragment changes. Routes added later
|
|
296
|
-
// may override previous routes.
|
|
297
|
-
route(t, e) {
|
|
298
|
-
this.handlers.unshift({ route: t, callback: e });
|
|
299
|
-
}
|
|
300
|
-
// Checks the current URL to see if it has changed, and if it has,
|
|
301
|
-
// calls `loadUrl`.
|
|
302
|
-
checkUrl() {
|
|
303
|
-
if (this.getFragment() === this.fragment)
|
|
304
|
-
return !1;
|
|
305
|
-
this.loadUrl();
|
|
306
|
-
}
|
|
307
|
-
// Attempt to load the current URL fragment. If a route succeeds with a
|
|
308
|
-
// match, returns `true`. If no defined routes matches the fragment,
|
|
309
|
-
// returns `false`.
|
|
310
|
-
loadUrl(t) {
|
|
311
|
-
return t = this.fragment = this.getFragment(t), this.handlers.some((e) => {
|
|
312
|
-
if (e.route.test(t))
|
|
313
|
-
return e.callback(t), !0;
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
// Save a fragment into the hash history, or replace the URL state if the
|
|
317
|
-
// 'replace' option is passed. You are responsible for properly URL-encoding
|
|
318
|
-
// the fragment in advance.
|
|
319
|
-
//
|
|
320
|
-
// The options object can contain `trigger: true` if you wish to have the
|
|
321
|
-
// route callback be fired (not usually desirable), or `replace: true`, if
|
|
322
|
-
// you wish to modify the current URL without adding an entry to the history.
|
|
323
|
-
update(t, e) {
|
|
324
|
-
if (!this.started)
|
|
325
|
-
return !1;
|
|
326
|
-
(!e || e === !0) && (e = { trigger: !!e });
|
|
327
|
-
let n = this.root + (t = this.getFragment(t || ""));
|
|
328
|
-
if (t = t.replace(xt, ""), this.fragment !== t) {
|
|
329
|
-
if (this.fragment = t, t === "" && n !== "/" && (n = n.slice(0, -1)), this._hasPushState)
|
|
330
|
-
this.history[e.replace ? "replaceState" : "pushState"]({}, document.title, n);
|
|
331
|
-
else if (this._wantsHashChange)
|
|
332
|
-
this._updateHash(this.location, t, e.replace);
|
|
333
|
-
else
|
|
334
|
-
return this.location.assign(n);
|
|
335
|
-
if (e.trigger)
|
|
336
|
-
return this.loadUrl(t);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
// Update the hash location, either replacing the current entry, or adding
|
|
340
|
-
// a new one to the browser history.
|
|
341
|
-
_updateHash(t, e, n) {
|
|
342
|
-
if (n) {
|
|
343
|
-
const i = t.href.replace(/(javascript:|#).*$/, "");
|
|
344
|
-
t.replace(`${i}#${e}`);
|
|
345
|
-
} else
|
|
346
|
-
t.hash = `#${e}`;
|
|
347
|
-
}
|
|
348
|
-
// add some features to History
|
|
349
|
-
// a generic callback for any changes
|
|
350
|
-
onChange(t) {
|
|
351
|
-
this.route(/^(.*?)$/, t);
|
|
352
|
-
}
|
|
353
|
-
// checks if the browser has pushstate support
|
|
354
|
-
hasPushState() {
|
|
355
|
-
if (!this.started)
|
|
356
|
-
throw new Error("only available after LocationBar.start()");
|
|
357
|
-
return this._hasPushState;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const B = /^[#\/]|\s+$/g, St = /^\/+|\/+$/g, Ut = /\/$/, xt = /#.*$/;
|
|
361
|
-
class Pt {
|
|
362
|
-
constructor(t = {}) {
|
|
363
|
-
this.path = t.path || "", this.options = C({
|
|
364
|
-
pushState: !1,
|
|
365
|
-
root: "/"
|
|
366
|
-
}, t), this.locationBar = new $t(), this.locationBar.onChange((e) => {
|
|
367
|
-
this.handleURL(`/${e || ""}`);
|
|
368
|
-
}), this.locationBar.start(t);
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Get the current URL
|
|
372
|
-
*/
|
|
373
|
-
getURL() {
|
|
374
|
-
return this.path;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Set the current URL without triggering any events
|
|
378
|
-
* back to the router. Add a new entry in browser's history.
|
|
379
|
-
*/
|
|
380
|
-
setURL(t, e = {}) {
|
|
381
|
-
this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0 }, e)));
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Set the current URL without triggering any events
|
|
385
|
-
* back to the router. Replace the latest entry in broser's history.
|
|
386
|
-
*/
|
|
387
|
-
replaceURL(t, e = {}) {
|
|
388
|
-
this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0, replace: !0 }, e)));
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Setup a URL change handler
|
|
392
|
-
* @param {Function} callback
|
|
393
|
-
*/
|
|
394
|
-
onChange(t) {
|
|
395
|
-
this.changeCallback = t;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Given a path, generate a URL appending root
|
|
399
|
-
* if pushState is used and # if hash state is used
|
|
400
|
-
*/
|
|
401
|
-
formatURL(t) {
|
|
402
|
-
if (this.locationBar.hasPushState()) {
|
|
403
|
-
let e = this.options.root;
|
|
404
|
-
return t !== "" && (e = e.replace(/\/$/, "")), e + t;
|
|
405
|
-
} else
|
|
406
|
-
return t[0] === "/" && (t = t.substr(1)), `#${t}`;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* When we use pushState with a custom root option,
|
|
410
|
-
* we need to take care of removingRoot at certain points.
|
|
411
|
-
* Specifically
|
|
412
|
-
* - browserLocation.update() can be called with the full URL by router
|
|
413
|
-
* - LocationBar expects all .update() calls to be called without root
|
|
414
|
-
* - this method is public so that we could dispatch URLs without root in router
|
|
415
|
-
*/
|
|
416
|
-
removeRoot(t) {
|
|
417
|
-
return this.options.pushState && this.options.root && this.options.root !== "/" ? t.replace(this.options.root, "") : t;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Stop listening to URL changes and link clicks
|
|
421
|
-
*/
|
|
422
|
-
destroy() {
|
|
423
|
-
this.locationBar.stop();
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
initially, the changeCallback won't be defined yet, but that's good
|
|
427
|
-
because we dont' want to kick off routing right away, the router
|
|
428
|
-
does that later by manually calling this handleURL method with the
|
|
429
|
-
url it reads of the location. But it's important this is called
|
|
430
|
-
first by Backbone, because we wanna set a correct this.path value
|
|
431
|
-
|
|
432
|
-
@private
|
|
433
|
-
*/
|
|
434
|
-
handleURL(t) {
|
|
435
|
-
this.path = t, this.changeCallback && this.changeCallback(t);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
class _t {
|
|
439
|
-
constructor({ path: t }) {
|
|
440
|
-
this.path = t || "";
|
|
441
|
-
}
|
|
442
|
-
getURL() {
|
|
443
|
-
return this.path;
|
|
444
|
-
}
|
|
445
|
-
setURL(t, e) {
|
|
446
|
-
this.path !== t && (this.path = t, this.handleURL(this.getURL(), e));
|
|
447
|
-
}
|
|
448
|
-
replaceURL(t, e) {
|
|
449
|
-
this.path !== t && this.setURL(t, e);
|
|
450
|
-
}
|
|
451
|
-
onChange(t) {
|
|
452
|
-
this.changeCallback = t;
|
|
453
|
-
}
|
|
454
|
-
handleURL(t, e = {}) {
|
|
455
|
-
this.path = t, e = C({ trigger: !0 }, e), this.changeCallback && e.trigger && this.changeCallback(t);
|
|
456
|
-
}
|
|
457
|
-
removeRoot(t) {
|
|
458
|
-
return t;
|
|
459
|
-
}
|
|
460
|
-
formatURL(t) {
|
|
461
|
-
return t;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
const I = "TransitionRedirected", P = "TransitionCancelled";
|
|
465
|
-
function W(r, t, e) {
|
|
466
|
-
r.middleware.forEach((n) => {
|
|
467
|
-
n.error && n.error(t, e);
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
function k(r) {
|
|
471
|
-
r = r || {};
|
|
472
|
-
const t = r.router, e = t.log, n = t.logError, i = r.path, s = r.match, c = s.routes, o = s.params, u = s.pathname, a = s.query, h = r.id, g = Date.now();
|
|
473
|
-
e("---"), e("Transition #" + h, "to", i), e("Transition #" + h, "routes:", c.map((l) => l.name)), e("Transition #" + h, "params:", o), e("Transition #" + h, "query:", a);
|
|
474
|
-
let m, f;
|
|
475
|
-
const d = new Promise(function(l, v) {
|
|
476
|
-
m = l, f = v;
|
|
477
|
-
});
|
|
478
|
-
d.then(function() {
|
|
479
|
-
e("Transition #" + h, "completed in", Date.now() - g + "ms");
|
|
480
|
-
}).catch(function(l) {
|
|
481
|
-
l.type !== I && l.type !== P && (e("Transition #" + h, "FAILED"), n(l));
|
|
482
|
-
});
|
|
483
|
-
let w = !1;
|
|
484
|
-
const p = {
|
|
485
|
-
id: h,
|
|
486
|
-
prev: {
|
|
487
|
-
routes: L(t.state.routes) || [],
|
|
488
|
-
path: t.state.path || "",
|
|
489
|
-
pathname: t.state.pathname || "",
|
|
490
|
-
params: L(t.state.params) || {},
|
|
491
|
-
query: L(t.state.query) || {}
|
|
492
|
-
},
|
|
493
|
-
routes: L(c),
|
|
494
|
-
path: i,
|
|
495
|
-
pathname: u,
|
|
496
|
-
params: L(o),
|
|
497
|
-
query: L(a),
|
|
498
|
-
redirectTo: function(...l) {
|
|
499
|
-
return t.transitionTo(...l);
|
|
500
|
-
},
|
|
501
|
-
retry: function() {
|
|
502
|
-
return t.transitionTo(i);
|
|
503
|
-
},
|
|
504
|
-
cancel: function(l) {
|
|
505
|
-
t.state.activeTransition === p && (p.isCancelled || (t.state.activeTransition = null, p.isCancelled = !0, w = !0, l || (l = new Error(P), l.type = P), l.type === P && e("Transition #" + h, "cancelled"), l.type === I && e("Transition #" + h, "redirected"), t.middleware.forEach((v) => {
|
|
506
|
-
v.cancel && v.cancel(p, l);
|
|
507
|
-
}), f(l)));
|
|
508
|
-
},
|
|
509
|
-
followRedirects: function() {
|
|
510
|
-
return d.catch(function(l) {
|
|
511
|
-
return t.state.activeTransition ? t.state.activeTransition.followRedirects() : Promise.reject(l);
|
|
512
|
-
});
|
|
513
|
-
},
|
|
514
|
-
then: d.then.bind(d),
|
|
515
|
-
catch: d.catch.bind(d)
|
|
516
|
-
};
|
|
517
|
-
t.middleware.forEach((l) => {
|
|
518
|
-
l.before && l.before(p);
|
|
519
|
-
});
|
|
520
|
-
function y(l, v) {
|
|
521
|
-
let E, b;
|
|
522
|
-
if (!w)
|
|
523
|
-
if (l < t.middleware.length) {
|
|
524
|
-
E = t.middleware[l], b = E.name || "anonymous", e("Transition #" + h, "resolving middleware:", b);
|
|
525
|
-
let S;
|
|
526
|
-
try {
|
|
527
|
-
S = E.resolve ? E.resolve(p, v) : v, q(p !== S, "Middleware %s returned a transition which resulted in a deadlock", b);
|
|
528
|
-
} catch (T) {
|
|
529
|
-
return t.state.activeTransition = null, W(t, p, T), f(T);
|
|
530
|
-
}
|
|
531
|
-
Promise.resolve(S).then(function(T) {
|
|
532
|
-
y(l + 1, T);
|
|
533
|
-
}).catch(function(T) {
|
|
534
|
-
e("Transition #" + h, "resolving middleware:", b, "FAILED"), t.state.activeTransition = null, W(t, p, T), f(T);
|
|
535
|
-
});
|
|
536
|
-
} else
|
|
537
|
-
t.state = {
|
|
538
|
-
activeTransition: null,
|
|
539
|
-
routes: c,
|
|
540
|
-
path: i,
|
|
541
|
-
pathname: u,
|
|
542
|
-
params: o,
|
|
543
|
-
query: a
|
|
544
|
-
}, t.middleware.forEach((S) => {
|
|
545
|
-
S.done && S.done(p);
|
|
546
|
-
}), m();
|
|
547
|
-
}
|
|
548
|
-
return r.noop ? m() : Promise.resolve().then(() => y(0)), r.noop && (p.noop = !0), p;
|
|
549
|
-
}
|
|
550
|
-
function At(r, t) {
|
|
551
|
-
const e = It(r, "click", function(n, i) {
|
|
552
|
-
qt(n, i) && t(n, i);
|
|
553
|
-
});
|
|
554
|
-
return function() {
|
|
555
|
-
Nt(r, "click", e);
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
function Ot(r) {
|
|
559
|
-
var e;
|
|
560
|
-
r = { parentNode: r };
|
|
561
|
-
const t = document;
|
|
562
|
-
for (; (r = r.parentNode) && r !== document; ) {
|
|
563
|
-
if (((e = r.tagName) == null ? void 0 : e.toLowerCase()) === "a")
|
|
564
|
-
return r;
|
|
565
|
-
if (r === t)
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function It(r, t, e) {
|
|
570
|
-
return rt(r, t, function(n) {
|
|
571
|
-
const i = n.target || n.srcElement, s = Ot(i);
|
|
572
|
-
s && e(n, s);
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
function Nt(r, t, e) {
|
|
576
|
-
nt(r, t, e);
|
|
577
|
-
}
|
|
578
|
-
function qt(r, t) {
|
|
579
|
-
if (Dt(r) !== 1 || r.metaKey || r.ctrlKey || r.shiftKey || r.defaultPrevented || t.target || t.getAttribute("data-bypass") !== null)
|
|
580
|
-
return;
|
|
581
|
-
const e = t.getAttribute("href");
|
|
582
|
-
if (!(!e || e.length === 0) && e[0] !== "#" && !(e.indexOf("http://") === 0 || e.indexOf("https://") === 0) && e.indexOf("mailto:") !== 0 && e.indexOf("javascript:") !== 0)
|
|
583
|
-
return !0;
|
|
584
|
-
}
|
|
585
|
-
function Dt(r) {
|
|
586
|
-
return r = r || window.event, r.which === null ? r.button : r.which;
|
|
587
|
-
}
|
|
588
|
-
function Q(r, t, e) {
|
|
589
|
-
e !== !0 && (r[t] = typeof e == "function" ? e : () => {
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
var Mt = {
|
|
593
|
-
parse(r) {
|
|
594
|
-
return r.split("&").reduce((t, e) => {
|
|
595
|
-
const n = e.split("=");
|
|
596
|
-
return t[n[0]] = decodeURIComponent(n[1]), t;
|
|
597
|
-
}, {});
|
|
598
|
-
},
|
|
599
|
-
stringify(r) {
|
|
600
|
-
return Object.keys(r).reduce((t, e) => (r[e] !== void 0 && t.push(e + "=" + encodeURIComponent(r[e])), t), []).join("&");
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
class jt {
|
|
604
|
-
constructor(t = {}) {
|
|
605
|
-
this.nextId = 1, this.state = {}, this.middleware = [], this.options = C({
|
|
606
|
-
location: "browser",
|
|
607
|
-
logError: !0,
|
|
608
|
-
qs: Mt
|
|
609
|
-
}, t), Q(this, "log", this.options.log), Q(this, "logError", this.options.logError), t.routes && this.map(t.routes);
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Add a middleware
|
|
613
|
-
* @param {Function} middleware
|
|
614
|
-
* @return {Object} router
|
|
615
|
-
* @api public
|
|
616
|
-
*/
|
|
617
|
-
use(t, e = {}) {
|
|
618
|
-
const n = typeof t == "function" ? { resolve: t } : t;
|
|
619
|
-
return typeof e.at == "number" ? this.middleware.splice(e.at, 0, n) : this.middleware.push(n), n.create && n.create(this), this;
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Add the route map
|
|
623
|
-
* @param {Function} routes
|
|
624
|
-
* @return {Object} router
|
|
625
|
-
* @api public
|
|
626
|
-
*/
|
|
627
|
-
map(t) {
|
|
628
|
-
this.routes = Array.isArray(t) ? X(t) : wt(t);
|
|
629
|
-
const e = this.matchers = [], n = {}, i = {};
|
|
630
|
-
s({ routes: this.routes }, [], (c) => {
|
|
631
|
-
let o = c.reduce((a, h) => (
|
|
632
|
-
// reset if there's a leading slash, otherwise concat
|
|
633
|
-
// and keep resetting the trailing slash
|
|
634
|
-
(h.path[0] === "/" ? h.path : `${a}/${h.path}`).replace(/\/$/, "")
|
|
635
|
-
), "");
|
|
636
|
-
o === "" && (o = "/");
|
|
637
|
-
const u = c[c.length - 1];
|
|
638
|
-
if (u.options.abstract) {
|
|
639
|
-
i[o] = u.name;
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
if (u.path === "") {
|
|
643
|
-
let a;
|
|
644
|
-
e.some((h) => {
|
|
645
|
-
if (h.path === o)
|
|
646
|
-
return a = h, !0;
|
|
647
|
-
}), a ? a.routes = c : i[o] && e.push({
|
|
648
|
-
routes: c,
|
|
649
|
-
name: i[o],
|
|
650
|
-
path: o
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
if (e.push({
|
|
654
|
-
routes: c,
|
|
655
|
-
name: u.name,
|
|
656
|
-
path: o
|
|
657
|
-
}), n[o] && u.path !== "")
|
|
658
|
-
throw new Error(`Routes ${n[o]} and ${u.name} have the same url path '${o}'`);
|
|
659
|
-
n[o] = u.name;
|
|
660
|
-
});
|
|
661
|
-
function s(c, o, u) {
|
|
662
|
-
c.routes.forEach((a) => {
|
|
663
|
-
u(o.concat(a)), a.routes.length && s(a, o.concat(a), u);
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
return this;
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Starts listening to the location changes.
|
|
670
|
-
* @param {Object} location (optional)
|
|
671
|
-
* @return {Promise} initial transition
|
|
672
|
-
*
|
|
673
|
-
* @api public
|
|
674
|
-
*/
|
|
675
|
-
listen(t) {
|
|
676
|
-
const e = this.location = this.createLocation(t || "");
|
|
677
|
-
return e.onChange((n) => {
|
|
678
|
-
const i = this.state.path;
|
|
679
|
-
this.dispatch(n).catch((s) => (s && s.type === P && this.location.replaceURL(i, { trigger: !1 }), s));
|
|
680
|
-
}), this.dispatch(e.getURL());
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Transition to a different route. Passe in url or a route name followed by params and query
|
|
684
|
-
* @param {String} url url or route name
|
|
685
|
-
* @param {Object} params Optional
|
|
686
|
-
* @param {Object} query Optional
|
|
687
|
-
* @return {Object} transition
|
|
688
|
-
*
|
|
689
|
-
* @api public
|
|
690
|
-
*/
|
|
691
|
-
transitionTo(t, e, n) {
|
|
692
|
-
return this.state.activeTransition ? this.replaceWith(t, e, n) : this.doTransition("setURL", t, e, n);
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Like transitionTo, but doesn't leave an entry in the browser's history,
|
|
696
|
-
* so clicking back will skip this route
|
|
697
|
-
* @param {String} url url or route name followed by params and query
|
|
698
|
-
* @param {Object} params Optional
|
|
699
|
-
* @param {Object} query Optional
|
|
700
|
-
* @return {Object} transition
|
|
701
|
-
*
|
|
702
|
-
* @api public
|
|
703
|
-
*/
|
|
704
|
-
replaceWith(t, e, n) {
|
|
705
|
-
return this.doTransition("replaceURL", t, e, n);
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Create an href
|
|
709
|
-
* @param {String} name target route name
|
|
710
|
-
* @param {Object} params
|
|
711
|
-
* @param {Object} query
|
|
712
|
-
* @return {String} href
|
|
713
|
-
*
|
|
714
|
-
* @api public
|
|
715
|
-
*/
|
|
716
|
-
generate(t, e, n) {
|
|
717
|
-
q(this.location, "call .listen() before using .generate()");
|
|
718
|
-
let i;
|
|
719
|
-
if (n = n || {}, this.matchers.forEach((c) => {
|
|
720
|
-
c.name === t && (i = c);
|
|
721
|
-
}), !i)
|
|
722
|
-
throw new Error(`No route is named ${t}`);
|
|
723
|
-
const s = Ct(this.options.qs, Tt(i.path, e), n);
|
|
724
|
-
return this.location.formatURL(s);
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Stop listening to URL changes
|
|
728
|
-
* @api public
|
|
729
|
-
*/
|
|
730
|
-
destroy() {
|
|
731
|
-
this.location && this.location.destroy && this.location.destroy(), this.state.activeTransition && this.state.activeTransition.cancel(), this.state = {}, this.middleware.forEach((t) => {
|
|
732
|
-
t.destroy && t.destroy(this);
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Check if the given route/params/query combo is active
|
|
737
|
-
* @param {String} name target route name
|
|
738
|
-
* @param {Object} params
|
|
739
|
-
* @param {Object} query
|
|
740
|
-
* @return {Boolean}
|
|
741
|
-
*
|
|
742
|
-
* @api public
|
|
743
|
-
*/
|
|
744
|
-
isActive(t, e, n, i) {
|
|
745
|
-
const s = this.state.routes || [], c = this.state.params, o = this.state.query;
|
|
746
|
-
let u = s.some((a) => a.name === t) && (!i || s[s.length - 1].name === t);
|
|
747
|
-
return u = u && (!e || O(e).every((a) => c[a] === e[a])), u = u && (!n || O(n).every((a) => o[a] === n[a])), u;
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* @api private
|
|
751
|
-
*/
|
|
752
|
-
doTransition(t, e, n, i) {
|
|
753
|
-
const s = this.location.getURL();
|
|
754
|
-
let c = e;
|
|
755
|
-
c[0] !== "/" && (c = this.generate(e, n, i), c = c.replace(/^#/, "/")), this.options.pushState && (c = this.location.removeRoot(c));
|
|
756
|
-
const o = this.dispatch(c);
|
|
757
|
-
return o.catch((u) => (u && u.type === P && this.location.replaceURL(s, { trigger: !1 }), u)), this.location[t](c, { trigger: !1 }), o;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Match the path against the routes
|
|
761
|
-
* @param {String} path
|
|
762
|
-
* @return {Object} the list of matching routes and params
|
|
763
|
-
*
|
|
764
|
-
* @api private
|
|
765
|
-
*/
|
|
766
|
-
match(t) {
|
|
767
|
-
t = (t || "").replace(/\/$/, "") || "/";
|
|
768
|
-
let e, n = [];
|
|
769
|
-
const i = et(t), s = this.options.qs;
|
|
770
|
-
return this.matchers.some((o) => {
|
|
771
|
-
if (e = Rt(o.path, i), e)
|
|
772
|
-
return n = o.routes, !0;
|
|
773
|
-
}), {
|
|
774
|
-
routes: n.map(c),
|
|
775
|
-
params: e || {},
|
|
776
|
-
pathname: i,
|
|
777
|
-
query: Lt(s, t) || {}
|
|
778
|
-
};
|
|
779
|
-
function c(o) {
|
|
780
|
-
return {
|
|
781
|
-
name: o.name,
|
|
782
|
-
path: o.path,
|
|
783
|
-
params: F(e, bt(o.path)),
|
|
784
|
-
options: L(o.options)
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
dispatch(t) {
|
|
789
|
-
const e = this.match(t), n = e.query, i = e.pathname, s = this.state.activeTransition;
|
|
790
|
-
if (s && s.pathname === i && H(s.query, n))
|
|
791
|
-
return s;
|
|
792
|
-
if (s) {
|
|
793
|
-
const o = new Error(I);
|
|
794
|
-
o.type = I, o.nextPath = t, s.cancel(o);
|
|
795
|
-
}
|
|
796
|
-
if (!s && this.state.pathname === i && H(this.state.query, n))
|
|
797
|
-
return k({
|
|
798
|
-
id: this.nextId++,
|
|
799
|
-
path: t,
|
|
800
|
-
match: e,
|
|
801
|
-
noop: !0,
|
|
802
|
-
router: this
|
|
803
|
-
});
|
|
804
|
-
const c = k({
|
|
805
|
-
id: this.nextId++,
|
|
806
|
-
path: t,
|
|
807
|
-
match: e,
|
|
808
|
-
router: this
|
|
809
|
-
});
|
|
810
|
-
return this.state.activeTransition = c, c;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Create the default location.
|
|
814
|
-
* This is used when no custom location is passed to
|
|
815
|
-
* the listen call.
|
|
816
|
-
* @return {Object} location
|
|
817
|
-
*
|
|
818
|
-
* @api private
|
|
819
|
-
*/
|
|
820
|
-
createLocation(t) {
|
|
821
|
-
const e = this.options.location;
|
|
822
|
-
if (typeof e != "string")
|
|
823
|
-
return e;
|
|
824
|
-
if (e === "browser")
|
|
825
|
-
return new Pt(F(this.options, ["pushState", "root"]));
|
|
826
|
-
if (e === "memory")
|
|
827
|
-
return new _t({ path: t });
|
|
828
|
-
throw new Error("Location can be `browser`, `memory` or a custom implementation");
|
|
829
|
-
}
|
|
830
|
-
log(...t) {
|
|
831
|
-
console.info(...t);
|
|
832
|
-
}
|
|
833
|
-
logError(...t) {
|
|
834
|
-
console.error(...t);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
function Ft(r, t, e) {
|
|
838
|
-
!t.hasAttribute("download") && !t.hasAttribute("data-phone-number") && (r.preventDefault(), e.transitionTo(e.location.removeRoot(t.getAttribute("href"))));
|
|
839
|
-
}
|
|
840
|
-
function Ht(r, t = document, e = Ft) {
|
|
841
|
-
return At(t, (n, i) => e(n, i, r));
|
|
842
|
-
}
|
|
843
|
-
const Bt = Promise.resolve();
|
|
844
|
-
let $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), j, U, x;
|
|
845
|
-
function Wt(r) {
|
|
846
|
-
const t = parseFloat(r);
|
|
847
|
-
return r == t ? t : r;
|
|
848
|
-
}
|
|
849
|
-
class kt {
|
|
850
|
-
constructor(t, e) {
|
|
851
|
-
this.key = t, this.format = e;
|
|
852
|
-
}
|
|
853
|
-
value(t) {
|
|
854
|
-
let e = this.getValue(t);
|
|
855
|
-
if (e !== void 0) {
|
|
856
|
-
const n = this.format;
|
|
857
|
-
n === "number" ? e = Wt(e) : typeof n == "function" && (e = n(e));
|
|
858
|
-
}
|
|
859
|
-
return e;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
function Qt(r) {
|
|
863
|
-
j = r, U = r.options.outlet;
|
|
864
|
-
}
|
|
865
|
-
function Vt() {
|
|
866
|
-
j = null, $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), x = null;
|
|
867
|
-
}
|
|
868
|
-
function Kt(r, t) {
|
|
869
|
-
const e = Object.keys(r);
|
|
870
|
-
return e.length === Object.keys(t).length && e.every((n) => t[n] === r[n]);
|
|
871
|
-
}
|
|
872
|
-
function zt(r) {
|
|
873
|
-
return (r.shadowRoot || r).querySelector(r.constructor.outlet || "wje-router-outlet");
|
|
874
|
-
}
|
|
875
|
-
function Jt() {
|
|
876
|
-
if (x)
|
|
877
|
-
return x;
|
|
878
|
-
if (!U)
|
|
879
|
-
return document.body;
|
|
880
|
-
if (x = typeof U == "string" ? document.querySelector(U) : U, !x)
|
|
881
|
-
throw new Error(`slick-router(wc): Invalid outlet option ${U}`);
|
|
882
|
-
return x;
|
|
883
|
-
}
|
|
884
|
-
function Zt(r, t) {
|
|
885
|
-
let e = r.routes[t];
|
|
886
|
-
for (; e; ) {
|
|
887
|
-
if (e.options.component)
|
|
888
|
-
return $[e.name];
|
|
889
|
-
e = r.routes[--t];
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
function Gt(r, t) {
|
|
893
|
-
let e, n, i;
|
|
894
|
-
const s = Math.max(r.length, t.length);
|
|
895
|
-
for (e = 0; e < s && (n = r[e], i = t[e], !(!(n && i) || n.name !== i.name || !Kt(n.params, i.params))); e++)
|
|
896
|
-
;
|
|
897
|
-
return e;
|
|
898
|
-
}
|
|
899
|
-
async function N(r, t, e, n) {
|
|
900
|
-
for (let i = 0; i < t.length; i++) {
|
|
901
|
-
let s;
|
|
902
|
-
const { route: c, el: o } = t[i], u = c.options[`${e}${n}`];
|
|
903
|
-
if (typeof u == "function" && (s = await u(r), s === !1 && r.cancel()), r.isCancelled)
|
|
904
|
-
break;
|
|
905
|
-
const a = o && o[`${e}Route${n}`];
|
|
906
|
-
if (typeof a == "function" && (s = await a.call(o, r), s === !1 && r.cancel()), r.isCancelled)
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
function Xt(r) {
|
|
911
|
-
return r && r.__esModule ? r.default : r;
|
|
912
|
-
}
|
|
913
|
-
async function Yt(r) {
|
|
914
|
-
const t = [];
|
|
915
|
-
for (const e of r) {
|
|
916
|
-
let n = e.options.reuse ? $[e.name] : void 0, i = e.options.component;
|
|
917
|
-
!n && i && (typeof i == "function" && !(i.prototype instanceof HTMLElement) && (i = M[e.name] || (M[e.name] = Xt(await i(e)))), n = typeof i == "string" ? document.createElement(i) : new i(), $[e.name] = n, n.$router = j), t.push({ el: n, route: e });
|
|
918
|
-
}
|
|
919
|
-
return t;
|
|
920
|
-
}
|
|
921
|
-
function V(r, t, e) {
|
|
922
|
-
e && Object.keys(e).forEach((n) => {
|
|
923
|
-
const i = e[n];
|
|
924
|
-
t[n] = i instanceof kt ? i.value(r) : i;
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
const it = /* @__PURE__ */ new WeakSet(), K = /* @__PURE__ */ new WeakMap();
|
|
928
|
-
async function te(r, t, e) {
|
|
929
|
-
const { path: n, pathname: i, routes: s, params: c, query: o } = r, u = { path: n, pathname: i, routes: s, params: c, query: o };
|
|
930
|
-
for (let a = 0; a < e; a++) {
|
|
931
|
-
const h = r.routes[a], g = $[h.name];
|
|
932
|
-
g && (g.$route = u, V(r, g, h.options.properties));
|
|
933
|
-
}
|
|
934
|
-
for (let a = 0; a < t.length; a++) {
|
|
935
|
-
const { el: h, route: g } = t[a];
|
|
936
|
-
if (h) {
|
|
937
|
-
const m = Zt(r, e + a - 1), f = m ? zt(m) : Jt();
|
|
938
|
-
if (f) {
|
|
939
|
-
const d = K.get(f) || f.firstElementChild;
|
|
940
|
-
d && (f.removeChild(d), it.add(d)), h.$route = u, V(r, h, g.options.properties), f.appendChild(h), K.set(f, h), await (h.updateComplete || Bt);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
function ee(r, t) {
|
|
946
|
-
let e;
|
|
947
|
-
for (let n = t.length - 1; n >= 0; n--) {
|
|
948
|
-
const { route: i, el: s } = t[n];
|
|
949
|
-
r.some(({ route: c }) => c.name === i.name) || (s && (!e && !it.has(s) && s.remove(), e = !0), $[i.name] = void 0);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
async function re(r) {
|
|
953
|
-
const t = r.prev.routes, e = Gt(t, r.routes), n = [];
|
|
954
|
-
for (let s = t.length - 1; s >= e; s--) {
|
|
955
|
-
const c = t[s];
|
|
956
|
-
n.push({ el: $[c.name], route: c });
|
|
957
|
-
}
|
|
958
|
-
if (await N(r, n, "before", "Leave"), r.isCancelled)
|
|
959
|
-
return;
|
|
960
|
-
const i = await Yt(r.routes.slice(e));
|
|
961
|
-
await N(r, i, "before", "Enter"), !r.isCancelled && (await te(r, i, e), ee(i, n), r.activated = i, r.deactivated = n);
|
|
962
|
-
}
|
|
963
|
-
function ne(r) {
|
|
964
|
-
N(r, r.deactivated, "after", "Leave"), N(r, r.activated, "after", "Enter");
|
|
965
|
-
}
|
|
966
|
-
const ie = {
|
|
967
|
-
create: Qt,
|
|
968
|
-
destroy: Vt,
|
|
969
|
-
resolve: re,
|
|
970
|
-
done: ne
|
|
971
|
-
};
|
|
972
|
-
let st;
|
|
973
|
-
function _(r, t) {
|
|
974
|
-
window.dispatchEvent(new CustomEvent(`${st}${r}`, { detail: t }));
|
|
975
|
-
}
|
|
976
|
-
const se = {
|
|
977
|
-
create: function(r) {
|
|
978
|
-
st = r.options.eventPrefix || "router-";
|
|
979
|
-
},
|
|
980
|
-
before: function(r) {
|
|
981
|
-
_("before:transition", { transition: r });
|
|
982
|
-
},
|
|
983
|
-
done: function(r) {
|
|
984
|
-
_("transition", { transition: r });
|
|
985
|
-
},
|
|
986
|
-
cancel: function(r, t) {
|
|
987
|
-
t.type !== "TransitionRedirected" && _("abort", { transition: r, error: t });
|
|
988
|
-
},
|
|
989
|
-
error: function(r, t) {
|
|
990
|
-
_("abort", { transition: r, error: t }), _("error", { transition: r, error: t });
|
|
991
|
-
}
|
|
992
|
-
};
|
|
993
|
-
class z extends ct {
|
|
994
|
-
/**
|
|
995
|
-
* Creates an instance of Routerx.
|
|
996
|
-
*
|
|
997
|
-
* @constructor
|
|
998
|
-
*/
|
|
999
|
-
constructor() {
|
|
1000
|
-
super();
|
|
1001
|
-
A(this, "className", "Routerx");
|
|
1002
|
-
/**
|
|
1003
|
-
* Sets the breadcrumb for the transition.
|
|
1004
|
-
*
|
|
1005
|
-
* @param {Object} transition - The transition.
|
|
1006
|
-
*/
|
|
1007
|
-
A(this, "setBreadcrumb", (e) => {
|
|
1008
|
-
let n = [
|
|
1009
|
-
...e.routes.filter((i) => "breadcrumb" in i.options).map((i, s) => {
|
|
1010
|
-
var c, o;
|
|
1011
|
-
return {
|
|
1012
|
-
name: i.options.breadcrumbPath || i.name,
|
|
1013
|
-
text: i.options.breadcrumb instanceof Function ? (o = (c = i.options).breadcrumb) == null ? void 0 : o.call(c, e) : i.options.breadcrumb,
|
|
1014
|
-
params: { ...i.params, ...e.params },
|
|
1015
|
-
path: this.router.generate(i.name, { ...i.params, ...e.params })
|
|
1016
|
-
};
|
|
1017
|
-
})
|
|
1018
|
-
];
|
|
1019
|
-
e.breadcrumbs = n;
|
|
1020
|
-
});
|
|
1021
|
-
/**
|
|
1022
|
-
* Resets the scroll position.
|
|
1023
|
-
*
|
|
1024
|
-
* @param {Object} transition - The transition.
|
|
1025
|
-
*/
|
|
1026
|
-
A(this, "resetScrollPosition", (e) => {
|
|
1027
|
-
window.scrollTo(0, 0);
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Returns the list of attributes to observe for changes.
|
|
1032
|
-
*
|
|
1033
|
-
* @static
|
|
1034
|
-
* @returns {Array<string>}
|
|
1035
|
-
*/
|
|
1036
|
-
static get observedAttributes() {
|
|
1037
|
-
return [];
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Sets up the attributes for the component.
|
|
1041
|
-
*/
|
|
1042
|
-
setupAttributes() {
|
|
1043
|
-
this.isShadowRoot = "open";
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Sets up the router after the component is drawn.
|
|
1047
|
-
*/
|
|
1048
|
-
afterDraw() {
|
|
1049
|
-
const e = this.outerHTML, s = new DOMParser().parseFromString(e, "text/html").querySelector("wje-router"), c = this.parseElement(s).root;
|
|
1050
|
-
this.router = new jt({
|
|
1051
|
-
outlet: this.outlet || "wje-router-outlet",
|
|
1052
|
-
log: !1,
|
|
1053
|
-
logError: !1,
|
|
1054
|
-
root: this.root || "/",
|
|
1055
|
-
pushState: !0
|
|
1056
|
-
}), this.router.map(c), this.router.use(this.setBreadcrumb), this.router.use(ie), this.router.use(ut), this.router.use(se), this.router.use(this.resetScrollPosition), this.router.listen(), this.unbindIntercept = Ht(this.router);
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Parses an element and returns an object representation.
|
|
1060
|
-
*
|
|
1061
|
-
* @param {Element} element - The element to parse.
|
|
1062
|
-
* @returns {Object} The object representation of the element.
|
|
1063
|
-
*/
|
|
1064
|
-
parseElement(e) {
|
|
1065
|
-
const n = {}, i = e.attributes;
|
|
1066
|
-
for (let o = 0; o < i.length; o++) {
|
|
1067
|
-
const u = i[o].name, a = i[o].value;
|
|
1068
|
-
u === "component" && a.indexOf(".js") > -1 ? n.component = () => import(
|
|
1069
|
-
/* @vite-ignore */
|
|
1070
|
-
a
|
|
1071
|
-
) : u !== "shadow" && (n[u] = a);
|
|
1072
|
-
}
|
|
1073
|
-
const s = [];
|
|
1074
|
-
return Array.from(e.children).forEach((o) => {
|
|
1075
|
-
s.push(this.parseElement(o));
|
|
1076
|
-
}), s.length > 0 && e.tagName === "WJ-ROUTE" ? n.children = s : n.root = s, n;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Cleans up before the component is disconnected.
|
|
1080
|
-
*/
|
|
1081
|
-
beforeDisconnect() {
|
|
1082
|
-
this.unbindIntercept(), this.router.destroy();
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
z.define("wje-router", z);
|
|
1086
|
-
export {
|
|
1087
|
-
z as default
|
|
1088
|
-
};
|