@dooboostore/simple-web-component 1.0.35 → 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 +21 -21
- 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 +18 -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 +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 +21 -20
- 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 +1 -1
- package/dist/cjs/decorators/index.js.map +1 -1
- 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/SwcAsync.js +6 -6
- package/dist/cjs/elements/SwcAsync.js.map +1 -1
- package/dist/cjs/elements/SwcChoose.js +5 -5
- package/dist/cjs/elements/SwcChoose.js.map +1 -1
- package/dist/cjs/elements/SwcIf.js +6 -6
- package/dist/cjs/elements/SwcIf.js.map +1 -1
- package/dist/cjs/elements/SwcLoop.js +5 -5
- package/dist/cjs/elements/SwcLoop.js.map +1 -1
- package/dist/cjs/elements/register.js +18 -18
- package/dist/cjs/elements/register.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +13 -13
- 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 +18 -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 +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 +19 -18
- 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 +1 -1
- package/dist/esm/decorators/index.js.map +1 -1
- 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/SwcAsync.js +7 -7
- package/dist/esm/elements/SwcAsync.js.map +1 -1
- package/dist/esm/elements/SwcChoose.js +6 -6
- package/dist/esm/elements/SwcChoose.js.map +1 -1
- package/dist/esm/elements/SwcIf.js +7 -7
- package/dist/esm/elements/SwcIf.js.map +1 -1
- package/dist/esm/elements/SwcLoop.js +6 -6
- package/dist/esm/elements/SwcLoop.js.map +1 -1
- package/dist/esm/elements/register.js +19 -19
- package/dist/esm/elements/register.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +13 -13
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +271 -308
- 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 +6 -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 +4 -9
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +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/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +7 -7
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +271 -308
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- 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 +21 -20
- 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 +21 -20
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +1 -1
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/SwcAsync.ts +7 -7
- package/src/elements/SwcChoose.ts +6 -6
- package/src/elements/SwcIf.ts +8 -8
- package/src/elements/SwcLoop.ts +6 -6
- package/src/elements/register.ts +20 -20
- package/src/types.ts +5 -5
- package/src/utils/Utils.ts +17 -18
- 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 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
package/src/elements/SwcLoop.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changedAttributeThis } from '../decorators/changedAttributeThis';
|
|
2
2
|
import { SwcUtils } from '../utils/Utils';
|
|
3
3
|
import { FunctionUtils, ActionExpression } from '@dooboostore/core';
|
|
4
4
|
import { ConvertUtils } from '@dooboostore/core-web';
|
|
5
|
-
import {
|
|
5
|
+
import { attributeThis, getAttributeValue } from '../decorators';
|
|
6
6
|
|
|
7
7
|
class SwcLoop extends HTMLTemplateElement {
|
|
8
8
|
_value: any[] = [];
|
|
9
9
|
|
|
10
|
-
@
|
|
10
|
+
@attributeThis('replace-wrap-start')
|
|
11
11
|
_replaceWrapStart: string | null;
|
|
12
|
-
@
|
|
12
|
+
@attributeThis('replace-wrap-end')
|
|
13
13
|
_replaceWrapEnd: string | null;
|
|
14
14
|
|
|
15
15
|
private _nodeGroups: Node[][] = [];
|
|
@@ -33,13 +33,13 @@ class SwcLoop extends HTMLTemplateElement {
|
|
|
33
33
|
// console.log('swc SwcLoop', this.getAttribute('value'));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@
|
|
36
|
+
@changedAttributeThis('value')
|
|
37
37
|
private setValue(value: any, o: string, n: string) {
|
|
38
38
|
this._value = value;
|
|
39
39
|
this.refresh(this._value);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// @
|
|
42
|
+
// @changedAttributeThis('replace-wrap')
|
|
43
43
|
// private setReplaceWrap(replaceWrapAttr?: string | null) {
|
|
44
44
|
// this.refresh();
|
|
45
45
|
// }
|
package/src/elements/register.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getElementConfig, elementDefine,
|
|
1
|
+
import { getElementConfig, elementDefine, attributeThis, changedAttributeThis, getAttributeValue } from '../decorators';
|
|
2
2
|
import { SwcAppMixin } from './SwcAppMixin';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
4
|
import { FunctionUtils,ActionExpression } from '@dooboostore/core';
|
|
@@ -149,15 +149,15 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
149
149
|
@elementDefine('swc-if', { extends: 'template', window: w })
|
|
150
150
|
class SwcIf extends HTMLTemplateElement {
|
|
151
151
|
// id =
|
|
152
|
-
// @
|
|
152
|
+
// @attributeThis('value')
|
|
153
153
|
_value: any;
|
|
154
154
|
|
|
155
|
-
@
|
|
155
|
+
@attributeThis('replace-wrap-start')
|
|
156
156
|
_replaceWrapStart: string | null;
|
|
157
|
-
@
|
|
157
|
+
@attributeThis('replace-wrap-end')
|
|
158
158
|
_replaceWrapEnd: string | null;
|
|
159
159
|
|
|
160
|
-
@
|
|
160
|
+
@attributeThis('skip-if-same')
|
|
161
161
|
_skipIfSame: string | null;
|
|
162
162
|
|
|
163
163
|
private _nodes: Node[] = [];
|
|
@@ -175,13 +175,13 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
175
175
|
super();
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
@
|
|
178
|
+
@changedAttributeThis('value')
|
|
179
179
|
private setValue(value: any, o: string, n: string) {
|
|
180
180
|
this._value = value;
|
|
181
181
|
this.refresh(this._value);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
// @
|
|
184
|
+
// @changedAttributeThis('replace-wrap')
|
|
185
185
|
// private setReplaceWrap(replaceWrapAttr?: string | null) {
|
|
186
186
|
// this.refresh();
|
|
187
187
|
// }
|
|
@@ -269,9 +269,9 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
269
269
|
class SwcLoop extends HTMLTemplateElement {
|
|
270
270
|
_value: any[] = [];
|
|
271
271
|
|
|
272
|
-
@
|
|
272
|
+
@attributeThis('replace-wrap-start')
|
|
273
273
|
_replaceWrapStart: string | null;
|
|
274
|
-
@
|
|
274
|
+
@attributeThis('replace-wrap-end')
|
|
275
275
|
_replaceWrapEnd: string | null;
|
|
276
276
|
|
|
277
277
|
private _nodeGroups: Node[][] = [];
|
|
@@ -295,13 +295,13 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
295
295
|
// console.log('swc SwcLoop', this.getAttribute('value'));
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
@
|
|
298
|
+
@changedAttributeThis('value')
|
|
299
299
|
private setValue(value: any, o: string, n: string) {
|
|
300
300
|
this._value = value;
|
|
301
301
|
this.refresh(this._value);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
// @
|
|
304
|
+
// @changedAttributeThis('replace-wrap')
|
|
305
305
|
// private setReplaceWrap(replaceWrapAttr?: string | null) {
|
|
306
306
|
// this.refresh();
|
|
307
307
|
// }
|
|
@@ -470,9 +470,9 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
470
470
|
class SwcChoose extends HTMLTemplateElement {
|
|
471
471
|
_value: any;
|
|
472
472
|
|
|
473
|
-
@
|
|
473
|
+
@attributeThis('replace-wrap-start')
|
|
474
474
|
_replaceWrapStart: string | null;
|
|
475
|
-
@
|
|
475
|
+
@attributeThis('replace-wrap-end')
|
|
476
476
|
_replaceWrapEnd: string | null;
|
|
477
477
|
|
|
478
478
|
private _nodes: Node[] = [];
|
|
@@ -501,14 +501,14 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
501
501
|
// console.log('-----------------choooooooose attr origin', na, o, n);
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
-
@
|
|
504
|
+
@changedAttributeThis('value')
|
|
505
505
|
private setValue(value: any, o: string, n: string) {
|
|
506
506
|
console.log('chooooooose value', value)
|
|
507
507
|
this._value = value;
|
|
508
508
|
this.refresh(this._value);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
// @
|
|
511
|
+
// @changedAttributeThis('replace-wrap')
|
|
512
512
|
// private setReplaceWrap(replaceWrapAttr?: string | null) {
|
|
513
513
|
// this.refresh();
|
|
514
514
|
// }
|
|
@@ -653,11 +653,11 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
653
653
|
|
|
654
654
|
@elementDefine('swc-async', { extends: 'template', window: w })
|
|
655
655
|
class SwcAsync extends HTMLTemplateElement {
|
|
656
|
-
@
|
|
656
|
+
@attributeThis('value')
|
|
657
657
|
_value: any;
|
|
658
|
-
@
|
|
658
|
+
@attributeThis('replace-wrap-start')
|
|
659
659
|
_replaceWrapStart: string | null;
|
|
660
|
-
@
|
|
660
|
+
@attributeThis('replace-wrap-end')
|
|
661
661
|
_replaceWrapEnd: string | null; resultValue?: any;
|
|
662
662
|
|
|
663
663
|
get value(): boolean {
|
|
@@ -670,12 +670,12 @@ export const registerAllElements = (w: any): Record<string, Constructor<HTMLElem
|
|
|
670
670
|
|
|
671
671
|
private _nodes: Node[] = [];
|
|
672
672
|
|
|
673
|
-
@
|
|
673
|
+
@changedAttributeThis('value')
|
|
674
674
|
private setValue(valueAttr?: string | null) {
|
|
675
675
|
this.executeAsync(this._value);
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
-
// @
|
|
678
|
+
// @changedAttributeThis('replace-wrap')
|
|
679
679
|
// private setReplaceWrap() {
|
|
680
680
|
// this.executeAsync(this._value);
|
|
681
681
|
// }
|
package/src/types.ts
CHANGED
|
@@ -17,7 +17,7 @@ export enum InjectSituationType {
|
|
|
17
17
|
|
|
18
18
|
export type SwcRootType = 'light' | 'shadow' | 'all' | 'auto';
|
|
19
19
|
|
|
20
|
-
export type SpecialSelector = '
|
|
20
|
+
export type SpecialSelector = '$this' | '$window' | '$document' | '$host' | '$appHost' | '$firstHost' | '$lastHost' | '$firstAppHost' | '$lastAppHost' | '$hosts' | '$appHosts';
|
|
21
21
|
|
|
22
22
|
export type SwcQueryOptions = { root?: SwcRootType };
|
|
23
23
|
|
|
@@ -30,11 +30,11 @@ export type HelperSet = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export type HostSet = {
|
|
33
|
-
$host: HTMLElement; //
|
|
34
|
-
$parentHost: HTMLElement | null; //
|
|
35
|
-
$hosts: HTMLElement[]; // [root, ..., parent
|
|
33
|
+
$host: HTMLElement | null; // Nearest parent SWC component
|
|
34
|
+
$parentHost: HTMLElement | null; // Grandparent SWC ancestor
|
|
35
|
+
$hosts: HTMLElement[]; // All SWC ancestors [root, ..., parent]
|
|
36
36
|
$firstHost: HTMLElement | null; // Top-most SWC ancestor
|
|
37
|
-
$lastHost: HTMLElement | null; // Same as $
|
|
37
|
+
$lastHost: HTMLElement | null; // Same as $host
|
|
38
38
|
$templateHost: HTMLTemplateElement | null | undefined;
|
|
39
39
|
$appHost: SwcAppInterface | null;
|
|
40
40
|
$appHosts: SwcAppInterface[];
|
package/src/utils/Utils.ts
CHANGED
|
@@ -225,7 +225,7 @@ export namespace SwcUtils {
|
|
|
225
225
|
* Finds the nearest logical SWC host for an element.
|
|
226
226
|
* Checks __swc_host property first, then climbs the DOM tree.
|
|
227
227
|
*/
|
|
228
|
-
export const
|
|
228
|
+
export const findNearestSwcHostIncludingSelf = (el: HTMLElement | Node): HTMLElement | undefined => {
|
|
229
229
|
const el1 = el as any;
|
|
230
230
|
if (el1.__swc_host) return el1.__swc_host;
|
|
231
231
|
|
|
@@ -243,32 +243,32 @@ export namespace SwcUtils {
|
|
|
243
243
|
/**
|
|
244
244
|
* Returns all SWC ancestors (excluding self) in [root, ..., parent] order.
|
|
245
245
|
*/
|
|
246
|
-
export const
|
|
246
|
+
export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {
|
|
247
247
|
const hosts: HTMLElement[] = [];
|
|
248
|
-
let current =
|
|
248
|
+
let current = findNearestSwcHostIncludingSelf(el);
|
|
249
249
|
while (current) {
|
|
250
250
|
hosts.push(current);
|
|
251
251
|
// To find the next ancestor, we must start searching from the PARENT of the found host
|
|
252
|
-
current =
|
|
252
|
+
current = findNearestSwcHostIncludingSelf(current);
|
|
253
253
|
}
|
|
254
254
|
return hosts.reverse();
|
|
255
255
|
};
|
|
256
256
|
|
|
257
257
|
export const getHosts = (el: HTMLElement): HTMLElement[] => {
|
|
258
|
-
const ancestors =
|
|
258
|
+
const ancestors = findAllSwcHostsIncludingSelf(el);
|
|
259
259
|
if (getElementConfig(el)) return [...ancestors, el];
|
|
260
260
|
return ancestors;
|
|
261
261
|
};
|
|
262
262
|
|
|
263
263
|
export const getHost = (el: HTMLElement): HTMLElement | undefined => {
|
|
264
264
|
if (getElementConfig(el)) return el;
|
|
265
|
-
return
|
|
265
|
+
return findNearestSwcHostIncludingSelf(el);
|
|
266
266
|
};
|
|
267
267
|
|
|
268
268
|
export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {
|
|
269
269
|
// const hosts = getHosts(el);
|
|
270
270
|
// return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];
|
|
271
|
-
const hosts = SwcUtils.
|
|
271
|
+
const hosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);
|
|
272
272
|
return hosts;
|
|
273
273
|
};
|
|
274
274
|
|
|
@@ -279,22 +279,22 @@ export namespace SwcUtils {
|
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
|
-
* Find
|
|
282
|
+
* Find the closest app host by traversing DOM tree directly, including the element itself.
|
|
283
283
|
* Only checks tagName and is attribute - no SWC host discovery.
|
|
284
284
|
* Useful for Safari polyfill compatibility where is="" elements upgrade in child-first order.
|
|
285
285
|
*/
|
|
286
|
-
export const
|
|
287
|
-
const appHosts =
|
|
286
|
+
export const findAppHostIncludingSelfDirect = (el: HTMLElement): SwcAppInterface | null => {
|
|
287
|
+
const appHosts = findAllAppHostsIncludingSelfDirect(el);
|
|
288
288
|
return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;
|
|
289
289
|
};
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
|
-
* Find all
|
|
293
|
-
* Returns array of all
|
|
292
|
+
* Find all app hosts by traversing DOM tree directly, including the element itself.
|
|
293
|
+
* Returns array of all app hosts in [root, ..., closest-parent-or-self] order.
|
|
294
294
|
* Only checks tagName and is attribute - no SWC host discovery.
|
|
295
295
|
* Useful for Safari polyfill compatibility where is="" elements upgrade in child-first order.
|
|
296
296
|
*/
|
|
297
|
-
export const
|
|
297
|
+
export const findAllAppHostsIncludingSelfDirect = (el: HTMLElement): SwcAppInterface[] => {
|
|
298
298
|
const appHosts: SwcAppInterface[] = [];
|
|
299
299
|
|
|
300
300
|
const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);
|
|
@@ -332,11 +332,11 @@ export namespace SwcUtils {
|
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
return appHosts.reverse(); // [root, ..., closest-parent]
|
|
335
|
+
return appHosts.reverse(); // [root, ..., closest-parent-or-self]
|
|
336
336
|
};
|
|
337
337
|
|
|
338
338
|
export const getHostSet = (el: HTMLElement): HostSet => {
|
|
339
|
-
const ancestors =
|
|
339
|
+
const ancestors = findAllSwcHostsIncludingSelf(el); // [root, ..., parent]
|
|
340
340
|
|
|
341
341
|
const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;
|
|
342
342
|
const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;
|
|
@@ -354,8 +354,7 @@ export namespace SwcUtils {
|
|
|
354
354
|
curr = curr.parentElement || (curr.getRootNode() as any).host;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
const $appHosts = SwcUtils.
|
|
358
|
-
// console.log('apphosts00000000', $appHosts)
|
|
357
|
+
const $appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);
|
|
359
358
|
const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;
|
|
360
359
|
const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
|
|
361
360
|
|
|
@@ -364,7 +363,7 @@ export namespace SwcUtils {
|
|
|
364
363
|
$parentHost,
|
|
365
364
|
$hosts,
|
|
366
365
|
$firstHost,
|
|
367
|
-
$lastHost: $
|
|
366
|
+
$lastHost: $host,
|
|
368
367
|
$templateHost: (el as any).__swc_template_host,
|
|
369
368
|
$appHost,
|
|
370
369
|
$appHosts,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttributeHost.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeHostOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeHostMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeHostOptions;\n}\n\nconst convertValue = (val: any, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n * @changedAttributeHost('count', { type: Number })\n */\nexport function changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeHostMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeHostMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeHostMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeHostMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAOO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,+BAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,aAAS,KAAK;AAAA,MACZ,eAAe;AAAA,MACf;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAA6D;AAC3G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,WAAW,yBAAa,gBAAgD,mCAAmC,WAAW,KAAK,CAAC;AAElI,QAAM,SAAS,oBAAI,IAA4C;AAC/D,WAAS,QAAQ,UAAQ;AACvB,SAAK,QAAQ,UAAQ;AACnB,UAAI,CAAC,OAAO,IAAI,KAAK,aAAa,GAAG;AACnC,eAAO,IAAI,KAAK,eAAe,CAAC,CAAC;AAAA,MACnC;AACA,aAAO,IAAI,KAAK,aAAa,EAAG,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,KAAU,SAA+D;AAC7G,SAAO,aAAa,KAAK,IAAI;AAC/B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/changedAttributeHost.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeHostOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeHostMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeHostOptions;\n}\n\nconst convertValue = (val: any, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n * @changedAttributeHost('count', { type: Number })\n */\nexport function changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeHostMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeHostMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeHostMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeHostMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAOO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,mBAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,aAAS,KAAK;AAAA,MACZ,eAAe;AAAA,MACf;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAA6D;AAC3G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,WAAW,aAAa,gBAAgD,mCAAmC,WAAW,KAAK,CAAC;AAElI,QAAM,SAAS,oBAAI,IAA4C;AAC/D,WAAS,QAAQ,UAAQ;AACvB,SAAK,QAAQ,UAAQ;AACnB,UAAI,CAAC,OAAO,IAAI,KAAK,aAAa,GAAG;AACnC,eAAO,IAAI,KAAK,eAAe,CAAC,CAAC;AAAA,MACnC;AACA,aAAO,IAAI,KAAK,aAAa,EAAG,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,KAAU,SAA+D;AAC7G,SAAO,aAAa,KAAK,IAAI;AAC/B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const ON_ATTRIBUTE_CHANGED_METADATA_KEY: unique symbol;
|
|
2
|
-
export interface ChangedAttributeHostOptions {
|
|
3
|
-
type?: typeof Number | typeof Boolean | typeof String;
|
|
4
|
-
while?: 'connected';
|
|
5
|
-
}
|
|
6
|
-
export interface ChangedAttributeHostMetadata {
|
|
7
|
-
attributeName: string;
|
|
8
|
-
propertyKey: string | symbol;
|
|
9
|
-
options: ChangedAttributeHostOptions;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @changedAttributeHost decorator - fires when any attribute on :host changes
|
|
13
|
-
* Usage: @changedAttributeHost('data-product-id')
|
|
14
|
-
* @changedAttributeHost('count', { type: Number })
|
|
15
|
-
*/
|
|
16
|
-
export declare function changedAttributeHost(attributeName?: string, options?: ChangedAttributeHostOptions): MethodDecorator;
|
|
17
|
-
export declare const getChangedAttributeMetadata: (target: any) => ChangedAttributeHostMetadata[] | undefined;
|
|
18
|
-
export declare const findAllAttributeChangedMetadata: (target: any) => Map<string, ChangedAttributeHostMetadata[]>;
|
|
19
|
-
export declare const convertAttributeValue: (val: any, type?: typeof Number | typeof Boolean | typeof String) => any;
|
|
20
|
-
//# sourceMappingURL=changedAttributeHost.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"changedAttributeHost.d.ts","sourceRoot":"","sources":["../../../src/decorators/changedAttributeHost.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,eAA0D,CAAC;AAEzG,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,OAAO,MAAM,GAAG,OAAO,OAAO,GAAG,OAAO,MAAM,CAAC;IACtD,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,EAAE,2BAA2B,CAAC;CACtC;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,2BAAgC,GAAG,eAAe,CAgBvH;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,GAAG,KAAG,4BAA4B,EAAE,GAAG,SAG1F,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,EAAE,4BAA4B,EAAE,CAcvG,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,KAAK,GAAG,EAAE,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,GAAG,OAAO,MAAM,KAAG,GAEvG,CAAC"}
|