@dooboostore/simple-web-component 1.0.34 → 1.0.36
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 +44 -51
- 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 +22 -17
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +17 -16
- 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 +234 -188
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +24 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +1 -1
- package/dist/cjs/decorators/index.js.map +1 -1
- package/dist/cjs/decorators/lifecycles.js +15 -17
- 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/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +8 -2
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +120 -65
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +31 -21
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +53 -34
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +54 -32
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +111 -37
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +249 -122
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -2
- package/dist/cjs/router/ElementRouter.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +31 -17
- package/dist/cjs/utils/Utils.js.map +2 -2
- 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 +22 -17
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +17 -16
- 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 +233 -187
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +24 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +15 -17
- 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/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +9 -2
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +122 -66
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +32 -22
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +54 -35
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +55 -33
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +112 -38
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +250 -123
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +5 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +31 -17
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +563 -557
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- 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 +7 -6
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- 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 +11 -12
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +1 -1
- package/dist/types/decorators/lifecycles.d.ts +10 -7
- 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/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +4 -5
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +4 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +11 -8
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +11 -8
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +563 -557
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- 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 +34 -21
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +21 -20
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +13 -14
- package/src/decorators/elementDefine.ts +402 -358
- package/src/decorators/emitCustomEvent.ts +40 -31
- package/src/decorators/index.ts +1 -1
- package/src/decorators/lifecycles.ts +11 -10
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +10 -10
- package/src/elements/SwcAppEngine.ts +10 -3
- package/src/elements/SwcAppMixin.ts +177 -97
- package/src/elements/SwcAsync.ts +32 -21
- package/src/elements/SwcChoose.ts +74 -37
- package/src/elements/SwcIf.ts +60 -23
- package/src/elements/SwcLoop.ts +141 -28
- package/src/elements/register.ts +300 -102
- package/src/types.ts +6 -5
- package/src/utils/Utils.ts +40 -23
- package/tsconfig.json +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -19
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooboostore/simple-web-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
"webpack-cli": "^5.1.4",
|
|
94
94
|
"webpack-dev-server": "^5.2.0",
|
|
95
95
|
"@dooboostore/core": "1.0.31",
|
|
96
|
-
"@dooboostore/
|
|
96
|
+
"@dooboostore/core-node": "1.0.12",
|
|
97
97
|
"@dooboostore/core-web": "1.0.10",
|
|
98
|
-
"@dooboostore/
|
|
98
|
+
"@dooboostore/simple-boot": "1.0.55"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"clean": "rm -rf dist",
|
|
@@ -47,19 +47,21 @@ export const getAddEventListenerMetadata = (target: any): AddEventListenerMetada
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @
|
|
51
|
-
* Usage: @addEventListenerHost('click')
|
|
52
|
-
* Usage: @addEventListenerHost('click', { stopPropagation: true })
|
|
50
|
+
* @addEventListenerThis decorator - simplified version of @addEventListener for $this selector
|
|
53
51
|
*/
|
|
54
|
-
export function
|
|
55
|
-
return addEventListener('
|
|
52
|
+
export function addEventListenerThis(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
53
|
+
return addEventListener('$this', type, options);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
|
-
* @addEventListenerAppHost decorator - simplified version of @addEventListener for
|
|
60
|
-
* Usage: @addEventListenerAppHost('click')
|
|
61
|
-
* Usage: @addEventListenerAppHost('click', { stopPropagation: true })
|
|
57
|
+
* @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector
|
|
62
58
|
*/
|
|
63
59
|
export function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
64
|
-
return addEventListener('
|
|
60
|
+
return addEventListener('$appHost', type, options);
|
|
61
|
+
}
|
|
62
|
+
export function addEventListenerWindow(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
63
|
+
return addEventListener('$window', type, options);
|
|
64
|
+
}
|
|
65
|
+
export function addEventListenerDocument(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {
|
|
66
|
+
return addEventListener('$document', type, options);
|
|
65
67
|
}
|
|
@@ -61,15 +61,16 @@ function createAttributeDecorator(action: AttributeAction) {
|
|
|
61
61
|
targetEls.push(t);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
if (selector === '
|
|
65
|
-
else if (selector === '
|
|
66
|
-
else if (selector === '
|
|
67
|
-
else if (selector === '
|
|
68
|
-
else if (selector === '
|
|
69
|
-
else if (selector === '
|
|
70
|
-
else if (selector === '
|
|
71
|
-
else if (selector === '
|
|
72
|
-
else if (selector === '
|
|
64
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
65
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
66
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
67
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
68
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
69
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
70
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
71
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
72
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
73
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
73
74
|
else {
|
|
74
75
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
75
76
|
if (targetRoot) {
|
|
@@ -140,13 +141,13 @@ export const setAttribute = (selector: string, nameOrOptions?: string | Attribut
|
|
|
140
141
|
export const updateAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')(selector, nameOrOptions, options);
|
|
141
142
|
export const removeAttribute = (selector: string, nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')(selector, nameOrOptions, options);
|
|
142
143
|
|
|
143
|
-
//
|
|
144
|
-
export function
|
|
145
|
-
return createAttributeDecorator(action)('
|
|
144
|
+
// This versions
|
|
145
|
+
export function applyAttributeThis(action: AttributeAction = 'update', options: AttributeApplyOptions = {}): MethodDecorator {
|
|
146
|
+
return createAttributeDecorator(action)('$this', options);
|
|
146
147
|
}
|
|
147
|
-
export const
|
|
148
|
-
export const
|
|
149
|
-
export const
|
|
148
|
+
export const setAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('set')('$this', nameOrOptions, options);
|
|
149
|
+
export const updateAttributeThis = (nameOrOptions: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('update')('$this', nameOrOptions, options);
|
|
150
|
+
export const removeAttributeThis = (nameOrOptions?: string | AttributeApplyOptions, options: AttributeApplyOptions = {}) => createAttributeDecorator('remove')('$this', nameOrOptions, options);
|
|
150
151
|
|
|
151
152
|
export const findAllAttributeApplyMetadata = (target: any): Map<string | symbol, AttributeApplyMetadata> => {
|
|
152
153
|
const result = new Map<string | symbol, AttributeApplyMetadata>();
|
|
@@ -57,15 +57,16 @@ function createClassDecorator(action: ClassAction) {
|
|
|
57
57
|
targetEls.push(t);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
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 === '
|
|
68
|
-
else if (selector === '
|
|
60
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
61
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
62
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
63
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
64
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
65
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
66
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
67
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
68
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
69
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
69
70
|
else {
|
|
70
71
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
71
72
|
if (targetRoot) {
|
|
@@ -150,15 +151,15 @@ export const addClass = (selector: string, classMapOrOptions?: string | { [class
|
|
|
150
151
|
export const removeClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(selector, classMapOrOptions, options);
|
|
151
152
|
export const toggleClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(selector, classMapOrOptions, options);
|
|
152
153
|
|
|
153
|
-
//
|
|
154
|
-
export function
|
|
155
|
-
return createClassDecorator(action)('
|
|
154
|
+
// This versions
|
|
155
|
+
export function applyClassThis(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {
|
|
156
|
+
return createClassDecorator(action)('$this', options);
|
|
156
157
|
}
|
|
157
|
-
export const
|
|
158
|
-
export const
|
|
159
|
-
export const
|
|
160
|
-
export const
|
|
161
|
-
export const
|
|
158
|
+
export const setClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')('$this', classMapOrOptions, options);
|
|
159
|
+
export const updateClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')('$this', classMapOrOptions, options);
|
|
160
|
+
export const addClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')('$this', classMapOrOptions, options);
|
|
161
|
+
export const removeClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')('$this', classMapOrOptions, options);
|
|
162
|
+
export const toggleClassThis = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')('$this', classMapOrOptions, options);
|
|
162
163
|
|
|
163
164
|
export const findAllClassMetadata = (target: any): Map<string | symbol, ClassApplyMetadata> => {
|
|
164
165
|
const result = new Map<string | symbol, ClassApplyMetadata>();
|
|
@@ -2,7 +2,15 @@ import { ReflectUtils } from '@dooboostore/core';
|
|
|
2
2
|
import { ensureInit, getElementConfig } from './elementDefine';
|
|
3
3
|
import { HelperHostSet, SwcRootType } from '../types';
|
|
4
4
|
import { SwcUtils } from "../utils/Utils";
|
|
5
|
-
|
|
5
|
+
/*
|
|
6
|
+
<!-- beforebegin -->
|
|
7
|
+
<p>
|
|
8
|
+
<!-- afterbegin -->
|
|
9
|
+
foo
|
|
10
|
+
<!-- beforeend -->
|
|
11
|
+
</p>
|
|
12
|
+
<!-- afterend -->
|
|
13
|
+
*/
|
|
6
14
|
export type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';
|
|
7
15
|
|
|
8
16
|
export interface ApplyNodeOptions {
|
|
@@ -97,11 +105,12 @@ export function applyNode(selector: string, options: ApplyNodeOptions = { positi
|
|
|
97
105
|
return t;
|
|
98
106
|
};
|
|
99
107
|
|
|
100
|
-
if (selector === '
|
|
101
|
-
if (selector === '
|
|
102
|
-
if (selector === '
|
|
103
|
-
if (selector === '
|
|
104
|
-
if (selector === '
|
|
108
|
+
if (selector === '$this') return applyRoot(this);
|
|
109
|
+
if (selector === '$host') return applyRoot(hostSet.$host);
|
|
110
|
+
if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
|
|
111
|
+
if (selector === '$appHost') return applyRoot(hostSet.$appHost);
|
|
112
|
+
if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
|
|
113
|
+
if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
|
|
105
114
|
|
|
106
115
|
const targetRoot = applyRoot(this);
|
|
107
116
|
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
@@ -149,28 +158,28 @@ export const findAllApplyNodeMetadata = (target: any): Map<string | symbol, Appl
|
|
|
149
158
|
return result;
|
|
150
159
|
};
|
|
151
160
|
|
|
152
|
-
export function
|
|
153
|
-
export function
|
|
154
|
-
export function
|
|
155
|
-
if (propertyKey !== undefined) return applyNode('
|
|
161
|
+
export function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
162
|
+
export function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
163
|
+
export function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
164
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);
|
|
156
165
|
const opt = targetOrOptions || {};
|
|
157
|
-
return applyNode('
|
|
166
|
+
return applyNode('$this', { position: 'beforeEnd', ...opt });
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
export function
|
|
161
|
-
export function
|
|
162
|
-
export function
|
|
163
|
-
if (propertyKey !== undefined) return applyNode('
|
|
169
|
+
export function applyReplaceChildrenNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
170
|
+
export function applyReplaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
171
|
+
export function applyReplaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
172
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);
|
|
164
173
|
const opt = targetOrOptions || {};
|
|
165
|
-
return applyNode('
|
|
174
|
+
return applyNode('$this', { position: 'replaceChildren', ...opt });
|
|
166
175
|
}
|
|
167
176
|
|
|
168
|
-
export function
|
|
169
|
-
export function
|
|
170
|
-
export function
|
|
171
|
-
if (propertyKey !== undefined) return applyNode('
|
|
177
|
+
export function applyInnerHtmlNodeThis(options: ApplyNodeOptions): MethodDecorator;
|
|
178
|
+
export function applyInnerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
179
|
+
export function applyInnerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
|
|
180
|
+
if (propertyKey !== undefined) return applyNode('$this', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);
|
|
172
181
|
const opt = targetOrOptions || {};
|
|
173
|
-
return applyNode('
|
|
182
|
+
return applyNode('$this', { position: 'innerHtml', ...opt });
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
export function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
|
|
@@ -180,3 +189,7 @@ export function applyReplaceChildrenNode(selector: string, options: ApplyNodeOpt
|
|
|
180
189
|
export function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
|
|
181
190
|
return applyNode(selector, { ...options, position: 'innerHtml' });
|
|
182
191
|
}
|
|
192
|
+
|
|
193
|
+
export function applyInnerTextNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {
|
|
194
|
+
return applyNode(selector, { ...options, position: 'innerText' });
|
|
195
|
+
}
|
|
@@ -38,7 +38,7 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
38
38
|
if (resolvedValue !== undefined) {
|
|
39
39
|
const win = (this as any).ownerDocument?.defaultView || window;
|
|
40
40
|
const host = this as unknown as HTMLElement;
|
|
41
|
-
const hostSet = SwcUtils.getHelperAndHostSet(win, host);
|
|
41
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
42
42
|
const r = options.root || 'auto';
|
|
43
43
|
const targetEls: HTMLElement[] = [];
|
|
44
44
|
|
|
@@ -47,15 +47,16 @@ function createStyleDecorator(action: StyleAction) {
|
|
|
47
47
|
targetEls.push(t);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
if (selector === '
|
|
51
|
-
else if (selector === '
|
|
52
|
-
else if (selector === '
|
|
53
|
-
else if (selector === '
|
|
54
|
-
else if (selector === '
|
|
55
|
-
else if (selector === '
|
|
56
|
-
else if (selector === '
|
|
57
|
-
else if (selector === '
|
|
58
|
-
else if (selector === '
|
|
50
|
+
if (selector === '$this' || !selector) applyRoot(host);
|
|
51
|
+
else if (selector === '$host') applyRoot(hostSet.$host);
|
|
52
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
53
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost);
|
|
54
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
55
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
56
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
57
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
58
|
+
else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
|
|
59
|
+
else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
59
60
|
else {
|
|
60
61
|
const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);
|
|
61
62
|
if (targetRoot) {
|
|
@@ -122,13 +123,13 @@ export const setStyle = (selector: string, options: StyleApplyOptions = {}) => c
|
|
|
122
123
|
export const updateStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('update')(selector, options);
|
|
123
124
|
export const removeStyle = (selector: string, options: StyleApplyOptions = {}) => createStyleDecorator('remove')(selector, options);
|
|
124
125
|
|
|
125
|
-
//
|
|
126
|
-
export function
|
|
127
|
-
return createStyleDecorator(action)('
|
|
126
|
+
// This versions
|
|
127
|
+
export function applyStyleThis(action: StyleAction = 'update', options: StyleApplyOptions = {}): MethodDecorator {
|
|
128
|
+
return createStyleDecorator(action)('$this', options);
|
|
128
129
|
}
|
|
129
|
-
export const
|
|
130
|
-
export const
|
|
131
|
-
export const
|
|
130
|
+
export const setStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('set')('$this', options);
|
|
131
|
+
export const updateStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('update')('$this', options);
|
|
132
|
+
export const removeStyleThis = (options: StyleApplyOptions = {}) => createStyleDecorator('remove')('$this', options);
|
|
132
133
|
|
|
133
134
|
export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleApplyMetadata> => {
|
|
134
135
|
const result = new Map<string | symbol, StyleApplyMetadata>();
|
|
@@ -41,7 +41,7 @@ export const getAttributeValue = (inst: any, attrName: string, options?: Attribu
|
|
|
41
41
|
|
|
42
42
|
// 표현식 체크
|
|
43
43
|
const ae = new ActionExpression(domVal);
|
|
44
|
-
const expr = ae.getFirstExpression('
|
|
44
|
+
const expr = ae.getFirstExpression('callReturn');
|
|
45
45
|
if (expr) {
|
|
46
46
|
try {
|
|
47
47
|
const result = FunctionUtils.executeReturn({
|
|
@@ -77,20 +77,21 @@ export const resolveTargetEls = (inst: any, selector: string, options: Attribute
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
if (selector === '
|
|
80
|
+
if (selector === '$this' || !selector) {
|
|
81
81
|
applyRoot(inst);
|
|
82
|
-
} else if (selector === '
|
|
82
|
+
} else if (selector === '$window') {
|
|
83
83
|
results.push(currentWin);
|
|
84
|
-
} else if (selector === '
|
|
84
|
+
} else if (selector === '$document') {
|
|
85
85
|
results.push(currentWin.document);
|
|
86
86
|
} else {
|
|
87
87
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
88
|
-
if (selector === '
|
|
89
|
-
else if (selector === '
|
|
90
|
-
else if (selector === '
|
|
91
|
-
else if (selector === '
|
|
92
|
-
else if (selector === '
|
|
93
|
-
else if (selector === '
|
|
88
|
+
if (selector === '$host') applyRoot(hostSet.$host);
|
|
89
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
90
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);
|
|
91
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
92
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
93
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
|
|
94
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
|
|
94
95
|
else {
|
|
95
96
|
if (r === 'shadow') {
|
|
96
97
|
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
@@ -189,29 +190,29 @@ export function attribute(selector: string, options: AttributeFieldOptions = {})
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
/**
|
|
192
|
-
* @
|
|
193
|
+
* @attributeThis decorator to sync a field value with the $this element's attribute.
|
|
193
194
|
*/
|
|
194
|
-
export function
|
|
195
|
-
export function
|
|
196
|
-
export function
|
|
197
|
-
export function
|
|
198
|
-
export function
|
|
195
|
+
export function attributeThis(target: Object, propertyKey: string | symbol): void;
|
|
196
|
+
export function attributeThis(options: AttributeFieldOptions): PropertyDecorator;
|
|
197
|
+
export function attributeThis(attrName: string): PropertyDecorator;
|
|
198
|
+
export function attributeThis(attrName: string, options: AttributeFieldOptions): PropertyDecorator;
|
|
199
|
+
export function attributeThis(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {
|
|
199
200
|
if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {
|
|
200
|
-
return attribute('
|
|
201
|
+
return attribute('$this', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
if (typeof targetOrAttrOrOptions === 'string') {
|
|
204
205
|
const attrName = targetOrAttrOrOptions;
|
|
205
206
|
const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeFieldOptions;
|
|
206
|
-
return attribute('
|
|
207
|
+
return attribute('$this', { ...options, name: attrName });
|
|
207
208
|
} else if (typeof targetOrAttrOrOptions === 'object') {
|
|
208
209
|
const options = targetOrAttrOrOptions as AttributeFieldOptions;
|
|
209
210
|
return (target: Object, propertyKey: string | symbol) => {
|
|
210
|
-
return attribute('
|
|
211
|
+
return attribute('$this', { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
211
212
|
};
|
|
212
213
|
} else {
|
|
213
214
|
return (target: Object, propertyKey: string | symbol) => {
|
|
214
|
-
return attribute('
|
|
215
|
+
return attribute('$this', { name: String(propertyKey) })(target, propertyKey);
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {ReflectUtils} from '@dooboostore/core';
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
2
|
|
|
3
3
|
export const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface ChangedAttributeThisOptions {
|
|
6
6
|
type?: typeof Number | typeof Boolean | typeof String;
|
|
7
|
+
while?: 'connected';
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export interface
|
|
10
|
+
export interface ChangedAttributeThisMetadata {
|
|
10
11
|
attributeName: string;
|
|
11
12
|
propertyKey: string | symbol;
|
|
12
|
-
options:
|
|
13
|
+
options: ChangedAttributeThisOptions;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const convertValue = (val: any, type: any): any => {
|
|
@@ -20,14 +21,12 @@ const convertValue = (val: any, type: any): any => {
|
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* @
|
|
24
|
-
* Usage: @changedAttributeHost('data-product-id')
|
|
25
|
-
* @changedAttributeHost('count', { type: Number })
|
|
24
|
+
* @changedAttributeThis decorator - fires when any attribute on $this changes
|
|
26
25
|
*/
|
|
27
|
-
export function
|
|
26
|
+
export function changedAttributeThis(attributeName?: string, options: ChangedAttributeThisOptions = {}): MethodDecorator {
|
|
28
27
|
return (target: Object, propertyKey: string | symbol) => {
|
|
29
28
|
const constructor = target.constructor;
|
|
30
|
-
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as
|
|
29
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];
|
|
31
30
|
if (!metaList) {
|
|
32
31
|
metaList = [];
|
|
33
32
|
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
@@ -42,16 +41,16 @@ export function changedAttributeHost(attributeName?: string, options: ChangedAtt
|
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
export const getChangedAttributeMetadata = (target: any):
|
|
44
|
+
export const getChangedAttributeMetadata = (target: any): ChangedAttributeThisMetadata[] | undefined => {
|
|
46
45
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
47
46
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
export const findAllAttributeChangedMetadata = (target: any): Map<string,
|
|
49
|
+
export const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeThisMetadata[]> => {
|
|
51
50
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
52
|
-
const metaList = ReflectUtils.findAllMetadata<
|
|
53
|
-
|
|
54
|
-
const result = new Map<string,
|
|
51
|
+
const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
52
|
+
|
|
53
|
+
const result = new Map<string, ChangedAttributeThisMetadata[]>();
|
|
55
54
|
metaList.forEach(meta => {
|
|
56
55
|
meta.forEach(item => {
|
|
57
56
|
if (!result.has(item.attributeName)) {
|