@dooboostore/simple-web-component 1.0.47 → 1.0.49
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 +223 -27
- package/dist/cjs/config/config.js +1 -1
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +412 -16
- package/dist/cjs/decorators/addEventListener.js.map +3 -3
- package/dist/cjs/decorators/applyAttribute.js +25 -0
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +49 -18
- package/dist/cjs/decorators/applyClass.js.map +3 -3
- package/dist/cjs/decorators/applyNode.js +67 -1
- package/dist/cjs/decorators/applyNode.js.map +3 -3
- package/dist/cjs/decorators/applyProperty.js +101 -3
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +36 -5
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +39 -0
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +244 -225
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +55 -0
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +5 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +209 -0
- package/dist/cjs/decorators/intersectionObserver.js.map +7 -0
- package/dist/cjs/decorators/mutationObserver.js +244 -0
- package/dist/cjs/decorators/mutationObserver.js.map +7 -0
- package/dist/cjs/decorators/query.js +129 -102
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/resizeObserver.js +191 -0
- package/dist/cjs/decorators/resizeObserver.js.map +7 -0
- package/dist/cjs/decorators/setInterval.js +82 -0
- package/dist/cjs/decorators/setInterval.js.map +7 -0
- package/dist/cjs/decorators/setTimeout.js +82 -0
- package/dist/cjs/decorators/setTimeout.js.map +7 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/config/config.js +1 -1
- package/dist/esm/config/config.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +413 -16
- package/dist/esm/decorators/addEventListener.js.map +3 -3
- package/dist/esm/decorators/applyAttribute.js +25 -0
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +49 -18
- package/dist/esm/decorators/applyClass.js.map +3 -3
- package/dist/esm/decorators/applyNode.js +67 -1
- package/dist/esm/decorators/applyNode.js.map +3 -3
- package/dist/esm/decorators/applyProperty.js +101 -3
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +36 -5
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +40 -0
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +249 -230
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +55 -0
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +5 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +191 -0
- package/dist/esm/decorators/intersectionObserver.js.map +7 -0
- package/dist/esm/decorators/mutationObserver.js +226 -0
- package/dist/esm/decorators/mutationObserver.js.map +7 -0
- package/dist/esm/decorators/query.js +129 -102
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/resizeObserver.js +173 -0
- package/dist/esm/decorators/resizeObserver.js.map +7 -0
- package/dist/esm/decorators/setInterval.js +64 -0
- package/dist/esm/decorators/setInterval.js.map +7 -0
- package/dist/esm/decorators/setTimeout.js +64 -0
- package/dist/esm/decorators/setTimeout.js.map +7 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
- package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2413 -889
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +93 -23
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +22 -34
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +34 -34
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +30 -20
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +57 -34
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +25 -12
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +11 -0
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +28 -4
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +5 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +49 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -0
- package/dist/types/decorators/mutationObserver.d.ts +46 -0
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -0
- package/dist/types/decorators/query.d.ts +63 -8
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/resizeObserver.d.ts +48 -0
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -0
- package/dist/types/decorators/setInterval.d.ts +29 -0
- package/dist/types/decorators/setInterval.d.ts.map +1 -0
- package/dist/types/decorators/setTimeout.d.ts +29 -0
- package/dist/types/decorators/setTimeout.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +7 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +6 -0
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +104 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2413 -889
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +8 -6
- package/src/config/config.ts +1 -1
- package/src/decorators/addEventListener.ts +426 -23
- package/src/decorators/applyAttribute.ts +50 -36
- package/src/decorators/applyClass.ts +76 -26
- package/src/decorators/applyNode.ts +114 -36
- package/src/decorators/applyProperty.ts +152 -40
- package/src/decorators/applyStyle.ts +64 -17
- package/src/decorators/changedAttribute.ts +46 -0
- package/src/decorators/elementDefine.ts +301 -317
- package/src/decorators/emitCustomEvent.ts +73 -5
- package/src/decorators/index.ts +5 -1
- package/src/decorators/intersectionObserver.ts +259 -0
- package/src/decorators/mutationObserver.ts +304 -0
- package/src/decorators/query.ts +182 -117
- package/src/decorators/resizeObserver.ts +235 -0
- package/src/decorators/setInterval.ts +80 -0
- package/src/decorators/setTimeout.ts +80 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +17 -0
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +19 -0
- package/src/examples/RxJSOperatorsExample.ts +279 -0
- package/src/types/index.ts +141 -0
- package/dist/cjs/decorators/queryAll.js +0 -181
- package/dist/cjs/decorators/queryAll.js.map +0 -7
- package/dist/cjs/elements/tt/SwcAppMixin.js +0 -1
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +0 -7
- package/dist/cjs/elements/tt/SwcAsync.js +0 -1
- package/dist/cjs/elements/tt/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +0 -1
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +0 -7
- package/dist/cjs/elements/tt/SwcChoose.js +0 -1
- package/dist/cjs/elements/tt/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +0 -1
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +0 -7
- package/dist/cjs/elements/tt/SwcIf.js +0 -1
- package/dist/cjs/elements/tt/SwcIf.js.map +0 -7
- package/dist/cjs/elements/tt/SwcIfTemplate.js +0 -1
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +0 -7
- package/dist/cjs/elements/tt/SwcLoop.js +0 -1
- package/dist/cjs/elements/tt/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +0 -1
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +0 -7
- package/dist/cjs/elements/tt/SwcSubTemplates.js +0 -1
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/tt/register.js +0 -1
- package/dist/cjs/elements/tt/register.js.map +0 -7
- package/dist/esm/decorators/queryAll.js +0 -162
- package/dist/esm/decorators/queryAll.js.map +0 -7
- package/dist/esm/elements/tt/SwcAppMixin.js +0 -1
- package/dist/esm/elements/tt/SwcAppMixin.js.map +0 -7
- package/dist/esm/elements/tt/SwcAsync.js +0 -1
- package/dist/esm/elements/tt/SwcAsync.js.map +0 -7
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +0 -1
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +0 -7
- package/dist/esm/elements/tt/SwcChoose.js +0 -1
- package/dist/esm/elements/tt/SwcChoose.js.map +0 -7
- package/dist/esm/elements/tt/SwcChooseTemplate.js +0 -1
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +0 -7
- package/dist/esm/elements/tt/SwcIf.js +0 -1
- package/dist/esm/elements/tt/SwcIf.js.map +0 -7
- package/dist/esm/elements/tt/SwcIfTemplate.js +0 -1
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +0 -7
- package/dist/esm/elements/tt/SwcLoop.js +0 -1
- package/dist/esm/elements/tt/SwcLoop.js.map +0 -7
- package/dist/esm/elements/tt/SwcLoopTemplate.js +0 -1
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +0 -7
- package/dist/esm/elements/tt/SwcSubTemplates.js +0 -1
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/tt/register.js +0 -1
- package/dist/esm/elements/tt/register.js.map +0 -7
- package/dist/types/decorators/queryAll.d.ts +0 -22
- package/dist/types/decorators/queryAll.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +0 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcAsync.d.ts +0 -1
- package/dist/types/elements/tt/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +0 -1
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcChoose.d.ts +0 -1
- package/dist/types/elements/tt/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +0 -1
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcIf.d.ts +0 -1
- package/dist/types/elements/tt/SwcIf.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +0 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcLoop.d.ts +0 -1
- package/dist/types/elements/tt/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +0 -1
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +0 -1
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +0 -1
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/tt/register.d.ts +0 -1
- package/dist/types/elements/tt/register.d.ts.map +0 -1
- package/src/decorators/queryAll.ts +0 -186
- package/src/elements/tt/SwcAppMixin.ts +0 -13
- package/src/elements/tt/SwcAsync.ts +0 -139
- package/src/elements/tt/SwcAsyncTemplate.ts +0 -126
- package/src/elements/tt/SwcChoose.ts +0 -182
- package/src/elements/tt/SwcChooseTemplate.ts +0 -229
- package/src/elements/tt/SwcIf.ts +0 -145
- package/src/elements/tt/SwcIfTemplate.ts +0 -158
- package/src/elements/tt/SwcLoop.ts +0 -222
- package/src/elements/tt/SwcLoopTemplate.ts +0 -255
- package/src/elements/tt/SwcSubTemplates.ts +0 -6
- package/src/elements/tt/register.ts +0 -720
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
-
import { getElementConfig, ensureInit } from './elementDefine';
|
|
3
|
-
import { SwcUtils } from '../utils/Utils';
|
|
4
|
-
import { SwcQueryOptions, HelperHostSet } from '../types';
|
|
5
|
-
|
|
6
|
-
export interface QueryAllOptions extends SwcQueryOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Filter function to determine whether to include the element.
|
|
9
|
-
* If it returns false, the element is skipped.
|
|
10
|
-
*/
|
|
11
|
-
filter?: (target: HTMLElement, meta: { currentThis: any, helper: HelperHostSet }) => boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface QueryAllMetadata {
|
|
15
|
-
propertyKey: string | symbol;
|
|
16
|
-
selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);
|
|
17
|
-
options: QueryAllOptions;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const QUERY_ALL_METADATA_KEY = Symbol.for('simple-web-component:query-all');
|
|
21
|
-
|
|
22
|
-
export function queryAll(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor | void;
|
|
23
|
-
export function queryAll(selector: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null), options?: QueryAllOptions): PropertyDecorator;
|
|
24
|
-
export function queryAll(options?: QueryAllOptions): PropertyDecorator;
|
|
25
|
-
/**
|
|
26
|
-
* @queryAll decorator to inject a list of elements into a class property.
|
|
27
|
-
*
|
|
28
|
-
* Supports both string selectors and function-based selectors:
|
|
29
|
-
* - String selector: @queryAll('.item')
|
|
30
|
-
* - Function selector: @queryAll((currentThis, helper) => currentThis.shadowRoot?.querySelectorAll('.item'))
|
|
31
|
-
*
|
|
32
|
-
* Supports filtering:
|
|
33
|
-
* - @queryAll('.item', { filter: (target, meta) => target.hasAttribute('active') })
|
|
34
|
-
*/
|
|
35
|
-
export function queryAll(selectorOrTarget?: string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null) | Object, optionsOrPropertyKey?: QueryAllOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
36
|
-
// Bare decorator: @queryAll
|
|
37
|
-
if (descriptor !== undefined && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol')) {
|
|
38
|
-
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
39
|
-
}
|
|
40
|
-
// With selector
|
|
41
|
-
if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
|
|
42
|
-
return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
|
|
43
|
-
if (descriptor !== undefined) {
|
|
44
|
-
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const constructor = targetObj.constructor;
|
|
48
|
-
let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);
|
|
49
|
-
if (!queries) {
|
|
50
|
-
queries = [];
|
|
51
|
-
ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
52
|
-
}
|
|
53
|
-
queries.push({ propertyKey, selector: selectorOrTarget as any, options: optionsOrPropertyKey as QueryAllOptions || {} });
|
|
54
|
-
|
|
55
|
-
Object.defineProperty(targetObj, propertyKey, {
|
|
56
|
-
get(this: HTMLElement) {
|
|
57
|
-
ensureInit(this);
|
|
58
|
-
const config = getElementConfig(this);
|
|
59
|
-
const win = config?.window || window;
|
|
60
|
-
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
61
|
-
|
|
62
|
-
// Resolve selector - can be string or function
|
|
63
|
-
let resolvedSelector: string;
|
|
64
|
-
let resolvedElements: HTMLElement[] = [];
|
|
65
|
-
|
|
66
|
-
if (typeof selectorOrTarget === 'function') {
|
|
67
|
-
const result = (selectorOrTarget as any)(this, hostSet);
|
|
68
|
-
// If function returns NodeList or Element[], convert to array
|
|
69
|
-
if (result instanceof win.NodeList) {
|
|
70
|
-
resolvedElements = Array.from(result).filter(el => el instanceof win.HTMLElement) as HTMLElement[];
|
|
71
|
-
} else if (Array.isArray(result)) {
|
|
72
|
-
resolvedElements = result.filter(el => el instanceof win.HTMLElement) as HTMLElement[];
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
resolvedSelector = selectorOrTarget;
|
|
76
|
-
|
|
77
|
-
const r = (optionsOrPropertyKey as QueryAllOptions)?.root || 'auto';
|
|
78
|
-
const applyRoot = (t: any): any[] => {
|
|
79
|
-
if (!t) return [];
|
|
80
|
-
const items = Array.isArray(t) ? t : [t];
|
|
81
|
-
const results: any[] = [];
|
|
82
|
-
items.forEach(it => {
|
|
83
|
-
if (!(it instanceof HTMLElement)) {
|
|
84
|
-
results.push(it);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (r === 'auto') results.push(it.shadowRoot || it);
|
|
88
|
-
else {
|
|
89
|
-
if (r === 'light' || r === 'all') results.push(it);
|
|
90
|
-
if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return results;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// --- Special Selectors: HostSet ---
|
|
97
|
-
if (resolvedSelector === '$hosts') resolvedElements = applyRoot(hostSet.$hosts).filter(el => el instanceof HTMLElement);
|
|
98
|
-
else if (resolvedSelector === '$appHosts') resolvedElements = applyRoot(hostSet.$appHosts).filter(el => el instanceof HTMLElement);
|
|
99
|
-
else if (resolvedSelector === '$host') resolvedElements = applyRoot(hostSet.$host).filter(el => el instanceof HTMLElement);
|
|
100
|
-
else if (resolvedSelector === '$parentHost') resolvedElements = applyRoot(hostSet.$parentHost).filter(el => el instanceof HTMLElement);
|
|
101
|
-
else if (resolvedSelector === '$appHost') resolvedElements = applyRoot(hostSet.$appHost).filter(el => el instanceof HTMLElement);
|
|
102
|
-
else if (resolvedSelector === '$firstHost') resolvedElements = applyRoot(hostSet.$firstHost).filter(el => el instanceof HTMLElement);
|
|
103
|
-
else if (resolvedSelector === '$lastHost') resolvedElements = applyRoot(hostSet.$lastHost).filter(el => el instanceof HTMLElement);
|
|
104
|
-
else if (resolvedSelector === '$firstAppHost') resolvedElements = applyRoot(hostSet.$firstAppHost).filter(el => el instanceof HTMLElement);
|
|
105
|
-
else if (resolvedSelector === '$lastAppHost') resolvedElements = applyRoot(hostSet.$lastAppHost).filter(el => el instanceof HTMLElement);
|
|
106
|
-
// --- Special Selectors: Env ---
|
|
107
|
-
else if (resolvedSelector === '$window') return [win];
|
|
108
|
-
else if (resolvedSelector === '$document') return [win.document];
|
|
109
|
-
else if (resolvedSelector === '$this') resolvedElements = applyRoot(this).filter(el => el instanceof HTMLElement);
|
|
110
|
-
// --- Standard Selectors ---
|
|
111
|
-
else {
|
|
112
|
-
if (r === 'shadow') resolvedElements = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];
|
|
113
|
-
else if (r === 'light') resolvedElements = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];
|
|
114
|
-
else if (r === 'all') {
|
|
115
|
-
const sNodes = this.shadowRoot ? (Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) as HTMLElement[]) : [];
|
|
116
|
-
const lNodes = Array.from(this.querySelectorAll(resolvedSelector)) as HTMLElement[];
|
|
117
|
-
resolvedElements = [...sNodes, ...lNodes];
|
|
118
|
-
}
|
|
119
|
-
else resolvedElements = (Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector)) as HTMLElement[]);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Apply filter if provided
|
|
124
|
-
if ((optionsOrPropertyKey as QueryAllOptions)?.filter) {
|
|
125
|
-
resolvedElements = resolvedElements.filter(el => {
|
|
126
|
-
if (!(el instanceof win.HTMLElement)) return true;
|
|
127
|
-
return (optionsOrPropertyKey as QueryAllOptions).filter!(el, { currentThis: this, helper: hostSet });
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return resolvedElements;
|
|
132
|
-
},
|
|
133
|
-
set(this: HTMLElement, nv: any) {
|
|
134
|
-
ensureInit(this);
|
|
135
|
-
if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {
|
|
136
|
-
const config = getElementConfig(this);
|
|
137
|
-
const win = config?.window || window;
|
|
138
|
-
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
139
|
-
|
|
140
|
-
// Resolve selector - can be string or function
|
|
141
|
-
if (typeof selectorOrTarget === 'function') {
|
|
142
|
-
// Get elements from function and remove them
|
|
143
|
-
const result = (selectorOrTarget as any)(this, hostSet);
|
|
144
|
-
if (result instanceof win.NodeList) {
|
|
145
|
-
Array.from(result).forEach(el => {
|
|
146
|
-
if (el instanceof win.Element) (el as Element).remove();
|
|
147
|
-
});
|
|
148
|
-
} else if (Array.isArray(result)) {
|
|
149
|
-
result.forEach(el => {
|
|
150
|
-
if (el instanceof win.Element) (el as Element).remove();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const resolvedSelector = selectorOrTarget;
|
|
157
|
-
|
|
158
|
-
if (resolvedSelector.startsWith('$') && resolvedSelector !== '$this') return;
|
|
159
|
-
|
|
160
|
-
const r = (optionsOrPropertyKey as SwcQueryOptions)?.root || 'auto';
|
|
161
|
-
let targets: (Element | Node)[] = [];
|
|
162
|
-
if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
163
|
-
else if (r === 'light') targets = Array.from(this.querySelectorAll(resolvedSelector));
|
|
164
|
-
else if (r === 'all') {
|
|
165
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
166
|
-
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
167
|
-
targets = [...sNodes, ...lNodes];
|
|
168
|
-
} else {
|
|
169
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
170
|
-
}
|
|
171
|
-
targets.forEach(t => (t as Element).remove());
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
enumerable: true,
|
|
175
|
-
configurable: true
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
// Without selector (defaults to $this)
|
|
180
|
-
return queryAll('$this', selectorOrTarget as SwcQueryOptions);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {
|
|
184
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
185
|
-
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
186
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// import {SwcAppEngine, SwcAttributeConfigType, SwcConfigType} from '../../SwcAppEngine';
|
|
2
|
-
// import {SwcAppInterface, SwcAppMessage} from '../../types';
|
|
3
|
-
// import {SwcUtils} from '../../utils/Utils';
|
|
4
|
-
// import {debounceTimeIntervalLock, FunctionUtils, Subscription} from '@dooboostore/core';
|
|
5
|
-
// import {RouterEventType} from '@dooboostore/core-web';
|
|
6
|
-
// import {getSubscribeSwcAppRouteChangeWhileConnectedMetadata} from '../../decorators/subscribeSwcAppRouteChangeWhileConnected';
|
|
7
|
-
// import {getSubscribeSwcAppMessageWhileConnectedMetadata} from '../../decorators/subscribeSwcAppMessageWhileConnected';
|
|
8
|
-
// import {findAllLifecycleMetadata, ON_CONNECTED_COMPLETED_SWC_APP_METADATA_KEY, ON_CONNECTED_INNER_HTML_METADATA_KEY, ON_CONNECTED_SWC_APP_METADATA_KEY} from "../../decorators";
|
|
9
|
-
//
|
|
10
|
-
// export function SwcAppMixin<T extends { new(...args: any[]): HTMLElement }>(Base: T) {
|
|
11
|
-
// //@ts-ignore
|
|
12
|
-
// return
|
|
13
|
-
// }
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// import {SwcUtils} from '../../utils/Utils';
|
|
2
|
-
// import {ActionExpression, FunctionUtils} from '@dooboostore/core';
|
|
3
|
-
// import {ConvertUtils} from '@dooboostore/core-web';
|
|
4
|
-
// import {elementDefine} from "../../decorators";
|
|
5
|
-
//
|
|
6
|
-
// export default async (w: Window) => {
|
|
7
|
-
// const tagName = 'swc-async';
|
|
8
|
-
// const existing = w.customElements.get(tagName);
|
|
9
|
-
// if (existing) return existing;
|
|
10
|
-
//
|
|
11
|
-
// @elementDefine(tagName, { window: w })
|
|
12
|
-
// class SwcAsync extends w.HTMLElement {
|
|
13
|
-
// private _value: any;
|
|
14
|
-
// private _replaceWrapStart: string | null = null;
|
|
15
|
-
// private _replaceWrapEnd: string | null = null;
|
|
16
|
-
// private _nodes: Node[] = [];
|
|
17
|
-
// resultValue?: any;
|
|
18
|
-
//
|
|
19
|
-
// static get observedAttributes() {
|
|
20
|
-
// return ['value', 'replace-wrap-start', 'replace-wrap-end'];
|
|
21
|
-
// }
|
|
22
|
-
//
|
|
23
|
-
// get value(): boolean {
|
|
24
|
-
// return this._value;
|
|
25
|
-
// }
|
|
26
|
-
//
|
|
27
|
-
// set value(nv: any) {
|
|
28
|
-
// this.executeAsync(nv);
|
|
29
|
-
// }
|
|
30
|
-
//
|
|
31
|
-
// connectedCallback() {
|
|
32
|
-
// if (this.hasAttribute('value')) {
|
|
33
|
-
// this.executeAsync(this._value);
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
//
|
|
37
|
-
// attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
38
|
-
// switch (name) {
|
|
39
|
-
// case 'value':
|
|
40
|
-
// this._value = newValue;
|
|
41
|
-
// this.executeAsync(this._value);
|
|
42
|
-
// break;
|
|
43
|
-
// case 'replace-wrap-start':
|
|
44
|
-
// this._replaceWrapStart = newValue;
|
|
45
|
-
// break;
|
|
46
|
-
// case 'replace-wrap-end':
|
|
47
|
-
// this._replaceWrapEnd = newValue;
|
|
48
|
-
// break;
|
|
49
|
-
// }
|
|
50
|
-
// }
|
|
51
|
-
//
|
|
52
|
-
// private executeAsync(result: any = this._value) {
|
|
53
|
-
// if (result === undefined || result === null) {
|
|
54
|
-
// this.refresh('default');
|
|
55
|
-
// return;
|
|
56
|
-
// }
|
|
57
|
-
// if (result instanceof Promise) {
|
|
58
|
-
// this.refresh('loading');
|
|
59
|
-
// result
|
|
60
|
-
// .then(v => {
|
|
61
|
-
// this.resultValue = v;
|
|
62
|
-
// this.refresh('success');
|
|
63
|
-
// })
|
|
64
|
-
// .catch(e => {
|
|
65
|
-
// console.error('[SWC-ASYNC] Promise rejected:', e);
|
|
66
|
-
// this.resultValue = e;
|
|
67
|
-
// this.refresh('error');
|
|
68
|
-
// });
|
|
69
|
-
// } else {
|
|
70
|
-
// this.resultValue = result;
|
|
71
|
-
// this.refresh('success');
|
|
72
|
-
// }
|
|
73
|
-
// }
|
|
74
|
-
//
|
|
75
|
-
// private replaceExpressions(html: string, groupArgs: any, context: any, wrap: { start: string, end: string }): string {
|
|
76
|
-
// let config: any = undefined;
|
|
77
|
-
// if (wrap) {
|
|
78
|
-
// config = {
|
|
79
|
-
// expression: {
|
|
80
|
-
// replace: {start: `${wrap.start}`, end: `${wrap.end}`},
|
|
81
|
-
// callReturn: {start: `${wrap.start}=`, end: `${wrap.end}`},
|
|
82
|
-
// call: {start: `${wrap.start}@`, end: `${wrap.end}`}
|
|
83
|
-
// }
|
|
84
|
-
// };
|
|
85
|
-
// }
|
|
86
|
-
// const ae = new ActionExpression(html, config);
|
|
87
|
-
// const win = this.ownerDocument?.defaultView || window;
|
|
88
|
-
// for (const expr of ae.getExpressions('replace')) {
|
|
89
|
-
// try {
|
|
90
|
-
// const value = FunctionUtils.executeReturn({
|
|
91
|
-
// script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
|
|
92
|
-
// context,
|
|
93
|
-
// args: groupArgs
|
|
94
|
-
// });
|
|
95
|
-
// ae.replace(expr, String(value));
|
|
96
|
-
// } catch (e) {
|
|
97
|
-
// console.error(`[SWC] Failed to execute ${expr.original}:`, e);
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
// return ae.getUnprocessedTemplate();
|
|
101
|
-
// }
|
|
102
|
-
//
|
|
103
|
-
// refresh(state: string = 'default') {
|
|
104
|
-
// this.cleanup();
|
|
105
|
-
// const portal = SwcUtils.getParentContainer(this);
|
|
106
|
-
// if (!portal) return;
|
|
107
|
-
// const win = this.ownerDocument?.defaultView || window;
|
|
108
|
-
// const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
109
|
-
// // HTMLElement에서는 children에서 template[is=swc-...] 찾기
|
|
110
|
-
// const t = Array.from(this.children).find(
|
|
111
|
-
// (el): el is HTMLTemplateElement => el.tagName === 'TEMPLATE' && el.getAttribute('is') === `swc-${state}`
|
|
112
|
-
// );
|
|
113
|
-
// if (t) {
|
|
114
|
-
// let htmlString = t.innerHTML;
|
|
115
|
-
// const groupArgs = {...helperSet, $value: this._value, $state: state, $templateHost: this};
|
|
116
|
-
// htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start: this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
|
|
117
|
-
// const temp = this.ownerDocument?.createElement('template') || document.createElement('template');
|
|
118
|
-
// temp.innerHTML = htmlString;
|
|
119
|
-
// const content = temp.content;
|
|
120
|
-
// this._nodes = Array.from(content.childNodes);
|
|
121
|
-
// this._nodes.forEach((node: any) => {
|
|
122
|
-
// if (node instanceof HTMLElement) (node as any).__template_swc_host = this;
|
|
123
|
-
// });
|
|
124
|
-
// portal.insertBefore(content, this.nextSibling);
|
|
125
|
-
// }
|
|
126
|
-
// }
|
|
127
|
-
//
|
|
128
|
-
// private cleanup() {
|
|
129
|
-
// this._nodes.forEach(n => n.parentElement?.removeChild(n));
|
|
130
|
-
// this._nodes = [];
|
|
131
|
-
// }
|
|
132
|
-
//
|
|
133
|
-
// disconnectedCallback() {
|
|
134
|
-
// this.cleanup();
|
|
135
|
-
// }
|
|
136
|
-
// }
|
|
137
|
-
//
|
|
138
|
-
// return w.customElements.whenDefined(tagName);
|
|
139
|
-
// }
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// import { changedAttributeThis } from '../../decorators/changedAttributeThis';
|
|
2
|
-
// import { SwcUtils } from '../../utils/Utils';
|
|
3
|
-
// import { FunctionUtils, ActionExpression } from '@dooboostore/core';
|
|
4
|
-
// import { ConvertUtils } from '@dooboostore/core-web';
|
|
5
|
-
// import { attributeThis } from '../../decorators';
|
|
6
|
-
//
|
|
7
|
-
// export class SwcAsyncTemplate extends HTMLTemplateElement {
|
|
8
|
-
// @attributeThis('value')
|
|
9
|
-
// _value: any;
|
|
10
|
-
// @attributeThis('replace-wrap-start')
|
|
11
|
-
// _replaceWrapStart: string | null;
|
|
12
|
-
// @attributeThis('replace-wrap-end')
|
|
13
|
-
// _replaceWrapEnd: string | null; resultValue?: any;
|
|
14
|
-
//
|
|
15
|
-
// get value(): boolean {
|
|
16
|
-
// return this._value;
|
|
17
|
-
// }
|
|
18
|
-
//
|
|
19
|
-
// set value(nv: any) {
|
|
20
|
-
// this.executeAsync(nv);
|
|
21
|
-
// }
|
|
22
|
-
//
|
|
23
|
-
// private _nodes: Node[] = [];
|
|
24
|
-
//
|
|
25
|
-
// @changedAttributeThis('value')
|
|
26
|
-
// private setValue(valueAttr?: string | null) {
|
|
27
|
-
// this.executeAsync(this._value);
|
|
28
|
-
// }
|
|
29
|
-
//
|
|
30
|
-
// // @changedAttributeThis('replace-wrap')
|
|
31
|
-
// // private setReplaceWrap() {
|
|
32
|
-
// // this.executeAsync(this._value);
|
|
33
|
-
// // }
|
|
34
|
-
//
|
|
35
|
-
// private executeAsync(result: any = this._value) {
|
|
36
|
-
// if (result === undefined || result === null) {
|
|
37
|
-
// this.refresh('default');
|
|
38
|
-
// return;
|
|
39
|
-
// }
|
|
40
|
-
//
|
|
41
|
-
// if (result instanceof Promise) {
|
|
42
|
-
// this.refresh('loading');
|
|
43
|
-
// result
|
|
44
|
-
// .then(v => {
|
|
45
|
-
// this.resultValue = v;
|
|
46
|
-
// this.refresh('success');
|
|
47
|
-
// })
|
|
48
|
-
// .catch(e => {
|
|
49
|
-
// console.error('[SWC-ASYNC] Promise rejected:', e);
|
|
50
|
-
// this.resultValue = e;
|
|
51
|
-
// this.refresh('error');
|
|
52
|
-
// });
|
|
53
|
-
// } else {
|
|
54
|
-
// this.resultValue = result;
|
|
55
|
-
// this.refresh('success');
|
|
56
|
-
// }
|
|
57
|
-
// }
|
|
58
|
-
//
|
|
59
|
-
// private replaceExpressions(html: string, groupArgs: any, context: any, wrap: {start: string, end: string}): string {
|
|
60
|
-
// let config: any = undefined;
|
|
61
|
-
// if (wrap) {
|
|
62
|
-
// config = {
|
|
63
|
-
// expression: {
|
|
64
|
-
// replace: { start: `${wrap.start}`, end: `${wrap.end}` },
|
|
65
|
-
// callReturn: { start: `${wrap.start}=`, end: `${wrap.end}` },
|
|
66
|
-
// call: { start: `${wrap.start}@`, end: `${wrap.end}` }
|
|
67
|
-
// }
|
|
68
|
-
// };
|
|
69
|
-
// }
|
|
70
|
-
// const ae = new ActionExpression(html, config);
|
|
71
|
-
// const win = this.ownerDocument?.defaultView || window;
|
|
72
|
-
//
|
|
73
|
-
// // @ts-ignore
|
|
74
|
-
// for (const expr of ae.getExpressions('replace')) {
|
|
75
|
-
// try {
|
|
76
|
-
// const value = FunctionUtils.executeReturn({
|
|
77
|
-
// script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
|
|
78
|
-
// context,
|
|
79
|
-
// args: groupArgs
|
|
80
|
-
// });
|
|
81
|
-
// ae.replace(expr, String(value));
|
|
82
|
-
// } catch (e) {
|
|
83
|
-
// console.error(`[SWC] Failed to execute ${expr.original}:`, e);
|
|
84
|
-
// }
|
|
85
|
-
// }
|
|
86
|
-
// return ae.getUnprocessedTemplate();
|
|
87
|
-
// }
|
|
88
|
-
//
|
|
89
|
-
// refresh(state: string = 'default') {
|
|
90
|
-
// // console.log('rrrrrrrrrrrrrrrrr', state);
|
|
91
|
-
// this.cleanup();
|
|
92
|
-
// const portal = SwcUtils.getParentContainer(this);
|
|
93
|
-
// if (!portal) return;
|
|
94
|
-
//
|
|
95
|
-
// const win = this.ownerDocument?.defaultView || window;
|
|
96
|
-
// const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
97
|
-
//
|
|
98
|
-
// const t = this.content.querySelector(`template[is="swc-${state}"]`) as HTMLTemplateElement;
|
|
99
|
-
// if (t) {
|
|
100
|
-
// let htmlString = t.innerHTML;
|
|
101
|
-
// const groupArgs = { ...helperSet, $value: this._value, $state: state, $templateHost: this };
|
|
102
|
-
//
|
|
103
|
-
// htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start:this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
|
|
104
|
-
//
|
|
105
|
-
// const temp = this.ownerDocument?.createElement('template') || document.createElement('template');
|
|
106
|
-
// temp.innerHTML = htmlString;
|
|
107
|
-
// const content = temp.content;
|
|
108
|
-
//
|
|
109
|
-
// this._nodes = Array.from(content.childNodes);
|
|
110
|
-
// this._nodes.forEach((node: any) => {
|
|
111
|
-
// if (node instanceof HTMLElement) (node as any).__template_swc_host = this;
|
|
112
|
-
// });
|
|
113
|
-
//
|
|
114
|
-
// portal.insertBefore(content, this.nextSibling);
|
|
115
|
-
// }
|
|
116
|
-
// }
|
|
117
|
-
//
|
|
118
|
-
// private cleanup() {
|
|
119
|
-
// this._nodes.forEach(n => n.parentElement?.removeChild(n));
|
|
120
|
-
// this._nodes = [];
|
|
121
|
-
// }
|
|
122
|
-
//
|
|
123
|
-
// disconnectedCallback() {
|
|
124
|
-
// this.cleanup();
|
|
125
|
-
// }
|
|
126
|
-
// }
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
// import {SwcUtils} from '../../utils/Utils';
|
|
2
|
-
// import {ActionExpression, FunctionUtils} from '@dooboostore/core';
|
|
3
|
-
// import {ConvertUtils} from '@dooboostore/core-web';
|
|
4
|
-
// import {elementDefine, getAttributeValue, getElementConfig} from '../../decorators';
|
|
5
|
-
//
|
|
6
|
-
// export default async (w: Window)=> {
|
|
7
|
-
// const tagName = 'swc-choose';
|
|
8
|
-
// const existing = w.customElements.get(tagName);
|
|
9
|
-
// if (existing) return existing;
|
|
10
|
-
// @elementDefine(tagName, { window: w })
|
|
11
|
-
// class SwcChoose extends w.HTMLElement {
|
|
12
|
-
// private _value: any;
|
|
13
|
-
// private _replaceWrapStart: string | null = null;
|
|
14
|
-
// private _replaceWrapEnd: string | null = null;
|
|
15
|
-
// private _nodes: Node[] = [];
|
|
16
|
-
// private _previousTemplate: HTMLTemplateElement | null = null;
|
|
17
|
-
//
|
|
18
|
-
// static get observedAttributes() {
|
|
19
|
-
// return ['value', 'replace-wrap-start', 'replace-wrap-end'];
|
|
20
|
-
// }
|
|
21
|
-
//
|
|
22
|
-
// get value(): any {
|
|
23
|
-
// return this._value;
|
|
24
|
-
// }
|
|
25
|
-
//
|
|
26
|
-
// set value(nv: any) {
|
|
27
|
-
// this._value = nv;
|
|
28
|
-
// this.refresh(this._value);
|
|
29
|
-
// }
|
|
30
|
-
//
|
|
31
|
-
// connectedCallback() {
|
|
32
|
-
// this.style.display = 'none';
|
|
33
|
-
// if (!this.id) {
|
|
34
|
-
// throw new Error('[SWC] SwcChoose must have an "id" attribute for reliable cleanup.');
|
|
35
|
-
// }
|
|
36
|
-
// if (this.hasAttribute('value')) {
|
|
37
|
-
// this.refresh();
|
|
38
|
-
// }
|
|
39
|
-
// }
|
|
40
|
-
//
|
|
41
|
-
// attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
|
|
42
|
-
// switch (name) {
|
|
43
|
-
// case 'value':
|
|
44
|
-
// this._value = newValue;
|
|
45
|
-
// this.refresh(this._value);
|
|
46
|
-
// break;
|
|
47
|
-
// case 'replace-wrap-start':
|
|
48
|
-
// this._replaceWrapStart = newValue;
|
|
49
|
-
// break;
|
|
50
|
-
// case 'replace-wrap-end':
|
|
51
|
-
// this._replaceWrapEnd = newValue;
|
|
52
|
-
// break;
|
|
53
|
-
// }
|
|
54
|
-
// }
|
|
55
|
-
//
|
|
56
|
-
// private replaceExpressions(html: string, groupArgs: any, context: any, wrap: { start: string, end: string }): string {
|
|
57
|
-
// let config: any = undefined;
|
|
58
|
-
// if (wrap) {
|
|
59
|
-
// config = {
|
|
60
|
-
// expression: {
|
|
61
|
-
// replace: {start: `${wrap.start}`, end: `${wrap.end}`},
|
|
62
|
-
// callReturn: {start: `${wrap.start}=`, end: `${wrap.end}`},
|
|
63
|
-
// call: {start: `${wrap.start}@`, end: `${wrap.end}`}
|
|
64
|
-
// }
|
|
65
|
-
// };
|
|
66
|
-
// }
|
|
67
|
-
// const ae = new ActionExpression(html, config);
|
|
68
|
-
// const win = this.ownerDocument?.defaultView || window;
|
|
69
|
-
// for (const expr of ae.getExpressions('replace')) {
|
|
70
|
-
// try {
|
|
71
|
-
// const value = FunctionUtils.executeReturn({
|
|
72
|
-
// script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
|
|
73
|
-
// context,
|
|
74
|
-
// args: groupArgs
|
|
75
|
-
// });
|
|
76
|
-
// ae.replace(expr, String(value));
|
|
77
|
-
// } catch (e) {
|
|
78
|
-
// console.error(`[SWC] Failed to execute ${expr.original}:`, e);
|
|
79
|
-
// }
|
|
80
|
-
// }
|
|
81
|
-
// return ae.getUnprocessedTemplate();
|
|
82
|
-
// }
|
|
83
|
-
//
|
|
84
|
-
// refresh(value?: any) {
|
|
85
|
-
// if (!this.id) return;
|
|
86
|
-
// value = value ?? getAttributeValue(this, 'value') ?? this._value;
|
|
87
|
-
// const portal = SwcUtils.getParentContainer(this);
|
|
88
|
-
// if (!portal) return;
|
|
89
|
-
// const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
|
|
90
|
-
// const helperSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
91
|
-
// const groupArgs = {...helperSet, $value: value, $templateHost: this};
|
|
92
|
-
// // HTMLElement에서는 children에서 template 찾기
|
|
93
|
-
// const templates = Array.from(this.children).filter(
|
|
94
|
-
// (el): el is HTMLTemplateElement => el.tagName === 'TEMPLATE'
|
|
95
|
-
// );
|
|
96
|
-
// let selected: HTMLTemplateElement | null = null;
|
|
97
|
-
// for (const t of templates) {
|
|
98
|
-
// if (t.getAttribute('is') === 'swc-when') {
|
|
99
|
-
// const attrVal = t.getAttribute('test') || '';
|
|
100
|
-
// let matches = false;
|
|
101
|
-
// const result = FunctionUtils.executeReturn({
|
|
102
|
-
// script: attrVal,
|
|
103
|
-
// context: t,
|
|
104
|
-
// args: groupArgs
|
|
105
|
-
// });
|
|
106
|
-
// matches = !!result;
|
|
107
|
-
// if (matches) {
|
|
108
|
-
// selected = t;
|
|
109
|
-
// break;
|
|
110
|
-
// }
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
|
-
// const target = selected || (templates.find(t => t.getAttribute('is') === 'swc-otherwise') ?? null);
|
|
114
|
-
// const skipValue = target?.getAttribute?.('skip-if-same');
|
|
115
|
-
// const skipValue2 = this._previousTemplate?.getAttribute?.('skip-if-same');
|
|
116
|
-
// const hasSkipIfSame = target?.hasAttribute?.('skip-if-same');
|
|
117
|
-
// const isSame = this._previousTemplate === target;
|
|
118
|
-
// if (hasSkipIfSame && isSame) {
|
|
119
|
-
// return;
|
|
120
|
-
// }
|
|
121
|
-
// this.cleanup();
|
|
122
|
-
// this._previousTemplate = target;
|
|
123
|
-
// if (target) {
|
|
124
|
-
// let htmlString = target.innerHTML;
|
|
125
|
-
// htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start: this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
|
|
126
|
-
// const result = this.ownerDocument?.createElement('template') || document.createElement('template');
|
|
127
|
-
// result.innerHTML = htmlString;
|
|
128
|
-
// const processedFragment = result.content;
|
|
129
|
-
// this._nodes = Array.from(processedFragment.childNodes);
|
|
130
|
-
// const setTemplateHost = (element: HTMLElement) => {
|
|
131
|
-
// (element as any).__swc_template_host = this;
|
|
132
|
-
// Array.from(element.children).forEach((child: any) => {
|
|
133
|
-
// if (child instanceof HTMLElement) {
|
|
134
|
-
// setTemplateHost(child);
|
|
135
|
-
// }
|
|
136
|
-
// });
|
|
137
|
-
// };
|
|
138
|
-
// this._nodes.forEach((node: any) => {
|
|
139
|
-
// if (node instanceof HTMLElement) {
|
|
140
|
-
// setTemplateHost(node as HTMLElement);
|
|
141
|
-
// }
|
|
142
|
-
// });
|
|
143
|
-
// const endpoint = this.ownerDocument?.createComment(`swc-choose endpoint id:${this.id}`) || document.createComment(`swc-choose endpoint id:${this.id}`);
|
|
144
|
-
// processedFragment.appendChild(endpoint);
|
|
145
|
-
// this._nodes.push(endpoint);
|
|
146
|
-
// portal.insertBefore(processedFragment, this.nextSibling);
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
|
-
//
|
|
150
|
-
// private cleanup() {
|
|
151
|
-
// if (this.id) {
|
|
152
|
-
// const portal = SwcUtils.getParentContainer(this);
|
|
153
|
-
// if (portal) {
|
|
154
|
-
// const endpointText = `swc-choose endpoint id:${this.id}`;
|
|
155
|
-
// let current = this.nextSibling;
|
|
156
|
-
// const toRemove: Node[] = [];
|
|
157
|
-
// while (current) {
|
|
158
|
-
// toRemove.push(current);
|
|
159
|
-
// if (current.nodeType === 8 && (current as Comment).data === endpointText) {
|
|
160
|
-
// toRemove.forEach(n => {
|
|
161
|
-
// const realNode = (n as any).__upgraded_instance || n;
|
|
162
|
-
// if (realNode.parentElement) {
|
|
163
|
-
// realNode.parentElement.removeChild(realNode);
|
|
164
|
-
// }
|
|
165
|
-
// });
|
|
166
|
-
// break;
|
|
167
|
-
// }
|
|
168
|
-
// current = current.nextSibling;
|
|
169
|
-
// }
|
|
170
|
-
// }
|
|
171
|
-
// }
|
|
172
|
-
// this._nodes = [];
|
|
173
|
-
// }
|
|
174
|
-
//
|
|
175
|
-
// disconnectedCallback() {
|
|
176
|
-
// this.cleanup();
|
|
177
|
-
// }
|
|
178
|
-
// }
|
|
179
|
-
//
|
|
180
|
-
// return w.customElements.whenDefined(tagName);
|
|
181
|
-
//
|
|
182
|
-
// }
|