godown 1.0.42 → 1.0.44
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.ts +35 -0
- package/out/conf.d.ts +18 -0
- package/out/conf.d.ts.map +1 -0
- package/out/conf.js +21 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -1
- package/out/react/items.d.ts +1 -0
- package/out/react/items.d.ts.map +1 -1
- package/out/react/items.js +5 -0
- package/out/react/view.d.ts +1 -0
- package/out/react/view.d.ts.map +1 -1
- package/out/react/view.js +5 -0
- package/out/src/deps.d.ts +3 -3
- package/out/src/deps.d.ts.map +1 -1
- package/out/src/deps.js +3 -3
- package/out/src/effect/std.d.ts +2 -2
- package/out/src/effect/std.d.ts.map +1 -1
- package/out/src/effect/std.js +2 -2
- package/out/src/glob.d.ts +1 -1
- package/out/src/glob.d.ts.map +1 -1
- package/out/src/glob.js +3 -3
- package/out/src/group/std.d.ts +2 -2
- package/out/src/group/std.d.ts.map +1 -1
- package/out/src/group/std.js +2 -2
- package/out/src/input-form/base-input.d.ts +1 -1
- package/out/src/input-form/base-input.d.ts.map +1 -1
- package/out/src/input-form/base-input.js +5 -0
- package/out/src/input-form/exp-input.d.ts +1 -2
- package/out/src/input-form/exp-input.d.ts.map +1 -1
- package/out/src/input-form/exp-input.js +4 -3
- package/out/src/input-form/label-input.d.ts +1 -2
- package/out/src/input-form/label-input.d.ts.map +1 -1
- package/out/src/input-form/label-input.js +4 -3
- package/out/src/input-form/search-input.d.ts +1 -1
- package/out/src/input-form/search-input.d.ts.map +1 -1
- package/out/src/input-form/search-input.js +4 -3
- package/out/src/input-form/select-input.d.ts +6 -6
- package/out/src/input-form/select-input.d.ts.map +1 -1
- package/out/src/input-form/select-input.js +54 -45
- package/out/src/input-form/split-input.d.ts +3 -1
- package/out/src/input-form/split-input.d.ts.map +1 -1
- package/out/src/input-form/split-input.js +11 -3
- package/out/src/input-form/std.d.ts +7 -3
- package/out/src/input-form/std.d.ts.map +1 -1
- package/out/src/input-form/std.js +18 -5
- package/out/src/items/index.d.ts +1 -0
- package/out/src/items/index.d.ts.map +1 -1
- package/out/src/items/index.js +1 -0
- package/out/src/items/link-a.d.ts +19 -0
- package/out/src/items/link-a.d.ts.map +1 -0
- package/out/src/items/link-a.js +96 -0
- package/out/src/items/std.d.ts +2 -2
- package/out/src/items/std.d.ts.map +1 -1
- package/out/src/items/std.js +2 -2
- package/out/src/items/super-a.d.ts +0 -2
- package/out/src/items/super-a.d.ts.map +1 -1
- package/out/src/items/super-a.js +4 -14
- package/out/src/layout/nav-layout.js +1 -1
- package/out/src/layout/std.d.ts +2 -2
- package/out/src/layout/std.d.ts.map +1 -1
- package/out/src/layout/std.js +2 -2
- package/out/src/view/index.d.ts +1 -0
- package/out/src/view/index.d.ts.map +1 -1
- package/out/src/view/index.js +1 -0
- package/out/src/view/route-view.d.ts +33 -0
- package/out/src/view/route-view.d.ts.map +1 -0
- package/out/src/view/route-view.js +239 -0
- package/out/src/view/std.d.ts +2 -2
- package/out/src/view/std.d.ts.map +1 -1
- package/out/src/view/std.js +2 -2
- package/out/src/with.d.ts.map +1 -1
- package/out/src/with.js +6 -5
- package/package.json +2 -1
package/out/src/view/index.js
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
import { LitElement } from "../deps.js";
|
2
|
+
export declare class RouteView extends LitElement {
|
3
|
+
_routesSort: any[];
|
4
|
+
params: Record<string, string>;
|
5
|
+
constructor();
|
6
|
+
static: boolean;
|
7
|
+
type: "united" | "child" | "field";
|
8
|
+
baseURL: string;
|
9
|
+
path: string;
|
10
|
+
override: boolean;
|
11
|
+
compoent: any;
|
12
|
+
set routes(v: any[]);
|
13
|
+
get routes(): any[];
|
14
|
+
static styles: import("lit").CSSResult;
|
15
|
+
render(): () => any;
|
16
|
+
connectedCallback(): void;
|
17
|
+
render_united(): any;
|
18
|
+
render_slotted(): import("lit-html").TemplateResult<1>;
|
19
|
+
render_field(): any;
|
20
|
+
useRouter(): {
|
21
|
+
path: string;
|
22
|
+
params: Record<string, string>;
|
23
|
+
};
|
24
|
+
getComponent(usedRouteTemplate: string): any;
|
25
|
+
childCompoent(): import("lit-html").TemplateResult<1>;
|
26
|
+
static sortRoutesPaths(ObjectArrayIncludePath: any[]): Array<{
|
27
|
+
path: string;
|
28
|
+
}>;
|
29
|
+
static useWhichRoute(ObjectArrayIncludePath: any[], path: string, baseURL?: string): string;
|
30
|
+
static parseRouterParams(routeTemplate: string, originpath: string): Record<string, string>;
|
31
|
+
static updateAll(): void;
|
32
|
+
}
|
33
|
+
//# sourceMappingURL=route-view.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"route-view.d.ts","sourceRoot":"","sources":["../../../src/view/route-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,UAAU,EAAY,MAAM,YAAY,CAAC;AAC3E,qBACa,SAAU,SAAQ,UAAU;IACvC,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;IAKF,MAAM,UAAS;IAChC,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAC9C,OAAO,SAAO;IACd,IAAI,SAA4B;IACf,QAAQ,UAAS;IAClB,QAAQ,MAAQ;IAC5C,IAAI,MAAM,CAAC,CAAC,OAAA,EAWX;IACD,IAAI,MAAM,UAET;IACD,MAAM,CAAC,MAAM,0BAAgC;IAC7C,MAAM;IASN,iBAAiB,IAAI,IAAI;IAkBzB,aAAa;IAMb,cAAc;IAId,YAAY;IAMZ,SAAS;;;;IAMT,YAAY,CAAC,iBAAiB,EAAE,MAAM;IAOtC,aAAa;IA6Bb,MAAM,CAAC,eAAe,CAAC,sBAAsB,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;KAAE,CAAC;IA+B/E,MAAM,CAAC,aAAa,CAAC,sBAAsB,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAY;IAqBvF,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAoB3F,MAAM,CAAC,SAAS;CAUjB"}
|
@@ -0,0 +1,239 @@
|
|
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
|
+
let RouteView = RouteView_1 = class RouteView extends LitElement {
|
10
|
+
constructor() {
|
11
|
+
super();
|
12
|
+
this.static = false;
|
13
|
+
this.type = "united";
|
14
|
+
this.baseURL = "/";
|
15
|
+
this.path = window.location.pathname;
|
16
|
+
this.override = false;
|
17
|
+
this.compoent = null;
|
18
|
+
this._routesSort = [];
|
19
|
+
}
|
20
|
+
set routes(v) {
|
21
|
+
if (Object.prototype.toString.call(v) !== "[object Array]") {
|
22
|
+
this._routesSort = [];
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
if (this.static) {
|
26
|
+
this._routesSort = v;
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
this._routesSort = RouteView_1.sortRoutesPaths(v);
|
30
|
+
}
|
31
|
+
this.requestUpdate();
|
32
|
+
}
|
33
|
+
get routes() {
|
34
|
+
return this._routesSort;
|
35
|
+
}
|
36
|
+
render() {
|
37
|
+
if (this.type === "child") {
|
38
|
+
return () => { var _a; return (_a = this.render_slotted()) !== null && _a !== void 0 ? _a : html `<slot></slot>`; };
|
39
|
+
}
|
40
|
+
if (this.type === "field") {
|
41
|
+
return () => { var _a; return (_a = this.render_field()) !== null && _a !== void 0 ? _a : html `<slot></slot>`; };
|
42
|
+
}
|
43
|
+
return () => { var _a; return (_a = this.render_united()) !== null && _a !== void 0 ? _a : html `<slot></slot>`; };
|
44
|
+
}
|
45
|
+
connectedCallback() {
|
46
|
+
super.connectedCallback();
|
47
|
+
window.addEventListener("popstate", (e) => {
|
48
|
+
this.path = window.location.pathname;
|
49
|
+
});
|
50
|
+
if (!this.override)
|
51
|
+
return;
|
52
|
+
const self = this;
|
53
|
+
const pushHistory = history.pushState;
|
54
|
+
history.pushState = function () {
|
55
|
+
pushHistory.apply(this, arguments);
|
56
|
+
self.path = window.location.pathname;
|
57
|
+
};
|
58
|
+
const replaceHistory = history.replaceState;
|
59
|
+
history.replaceState = function () {
|
60
|
+
replaceHistory.apply(this, arguments);
|
61
|
+
self.path = window.location.pathname;
|
62
|
+
};
|
63
|
+
}
|
64
|
+
render_united() {
|
65
|
+
const slottedCompoent = this.render_slotted();
|
66
|
+
if (slottedCompoent)
|
67
|
+
return slottedCompoent;
|
68
|
+
const fieldCompoent = this.render_field();
|
69
|
+
return fieldCompoent;
|
70
|
+
}
|
71
|
+
render_slotted() {
|
72
|
+
const childCompoent = this.childCompoent();
|
73
|
+
return childCompoent;
|
74
|
+
}
|
75
|
+
render_field() {
|
76
|
+
const usedRouteTemplate = RouteView_1.useWhichRoute(this.routes, this.path);
|
77
|
+
const RouterParmasObject = RouteView_1.parseRouterParams(usedRouteTemplate, this.path);
|
78
|
+
this.params = RouterParmasObject;
|
79
|
+
return this.getComponent(usedRouteTemplate);
|
80
|
+
}
|
81
|
+
useRouter() {
|
82
|
+
return {
|
83
|
+
path: this.path,
|
84
|
+
params: this.params,
|
85
|
+
};
|
86
|
+
}
|
87
|
+
getComponent(usedRouteTemplate) {
|
88
|
+
if (!usedRouteTemplate)
|
89
|
+
return;
|
90
|
+
const route = this.routes.find((r) => r.path === usedRouteTemplate);
|
91
|
+
if (!route)
|
92
|
+
return null;
|
93
|
+
const { component } = route;
|
94
|
+
return component;
|
95
|
+
}
|
96
|
+
childCompoent() {
|
97
|
+
const childNodes = this.querySelectorAll(":scope > *[slot]");
|
98
|
+
const slots = Array.from(childNodes).map((node) => {
|
99
|
+
const slotname = node.getAttribute("slot");
|
100
|
+
if (slotname.startsWith("/")) {
|
101
|
+
return {
|
102
|
+
path: slotname,
|
103
|
+
slotname
|
104
|
+
};
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
return {
|
108
|
+
path: this.baseURL + "/" + slotname,
|
109
|
+
slotname
|
110
|
+
};
|
111
|
+
}
|
112
|
+
});
|
113
|
+
let slotsSort;
|
114
|
+
if (this.static) {
|
115
|
+
slotsSort = slots;
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
slotsSort = RouteView_1.sortRoutesPaths(slots);
|
119
|
+
}
|
120
|
+
const usedSlot = RouteView_1.useWhichRoute(slotsSort, this.path);
|
121
|
+
const slotElement = slots.find((s) => s.path === usedSlot);
|
122
|
+
const RouterParmasObject = RouteView_1.parseRouterParams(usedSlot, this.path);
|
123
|
+
this.params = RouterParmasObject;
|
124
|
+
if (!slotElement)
|
125
|
+
return null;
|
126
|
+
return html `<slot name="${slotElement.slotname}"></slot>`;
|
127
|
+
}
|
128
|
+
static sortRoutesPaths(ObjectArrayIncludePath) {
|
129
|
+
const all = ObjectArrayIncludePath.map((route) => {
|
130
|
+
const path = route.path;
|
131
|
+
const pathArray = path.split("/");
|
132
|
+
const Single_dynamicRouteCount = pathArray.filter((p) => p.startsWith(":")).length;
|
133
|
+
return {
|
134
|
+
...route,
|
135
|
+
path,
|
136
|
+
Single_dynamicRouteCount,
|
137
|
+
};
|
138
|
+
});
|
139
|
+
const allSort = all.sort((a, b) => a.Single_dynamicRouteCount - b.Single_dynamicRouteCount);
|
140
|
+
const multi = allSort.filter((route) => {
|
141
|
+
const path = route.path;
|
142
|
+
const pathArray = path.split("/");
|
143
|
+
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
144
|
+
return double_dynamicRouteCount > 0;
|
145
|
+
});
|
146
|
+
multi.sort((a, b) => {
|
147
|
+
const aIndex = a.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
148
|
+
const bIndex = b.path.split("/").findIndex((template) => template.startsWith("...") || template.startsWith("*"));
|
149
|
+
return aIndex !== -1 && bIndex !== -1 ? bIndex - aIndex : 0;
|
150
|
+
});
|
151
|
+
const sigle = allSort.filter((route) => {
|
152
|
+
const path = route.path;
|
153
|
+
const pathArray = path.split("/");
|
154
|
+
const double_dynamicRouteCount = pathArray.filter((p) => p.startsWith("...") || p.startsWith("*")).length;
|
155
|
+
return double_dynamicRouteCount === 0;
|
156
|
+
});
|
157
|
+
return [...sigle, ...multi];
|
158
|
+
}
|
159
|
+
static useWhichRoute(ObjectArrayIncludePath, path, baseURL = "/") {
|
160
|
+
const originpath = path.startsWith("/") ? path : baseURL + path;
|
161
|
+
const routes = ObjectArrayIncludePath;
|
162
|
+
const pathTemplateArray = routes.map((r) => r.path);
|
163
|
+
for (const pathTemplate of pathTemplateArray) {
|
164
|
+
const pathsplits = pathTemplate.split("/").slice(1);
|
165
|
+
const reg = new RegExp(pathsplits.map((s) => {
|
166
|
+
if (s.startsWith(":")) {
|
167
|
+
return "[^/]+";
|
168
|
+
}
|
169
|
+
else if (s.startsWith("...") || s.startsWith("*")) {
|
170
|
+
return ".*";
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
return s;
|
174
|
+
}
|
175
|
+
}).join("/") + "$");
|
176
|
+
if (reg.test(originpath)) {
|
177
|
+
return pathTemplate;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
return null;
|
181
|
+
}
|
182
|
+
static parseRouterParams(routeTemplate, originpath) {
|
183
|
+
if (!routeTemplate || !originpath)
|
184
|
+
return;
|
185
|
+
const params = {};
|
186
|
+
const originpathArray = originpath.split("/").splice(1);
|
187
|
+
const routeTemplateSplit = routeTemplate.split("/").splice(1);
|
188
|
+
for (const [index, path] of routeTemplateSplit.entries()) {
|
189
|
+
if (path.startsWith(":")) {
|
190
|
+
params[path.slice(1)] = originpathArray[index];
|
191
|
+
}
|
192
|
+
else if (path.startsWith("*")) {
|
193
|
+
params[path.slice(1)] = originpathArray.slice(index).join("/");
|
194
|
+
}
|
195
|
+
else if (path.startsWith("...")) {
|
196
|
+
params[path.slice(1)] = originpathArray.slice(index).join("/");
|
197
|
+
}
|
198
|
+
else {
|
199
|
+
if (path !== originpathArray[index]) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
return params;
|
205
|
+
}
|
206
|
+
static updateAll() {
|
207
|
+
const routeViewTagName = conf.namemap.get("route-view");
|
208
|
+
const routeViewArray = document.querySelectorAll(routeViewTagName);
|
209
|
+
const ArrayLength = routeViewArray.length;
|
210
|
+
if (ArrayLength > 0) {
|
211
|
+
for (let index = 0, ArrayItem; ArrayItem = routeViewArray[index]; index++) {
|
212
|
+
ArrayItem.path = window.location.pathname;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
};
|
217
|
+
RouteView.styles = css `:host{display:contents}`;
|
218
|
+
__decorate([
|
219
|
+
property({ type: Boolean })
|
220
|
+
], RouteView.prototype, "static", void 0);
|
221
|
+
__decorate([
|
222
|
+
property()
|
223
|
+
], RouteView.prototype, "type", void 0);
|
224
|
+
__decorate([
|
225
|
+
property()
|
226
|
+
], RouteView.prototype, "baseURL", void 0);
|
227
|
+
__decorate([
|
228
|
+
property()
|
229
|
+
], RouteView.prototype, "path", void 0);
|
230
|
+
__decorate([
|
231
|
+
property({ type: Boolean })
|
232
|
+
], RouteView.prototype, "override", void 0);
|
233
|
+
__decorate([
|
234
|
+
property({ type: Object })
|
235
|
+
], RouteView.prototype, "compoent", void 0);
|
236
|
+
RouteView = RouteView_1 = __decorate([
|
237
|
+
define("route-view")
|
238
|
+
], RouteView);
|
239
|
+
export { RouteView };
|
package/out/src/view/std.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"std.d.ts","sourceRoot":"","sources":["../../../src/view/std.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"std.d.ts","sourceRoot":"","sources":["../../../src/view/std.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAO,MAAM,YAAY,CAAC;AAC1C,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;CAAI;AAChD,eAAO,MAAM,UAAU,yBAiCtB,CAAC"}
|
package/out/src/view/std.js
CHANGED
package/out/src/with.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"with.d.ts","sourceRoot":"","sources":["../../src/with.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,SAAU,MAAM,YAAY,wBAAwB,mBAAmB,wBAAwB,
|
1
|
+
{"version":3,"file":"with.d.ts","sourceRoot":"","sources":["../../src/with.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,SAAU,MAAM,YAAY,wBAAwB,mBAAmB,wBAAwB,SAOjH,CAAC;AACF;;;;EAIE;AACF,eAAO,MAAM,MAAM,WAAY,MAAM,GAAG,MAAM,QAAQ;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;CAAE,SAK3G,CAAC;AACF;;;EAGE;AACF,eAAO,MAAM,MAAM,oBAqBlB,CAAC;AACF;;;EAGE;AACF,eAAO,MAAM,KAAK,oBAuBjB,CAAC"}
|
package/out/src/with.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { conf } from "
|
1
|
+
import { conf } from "../conf.js";
|
2
2
|
export const define = (name, options) => (constructor) => {
|
3
|
-
var _a;
|
4
|
-
|
5
|
-
if (customElements.get(
|
6
|
-
customElements.define(
|
3
|
+
var _a, _b;
|
4
|
+
const tagname = conf === null || conf === void 0 ? void 0 : conf.tag(name);
|
5
|
+
if (customElements.get(tagname) === undefined) {
|
6
|
+
customElements.define(tagname, constructor, options);
|
7
7
|
(_a = conf === null || conf === void 0 ? void 0 : conf.enabled) === null || _a === void 0 ? void 0 : _a.push(name);
|
8
|
+
(_b = conf === null || conf === void 0 ? void 0 : conf.namemap) === null || _b === void 0 ? void 0 : _b.set(name, tagname);
|
8
9
|
}
|
9
10
|
};
|
10
11
|
/**
|
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "godown",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.44",
|
4
4
|
"main": "./out/index.js",
|
5
5
|
"exports": {
|
6
6
|
".": "./out/index.js",
|
7
7
|
"./out": "./out/index.js",
|
8
|
+
"./out/conf": "./out/conf.js",
|
8
9
|
"./out/react": "./out/react/index.js"
|
9
10
|
},
|
10
11
|
"type": "module",
|