@dooboostore/simple-web-component 1.0.16 → 1.0.18
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 +109 -48
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/appendChild.js +48 -0
- package/dist/cjs/decorators/appendChild.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +216 -67
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/index.js +2 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/{innerHtml.js → onConnectedInnerHtml.js} +8 -8
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +7 -0
- package/dist/cjs/decorators/query.js +38 -0
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +32 -0
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/replaceChildren.js +53 -0
- package/dist/cjs/decorators/replaceChildren.js.map +7 -0
- package/dist/cjs/elements/SwcAppEngine.js +2 -1
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +188 -0
- package/dist/cjs/elements/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/SwcChoose.js +155 -0
- package/dist/cjs/elements/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/SwcIf.js +167 -0
- package/dist/cjs/elements/SwcIf.js.map +7 -0
- package/dist/cjs/elements/SwcLoop.js +246 -0
- package/dist/cjs/elements/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/SwcSubTemplates.js +65 -0
- package/dist/cjs/elements/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/index.js +7 -0
- package/dist/cjs/elements/index.js.map +2 -2
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +74 -37
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/appendChild.js +29 -0
- package/dist/esm/decorators/appendChild.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +216 -67
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/index.js +2 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/{innerHtml.js → onConnectedInnerHtml.js} +5 -5
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +7 -0
- package/dist/esm/decorators/query.js +38 -0
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +32 -0
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/replaceChildren.js +34 -0
- package/dist/esm/decorators/replaceChildren.js.map +7 -0
- package/dist/esm/elements/SwcAppEngine.js +2 -1
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +169 -0
- package/dist/esm/elements/SwcAsync.js.map +7 -0
- package/dist/esm/elements/SwcChoose.js +136 -0
- package/dist/esm/elements/SwcChoose.js.map +7 -0
- package/dist/esm/elements/SwcIf.js +148 -0
- package/dist/esm/elements/SwcIf.js.map +7 -0
- package/dist/esm/elements/SwcLoop.js +227 -0
- package/dist/esm/elements/SwcLoop.js.map +7 -0
- package/dist/esm/elements/SwcSubTemplates.js +46 -0
- package/dist/esm/elements/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/index.js +7 -0
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +74 -37
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1226 -149
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +1 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/appendChild.d.ts +17 -0
- package/dist/types/decorators/appendChild.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/onConnectedInnerHtml.d.ts +15 -0
- package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +1 -0
- package/dist/types/decorators/query.d.ts +0 -2
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +0 -2
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/replaceChildren.d.ts +9 -0
- package/dist/types/decorators/replaceChildren.d.ts.map +1 -0
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAsync.d.ts +16 -0
- package/dist/types/elements/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/SwcChoose.d.ts +13 -0
- package/dist/types/elements/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/SwcIf.d.ts +15 -0
- package/dist/types/elements/SwcIf.d.ts.map +1 -0
- package/dist/types/elements/SwcLoop.d.ts +20 -0
- package/dist/types/elements/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/SwcSubTemplates.d.ts +13 -0
- package/dist/types/elements/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +7 -0
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +8 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +16 -10
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1226 -149
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +10 -3
- package/src/decorators/addEventListener.ts +1 -0
- package/src/decorators/appendChild.ts +42 -0
- package/src/decorators/elementDefine.ts +225 -71
- package/src/decorators/index.ts +2 -1
- package/src/decorators/{innerHtml.ts → onConnectedInnerHtml.ts} +7 -6
- package/src/decorators/query.ts +32 -2
- package/src/decorators/queryAll.ts +32 -2
- package/src/decorators/replaceChildren.ts +35 -0
- package/src/elements/SwcAppEngine.ts +2 -1
- package/src/elements/SwcAsync.ts +163 -0
- package/src/elements/SwcChoose.ts +127 -0
- package/src/elements/SwcIf.ts +134 -0
- package/src/elements/SwcLoop.ts +215 -0
- package/src/elements/SwcSubTemplates.ts +19 -0
- package/src/elements/index.ts +8 -3
- package/src/index.ts +5 -2
- package/src/types.ts +9 -1
- package/src/utils/Utils.ts +86 -36
- package/dist/cjs/decorators/innerHtml.js.map +0 -7
- package/dist/esm/decorators/innerHtml.js.map +0 -7
- package/dist/types/decorators/innerHtml.d.ts +0 -12
- package/dist/types/decorators/innerHtml.d.ts.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/SwcChoose.ts"],
|
|
4
|
+
"sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\nimport { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\nimport { SwcWhen, SwcOtherwise } from './SwcSubTemplates';\n\n@elementDefine({ name: 'swc-choose', extends: 'template' })\nexport class SwcChoose extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this._value = nv;\n this.render();\n }\n\n private _executeCallback(attrName: string, extraArgs: Record<string, any>) {\n const script = this.getAttribute(attrName);\n if (!script) return;\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });\n } catch (e) {\n console.error(`[SwcChoose] Error in ${attrName}:`, e);\n }\n }\n\n @changedAttribute('on-get-value')\n private refresh(newValue?: string | null) {\n const script = newValue !== undefined ? newValue : this.getAttribute('on-get-value');\n if (!script) {\n this.value = null;\n return;\n }\n if (!this.parentElement) return;\n\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n const result = FunctionUtils.executeReturn({\n script,\n context: this,\n args: helperHostSet\n });\n this.value = result;\n } catch (e) {\n console.error('[SwcChoose] Error in on-get-value:', e);\n }\n }\n\n private render() {\n this.cleanup();\n if (!this.parentElement) return;\n\n const templates = Array.from(this.content.querySelectorAll('template'));\n let selected: HTMLTemplateElement | null = null;\n let otherwise: HTMLTemplateElement | null = null;\n let defaultTmp: HTMLTemplateElement | null = null;\n\n for (const t of templates) {\n const is = t.getAttribute('is');\n if (is === 'swc-when') {\n const whenVal = t.getAttribute('value');\n if (String(whenVal) === String(this._value)) {\n selected = t;\n break;\n }\n } else if (is === 'swc-otherwise') {\n otherwise = t;\n } else if (is === 'swc-default') {\n defaultTmp = t;\n }\n }\n\n const targetTemplate = (this._value == null ? defaultTmp : selected) || otherwise || defaultTmp;\n if (targetTemplate) {\n const clone = targetTemplate.content.cloneNode(true) as DocumentFragment;\n const nodes = Array.from(clone.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n const ctx = {\n $value: this._value,\n $nodes: nodes,\n $elements: elements,\n $firstNode: nodes[0],\n $lastNode: nodes[nodes.length - 1],\n $firstElement: elements[0],\n $lastElement: elements[elements.length - 1]\n };\n\n // Execution Callbacks\n this._executeCallback('on-clone-nodes', ctx);\n nodes.forEach((node, nodeIndex) => {\n if (node instanceof HTMLElement) {\n (node as any).__swc_host = this;\n }\n this._executeCallback('on-clone-node', {\n ...ctx,\n $node: node,\n $nodeIndex: nodeIndex,\n $isElement: node.nodeType === 1\n });\n });\n\n this._nodes = nodes;\n this.parentElement.insertBefore(clone, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => {\n if (n.parentElement) n.parentElement.remove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B,SAAK,QAAO;EACd;;AA7FQ,WAAA;MADP,0CAAiB,cAAc;;;;;AAxBrB,YAAS,WAAA;MADrB,oCAAc,EAAE,MAAM,cAAc,SAAS,WAAU,CAAE;GAC7C,SAAS;",
|
|
6
|
+
"names": ["SwcChoose"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var SwcIf_exports = {};
|
|
19
|
+
__export(SwcIf_exports, {
|
|
20
|
+
SwcIf: () => SwcIf
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(SwcIf_exports);
|
|
23
|
+
var import_elementDefine = require("../decorators/elementDefine");
|
|
24
|
+
var import_changedAttribute = require("../decorators/changedAttribute");
|
|
25
|
+
var import_Utils = require("../utils/Utils");
|
|
26
|
+
var import_FunctionUtils = require("@dooboostore/core/function/FunctionUtils");
|
|
27
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
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;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
};
|
|
33
|
+
var __metadata = function(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
};
|
|
36
|
+
let SwcIf = class SwcIf2 extends HTMLTemplateElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this._nodes = [];
|
|
40
|
+
this._value = null;
|
|
41
|
+
}
|
|
42
|
+
get value() {
|
|
43
|
+
return this._value;
|
|
44
|
+
}
|
|
45
|
+
set value(nv) {
|
|
46
|
+
this._value = nv;
|
|
47
|
+
this.render();
|
|
48
|
+
}
|
|
49
|
+
_getTarget() {
|
|
50
|
+
const script = this.getAttribute("on-get-portal");
|
|
51
|
+
if (!script)
|
|
52
|
+
return null;
|
|
53
|
+
try {
|
|
54
|
+
const res = import_FunctionUtils.FunctionUtils.executeReturn({
|
|
55
|
+
script,
|
|
56
|
+
context: this,
|
|
57
|
+
args: import_Utils.SwcUtils.getHelperAndHostSet(window, this)
|
|
58
|
+
});
|
|
59
|
+
if (typeof res === "string")
|
|
60
|
+
return document.querySelector(res);
|
|
61
|
+
if (res instanceof Node)
|
|
62
|
+
return res;
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error("[SwcIf] Portal target error:", e);
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
_executeCallback(attrName, extraArgs) {
|
|
69
|
+
const script = this.getAttribute(attrName);
|
|
70
|
+
if (!script)
|
|
71
|
+
return;
|
|
72
|
+
const helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(window, this);
|
|
73
|
+
try {
|
|
74
|
+
import_FunctionUtils.FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error(`[SwcIf] Error in ${attrName}:`, e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
refresh(newValue) {
|
|
80
|
+
const script = newValue !== void 0 ? newValue : this.getAttribute("on-get-value");
|
|
81
|
+
if (!script) {
|
|
82
|
+
this.value = null;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!this.parentElement)
|
|
86
|
+
return;
|
|
87
|
+
const helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(window, this);
|
|
88
|
+
try {
|
|
89
|
+
const result = import_FunctionUtils.FunctionUtils.executeReturn({
|
|
90
|
+
script,
|
|
91
|
+
context: this,
|
|
92
|
+
args: helperHostSet
|
|
93
|
+
});
|
|
94
|
+
this.value = result;
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.error("[SwcIf] Error in on-get-value:", e);
|
|
97
|
+
this.value = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
this.cleanup();
|
|
102
|
+
if (!this.parentElement)
|
|
103
|
+
return;
|
|
104
|
+
let fragment = null;
|
|
105
|
+
const ctx = { $value: this._value, $nodes: [], $elements: [] };
|
|
106
|
+
if (this._value) {
|
|
107
|
+
const clone = this.content.cloneNode(true);
|
|
108
|
+
Array.from(clone.querySelectorAll('template[is="swc-default"]')).forEach((t) => t.remove());
|
|
109
|
+
fragment = clone;
|
|
110
|
+
} else {
|
|
111
|
+
const t = this.content.querySelector('template[is="swc-default"]');
|
|
112
|
+
if (t)
|
|
113
|
+
fragment = t.content.cloneNode(true);
|
|
114
|
+
}
|
|
115
|
+
if (fragment) {
|
|
116
|
+
this.mount(fragment, ctx);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
mount(fragment, ctx) {
|
|
120
|
+
const nodes = Array.from(fragment.childNodes);
|
|
121
|
+
const elements = nodes.filter((n) => n.nodeType === 1);
|
|
122
|
+
Object.assign(ctx, {
|
|
123
|
+
$nodes: nodes,
|
|
124
|
+
$elements: elements,
|
|
125
|
+
$firstNode: nodes[0],
|
|
126
|
+
$lastNode: nodes[nodes.length - 1],
|
|
127
|
+
$firstElement: elements[0],
|
|
128
|
+
$lastElement: elements[elements.length - 1]
|
|
129
|
+
});
|
|
130
|
+
this._executeCallback("on-clone-nodes", ctx);
|
|
131
|
+
nodes.forEach((node, nodeIndex) => {
|
|
132
|
+
if (node instanceof HTMLElement)
|
|
133
|
+
node.__swc_host = this;
|
|
134
|
+
this._executeCallback("on-clone-node", { ...ctx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });
|
|
135
|
+
});
|
|
136
|
+
this._nodes = nodes;
|
|
137
|
+
const target = this._getTarget();
|
|
138
|
+
if (target) {
|
|
139
|
+
target.appendChild(fragment);
|
|
140
|
+
} else {
|
|
141
|
+
this.parentElement?.insertBefore(fragment, this.nextSibling);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
cleanup() {
|
|
145
|
+
this._nodes.forEach((n) => {
|
|
146
|
+
if (n.parentElement)
|
|
147
|
+
n.parentElement.removeChild(n);
|
|
148
|
+
});
|
|
149
|
+
this._nodes = [];
|
|
150
|
+
}
|
|
151
|
+
connectedCallback() {
|
|
152
|
+
this.refresh();
|
|
153
|
+
}
|
|
154
|
+
disconnectedCallback() {
|
|
155
|
+
this.cleanup();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, import_changedAttribute.changedAttribute)("on-get-value"),
|
|
160
|
+
__metadata("design:type", Function),
|
|
161
|
+
__metadata("design:paramtypes", [String]),
|
|
162
|
+
__metadata("design:returntype", void 0)
|
|
163
|
+
], SwcIf.prototype, "refresh", null);
|
|
164
|
+
SwcIf = __decorate([
|
|
165
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-if", extends: "template" })
|
|
166
|
+
], SwcIf);
|
|
167
|
+
//# sourceMappingURL=SwcIf.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/SwcIf.ts"],
|
|
4
|
+
"sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\nimport { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\n@elementDefine({ name: 'swc-if', extends: 'template' })\nexport class SwcIf extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this._value = nv;\n this.render();\n }\n\n private _getTarget(): Element | DocumentFragment | null {\n const script = this.getAttribute('on-get-portal');\n if (!script) return null;\n try {\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(window, this)\n });\n if (typeof res === 'string') return document.querySelector(res);\n if (res instanceof Node) return res as any;\n } catch (e) {\n console.error('[SwcIf] Portal target error:', e);\n }\n return null;\n }\n\n private _executeCallback(attrName: string, extraArgs: Record<string, any>) {\n const script = this.getAttribute(attrName);\n if (!script) return;\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });\n } catch (e) {\n console.error(`[SwcIf] Error in ${attrName}:`, e);\n }\n }\n\n @changedAttribute('on-get-value')\n private refresh(newValue?: string | null) {\n const script = newValue !== undefined ? newValue : this.getAttribute('on-get-value');\n if (!script) {\n this.value = null;\n return;\n }\n if (!this.parentElement) return;\n\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n const result = FunctionUtils.executeReturn({\n script,\n context: this,\n args: helperHostSet\n });\n this.value = result;\n } catch (e) {\n console.error('[SwcIf] Error in on-get-value:', e);\n this.value = null;\n }\n }\n\n private render() {\n this.cleanup();\n if (!this.parentElement) return;\n\n let fragment: DocumentFragment | null = null;\n const ctx: any = { $value: this._value, $nodes: [], $elements: [] };\n\n if (this._value) {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n Array.from(clone.querySelectorAll('template[is=\"swc-default\"]')).forEach(t => t.remove());\n fragment = clone;\n } else {\n const t = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (t) fragment = t.content.cloneNode(true) as DocumentFragment;\n }\n\n if (fragment) {\n this.mount(fragment, ctx);\n }\n }\n\n private mount(fragment: DocumentFragment, ctx: any) {\n const nodes = Array.from(fragment.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n Object.assign(ctx, {\n $nodes: nodes,\n $elements: elements,\n $firstNode: nodes[0],\n $lastNode: nodes[nodes.length - 1],\n $firstElement: elements[0],\n $lastElement: elements[elements.length - 1]\n });\n\n this._executeCallback('on-clone-nodes', ctx);\n nodes.forEach((node, nodeIndex) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCallback('on-clone-node', { ...ctx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });\n });\n\n this._nodes = nodes;\n const target = this._getTarget();\n if (target) {\n target.appendChild(fragment);\n } else {\n this.parentElement?.insertBefore(fragment, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => {\n if (n.parentElement) n.parentElement.removeChild(n);\n });\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA8B;AAC9B,8BAAiC;AACjC,mBAAyB;AACzB,2BAA8B;;;;;;;;;;AAGvB,IAAM,QAAN,MAAMA,eAAc,oBAAmB;EAAvC,cAAA;;AACG,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EA6HxB;EA3HE,IAAI,QAAK;AACP,WAAO,K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AAO;EACd;EAEA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AApFQ,WAAA;MADP,0CAAiB,cAAc;;;;;AAzCrB,QAAK,WAAA;MADjB,oCAAc,EAAE,MAAM,UAAU,SAAS,WAAU,CAAE;GACzC,KAAK;",
|
|
6
|
+
"names": ["SwcIf"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var SwcLoop_exports = {};
|
|
19
|
+
__export(SwcLoop_exports, {
|
|
20
|
+
SwcLoop: () => SwcLoop
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(SwcLoop_exports);
|
|
23
|
+
var import_elementDefine = require("../decorators/elementDefine");
|
|
24
|
+
var import_changedAttribute = require("../decorators/changedAttribute");
|
|
25
|
+
var import_Utils = require("../utils/Utils");
|
|
26
|
+
var import_FunctionUtils = require("@dooboostore/core/function/FunctionUtils");
|
|
27
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
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;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
};
|
|
33
|
+
var __metadata = function(k, v) {
|
|
34
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
|
+
};
|
|
36
|
+
let SwcLoop = class SwcLoop2 extends HTMLTemplateElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this._value = [];
|
|
40
|
+
this._nodes = [];
|
|
41
|
+
this._defaultNodes = [];
|
|
42
|
+
}
|
|
43
|
+
get value() {
|
|
44
|
+
return this._value;
|
|
45
|
+
}
|
|
46
|
+
set value(nv) {
|
|
47
|
+
this._value = Array.isArray(nv) ? [...nv] : [];
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
getNodes(index) {
|
|
51
|
+
return this._nodes[index] || null;
|
|
52
|
+
}
|
|
53
|
+
_getTarget() {
|
|
54
|
+
const script = this.getAttribute("on-get-portal");
|
|
55
|
+
if (!script)
|
|
56
|
+
return null;
|
|
57
|
+
try {
|
|
58
|
+
const res = import_FunctionUtils.FunctionUtils.executeReturn({
|
|
59
|
+
script,
|
|
60
|
+
context: this,
|
|
61
|
+
args: import_Utils.SwcUtils.getHelperAndHostSet(window, this)
|
|
62
|
+
});
|
|
63
|
+
if (typeof res === "string")
|
|
64
|
+
return document.querySelector(res);
|
|
65
|
+
if (res instanceof Node)
|
|
66
|
+
return res;
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error("[SwcLoop] Portal target error:", e);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
append(...items) {
|
|
73
|
+
if (!items.length || !this.parentElement)
|
|
74
|
+
return;
|
|
75
|
+
if (this._defaultNodes.length > 0)
|
|
76
|
+
this._cleanupDefault();
|
|
77
|
+
const fragment = document.createDocumentFragment();
|
|
78
|
+
const startIndex = this._value.length;
|
|
79
|
+
items.forEach((item, i) => {
|
|
80
|
+
const index = startIndex + i;
|
|
81
|
+
const nodes = this._createItemNodes(item, index);
|
|
82
|
+
if (nodes) {
|
|
83
|
+
this._nodes.push(nodes);
|
|
84
|
+
nodes.forEach((n) => fragment.appendChild(n));
|
|
85
|
+
this._value.push(item);
|
|
86
|
+
} else {
|
|
87
|
+
this._nodes.push(null);
|
|
88
|
+
this._value.push(null);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const target = this._getTarget();
|
|
92
|
+
if (target) {
|
|
93
|
+
target.appendChild(fragment);
|
|
94
|
+
} else {
|
|
95
|
+
const lastValidIdx = this._nodes.length - items.length - 1;
|
|
96
|
+
let refNode = this;
|
|
97
|
+
for (let i = lastValidIdx; i >= 0; i--) {
|
|
98
|
+
const group = this._nodes[i];
|
|
99
|
+
if (group && group.length > 0) {
|
|
100
|
+
refNode = group[group.length - 1];
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.parentElement.insertBefore(fragment, refNode.nextSibling);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
remove(index) {
|
|
108
|
+
const targetIdx = index !== void 0 ? index : this._nodes.length - 1;
|
|
109
|
+
if (targetIdx < 0 || targetIdx >= this._nodes.length)
|
|
110
|
+
return;
|
|
111
|
+
const nodes = this._nodes[targetIdx];
|
|
112
|
+
if (nodes) {
|
|
113
|
+
nodes.forEach((n) => {
|
|
114
|
+
if (n.parentElement)
|
|
115
|
+
n.parentElement.removeChild(n);
|
|
116
|
+
});
|
|
117
|
+
this._nodes[targetIdx] = null;
|
|
118
|
+
this._value[targetIdx] = null;
|
|
119
|
+
}
|
|
120
|
+
const activeRows = this._value.filter((v) => v !== null);
|
|
121
|
+
if (activeRows.length === 0) {
|
|
122
|
+
this.render();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_createItemNodes(item, index) {
|
|
126
|
+
const clone = this.content.cloneNode(true);
|
|
127
|
+
Array.from(clone.querySelectorAll('template[is="swc-default"]')).forEach((t) => t.remove());
|
|
128
|
+
const nodes = Array.from(clone.childNodes);
|
|
129
|
+
const elements = nodes.filter((n) => n.nodeType === 1);
|
|
130
|
+
const groupCtx = {
|
|
131
|
+
$index: index,
|
|
132
|
+
$item: item,
|
|
133
|
+
$nodes: nodes,
|
|
134
|
+
$elements: elements,
|
|
135
|
+
$firstNode: nodes[0],
|
|
136
|
+
$lastNode: nodes[nodes.length - 1],
|
|
137
|
+
$firstElement: elements[0],
|
|
138
|
+
$lastElement: elements[elements.length - 1],
|
|
139
|
+
$isFirst: index === 0,
|
|
140
|
+
$isLast: index === this._value.length - 1,
|
|
141
|
+
$isEven: index % 2 === 0,
|
|
142
|
+
$isOdd: index % 2 !== 0,
|
|
143
|
+
$count: this._value.length
|
|
144
|
+
};
|
|
145
|
+
this._executeCallback("on-clone-nodes", groupCtx);
|
|
146
|
+
nodes.forEach((node, nodeIndex) => {
|
|
147
|
+
if (node instanceof HTMLElement)
|
|
148
|
+
node.__swc_host = this;
|
|
149
|
+
this._executeCallback("on-clone-node", { ...groupCtx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });
|
|
150
|
+
});
|
|
151
|
+
return nodes;
|
|
152
|
+
}
|
|
153
|
+
_executeCallback(attrName, extraArgs) {
|
|
154
|
+
const script = this.getAttribute(attrName);
|
|
155
|
+
if (!script)
|
|
156
|
+
return;
|
|
157
|
+
const helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(window, this);
|
|
158
|
+
try {
|
|
159
|
+
import_FunctionUtils.FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.error(`[SwcLoop] Error in ${attrName}:`, e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
refreshValue(newValue) {
|
|
165
|
+
const script = newValue !== void 0 ? newValue : this.getAttribute("on-get-value");
|
|
166
|
+
if (!script) {
|
|
167
|
+
this.value = [];
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(window, this);
|
|
171
|
+
try {
|
|
172
|
+
const res = import_FunctionUtils.FunctionUtils.executeReturn({ script, context: this, args: helperHostSet });
|
|
173
|
+
if (Array.isArray(res)) {
|
|
174
|
+
this.value = res;
|
|
175
|
+
}
|
|
176
|
+
} catch (e) {
|
|
177
|
+
console.error("[SwcLoop] Failed to get value from on-get-value script:", e);
|
|
178
|
+
this.value = [];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
render() {
|
|
182
|
+
this._cleanup();
|
|
183
|
+
if (!this.parentElement)
|
|
184
|
+
return;
|
|
185
|
+
const activeRows = this._value.filter((v) => v !== null);
|
|
186
|
+
const target = this._getTarget();
|
|
187
|
+
if (activeRows.length === 0) {
|
|
188
|
+
const t = this.content.querySelector('template[is="swc-default"]');
|
|
189
|
+
if (t) {
|
|
190
|
+
const clone = t.content.cloneNode(true);
|
|
191
|
+
this._defaultNodes = Array.from(clone.childNodes);
|
|
192
|
+
this._defaultNodes.forEach((n) => {
|
|
193
|
+
if (n instanceof HTMLElement)
|
|
194
|
+
n.__swc_host = this;
|
|
195
|
+
});
|
|
196
|
+
if (target)
|
|
197
|
+
target.appendChild(clone);
|
|
198
|
+
else
|
|
199
|
+
this.parentElement.insertBefore(clone, this.nextSibling);
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const fragment = document.createDocumentFragment();
|
|
204
|
+
this._value.forEach((item, index) => {
|
|
205
|
+
if (item === null) {
|
|
206
|
+
this._nodes.push(null);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const nodes = this._createItemNodes(item, index);
|
|
210
|
+
this._nodes.push(nodes);
|
|
211
|
+
nodes.forEach((n) => fragment.appendChild(n));
|
|
212
|
+
});
|
|
213
|
+
if (target)
|
|
214
|
+
target.appendChild(fragment);
|
|
215
|
+
else
|
|
216
|
+
this.parentElement.insertBefore(fragment, this.nextSibling);
|
|
217
|
+
}
|
|
218
|
+
_cleanup() {
|
|
219
|
+
this._nodes.forEach((group) => {
|
|
220
|
+
if (group)
|
|
221
|
+
group.forEach((node) => node.parentElement?.removeChild(node));
|
|
222
|
+
});
|
|
223
|
+
this._nodes = [];
|
|
224
|
+
this._cleanupDefault();
|
|
225
|
+
}
|
|
226
|
+
_cleanupDefault() {
|
|
227
|
+
this._defaultNodes.forEach((n) => n.parentElement?.removeChild(n));
|
|
228
|
+
this._defaultNodes = [];
|
|
229
|
+
}
|
|
230
|
+
connectedCallback() {
|
|
231
|
+
this.refreshValue();
|
|
232
|
+
}
|
|
233
|
+
disconnectedCallback() {
|
|
234
|
+
this._cleanup();
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, import_changedAttribute.changedAttribute)("on-get-value"),
|
|
239
|
+
__metadata("design:type", Function),
|
|
240
|
+
__metadata("design:paramtypes", [String]),
|
|
241
|
+
__metadata("design:returntype", void 0)
|
|
242
|
+
], SwcLoop.prototype, "refreshValue", null);
|
|
243
|
+
SwcLoop = __decorate([
|
|
244
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-loop", extends: "template" })
|
|
245
|
+
], SwcLoop);
|
|
246
|
+
//# sourceMappingURL=SwcLoop.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/SwcLoop.ts"],
|
|
4
|
+
"sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\nimport { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\n@elementDefine({ name: 'swc-loop', extends: 'template' })\nexport class SwcLoop extends HTMLTemplateElement {\n private _value: any[] = [];\n private _nodes: (Node[] | null)[] = [];\n private _defaultNodes: Node[] = [];\n\n get value(): any[] {\n return this._value;\n }\n\n set value(nv: any[]) {\n this._value = Array.isArray(nv) ? [...nv] : [];\n this.render();\n }\n\n getNodes(index: number): Node[] | null {\n return this._nodes[index] || null;\n }\n\n private _getTarget(): Element | DocumentFragment | null {\n const script = this.getAttribute('on-get-portal');\n if (!script) return null;\n try {\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(window, this)\n });\n if (typeof res === 'string') return document.querySelector(res);\n if (res instanceof Node) return res as any;\n } catch (e) {\n console.error('[SwcLoop] Portal target error:', e);\n }\n return null;\n }\n\n append(...items: any[]) {\n if (!items.length || !this.parentElement) return;\n if (this._defaultNodes.length > 0) this._cleanupDefault();\n\n const fragment = document.createDocumentFragment();\n const startIndex = this._value.length;\n\n items.forEach((item, i) => {\n const index = startIndex + i;\n const nodes = this._createItemNodes(item, index);\n if (nodes) {\n this._nodes.push(nodes);\n nodes.forEach(n => fragment.appendChild(n));\n this._value.push(item);\n } else {\n this._nodes.push(null);\n this._value.push(null);\n }\n });\n\n const target = this._getTarget();\n if (target) {\n target.appendChild(fragment);\n } else {\n const lastValidIdx = this._nodes.length - items.length - 1;\n let refNode: Node = this;\n for (let i = lastValidIdx; i >= 0; i--) {\n const group = this._nodes[i];\n if (group && group.length > 0) {\n refNode = group[group.length - 1];\n break;\n }\n }\n this.parentElement.insertBefore(fragment, refNode.nextSibling);\n }\n }\n\n remove(index?: number) {\n const targetIdx = index !== undefined ? index : this._nodes.length - 1;\n if (targetIdx < 0 || targetIdx >= this._nodes.length) return;\n\n const nodes = this._nodes[targetIdx];\n if (nodes) {\n nodes.forEach(n => {\n if (n.parentElement) n.parentElement.removeChild(n);\n });\n this._nodes[targetIdx] = null;\n this._value[targetIdx] = null;\n }\n\n const activeRows = this._value.filter(v => v !== null);\n if (activeRows.length === 0) {\n this.render();\n }\n }\n\n private _createItemNodes(item: any, index: number): Node[] {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n Array.from(clone.querySelectorAll('template[is=\"swc-default\"]')).forEach(t => t.remove());\n\n const nodes = Array.from(clone.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n const groupCtx = {\n $index: index,\n $item: item,\n $nodes: nodes,\n $elements: elements,\n $firstNode: nodes[0],\n $lastNode: nodes[nodes.length - 1],\n $firstElement: elements[0],\n $lastElement: elements[elements.length - 1],\n $isFirst: index === 0,\n $isLast: index === this._value.length - 1,\n $isEven: index % 2 === 0,\n $isOdd: index % 2 !== 0,\n $count: this._value.length\n };\n\n this._executeCallback('on-clone-nodes', groupCtx);\n nodes.forEach((node, nodeIndex) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCallback('on-clone-node', { ...groupCtx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });\n });\n\n return nodes;\n }\n\n private _executeCallback(attrName: string, extraArgs: Record<string, any>) {\n const script = this.getAttribute(attrName);\n if (!script) return;\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });\n } catch (e) {\n console.error(`[SwcLoop] Error in ${attrName}:`, e);\n }\n }\n\n @changedAttribute('on-get-value')\n private refreshValue(newValue?: string | null) {\n const script = newValue !== undefined ? newValue : this.getAttribute('on-get-value');\n if (!script) {\n this.value = [];\n return;\n }\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n const res = FunctionUtils.executeReturn({ script, context: this, args: helperHostSet });\n if (Array.isArray(res)) {\n this.value = res;\n }\n } catch (e) {\n console.error('[SwcLoop] Failed to get value from on-get-value script:', e);\n this.value = [];\n }\n }\n\n render() {\n this._cleanup();\n if (!this.parentElement) return;\n\n const activeRows = this._value.filter(v => v !== null);\n const target = this._getTarget();\n\n if (activeRows.length === 0) {\n const t = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (t) {\n const clone = t.content.cloneNode(true) as DocumentFragment;\n this._defaultNodes = Array.from(clone.childNodes);\n this._defaultNodes.forEach(n => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n });\n if (target) target.appendChild(clone);\n else this.parentElement.insertBefore(clone, this.nextSibling);\n }\n return;\n }\n\n const fragment = document.createDocumentFragment();\n this._value.forEach((item, index) => {\n if (item === null) {\n this._nodes.push(null);\n return;\n }\n const nodes = this._createItemNodes(item, index);\n this._nodes.push(nodes);\n nodes.forEach(n => fragment.appendChild(n));\n });\n\n if (target) target.appendChild(fragment);\n else this.parentElement.insertBefore(fragment, this.nextSibling);\n }\n\n private _cleanup() {\n this._nodes.forEach(group => {\n if (group) group.forEach(node => node.parentElement?.removeChild(node));\n });\n this._nodes = [];\n this._cleanupDefault();\n }\n\n private _cleanupDefault() {\n this._defaultNodes.forEach(n => n.parentElement?.removeChild(n));\n this._defaultNodes = [];\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this._cleanup();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA8B;AAC9B,8BAAiC;AACjC,mBAAyB;AACzB,2BAA8B;;;;;;;;;;AAGvB,IAAM,UAAN,MAAMA,iBAAgB,oBAAmB;EAAzC,cAAA;;AACG,SAAA,SAAgB,CAAA;AAChB,SAAA,SAA4B,CAAA;AAC5B,SAAA,gBAAwB,CAAA;EA6MlC;EA3ME,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EAEA,IAAI,MAAM,IAAS;AACjB,SAAK,SAAS,MAAM,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAA;AAC5C,SAAK,OAAM;EACb;EAEA,SAAS,OAAa;AACpB,WAAO,KAAK,OAAO,KAAK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,eAAK,cAAc,aAAa,OAAO,KAAK,WAAW;MAC9D;AACA;IACF;AAEA,UAAM,WAAW,SAAS,uBAAsB;AAChD,SAAK,OAAO,QAAQ,CAAC,MAAM,UAAS;AAClC,UAAI,SAAS,MAAM;AACjB,aAAK,OAAO,KAAK,IAAI;AACrB;MACF;AACA,YAAM,QAAQ,KAAK,iBAAiB,MAAM,KAAK;AAC/C,WAAK,OAAO,KAAK,KAAK;AACtB,YAAM,QAAQ,OAAK,SAAS,YAAY,CAAC,CAAC;IAC5C,CAAC;AAED,QAAI;AAAQ,aAAO,YAAY,QAAQ;;AAClC,WAAK,cAAc,aAAa,UAAU,KAAK,WAAW;EACjE;EAEQ,WAAQ;AACd,SAAK,OAAO,QAAQ,WAAQ;AAC1B,UAAI;AAAO,cAAM,QAAQ,UAAQ,KAAK,eAAe,YAAY,IAAI,CAAC;IACxE,CAAC;AACD,SAAK,SAAS,CAAA;AACd,SAAK,gBAAe;EACtB;EAEQ,kBAAe;AACrB,SAAK,cAAc,QAAQ,OAAK,EAAE,eAAe,YAAY,CAAC,CAAC;AAC/D,SAAK,gBAAgB,CAAA;EACvB;EAEA,oBAAiB;AACf,SAAK,aAAY;EACnB;EACA,uBAAoB;AAClB,SAAK,SAAQ;EACf;;AAxEQ,WAAA;MADP,0CAAiB,cAAc;;;;;AAtIrB,UAAO,WAAA;MADnB,oCAAc,EAAE,MAAM,YAAY,SAAS,WAAU,CAAE;GAC3C,OAAO;",
|
|
6
|
+
"names": ["SwcLoop"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var SwcSubTemplates_exports = {};
|
|
19
|
+
__export(SwcSubTemplates_exports, {
|
|
20
|
+
SwcDefault: () => SwcDefault,
|
|
21
|
+
SwcError: () => SwcError,
|
|
22
|
+
SwcLoading: () => SwcLoading,
|
|
23
|
+
SwcOtherwise: () => SwcOtherwise,
|
|
24
|
+
SwcSuccess: () => SwcSuccess,
|
|
25
|
+
SwcWhen: () => SwcWhen
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(SwcSubTemplates_exports);
|
|
28
|
+
var import_elementDefine = require("../decorators/elementDefine");
|
|
29
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
30
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32
|
+
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;
|
|
33
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
34
|
+
};
|
|
35
|
+
let SwcLoading = class SwcLoading2 extends HTMLTemplateElement {
|
|
36
|
+
};
|
|
37
|
+
SwcLoading = __decorate([
|
|
38
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-loading", extends: "template" })
|
|
39
|
+
], SwcLoading);
|
|
40
|
+
let SwcError = class SwcError2 extends HTMLTemplateElement {
|
|
41
|
+
};
|
|
42
|
+
SwcError = __decorate([
|
|
43
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-error", extends: "template" })
|
|
44
|
+
], SwcError);
|
|
45
|
+
let SwcSuccess = class SwcSuccess2 extends HTMLTemplateElement {
|
|
46
|
+
};
|
|
47
|
+
SwcSuccess = __decorate([
|
|
48
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-success", extends: "template" })
|
|
49
|
+
], SwcSuccess);
|
|
50
|
+
let SwcWhen = class SwcWhen2 extends HTMLTemplateElement {
|
|
51
|
+
};
|
|
52
|
+
SwcWhen = __decorate([
|
|
53
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-when", extends: "template" })
|
|
54
|
+
], SwcWhen);
|
|
55
|
+
let SwcOtherwise = class SwcOtherwise2 extends HTMLTemplateElement {
|
|
56
|
+
};
|
|
57
|
+
SwcOtherwise = __decorate([
|
|
58
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-otherwise", extends: "template" })
|
|
59
|
+
], SwcOtherwise);
|
|
60
|
+
let SwcDefault = class SwcDefault2 extends HTMLTemplateElement {
|
|
61
|
+
};
|
|
62
|
+
SwcDefault = __decorate([
|
|
63
|
+
(0, import_elementDefine.elementDefine)({ name: "swc-default", extends: "template" })
|
|
64
|
+
], SwcDefault);
|
|
65
|
+
//# sourceMappingURL=SwcSubTemplates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/SwcSubTemplates.ts"],
|
|
4
|
+
"sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\n\n@elementDefine({ name: 'swc-loading', extends: 'template' })\nexport class SwcLoading extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-error', extends: 'template' })\nexport class SwcError extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-success', extends: 'template' })\nexport class SwcSuccess extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-when', extends: 'template' })\nexport class SwcWhen extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-otherwise', extends: 'template' })\nexport class SwcOtherwise extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-default', extends: 'template' })\nexport class SwcDefault extends HTMLTemplateElement {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA8B;;;;;;;AAGvB,IAAM,aAAN,MAAMA,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;MADtB,oCAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;AAGhB,IAAM,WAAN,MAAMC,kBAAiB,oBAAmB;;AAApC,WAAQ,WAAA;MADpB,oCAAc,EAAE,MAAM,aAAa,SAAS,WAAU,CAAE;GAC5C,QAAQ;AAGd,IAAM,aAAN,MAAMC,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;MADtB,oCAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;AAGhB,IAAM,UAAN,MAAMC,iBAAgB,oBAAmB;;AAAnC,UAAO,WAAA;MADnB,oCAAc,EAAE,MAAM,YAAY,SAAS,WAAU,CAAE;GAC3C,OAAO;AAGb,IAAM,eAAN,MAAMC,sBAAqB,oBAAmB;;AAAxC,eAAY,WAAA;MADxB,oCAAc,EAAE,MAAM,iBAAiB,SAAS,WAAU,CAAE;GAChD,YAAY;AAGlB,IAAM,aAAN,MAAMC,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;MADtB,oCAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;",
|
|
6
|
+
"names": ["SwcLoading", "SwcError", "SwcSuccess", "SwcWhen", "SwcOtherwise", "SwcDefault"]
|
|
7
|
+
}
|
|
@@ -15,4 +15,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
15
15
|
var elements_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(elements_exports);
|
|
17
17
|
__reExport(elements_exports, require("./is"), module.exports);
|
|
18
|
+
__reExport(elements_exports, require("./SwcSubTemplates"), module.exports);
|
|
19
|
+
__reExport(elements_exports, require("./SwcLoop"), module.exports);
|
|
20
|
+
__reExport(elements_exports, require("./SwcIf"), module.exports);
|
|
21
|
+
__reExport(elements_exports, require("./SwcChoose"), module.exports);
|
|
22
|
+
__reExport(elements_exports, require("./SwcAsync"), module.exports);
|
|
23
|
+
__reExport(elements_exports, require("./SwcApp"), module.exports);
|
|
24
|
+
__reExport(elements_exports, require("./SwcAppEngine"), module.exports);
|
|
18
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAEA,6BAAc,
|
|
4
|
+
"sourcesContent": ["export * from './is';\nexport * from './SwcSubTemplates';\nexport * from './SwcLoop';\nexport * from './SwcIf';\nexport * from './SwcChoose';\nexport * from './SwcAsync';\nexport * from './SwcApp';\nexport * from './SwcAppEngine';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,iBAAd;AACA,6BAAc,8BADd;AAEA,6BAAc,sBAFd;AAGA,6BAAc,oBAHd;AAIA,6BAAc,wBAJd;AAKA,6BAAc,uBALd;AAMA,6BAAc,qBANd;AAOA,6BAAc,2BAPd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
5
9
|
var __copyProps = (to, from, except, desc) => {
|
|
6
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -13,18 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
19
|
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
innerHtml: () => import_onConnectedInnerHtml.onConnectedInnerHtml
|
|
22
|
+
});
|
|
16
23
|
module.exports = __toCommonJS(src_exports);
|
|
17
24
|
var import_reflect_metadata = require("reflect-metadata");
|
|
18
25
|
__reExport(src_exports, require("./decorators/elementDefine"), module.exports);
|
|
19
26
|
__reExport(src_exports, require("./decorators/setAttribute"), module.exports);
|
|
20
27
|
__reExport(src_exports, require("./decorators/changedAttribute"), module.exports);
|
|
21
|
-
__reExport(src_exports, require("./decorators/
|
|
28
|
+
__reExport(src_exports, require("./decorators/onConnectedInnerHtml"), module.exports);
|
|
29
|
+
var import_onConnectedInnerHtml = require("./decorators/onConnectedInnerHtml");
|
|
30
|
+
__reExport(src_exports, require("./decorators/replaceChildren"), module.exports);
|
|
31
|
+
__reExport(src_exports, require("./decorators/appendChild"), module.exports);
|
|
22
32
|
__reExport(src_exports, require("./decorators/emitCustomEvent"), module.exports);
|
|
23
33
|
__reExport(src_exports, require("./decorators/lifecycles"), module.exports);
|
|
24
34
|
__reExport(src_exports, require("./decorators/query"), module.exports);
|
|
25
35
|
__reExport(src_exports, require("./decorators/queryAll"), module.exports);
|
|
26
36
|
__reExport(src_exports, require("./decorators/addEventListener"), module.exports);
|
|
27
37
|
__reExport(src_exports, require("./types"), module.exports);
|
|
28
|
-
__reExport(src_exports, require("./elements
|
|
38
|
+
__reExport(src_exports, require("./elements"), module.exports);
|
|
29
39
|
__reExport(src_exports, require("./utils/Utils"), module.exports);
|
|
30
40
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import 'reflect-metadata';\n\n// Decorators\nexport * from './decorators/elementDefine';\nexport * from './decorators/setAttribute';\nexport * from './decorators/changedAttribute';\nexport * from './decorators/innerHtml';\nexport * from './decorators/emitCustomEvent';\nexport * from './decorators/lifecycles';\nexport * from './decorators/query';\nexport * from './decorators/queryAll';\nexport * from './decorators/addEventListener';\n\n// Types\nexport * from './types';\n\n// Apps (Customized Built-in Elements)\nexport * from './elements
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import 'reflect-metadata';\n\n// Decorators\nexport * from './decorators/elementDefine';\nexport * from './decorators/setAttribute';\nexport * from './decorators/changedAttribute';\nexport * from './decorators/onConnectedInnerHtml';\nexport { onConnectedInnerHtml as innerHtml } from './decorators/onConnectedInnerHtml';\nexport * from './decorators/replaceChildren';\nexport * from './decorators/appendChild';\nexport * from './decorators/emitCustomEvent';\nexport * from './decorators/lifecycles';\nexport * from './decorators/query';\nexport * from './decorators/queryAll';\nexport * from './decorators/addEventListener';\n\n// Types\nexport * from './types';\n\n// Apps (Customized Built-in Elements)\nexport * from './elements';\n\n// Utilities\nexport * from './utils/Utils';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAO;AAGP,wBAAc,uCAHd;AAIA,wBAAc,sCAJd;AAKA,wBAAc,0CALd;AAMA,wBAAc,8CANd;AAOA,kCAAkD;AAClD,wBAAc,yCARd;AASA,wBAAc,qCATd;AAUA,wBAAc,yCAVd;AAWA,wBAAc,oCAXd;AAYA,wBAAc,+BAZd;AAaA,wBAAc,kCAbd;AAcA,wBAAc,0CAdd;AAiBA,wBAAc,oBAjBd;AAoBA,wBAAc,uBApBd;AAuBA,wBAAc,0BAvBd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [self, parent, ..., top]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n routing(path: string): Promise<void>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n}\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [self, parent, ..., top]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport type HelperHostSet = HelperSet & HostSet;\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n routing(path: string): Promise<void>;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,iBAAc;AACd,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AAVN,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["InjectSituationType"]
|
|
7
7
|
}
|