wj-elements 0.0.3 → 0.0.5
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/router-links-e0087f84.js +146 -0
- package/dist/style.css +2 -2365
- package/dist/wj-aside.js +18 -22
- package/dist/wj-avatar.js +32 -49
- package/dist/wj-badge.js +18 -22
- package/dist/wj-breadcrumb.js +53 -103
- package/dist/wj-breadcrumbs.js +21 -36
- package/dist/wj-button-group.js +24 -36
- package/dist/wj-button.js +37 -80
- package/dist/wj-card-content.js +16 -18
- package/dist/wj-card-controls.js +16 -18
- package/dist/wj-card-header.js +16 -20
- package/dist/wj-card-subtitle.js +17 -19
- package/dist/wj-card-title.js +16 -18
- package/dist/wj-card.js +16 -20
- package/dist/wj-checkbox.js +24 -46
- package/dist/wj-chip.js +21 -39
- package/dist/wj-col.js +18 -32
- package/dist/wj-color-picker.js +503 -868
- package/dist/wj-container.js +18 -20
- package/dist/wj-copy-button.js +66 -112
- package/dist/wj-dialog.js +43 -67
- package/dist/wj-divider.js +16 -20
- package/dist/wj-dropdown.js +22 -31
- package/dist/wj-element.js +241 -416
- package/dist/wj-footer.js +16 -18
- package/dist/wj-form.js +16 -18
- package/dist/wj-grid.js +17 -21
- package/dist/wj-header.js +18 -22
- package/dist/wj-icon-picker.js +66 -107
- package/dist/wj-icon.js +67 -142
- package/dist/wj-img-comparer.js +43 -72
- package/dist/wj-img.js +21 -31
- package/dist/wj-infinite-scroll.js +49 -84
- package/dist/wj-input.js +67 -146
- package/dist/wj-item.js +19 -34
- package/dist/wj-label.js +19 -21
- package/dist/wj-list.js +17 -20
- package/dist/wj-main.js +16 -18
- package/dist/wj-master.js +331 -462
- package/dist/wj-menu-button.js +18 -21
- package/dist/wj-menu-item.js +67 -144
- package/dist/wj-menu-label.js +17 -21
- package/dist/wj-menu.js +20 -24
- package/dist/wj-popup.js +714 -1140
- package/dist/wj-progress-bar.js +42 -100
- package/dist/wj-radio-group.js +27 -38
- package/dist/wj-radio.js +24 -46
- package/dist/wj-route.js +8 -11
- package/dist/wj-router-link.js +19 -22
- package/dist/wj-router-outlet.js +71 -135
- package/dist/wj-routerx.js +641 -1121
- package/dist/wj-row.js +20 -22
- package/dist/wj-slider.js +55 -97
- package/dist/wj-split-view.js +45 -81
- package/dist/wj-store.js +110 -195
- package/dist/wj-textarea.js +39 -86
- package/dist/wj-thumbnail.js +17 -19
- package/dist/wj-toast.js +34 -88
- package/dist/wj-toggle.js +24 -42
- package/dist/wj-toolbar-action.js +16 -27
- package/dist/wj-toolbar.js +21 -26
- package/dist/wj-tooltip.js +27 -41
- package/dist/wj-visually-hidden.js +16 -18
- package/package.json +1 -1
- package/dist/router-links-26e4a166.js +0 -204
package/dist/wj-routerx.js
CHANGED
|
@@ -1,379 +1,254 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import WJElement from "./wj-element.js";
|
|
8
|
-
import { r as routerLinks } from "./router-links-26e4a166.js";
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var ot = (r, t, e) => t in r ? st(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var A = (r, t, e) => (ot(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import at from "./wj-element.js";
|
|
5
|
+
import { r as ct } from "./router-links-e0087f84.js";
|
|
9
6
|
import "./wj-store.js";
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (str[i] === "\\") {
|
|
16
|
-
i += 2;
|
|
7
|
+
var z = "/";
|
|
8
|
+
function ut(r, t, e, n) {
|
|
9
|
+
for (var i = 0, s = n; s < e.length; ) {
|
|
10
|
+
if (e[s] === "\\") {
|
|
11
|
+
s += 2;
|
|
17
12
|
continue;
|
|
18
13
|
}
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return i + 1;
|
|
23
|
-
}
|
|
24
|
-
if (str[i] === open) {
|
|
25
|
-
count++;
|
|
26
|
-
}
|
|
27
|
-
i++;
|
|
14
|
+
if (e[s] === t && (i--, i === 0))
|
|
15
|
+
return s + 1;
|
|
16
|
+
e[s] === r && i++, s++;
|
|
28
17
|
}
|
|
29
18
|
return -1;
|
|
30
19
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var defaultDelimiter = (_a = options.delimiter, _a !== null && _a !== void 0 ? _a : DEFAULT_DELIMITER);
|
|
38
|
-
var whitelist = (_b = options.whitelist, _b !== null && _b !== void 0 ? _b : void 0);
|
|
39
|
-
var i = 0;
|
|
40
|
-
var key = 0;
|
|
41
|
-
var path = "";
|
|
42
|
-
var isEscaped = false;
|
|
43
|
-
while (i < str.length) {
|
|
44
|
-
var prefix = "";
|
|
45
|
-
var name = "";
|
|
46
|
-
var pattern = "";
|
|
47
|
-
if (str[i] === "\\") {
|
|
48
|
-
i++;
|
|
49
|
-
path += str[i++];
|
|
50
|
-
isEscaped = true;
|
|
20
|
+
function ht(r, t) {
|
|
21
|
+
t === void 0 && (t = {});
|
|
22
|
+
for (var e, n, i = [], s = (e = t.delimiter, e ?? z), c = (n = t.whitelist, n ?? void 0), o = 0, u = 0, a = "", h = !1; o < r.length; ) {
|
|
23
|
+
var g = "", m = "", f = "";
|
|
24
|
+
if (r[o] === "\\") {
|
|
25
|
+
o++, a += r[o++], h = !0;
|
|
51
26
|
continue;
|
|
52
27
|
}
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
var
|
|
28
|
+
if (r[o] === ":") {
|
|
29
|
+
for (; ++o < r.length; ) {
|
|
30
|
+
var d = r.charCodeAt(o);
|
|
56
31
|
if (
|
|
57
32
|
// `0-9`
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
d >= 48 && d <= 57 || // `A-Z`
|
|
34
|
+
d >= 65 && d <= 90 || // `a-z`
|
|
35
|
+
d >= 97 && d <= 122 || // `_`
|
|
36
|
+
d === 95
|
|
62
37
|
) {
|
|
63
|
-
|
|
38
|
+
m += r[o];
|
|
64
39
|
continue;
|
|
65
40
|
}
|
|
66
41
|
break;
|
|
67
42
|
}
|
|
68
|
-
|
|
69
|
-
i--;
|
|
43
|
+
m || o--;
|
|
70
44
|
}
|
|
71
|
-
if (
|
|
72
|
-
var
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
i = end;
|
|
76
|
-
if (pattern[0] === "?") {
|
|
45
|
+
if (r[o] === "(") {
|
|
46
|
+
var w = ut("(", ")", r, o);
|
|
47
|
+
if (w > -1) {
|
|
48
|
+
if (f = r.slice(o + 1, w - 1), o = w, f[0] === "?")
|
|
77
49
|
throw new TypeError("Path pattern must be a capturing group");
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + validPattern + ")");
|
|
50
|
+
if (/\((?=[^?])/.test(f)) {
|
|
51
|
+
var p = f.replace(/\((?=[^?])/, "(?:");
|
|
52
|
+
throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + p + ")");
|
|
82
53
|
}
|
|
83
54
|
}
|
|
84
55
|
}
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
isEscaped = false;
|
|
56
|
+
if (m === "" && f === "") {
|
|
57
|
+
a += r[o++], h = !1;
|
|
88
58
|
continue;
|
|
89
59
|
}
|
|
90
|
-
if (
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var optional = str[i] === "?" || str[i] === "*";
|
|
104
|
-
var delimiter = prefix || defaultDelimiter;
|
|
105
|
-
if (repeat || optional)
|
|
106
|
-
i++;
|
|
107
|
-
tokens.push({
|
|
108
|
-
name: name || key++,
|
|
109
|
-
prefix,
|
|
110
|
-
delimiter,
|
|
111
|
-
optional,
|
|
112
|
-
repeat,
|
|
113
|
-
pattern: pattern || "[^" + escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter) + "]+?"
|
|
60
|
+
if (a.length && !h) {
|
|
61
|
+
var y = a[a.length - 1], l = c ? c.indexOf(y) > -1 : !0;
|
|
62
|
+
l && (g = y, a = a.slice(0, -1));
|
|
63
|
+
}
|
|
64
|
+
a.length && (i.push(a), a = "");
|
|
65
|
+
var v = r[o] === "+" || r[o] === "*", E = r[o] === "?" || r[o] === "*", b = g || s;
|
|
66
|
+
(v || E) && o++, i.push({
|
|
67
|
+
name: m || u++,
|
|
68
|
+
prefix: g,
|
|
69
|
+
delimiter: b,
|
|
70
|
+
optional: E,
|
|
71
|
+
repeat: v,
|
|
72
|
+
pattern: f || "[^" + R(b === s ? b : b + s) + "]+?"
|
|
114
73
|
});
|
|
115
74
|
}
|
|
116
|
-
|
|
117
|
-
tokens.push(path);
|
|
118
|
-
return tokens;
|
|
75
|
+
return a.length && i.push(a), i;
|
|
119
76
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
77
|
+
function R(r) {
|
|
78
|
+
return r.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
122
79
|
}
|
|
123
|
-
function
|
|
124
|
-
return
|
|
80
|
+
function J(r) {
|
|
81
|
+
return r && r.sensitive ? "" : "i";
|
|
125
82
|
}
|
|
126
|
-
function
|
|
127
|
-
if (!
|
|
128
|
-
return
|
|
129
|
-
var
|
|
130
|
-
if (
|
|
131
|
-
for (var
|
|
132
|
-
|
|
133
|
-
name:
|
|
83
|
+
function lt(r, t) {
|
|
84
|
+
if (!t)
|
|
85
|
+
return r;
|
|
86
|
+
var e = r.source.match(/\((?!\?)/g);
|
|
87
|
+
if (e)
|
|
88
|
+
for (var n = 0; n < e.length; n++)
|
|
89
|
+
t.push({
|
|
90
|
+
name: n,
|
|
134
91
|
prefix: "",
|
|
135
92
|
delimiter: "",
|
|
136
|
-
optional:
|
|
137
|
-
repeat:
|
|
93
|
+
optional: !1,
|
|
94
|
+
repeat: !1,
|
|
138
95
|
pattern: ""
|
|
139
96
|
});
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
return path;
|
|
97
|
+
return r;
|
|
143
98
|
}
|
|
144
|
-
function
|
|
145
|
-
var
|
|
146
|
-
return
|
|
99
|
+
function ft(r, t, e) {
|
|
100
|
+
var n = r.map(function(i) {
|
|
101
|
+
return Z(i, t, e).source;
|
|
147
102
|
});
|
|
148
|
-
return new RegExp("(?:" +
|
|
103
|
+
return new RegExp("(?:" + n.join("|") + ")", J(e));
|
|
149
104
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
105
|
+
function pt(r, t, e) {
|
|
106
|
+
return dt(ht(r, e), t, e);
|
|
152
107
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (token.optional) {
|
|
171
|
-
if (!token.prefix) {
|
|
172
|
-
route += "(" + capture + ")?";
|
|
173
|
-
} else {
|
|
174
|
-
route += "(?:" + escapeString(token.prefix) + "(" + capture + "))?";
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
route += escapeString(token.prefix) + "(" + capture + ")";
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (end) {
|
|
182
|
-
if (!strict)
|
|
183
|
-
route += "(?:" + escapeString(delimiter) + ")?";
|
|
184
|
-
route += endsWith === "$" ? "$" : "(?=" + endsWith + ")";
|
|
185
|
-
} else {
|
|
186
|
-
var endToken = tokens[tokens.length - 1];
|
|
187
|
-
var isEndDelimited = typeof endToken === "string" ? endToken[endToken.length - 1] === delimiter : (
|
|
108
|
+
function dt(r, t, e) {
|
|
109
|
+
e === void 0 && (e = {});
|
|
110
|
+
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 ? z : u, h = e.encode, g = h === void 0 ? function(E) {
|
|
111
|
+
return E;
|
|
112
|
+
} : 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++) {
|
|
113
|
+
var p = w[d];
|
|
114
|
+
if (typeof p == "string")
|
|
115
|
+
f += R(g(p));
|
|
116
|
+
else {
|
|
117
|
+
var y = p.repeat ? "(?:" + p.pattern + ")(?:" + R(p.delimiter) + "(?:" + p.pattern + "))*" : p.pattern;
|
|
118
|
+
t && t.push(p), p.optional ? p.prefix ? f += "(?:" + R(p.prefix) + "(" + y + "))?" : f += "(" + y + ")?" : f += R(p.prefix) + "(" + y + ")";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (o)
|
|
122
|
+
n || (f += "(?:" + R(a) + ")?"), f += m === "$" ? "$" : "(?=" + m + ")";
|
|
123
|
+
else {
|
|
124
|
+
var l = r[r.length - 1], v = typeof l == "string" ? l[l.length - 1] === a : (
|
|
188
125
|
// tslint:disable-next-line
|
|
189
|
-
|
|
126
|
+
l === void 0
|
|
190
127
|
);
|
|
191
|
-
|
|
192
|
-
route += "(?:" + escapeString(delimiter) + "(?=" + endsWith + "))?";
|
|
193
|
-
}
|
|
194
|
-
if (!isEndDelimited) {
|
|
195
|
-
route += "(?=" + escapeString(delimiter) + "|" + endsWith + ")";
|
|
196
|
-
}
|
|
128
|
+
n || (f += "(?:" + R(a) + "(?=" + m + "))?"), v || (f += "(?=" + R(a) + "|" + m + ")");
|
|
197
129
|
}
|
|
198
|
-
return new RegExp(
|
|
130
|
+
return new RegExp(f, J(e));
|
|
199
131
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
return regexpToRegexp(path, keys2);
|
|
203
|
-
}
|
|
204
|
-
if (Array.isArray(path)) {
|
|
205
|
-
return arrayToRegexp(path, keys2, options);
|
|
206
|
-
}
|
|
207
|
-
return stringToRegexp(path, keys2, options);
|
|
132
|
+
function Z(r, t, e) {
|
|
133
|
+
return r instanceof RegExp ? lt(r, t) : Array.isArray(r) ? ft(r, t, e) : pt(r, t, e);
|
|
208
134
|
}
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
return
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const pick = (obj, attrs) => attrs.reduce((acc, attr) => obj[attr] === void 0 ? acc : assoc(acc, attr, obj[attr]), {});
|
|
217
|
-
const isEqual$1 = (obj1, obj2) => {
|
|
218
|
-
const keys1 = keys(obj1);
|
|
219
|
-
return keys1.length === keys(obj2).length && keys1.every((key) => obj2[key] === obj1[key]);
|
|
220
|
-
};
|
|
221
|
-
const extend = Object.assign;
|
|
222
|
-
function invariant(condition, format, ...args) {
|
|
223
|
-
if (!condition) {
|
|
224
|
-
let argIndex = 0;
|
|
135
|
+
const mt = (r, t, e) => (r[t] = e, r), gt = Array.isArray, O = Object.keys, L = (r) => r && (gt(r) ? r.slice(0) : C({}, r)), F = (r, t) => t.reduce((e, n) => r[n] === void 0 ? e : mt(e, n, r[n]), {}), H = (r, t) => {
|
|
136
|
+
const e = O(r);
|
|
137
|
+
return e.length === O(t).length && e.every((n) => t[n] === r[n]);
|
|
138
|
+
}, C = Object.assign;
|
|
139
|
+
function q(r, t, ...e) {
|
|
140
|
+
if (!r) {
|
|
141
|
+
let n = 0;
|
|
225
142
|
throw new Error(
|
|
226
|
-
"Invariant Violation: " +
|
|
143
|
+
"Invariant Violation: " + t.replace(/%s/g, () => e[n++])
|
|
227
144
|
);
|
|
228
145
|
}
|
|
229
146
|
}
|
|
230
|
-
function
|
|
231
|
-
let
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
options
|
|
244
|
-
}
|
|
245
|
-
if (typeof options.path !== "string") {
|
|
246
|
-
const parts = name.split(".");
|
|
247
|
-
options.path = parts[parts.length - 1];
|
|
248
|
-
}
|
|
249
|
-
if (childrenCallback) {
|
|
250
|
-
ancestors = ancestors.concat(name);
|
|
251
|
-
childrenCallback();
|
|
252
|
-
routes = pop();
|
|
253
|
-
ancestors.splice(-1);
|
|
254
|
-
}
|
|
255
|
-
push({
|
|
256
|
-
name,
|
|
257
|
-
path: options.path,
|
|
258
|
-
routes: routes || [],
|
|
259
|
-
options
|
|
147
|
+
function vt(r) {
|
|
148
|
+
let t = [];
|
|
149
|
+
const e = {}, n = {};
|
|
150
|
+
r(function(u, a, h) {
|
|
151
|
+
let g;
|
|
152
|
+
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") {
|
|
153
|
+
const m = u.split(".");
|
|
154
|
+
a.path = m[m.length - 1];
|
|
155
|
+
}
|
|
156
|
+
h && (t = t.concat(u), h(), g = i(), t.splice(-1)), s({
|
|
157
|
+
name: u,
|
|
158
|
+
path: a.path,
|
|
159
|
+
routes: g || [],
|
|
160
|
+
options: a
|
|
260
161
|
});
|
|
261
162
|
});
|
|
262
|
-
function
|
|
263
|
-
return
|
|
163
|
+
function i() {
|
|
164
|
+
return e[c()] || [];
|
|
264
165
|
}
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
matches[level].push(route);
|
|
166
|
+
function s(o) {
|
|
167
|
+
const u = c();
|
|
168
|
+
e[u] = e[u] || [], e[u].push(o);
|
|
269
169
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
170
|
+
function c() {
|
|
171
|
+
return t.join(".");
|
|
272
172
|
}
|
|
273
|
-
return
|
|
173
|
+
return i();
|
|
274
174
|
}
|
|
275
|
-
function
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
if (typeof
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
175
|
+
function G(r) {
|
|
176
|
+
const t = [];
|
|
177
|
+
return r.forEach(({ name: e, children: n, ...i }) => {
|
|
178
|
+
if (typeof i.path != "string") {
|
|
179
|
+
const s = e.split(".");
|
|
180
|
+
i.path = s[s.length - 1];
|
|
181
|
+
}
|
|
182
|
+
t.push(
|
|
283
183
|
{
|
|
284
|
-
name,
|
|
285
|
-
path:
|
|
286
|
-
options,
|
|
287
|
-
routes:
|
|
184
|
+
name: e,
|
|
185
|
+
path: i.path,
|
|
186
|
+
options: i,
|
|
187
|
+
routes: n ? G(n) : []
|
|
288
188
|
}
|
|
289
189
|
);
|
|
290
|
-
});
|
|
291
|
-
return result;
|
|
190
|
+
}), t;
|
|
292
191
|
}
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const re = pathToRegexp(pattern, paramNames);
|
|
301
|
-
_compiledPatterns[pattern] = {
|
|
302
|
-
matcher: re,
|
|
303
|
-
paramNames: paramNames.map((p) => p.name)
|
|
192
|
+
const wt = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g, yt = /[+*?]$/g, X = /\?(.+)/, D = {};
|
|
193
|
+
function Y(r) {
|
|
194
|
+
if (!(r in D)) {
|
|
195
|
+
const t = [], e = Z(r, t);
|
|
196
|
+
D[r] = {
|
|
197
|
+
matcher: e,
|
|
198
|
+
paramNames: t.map((n) => n.name)
|
|
304
199
|
};
|
|
305
200
|
}
|
|
306
|
-
return
|
|
201
|
+
return D[r];
|
|
307
202
|
}
|
|
308
|
-
function
|
|
309
|
-
return
|
|
203
|
+
function Et(r) {
|
|
204
|
+
return Y(r).paramNames;
|
|
310
205
|
}
|
|
311
|
-
function
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
const paramNames = cp.paramNames;
|
|
315
|
-
const match = path.match(matcher);
|
|
316
|
-
if (!match) {
|
|
206
|
+
function bt(r, t) {
|
|
207
|
+
const e = Y(r), n = e.matcher, i = e.paramNames, s = t.match(n);
|
|
208
|
+
if (!s)
|
|
317
209
|
return null;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
});
|
|
323
|
-
return params;
|
|
210
|
+
const c = {};
|
|
211
|
+
return i.forEach(function(o, u) {
|
|
212
|
+
c[o] = s[u + 1] && decodeURIComponent(s[u + 1]);
|
|
213
|
+
}), c;
|
|
324
214
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (lastChar === "?" || lastChar === "*") {
|
|
331
|
-
if (params[paramName] == null) {
|
|
215
|
+
function Rt(r, t) {
|
|
216
|
+
return t = t || {}, r.replace(wt, function(e, n) {
|
|
217
|
+
const i = n.replace(yt, ""), s = n.slice(-1);
|
|
218
|
+
if (s === "?" || s === "*") {
|
|
219
|
+
if (t[i] == null)
|
|
332
220
|
return "";
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
params[paramName] != null,
|
|
221
|
+
} else
|
|
222
|
+
q(
|
|
223
|
+
t[i] != null,
|
|
337
224
|
"Missing '%s' parameter for path '%s'",
|
|
338
|
-
|
|
339
|
-
|
|
225
|
+
i,
|
|
226
|
+
r
|
|
340
227
|
);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (lastChar === "*" || lastChar === "+") {
|
|
344
|
-
paramValue = paramValue.replaceAll("%2F", "/");
|
|
345
|
-
}
|
|
346
|
-
return paramValue;
|
|
228
|
+
let c = encodeURIComponent(t[i]);
|
|
229
|
+
return (s === "*" || s === "+") && (c = c.replaceAll("%2F", "/")), c;
|
|
347
230
|
});
|
|
348
231
|
}
|
|
349
|
-
function
|
|
350
|
-
const
|
|
351
|
-
return
|
|
232
|
+
function Tt(r, t) {
|
|
233
|
+
const e = t.match(X);
|
|
234
|
+
return e && r.parse(e[1]);
|
|
352
235
|
}
|
|
353
|
-
function
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
return withoutQuery(path) + "?" + queryString;
|
|
357
|
-
}
|
|
358
|
-
return path;
|
|
236
|
+
function Lt(r, t, e) {
|
|
237
|
+
const n = r.stringify(e, { indices: !1 });
|
|
238
|
+
return n ? tt(t) + "?" + n : t;
|
|
359
239
|
}
|
|
360
|
-
function
|
|
361
|
-
return
|
|
240
|
+
function tt(r) {
|
|
241
|
+
return r.replace(X, "");
|
|
362
242
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
365
|
-
return fn;
|
|
243
|
+
function et(r, t, e) {
|
|
244
|
+
return r.addEventListener(t, e), e;
|
|
366
245
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
369
|
-
return fn;
|
|
246
|
+
function rt(r, t, e) {
|
|
247
|
+
return r.removeEventListener(t, e), e;
|
|
370
248
|
}
|
|
371
|
-
class
|
|
249
|
+
class Ct {
|
|
372
250
|
constructor() {
|
|
373
|
-
this.handlers = [];
|
|
374
|
-
this.checkUrl = this.checkUrl.bind(this);
|
|
375
|
-
this.location = window.location;
|
|
376
|
-
this.history = window.history;
|
|
251
|
+
this.handlers = [], this.checkUrl = this.checkUrl.bind(this), this.location = window.location, this.history = window.history;
|
|
377
252
|
}
|
|
378
253
|
// Set up all inheritable **Backbone.History** properties and methods.
|
|
379
254
|
// Are we at the app root?
|
|
@@ -383,49 +258,32 @@ class History {
|
|
|
383
258
|
// Gets the true hash value. Cannot use location.hash directly due to bug
|
|
384
259
|
// in Firefox where location.hash will always be decoded.
|
|
385
260
|
getHash() {
|
|
386
|
-
const
|
|
387
|
-
return
|
|
261
|
+
const t = this.location.href.match(/#(.*)$/);
|
|
262
|
+
return t ? t[1] : "";
|
|
388
263
|
}
|
|
389
264
|
// Get the cross-browser normalized URL fragment, either from the URL,
|
|
390
265
|
// the hash, or the override.
|
|
391
|
-
getFragment(
|
|
392
|
-
if (
|
|
393
|
-
if (this._hasPushState || !this._wantsHashChange ||
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return fragment.replace(routeStripper, "");
|
|
266
|
+
getFragment(t, e) {
|
|
267
|
+
if (t == null)
|
|
268
|
+
if (this._hasPushState || !this._wantsHashChange || e) {
|
|
269
|
+
t = decodeURI(this.location.pathname + this.location.search);
|
|
270
|
+
const n = this.root.replace(St, "");
|
|
271
|
+
t.indexOf(n) || (t = t.slice(n.length));
|
|
272
|
+
} else
|
|
273
|
+
t = this.getHash();
|
|
274
|
+
return t.replace(B, "");
|
|
403
275
|
}
|
|
404
276
|
// Start the hash change handling, returning `true` if the current URL matches
|
|
405
277
|
// an existing route, and `false` otherwise.
|
|
406
|
-
start(
|
|
407
|
-
this.started =
|
|
408
|
-
|
|
409
|
-
this.
|
|
410
|
-
|
|
411
|
-
this.root = this.options.root;
|
|
412
|
-
this._wantsHashChange = this.options.hashChange !== false;
|
|
413
|
-
this._wantsPushState = !!this.options.pushState;
|
|
414
|
-
this._hasPushState = this._wantsPushState;
|
|
415
|
-
const fragment = this.getFragment();
|
|
416
|
-
this.root = `/${this.root}/`.replace(rootStripper, "/");
|
|
417
|
-
bindEvent(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl);
|
|
418
|
-
this.fragment = fragment;
|
|
419
|
-
const loc = this.location;
|
|
278
|
+
start(t = {}) {
|
|
279
|
+
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;
|
|
280
|
+
const e = this.getFragment();
|
|
281
|
+
this.root = `/${this.root}/`.replace($t, "/"), et(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.fragment = e;
|
|
282
|
+
const n = this.location;
|
|
420
283
|
if (this._wantsHashChange && this._wantsPushState) {
|
|
421
|
-
if (!this._hasPushState && !this.atRoot())
|
|
422
|
-
this.fragment = this.getFragment(null,
|
|
423
|
-
|
|
424
|
-
return true;
|
|
425
|
-
} else if (this._hasPushState && this.atRoot() && loc.hash) {
|
|
426
|
-
this.fragment = this.getHash().replace(routeStripper, "");
|
|
427
|
-
this.history.replaceState({}, document.title, this.root + this.fragment);
|
|
428
|
-
}
|
|
284
|
+
if (!this._hasPushState && !this.atRoot())
|
|
285
|
+
return this.fragment = this.getFragment(null, !0), this.location.replace(`${this.root}#${this.fragment}`), !0;
|
|
286
|
+
this._hasPushState && this.atRoot() && n.hash && (this.fragment = this.getHash().replace(B, ""), this.history.replaceState({}, document.title, this.root + this.fragment));
|
|
429
287
|
}
|
|
430
288
|
if (!this.options.silent)
|
|
431
289
|
return this.loadUrl();
|
|
@@ -433,32 +291,27 @@ class History {
|
|
|
433
291
|
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
|
434
292
|
// but possibly useful for unit testing Routers.
|
|
435
293
|
stop() {
|
|
436
|
-
|
|
437
|
-
this.started = false;
|
|
294
|
+
rt(window, this._hasPushState ? "popstate" : "hashchange", this.checkUrl), this.started = !1;
|
|
438
295
|
}
|
|
439
296
|
// Add a route to be tested when the fragment changes. Routes added later
|
|
440
297
|
// may override previous routes.
|
|
441
|
-
route(
|
|
442
|
-
this.handlers.unshift({ route, callback });
|
|
298
|
+
route(t, e) {
|
|
299
|
+
this.handlers.unshift({ route: t, callback: e });
|
|
443
300
|
}
|
|
444
301
|
// Checks the current URL to see if it has changed, and if it has,
|
|
445
302
|
// calls `loadUrl`.
|
|
446
303
|
checkUrl() {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
return false;
|
|
304
|
+
if (this.getFragment() === this.fragment)
|
|
305
|
+
return !1;
|
|
450
306
|
this.loadUrl();
|
|
451
307
|
}
|
|
452
308
|
// Attempt to load the current URL fragment. If a route succeeds with a
|
|
453
309
|
// match, returns `true`. If no defined routes matches the fragment,
|
|
454
310
|
// returns `false`.
|
|
455
|
-
loadUrl(
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
handler.callback(fragment);
|
|
460
|
-
return true;
|
|
461
|
-
}
|
|
311
|
+
loadUrl(t) {
|
|
312
|
+
return t = this.fragment = this.getFragment(t), this.handlers.some((e) => {
|
|
313
|
+
if (e.route.test(t))
|
|
314
|
+
return e.callback(t), !0;
|
|
462
315
|
});
|
|
463
316
|
}
|
|
464
317
|
// Save a fragment into the hash history, or replace the URL state if the
|
|
@@ -468,67 +321,52 @@ class History {
|
|
|
468
321
|
// The options object can contain `trigger: true` if you wish to have the
|
|
469
322
|
// route callback be fired (not usually desirable), or `replace: true`, if
|
|
470
323
|
// you wish to modify the current URL without adding an entry to the history.
|
|
471
|
-
update(
|
|
324
|
+
update(t, e) {
|
|
472
325
|
if (!this.started)
|
|
473
|
-
return
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
} else if (this._wantsHashChange) {
|
|
486
|
-
this._updateHash(this.location, fragment, options.replace);
|
|
487
|
-
} else {
|
|
488
|
-
return this.location.assign(url);
|
|
326
|
+
return !1;
|
|
327
|
+
(!e || e === !0) && (e = { trigger: !!e });
|
|
328
|
+
let n = this.root + (t = this.getFragment(t || ""));
|
|
329
|
+
if (t = t.replace(Ut, ""), this.fragment !== t) {
|
|
330
|
+
if (this.fragment = t, t === "" && n !== "/" && (n = n.slice(0, -1)), this._hasPushState)
|
|
331
|
+
this.history[e.replace ? "replaceState" : "pushState"]({}, document.title, n);
|
|
332
|
+
else if (this._wantsHashChange)
|
|
333
|
+
this._updateHash(this.location, t, e.replace);
|
|
334
|
+
else
|
|
335
|
+
return this.location.assign(n);
|
|
336
|
+
if (e.trigger)
|
|
337
|
+
return this.loadUrl(t);
|
|
489
338
|
}
|
|
490
|
-
if (options.trigger)
|
|
491
|
-
return this.loadUrl(fragment);
|
|
492
339
|
}
|
|
493
340
|
// Update the hash location, either replacing the current entry, or adding
|
|
494
341
|
// a new one to the browser history.
|
|
495
|
-
_updateHash(
|
|
496
|
-
if (
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
} else
|
|
500
|
-
|
|
501
|
-
}
|
|
342
|
+
_updateHash(t, e, n) {
|
|
343
|
+
if (n) {
|
|
344
|
+
const i = t.href.replace(/(javascript:|#).*$/, "");
|
|
345
|
+
t.replace(`${i}#${e}`);
|
|
346
|
+
} else
|
|
347
|
+
t.hash = `#${e}`;
|
|
502
348
|
}
|
|
503
349
|
// add some features to History
|
|
504
350
|
// a generic callback for any changes
|
|
505
|
-
onChange(
|
|
506
|
-
this.route(/^(.*?)$/,
|
|
351
|
+
onChange(t) {
|
|
352
|
+
this.route(/^(.*?)$/, t);
|
|
507
353
|
}
|
|
508
354
|
// checks if the browser has pushstate support
|
|
509
355
|
hasPushState() {
|
|
510
|
-
if (!this.started)
|
|
356
|
+
if (!this.started)
|
|
511
357
|
throw new Error("only available after LocationBar.start()");
|
|
512
|
-
}
|
|
513
358
|
return this._hasPushState;
|
|
514
359
|
}
|
|
515
360
|
}
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
constructor(options = {}) {
|
|
522
|
-
this.path = options.path || "";
|
|
523
|
-
this.options = extend({
|
|
524
|
-
pushState: false,
|
|
361
|
+
const B = /^[#\/]|\s+$/g, $t = /^\/+|\/+$/g, St = /\/$/, Ut = /#.*$/;
|
|
362
|
+
class xt {
|
|
363
|
+
constructor(t = {}) {
|
|
364
|
+
this.path = t.path || "", this.options = C({
|
|
365
|
+
pushState: !1,
|
|
525
366
|
root: "/"
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
this.locationBar.
|
|
529
|
-
this.handleURL(`/${path || ""}`);
|
|
530
|
-
});
|
|
531
|
-
this.locationBar.start(options);
|
|
367
|
+
}, t), this.locationBar = new Ct(), this.locationBar.onChange((e) => {
|
|
368
|
+
this.handleURL(`/${e || ""}`);
|
|
369
|
+
}), this.locationBar.start(t);
|
|
532
370
|
}
|
|
533
371
|
/**
|
|
534
372
|
* Get the current URL
|
|
@@ -540,46 +378,33 @@ class BrowserLocation {
|
|
|
540
378
|
* Set the current URL without triggering any events
|
|
541
379
|
* back to the router. Add a new entry in browser's history.
|
|
542
380
|
*/
|
|
543
|
-
setURL(
|
|
544
|
-
|
|
545
|
-
this.path = path;
|
|
546
|
-
this.locationBar.update(path, extend({ trigger: true }, options));
|
|
547
|
-
}
|
|
381
|
+
setURL(t, e = {}) {
|
|
382
|
+
this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0 }, e)));
|
|
548
383
|
}
|
|
549
384
|
/**
|
|
550
385
|
* Set the current URL without triggering any events
|
|
551
386
|
* back to the router. Replace the latest entry in broser's history.
|
|
552
387
|
*/
|
|
553
|
-
replaceURL(
|
|
554
|
-
|
|
555
|
-
this.path = path;
|
|
556
|
-
this.locationBar.update(path, extend({ trigger: true, replace: true }, options));
|
|
557
|
-
}
|
|
388
|
+
replaceURL(t, e = {}) {
|
|
389
|
+
this.path !== t && (this.path = t, this.locationBar.update(t, C({ trigger: !0, replace: !0 }, e)));
|
|
558
390
|
}
|
|
559
391
|
/**
|
|
560
392
|
* Setup a URL change handler
|
|
561
393
|
* @param {Function} callback
|
|
562
394
|
*/
|
|
563
|
-
onChange(
|
|
564
|
-
this.changeCallback =
|
|
395
|
+
onChange(t) {
|
|
396
|
+
this.changeCallback = t;
|
|
565
397
|
}
|
|
566
398
|
/**
|
|
567
399
|
* Given a path, generate a URL appending root
|
|
568
400
|
* if pushState is used and # if hash state is used
|
|
569
401
|
*/
|
|
570
|
-
formatURL(
|
|
402
|
+
formatURL(t) {
|
|
571
403
|
if (this.locationBar.hasPushState()) {
|
|
572
|
-
let
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
return rootURL + path;
|
|
577
|
-
} else {
|
|
578
|
-
if (path[0] === "/") {
|
|
579
|
-
path = path.substr(1);
|
|
580
|
-
}
|
|
581
|
-
return `#${path}`;
|
|
582
|
-
}
|
|
404
|
+
let e = this.options.root;
|
|
405
|
+
return t !== "" && (e = e.replace(/\/$/, "")), e + t;
|
|
406
|
+
} else
|
|
407
|
+
return t[0] === "/" && (t = t.substr(1)), `#${t}`;
|
|
583
408
|
}
|
|
584
409
|
/**
|
|
585
410
|
* When we use pushState with a custom root option,
|
|
@@ -589,12 +414,8 @@ class BrowserLocation {
|
|
|
589
414
|
* - LocationBar expects all .update() calls to be called without root
|
|
590
415
|
* - this method is public so that we could dispatch URLs without root in router
|
|
591
416
|
*/
|
|
592
|
-
removeRoot(
|
|
593
|
-
|
|
594
|
-
return url.replace(this.options.root, "");
|
|
595
|
-
} else {
|
|
596
|
-
return url;
|
|
597
|
-
}
|
|
417
|
+
removeRoot(t) {
|
|
418
|
+
return this.options.pushState && this.options.root && this.options.root !== "/" ? t.replace(this.options.root, "") : t;
|
|
598
419
|
}
|
|
599
420
|
/**
|
|
600
421
|
* Stop listening to URL changes and link clicks
|
|
@@ -611,298 +432,182 @@ class BrowserLocation {
|
|
|
611
432
|
|
|
612
433
|
@private
|
|
613
434
|
*/
|
|
614
|
-
handleURL(
|
|
615
|
-
this.path =
|
|
616
|
-
if (this.changeCallback) {
|
|
617
|
-
this.changeCallback(url);
|
|
618
|
-
}
|
|
435
|
+
handleURL(t) {
|
|
436
|
+
this.path = t, this.changeCallback && this.changeCallback(t);
|
|
619
437
|
}
|
|
620
438
|
}
|
|
621
|
-
class
|
|
622
|
-
constructor({ path }) {
|
|
623
|
-
this.path =
|
|
439
|
+
class Pt {
|
|
440
|
+
constructor({ path: t }) {
|
|
441
|
+
this.path = t || "";
|
|
624
442
|
}
|
|
625
443
|
getURL() {
|
|
626
444
|
return this.path;
|
|
627
445
|
}
|
|
628
|
-
setURL(
|
|
629
|
-
|
|
630
|
-
this.path = path;
|
|
631
|
-
this.handleURL(this.getURL(), options);
|
|
632
|
-
}
|
|
446
|
+
setURL(t, e) {
|
|
447
|
+
this.path !== t && (this.path = t, this.handleURL(this.getURL(), e));
|
|
633
448
|
}
|
|
634
|
-
replaceURL(
|
|
635
|
-
|
|
636
|
-
this.setURL(path, options);
|
|
637
|
-
}
|
|
449
|
+
replaceURL(t, e) {
|
|
450
|
+
this.path !== t && this.setURL(t, e);
|
|
638
451
|
}
|
|
639
|
-
onChange(
|
|
640
|
-
this.changeCallback =
|
|
452
|
+
onChange(t) {
|
|
453
|
+
this.changeCallback = t;
|
|
641
454
|
}
|
|
642
|
-
handleURL(
|
|
643
|
-
this.path =
|
|
644
|
-
options = extend({ trigger: true }, options);
|
|
645
|
-
if (this.changeCallback && options.trigger) {
|
|
646
|
-
this.changeCallback(url);
|
|
647
|
-
}
|
|
455
|
+
handleURL(t, e = {}) {
|
|
456
|
+
this.path = t, e = C({ trigger: !0 }, e), this.changeCallback && e.trigger && this.changeCallback(t);
|
|
648
457
|
}
|
|
649
|
-
removeRoot(
|
|
650
|
-
return
|
|
458
|
+
removeRoot(t) {
|
|
459
|
+
return t;
|
|
651
460
|
}
|
|
652
|
-
formatURL(
|
|
653
|
-
return
|
|
461
|
+
formatURL(t) {
|
|
462
|
+
return t;
|
|
654
463
|
}
|
|
655
464
|
}
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
m.error && m.error(transition2, err);
|
|
465
|
+
const N = "TransitionRedirected", P = "TransitionCancelled";
|
|
466
|
+
function W(r, t, e) {
|
|
467
|
+
r.middleware.forEach((n) => {
|
|
468
|
+
n.error && n.error(t, e);
|
|
661
469
|
});
|
|
662
470
|
}
|
|
663
|
-
function
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
const routes = match.routes;
|
|
671
|
-
const params = match.params;
|
|
672
|
-
const pathname = match.pathname;
|
|
673
|
-
const query = match.query;
|
|
674
|
-
const id = options.id;
|
|
675
|
-
const startTime = Date.now();
|
|
676
|
-
log("---");
|
|
677
|
-
log("Transition #" + id, "to", path);
|
|
678
|
-
log("Transition #" + id, "routes:", routes.map((r) => r.name));
|
|
679
|
-
log("Transition #" + id, "params:", params);
|
|
680
|
-
log("Transition #" + id, "query:", query);
|
|
681
|
-
let resolve2, reject;
|
|
682
|
-
const promise = new Promise(function(res, rej) {
|
|
683
|
-
resolve2 = res;
|
|
684
|
-
reject = rej;
|
|
471
|
+
function k(r) {
|
|
472
|
+
r = r || {};
|
|
473
|
+
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();
|
|
474
|
+
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);
|
|
475
|
+
let m, f;
|
|
476
|
+
const d = new Promise(function(l, v) {
|
|
477
|
+
m = l, f = v;
|
|
685
478
|
});
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}).catch(function(
|
|
689
|
-
|
|
690
|
-
log("Transition #" + id, "FAILED");
|
|
691
|
-
logError(err);
|
|
692
|
-
}
|
|
479
|
+
d.then(function() {
|
|
480
|
+
e("Transition #" + h, "completed in", Date.now() - g + "ms");
|
|
481
|
+
}).catch(function(l) {
|
|
482
|
+
l.type !== N && l.type !== P && (e("Transition #" + h, "FAILED"), n(l));
|
|
693
483
|
});
|
|
694
|
-
let
|
|
695
|
-
const
|
|
696
|
-
id,
|
|
484
|
+
let w = !1;
|
|
485
|
+
const p = {
|
|
486
|
+
id: h,
|
|
697
487
|
prev: {
|
|
698
|
-
routes:
|
|
699
|
-
path:
|
|
700
|
-
pathname:
|
|
701
|
-
params:
|
|
702
|
-
query:
|
|
488
|
+
routes: L(t.state.routes) || [],
|
|
489
|
+
path: t.state.path || "",
|
|
490
|
+
pathname: t.state.pathname || "",
|
|
491
|
+
params: L(t.state.params) || {},
|
|
492
|
+
query: L(t.state.query) || {}
|
|
703
493
|
},
|
|
704
|
-
routes:
|
|
705
|
-
path,
|
|
706
|
-
pathname,
|
|
707
|
-
params:
|
|
708
|
-
query:
|
|
709
|
-
redirectTo: function(...
|
|
710
|
-
return
|
|
494
|
+
routes: L(c),
|
|
495
|
+
path: i,
|
|
496
|
+
pathname: u,
|
|
497
|
+
params: L(o),
|
|
498
|
+
query: L(a),
|
|
499
|
+
redirectTo: function(...l) {
|
|
500
|
+
return t.transitionTo(...l);
|
|
711
501
|
},
|
|
712
502
|
retry: function() {
|
|
713
|
-
return
|
|
503
|
+
return t.transitionTo(i);
|
|
714
504
|
},
|
|
715
|
-
cancel: function(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
if (transition2.isCancelled) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
router2.state.activeTransition = null;
|
|
723
|
-
transition2.isCancelled = true;
|
|
724
|
-
cancelled = true;
|
|
725
|
-
if (!err) {
|
|
726
|
-
err = new Error(TRANSITION_CANCELLED);
|
|
727
|
-
err.type = TRANSITION_CANCELLED;
|
|
728
|
-
}
|
|
729
|
-
if (err.type === TRANSITION_CANCELLED) {
|
|
730
|
-
log("Transition #" + id, "cancelled");
|
|
731
|
-
}
|
|
732
|
-
if (err.type === TRANSITION_REDIRECTED) {
|
|
733
|
-
log("Transition #" + id, "redirected");
|
|
734
|
-
}
|
|
735
|
-
router2.middleware.forEach((m) => {
|
|
736
|
-
m.cancel && m.cancel(transition2, err);
|
|
737
|
-
});
|
|
738
|
-
reject(err);
|
|
505
|
+
cancel: function(l) {
|
|
506
|
+
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 === N && e("Transition #" + h, "redirected"), t.middleware.forEach((v) => {
|
|
507
|
+
v.cancel && v.cancel(p, l);
|
|
508
|
+
}), f(l)));
|
|
739
509
|
},
|
|
740
510
|
followRedirects: function() {
|
|
741
|
-
return
|
|
742
|
-
|
|
743
|
-
return router2.state.activeTransition.followRedirects();
|
|
744
|
-
}
|
|
745
|
-
return Promise.reject(reason);
|
|
511
|
+
return d.catch(function(l) {
|
|
512
|
+
return t.state.activeTransition ? t.state.activeTransition.followRedirects() : Promise.reject(l);
|
|
746
513
|
});
|
|
747
514
|
},
|
|
748
|
-
then:
|
|
749
|
-
catch:
|
|
515
|
+
then: d.then.bind(d),
|
|
516
|
+
catch: d.catch.bind(d)
|
|
750
517
|
};
|
|
751
|
-
|
|
752
|
-
|
|
518
|
+
t.middleware.forEach((l) => {
|
|
519
|
+
l.before && l.before(p);
|
|
753
520
|
});
|
|
754
|
-
function
|
|
755
|
-
let
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
activeTransition: null,
|
|
784
|
-
routes,
|
|
785
|
-
path,
|
|
786
|
-
pathname,
|
|
787
|
-
params,
|
|
788
|
-
query
|
|
789
|
-
};
|
|
790
|
-
router2.middleware.forEach((m) => {
|
|
791
|
-
m.done && m.done(transition2);
|
|
792
|
-
});
|
|
793
|
-
resolve2();
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (!options.noop) {
|
|
797
|
-
Promise.resolve().then(() => callNext(0));
|
|
798
|
-
} else {
|
|
799
|
-
resolve2();
|
|
800
|
-
}
|
|
801
|
-
if (options.noop) {
|
|
802
|
-
transition2.noop = true;
|
|
803
|
-
}
|
|
804
|
-
return transition2;
|
|
521
|
+
function y(l, v) {
|
|
522
|
+
let E, b;
|
|
523
|
+
if (!w)
|
|
524
|
+
if (l < t.middleware.length) {
|
|
525
|
+
E = t.middleware[l], b = E.name || "anonymous", e("Transition #" + h, "resolving middleware:", b);
|
|
526
|
+
let S;
|
|
527
|
+
try {
|
|
528
|
+
S = E.resolve ? E.resolve(p, v) : v, q(p !== S, "Middleware %s returned a transition which resulted in a deadlock", b);
|
|
529
|
+
} catch (T) {
|
|
530
|
+
return t.state.activeTransition = null, W(t, p, T), f(T);
|
|
531
|
+
}
|
|
532
|
+
Promise.resolve(S).then(function(T) {
|
|
533
|
+
y(l + 1, T);
|
|
534
|
+
}).catch(function(T) {
|
|
535
|
+
e("Transition #" + h, "resolving middleware:", b, "FAILED"), t.state.activeTransition = null, W(t, p, T), f(T);
|
|
536
|
+
});
|
|
537
|
+
} else
|
|
538
|
+
t.state = {
|
|
539
|
+
activeTransition: null,
|
|
540
|
+
routes: c,
|
|
541
|
+
path: i,
|
|
542
|
+
pathname: u,
|
|
543
|
+
params: o,
|
|
544
|
+
query: a
|
|
545
|
+
}, t.middleware.forEach((S) => {
|
|
546
|
+
S.done && S.done(p);
|
|
547
|
+
}), m();
|
|
548
|
+
}
|
|
549
|
+
return r.noop ? m() : Promise.resolve().then(() => y(0)), r.noop && (p.noop = !0), p;
|
|
805
550
|
}
|
|
806
|
-
function
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
fn(e, el2);
|
|
551
|
+
function _t(r, t) {
|
|
552
|
+
const e = Ot(r, "click", function(n, i) {
|
|
553
|
+
It(n, i) && t(n, i);
|
|
810
554
|
});
|
|
811
|
-
return function
|
|
812
|
-
|
|
555
|
+
return function() {
|
|
556
|
+
Nt(r, "click", e);
|
|
813
557
|
};
|
|
814
558
|
}
|
|
815
|
-
function
|
|
816
|
-
var
|
|
817
|
-
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
if (((
|
|
821
|
-
return
|
|
822
|
-
|
|
823
|
-
if (element === root) {
|
|
559
|
+
function At(r) {
|
|
560
|
+
var e;
|
|
561
|
+
r = { parentNode: r };
|
|
562
|
+
const t = document;
|
|
563
|
+
for (; (r = r.parentNode) && r !== document; ) {
|
|
564
|
+
if (((e = r.tagName) == null ? void 0 : e.toLowerCase()) === "a")
|
|
565
|
+
return r;
|
|
566
|
+
if (r === t)
|
|
824
567
|
return;
|
|
825
|
-
}
|
|
826
568
|
}
|
|
827
569
|
}
|
|
828
|
-
function
|
|
829
|
-
return
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
if (el2) {
|
|
833
|
-
fn(e, el2);
|
|
834
|
-
}
|
|
570
|
+
function Ot(r, t, e) {
|
|
571
|
+
return et(r, t, function(n) {
|
|
572
|
+
const i = n.target || n.srcElement, s = At(i);
|
|
573
|
+
s && e(n, s);
|
|
835
574
|
});
|
|
836
575
|
}
|
|
837
|
-
function
|
|
838
|
-
|
|
576
|
+
function Nt(r, t, e) {
|
|
577
|
+
rt(r, t, e);
|
|
839
578
|
}
|
|
840
|
-
function
|
|
841
|
-
if (
|
|
579
|
+
function It(r, t) {
|
|
580
|
+
if (qt(r) !== 1 || r.metaKey || r.ctrlKey || r.shiftKey || r.defaultPrevented || t.target || t.getAttribute("data-bypass") !== null)
|
|
842
581
|
return;
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
return;
|
|
847
|
-
if (el.target)
|
|
848
|
-
return;
|
|
849
|
-
if (el.getAttribute("data-bypass") !== null)
|
|
850
|
-
return;
|
|
851
|
-
const href = el.getAttribute("href");
|
|
852
|
-
if (!href || href.length === 0)
|
|
853
|
-
return;
|
|
854
|
-
if (href[0] === "#")
|
|
855
|
-
return;
|
|
856
|
-
if (href.indexOf("http://") === 0 || href.indexOf("https://") === 0)
|
|
857
|
-
return;
|
|
858
|
-
if (href.indexOf("mailto:") === 0)
|
|
859
|
-
return;
|
|
860
|
-
if (href.indexOf("javascript:") === 0)
|
|
861
|
-
return;
|
|
862
|
-
return true;
|
|
582
|
+
const e = t.getAttribute("href");
|
|
583
|
+
if (!(!e || e.length === 0) && e[0] !== "#" && !(e.indexOf("http://") === 0 || e.indexOf("https://") === 0) && e.indexOf("mailto:") !== 0 && e.indexOf("javascript:") !== 0)
|
|
584
|
+
return !0;
|
|
863
585
|
}
|
|
864
|
-
function
|
|
865
|
-
|
|
866
|
-
return e.which === null ? e.button : e.which;
|
|
586
|
+
function qt(r) {
|
|
587
|
+
return r = r || window.event, r.which === null ? r.button : r.which;
|
|
867
588
|
}
|
|
868
|
-
function
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
router2[method] = typeof fn === "function" ? fn : () => {
|
|
872
|
-
};
|
|
589
|
+
function Q(r, t, e) {
|
|
590
|
+
e !== !0 && (r[t] = typeof e == "function" ? e : () => {
|
|
591
|
+
});
|
|
873
592
|
}
|
|
874
|
-
var
|
|
875
|
-
parse(
|
|
876
|
-
return
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
return acc;
|
|
593
|
+
var Dt = {
|
|
594
|
+
parse(r) {
|
|
595
|
+
return r.split("&").reduce((t, e) => {
|
|
596
|
+
const n = e.split("=");
|
|
597
|
+
return t[n[0]] = decodeURIComponent(n[1]), t;
|
|
880
598
|
}, {});
|
|
881
599
|
},
|
|
882
|
-
stringify(
|
|
883
|
-
return Object.keys(
|
|
884
|
-
if (params[key] !== void 0) {
|
|
885
|
-
acc.push(key + "=" + encodeURIComponent(params[key]));
|
|
886
|
-
}
|
|
887
|
-
return acc;
|
|
888
|
-
}, []).join("&");
|
|
600
|
+
stringify(r) {
|
|
601
|
+
return Object.keys(r).reduce((t, e) => (r[e] !== void 0 && t.push(e + "=" + encodeURIComponent(r[e])), t), []).join("&");
|
|
889
602
|
}
|
|
890
603
|
};
|
|
891
|
-
class
|
|
892
|
-
constructor(
|
|
893
|
-
this.nextId = 1
|
|
894
|
-
this.state = {};
|
|
895
|
-
this.middleware = [];
|
|
896
|
-
this.options = extend({
|
|
604
|
+
class Mt {
|
|
605
|
+
constructor(t = {}) {
|
|
606
|
+
this.nextId = 1, this.state = {}, this.middleware = [], this.options = C({
|
|
897
607
|
location: "browser",
|
|
898
|
-
logError:
|
|
899
|
-
qs
|
|
900
|
-
}, options);
|
|
901
|
-
defineLogger(this, "log", this.options.log);
|
|
902
|
-
defineLogger(this, "logError", this.options.logError);
|
|
903
|
-
if (options.routes) {
|
|
904
|
-
this.map(options.routes);
|
|
905
|
-
}
|
|
608
|
+
logError: !0,
|
|
609
|
+
qs: Dt
|
|
610
|
+
}, t), Q(this, "log", this.options.log), Q(this, "logError", this.options.logError), t.routes && this.map(t.routes);
|
|
906
611
|
}
|
|
907
612
|
/**
|
|
908
613
|
* Add a middleware
|
|
@@ -910,11 +615,9 @@ class Router {
|
|
|
910
615
|
* @return {Object} router
|
|
911
616
|
* @api public
|
|
912
617
|
*/
|
|
913
|
-
use(
|
|
914
|
-
const
|
|
915
|
-
typeof
|
|
916
|
-
m.create && m.create(this);
|
|
917
|
-
return this;
|
|
618
|
+
use(t, e = {}) {
|
|
619
|
+
const n = typeof t == "function" ? { resolve: t } : t;
|
|
620
|
+
return typeof e.at == "number" ? this.middleware.splice(e.at, 0, n) : this.middleware.push(n), n.create && n.create(this), this;
|
|
918
621
|
}
|
|
919
622
|
/**
|
|
920
623
|
* Add the route map
|
|
@@ -922,59 +625,43 @@ class Router {
|
|
|
922
625
|
* @return {Object} router
|
|
923
626
|
* @api public
|
|
924
627
|
*/
|
|
925
|
-
map(
|
|
926
|
-
this.routes = Array.isArray(
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
eachBranch({ routes: this.routes }, [], (routes2) => {
|
|
931
|
-
let path = routes2.reduce((memo, r) => (
|
|
628
|
+
map(t) {
|
|
629
|
+
this.routes = Array.isArray(t) ? G(t) : vt(t);
|
|
630
|
+
const e = this.matchers = [], n = {}, i = {};
|
|
631
|
+
s({ routes: this.routes }, [], (c) => {
|
|
632
|
+
let o = c.reduce((a, h) => (
|
|
932
633
|
// reset if there's a leading slash, otherwise concat
|
|
933
634
|
// and keep resetting the trailing slash
|
|
934
|
-
(
|
|
635
|
+
(h.path[0] === "/" ? h.path : `${a}/${h.path}`).replace(/\/$/, "")
|
|
935
636
|
), "");
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (lastRoute.options.abstract) {
|
|
941
|
-
abstracts[path] = lastRoute.name;
|
|
637
|
+
o === "" && (o = "/");
|
|
638
|
+
const u = c[c.length - 1];
|
|
639
|
+
if (u.options.abstract) {
|
|
640
|
+
i[o] = u.name;
|
|
942
641
|
return;
|
|
943
642
|
}
|
|
944
|
-
if (
|
|
945
|
-
let
|
|
946
|
-
|
|
947
|
-
if (
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
643
|
+
if (u.path === "") {
|
|
644
|
+
let a;
|
|
645
|
+
e.some((h) => {
|
|
646
|
+
if (h.path === o)
|
|
647
|
+
return a = h, !0;
|
|
648
|
+
}), a ? a.routes = c : i[o] && e.push({
|
|
649
|
+
routes: c,
|
|
650
|
+
name: i[o],
|
|
651
|
+
path: o
|
|
951
652
|
});
|
|
952
|
-
if (matcher) {
|
|
953
|
-
matcher.routes = routes2;
|
|
954
|
-
} else if (abstracts[path]) {
|
|
955
|
-
matchers.push({
|
|
956
|
-
routes: routes2,
|
|
957
|
-
name: abstracts[path],
|
|
958
|
-
path
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
653
|
}
|
|
962
|
-
|
|
963
|
-
routes:
|
|
964
|
-
name:
|
|
965
|
-
path
|
|
966
|
-
})
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
dupes[path] = lastRoute.name;
|
|
654
|
+
if (e.push({
|
|
655
|
+
routes: c,
|
|
656
|
+
name: u.name,
|
|
657
|
+
path: o
|
|
658
|
+
}), n[o] && u.path !== "")
|
|
659
|
+
throw new Error(`Routes ${n[o]} and ${u.name} have the same url path '${o}'`);
|
|
660
|
+
n[o] = u.name;
|
|
971
661
|
});
|
|
972
|
-
function
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
if (route.routes.length) {
|
|
976
|
-
eachBranch(route, memo.concat(route), fn);
|
|
977
|
-
}
|
|
662
|
+
function s(c, o, u) {
|
|
663
|
+
c.routes.forEach((a) => {
|
|
664
|
+
u(o.concat(a)), a.routes.length && s(a, o.concat(a), u);
|
|
978
665
|
});
|
|
979
666
|
}
|
|
980
667
|
return this;
|
|
@@ -986,18 +673,12 @@ class Router {
|
|
|
986
673
|
*
|
|
987
674
|
* @api public
|
|
988
675
|
*/
|
|
989
|
-
listen(
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
this.dispatch(
|
|
994
|
-
|
|
995
|
-
this.location.replaceURL(previousUrl, { trigger: false });
|
|
996
|
-
}
|
|
997
|
-
return err;
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
return this.dispatch(location.getURL());
|
|
676
|
+
listen(t) {
|
|
677
|
+
const e = this.location = this.createLocation(t || "");
|
|
678
|
+
return e.onChange((n) => {
|
|
679
|
+
const i = this.state.path;
|
|
680
|
+
this.dispatch(n).catch((s) => (s && s.type === P && this.location.replaceURL(i, { trigger: !1 }), s));
|
|
681
|
+
}), this.dispatch(e.getURL());
|
|
1001
682
|
}
|
|
1002
683
|
/**
|
|
1003
684
|
* Transition to a different route. Passe in url or a route name followed by params and query
|
|
@@ -1008,11 +689,8 @@ class Router {
|
|
|
1008
689
|
*
|
|
1009
690
|
* @api public
|
|
1010
691
|
*/
|
|
1011
|
-
transitionTo(
|
|
1012
|
-
|
|
1013
|
-
return this.replaceWith(name, params, query);
|
|
1014
|
-
}
|
|
1015
|
-
return this.doTransition("setURL", name, params, query);
|
|
692
|
+
transitionTo(t, e, n) {
|
|
693
|
+
return this.state.activeTransition ? this.replaceWith(t, e, n) : this.doTransition("setURL", t, e, n);
|
|
1016
694
|
}
|
|
1017
695
|
/**
|
|
1018
696
|
* Like transitionTo, but doesn't leave an entry in the browser's history,
|
|
@@ -1024,8 +702,8 @@ class Router {
|
|
|
1024
702
|
*
|
|
1025
703
|
* @api public
|
|
1026
704
|
*/
|
|
1027
|
-
replaceWith(
|
|
1028
|
-
return this.doTransition("replaceURL",
|
|
705
|
+
replaceWith(t, e, n) {
|
|
706
|
+
return this.doTransition("replaceURL", t, e, n);
|
|
1029
707
|
}
|
|
1030
708
|
/**
|
|
1031
709
|
* Create an href
|
|
@@ -1036,35 +714,23 @@ class Router {
|
|
|
1036
714
|
*
|
|
1037
715
|
* @api public
|
|
1038
716
|
*/
|
|
1039
|
-
generate(
|
|
1040
|
-
|
|
1041
|
-
let
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
if (!matcher) {
|
|
1049
|
-
throw new Error(`No route is named ${name}`);
|
|
1050
|
-
}
|
|
1051
|
-
const url = withQuery(this.options.qs, injectParams(matcher.path, params), query);
|
|
1052
|
-
return this.location.formatURL(url);
|
|
717
|
+
generate(t, e, n) {
|
|
718
|
+
q(this.location, "call .listen() before using .generate()");
|
|
719
|
+
let i;
|
|
720
|
+
if (n = n || {}, this.matchers.forEach((c) => {
|
|
721
|
+
c.name === t && (i = c);
|
|
722
|
+
}), !i)
|
|
723
|
+
throw new Error(`No route is named ${t}`);
|
|
724
|
+
const s = Lt(this.options.qs, Rt(i.path, e), n);
|
|
725
|
+
return this.location.formatURL(s);
|
|
1053
726
|
}
|
|
1054
727
|
/**
|
|
1055
728
|
* Stop listening to URL changes
|
|
1056
729
|
* @api public
|
|
1057
730
|
*/
|
|
1058
731
|
destroy() {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
if (this.state.activeTransition) {
|
|
1063
|
-
this.state.activeTransition.cancel();
|
|
1064
|
-
}
|
|
1065
|
-
this.state = {};
|
|
1066
|
-
this.middleware.forEach((m) => {
|
|
1067
|
-
m.destroy && m.destroy(this);
|
|
732
|
+
this.location && this.location.destroy && this.location.destroy(), this.state.activeTransition && this.state.activeTransition.cancel(), this.state = {}, this.middleware.forEach((t) => {
|
|
733
|
+
t.destroy && t.destroy(this);
|
|
1068
734
|
});
|
|
1069
735
|
}
|
|
1070
736
|
/**
|
|
@@ -1076,37 +742,20 @@ class Router {
|
|
|
1076
742
|
*
|
|
1077
743
|
* @api public
|
|
1078
744
|
*/
|
|
1079
|
-
isActive(
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
let isActive = activeRoutes.some((route) => route.name === name) && (!exact || activeRoutes[activeRoutes.length - 1].name === name);
|
|
1084
|
-
isActive = isActive && (!params || keys(params).every((key) => activeParams[key] === params[key]));
|
|
1085
|
-
isActive = isActive && (!query || keys(query).every((key) => activeQuery[key] === query[key]));
|
|
1086
|
-
return isActive;
|
|
745
|
+
isActive(t, e, n, i) {
|
|
746
|
+
const s = this.state.routes || [], c = this.state.params, o = this.state.query;
|
|
747
|
+
let u = s.some((a) => a.name === t) && (!i || s[s.length - 1].name === t);
|
|
748
|
+
return u = u && (!e || O(e).every((a) => c[a] === e[a])), u = u && (!n || O(n).every((a) => o[a] === n[a])), u;
|
|
1087
749
|
}
|
|
1088
750
|
/**
|
|
1089
751
|
* @api private
|
|
1090
752
|
*/
|
|
1091
|
-
doTransition(
|
|
1092
|
-
const
|
|
1093
|
-
let
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
if (this.options.pushState) {
|
|
1099
|
-
url = this.location.removeRoot(url);
|
|
1100
|
-
}
|
|
1101
|
-
const transition2 = this.dispatch(url);
|
|
1102
|
-
transition2.catch((err) => {
|
|
1103
|
-
if (err && err.type === TRANSITION_CANCELLED) {
|
|
1104
|
-
this.location.replaceURL(previousUrl, { trigger: false });
|
|
1105
|
-
}
|
|
1106
|
-
return err;
|
|
1107
|
-
});
|
|
1108
|
-
this.location[method](url, { trigger: false });
|
|
1109
|
-
return transition2;
|
|
753
|
+
doTransition(t, e, n, i) {
|
|
754
|
+
const s = this.location.getURL();
|
|
755
|
+
let c = e;
|
|
756
|
+
c[0] !== "/" && (c = this.generate(e, n, i), c = c.replace(/^#/, "/")), this.options.pushState && (c = this.location.removeRoot(c));
|
|
757
|
+
const o = this.dispatch(c);
|
|
758
|
+
return o.catch((u) => (u && u.type === P && this.location.replaceURL(s, { trigger: !1 }), u)), this.location[t](c, { trigger: !1 }), o;
|
|
1110
759
|
}
|
|
1111
760
|
/**
|
|
1112
761
|
* Match the path against the routes
|
|
@@ -1115,67 +764,51 @@ class Router {
|
|
|
1115
764
|
*
|
|
1116
765
|
* @api private
|
|
1117
766
|
*/
|
|
1118
|
-
match(
|
|
1119
|
-
|
|
1120
|
-
let
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
});
|
|
1131
|
-
return {
|
|
1132
|
-
routes: routes.map(descriptor),
|
|
1133
|
-
params: params || {},
|
|
1134
|
-
pathname: pathWithoutQuery,
|
|
1135
|
-
query: extractQuery(qs2, path) || {}
|
|
767
|
+
match(t) {
|
|
768
|
+
t = (t || "").replace(/\/$/, "") || "/";
|
|
769
|
+
let e, n = [];
|
|
770
|
+
const i = tt(t), s = this.options.qs;
|
|
771
|
+
return this.matchers.some((o) => {
|
|
772
|
+
if (e = bt(o.path, i), e)
|
|
773
|
+
return n = o.routes, !0;
|
|
774
|
+
}), {
|
|
775
|
+
routes: n.map(c),
|
|
776
|
+
params: e || {},
|
|
777
|
+
pathname: i,
|
|
778
|
+
query: Tt(s, t) || {}
|
|
1136
779
|
};
|
|
1137
|
-
function
|
|
780
|
+
function c(o) {
|
|
1138
781
|
return {
|
|
1139
|
-
name:
|
|
1140
|
-
path:
|
|
1141
|
-
params:
|
|
1142
|
-
options:
|
|
782
|
+
name: o.name,
|
|
783
|
+
path: o.path,
|
|
784
|
+
params: F(e, Et(o.path)),
|
|
785
|
+
options: L(o.options)
|
|
1143
786
|
};
|
|
1144
787
|
}
|
|
1145
788
|
}
|
|
1146
|
-
dispatch(
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1154
|
-
if (
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
id: this.nextId++,
|
|
1164
|
-
path,
|
|
1165
|
-
match,
|
|
1166
|
-
noop: true,
|
|
1167
|
-
router: this
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
const t = transition({
|
|
789
|
+
dispatch(t) {
|
|
790
|
+
const e = this.match(t), n = e.query, i = e.pathname, s = this.state.activeTransition;
|
|
791
|
+
if (s && s.pathname === i && H(s.query, n))
|
|
792
|
+
return s;
|
|
793
|
+
if (s) {
|
|
794
|
+
const o = new Error(N);
|
|
795
|
+
o.type = N, o.nextPath = t, s.cancel(o);
|
|
796
|
+
}
|
|
797
|
+
if (!s && this.state.pathname === i && H(this.state.query, n))
|
|
798
|
+
return k({
|
|
799
|
+
id: this.nextId++,
|
|
800
|
+
path: t,
|
|
801
|
+
match: e,
|
|
802
|
+
noop: !0,
|
|
803
|
+
router: this
|
|
804
|
+
});
|
|
805
|
+
const c = k({
|
|
1172
806
|
id: this.nextId++,
|
|
1173
|
-
path,
|
|
1174
|
-
match,
|
|
807
|
+
path: t,
|
|
808
|
+
match: e,
|
|
1175
809
|
router: this
|
|
1176
810
|
});
|
|
1177
|
-
this.state.activeTransition =
|
|
1178
|
-
return t;
|
|
811
|
+
return this.state.activeTransition = c, c;
|
|
1179
812
|
}
|
|
1180
813
|
/**
|
|
1181
814
|
* Create the default location.
|
|
@@ -1185,284 +818,198 @@ class Router {
|
|
|
1185
818
|
*
|
|
1186
819
|
* @api private
|
|
1187
820
|
*/
|
|
1188
|
-
createLocation(
|
|
1189
|
-
const
|
|
1190
|
-
if (typeof
|
|
1191
|
-
return
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
console.
|
|
1203
|
-
}
|
|
1204
|
-
logError(...args) {
|
|
1205
|
-
console.error(...args);
|
|
821
|
+
createLocation(t) {
|
|
822
|
+
const e = this.options.location;
|
|
823
|
+
if (typeof e != "string")
|
|
824
|
+
return e;
|
|
825
|
+
if (e === "browser")
|
|
826
|
+
return new xt(F(this.options, ["pushState", "root"]));
|
|
827
|
+
if (e === "memory")
|
|
828
|
+
return new Pt({ path: t });
|
|
829
|
+
throw new Error("Location can be `browser`, `memory` or a custom implementation");
|
|
830
|
+
}
|
|
831
|
+
log(...t) {
|
|
832
|
+
console.info(...t);
|
|
833
|
+
}
|
|
834
|
+
logError(...t) {
|
|
835
|
+
console.error(...t);
|
|
1206
836
|
}
|
|
1207
837
|
}
|
|
1208
|
-
function
|
|
1209
|
-
|
|
1210
|
-
event.preventDefault();
|
|
1211
|
-
router2.transitionTo(router2.location.removeRoot(link2.getAttribute("href")));
|
|
1212
|
-
}
|
|
838
|
+
function jt(r, t, e) {
|
|
839
|
+
!t.hasAttribute("download") && !t.hasAttribute("data-phone-number") && (r.preventDefault(), e.transitionTo(e.location.removeRoot(t.getAttribute("href"))));
|
|
1213
840
|
}
|
|
1214
|
-
function
|
|
1215
|
-
return
|
|
841
|
+
function Ft(r, t = document, e = jt) {
|
|
842
|
+
return _t(t, (n, i) => e(n, i, r));
|
|
1216
843
|
}
|
|
1217
|
-
const
|
|
1218
|
-
let
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
const n = parseFloat(value);
|
|
1223
|
-
const isNumeric = value == n;
|
|
1224
|
-
return isNumeric ? n : value;
|
|
844
|
+
const Ht = Promise.resolve();
|
|
845
|
+
let $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), j, U, x;
|
|
846
|
+
function Bt(r) {
|
|
847
|
+
const t = parseFloat(r);
|
|
848
|
+
return r == t ? t : r;
|
|
1225
849
|
}
|
|
1226
|
-
class
|
|
1227
|
-
constructor(
|
|
1228
|
-
this.key =
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
if (format === "number") {
|
|
1236
|
-
result = parseNumber(result);
|
|
1237
|
-
} else if (typeof format === "function") {
|
|
1238
|
-
result = format(result);
|
|
1239
|
-
}
|
|
850
|
+
class Wt {
|
|
851
|
+
constructor(t, e) {
|
|
852
|
+
this.key = t, this.format = e;
|
|
853
|
+
}
|
|
854
|
+
value(t) {
|
|
855
|
+
let e = this.getValue(t);
|
|
856
|
+
if (e !== void 0) {
|
|
857
|
+
const n = this.format;
|
|
858
|
+
n === "number" ? e = Bt(e) : typeof n == "function" && (e = n(e));
|
|
1240
859
|
}
|
|
1241
|
-
return
|
|
860
|
+
return e;
|
|
1242
861
|
}
|
|
1243
862
|
}
|
|
1244
|
-
function
|
|
1245
|
-
|
|
1246
|
-
rootOutlet = instance.options.outlet;
|
|
863
|
+
function kt(r) {
|
|
864
|
+
j = r, U = r.options.outlet;
|
|
1247
865
|
}
|
|
1248
|
-
function
|
|
1249
|
-
|
|
1250
|
-
routeElMap = /* @__PURE__ */ Object.create(null);
|
|
1251
|
-
routeComponentMap = /* @__PURE__ */ Object.create(null);
|
|
1252
|
-
rootOutletEl = null;
|
|
866
|
+
function Qt() {
|
|
867
|
+
j = null, $ = /* @__PURE__ */ Object.create(null), M = /* @__PURE__ */ Object.create(null), x = null;
|
|
1253
868
|
}
|
|
1254
|
-
function
|
|
1255
|
-
const
|
|
1256
|
-
return
|
|
869
|
+
function Vt(r, t) {
|
|
870
|
+
const e = Object.keys(r);
|
|
871
|
+
return e.length === Object.keys(t).length && e.every((n) => t[n] === r[n]);
|
|
1257
872
|
}
|
|
1258
|
-
function
|
|
1259
|
-
|
|
1260
|
-
return renderRoot.querySelector(el.constructor.outlet || "wj-router-outlet");
|
|
873
|
+
function Kt(r) {
|
|
874
|
+
return (r.shadowRoot || r).querySelector(r.constructor.outlet || "wj-router-outlet");
|
|
1261
875
|
}
|
|
1262
|
-
function
|
|
1263
|
-
if (
|
|
1264
|
-
return
|
|
1265
|
-
if (!
|
|
876
|
+
function zt() {
|
|
877
|
+
if (x)
|
|
878
|
+
return x;
|
|
879
|
+
if (!U)
|
|
1266
880
|
return document.body;
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
}
|
|
1271
|
-
return rootOutletEl;
|
|
881
|
+
if (x = typeof U == "string" ? document.querySelector(U) : U, !x)
|
|
882
|
+
throw new Error(`slick-router(wc): Invalid outlet option ${U}`);
|
|
883
|
+
return x;
|
|
1272
884
|
}
|
|
1273
|
-
function
|
|
1274
|
-
let
|
|
1275
|
-
|
|
1276
|
-
if (
|
|
1277
|
-
return
|
|
1278
|
-
|
|
1279
|
-
parent = transition2.routes[--parentIndex];
|
|
885
|
+
function Jt(r, t) {
|
|
886
|
+
let e = r.routes[t];
|
|
887
|
+
for (; e; ) {
|
|
888
|
+
if (e.options.component)
|
|
889
|
+
return $[e.name];
|
|
890
|
+
e = r.routes[--t];
|
|
1280
891
|
}
|
|
1281
892
|
}
|
|
1282
|
-
function
|
|
1283
|
-
let
|
|
1284
|
-
const
|
|
1285
|
-
for (
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
if (!(prev && current) || prev.name !== current.name || !isEqual(prev.params, current.params)) {
|
|
1289
|
-
break;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
return index;
|
|
893
|
+
function Zt(r, t) {
|
|
894
|
+
let e, n, i;
|
|
895
|
+
const s = Math.max(r.length, t.length);
|
|
896
|
+
for (e = 0; e < s && (n = r[e], i = t[e], !(!(n && i) || n.name !== i.name || !Vt(n.params, i.params))); e++)
|
|
897
|
+
;
|
|
898
|
+
return e;
|
|
1293
899
|
}
|
|
1294
|
-
async function
|
|
1295
|
-
for (let i = 0; i <
|
|
1296
|
-
let
|
|
1297
|
-
const { route, el } =
|
|
1298
|
-
|
|
1299
|
-
if (typeof routeMethod === "function") {
|
|
1300
|
-
result = await routeMethod(transition2);
|
|
1301
|
-
if (result === false) {
|
|
1302
|
-
transition2.cancel();
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
if (transition2.isCancelled)
|
|
900
|
+
async function I(r, t, e, n) {
|
|
901
|
+
for (let i = 0; i < t.length; i++) {
|
|
902
|
+
let s;
|
|
903
|
+
const { route: c, el: o } = t[i], u = c.options[`${e}${n}`];
|
|
904
|
+
if (typeof u == "function" && (s = await u(r), s === !1 && r.cancel()), r.isCancelled)
|
|
1306
905
|
break;
|
|
1307
|
-
const
|
|
1308
|
-
if (typeof
|
|
1309
|
-
result = await elMethod.call(el, transition2);
|
|
1310
|
-
if (result === false) {
|
|
1311
|
-
transition2.cancel();
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
if (transition2.isCancelled)
|
|
906
|
+
const a = o && o[`${e}Route${n}`];
|
|
907
|
+
if (typeof a == "function" && (s = await a.call(o, r), s === !1 && r.cancel()), r.isCancelled)
|
|
1315
908
|
break;
|
|
1316
909
|
}
|
|
1317
910
|
}
|
|
1318
|
-
function
|
|
1319
|
-
return
|
|
911
|
+
function Gt(r) {
|
|
912
|
+
return r && r.__esModule ? r.default : r;
|
|
1320
913
|
}
|
|
1321
|
-
async function
|
|
1322
|
-
const
|
|
1323
|
-
for (const
|
|
1324
|
-
let
|
|
1325
|
-
|
|
1326
|
-
if (!el && Component) {
|
|
1327
|
-
if (typeof Component === "function" && !(Component.prototype instanceof HTMLElement)) {
|
|
1328
|
-
Component = routeComponentMap[route.name] || (routeComponentMap[route.name] = resolveModule(await Component(route)));
|
|
1329
|
-
}
|
|
1330
|
-
el = typeof Component === "string" ? document.createElement(Component) : new Component();
|
|
1331
|
-
routeElMap[route.name] = el;
|
|
1332
|
-
el.$router = router;
|
|
1333
|
-
}
|
|
1334
|
-
result.push({ el, route });
|
|
914
|
+
async function Xt(r) {
|
|
915
|
+
const t = [];
|
|
916
|
+
for (const e of r) {
|
|
917
|
+
let n = e.options.reuse ? $[e.name] : void 0, i = e.options.component;
|
|
918
|
+
!n && i && (typeof i == "function" && !(i.prototype instanceof HTMLElement) && (i = M[e.name] || (M[e.name] = Gt(await i(e)))), n = typeof i == "string" ? document.createElement(i) : new i(), $[e.name] = n, n.$router = j), t.push({ el: n, route: e });
|
|
1335
919
|
}
|
|
1336
|
-
return
|
|
920
|
+
return t;
|
|
1337
921
|
}
|
|
1338
|
-
function
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
922
|
+
function V(r, t, e) {
|
|
923
|
+
e && Object.keys(e).forEach((n) => {
|
|
924
|
+
const i = e[n];
|
|
925
|
+
t[n] = i instanceof Wt ? i.value(r) : i;
|
|
926
|
+
});
|
|
1345
927
|
}
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
const { el, route } = activated[i];
|
|
1361
|
-
if (el) {
|
|
1362
|
-
const parentEl = getParentEl(transition2, changingIndex + i - 1);
|
|
1363
|
-
const outletEl = parentEl ? getOutlet(parentEl) : resolveRootOutlet();
|
|
1364
|
-
if (outletEl) {
|
|
1365
|
-
const currentEl = outletCurrentEl.get(outletEl) || outletEl.firstElementChild;
|
|
1366
|
-
if (currentEl) {
|
|
1367
|
-
outletEl.removeChild(currentEl);
|
|
1368
|
-
removedEls.add(currentEl);
|
|
1369
|
-
}
|
|
1370
|
-
el.$route = routeState;
|
|
1371
|
-
applyProperties(transition2, el, route.options.properties);
|
|
1372
|
-
outletEl.appendChild(el);
|
|
1373
|
-
outletCurrentEl.set(outletEl, el);
|
|
1374
|
-
await (el.updateComplete || resolved);
|
|
928
|
+
const nt = /* @__PURE__ */ new WeakSet(), K = /* @__PURE__ */ new WeakMap();
|
|
929
|
+
async function Yt(r, t, e) {
|
|
930
|
+
const { path: n, pathname: i, routes: s, params: c, query: o } = r, u = { path: n, pathname: i, routes: s, params: c, query: o };
|
|
931
|
+
for (let a = 0; a < e; a++) {
|
|
932
|
+
const h = r.routes[a], g = $[h.name];
|
|
933
|
+
g && (g.$route = u, V(r, g, h.options.properties));
|
|
934
|
+
}
|
|
935
|
+
for (let a = 0; a < t.length; a++) {
|
|
936
|
+
const { el: h, route: g } = t[a];
|
|
937
|
+
if (h) {
|
|
938
|
+
const m = Jt(r, e + a - 1), f = m ? Kt(m) : zt();
|
|
939
|
+
if (f) {
|
|
940
|
+
const d = K.get(f) || f.firstElementChild;
|
|
941
|
+
d && (f.removeChild(d), nt.add(d)), h.$route = u, V(r, h, g.options.properties), f.appendChild(h), K.set(f, h), await (h.updateComplete || Ht);
|
|
1375
942
|
}
|
|
1376
943
|
}
|
|
1377
944
|
}
|
|
1378
945
|
}
|
|
1379
|
-
function
|
|
1380
|
-
let
|
|
1381
|
-
for (let
|
|
1382
|
-
const { route, el } =
|
|
1383
|
-
|
|
1384
|
-
if (el) {
|
|
1385
|
-
if (!parentElRemoved && !removedEls.has(el))
|
|
1386
|
-
el.remove();
|
|
1387
|
-
parentElRemoved = true;
|
|
1388
|
-
}
|
|
1389
|
-
routeElMap[route.name] = void 0;
|
|
1390
|
-
}
|
|
946
|
+
function te(r, t) {
|
|
947
|
+
let e;
|
|
948
|
+
for (let n = t.length - 1; n >= 0; n--) {
|
|
949
|
+
const { route: i, el: s } = t[n];
|
|
950
|
+
r.some(({ route: c }) => c.name === i.name) || (s && (!e && !nt.has(s) && s.remove(), e = !0), $[i.name] = void 0);
|
|
1391
951
|
}
|
|
1392
952
|
}
|
|
1393
|
-
async function
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
await runLifeCycle(transition2, deactivated, "before", "Leave");
|
|
1402
|
-
if (transition2.isCancelled)
|
|
1403
|
-
return;
|
|
1404
|
-
const activated = await resolveComponents(transition2.routes.slice(changingIndex));
|
|
1405
|
-
await runLifeCycle(transition2, activated, "before", "Enter");
|
|
1406
|
-
if (transition2.isCancelled)
|
|
953
|
+
async function ee(r) {
|
|
954
|
+
const t = r.prev.routes, e = Zt(t, r.routes), n = [];
|
|
955
|
+
for (let s = t.length - 1; s >= e; s--) {
|
|
956
|
+
const c = t[s];
|
|
957
|
+
n.push({ el: $[c.name], route: c });
|
|
958
|
+
}
|
|
959
|
+
if (await I(r, n, "before", "Leave"), r.isCancelled)
|
|
1407
960
|
return;
|
|
1408
|
-
await
|
|
1409
|
-
|
|
1410
|
-
transition2.activated = activated;
|
|
1411
|
-
transition2.deactivated = deactivated;
|
|
961
|
+
const i = await Xt(r.routes.slice(e));
|
|
962
|
+
await I(r, i, "before", "Enter"), !r.isCancelled && (await Yt(r, i, e), te(i, n), r.activated = i, r.deactivated = n);
|
|
1412
963
|
}
|
|
1413
|
-
function
|
|
1414
|
-
|
|
1415
|
-
runLifeCycle(transition2, transition2.activated, "after", "Enter");
|
|
964
|
+
function re(r) {
|
|
965
|
+
I(r, r.deactivated, "after", "Leave"), I(r, r.activated, "after", "Enter");
|
|
1416
966
|
}
|
|
1417
|
-
const
|
|
1418
|
-
create,
|
|
1419
|
-
destroy,
|
|
1420
|
-
resolve,
|
|
1421
|
-
done
|
|
967
|
+
const ne = {
|
|
968
|
+
create: kt,
|
|
969
|
+
destroy: Qt,
|
|
970
|
+
resolve: ee,
|
|
971
|
+
done: re
|
|
1422
972
|
};
|
|
1423
|
-
let
|
|
1424
|
-
function
|
|
1425
|
-
window.dispatchEvent(new CustomEvent(`${
|
|
973
|
+
let it;
|
|
974
|
+
function _(r, t) {
|
|
975
|
+
window.dispatchEvent(new CustomEvent(`${it}${r}`, { detail: t }));
|
|
1426
976
|
}
|
|
1427
|
-
const
|
|
1428
|
-
create: function(
|
|
1429
|
-
|
|
977
|
+
const ie = {
|
|
978
|
+
create: function(r) {
|
|
979
|
+
it = r.options.eventPrefix || "router-";
|
|
1430
980
|
},
|
|
1431
|
-
before: function(
|
|
1432
|
-
|
|
981
|
+
before: function(r) {
|
|
982
|
+
_("before:transition", { transition: r });
|
|
1433
983
|
},
|
|
1434
|
-
done: function(
|
|
1435
|
-
|
|
984
|
+
done: function(r) {
|
|
985
|
+
_("transition", { transition: r });
|
|
1436
986
|
},
|
|
1437
|
-
cancel: function(
|
|
1438
|
-
|
|
1439
|
-
trigger("abort", { transition: transition2, error });
|
|
1440
|
-
}
|
|
987
|
+
cancel: function(r, t) {
|
|
988
|
+
t.type !== "TransitionRedirected" && _("abort", { transition: r, error: t });
|
|
1441
989
|
},
|
|
1442
|
-
error: function(
|
|
1443
|
-
|
|
1444
|
-
trigger("error", { transition: transition2, error });
|
|
990
|
+
error: function(r, t) {
|
|
991
|
+
_("abort", { transition: r, error: t }), _("error", { transition: r, error: t });
|
|
1445
992
|
}
|
|
1446
993
|
};
|
|
1447
|
-
class
|
|
994
|
+
class se extends at {
|
|
1448
995
|
constructor() {
|
|
1449
996
|
super();
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
let
|
|
1453
|
-
...
|
|
1454
|
-
var
|
|
997
|
+
A(this, "className", "Routerx");
|
|
998
|
+
A(this, "setBreadcrumb", (e) => {
|
|
999
|
+
let n = [
|
|
1000
|
+
...e.routes.filter((i) => "breadcrumb" in i.options).map((i, s) => {
|
|
1001
|
+
var c, o;
|
|
1455
1002
|
return {
|
|
1456
|
-
name:
|
|
1457
|
-
text:
|
|
1458
|
-
params: { ...
|
|
1459
|
-
path: this.router.generate(
|
|
1003
|
+
name: i.options.breadcrumbPath || i.name,
|
|
1004
|
+
text: i.options.breadcrumb instanceof Function ? (o = (c = i.options).breadcrumb) == null ? void 0 : o.call(c, e) : i.options.breadcrumb,
|
|
1005
|
+
params: { ...i.params, ...e.params },
|
|
1006
|
+
path: this.router.generate(i.name, { ...i.params, ...e.params })
|
|
1460
1007
|
};
|
|
1461
1008
|
})
|
|
1462
1009
|
];
|
|
1463
|
-
|
|
1010
|
+
e.breadcrumbs = n;
|
|
1464
1011
|
});
|
|
1465
|
-
|
|
1012
|
+
A(this, "resetScrollPosition", (e) => {
|
|
1466
1013
|
window.scrollTo(0, 0);
|
|
1467
1014
|
});
|
|
1468
1015
|
}
|
|
@@ -1473,55 +1020,28 @@ class Routerx extends WJElement {
|
|
|
1473
1020
|
this.isShadowRoot = "open";
|
|
1474
1021
|
}
|
|
1475
1022
|
afterDraw() {
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
const htmlDocument = parser.parseFromString(htmlString, "text/html");
|
|
1479
|
-
const rootElement = htmlDocument.querySelector("wj-router");
|
|
1480
|
-
const routes = this.parseElement(rootElement).root;
|
|
1481
|
-
this.router = new Router({
|
|
1023
|
+
const e = this.outerHTML, s = new DOMParser().parseFromString(e, "text/html").querySelector("wj-router"), c = this.parseElement(s).root;
|
|
1024
|
+
this.router = new Mt({
|
|
1482
1025
|
outlet: this.outlet || "wj-router-outlet",
|
|
1483
|
-
log:
|
|
1484
|
-
logError:
|
|
1026
|
+
log: !1,
|
|
1027
|
+
logError: !1,
|
|
1485
1028
|
root: "/",
|
|
1486
|
-
pushState:
|
|
1487
|
-
});
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
this.router.listen();
|
|
1495
|
-
interceptLinks(this.router);
|
|
1496
|
-
}
|
|
1497
|
-
parseElement(element) {
|
|
1498
|
-
const obj = {};
|
|
1499
|
-
const attributes = element.attributes;
|
|
1500
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
1501
|
-
const attributeName = attributes[i].name;
|
|
1502
|
-
const attributeValue = attributes[i].value;
|
|
1503
|
-
if (attributeName === "component" && attributeValue.indexOf(".js") > -1) {
|
|
1504
|
-
obj.component = () => import(attributeValue);
|
|
1505
|
-
} else {
|
|
1506
|
-
if (attributeName !== "shadow") {
|
|
1507
|
-
obj[attributeName] = attributeValue;
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
const children = [];
|
|
1512
|
-
const childElements = Array.from(element.children);
|
|
1513
|
-
childElements.forEach((childElement) => {
|
|
1514
|
-
children.push(this.parseElement(childElement));
|
|
1515
|
-
});
|
|
1516
|
-
if (children.length > 0 && element.tagName === "WJ-ROUTE") {
|
|
1517
|
-
obj.children = children;
|
|
1518
|
-
} else {
|
|
1519
|
-
obj.root = children;
|
|
1029
|
+
pushState: !0
|
|
1030
|
+
}), this.router.map(c), this.router.use(this.setBreadcrumb), this.router.use(ne), this.router.use(ct), this.router.use(ie), this.router.use(this.resetScrollPosition), this.router.listen(), Ft(this.router);
|
|
1031
|
+
}
|
|
1032
|
+
parseElement(e) {
|
|
1033
|
+
const n = {}, i = e.attributes;
|
|
1034
|
+
for (let o = 0; o < i.length; o++) {
|
|
1035
|
+
const u = i[o].name, a = i[o].value;
|
|
1036
|
+
u === "component" && a.indexOf(".js") > -1 ? n.component = () => import(a) : u !== "shadow" && (n[u] = a);
|
|
1520
1037
|
}
|
|
1521
|
-
|
|
1038
|
+
const s = [];
|
|
1039
|
+
return Array.from(e.children).forEach((o) => {
|
|
1040
|
+
s.push(this.parseElement(o));
|
|
1041
|
+
}), s.length > 0 && e.tagName === "WJ-ROUTE" ? n.children = s : n.root = s, n;
|
|
1522
1042
|
}
|
|
1523
1043
|
}
|
|
1524
|
-
customElements.get("wj-router") || window.customElements.define("wj-router",
|
|
1044
|
+
customElements.get("wj-router") || window.customElements.define("wj-router", se);
|
|
1525
1045
|
export {
|
|
1526
|
-
Routerx
|
|
1046
|
+
se as Routerx
|
|
1527
1047
|
};
|