godown 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conf.d.ts +18 -18
- package/conf.js +22 -22
- package/deps.d.ts +7 -7
- package/deps.js +7 -7
- package/effect/index.d.ts +3 -3
- package/effect/index.js +3 -3
- package/effect/ov-effect.d.ts +23 -23
- package/effect/ov-effect.js +63 -63
- package/effect/ro-effect.d.ts +19 -19
- package/effect/ro-effect.js +76 -76
- package/effect/std.d.ts +3 -3
- package/effect/std.js +3 -3
- package/effect/tw-effect.d.ts +21 -21
- package/effect/tw-effect.js +90 -90
- package/glob.d.ts +8 -8
- package/glob.js +9 -9
- package/group/avatar-group.d.ts +20 -20
- package/group/avatar-group.js +88 -88
- package/group/button-group.d.ts +12 -12
- package/group/button-group.js +26 -26
- package/group/details-group.d.ts +16 -16
- package/group/details-group.js +51 -51
- package/group/index.d.ts +3 -3
- package/group/index.js +3 -3
- package/group/std.d.ts +3 -3
- package/group/std.js +3 -3
- package/index.d.ts +7 -7
- package/index.js +7 -7
- package/input-form/base-input.d.ts +32 -32
- package/input-form/base-input.js +129 -129
- package/input-form/exp-input.d.ts +22 -22
- package/input-form/exp-input.js +67 -67
- package/input-form/index.d.ts +8 -8
- package/input-form/index.js +8 -8
- package/input-form/label-input.d.ts +21 -21
- package/input-form/label-input.js +69 -69
- package/input-form/search-input.d.ts +36 -36
- package/input-form/search-input.js +162 -162
- package/input-form/select-input.d.ts +31 -31
- package/input-form/select-input.js +256 -256
- package/input-form/sign-form.d.ts +25 -25
- package/input-form/sign-form.js +147 -147
- package/input-form/split-input.d.ts +26 -26
- package/input-form/split-input.js +127 -127
- package/input-form/std.d.ts +19 -19
- package/input-form/std.js +56 -55
- package/input-form/switch-input.d.ts +22 -22
- package/input-form/switch-input.js +73 -73
- package/items/alert-item.d.ts +16 -16
- package/items/alert-item.js +46 -46
- package/items/avatar-anchor.d.ts +19 -19
- package/items/avatar-anchor.js +62 -62
- package/items/base-button.d.ts +16 -16
- package/items/base-button.js +44 -44
- package/items/dialog-item.d.ts +24 -24
- package/items/dialog-item.js +92 -92
- package/items/index.d.ts +7 -7
- package/items/index.js +7 -7
- package/items/link-a.d.ts +19 -19
- package/items/link-a.js +76 -76
- package/items/load-track.d.ts +20 -20
- package/items/load-track.js +76 -76
- package/items/std.d.ts +3 -3
- package/items/std.js +3 -3
- package/items/super-a.d.ts +15 -15
- package/items/super-a.js +46 -46
- package/layout/div-line.d.ts +15 -15
- package/layout/div-line.js +39 -39
- package/layout/drag-box.d.ts +25 -25
- package/layout/drag-box.js +88 -88
- package/layout/flex-flow.d.ts +13 -13
- package/layout/flex-flow.js +32 -32
- package/layout/index.d.ts +5 -5
- package/layout/index.js +5 -5
- package/layout/nav-aside.d.ts +13 -13
- package/layout/nav-aside.js +38 -38
- package/layout/nav-layout.d.ts +16 -16
- package/layout/nav-layout.js +51 -51
- package/layout/std.d.ts +4 -4
- package/layout/std.js +4 -4
- package/package.json +6 -5
- package/react/effect.d.ts +9 -9
- package/react/effect.d.ts.map +1 -1
- package/react/effect.js +33 -33
- package/react/group.d.ts +4 -4
- package/react/group.d.ts.map +1 -1
- package/react/group.js +19 -19
- package/react/index.d.ts +7 -7
- package/react/index.d.ts.map +1 -1
- package/react/index.js +7 -7
- package/react/input-form.d.ts +32 -32
- package/react/input-form.d.ts.map +1 -1
- package/react/input-form.js +65 -65
- package/react/items.d.ts +8 -8
- package/react/items.d.ts.map +1 -1
- package/react/items.js +39 -39
- package/react/layout.d.ts +6 -6
- package/react/layout.d.ts.map +1 -1
- package/react/layout.js +29 -29
- package/react/view.d.ts +6 -6
- package/react/view.d.ts.map +1 -1
- package/react/view.js +29 -29
- package/view/details-expand.d.ts +18 -18
- package/view/details-expand.js +53 -53
- package/view/down-drop.d.ts +18 -18
- package/view/down-drop.js +71 -71
- package/view/index.d.ts +5 -5
- package/view/index.js +5 -5
- package/view/menu-list.d.ts +16 -16
- package/view/menu-list.js +48 -48
- package/view/route-view.d.ts +57 -57
- package/view/route-view.js +257 -257
- package/view/scroll-x.d.ts +14 -14
- package/view/scroll-x.js +47 -47
- package/view/std.d.ts +4 -4
- package/view/std.js +4 -4
- package/with.d.ts +27 -27
- package/with.js +77 -77
package/view/route-view.d.ts
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
import type { TemplateResult } from "lit";
|
2
|
-
import { LitElement } from "../deps.js";
|
3
|
-
export declare class RouteView extends LitElement {
|
4
|
-
_routes: Array<{
|
5
|
-
path: string;
|
6
|
-
[key: string]: any;
|
7
|
-
}>;
|
8
|
-
params: Record<string, string>;
|
9
|
-
static: boolean;
|
10
|
-
type: "united" | "child" | "slotted" | "field";
|
11
|
-
baseURL: string;
|
12
|
-
path: string;
|
13
|
-
override: boolean;
|
14
|
-
compoent: any;
|
15
|
-
set routes(v: {
|
16
|
-
[key: string]: any;
|
17
|
-
path: string;
|
18
|
-
}[]);
|
19
|
-
get routes(): {
|
20
|
-
[key: string]: any;
|
21
|
-
path: string;
|
22
|
-
}[];
|
23
|
-
static styles: import("lit").CSSResult;
|
24
|
-
render(): TemplateResult
|
25
|
-
useRouter(): {
|
26
|
-
path: string;
|
27
|
-
params: Record<string, string>;
|
28
|
-
};
|
29
|
-
connectedCallback(): void;
|
30
|
-
render_united(): TemplateResult
|
31
|
-
render_slotted(): TemplateResult
|
32
|
-
render_field(): TemplateResult
|
33
|
-
fieldComponent(usedRouteTemplate: string): null | TemplateResult;
|
34
|
-
slottedCompoent(usedRouteTemplate: string, ObjectArrayIncludePath: Array<{
|
35
|
-
path: string;
|
36
|
-
slotElement?: string;
|
37
|
-
[key: string]: any;
|
38
|
-
}>): null | TemplateResult;
|
39
|
-
static sortRoutesPaths(ObjectArrayIncludePath: Array<{
|
40
|
-
path: string;
|
41
|
-
[key: string]: any;
|
42
|
-
}>): Array<{
|
43
|
-
path: string;
|
44
|
-
}>;
|
45
|
-
static useWhichRoute(ObjectArrayIncludePath: Array<{
|
46
|
-
path: string;
|
47
|
-
[key: string]: any;
|
48
|
-
}>, path: string, baseURL?: string): string;
|
49
|
-
static parseRouterParams(routeTemplate: string, originpath: string): Record<string, string>;
|
50
|
-
static updateAll(): void;
|
51
|
-
}
|
52
|
-
export default RouteView;
|
53
|
-
declare global {
|
54
|
-
interface HTMLElementTagNameMap {
|
55
|
-
"route-view": RouteView;
|
56
|
-
}
|
57
|
-
}
|
1
|
+
import type { TemplateResult } from "lit";
|
2
|
+
import { LitElement } from "../deps.js";
|
3
|
+
export declare class RouteView extends LitElement {
|
4
|
+
_routes: Array<{
|
5
|
+
path: string;
|
6
|
+
[key: string]: any;
|
7
|
+
}>;
|
8
|
+
params: Record<string, string>;
|
9
|
+
static: boolean;
|
10
|
+
type: "united" | "child" | "slotted" | "field";
|
11
|
+
baseURL: string;
|
12
|
+
path: string;
|
13
|
+
override: boolean;
|
14
|
+
compoent: any;
|
15
|
+
set routes(v: {
|
16
|
+
[key: string]: any;
|
17
|
+
path: string;
|
18
|
+
}[]);
|
19
|
+
get routes(): {
|
20
|
+
[key: string]: any;
|
21
|
+
path: string;
|
22
|
+
}[];
|
23
|
+
static styles: import("lit").CSSResult;
|
24
|
+
render(): TemplateResult;
|
25
|
+
useRouter(): {
|
26
|
+
path: string;
|
27
|
+
params: Record<string, string>;
|
28
|
+
};
|
29
|
+
connectedCallback(): void;
|
30
|
+
render_united(): TemplateResult;
|
31
|
+
render_slotted(): TemplateResult;
|
32
|
+
render_field(): TemplateResult;
|
33
|
+
fieldComponent(usedRouteTemplate: string): null | TemplateResult;
|
34
|
+
slottedCompoent(usedRouteTemplate: string, ObjectArrayIncludePath: Array<{
|
35
|
+
path: string;
|
36
|
+
slotElement?: string;
|
37
|
+
[key: string]: any;
|
38
|
+
}>): null | TemplateResult;
|
39
|
+
static sortRoutesPaths(ObjectArrayIncludePath: Array<{
|
40
|
+
path: string;
|
41
|
+
[key: string]: any;
|
42
|
+
}>): Array<{
|
43
|
+
path: string;
|
44
|
+
}>;
|
45
|
+
static useWhichRoute(ObjectArrayIncludePath: Array<{
|
46
|
+
path: string;
|
47
|
+
[key: string]: any;
|
48
|
+
}>, path: string, baseURL?: string): string;
|
49
|
+
static parseRouterParams(routeTemplate: string, originpath: string): Record<string, string>;
|
50
|
+
static updateAll(): void;
|
51
|
+
}
|
52
|
+
export default RouteView;
|
53
|
+
declare global {
|
54
|
+
interface HTMLElementTagNameMap {
|
55
|
+
"route-view": RouteView;
|
56
|
+
}
|
57
|
+
}
|
58
58
|
//# sourceMappingURL=route-view.d.ts.map
|
package/view/route-view.js
CHANGED
@@ -1,261 +1,261 @@
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
-
};
|
7
|
-
var RouteView_1;
|
8
|
-
import { conf, css, define, html, LitElement, property } from "../deps.js";
|
9
|
-
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
10
|
-
let RouteView = RouteView_1 = class RouteView extends LitElement {
|
11
|
-
constructor() {
|
12
|
-
super(...arguments);
|
13
|
-
this._routes = [];
|
14
|
-
this.params = {};
|
15
|
-
this.static = false;
|
16
|
-
this.type = "united";
|
17
|
-
this.baseURL = "";
|
18
|
-
this.path = "";
|
19
|
-
this.override = false;
|
20
|
-
this.compoent = null;
|
21
|
-
}
|
22
|
-
set routes(v) {
|
23
|
-
if (Object.prototype.toString.call(v) !== "[object Array]") {
|
24
|
-
this._routes = [];
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
if (this.static) {
|
28
|
-
this._routes = v;
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
this._routes = RouteView_1.sortRoutesPaths(v);
|
32
|
-
}
|
33
|
-
this.requestUpdate();
|
34
|
-
}
|
35
|
-
get routes() {
|
36
|
-
return this._routes;
|
37
|
-
}
|
38
|
-
render() {
|
39
|
-
var _a, _b, _c;
|
40
|
-
if (this.type === "field") {
|
41
|
-
return (_a = this.render_field()) !== null && _a !== void 0 ? _a : html `<slot></slot>`;
|
42
|
-
}
|
43
|
-
if (this.type === "slotted" || this.type === "child") {
|
44
|
-
return (_b = this.render_slotted()) !== null && _b !== void 0 ? _b : html `<slot></slot>`;
|
45
|
-
}
|
46
|
-
return (_c = this.render_united()) !== null && _c !== void 0 ? _c : html `<slot></slot>`;
|
47
|
-
}
|
48
|
-
useRouter() {
|
49
|
-
return {
|
50
|
-
path: this.path,
|
51
|
-
params: this.params,
|
52
|
-
};
|
53
|
-
}
|
54
|
-
connectedCallback() {
|
55
|
-
super.connectedCallback();
|
56
|
-
this.path = window.location.pathname;
|
57
|
-
window.addEventListener("popstate", (e) => {
|
58
|
-
this.path = window.location.pathname;
|
59
|
-
});
|
60
|
-
if (!this.override)
|
61
|
-
return;
|
62
|
-
const pushHistory = history.pushState;
|
63
|
-
history.pushState = function () {
|
64
|
-
pushHistory.apply(this, arguments);
|
65
|
-
this.path = window.location.pathname;
|
66
|
-
};
|
67
|
-
const replaceHistory = history.replaceState;
|
68
|
-
history.replaceState = function () {
|
69
|
-
replaceHistory.apply(this, arguments);
|
70
|
-
this.path = window.location.pathname;
|
71
|
-
};
|
72
|
-
}
|
73
|
-
render_united() {
|
74
|
-
const slottedCompoent = this.render_slotted();
|
75
|
-
if (slottedCompoent)
|
76
|
-
return slottedCompoent;
|
77
|
-
const Compoent = this.render_field();
|
78
|
-
return Compoent;
|
79
|
-
}
|
80
|
-
render_slotted() {
|
81
|
-
const childNodes = this.querySelectorAll(":scope > *[slot]");
|
82
|
-
const slots = Array.from(childNodes).map((node) => {
|
83
|
-
const slotname = node.getAttribute("slot");
|
84
|
-
return {
|
85
|
-
path: this.baseURL + slotname,
|
86
|
-
slotname,
|
87
|
-
};
|
88
|
-
});
|
89
|
-
let slotsSort;
|
90
|
-
if (this.static) {
|
91
|
-
slotsSort = slots;
|
92
|
-
}
|
93
|
-
else {
|
94
|
-
slotsSort = RouteView_1.sortRoutesPaths(slots);
|
95
|
-
}
|
96
|
-
const usedRouteTemplate = RouteView_1.useWhichRoute(slotsSort, this.path);
|
97
|
-
const Compoent = this.slottedCompoent(usedRouteTemplate, slotsSort);
|
98
|
-
return Compoent;
|
99
|
-
}
|
100
|
-
render_field() {
|
101
|
-
const usedRouteTemplate = RouteView_1.useWhichRoute(this.routes, this.path);
|
102
|
-
const RouterParmasObject = RouteView_1.parseRouterParams(usedRouteTemplate, this.path);
|
103
|
-
this.params = RouterParmasObject;
|
104
|
-
const Compoent = this.fieldComponent(usedRouteTemplate);
|
105
|
-
return Compoent;
|
106
|
-
}
|
107
|
-
fieldComponent(usedRouteTemplate) {
|
108
|
-
if (!usedRouteTemplate)
|
109
|
-
return;
|
110
|
-
const route = this.routes.find((r) => r.path === usedRouteTemplate);
|
111
|
-
if (!route)
|
112
|
-
return null;
|
113
|
-
return route.component || (route.html ? unsafeHTML(route.html) : null);
|
114
|
-
}
|
115
|
-
slottedCompoent(usedRouteTemplate, ObjectArrayIncludePath) {
|
116
|
-
if (!usedRouteTemplate)
|
117
|
-
return;
|
118
|
-
const slotElement = ObjectArrayIncludePath.find((s) => s.path === usedRouteTemplate);
|
119
|
-
if (!slotElement)
|
120
|
-
return null;
|
121
|
-
const RouterParmasObject = RouteView_1.parseRouterParams(usedRouteTemplate, this.path);
|
122
|
-
this.params = RouterParmasObject;
|
123
|
-
return html `<slot name="${slotElement.slotname}"></slot>`;
|
124
|
-
}
|
125
|
-
static sortRoutesPaths(ObjectArrayIncludePath) {
|
126
|
-
const all = ObjectArrayIncludePath.map((route) => {
|
127
|
-
const path = route.path;
|
128
|
-
const pathArray = path.split("/");
|
129
|
-
const Single_dynamicRouteCount = pathArray.filter((p) => p.startsWith(":")).length;
|
130
|
-
return {
|
131
|
-
...route,
|
132
|
-
path,
|
133
|
-
Single_dynamicRouteCount,
|
134
|
-
};
|
135
|
-
});
|
136
|
-
const allSort = all.sort((a, b) => a.Single_dynamicRouteCount - b.Single_dynamicRouteCount);
|
137
|
-
const multi = allSort.filter((route) => {
|
138
|
-
const path = route.path;
|
139
|
-
const pathArray = path.split("/");
|
140
|
-
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
141
|
-
return double_dynamicRouteCount > 0;
|
142
|
-
});
|
143
|
-
multi.sort((a, b) => {
|
144
|
-
const aIndex = a.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
145
|
-
const bIndex = b.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
146
|
-
return aIndex !== -1 && bIndex !== -1 ? bIndex - aIndex : 0;
|
147
|
-
});
|
148
|
-
const sigle = allSort.filter((route) => {
|
149
|
-
const path = route.path;
|
150
|
-
const pathArray = path.split("/");
|
151
|
-
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
152
|
-
return double_dynamicRouteCount === 0;
|
153
|
-
});
|
154
|
-
return [...sigle, ...multi];
|
155
|
-
}
|
156
|
-
static useWhichRoute(ObjectArrayIncludePath, path, baseURL = "") {
|
157
|
-
const originpath = baseURL + path;
|
158
|
-
const originsplits = originpath.split("/").slice(1);
|
159
|
-
const routes = ObjectArrayIncludePath;
|
160
|
-
const pathTemplateArray = routes.map((r) => r.path);
|
161
|
-
for (const pathTemplate of pathTemplateArray) {
|
162
|
-
const pathsplits = pathTemplate.split("/").slice(1);
|
163
|
-
const ifmatched = pathsplits.every((pathsplit, index) => {
|
164
|
-
const originsplit = originsplits[index];
|
165
|
-
if (pathsplit.startsWith(":")) {
|
166
|
-
return originsplits.length <= pathsplits.length;
|
167
|
-
}
|
168
|
-
else if (pathsplit.startsWith("...")) {
|
169
|
-
return originsplits.length >= pathsplits.length;
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
return originsplits.length === pathsplits.length && originsplit === pathsplit;
|
173
|
-
}
|
174
|
-
});
|
175
|
-
if (ifmatched) {
|
176
|
-
return pathTemplate;
|
177
|
-
}
|
178
|
-
}
|
179
|
-
return null;
|
180
|
-
/*
|
181
|
-
const originpath: string = baseURL + path;
|
182
|
-
const routes = ObjectArrayIncludePath as Array<{ path?: string; }>;
|
183
|
-
const pathTemplateArray = routes.map((r) => r.path) as Array<string>;
|
184
|
-
for (const pathTemplate of pathTemplateArray) {
|
185
|
-
const pathsplits = pathTemplate.split("/").slice(1);
|
186
|
-
const reg = new RegExp(pathsplits.map((s: string) => {
|
187
|
-
if (s.startsWith(":")) {
|
188
|
-
return "^\/[^\/]+$";
|
189
|
-
} else if (s.startsWith("...") || s.startsWith("*")) {
|
190
|
-
return ".*";
|
191
|
-
} else {
|
192
|
-
return s;
|
193
|
-
}
|
194
|
-
}).join("/") + "$");
|
195
|
-
if (reg.test(originpath)) {
|
196
|
-
return pathTemplate;
|
197
|
-
}
|
198
|
-
}
|
199
|
-
return null;
|
200
|
-
*/
|
201
|
-
}
|
202
|
-
static parseRouterParams(routeTemplate, originpath) {
|
203
|
-
if (!routeTemplate || !originpath)
|
204
|
-
return;
|
205
|
-
const params = {};
|
206
|
-
const originpathArray = originpath.split("/").splice(1);
|
207
|
-
const routeTemplateSplit = routeTemplate.split("/").splice(1);
|
208
|
-
for (const [index, path] of routeTemplateSplit.entries()) {
|
209
|
-
if (path.startsWith(":")) {
|
210
|
-
params[path.slice(1)] = originpathArray[index];
|
211
|
-
}
|
212
|
-
else if (path.startsWith("*")) {
|
213
|
-
params[path.slice(1)] = originpathArray.slice(index).join("/");
|
214
|
-
}
|
215
|
-
else if (path.startsWith("...")) {
|
216
|
-
params[path.slice(3)] = originpathArray.slice(index).join("/");
|
217
|
-
}
|
218
|
-
else {
|
219
|
-
if (path !== originpathArray[index]) {
|
220
|
-
return;
|
221
|
-
}
|
222
|
-
}
|
223
|
-
}
|
224
|
-
return params;
|
225
|
-
}
|
226
|
-
static updateAll() {
|
227
|
-
const routeViewTagName = conf.namemap.get("route-view");
|
228
|
-
const routeViewArray = document.querySelectorAll(`${routeViewTagName}:not([override])`);
|
229
|
-
for (let index = 0, ArrayItem; (ArrayItem = routeViewArray[index]); index++) {
|
230
|
-
ArrayItem.path = window.location.pathname;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
};
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var RouteView_1;
|
8
|
+
import { conf, css, define, html, LitElement, property } from "../deps.js";
|
9
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
10
|
+
let RouteView = RouteView_1 = class RouteView extends LitElement {
|
11
|
+
constructor() {
|
12
|
+
super(...arguments);
|
13
|
+
this._routes = [];
|
14
|
+
this.params = {};
|
15
|
+
this.static = false;
|
16
|
+
this.type = "united";
|
17
|
+
this.baseURL = "";
|
18
|
+
this.path = "";
|
19
|
+
this.override = false;
|
20
|
+
this.compoent = null;
|
21
|
+
}
|
22
|
+
set routes(v) {
|
23
|
+
if (Object.prototype.toString.call(v) !== "[object Array]") {
|
24
|
+
this._routes = [];
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
if (this.static) {
|
28
|
+
this._routes = v;
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
this._routes = RouteView_1.sortRoutesPaths(v);
|
32
|
+
}
|
33
|
+
this.requestUpdate();
|
34
|
+
}
|
35
|
+
get routes() {
|
36
|
+
return this._routes;
|
37
|
+
}
|
38
|
+
render() {
|
39
|
+
var _a, _b, _c;
|
40
|
+
if (this.type === "field") {
|
41
|
+
return (_a = this.render_field()) !== null && _a !== void 0 ? _a : html `<slot></slot>`;
|
42
|
+
}
|
43
|
+
if (this.type === "slotted" || this.type === "child") {
|
44
|
+
return (_b = this.render_slotted()) !== null && _b !== void 0 ? _b : html `<slot></slot>`;
|
45
|
+
}
|
46
|
+
return (_c = this.render_united()) !== null && _c !== void 0 ? _c : html `<slot></slot>`;
|
47
|
+
}
|
48
|
+
useRouter() {
|
49
|
+
return {
|
50
|
+
path: this.path,
|
51
|
+
params: this.params,
|
52
|
+
};
|
53
|
+
}
|
54
|
+
connectedCallback() {
|
55
|
+
super.connectedCallback();
|
56
|
+
this.path = window.location.pathname;
|
57
|
+
window.addEventListener("popstate", (e) => {
|
58
|
+
this.path = window.location.pathname;
|
59
|
+
});
|
60
|
+
if (!this.override)
|
61
|
+
return;
|
62
|
+
const pushHistory = history.pushState;
|
63
|
+
history.pushState = function () {
|
64
|
+
pushHistory.apply(this, arguments);
|
65
|
+
this.path = window.location.pathname;
|
66
|
+
};
|
67
|
+
const replaceHistory = history.replaceState;
|
68
|
+
history.replaceState = function () {
|
69
|
+
replaceHistory.apply(this, arguments);
|
70
|
+
this.path = window.location.pathname;
|
71
|
+
};
|
72
|
+
}
|
73
|
+
render_united() {
|
74
|
+
const slottedCompoent = this.render_slotted();
|
75
|
+
if (slottedCompoent)
|
76
|
+
return slottedCompoent;
|
77
|
+
const Compoent = this.render_field();
|
78
|
+
return Compoent;
|
79
|
+
}
|
80
|
+
render_slotted() {
|
81
|
+
const childNodes = this.querySelectorAll(":scope > *[slot]");
|
82
|
+
const slots = Array.from(childNodes).map((node) => {
|
83
|
+
const slotname = node.getAttribute("slot");
|
84
|
+
return {
|
85
|
+
path: this.baseURL + slotname,
|
86
|
+
slotname,
|
87
|
+
};
|
88
|
+
});
|
89
|
+
let slotsSort;
|
90
|
+
if (this.static) {
|
91
|
+
slotsSort = slots;
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
slotsSort = RouteView_1.sortRoutesPaths(slots);
|
95
|
+
}
|
96
|
+
const usedRouteTemplate = RouteView_1.useWhichRoute(slotsSort, this.path);
|
97
|
+
const Compoent = this.slottedCompoent(usedRouteTemplate, slotsSort);
|
98
|
+
return Compoent;
|
99
|
+
}
|
100
|
+
render_field() {
|
101
|
+
const usedRouteTemplate = RouteView_1.useWhichRoute(this.routes, this.path);
|
102
|
+
const RouterParmasObject = RouteView_1.parseRouterParams(usedRouteTemplate, this.path);
|
103
|
+
this.params = RouterParmasObject;
|
104
|
+
const Compoent = this.fieldComponent(usedRouteTemplate);
|
105
|
+
return Compoent;
|
106
|
+
}
|
107
|
+
fieldComponent(usedRouteTemplate) {
|
108
|
+
if (!usedRouteTemplate)
|
109
|
+
return;
|
110
|
+
const route = this.routes.find((r) => r.path === usedRouteTemplate);
|
111
|
+
if (!route)
|
112
|
+
return null;
|
113
|
+
return route.component || (route.html ? unsafeHTML(route.html) : null);
|
114
|
+
}
|
115
|
+
slottedCompoent(usedRouteTemplate, ObjectArrayIncludePath) {
|
116
|
+
if (!usedRouteTemplate)
|
117
|
+
return;
|
118
|
+
const slotElement = ObjectArrayIncludePath.find((s) => s.path === usedRouteTemplate);
|
119
|
+
if (!slotElement)
|
120
|
+
return null;
|
121
|
+
const RouterParmasObject = RouteView_1.parseRouterParams(usedRouteTemplate, this.path);
|
122
|
+
this.params = RouterParmasObject;
|
123
|
+
return html `<slot name="${slotElement.slotname}"></slot>`;
|
124
|
+
}
|
125
|
+
static sortRoutesPaths(ObjectArrayIncludePath) {
|
126
|
+
const all = ObjectArrayIncludePath.map((route) => {
|
127
|
+
const path = route.path;
|
128
|
+
const pathArray = path.split("/");
|
129
|
+
const Single_dynamicRouteCount = pathArray.filter((p) => p.startsWith(":")).length;
|
130
|
+
return {
|
131
|
+
...route,
|
132
|
+
path,
|
133
|
+
Single_dynamicRouteCount,
|
134
|
+
};
|
135
|
+
});
|
136
|
+
const allSort = all.sort((a, b) => a.Single_dynamicRouteCount - b.Single_dynamicRouteCount);
|
137
|
+
const multi = allSort.filter((route) => {
|
138
|
+
const path = route.path;
|
139
|
+
const pathArray = path.split("/");
|
140
|
+
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
141
|
+
return double_dynamicRouteCount > 0;
|
142
|
+
});
|
143
|
+
multi.sort((a, b) => {
|
144
|
+
const aIndex = a.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
145
|
+
const bIndex = b.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
146
|
+
return aIndex !== -1 && bIndex !== -1 ? bIndex - aIndex : 0;
|
147
|
+
});
|
148
|
+
const sigle = allSort.filter((route) => {
|
149
|
+
const path = route.path;
|
150
|
+
const pathArray = path.split("/");
|
151
|
+
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
152
|
+
return double_dynamicRouteCount === 0;
|
153
|
+
});
|
154
|
+
return [...sigle, ...multi];
|
155
|
+
}
|
156
|
+
static useWhichRoute(ObjectArrayIncludePath, path, baseURL = "") {
|
157
|
+
const originpath = baseURL + path;
|
158
|
+
const originsplits = originpath.split("/").slice(1);
|
159
|
+
const routes = ObjectArrayIncludePath;
|
160
|
+
const pathTemplateArray = routes.map((r) => r.path);
|
161
|
+
for (const pathTemplate of pathTemplateArray) {
|
162
|
+
const pathsplits = pathTemplate.split("/").slice(1);
|
163
|
+
const ifmatched = pathsplits.every((pathsplit, index) => {
|
164
|
+
const originsplit = originsplits[index];
|
165
|
+
if (pathsplit.startsWith(":")) {
|
166
|
+
return originsplits.length <= pathsplits.length;
|
167
|
+
}
|
168
|
+
else if (pathsplit.startsWith("...")) {
|
169
|
+
return originsplits.length >= pathsplits.length;
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
return originsplits.length === pathsplits.length && originsplit === pathsplit;
|
173
|
+
}
|
174
|
+
});
|
175
|
+
if (ifmatched) {
|
176
|
+
return pathTemplate;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
return null;
|
180
|
+
/*
|
181
|
+
const originpath: string = baseURL + path;
|
182
|
+
const routes = ObjectArrayIncludePath as Array<{ path?: string; }>;
|
183
|
+
const pathTemplateArray = routes.map((r) => r.path) as Array<string>;
|
184
|
+
for (const pathTemplate of pathTemplateArray) {
|
185
|
+
const pathsplits = pathTemplate.split("/").slice(1);
|
186
|
+
const reg = new RegExp(pathsplits.map((s: string) => {
|
187
|
+
if (s.startsWith(":")) {
|
188
|
+
return "^\/[^\/]+$";
|
189
|
+
} else if (s.startsWith("...") || s.startsWith("*")) {
|
190
|
+
return ".*";
|
191
|
+
} else {
|
192
|
+
return s;
|
193
|
+
}
|
194
|
+
}).join("/") + "$");
|
195
|
+
if (reg.test(originpath)) {
|
196
|
+
return pathTemplate;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
return null;
|
200
|
+
*/
|
201
|
+
}
|
202
|
+
static parseRouterParams(routeTemplate, originpath) {
|
203
|
+
if (!routeTemplate || !originpath)
|
204
|
+
return;
|
205
|
+
const params = {};
|
206
|
+
const originpathArray = originpath.split("/").splice(1);
|
207
|
+
const routeTemplateSplit = routeTemplate.split("/").splice(1);
|
208
|
+
for (const [index, path] of routeTemplateSplit.entries()) {
|
209
|
+
if (path.startsWith(":")) {
|
210
|
+
params[path.slice(1)] = originpathArray[index];
|
211
|
+
}
|
212
|
+
else if (path.startsWith("*")) {
|
213
|
+
params[path.slice(1)] = originpathArray.slice(index).join("/");
|
214
|
+
}
|
215
|
+
else if (path.startsWith("...")) {
|
216
|
+
params[path.slice(3)] = originpathArray.slice(index).join("/");
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
if (path !== originpathArray[index]) {
|
220
|
+
return;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
return params;
|
225
|
+
}
|
226
|
+
static updateAll() {
|
227
|
+
const routeViewTagName = conf.namemap.get("route-view");
|
228
|
+
const routeViewArray = document.querySelectorAll(`${routeViewTagName}:not([override])`);
|
229
|
+
for (let index = 0, ArrayItem; (ArrayItem = routeViewArray[index]); index++) {
|
230
|
+
ArrayItem.path = window.location.pathname;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
};
|
234
234
|
RouteView.styles = css `
|
235
235
|
:host {
|
236
236
|
display: contents;
|
237
237
|
}
|
238
|
-
`;
|
239
|
-
__decorate([
|
240
|
-
property({ type: Boolean })
|
241
|
-
], RouteView.prototype, "static", void 0);
|
242
|
-
__decorate([
|
243
|
-
property()
|
244
|
-
], RouteView.prototype, "type", void 0);
|
245
|
-
__decorate([
|
246
|
-
property()
|
247
|
-
], RouteView.prototype, "baseURL", void 0);
|
248
|
-
__decorate([
|
249
|
-
property()
|
250
|
-
], RouteView.prototype, "path", void 0);
|
251
|
-
__decorate([
|
252
|
-
property({ type: Boolean })
|
253
|
-
], RouteView.prototype, "override", void 0);
|
254
|
-
__decorate([
|
255
|
-
property({ type: Object })
|
256
|
-
], RouteView.prototype, "compoent", void 0);
|
257
|
-
RouteView = RouteView_1 = __decorate([
|
258
|
-
define("route-view")
|
259
|
-
], RouteView);
|
260
|
-
export { RouteView };
|
261
|
-
export default RouteView;
|
238
|
+
`;
|
239
|
+
__decorate([
|
240
|
+
property({ type: Boolean })
|
241
|
+
], RouteView.prototype, "static", void 0);
|
242
|
+
__decorate([
|
243
|
+
property()
|
244
|
+
], RouteView.prototype, "type", void 0);
|
245
|
+
__decorate([
|
246
|
+
property()
|
247
|
+
], RouteView.prototype, "baseURL", void 0);
|
248
|
+
__decorate([
|
249
|
+
property()
|
250
|
+
], RouteView.prototype, "path", void 0);
|
251
|
+
__decorate([
|
252
|
+
property({ type: Boolean })
|
253
|
+
], RouteView.prototype, "override", void 0);
|
254
|
+
__decorate([
|
255
|
+
property({ type: Object })
|
256
|
+
], RouteView.prototype, "compoent", void 0);
|
257
|
+
RouteView = RouteView_1 = __decorate([
|
258
|
+
define("route-view")
|
259
|
+
], RouteView);
|
260
|
+
export { RouteView };
|
261
|
+
export default RouteView;
|
package/view/scroll-x.d.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
import STD from "./std.js";
|
2
|
-
export declare class ScrollX extends STD {
|
3
|
-
static styles: import("lit").CSSResult;
|
4
|
-
get _section(): HTMLElement;
|
5
|
-
render(): import("lit-html").TemplateResult<1>;
|
6
|
-
firstUpdated(): void;
|
7
|
-
resize(): void;
|
8
|
-
}
|
9
|
-
export default ScrollX;
|
10
|
-
declare global {
|
11
|
-
interface HTMLElementTagNameMap {
|
12
|
-
"scroll-x": ScrollX;
|
13
|
-
}
|
14
|
-
}
|
1
|
+
import STD from "./std.js";
|
2
|
+
export declare class ScrollX extends STD {
|
3
|
+
static styles: import("lit").CSSResult;
|
4
|
+
get _section(): HTMLElement;
|
5
|
+
render(): import("lit-html").TemplateResult<1>;
|
6
|
+
firstUpdated(): void;
|
7
|
+
resize(): void;
|
8
|
+
}
|
9
|
+
export default ScrollX;
|
10
|
+
declare global {
|
11
|
+
interface HTMLElementTagNameMap {
|
12
|
+
"scroll-x": ScrollX;
|
13
|
+
}
|
14
|
+
}
|
15
15
|
//# sourceMappingURL=scroll-x.d.ts.map
|