wj-elements 0.1.129 → 0.1.130
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/README.md +8 -4
- package/dist/assets/tags.json +3252 -22012
- package/dist/dark.css +213 -210
- package/dist/{infinite-scroll.element-R3y_ZQj6.js → infinite-scroll.element-BmojLp3Z.js} +16 -34
- package/dist/light.css +511 -501
- package/dist/{list.element-syl98NWS.js → list.element-Ce1vIm1O.js} +2 -11
- package/dist/localize.js +1 -2
- package/dist/{popup.element-C0a1z1y2.js → popup.element-4DNn6DjX.js} +102 -224
- package/dist/{router-links-I2vcmVCs.js → router-links-CJnOdbas.js} +30 -77
- package/dist/styles.css +485 -473
- package/dist/wje-accordion-item.js +12 -10
- package/dist/wje-accordion.js +51 -14
- package/dist/wje-animation.js +9 -13
- package/dist/wje-aside.js +6 -11
- package/dist/wje-avatar.js +7 -10
- package/dist/wje-badge.js +23 -18
- package/dist/wje-breadcrumb.js +30 -48
- package/dist/wje-breadcrumbs.js +80 -23
- package/dist/wje-button-group.js +15 -21
- package/dist/wje-button.js +64 -71
- package/dist/wje-card-content.js +9 -12
- package/dist/wje-card-controls.js +9 -12
- package/dist/wje-card-header.js +4 -8
- package/dist/wje-card-subtitle.js +4 -7
- package/dist/wje-card-title.js +4 -7
- package/dist/wje-card.js +13 -14
- package/dist/wje-carousel-item.js +25 -0
- package/dist/wje-carousel.js +140 -23
- package/dist/wje-checkbox.js +294 -48
- package/dist/wje-chip.js +30 -11
- package/dist/wje-col.js +7 -17
- package/dist/wje-color-picker.js +32 -34
- package/dist/wje-container.js +5 -9
- package/dist/wje-copy-button.js +11 -15
- package/dist/wje-dialog.js +12 -17
- package/dist/wje-divider.js +1 -4
- package/dist/wje-dropdown.js +41 -23
- package/dist/wje-element.js +214 -196
- package/dist/wje-file-upload-item.js +11 -21
- package/dist/wje-file-upload.js +64 -59
- package/dist/wje-footer.js +2 -9
- package/dist/wje-form.js +22 -0
- package/dist/wje-format-digital.js +4 -12
- package/dist/wje-grid.js +23 -2
- package/dist/wje-header.js +2 -9
- package/dist/wje-icon-picker.js +14 -33
- package/dist/wje-icon.js +9 -12
- package/dist/wje-img-comparer.js +7 -15
- package/dist/wje-img.js +3 -12
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-input-file.js +19 -19
- package/dist/wje-input.js +50 -66
- package/dist/wje-item.js +11 -15
- package/dist/wje-kanban.js +22 -23
- package/dist/wje-label.js +3 -11
- package/dist/wje-list.js +1 -1
- package/dist/wje-main.js +3 -10
- package/dist/wje-masonry.js +16 -21
- package/dist/wje-master.js +197 -236
- package/dist/wje-menu-button.js +4 -15
- package/dist/wje-menu-item.js +209 -37
- package/dist/wje-menu-label.js +3 -10
- package/dist/wje-menu.js +5 -17
- package/dist/wje-option.js +18 -29
- package/dist/wje-options.js +141 -55
- package/dist/wje-orgchart-group.js +8 -15
- package/dist/wje-orgchart-item.js +10 -157
- package/dist/wje-orgchart.js +3 -9
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +11 -25
- package/dist/wje-qr-code.js +27 -11
- package/dist/wje-radio-group.js +20 -45
- package/dist/wje-radio.js +45 -7
- package/dist/wje-rate.js +35 -58
- package/dist/wje-relative-time.js +19 -29
- package/dist/wje-reorder-dropzone.js +20 -2
- package/dist/wje-reorder-handle.js +62 -3
- package/dist/wje-reorder-item.js +20 -2
- package/dist/wje-reorder.js +43 -49
- package/dist/wje-route.js +2 -8
- package/dist/wje-router-link.js +9 -12
- package/dist/wje-router-outlet.js +35 -37
- package/dist/wje-routerx.js +231 -340
- package/dist/wje-row.js +7 -9
- package/dist/wje-select.js +72 -99
- package/dist/wje-slider.js +13 -32
- package/dist/wje-sliding-container.js +3 -7
- package/dist/wje-split-view.js +8 -22
- package/dist/wje-status.js +8 -12
- package/dist/wje-step.js +18 -0
- package/dist/wje-stepper.js +41 -4823
- package/dist/wje-store.js +178 -74
- package/dist/wje-tab-group.js +7 -19
- package/dist/wje-tab-panel.js +3 -12
- package/dist/wje-tab.js +5 -16
- package/dist/wje-textarea.js +127 -47
- package/dist/wje-thumbnail.js +9 -14
- package/dist/wje-toast.js +27 -64
- package/dist/wje-toggle.js +21 -32
- package/dist/wje-toolbar-action.js +10 -14
- package/dist/wje-toolbar.js +10 -15
- package/dist/wje-tooltip.js +33 -25
- package/dist/wje-visually-hidden.js +9 -13
- package/package.json +15 -8
package/dist/wje-routerx.js
CHANGED
|
@@ -1,207 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { r as routerLinks } from "./router-links-CJnOdbas.js";
|
|
4
5
|
import WJElement from "./wje-element.js";
|
|
5
|
-
import { r as routerLinks } from "./router-links-I2vcmVCs.js";
|
|
6
|
-
var DEFAULT_DELIMITER = "/";
|
|
7
|
-
function balanced(open, close, str, index) {
|
|
8
|
-
var count = 0;
|
|
9
|
-
var i = index;
|
|
10
|
-
while (i < str.length) {
|
|
11
|
-
if (str[i] === "\\") {
|
|
12
|
-
i += 2;
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
if (str[i] === close) {
|
|
16
|
-
count--;
|
|
17
|
-
if (count === 0)
|
|
18
|
-
return i + 1;
|
|
19
|
-
}
|
|
20
|
-
if (str[i] === open) {
|
|
21
|
-
count++;
|
|
22
|
-
}
|
|
23
|
-
i++;
|
|
24
|
-
}
|
|
25
|
-
return -1;
|
|
26
|
-
}
|
|
27
|
-
function parse(str, options) {
|
|
28
|
-
if (options === void 0) {
|
|
29
|
-
options = {};
|
|
30
|
-
}
|
|
31
|
-
var _a, _b;
|
|
32
|
-
var tokens = [];
|
|
33
|
-
var defaultDelimiter = (_a = options.delimiter, _a !== null && _a !== void 0 ? _a : DEFAULT_DELIMITER);
|
|
34
|
-
var whitelist = (_b = options.whitelist, _b !== null && _b !== void 0 ? _b : void 0);
|
|
35
|
-
var i = 0;
|
|
36
|
-
var key = 0;
|
|
37
|
-
var path = "";
|
|
38
|
-
var isEscaped = false;
|
|
39
|
-
while (i < str.length) {
|
|
40
|
-
var prefix = "";
|
|
41
|
-
var name = "";
|
|
42
|
-
var pattern = "";
|
|
43
|
-
if (str[i] === "\\") {
|
|
44
|
-
i++;
|
|
45
|
-
path += str[i++];
|
|
46
|
-
isEscaped = true;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (str[i] === ":") {
|
|
50
|
-
while (++i < str.length) {
|
|
51
|
-
var code = str.charCodeAt(i);
|
|
52
|
-
if (
|
|
53
|
-
// `0-9`
|
|
54
|
-
code >= 48 && code <= 57 || // `A-Z`
|
|
55
|
-
code >= 65 && code <= 90 || // `a-z`
|
|
56
|
-
code >= 97 && code <= 122 || // `_`
|
|
57
|
-
code === 95
|
|
58
|
-
) {
|
|
59
|
-
name += str[i];
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
if (!name)
|
|
65
|
-
i--;
|
|
66
|
-
}
|
|
67
|
-
if (str[i] === "(") {
|
|
68
|
-
var end = balanced("(", ")", str, i);
|
|
69
|
-
if (end > -1) {
|
|
70
|
-
pattern = str.slice(i + 1, end - 1);
|
|
71
|
-
i = end;
|
|
72
|
-
if (pattern[0] === "?") {
|
|
73
|
-
throw new TypeError("Path pattern must be a capturing group");
|
|
74
|
-
}
|
|
75
|
-
if (/\((?=[^?])/.test(pattern)) {
|
|
76
|
-
var validPattern = pattern.replace(/\((?=[^?])/, "(?:");
|
|
77
|
-
throw new TypeError("Capturing groups are not allowed in pattern, use a non-capturing group: (" + validPattern + ")");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (name === "" && pattern === "") {
|
|
82
|
-
path += str[i++];
|
|
83
|
-
isEscaped = false;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (path.length && !isEscaped) {
|
|
87
|
-
var char = path[path.length - 1];
|
|
88
|
-
var matches = whitelist ? whitelist.indexOf(char) > -1 : true;
|
|
89
|
-
if (matches) {
|
|
90
|
-
prefix = char;
|
|
91
|
-
path = path.slice(0, -1);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (path.length) {
|
|
95
|
-
tokens.push(path);
|
|
96
|
-
path = "";
|
|
97
|
-
}
|
|
98
|
-
var repeat = str[i] === "+" || str[i] === "*";
|
|
99
|
-
var optional = str[i] === "?" || str[i] === "*";
|
|
100
|
-
var delimiter = prefix || defaultDelimiter;
|
|
101
|
-
if (repeat || optional)
|
|
102
|
-
i++;
|
|
103
|
-
tokens.push({
|
|
104
|
-
name: name || key++,
|
|
105
|
-
prefix,
|
|
106
|
-
delimiter,
|
|
107
|
-
optional,
|
|
108
|
-
repeat,
|
|
109
|
-
pattern: pattern || "[^" + escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter) + "]+?"
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (path.length)
|
|
113
|
-
tokens.push(path);
|
|
114
|
-
return tokens;
|
|
115
|
-
}
|
|
116
|
-
function escapeString(str) {
|
|
117
|
-
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
118
|
-
}
|
|
119
|
-
function flags(options) {
|
|
120
|
-
return options && options.sensitive ? "" : "i";
|
|
121
|
-
}
|
|
122
|
-
function regexpToRegexp(path, keys2) {
|
|
123
|
-
if (!keys2)
|
|
124
|
-
return path;
|
|
125
|
-
var groups = path.source.match(/\((?!\?)/g);
|
|
126
|
-
if (groups) {
|
|
127
|
-
for (var i = 0; i < groups.length; i++) {
|
|
128
|
-
keys2.push({
|
|
129
|
-
name: i,
|
|
130
|
-
prefix: "",
|
|
131
|
-
delimiter: "",
|
|
132
|
-
optional: false,
|
|
133
|
-
repeat: false,
|
|
134
|
-
pattern: ""
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return path;
|
|
139
|
-
}
|
|
140
|
-
function arrayToRegexp(paths, keys2, options) {
|
|
141
|
-
var parts = paths.map(function(path) {
|
|
142
|
-
return pathToRegexp(path, keys2, options).source;
|
|
143
|
-
});
|
|
144
|
-
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
145
|
-
}
|
|
146
|
-
function stringToRegexp(path, keys2, options) {
|
|
147
|
-
return tokensToRegexp(parse(path, options), keys2, options);
|
|
148
|
-
}
|
|
149
|
-
function tokensToRegexp(tokens, keys2, options) {
|
|
150
|
-
if (options === void 0) {
|
|
151
|
-
options = {};
|
|
152
|
-
}
|
|
153
|
-
var strict = options.strict, _a = options.start, start = _a === void 0 ? true : _a, _b = options.end, end = _b === void 0 ? true : _b, _c = options.delimiter, delimiter = _c === void 0 ? DEFAULT_DELIMITER : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
|
154
|
-
return x;
|
|
155
|
-
} : _d;
|
|
156
|
-
var endsWith = (typeof options.endsWith === "string" ? options.endsWith.split("") : options.endsWith || []).map(escapeString).concat("$").join("|");
|
|
157
|
-
var route = start ? "^" : "";
|
|
158
|
-
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
159
|
-
var token = tokens_1[_i];
|
|
160
|
-
if (typeof token === "string") {
|
|
161
|
-
route += escapeString(encode(token));
|
|
162
|
-
} else {
|
|
163
|
-
var capture = token.repeat ? "(?:" + token.pattern + ")(?:" + escapeString(token.delimiter) + "(?:" + token.pattern + "))*" : token.pattern;
|
|
164
|
-
if (keys2)
|
|
165
|
-
keys2.push(token);
|
|
166
|
-
if (token.optional) {
|
|
167
|
-
if (!token.prefix) {
|
|
168
|
-
route += "(" + capture + ")?";
|
|
169
|
-
} else {
|
|
170
|
-
route += "(?:" + escapeString(token.prefix) + "(" + capture + "))?";
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
route += escapeString(token.prefix) + "(" + capture + ")";
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (end) {
|
|
178
|
-
if (!strict)
|
|
179
|
-
route += "(?:" + escapeString(delimiter) + ")?";
|
|
180
|
-
route += endsWith === "$" ? "$" : "(?=" + endsWith + ")";
|
|
181
|
-
} else {
|
|
182
|
-
var endToken = tokens[tokens.length - 1];
|
|
183
|
-
var isEndDelimited = typeof endToken === "string" ? endToken[endToken.length - 1] === delimiter : (
|
|
184
|
-
// tslint:disable-next-line
|
|
185
|
-
endToken === void 0
|
|
186
|
-
);
|
|
187
|
-
if (!strict) {
|
|
188
|
-
route += "(?:" + escapeString(delimiter) + "(?=" + endsWith + "))?";
|
|
189
|
-
}
|
|
190
|
-
if (!isEndDelimited) {
|
|
191
|
-
route += "(?=" + escapeString(delimiter) + "|" + endsWith + ")";
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return new RegExp(route, flags(options));
|
|
195
|
-
}
|
|
196
|
-
function pathToRegexp(path, keys2, options) {
|
|
197
|
-
if (path instanceof RegExp) {
|
|
198
|
-
return regexpToRegexp(path, keys2);
|
|
199
|
-
}
|
|
200
|
-
if (Array.isArray(path)) {
|
|
201
|
-
return arrayToRegexp(path, keys2, options);
|
|
202
|
-
}
|
|
203
|
-
return stringToRegexp(path, keys2, options);
|
|
204
|
-
}
|
|
205
6
|
const assoc = (obj, attr, val) => {
|
|
206
7
|
obj[attr] = val;
|
|
207
8
|
return obj;
|
|
@@ -218,9 +19,7 @@ const extend = Object.assign;
|
|
|
218
19
|
function invariant(condition, format, ...args) {
|
|
219
20
|
if (!condition) {
|
|
220
21
|
let argIndex = 0;
|
|
221
|
-
throw new Error(
|
|
222
|
-
"Invariant Violation: " + format.replace(/%s/g, () => args[argIndex++])
|
|
223
|
-
);
|
|
22
|
+
throw new Error("Invariant Violation: " + format.replace(/%s/g, () => args[argIndex++]));
|
|
224
23
|
}
|
|
225
24
|
}
|
|
226
25
|
function functionDsl(callback) {
|
|
@@ -229,7 +28,11 @@ function functionDsl(callback) {
|
|
|
229
28
|
const names = {};
|
|
230
29
|
callback(function route(name, options, childrenCallback) {
|
|
231
30
|
let routes;
|
|
232
|
-
invariant(
|
|
31
|
+
invariant(
|
|
32
|
+
!names[name],
|
|
33
|
+
'Route names must be unique, but route "%s" is declared multiple times',
|
|
34
|
+
name
|
|
35
|
+
);
|
|
233
36
|
names[name] = true;
|
|
234
37
|
if (arguments.length === 1) {
|
|
235
38
|
options = {};
|
|
@@ -275,14 +78,12 @@ function arrayDsl(routes) {
|
|
|
275
78
|
const parts = name.split(".");
|
|
276
79
|
options.path = parts[parts.length - 1];
|
|
277
80
|
}
|
|
278
|
-
result.push(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
);
|
|
81
|
+
result.push({
|
|
82
|
+
name,
|
|
83
|
+
path: options.path,
|
|
84
|
+
options,
|
|
85
|
+
routes: children ? arrayDsl(children) : []
|
|
86
|
+
});
|
|
286
87
|
});
|
|
287
88
|
return result;
|
|
288
89
|
}
|
|
@@ -290,22 +91,17 @@ const paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?+*]?)/g;
|
|
|
290
91
|
const specialParamChars = /[+*?]$/g;
|
|
291
92
|
const queryMatcher = /\?(.+)/;
|
|
292
93
|
const _compiledPatterns = {};
|
|
293
|
-
function compilePattern(pattern) {
|
|
94
|
+
function compilePattern(pattern, compiler) {
|
|
294
95
|
if (!(pattern in _compiledPatterns)) {
|
|
295
|
-
|
|
296
|
-
const re = pathToRegexp(pattern, paramNames);
|
|
297
|
-
_compiledPatterns[pattern] = {
|
|
298
|
-
matcher: re,
|
|
299
|
-
paramNames: paramNames.map((p) => p.name)
|
|
300
|
-
};
|
|
96
|
+
_compiledPatterns[pattern] = compiler(pattern);
|
|
301
97
|
}
|
|
302
98
|
return _compiledPatterns[pattern];
|
|
303
99
|
}
|
|
304
|
-
function extractParamNames(pattern) {
|
|
305
|
-
return compilePattern(pattern).paramNames;
|
|
100
|
+
function extractParamNames(pattern, compiler) {
|
|
101
|
+
return compilePattern(pattern, compiler).paramNames;
|
|
306
102
|
}
|
|
307
|
-
function extractParams(pattern, path) {
|
|
308
|
-
const cp = compilePattern(pattern);
|
|
103
|
+
function extractParams(pattern, path, compiler) {
|
|
104
|
+
const cp = compilePattern(pattern, compiler);
|
|
309
105
|
const matcher = cp.matcher;
|
|
310
106
|
const paramNames = cp.paramNames;
|
|
311
107
|
const match = path.match(matcher);
|
|
@@ -337,7 +133,7 @@ function injectParams(pattern, params) {
|
|
|
337
133
|
}
|
|
338
134
|
let paramValue = encodeURIComponent(params[paramName]);
|
|
339
135
|
if (lastChar === "*" || lastChar === "+") {
|
|
340
|
-
paramValue = paramValue.
|
|
136
|
+
paramValue = paramValue.replace("%2F", "/");
|
|
341
137
|
}
|
|
342
138
|
return paramValue;
|
|
343
139
|
});
|
|
@@ -508,10 +304,13 @@ const pathStripper = /#.*$/;
|
|
|
508
304
|
class BrowserLocation {
|
|
509
305
|
constructor(options = {}) {
|
|
510
306
|
this.path = options.path || "";
|
|
511
|
-
this.options = extend(
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
307
|
+
this.options = extend(
|
|
308
|
+
{
|
|
309
|
+
pushState: false,
|
|
310
|
+
root: "/"
|
|
311
|
+
},
|
|
312
|
+
options
|
|
313
|
+
);
|
|
515
314
|
this.locationBar = new History();
|
|
516
315
|
this.locationBar.onChange((path) => {
|
|
517
316
|
this.handleURL(`/${path || ""}`);
|
|
@@ -663,7 +462,11 @@ function transition(options) {
|
|
|
663
462
|
const startTime = Date.now();
|
|
664
463
|
log("---");
|
|
665
464
|
log("Transition #" + id, "to", path);
|
|
666
|
-
log(
|
|
465
|
+
log(
|
|
466
|
+
"Transition #" + id,
|
|
467
|
+
"routes:",
|
|
468
|
+
routes.map((r) => r.name)
|
|
469
|
+
);
|
|
667
470
|
log("Transition #" + id, "params:", params);
|
|
668
471
|
log("Transition #" + id, "query:", query);
|
|
669
472
|
let resolve2, reject;
|
|
@@ -752,7 +555,11 @@ function transition(options) {
|
|
|
752
555
|
let middlewarePromise;
|
|
753
556
|
try {
|
|
754
557
|
middlewarePromise = middleware.resolve ? middleware.resolve(transition2, prevResult) : prevResult;
|
|
755
|
-
invariant(
|
|
558
|
+
invariant(
|
|
559
|
+
transition2 !== middlewarePromise,
|
|
560
|
+
"Middleware %s returned a transition which resulted in a deadlock",
|
|
561
|
+
middlewareName
|
|
562
|
+
);
|
|
756
563
|
} catch (err) {
|
|
757
564
|
router2.state.activeTransition = null;
|
|
758
565
|
runError(router2, transition2, err);
|
|
@@ -796,34 +603,17 @@ function intercept(el, fn) {
|
|
|
796
603
|
if (clickable(e, el2)) fn(e, el2);
|
|
797
604
|
});
|
|
798
605
|
return function dispose() {
|
|
799
|
-
|
|
606
|
+
unbindEvent(el, "click", cb);
|
|
800
607
|
};
|
|
801
608
|
}
|
|
802
|
-
function link(element) {
|
|
803
|
-
var _a;
|
|
804
|
-
element = { parentNode: element };
|
|
805
|
-
const root = document;
|
|
806
|
-
while ((element = element.parentNode) && element !== document) {
|
|
807
|
-
if (((_a = element.tagName) == null ? void 0 : _a.toLowerCase()) === "a") {
|
|
808
|
-
return element;
|
|
809
|
-
}
|
|
810
|
-
if (element === root) {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
609
|
function delegate(el, type, fn) {
|
|
816
610
|
return bindEvent(el, type, function(e) {
|
|
817
|
-
const
|
|
818
|
-
const el2 = link(target);
|
|
611
|
+
const el2 = e.target.closest("a");
|
|
819
612
|
if (el2) {
|
|
820
613
|
fn(e, el2);
|
|
821
614
|
}
|
|
822
615
|
});
|
|
823
616
|
}
|
|
824
|
-
function undelegate(el, type, fn) {
|
|
825
|
-
unbindEvent(el, type, fn);
|
|
826
|
-
}
|
|
827
617
|
function clickable(e, el) {
|
|
828
618
|
if (which(e) !== 1) return;
|
|
829
619
|
if (e.metaKey || e.ctrlKey || e.shiftKey) return;
|
|
@@ -832,10 +622,7 @@ function clickable(e, el) {
|
|
|
832
622
|
if (el.getAttribute("data-bypass") !== null) return;
|
|
833
623
|
const href = el.getAttribute("href");
|
|
834
624
|
if (!href || href.length === 0) return;
|
|
835
|
-
if (
|
|
836
|
-
if (href.indexOf("http://") === 0 || href.indexOf("https://") === 0) return;
|
|
837
|
-
if (href.indexOf("mailto:") === 0) return;
|
|
838
|
-
if (href.indexOf("javascript:") === 0) return;
|
|
625
|
+
if (/^(#|https{0,1}:\/\/|mailto|javascript:)/i.test(href)) return;
|
|
839
626
|
return true;
|
|
840
627
|
}
|
|
841
628
|
function which(e) {
|
|
@@ -847,7 +634,7 @@ function defineLogger(router2, method, fn) {
|
|
|
847
634
|
router2[method] = typeof fn === "function" ? fn : () => {
|
|
848
635
|
};
|
|
849
636
|
}
|
|
850
|
-
|
|
637
|
+
const qs = {
|
|
851
638
|
parse(querystring) {
|
|
852
639
|
return querystring.split("&").reduce((acc, pair) => {
|
|
853
640
|
const parts = pair.split("=");
|
|
@@ -864,16 +651,58 @@ var qs = {
|
|
|
864
651
|
}, []).join("&");
|
|
865
652
|
}
|
|
866
653
|
};
|
|
867
|
-
|
|
654
|
+
function parse(input, loose) {
|
|
655
|
+
if (input instanceof RegExp) return { keys: false, pattern: input };
|
|
656
|
+
var c, o, tmp, ext, keys2 = [], pattern = "", arr = input.split("/");
|
|
657
|
+
arr[0] || arr.shift();
|
|
658
|
+
while (tmp = arr.shift()) {
|
|
659
|
+
c = tmp[0];
|
|
660
|
+
if (c === "*") {
|
|
661
|
+
keys2.push(c);
|
|
662
|
+
pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
|
|
663
|
+
} else if (c === ":") {
|
|
664
|
+
o = tmp.indexOf("?", 1);
|
|
665
|
+
ext = tmp.indexOf(".", 1);
|
|
666
|
+
keys2.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
|
|
667
|
+
pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
|
|
668
|
+
if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
|
|
669
|
+
} else {
|
|
670
|
+
pattern += "/" + tmp;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
keys: keys2,
|
|
675
|
+
pattern: new RegExp("^" + pattern + "/?$", "i")
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
const splatRegex = /:(\w+)\*/;
|
|
679
|
+
function patternCompiler(pattern) {
|
|
680
|
+
const splatMatch = splatRegex.exec(pattern);
|
|
681
|
+
const normalizedPattern = splatMatch ? pattern.replace(splatRegex, "*") : pattern;
|
|
682
|
+
const { pattern: matcher, keys: keys2 } = parse(normalizedPattern);
|
|
683
|
+
const paramNames = splatMatch ? keys2.map((key) => key === "*" ? splatMatch[1] : key) : keys2;
|
|
684
|
+
return {
|
|
685
|
+
matcher,
|
|
686
|
+
paramNames
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
let Router$1 = class Router {
|
|
690
|
+
/**
|
|
691
|
+
* @param {RouterOptions} [options]
|
|
692
|
+
*/
|
|
868
693
|
constructor(options = {}) {
|
|
869
694
|
this.nextId = 1;
|
|
870
695
|
this.state = {};
|
|
871
696
|
this.middleware = [];
|
|
872
|
-
this.options = extend(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
697
|
+
this.options = extend(
|
|
698
|
+
{
|
|
699
|
+
location: "browser",
|
|
700
|
+
logError: true,
|
|
701
|
+
qs,
|
|
702
|
+
patternCompiler
|
|
703
|
+
},
|
|
704
|
+
options
|
|
705
|
+
);
|
|
877
706
|
defineLogger(this, "log", this.options.log);
|
|
878
707
|
defineLogger(this, "logError", this.options.logError);
|
|
879
708
|
if (options.routes) {
|
|
@@ -883,7 +712,7 @@ class Router {
|
|
|
883
712
|
/**
|
|
884
713
|
* Add a middleware
|
|
885
714
|
* @param {Function} middleware
|
|
886
|
-
* @return {
|
|
715
|
+
* @return {Router}
|
|
887
716
|
* @api public
|
|
888
717
|
*/
|
|
889
718
|
use(middleware, options = {}) {
|
|
@@ -894,8 +723,8 @@ class Router {
|
|
|
894
723
|
}
|
|
895
724
|
/**
|
|
896
725
|
* Add the route map
|
|
897
|
-
* @param {
|
|
898
|
-
* @return {
|
|
726
|
+
* @param {routeCallback | RouteDef[]} routes
|
|
727
|
+
* @return {Router}
|
|
899
728
|
* @api public
|
|
900
729
|
*/
|
|
901
730
|
map(routes) {
|
|
@@ -904,11 +733,13 @@ class Router {
|
|
|
904
733
|
const dupes = {};
|
|
905
734
|
const abstracts = {};
|
|
906
735
|
eachBranch({ routes: this.routes }, [], (routes2) => {
|
|
907
|
-
let path = routes2.reduce(
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
736
|
+
let path = routes2.reduce(
|
|
737
|
+
(memo, r) => (
|
|
738
|
+
// and keep resetting the trailing slash
|
|
739
|
+
(r.path[0] === "/" ? r.path : `${memo}/${r.path}`).replace(/\/$/, "")
|
|
740
|
+
),
|
|
741
|
+
""
|
|
742
|
+
);
|
|
912
743
|
if (path === "") {
|
|
913
744
|
path = "/";
|
|
914
745
|
}
|
|
@@ -941,7 +772,9 @@ class Router {
|
|
|
941
772
|
path
|
|
942
773
|
});
|
|
943
774
|
if (dupes[path] && lastRoute.path !== "") {
|
|
944
|
-
throw new Error(
|
|
775
|
+
throw new Error(
|
|
776
|
+
`Routes ${dupes[path]} and ${lastRoute.name} have the same url path '${path}'`
|
|
777
|
+
);
|
|
945
778
|
}
|
|
946
779
|
dupes[path] = lastRoute.name;
|
|
947
780
|
});
|
|
@@ -957,8 +790,8 @@ class Router {
|
|
|
957
790
|
}
|
|
958
791
|
/**
|
|
959
792
|
* Starts listening to the location changes.
|
|
960
|
-
* @param {
|
|
961
|
-
* @return {
|
|
793
|
+
* @param {String} [path]
|
|
794
|
+
* @return {Transition} initial transition
|
|
962
795
|
*
|
|
963
796
|
* @api public
|
|
964
797
|
*/
|
|
@@ -977,10 +810,10 @@ class Router {
|
|
|
977
810
|
}
|
|
978
811
|
/**
|
|
979
812
|
* Transition to a different route. Passe in url or a route name followed by params and query
|
|
980
|
-
* @param {String}
|
|
981
|
-
* @param {Object} params Optional
|
|
982
|
-
* @param {Object} query Optional
|
|
983
|
-
* @return {
|
|
813
|
+
* @param {String} name url or route name
|
|
814
|
+
* @param {Object} [params] Optional
|
|
815
|
+
* @param {Object} [query] Optional
|
|
816
|
+
* @return {Transition} transition
|
|
984
817
|
*
|
|
985
818
|
* @api public
|
|
986
819
|
*/
|
|
@@ -993,10 +826,10 @@ class Router {
|
|
|
993
826
|
/**
|
|
994
827
|
* Like transitionTo, but doesn't leave an entry in the browser's history,
|
|
995
828
|
* so clicking back will skip this route
|
|
996
|
-
* @param {String}
|
|
997
|
-
* @param {
|
|
998
|
-
* @param {
|
|
999
|
-
* @return {
|
|
829
|
+
* @param {String} name url or route name followed by params and query
|
|
830
|
+
* @param {Record<string, any>} [params]
|
|
831
|
+
* @param {Record<string, any>} [query]
|
|
832
|
+
* @return {Transition} transition
|
|
1000
833
|
*
|
|
1001
834
|
* @api public
|
|
1002
835
|
*/
|
|
@@ -1006,8 +839,8 @@ class Router {
|
|
|
1006
839
|
/**
|
|
1007
840
|
* Create an href
|
|
1008
841
|
* @param {String} name target route name
|
|
1009
|
-
* @param {Object} params
|
|
1010
|
-
* @param {Object} query
|
|
842
|
+
* @param {Object} [params]
|
|
843
|
+
* @param {Object} [query]
|
|
1011
844
|
* @return {String} href
|
|
1012
845
|
*
|
|
1013
846
|
* @api public
|
|
@@ -1046,8 +879,9 @@ class Router {
|
|
|
1046
879
|
/**
|
|
1047
880
|
* Check if the given route/params/query combo is active
|
|
1048
881
|
* @param {String} name target route name
|
|
1049
|
-
* @param {
|
|
1050
|
-
* @param {
|
|
882
|
+
* @param {Record<string, any>} [params]
|
|
883
|
+
* @param {Record<string, any>} [query]
|
|
884
|
+
* @param {Boolean} [exact]
|
|
1051
885
|
* @return {Boolean}
|
|
1052
886
|
*
|
|
1053
887
|
* @api public
|
|
@@ -1063,6 +897,11 @@ class Router {
|
|
|
1063
897
|
}
|
|
1064
898
|
/**
|
|
1065
899
|
* @api private
|
|
900
|
+
* @param {String} method pushState or replaceState
|
|
901
|
+
* @param {String} name target route name
|
|
902
|
+
* @param {Object} [params]
|
|
903
|
+
* @param {Object} [query]
|
|
904
|
+
* @return {Transition} transition
|
|
1066
905
|
*/
|
|
1067
906
|
doTransition(method, name, params, query) {
|
|
1068
907
|
const previousUrl = this.location.getURL();
|
|
@@ -1096,9 +935,9 @@ class Router {
|
|
|
1096
935
|
let params;
|
|
1097
936
|
let routes = [];
|
|
1098
937
|
const pathWithoutQuery = withoutQuery(path);
|
|
1099
|
-
const qs2 = this.options
|
|
938
|
+
const { qs: qs2, patternCompiler: patternCompiler2 } = this.options;
|
|
1100
939
|
this.matchers.some((matcher) => {
|
|
1101
|
-
params = extractParams(matcher.path, pathWithoutQuery);
|
|
940
|
+
params = extractParams(matcher.path, pathWithoutQuery, patternCompiler2);
|
|
1102
941
|
if (params) {
|
|
1103
942
|
routes = matcher.routes;
|
|
1104
943
|
return true;
|
|
@@ -1114,11 +953,16 @@ class Router {
|
|
|
1114
953
|
return {
|
|
1115
954
|
name: route.name,
|
|
1116
955
|
path: route.path,
|
|
1117
|
-
params: pick(params, extractParamNames(route.path)),
|
|
956
|
+
params: pick(params, extractParamNames(route.path, patternCompiler2)),
|
|
1118
957
|
options: clone(route.options)
|
|
1119
958
|
};
|
|
1120
959
|
}
|
|
1121
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
*
|
|
963
|
+
* @param {string} path
|
|
964
|
+
* @returns {Transition}
|
|
965
|
+
*/
|
|
1122
966
|
dispatch(path) {
|
|
1123
967
|
const match = this.match(path);
|
|
1124
968
|
const query = match.query;
|
|
@@ -1157,6 +1001,7 @@ class Router {
|
|
|
1157
1001
|
* Create the default location.
|
|
1158
1002
|
* This is used when no custom location is passed to
|
|
1159
1003
|
* the listen call.
|
|
1004
|
+
* @param {LocationParam} path
|
|
1160
1005
|
* @return {Object} location
|
|
1161
1006
|
*
|
|
1162
1007
|
* @api private
|
|
@@ -1180,42 +1025,41 @@ class Router {
|
|
|
1180
1025
|
logError(...args) {
|
|
1181
1026
|
console.error(...args);
|
|
1182
1027
|
}
|
|
1183
|
-
}
|
|
1184
|
-
function defaultClickHandler(event,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
router2.transitionTo(router2.location.removeRoot(link2.getAttribute("href")));
|
|
1188
|
-
}
|
|
1028
|
+
};
|
|
1029
|
+
function defaultClickHandler(event, link, router2) {
|
|
1030
|
+
event.preventDefault();
|
|
1031
|
+
router2.transitionTo(router2.location.removeRoot(link.getAttribute("href")));
|
|
1189
1032
|
}
|
|
1190
1033
|
function interceptLinks(router2, el = document, clickHandler = defaultClickHandler) {
|
|
1191
|
-
return intercept(el, (event,
|
|
1034
|
+
return intercept(el, (event, link) => clickHandler(event, link, router2));
|
|
1192
1035
|
}
|
|
1193
1036
|
const resolved = Promise.resolve();
|
|
1194
1037
|
let routeElMap = /* @__PURE__ */ Object.create(null);
|
|
1195
1038
|
let routeComponentMap = /* @__PURE__ */ Object.create(null);
|
|
1039
|
+
let routePropertiesMap = /* @__PURE__ */ Object.create(null);
|
|
1196
1040
|
let router, rootOutlet, rootOutletEl;
|
|
1197
1041
|
function parseNumber(value) {
|
|
1198
1042
|
const n = parseFloat(value);
|
|
1199
1043
|
const isNumeric = value == n;
|
|
1200
1044
|
return isNumeric ? n : value;
|
|
1201
1045
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
if (result !== void 0) {
|
|
1210
|
-
const format = this.format;
|
|
1211
|
-
if (format === "number") {
|
|
1212
|
-
result = parseNumber(result);
|
|
1213
|
-
} else if (typeof format === "function") {
|
|
1214
|
-
result = format(result);
|
|
1215
|
-
}
|
|
1046
|
+
function getFormattedValue(value, format) {
|
|
1047
|
+
let v = value;
|
|
1048
|
+
if (v !== void 0) {
|
|
1049
|
+
if (format === "number") {
|
|
1050
|
+
v = parseNumber(value);
|
|
1051
|
+
} else if (typeof format === "function") {
|
|
1052
|
+
v = format(value);
|
|
1216
1053
|
}
|
|
1217
|
-
return result;
|
|
1218
1054
|
}
|
|
1055
|
+
return v;
|
|
1056
|
+
}
|
|
1057
|
+
function fromValue(value) {
|
|
1058
|
+
return {
|
|
1059
|
+
init(setValue) {
|
|
1060
|
+
setValue(value);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1219
1063
|
}
|
|
1220
1064
|
function create(instance) {
|
|
1221
1065
|
router = instance;
|
|
@@ -1225,6 +1069,7 @@ function destroy() {
|
|
|
1225
1069
|
router = null;
|
|
1226
1070
|
routeElMap = /* @__PURE__ */ Object.create(null);
|
|
1227
1071
|
routeComponentMap = /* @__PURE__ */ Object.create(null);
|
|
1072
|
+
routePropertiesMap = /* @__PURE__ */ Object.create(null);
|
|
1228
1073
|
rootOutletEl = null;
|
|
1229
1074
|
}
|
|
1230
1075
|
function isEqual(obj1, obj2) {
|
|
@@ -1233,7 +1078,7 @@ function isEqual(obj1, obj2) {
|
|
|
1233
1078
|
}
|
|
1234
1079
|
function getOutlet(el) {
|
|
1235
1080
|
const renderRoot = el.shadowRoot || el;
|
|
1236
|
-
return renderRoot.querySelector(el.constructor.outlet || "
|
|
1081
|
+
return renderRoot.querySelector(el.constructor.outlet || "router-outlet");
|
|
1237
1082
|
}
|
|
1238
1083
|
function resolveRootOutlet() {
|
|
1239
1084
|
if (rootOutletEl) return rootOutletEl;
|
|
@@ -1265,6 +1110,19 @@ function getChangingIndex(prevRoutes, currentRoutes) {
|
|
|
1265
1110
|
}
|
|
1266
1111
|
return index;
|
|
1267
1112
|
}
|
|
1113
|
+
function runPropertyHookMethod(transition2, routes, method) {
|
|
1114
|
+
for (let i = 0; i < routes.length; i++) {
|
|
1115
|
+
const { route } = routes[i];
|
|
1116
|
+
const propertiesData = routePropertiesMap[route.name];
|
|
1117
|
+
for (const { hooks, set } of Object.values(propertiesData)) {
|
|
1118
|
+
hooks.forEach((hook) => {
|
|
1119
|
+
if (typeof hook[method] === "function") {
|
|
1120
|
+
hook[method](transition2, set);
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1268
1126
|
async function runLifeCycle(transition2, routes, prefix, suffix) {
|
|
1269
1127
|
for (let i = 0; i < routes.length; i++) {
|
|
1270
1128
|
let result;
|
|
@@ -1290,7 +1148,44 @@ async function runLifeCycle(transition2, routes, prefix, suffix) {
|
|
|
1290
1148
|
function resolveModule(value) {
|
|
1291
1149
|
return value && value.__esModule ? value.default : value;
|
|
1292
1150
|
}
|
|
1293
|
-
|
|
1151
|
+
function initPropertyHook(value) {
|
|
1152
|
+
if (value && typeof value === "object") return value;
|
|
1153
|
+
return fromValue(value);
|
|
1154
|
+
}
|
|
1155
|
+
function initProperties(route) {
|
|
1156
|
+
let propertiesData = routePropertiesMap[route.name];
|
|
1157
|
+
if (!propertiesData) {
|
|
1158
|
+
propertiesData = routePropertiesMap[route.name] = /* @__PURE__ */ Object.create(null);
|
|
1159
|
+
const properties = route.options.properties;
|
|
1160
|
+
if (properties) {
|
|
1161
|
+
for (const [name, hookOrValue] of Object.entries(properties)) {
|
|
1162
|
+
const hooks = Array.isArray(hookOrValue) ? hookOrValue.map(initPropertyHook) : [initPropertyHook(hookOrValue)];
|
|
1163
|
+
const set = (v, format) => {
|
|
1164
|
+
const propertyData = propertiesData[name];
|
|
1165
|
+
const newValue = getFormattedValue(v, format);
|
|
1166
|
+
if (propertyData.value === newValue) return;
|
|
1167
|
+
propertyData.value = newValue;
|
|
1168
|
+
const el = routeElMap[route.name];
|
|
1169
|
+
if (el) {
|
|
1170
|
+
el[name] = newValue;
|
|
1171
|
+
}
|
|
1172
|
+
hooks.forEach((hook) => {
|
|
1173
|
+
if (typeof hook.update === "function") {
|
|
1174
|
+
hook.update(newValue, el);
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
};
|
|
1178
|
+
propertiesData[name] = { hooks, set };
|
|
1179
|
+
hooks.forEach((hook) => {
|
|
1180
|
+
if (typeof hook.init === "function") {
|
|
1181
|
+
hook.init(set);
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
async function resolveRoutes(routes) {
|
|
1294
1189
|
const result = [];
|
|
1295
1190
|
for (const route of routes) {
|
|
1296
1191
|
let el = route.options.reuse ? routeElMap[route.name] : void 0;
|
|
@@ -1303,17 +1198,16 @@ async function resolveComponents(routes) {
|
|
|
1303
1198
|
routeElMap[route.name] = el;
|
|
1304
1199
|
el.$router = router;
|
|
1305
1200
|
}
|
|
1201
|
+
initProperties(route);
|
|
1306
1202
|
result.push({ el, route });
|
|
1307
1203
|
}
|
|
1308
1204
|
return result;
|
|
1309
1205
|
}
|
|
1310
|
-
function applyProperties(
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1206
|
+
function applyProperties(el, route) {
|
|
1207
|
+
const propertiesData = routePropertiesMap[route.name];
|
|
1208
|
+
Object.entries(propertiesData).forEach(([name, { value }]) => {
|
|
1209
|
+
el[name] = value;
|
|
1210
|
+
});
|
|
1317
1211
|
}
|
|
1318
1212
|
const removedEls = /* @__PURE__ */ new WeakSet();
|
|
1319
1213
|
const outletCurrentEl = /* @__PURE__ */ new WeakMap();
|
|
@@ -1325,7 +1219,7 @@ async function renderElements(transition2, activated, changingIndex) {
|
|
|
1325
1219
|
const el = routeElMap[route.name];
|
|
1326
1220
|
if (el) {
|
|
1327
1221
|
el.$route = routeState;
|
|
1328
|
-
applyProperties(
|
|
1222
|
+
applyProperties(el, route);
|
|
1329
1223
|
}
|
|
1330
1224
|
}
|
|
1331
1225
|
for (let i = 0; i < activated.length; i++) {
|
|
@@ -1340,7 +1234,7 @@ async function renderElements(transition2, activated, changingIndex) {
|
|
|
1340
1234
|
removedEls.add(currentEl);
|
|
1341
1235
|
}
|
|
1342
1236
|
el.$route = routeState;
|
|
1343
|
-
applyProperties(
|
|
1237
|
+
applyProperties(el, route);
|
|
1344
1238
|
outletEl.appendChild(el);
|
|
1345
1239
|
outletCurrentEl.set(outletEl, el);
|
|
1346
1240
|
await (el.updateComplete || resolved);
|
|
@@ -1371,15 +1265,17 @@ async function resolve(transition2) {
|
|
|
1371
1265
|
}
|
|
1372
1266
|
await runLifeCycle(transition2, deactivated, "before", "Leave");
|
|
1373
1267
|
if (transition2.isCancelled) return;
|
|
1374
|
-
const activated = await
|
|
1268
|
+
const activated = await resolveRoutes(transition2.routes.slice(changingIndex));
|
|
1375
1269
|
await runLifeCycle(transition2, activated, "before", "Enter");
|
|
1376
1270
|
if (transition2.isCancelled) return;
|
|
1271
|
+
runPropertyHookMethod(transition2, activated, "enter");
|
|
1377
1272
|
await renderElements(transition2, activated, changingIndex);
|
|
1378
1273
|
updateDOMTree(activated, deactivated);
|
|
1379
1274
|
transition2.activated = activated;
|
|
1380
1275
|
transition2.deactivated = deactivated;
|
|
1381
1276
|
}
|
|
1382
1277
|
function done(transition2) {
|
|
1278
|
+
runPropertyHookMethod(transition2, transition2.deactivated, "leave");
|
|
1383
1279
|
runLifeCycle(transition2, transition2.deactivated, "after", "Leave");
|
|
1384
1280
|
runLifeCycle(transition2, transition2.activated, "after", "Enter");
|
|
1385
1281
|
}
|
|
@@ -1389,6 +1285,13 @@ const wc = {
|
|
|
1389
1285
|
resolve,
|
|
1390
1286
|
done
|
|
1391
1287
|
};
|
|
1288
|
+
class Router2 extends Router$1 {
|
|
1289
|
+
constructor(options) {
|
|
1290
|
+
super(options);
|
|
1291
|
+
this.use(wc);
|
|
1292
|
+
this.use(routerLinks);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1392
1295
|
let eventPrefix;
|
|
1393
1296
|
function trigger(name, detail) {
|
|
1394
1297
|
window.dispatchEvent(new CustomEvent(`${eventPrefix}${name}`, { detail }));
|
|
@@ -1416,15 +1319,14 @@ const events = {
|
|
|
1416
1319
|
class Routerx extends WJElement {
|
|
1417
1320
|
/**
|
|
1418
1321
|
* Creates an instance of Routerx.
|
|
1419
|
-
*
|
|
1420
|
-
* @constructor
|
|
1322
|
+
* @class
|
|
1421
1323
|
*/
|
|
1422
1324
|
constructor() {
|
|
1423
1325
|
super();
|
|
1424
1326
|
__publicField(this, "className", "Routerx");
|
|
1425
1327
|
/**
|
|
1426
1328
|
* Sets the breadcrumb for the transition.
|
|
1427
|
-
* @param {
|
|
1329
|
+
* @param {object} transition The transition object.
|
|
1428
1330
|
*/
|
|
1429
1331
|
__publicField(this, "setBreadcrumb", (transition2) => {
|
|
1430
1332
|
let breadcrumb = [
|
|
@@ -1442,8 +1344,7 @@ class Routerx extends WJElement {
|
|
|
1442
1344
|
});
|
|
1443
1345
|
/**
|
|
1444
1346
|
* Resets the scroll position.
|
|
1445
|
-
*
|
|
1446
|
-
* @param {Object} transition - The transition.
|
|
1347
|
+
* @param {object} transition The transition object.
|
|
1447
1348
|
*/
|
|
1448
1349
|
__publicField(this, "resetScrollPosition", (transition2) => {
|
|
1449
1350
|
window.scrollTo(0, 0);
|
|
@@ -1451,7 +1352,6 @@ class Routerx extends WJElement {
|
|
|
1451
1352
|
}
|
|
1452
1353
|
/**
|
|
1453
1354
|
* Returns the list of attributes to observe for changes.
|
|
1454
|
-
*
|
|
1455
1355
|
* @static
|
|
1456
1356
|
* @returns {Array<string>}
|
|
1457
1357
|
*/
|
|
@@ -1466,17 +1366,14 @@ class Routerx extends WJElement {
|
|
|
1466
1366
|
}
|
|
1467
1367
|
/**
|
|
1468
1368
|
* Sets up the router after the component is drawn.
|
|
1469
|
-
* @params {Object} context - The context for drawing.
|
|
1470
|
-
* @params {Object} store - The store for drawing.
|
|
1471
|
-
* @params {Object} params - The parameters for drawing.
|
|
1472
1369
|
*/
|
|
1473
|
-
|
|
1370
|
+
beforeDraw() {
|
|
1474
1371
|
const htmlString = this.outerHTML;
|
|
1475
1372
|
const parser = new DOMParser();
|
|
1476
1373
|
const htmlDocument = parser.parseFromString(htmlString, "text/html");
|
|
1477
1374
|
const rootElement = htmlDocument.querySelector("wje-router");
|
|
1478
1375
|
const routes = this.parseElement(rootElement).root;
|
|
1479
|
-
this.router = new
|
|
1376
|
+
this.router = new Router2({
|
|
1480
1377
|
outlet: this.outlet || "wje-router-outlet",
|
|
1481
1378
|
log: false,
|
|
1482
1379
|
logError: true,
|
|
@@ -1485,8 +1382,6 @@ class Routerx extends WJElement {
|
|
|
1485
1382
|
});
|
|
1486
1383
|
this.router.map(routes);
|
|
1487
1384
|
this.router.use(this.setBreadcrumb);
|
|
1488
|
-
this.router.use(wc);
|
|
1489
|
-
this.router.use(routerLinks);
|
|
1490
1385
|
this.router.use(events);
|
|
1491
1386
|
this.router.use(this.resetScrollPosition);
|
|
1492
1387
|
this.router.listen();
|
|
@@ -1494,9 +1389,8 @@ class Routerx extends WJElement {
|
|
|
1494
1389
|
}
|
|
1495
1390
|
/**
|
|
1496
1391
|
* Parses an element and returns an object representation.
|
|
1497
|
-
*
|
|
1498
|
-
* @
|
|
1499
|
-
* @returns {Object} The object representation of the element.
|
|
1392
|
+
* @param {Element} element The element to parse.
|
|
1393
|
+
* @returns {object} The object representation of the element.
|
|
1500
1394
|
*/
|
|
1501
1395
|
parseElement(element) {
|
|
1502
1396
|
const obj = {};
|
|
@@ -1506,7 +1400,7 @@ class Routerx extends WJElement {
|
|
|
1506
1400
|
const attributeValue = attributes[i].value;
|
|
1507
1401
|
if (attributeName === "component" && attributeValue.indexOf(".js") > -1) {
|
|
1508
1402
|
obj.component = () => import(
|
|
1509
|
-
/*vite-ignore*/
|
|
1403
|
+
/* @vite-ignore */
|
|
1510
1404
|
attributeValue
|
|
1511
1405
|
);
|
|
1512
1406
|
} else {
|
|
@@ -1528,9 +1422,6 @@ class Routerx extends WJElement {
|
|
|
1528
1422
|
}
|
|
1529
1423
|
return obj;
|
|
1530
1424
|
}
|
|
1531
|
-
setRouteParamsToStore(transition2) {
|
|
1532
|
-
this.store.dispatch(this.defaultStoreActions.addAction("params")(transition2.params));
|
|
1533
|
-
}
|
|
1534
1425
|
/**
|
|
1535
1426
|
* Cleans up before the component is disconnected.
|
|
1536
1427
|
*/
|