@dooboostore/simple-web-component 1.0.35 → 1.0.37
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 +58 -21
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +6 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +12 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +19 -18
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +23 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +28 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +122 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +16 -15
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
- package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +59 -50
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +18 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +56 -8
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +38 -60
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +31 -63
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +13 -12
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/index.js +21 -2
- package/dist/cjs/elements/index.js.map +3 -3
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +12 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +22 -19
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +12 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +19 -18
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +23 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +28 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +103 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +16 -15
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +60 -51
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +18 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +56 -8
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +38 -60
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +31 -63
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +13 -12
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/index.js +7 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +22 -19
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4189 -456
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -7
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +4 -4
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -6
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +9 -9
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts +4 -4
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -5
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
- package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
- package/dist/types/decorators/emitCustomEvent.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/lifecycles.d.ts +21 -6
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +17 -63
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -63
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +7 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +13 -12
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4189 -456
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
- package/src/decorators/addEventListener.ts +11 -9
- package/src/decorators/applyAttribute.ts +16 -15
- package/src/decorators/applyClass.ts +18 -17
- package/src/decorators/applyNode.ts +30 -27
- package/src/decorators/applySlot.ts +228 -0
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +20 -19
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
- package/src/decorators/elementDefine.ts +80 -57
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +2 -1
- package/src/decorators/lifecycles.ts +76 -11
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
- package/src/elements/index.ts +11 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +13 -9
- package/src/types/window.d.ts +43 -0
- package/src/types.ts +9 -8
- package/src/utils/Utils.ts +28 -24
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAppMixin.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAppMixin.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAppMixin.d.ts +0 -386
- package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -8,21 +8,76 @@ export const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-compone
|
|
|
8
8
|
export const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');
|
|
9
9
|
export const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');
|
|
10
10
|
export const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');
|
|
11
|
+
export const ON_CONNECTED_INNER_HTML_METADATA_KEY = Symbol.for('simple-web-component:inner-html');
|
|
11
12
|
export const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');
|
|
12
|
-
export const
|
|
13
|
+
export const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');
|
|
13
14
|
|
|
14
15
|
export const ATTRIBUTE_CHANGED_WILDCARD = '*';
|
|
15
16
|
|
|
16
17
|
export interface InnerHtmlOptions {
|
|
18
|
+
ssrFirst?: boolean;
|
|
17
19
|
replaceWrap?:{ start: string, end:string},
|
|
18
20
|
useShadow?: boolean;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
22
|
export interface InnerHtmlMetadata {
|
|
22
23
|
propertyKey: string | symbol;
|
|
23
24
|
options: InnerHtmlOptions;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
export interface OnConnectedOptions {
|
|
28
|
+
ssrFirst?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface OnConnectedMetadata {
|
|
31
|
+
propertyKey: string | symbol;
|
|
32
|
+
options: OnConnectedOptions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export function onConnectedBefore(options: OnConnectedOptions): MethodDecorator;
|
|
37
|
+
export function onConnectedBefore(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
38
|
+
export function onConnectedBefore(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
39
|
+
const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {
|
|
40
|
+
const constructor = target.constructor;
|
|
41
|
+
let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor);
|
|
42
|
+
if (!list) {
|
|
43
|
+
list = [];
|
|
44
|
+
ReflectUtils.defineMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, list, constructor);
|
|
45
|
+
}
|
|
46
|
+
list.push({ propertyKey, options });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (arg2) {
|
|
50
|
+
return decorator({}, arg1!, arg2);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
54
|
+
decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function onConnectedAfter(options: OnConnectedOptions): MethodDecorator;
|
|
59
|
+
export function onConnectedAfter(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
60
|
+
export function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
61
|
+
const decorator = (options: OnConnectedOptions, target: Object, propertyKey: string | symbol) => {
|
|
62
|
+
const constructor = target.constructor;
|
|
63
|
+
let list = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor);
|
|
64
|
+
if (!list) {
|
|
65
|
+
list = [];
|
|
66
|
+
ReflectUtils.defineMetadata(ON_AFTER_CONNECTED_METADATA_KEY, list, constructor);
|
|
67
|
+
}
|
|
68
|
+
list.push({ propertyKey, options });
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (arg2) {
|
|
72
|
+
return decorator({}, arg1!, arg2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
76
|
+
decorator((arg1 as OnConnectedOptions) || {}, target, propertyKey);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
26
81
|
function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
|
|
27
82
|
return (target: Object, propertyKey: string | symbol) => {
|
|
28
83
|
const constructor = target.constructor;
|
|
@@ -36,8 +91,8 @@ function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
|
|
|
36
91
|
}
|
|
37
92
|
|
|
38
93
|
export const onInitialize = createLifecycleDecorator(ON_INITIALIZE_METADATA_KEY);
|
|
39
|
-
export const onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
40
|
-
export const onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
94
|
+
// export const onConnectedBefore = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
95
|
+
// export const onConnectedAfter = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
|
|
41
96
|
export const onConnected = onConnectedAfter;
|
|
42
97
|
|
|
43
98
|
export const onDisconnectedBefore = createLifecycleDecorator(ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
@@ -50,7 +105,8 @@ export const onAdopted = onAdoptedAfter;
|
|
|
50
105
|
|
|
51
106
|
export const onAddEventListener = createLifecycleDecorator(ON_ADD_EVENT_LISTENER_METADATA_KEY);
|
|
52
107
|
|
|
53
|
-
|
|
108
|
+
export const onConnectedSwcApp = createLifecycleDecorator(ON_CONNECTED_SWC_APP_METADATA_KEY);
|
|
109
|
+
export const onConnectedCompleted = createLifecycleDecorator(ON_CONNECTED_COMPLETED_METADATA_KEY);
|
|
54
110
|
|
|
55
111
|
/**
|
|
56
112
|
* @onConnectedInnerHtml decorator to define the initial HTML content when connected.
|
|
@@ -60,10 +116,10 @@ export function onConnectedInnerHtml(target: Object, propertyKey: string | symbo
|
|
|
60
116
|
export function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
61
117
|
const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {
|
|
62
118
|
const constructor = target.constructor;
|
|
63
|
-
let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(
|
|
119
|
+
let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(ON_CONNECTED_INNER_HTML_METADATA_KEY, constructor);
|
|
64
120
|
if (!list) {
|
|
65
121
|
list = [];
|
|
66
|
-
ReflectUtils.defineMetadata(
|
|
122
|
+
ReflectUtils.defineMetadata(ON_CONNECTED_INNER_HTML_METADATA_KEY, list, constructor);
|
|
67
123
|
}
|
|
68
124
|
list.push({ propertyKey, options });
|
|
69
125
|
};
|
|
@@ -80,12 +136,21 @@ export function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: st
|
|
|
80
136
|
/**
|
|
81
137
|
* 프로토타입 체인을 순회하며 모든 라이프사이클 메서드를 수집합니다.
|
|
82
138
|
*/
|
|
83
|
-
export const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {
|
|
139
|
+
// export const findAllLifecycleMetadata = <T = (string | symbol)[]>(target: any, metadataKey: symbol): T | undefined => {
|
|
140
|
+
export const findAllLifecycleMetadata = (target: any, metadataKey: symbol): (string | symbol)[] => {
|
|
84
141
|
const results = ReflectUtils.findAllMetadataFlatten(metadataKey, target);
|
|
85
|
-
return results
|
|
142
|
+
return results;
|
|
86
143
|
};
|
|
87
144
|
|
|
88
|
-
export const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[]
|
|
145
|
+
export const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] => {
|
|
146
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
147
|
+
return ReflectUtils.getMetadata(ON_CONNECTED_INNER_HTML_METADATA_KEY, constructor) ?? [];
|
|
148
|
+
};
|
|
149
|
+
export const getOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {
|
|
150
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
151
|
+
return ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
152
|
+
};
|
|
153
|
+
export const getOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {
|
|
89
154
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
90
|
-
return ReflectUtils.getMetadata(
|
|
155
|
+
return ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
91
156
|
};
|
package/src/decorators/query.ts
CHANGED
|
@@ -30,8 +30,6 @@ export function query(selectorOrTarget: string, options: any = {}): PropertyDeco
|
|
|
30
30
|
}
|
|
31
31
|
queries.push({ propertyKey, selector: selectorOrTarget, options });
|
|
32
32
|
|
|
33
|
-
// const propertyType = Reflect.getMetadata("design:type", targetObj, propertyKey);
|
|
34
|
-
// console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);
|
|
35
33
|
Object.defineProperty(targetObj, propertyKey, {
|
|
36
34
|
get(this: HTMLElement) {
|
|
37
35
|
ensureInit(this);
|
|
@@ -43,25 +41,26 @@ export function query(selectorOrTarget: string, options: any = {}): PropertyDeco
|
|
|
43
41
|
if (r === 'auto') return t.shadowRoot || t;
|
|
44
42
|
if (r === 'shadow') return t.shadowRoot;
|
|
45
43
|
if (r === 'light') return t;
|
|
46
|
-
if (r === 'all') return t.shadowRoot || t;
|
|
44
|
+
if (r === 'all') return t.shadowRoot || t;
|
|
47
45
|
return t;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
// --- Special Selectors: HostSet ---
|
|
51
49
|
const hostSet = SwcUtils.getHostSet(this);
|
|
52
|
-
if (selector === '
|
|
53
|
-
if (selector === '
|
|
54
|
-
if (selector === '
|
|
55
|
-
if (selector === '
|
|
56
|
-
if (selector === '
|
|
57
|
-
if (selector === '
|
|
50
|
+
if (selector === '$this') return applyRoot(this);
|
|
51
|
+
if (selector === '$host') return applyRoot(hostSet.$host);
|
|
52
|
+
if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
|
|
53
|
+
if (selector === '$appHost') return applyRoot(hostSet.$appHost);
|
|
54
|
+
if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
|
|
55
|
+
if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
|
|
56
|
+
if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
|
|
57
|
+
if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
|
|
58
58
|
|
|
59
59
|
// --- Special Selectors: Env ---
|
|
60
60
|
const config = getElementConfig(this);
|
|
61
61
|
const win = config?.window || window;
|
|
62
|
-
if (selector === '
|
|
63
|
-
if (selector === '
|
|
64
|
-
if (selector === ':host') return applyRoot(this);
|
|
62
|
+
if (selector === '$window') return win;
|
|
63
|
+
if (selector === '$document') return win.document;
|
|
65
64
|
|
|
66
65
|
// --- Standard Selectors ---
|
|
67
66
|
if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
@@ -76,7 +75,7 @@ export function query(selectorOrTarget: string, options: any = {}): PropertyDeco
|
|
|
76
75
|
ensureInit(this);
|
|
77
76
|
if (nv === null || nv === undefined) {
|
|
78
77
|
const selector = selectorOrTarget;
|
|
79
|
-
if (selector.startsWith('
|
|
78
|
+
if (selector.startsWith('$') && selector !== '$this') return;
|
|
80
79
|
|
|
81
80
|
const r = options.root || 'auto';
|
|
82
81
|
const targets: Element[] = [];
|
|
@@ -103,157 +102,85 @@ export function query(selectorOrTarget: string, options: any = {}): PropertyDeco
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
|
-
* @
|
|
107
|
-
* Usage: @queryHost testzzs: HTMLElement | undefined;
|
|
108
|
-
* Usage: @queryHost() testzzs: HTMLElement | undefined;
|
|
109
|
-
* Usage: @queryHost({ root: 'shadow' }) testzzs: HTMLElement | undefined;
|
|
105
|
+
* @queryThis decorator - simplified version of @query for $this selector
|
|
110
106
|
*/
|
|
111
|
-
export function
|
|
112
|
-
export function
|
|
113
|
-
export function
|
|
114
|
-
export function
|
|
115
|
-
// Direct decorator usage: @queryHost (no parentheses)
|
|
116
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
117
|
-
return query(':host', {})(targetOrOptions, propertyKey);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// @queryHost() or @queryHost(options)
|
|
121
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
122
|
-
return query(':host', targetOrOptions as SwcQueryOptions);
|
|
123
|
-
} else {
|
|
124
|
-
return query(':host', {});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @host - Alias for @queryHost decorator
|
|
130
|
-
* Usage: @host element: HTMLElement | undefined;
|
|
131
|
-
* Usage: @host() element: HTMLElement | undefined;
|
|
132
|
-
* Usage: @host({ root: 'shadow' }) element: HTMLElement | undefined;
|
|
133
|
-
*/
|
|
134
|
-
export const host = queryHost;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @parentHost - Query :parentHost (Direct parent SWC component)
|
|
138
|
-
* Usage: @parentHost parent: HTMLElement | undefined;
|
|
139
|
-
* Usage: @parentHost() parent: HTMLElement | undefined;
|
|
140
|
-
* Usage: @parentHost({ root: 'shadow' }) parent: HTMLElement | undefined;
|
|
141
|
-
*/
|
|
142
|
-
export function parentHost(target: Object, propertyKey: string | symbol): void;
|
|
143
|
-
export function parentHost(): PropertyDecorator;
|
|
144
|
-
export function parentHost(options: SwcQueryOptions): PropertyDecorator;
|
|
145
|
-
export function parentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
107
|
+
export function queryThis(target: Object, propertyKey: string | symbol): void;
|
|
108
|
+
export function queryThis(): PropertyDecorator;
|
|
109
|
+
export function queryThis(options: SwcQueryOptions): PropertyDecorator;
|
|
110
|
+
export function queryThis(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
146
111
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
147
|
-
return query('
|
|
112
|
+
return query('$this', {})(targetOrOptions, propertyKey);
|
|
148
113
|
}
|
|
149
114
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
150
|
-
return query('
|
|
115
|
+
return query('$this', targetOrOptions as SwcQueryOptions);
|
|
151
116
|
} else {
|
|
152
|
-
return query('
|
|
117
|
+
return query('$this', {});
|
|
153
118
|
}
|
|
154
119
|
}
|
|
155
120
|
|
|
156
|
-
/**
|
|
157
|
-
* @appHost - Query :appHost (Nearest <swc-app>)
|
|
158
|
-
* Usage: @appHost app: SwcAppInterface | undefined;
|
|
159
|
-
* Usage: @appHost() app: SwcAppInterface | undefined;
|
|
160
|
-
* Usage: @appHost({ root: 'shadow' }) app: SwcAppInterface | undefined;
|
|
161
|
-
*/
|
|
162
|
-
export function appHost(target: Object, propertyKey: string | symbol): void;
|
|
163
|
-
export function appHost(): PropertyDecorator;
|
|
164
|
-
export function appHost(options: SwcQueryOptions): PropertyDecorator;
|
|
165
|
-
export function appHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
166
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
167
|
-
return query(':appHost', {})(targetOrOptions, propertyKey);
|
|
168
|
-
}
|
|
169
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
170
|
-
return query(':appHost', targetOrOptions as SwcQueryOptions);
|
|
171
|
-
} else {
|
|
172
|
-
return query(':appHost', {});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
121
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* Usage: @firstHost({ root: 'shadow' }) first: HTMLElement | undefined;
|
|
181
|
-
*/
|
|
182
|
-
export function firstHost(target: Object, propertyKey: string | symbol): void;
|
|
183
|
-
export function firstHost(): PropertyDecorator;
|
|
184
|
-
export function firstHost(options: SwcQueryOptions): PropertyDecorator;
|
|
185
|
-
export function firstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
122
|
+
export function queryWindow(target: Object, propertyKey: string | symbol): void;
|
|
123
|
+
export function queryWindow(): PropertyDecorator;
|
|
124
|
+
export function queryWindow(options: SwcQueryOptions): PropertyDecorator;
|
|
125
|
+
export function queryWindow(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
186
126
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
187
|
-
return query('
|
|
127
|
+
return query('$window', {})(targetOrOptions, propertyKey);
|
|
188
128
|
}
|
|
189
129
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
190
|
-
return query('
|
|
130
|
+
return query('$window', targetOrOptions as SwcQueryOptions);
|
|
191
131
|
} else {
|
|
192
|
-
return query('
|
|
132
|
+
return query('$window', {});
|
|
193
133
|
}
|
|
194
134
|
}
|
|
195
135
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* Usage: @lastHost({ root: 'shadow' }) last: HTMLElement | undefined;
|
|
201
|
-
*/
|
|
202
|
-
export function lastHost(target: Object, propertyKey: string | symbol): void;
|
|
203
|
-
export function lastHost(): PropertyDecorator;
|
|
204
|
-
export function lastHost(options: SwcQueryOptions): PropertyDecorator;
|
|
205
|
-
export function lastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
136
|
+
export function queryDocument(target: Object, propertyKey: string | symbol): void;
|
|
137
|
+
export function queryDocument(): PropertyDecorator;
|
|
138
|
+
export function queryDocument(options: SwcQueryOptions): PropertyDecorator;
|
|
139
|
+
export function queryDocument(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
206
140
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
207
|
-
return query('
|
|
141
|
+
return query('$document', {})(targetOrOptions, propertyKey);
|
|
208
142
|
}
|
|
209
143
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
210
|
-
return query('
|
|
144
|
+
return query('$document', targetOrOptions as SwcQueryOptions);
|
|
211
145
|
} else {
|
|
212
|
-
return query('
|
|
146
|
+
return query('$document', {});
|
|
213
147
|
}
|
|
214
148
|
}
|
|
215
|
-
|
|
216
149
|
/**
|
|
217
|
-
* @
|
|
218
|
-
* Usage: @firstAppHost app: SwcAppInterface | undefined;
|
|
219
|
-
* Usage: @firstAppHost() app: SwcAppInterface | undefined;
|
|
220
|
-
* Usage: @firstAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;
|
|
150
|
+
* @host - Query $host (Direct parent SWC component)
|
|
221
151
|
*/
|
|
222
|
-
export function
|
|
223
|
-
export function
|
|
224
|
-
export function
|
|
225
|
-
export function
|
|
152
|
+
export function queryHost(target: Object, propertyKey: string | symbol): void;
|
|
153
|
+
export function queryHost(): PropertyDecorator;
|
|
154
|
+
export function queryHost(options: SwcQueryOptions): PropertyDecorator;
|
|
155
|
+
export function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
226
156
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
227
|
-
return query('
|
|
157
|
+
return query('$host', {})(targetOrOptions, propertyKey);
|
|
228
158
|
}
|
|
229
159
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
230
|
-
return query('
|
|
160
|
+
return query('$host', targetOrOptions as SwcQueryOptions);
|
|
231
161
|
} else {
|
|
232
|
-
return query('
|
|
162
|
+
return query('$host', {});
|
|
233
163
|
}
|
|
234
164
|
}
|
|
235
165
|
|
|
236
166
|
/**
|
|
237
|
-
* @
|
|
238
|
-
* Usage: @lastAppHost app: SwcAppInterface | undefined;
|
|
239
|
-
* Usage: @lastAppHost() app: SwcAppInterface | undefined;
|
|
240
|
-
* Usage: @lastAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;
|
|
167
|
+
* @appHost - Query $appHost (Nearest <swc-app>)
|
|
241
168
|
*/
|
|
242
|
-
export function
|
|
243
|
-
export function
|
|
244
|
-
export function
|
|
245
|
-
export function
|
|
169
|
+
export function queryAppHost(target: Object, propertyKey: string | symbol): void;
|
|
170
|
+
export function queryAppHost(): PropertyDecorator;
|
|
171
|
+
export function queryAppHost(options: SwcQueryOptions): PropertyDecorator;
|
|
172
|
+
export function queryAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
246
173
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
247
|
-
return query('
|
|
174
|
+
return query('$appHost', {})(targetOrOptions, propertyKey);
|
|
248
175
|
}
|
|
249
176
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
250
|
-
return query('
|
|
177
|
+
return query('$appHost', targetOrOptions as SwcQueryOptions);
|
|
251
178
|
} else {
|
|
252
|
-
return query('
|
|
179
|
+
return query('$appHost', {});
|
|
253
180
|
}
|
|
254
181
|
}
|
|
255
182
|
|
|
256
183
|
export const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {
|
|
257
184
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
258
185
|
return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
259
|
-
};
|
|
186
|
+
};
|
|
@@ -56,15 +56,22 @@ export function queryAll(selectorOrTarget: string, options: any = {}): PropertyD
|
|
|
56
56
|
|
|
57
57
|
// --- Special Selectors: HostSet ---
|
|
58
58
|
const hostSet = SwcUtils.getHostSet(this);
|
|
59
|
-
if (selector === '
|
|
60
|
-
if (selector === '
|
|
59
|
+
if (selector === '$hosts') return applyRoot(hostSet.$hosts);
|
|
60
|
+
if (selector === '$appHosts') return applyRoot(hostSet.$appHosts);
|
|
61
|
+
if (selector === '$host') return applyRoot(hostSet.$host);
|
|
62
|
+
if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
|
|
63
|
+
if (selector === '$appHost') return applyRoot(hostSet.$appHost);
|
|
64
|
+
if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
|
|
65
|
+
if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
|
|
66
|
+
if (selector === '$firstAppHost') return applyRoot(hostSet.$firstAppHost);
|
|
67
|
+
if (selector === '$lastAppHost') return applyRoot(hostSet.$lastAppHost);
|
|
61
68
|
|
|
62
69
|
// --- Special Selectors: Env ---
|
|
63
70
|
const config = getElementConfig(this);
|
|
64
71
|
const win = config?.window || window;
|
|
65
|
-
if (selector === '
|
|
66
|
-
if (selector === '
|
|
67
|
-
if (selector === '
|
|
72
|
+
if (selector === '$window') return [win];
|
|
73
|
+
if (selector === '$document') return [win.document];
|
|
74
|
+
if (selector === '$this') return applyRoot(this);
|
|
68
75
|
|
|
69
76
|
// --- Standard Selectors ---
|
|
70
77
|
if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
@@ -81,7 +88,7 @@ export function queryAll(selectorOrTarget: string, options: any = {}): PropertyD
|
|
|
81
88
|
ensureInit(this);
|
|
82
89
|
if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {
|
|
83
90
|
const selector = selectorOrTarget;
|
|
84
|
-
if (selector.startsWith('
|
|
91
|
+
if (selector.startsWith('$') && selector !== '$this') return;
|
|
85
92
|
|
|
86
93
|
const r = options.root || 'auto';
|
|
87
94
|
let targets: (Element | Node)[] = [];
|
|
@@ -102,164 +109,60 @@ export function queryAll(selectorOrTarget: string, options: any = {}): PropertyD
|
|
|
102
109
|
});
|
|
103
110
|
};
|
|
104
111
|
}
|
|
112
|
+
|
|
105
113
|
/**
|
|
106
|
-
* @
|
|
107
|
-
* Usage: @hostQueryAll()
|
|
108
|
-
* Usage: @hostQueryAll({ root: 'shadow' })
|
|
109
|
-
*/
|
|
110
|
-
/**
|
|
111
|
-
* @queryAllHost decorator - simplified version of @queryAll for :host selector
|
|
112
|
-
* Usage: @queryAllHost items: HTMLElement[];
|
|
113
|
-
* Usage: @queryAllHost() items: HTMLElement[];
|
|
114
|
-
* Usage: @queryAllHost({ root: 'shadow' }) items: HTMLElement[];
|
|
114
|
+
* @queryAllThis decorator - simplified version of @queryAll for $this selector
|
|
115
115
|
*/
|
|
116
|
-
export function
|
|
117
|
-
export function
|
|
118
|
-
export function
|
|
119
|
-
export function
|
|
120
|
-
// Direct decorator usage: @queryAllHost (no parentheses)
|
|
116
|
+
export function queryAllThis(target: Object, propertyKey: string | symbol): void;
|
|
117
|
+
export function queryAllThis(): PropertyDecorator;
|
|
118
|
+
export function queryAllThis(options: SwcQueryOptions): PropertyDecorator;
|
|
119
|
+
export function queryAllThis(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
121
120
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
122
|
-
return queryAll('
|
|
121
|
+
return queryAll('$this', {})(targetOrOptions, propertyKey);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
// @queryAllHost() or @queryAllHost(options)
|
|
126
124
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
127
|
-
return queryAll('
|
|
125
|
+
return queryAll('$this', targetOrOptions as SwcQueryOptions);
|
|
128
126
|
} else {
|
|
129
|
-
return queryAll('
|
|
127
|
+
return queryAll('$this', {});
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
/**
|
|
134
|
-
* @
|
|
135
|
-
* Usage: @allHost items: HTMLElement[];
|
|
136
|
-
* Usage: @allHost() items: HTMLElement[];
|
|
137
|
-
* Usage: @allHost({ root: 'shadow' }) items: HTMLElement[];
|
|
138
|
-
*/
|
|
139
|
-
export const allHost = queryAllHost;
|
|
140
|
-
/**
|
|
141
|
-
* @allParentHost - Query all :parentHost (All parent SWC components)
|
|
142
|
-
* Usage: @allParentHost parents: HTMLElement[];
|
|
143
|
-
* Usage: @allParentHost() parents: HTMLElement[];
|
|
144
|
-
* Usage: @allParentHost({ root: 'shadow' }) parents: HTMLElement[];
|
|
132
|
+
* @allParentHost - Query all parent SWC components
|
|
145
133
|
*/
|
|
146
134
|
export function allParentHost(target: Object, propertyKey: string | symbol): void;
|
|
147
135
|
export function allParentHost(): PropertyDecorator;
|
|
148
136
|
export function allParentHost(options: SwcQueryOptions): PropertyDecorator;
|
|
149
137
|
export function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
150
138
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
151
|
-
return queryAll('
|
|
139
|
+
return queryAll('$host', {})(targetOrOptions, propertyKey);
|
|
152
140
|
}
|
|
153
141
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
154
|
-
return queryAll('
|
|
142
|
+
return queryAll('$host', targetOrOptions as SwcQueryOptions);
|
|
155
143
|
} else {
|
|
156
|
-
return queryAll('
|
|
144
|
+
return queryAll('$host', {});
|
|
157
145
|
}
|
|
158
146
|
}
|
|
159
147
|
|
|
160
148
|
/**
|
|
161
|
-
* @allAppHost - Query all
|
|
162
|
-
* Usage: @allAppHost apps: SwcAppInterface[];
|
|
163
|
-
* Usage: @allAppHost() apps: SwcAppInterface[];
|
|
164
|
-
* Usage: @allAppHost({ root: 'shadow' }) apps: SwcAppInterface[];
|
|
149
|
+
* @allAppHost - Query all $appHost (All <swc-app> instances)
|
|
165
150
|
*/
|
|
166
151
|
export function allAppHost(target: Object, propertyKey: string | symbol): void;
|
|
167
152
|
export function allAppHost(): PropertyDecorator;
|
|
168
153
|
export function allAppHost(options: SwcQueryOptions): PropertyDecorator;
|
|
169
154
|
export function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
170
155
|
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
171
|
-
return queryAll('
|
|
172
|
-
}
|
|
173
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
174
|
-
return queryAll(':appHost', targetOrOptions as SwcQueryOptions);
|
|
175
|
-
} else {
|
|
176
|
-
return queryAll(':appHost', {});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @allFirstHost - Query all :firstHost (All first components in hierarchy)
|
|
182
|
-
* Usage: @allFirstHost firsts: HTMLElement[];
|
|
183
|
-
* Usage: @allFirstHost() firsts: HTMLElement[];
|
|
184
|
-
* Usage: @allFirstHost({ root: 'shadow' }) firsts: HTMLElement[];
|
|
185
|
-
*/
|
|
186
|
-
export function allFirstHost(target: Object, propertyKey: string | symbol): void;
|
|
187
|
-
export function allFirstHost(): PropertyDecorator;
|
|
188
|
-
export function allFirstHost(options: SwcQueryOptions): PropertyDecorator;
|
|
189
|
-
export function allFirstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
190
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
191
|
-
return queryAll(':firstHost', {})(targetOrOptions, propertyKey);
|
|
156
|
+
return queryAll('$appHost', {})(targetOrOptions, propertyKey);
|
|
192
157
|
}
|
|
193
158
|
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
194
|
-
return queryAll('
|
|
159
|
+
return queryAll('$appHost', targetOrOptions as SwcQueryOptions);
|
|
195
160
|
} else {
|
|
196
|
-
return queryAll('
|
|
161
|
+
return queryAll('$appHost', {});
|
|
197
162
|
}
|
|
198
163
|
}
|
|
199
164
|
|
|
200
|
-
/**
|
|
201
|
-
* @allLastHost - Query all :lastHost (All last components in hierarchy)
|
|
202
|
-
* Usage: @allLastHost lasts: HTMLElement[];
|
|
203
|
-
* Usage: @allLastHost() lasts: HTMLElement[];
|
|
204
|
-
* Usage: @allLastHost({ root: 'shadow' }) lasts: HTMLElement[];
|
|
205
|
-
*/
|
|
206
|
-
export function allLastHost(target: Object, propertyKey: string | symbol): void;
|
|
207
|
-
export function allLastHost(): PropertyDecorator;
|
|
208
|
-
export function allLastHost(options: SwcQueryOptions): PropertyDecorator;
|
|
209
|
-
export function allLastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
210
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
211
|
-
return queryAll(':lastHost', {})(targetOrOptions, propertyKey);
|
|
212
|
-
}
|
|
213
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
214
|
-
return queryAll(':lastHost', targetOrOptions as SwcQueryOptions);
|
|
215
|
-
} else {
|
|
216
|
-
return queryAll(':lastHost', {});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @allFirstAppHost - Query all :firstAppHost (All first <swc-app> in hierarchy)
|
|
222
|
-
* Usage: @allFirstAppHost apps: SwcAppInterface[];
|
|
223
|
-
* Usage: @allFirstAppHost() apps: SwcAppInterface[];
|
|
224
|
-
* Usage: @allFirstAppHost({ root: 'shadow' }) apps: SwcAppInterface[];
|
|
225
|
-
*/
|
|
226
|
-
export function allFirstAppHost(target: Object, propertyKey: string | symbol): void;
|
|
227
|
-
export function allFirstAppHost(): PropertyDecorator;
|
|
228
|
-
export function allFirstAppHost(options: SwcQueryOptions): PropertyDecorator;
|
|
229
|
-
export function allFirstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
230
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
231
|
-
return queryAll(':firstAppHost', {})(targetOrOptions, propertyKey);
|
|
232
|
-
}
|
|
233
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
234
|
-
return queryAll(':firstAppHost', targetOrOptions as SwcQueryOptions);
|
|
235
|
-
} else {
|
|
236
|
-
return queryAll(':firstAppHost', {});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @allLastAppHost - Query all :lastAppHost (All last <swc-app> in hierarchy)
|
|
242
|
-
* Usage: @allLastAppHost apps: SwcAppInterface[];
|
|
243
|
-
* Usage: @allLastAppHost() apps: SwcAppInterface[];
|
|
244
|
-
* Usage: @allLastAppHost({ root: 'shadow' }) apps: SwcAppInterface[];
|
|
245
|
-
*/
|
|
246
|
-
export function allLastAppHost(target: Object, propertyKey: string | symbol): void;
|
|
247
|
-
export function allLastAppHost(): PropertyDecorator;
|
|
248
|
-
export function allLastAppHost(options: SwcQueryOptions): PropertyDecorator;
|
|
249
|
-
export function allLastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {
|
|
250
|
-
if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {
|
|
251
|
-
return queryAll(':lastAppHost', {})(targetOrOptions, propertyKey);
|
|
252
|
-
}
|
|
253
|
-
if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {
|
|
254
|
-
return queryAll(':lastAppHost', targetOrOptions as SwcQueryOptions);
|
|
255
|
-
} else {
|
|
256
|
-
return queryAll(':lastAppHost', {});
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
165
|
export const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {
|
|
262
166
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
263
167
|
return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
264
168
|
};
|
|
265
|
-
|
|
@@ -56,15 +56,16 @@ export const setProperty = (selector: string, propertyNameOrOptions?: string | P
|
|
|
56
56
|
targetEls.push(t);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
if (selector === '
|
|
60
|
-
else if (selector === '
|
|
61
|
-
else if (selector === '
|
|
62
|
-
else if (selector === '
|
|
63
|
-
else if (selector === '
|
|
64
|
-
else if (selector === '
|
|
65
|
-
else if (selector === '
|
|
66
|
-
else if (selector === '
|
|
67
|
-
else if (selector === '
|
|
59
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
60
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
61
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
62
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
63
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
64
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
65
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
66
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
67
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
68
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
68
69
|
else {
|
|
69
70
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
70
71
|
if (targetRoot) {
|
|
@@ -106,6 +107,6 @@ export const setProperty = (selector: string, propertyNameOrOptions?: string | P
|
|
|
106
107
|
};
|
|
107
108
|
};
|
|
108
109
|
|
|
109
|
-
export const
|
|
110
|
-
return setProperty('
|
|
110
|
+
export const setPropertyThis = (propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {
|
|
111
|
+
return setProperty('$this', propertyNameOrOptions, options);
|
|
111
112
|
};
|