@dooboostore/simple-web-component 1.0.33 → 1.0.34
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/dist/cjs/decorators/addEventListener.js.map +1 -1
- package/dist/cjs/decorators/applyAttribute.js +67 -57
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +80 -70
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +1 -8
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +66 -56
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +35 -29
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +32 -12
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +29 -16
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +57 -44
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +50 -39
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +1 -1
- package/dist/cjs/elements/SwcAppEngine.js +7 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +60 -42
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +19 -15
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/register.js +21 -16
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/utils/Utils.js +7 -3
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js.map +1 -1
- package/dist/esm/decorators/applyAttribute.js +67 -57
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +80 -70
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +1 -8
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +66 -56
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +35 -29
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +32 -12
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +30 -17
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +57 -44
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +50 -39
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +1 -1
- package/dist/esm/elements/SwcAppEngine.js +6 -6
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +60 -42
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +20 -16
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/register.js +22 -17
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/utils/Utils.js +7 -3
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +425 -335
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +4 -1
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +5 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +4 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +4 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +5 -1
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts +13 -3
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +5 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +5 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +2 -2
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +6 -3
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +5 -3
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +425 -335
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +74 -61
- package/src/decorators/applyClass.ts +91 -77
- package/src/decorators/applyNode.ts +3 -12
- package/src/decorators/applyStyle.ts +75 -61
- package/src/decorators/attribute.ts +55 -43
- package/src/decorators/changedAttributeHost.ts +47 -14
- package/src/decorators/elementDefine.ts +38 -20
- package/src/decorators/emitCustomEvent.ts +65 -49
- package/src/decorators/setProperty.ts +58 -44
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +2 -2
- package/src/elements/SwcAppEngine.ts +11 -12
- package/src/elements/SwcAppMixin.ts +76 -44
- package/src/elements/SwcChoose.ts +28 -7
- package/src/elements/register.ts +28 -7
- package/src/utils/Utils.ts +15 -5
|
@@ -1179,6 +1179,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1179
1179
|
attributeHost: () => attributeHost,
|
|
1180
1180
|
changedAttributeHost: () => changedAttributeHost,
|
|
1181
1181
|
commentNode: () => commentNode,
|
|
1182
|
+
convertAttributeValue: () => convertAttributeValue,
|
|
1183
|
+
convertValue: () => convertValue2,
|
|
1182
1184
|
createElement: () => createElement,
|
|
1183
1185
|
elementDefine: () => elementDefine,
|
|
1184
1186
|
emitCustomEvent: () => emitCustomEvent,
|
|
@@ -1194,6 +1196,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1194
1196
|
firstAppHost: () => firstAppHost,
|
|
1195
1197
|
firstHost: () => firstHost,
|
|
1196
1198
|
getAddEventListenerMetadata: () => getAddEventListenerMetadata,
|
|
1199
|
+
getAttributeValue: () => getAttributeValue,
|
|
1197
1200
|
getChangedAttributeMetadata: () => getChangedAttributeMetadata,
|
|
1198
1201
|
getElementConfig: () => getElementConfig,
|
|
1199
1202
|
getEmitCustomEventMetadataList: () => getEmitCustomEventMetadataList,
|
|
@@ -6340,8 +6343,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6340
6343
|
return (0, SwcUtils2.findNearestSwcHost)(el);
|
|
6341
6344
|
};
|
|
6342
6345
|
SwcUtils2.getAppHosts = (el) => {
|
|
6343
|
-
const hosts =
|
|
6344
|
-
return hosts
|
|
6346
|
+
const hosts = SwcUtils2.findAllParentAppHostsDirect(el);
|
|
6347
|
+
return hosts;
|
|
6345
6348
|
};
|
|
6346
6349
|
SwcUtils2.getAppHost = (el) => {
|
|
6347
6350
|
const appHosts = (0, SwcUtils2.getAppHosts)(el);
|
|
@@ -6354,6 +6357,10 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6354
6357
|
};
|
|
6355
6358
|
SwcUtils2.findAllParentAppHostsDirect = (el) => {
|
|
6356
6359
|
const appHosts = [];
|
|
6360
|
+
const w = el.ownerDocument?.defaultView || (typeof window !== "undefined" ? window : void 0);
|
|
6361
|
+
if (!w) {
|
|
6362
|
+
return appHosts;
|
|
6363
|
+
}
|
|
6357
6364
|
let current = el;
|
|
6358
6365
|
while (current) {
|
|
6359
6366
|
const isAppHost = current.tagName.toLowerCase() === "swc-app" || current.getAttribute("is")?.startsWith("swc-app-");
|
|
@@ -6364,7 +6371,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6364
6371
|
current = current.parentElement;
|
|
6365
6372
|
} else {
|
|
6366
6373
|
const root = current.getRootNode();
|
|
6367
|
-
if (root instanceof ShadowRoot) {
|
|
6374
|
+
if (w.ShadowRoot && root instanceof w.ShadowRoot) {
|
|
6368
6375
|
current = root.host;
|
|
6369
6376
|
} else {
|
|
6370
6377
|
break;
|
|
@@ -6439,54 +6446,67 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6439
6446
|
}
|
|
6440
6447
|
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
6441
6448
|
const original = descriptor.value;
|
|
6442
|
-
descriptor.value =
|
|
6449
|
+
descriptor.value = function(...args) {
|
|
6443
6450
|
ensureInit(this);
|
|
6444
|
-
const
|
|
6445
|
-
const
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
if (
|
|
6459
|
-
|
|
6460
|
-
if (
|
|
6461
|
-
|
|
6462
|
-
if (
|
|
6463
|
-
|
|
6464
|
-
if (
|
|
6465
|
-
|
|
6466
|
-
if (
|
|
6467
|
-
|
|
6468
|
-
if (
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
searchRoots.push(this);
|
|
6482
|
-
if (
|
|
6451
|
+
const res = original.apply(this, args);
|
|
6452
|
+
const handleResult = (detail) => {
|
|
6453
|
+
const event = new CustomEvent(type, {
|
|
6454
|
+
detail,
|
|
6455
|
+
bubbles: fullOptions.bubbles,
|
|
6456
|
+
composed: fullOptions.composed,
|
|
6457
|
+
cancelable: fullOptions.cancelable
|
|
6458
|
+
});
|
|
6459
|
+
const hostSet = SwcUtils.getHostSet(this);
|
|
6460
|
+
const conf = getElementConfig(this);
|
|
6461
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6462
|
+
const eventTargets = [];
|
|
6463
|
+
if (selectorOrTarget === ":window") eventTargets.push(currentWin);
|
|
6464
|
+
else if (selectorOrTarget === ":document") eventTargets.push(currentWin.document);
|
|
6465
|
+
else if (selectorOrTarget === ":parentHost") {
|
|
6466
|
+
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
6467
|
+
} else if (selectorOrTarget === ":appHost") {
|
|
6468
|
+
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
6469
|
+
} else if (selectorOrTarget === ":firstHost") {
|
|
6470
|
+
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
6471
|
+
} else if (selectorOrTarget === ":lastHost") {
|
|
6472
|
+
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
6473
|
+
} else if (selectorOrTarget === ":firstAppHost") {
|
|
6474
|
+
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
6475
|
+
} else if (selectorOrTarget === ":lastAppHost") {
|
|
6476
|
+
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
6477
|
+
} else if (selectorOrTarget === ":hosts") {
|
|
6478
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
6479
|
+
} else if (selectorOrTarget === ":appHosts") {
|
|
6480
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
6481
|
+
} else if (selectorOrTarget === ":host" || !selectorOrTarget) {
|
|
6482
|
+
eventTargets.push(this);
|
|
6483
|
+
} else {
|
|
6484
|
+
const r = fullOptions.root || "auto";
|
|
6485
|
+
const searchRoots = [];
|
|
6486
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
6487
|
+
else if (r === "light") searchRoots.push(this);
|
|
6488
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6489
|
+
else if (r === "all") {
|
|
6490
|
+
searchRoots.push(this);
|
|
6491
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
6492
|
+
}
|
|
6493
|
+
searchRoots.forEach((sr) => {
|
|
6494
|
+
sr.querySelectorAll(selectorOrTarget).forEach((el) => eventTargets.push(el));
|
|
6495
|
+
});
|
|
6483
6496
|
}
|
|
6484
|
-
|
|
6485
|
-
|
|
6497
|
+
eventTargets.forEach((t) => {
|
|
6498
|
+
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
6499
|
+
return;
|
|
6500
|
+
}
|
|
6501
|
+
t.dispatchEvent(event);
|
|
6486
6502
|
});
|
|
6503
|
+
return detail;
|
|
6504
|
+
};
|
|
6505
|
+
if (res instanceof Promise) {
|
|
6506
|
+
return res.then(handleResult);
|
|
6507
|
+
} else {
|
|
6508
|
+
return handleResult(res);
|
|
6487
6509
|
}
|
|
6488
|
-
eventTargets.forEach((t) => t.dispatchEvent(event));
|
|
6489
|
-
return detail;
|
|
6490
6510
|
};
|
|
6491
6511
|
};
|
|
6492
6512
|
}
|
|
@@ -6503,21 +6523,26 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6503
6523
|
|
|
6504
6524
|
// src/decorators/changedAttributeHost.ts
|
|
6505
6525
|
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
6506
|
-
|
|
6526
|
+
var convertValue = (val, type) => {
|
|
6527
|
+
if (val === null || val === void 0) return val;
|
|
6528
|
+
if (type === Number) return Number(val);
|
|
6529
|
+
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
6530
|
+
return val;
|
|
6531
|
+
};
|
|
6532
|
+
function changedAttributeHost(attributeName, options = {}) {
|
|
6507
6533
|
return (target, propertyKey) => {
|
|
6508
6534
|
const constructor = target.constructor;
|
|
6509
|
-
let
|
|
6510
|
-
if (!
|
|
6511
|
-
|
|
6512
|
-
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY,
|
|
6535
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6536
|
+
if (!metaList) {
|
|
6537
|
+
metaList = [];
|
|
6538
|
+
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
6513
6539
|
}
|
|
6514
6540
|
const name = attributeName || String(propertyKey);
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
}
|
|
6520
|
-
if (!methods.includes(propertyKey)) methods.push(propertyKey);
|
|
6541
|
+
metaList.push({
|
|
6542
|
+
attributeName: name,
|
|
6543
|
+
propertyKey,
|
|
6544
|
+
options
|
|
6545
|
+
});
|
|
6521
6546
|
};
|
|
6522
6547
|
}
|
|
6523
6548
|
var getChangedAttributeMetadata = (target) => {
|
|
@@ -6525,7 +6550,21 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6525
6550
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
6526
6551
|
};
|
|
6527
6552
|
var findAllAttributeChangedMetadata = (target) => {
|
|
6528
|
-
|
|
6553
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
6554
|
+
const metaList = ReflectUtils.findAllMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
6555
|
+
const result = /* @__PURE__ */ new Map();
|
|
6556
|
+
metaList.forEach((meta) => {
|
|
6557
|
+
meta.forEach((item) => {
|
|
6558
|
+
if (!result.has(item.attributeName)) {
|
|
6559
|
+
result.set(item.attributeName, []);
|
|
6560
|
+
}
|
|
6561
|
+
result.get(item.attributeName).push(item);
|
|
6562
|
+
});
|
|
6563
|
+
});
|
|
6564
|
+
return result;
|
|
6565
|
+
};
|
|
6566
|
+
var convertAttributeValue = (val, type) => {
|
|
6567
|
+
return convertValue(val, type);
|
|
6529
6568
|
};
|
|
6530
6569
|
|
|
6531
6570
|
// src/decorators/applyAttribute.ts
|
|
@@ -6551,70 +6590,80 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6551
6590
|
options: { ...finalOptions, name: attributeName }
|
|
6552
6591
|
});
|
|
6553
6592
|
const original = descriptor.value;
|
|
6554
|
-
descriptor.value =
|
|
6593
|
+
descriptor.value = function(...args) {
|
|
6555
6594
|
ensureInit(this);
|
|
6556
|
-
const res =
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6595
|
+
const res = original.apply(this, args);
|
|
6596
|
+
const handleResult = (resolvedValue) => {
|
|
6597
|
+
if (resolvedValue !== void 0) {
|
|
6598
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6599
|
+
const host2 = this;
|
|
6600
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6601
|
+
const r = finalOptions.root || "auto";
|
|
6602
|
+
const targetEls = [];
|
|
6603
|
+
const applyRoot = (t) => {
|
|
6604
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6605
|
+
targetEls.push(t);
|
|
6606
|
+
};
|
|
6607
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6608
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6609
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6610
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6611
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6612
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6613
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6614
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6615
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6616
|
+
else {
|
|
6617
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
6618
|
+
if (targetRoot) {
|
|
6619
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6620
|
+
if (found) targetEls.push(...Array.from(found));
|
|
6621
|
+
}
|
|
6581
6622
|
}
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6623
|
+
targetEls.forEach((targetEl) => {
|
|
6624
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
6625
|
+
return;
|
|
6626
|
+
}
|
|
6627
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
6628
|
+
if (action === "set" || action === "update") {
|
|
6629
|
+
if (attributeName) {
|
|
6630
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
6631
|
+
targetEl.removeAttribute(attributeName);
|
|
6632
|
+
} else {
|
|
6633
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
6634
|
+
}
|
|
6635
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6636
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6637
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6638
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6639
|
+
targetEl.removeAttribute(attr);
|
|
6640
|
+
} else {
|
|
6641
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6642
|
+
}
|
|
6643
|
+
});
|
|
6644
|
+
}
|
|
6645
|
+
} else if (action === "remove") {
|
|
6646
|
+
if (attributeName) {
|
|
6588
6647
|
targetEl.removeAttribute(attributeName);
|
|
6648
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6649
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6650
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6651
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
6652
|
+
});
|
|
6589
6653
|
} else {
|
|
6590
|
-
|
|
6654
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6655
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6591
6656
|
}
|
|
6592
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6593
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6594
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
6595
|
-
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
6596
|
-
targetEl.removeAttribute(attr);
|
|
6597
|
-
} else {
|
|
6598
|
-
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
6599
|
-
}
|
|
6600
|
-
});
|
|
6601
|
-
}
|
|
6602
|
-
} else if (action === "remove") {
|
|
6603
|
-
if (attributeName) {
|
|
6604
|
-
targetEl.removeAttribute(attributeName);
|
|
6605
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
6606
|
-
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
6607
|
-
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
6608
|
-
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
6609
|
-
});
|
|
6610
|
-
} else {
|
|
6611
|
-
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
6612
|
-
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
6613
6657
|
}
|
|
6614
|
-
}
|
|
6615
|
-
}
|
|
6658
|
+
});
|
|
6659
|
+
}
|
|
6660
|
+
return resolvedValue;
|
|
6661
|
+
};
|
|
6662
|
+
if (res instanceof Promise) {
|
|
6663
|
+
return res.then(handleResult);
|
|
6664
|
+
} else {
|
|
6665
|
+
return handleResult(res);
|
|
6616
6666
|
}
|
|
6617
|
-
return res;
|
|
6618
6667
|
};
|
|
6619
6668
|
return descriptor;
|
|
6620
6669
|
};
|
|
@@ -7912,7 +7961,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7912
7961
|
}
|
|
7913
7962
|
};
|
|
7914
7963
|
function buildEnv(configWindow) {
|
|
7915
|
-
const win = configWindow
|
|
7964
|
+
const win = configWindow;
|
|
7916
7965
|
const doc = win?.document;
|
|
7917
7966
|
const builtInTagMap = /* @__PURE__ */ new Map();
|
|
7918
7967
|
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
@@ -7951,7 +8000,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7951
8000
|
const aConf = getElementConfig(ancestors[i]);
|
|
7952
8001
|
if (aConf?.window) return aConf.window;
|
|
7953
8002
|
}
|
|
7954
|
-
return typeof window !== "undefined" ? window : void 0;
|
|
8003
|
+
return getElementConfig(this).window ?? (typeof window !== "undefined" ? window : void 0);
|
|
7955
8004
|
};
|
|
7956
8005
|
proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
|
|
7957
8006
|
ensureInit(this);
|
|
@@ -8053,8 +8102,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8053
8102
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
8054
8103
|
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
8055
8104
|
const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
|
|
8105
|
+
const proto = constructor.prototype;
|
|
8106
|
+
const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
|
|
8056
8107
|
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
8057
8108
|
...metadata.observedAttributes ?? [],
|
|
8109
|
+
...originalStaticObservedAttributes,
|
|
8058
8110
|
...attrChangeMap.keys(),
|
|
8059
8111
|
...attributeApplyNames,
|
|
8060
8112
|
...hostAttributes,
|
|
@@ -8063,7 +8115,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8063
8115
|
...swcOnEvents
|
|
8064
8116
|
])];
|
|
8065
8117
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
8066
|
-
const proto = constructor.prototype;
|
|
8067
8118
|
setupPrototype(proto);
|
|
8068
8119
|
const originalConnected = proto.connectedCallback;
|
|
8069
8120
|
proto.connectedCallback = function() {
|
|
@@ -8072,8 +8123,10 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8072
8123
|
const appHost2 = hostSet.$appHost;
|
|
8073
8124
|
const conf = getElementConfig(this);
|
|
8074
8125
|
const currentWin = this._resolveWindow(conf);
|
|
8075
|
-
|
|
8076
|
-
|
|
8126
|
+
const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
|
|
8127
|
+
if (shadowMode && !this.shadowRoot) {
|
|
8128
|
+
const mode = shadowMode === true ? "open" : shadowMode;
|
|
8129
|
+
this.attachShadow({ mode });
|
|
8077
8130
|
}
|
|
8078
8131
|
this._executeSwcScript("swc-on-before-connected", hostSet);
|
|
8079
8132
|
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
@@ -8085,12 +8138,16 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8085
8138
|
for (const meta of connectedInnerHtmlList) {
|
|
8086
8139
|
const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
|
|
8087
8140
|
if (res !== void 0) {
|
|
8088
|
-
if (meta.options.useShadow) sContent += res;
|
|
8141
|
+
if (meta.options.useShadow || conf?.useShadow) sContent += res;
|
|
8089
8142
|
else lContent += res;
|
|
8090
8143
|
}
|
|
8091
8144
|
}
|
|
8092
|
-
|
|
8093
|
-
|
|
8145
|
+
try {
|
|
8146
|
+
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
8147
|
+
if (lContent) this.innerHTML = lContent;
|
|
8148
|
+
} catch (e) {
|
|
8149
|
+
console.error("[ElementDefine] innerHTML setting error:", e);
|
|
8150
|
+
}
|
|
8094
8151
|
}
|
|
8095
8152
|
const root = this.getRootNode();
|
|
8096
8153
|
if (!globalDelegatedRoots.has(root)) {
|
|
@@ -8202,7 +8259,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8202
8259
|
const handler = async (event) => {
|
|
8203
8260
|
if (options.filter) {
|
|
8204
8261
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
8205
|
-
if (!options.filter(event, helper)) {
|
|
8262
|
+
if (!options.filter(event, { currentThis: this, helper })) {
|
|
8206
8263
|
return;
|
|
8207
8264
|
}
|
|
8208
8265
|
}
|
|
@@ -8286,15 +8343,17 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8286
8343
|
const expr = ae.getFirstExpression("call-return");
|
|
8287
8344
|
if (expr) {
|
|
8288
8345
|
const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
|
|
8346
|
+
const helperAndHostSet = SwcUtils.getHelperAndHostSet(win2, this);
|
|
8289
8347
|
try {
|
|
8348
|
+
const script = ConvertUtils2.decodeHtmlEntity(expr.script, win2.document);
|
|
8290
8349
|
const result = FunctionUtils.executeReturn({
|
|
8291
|
-
script
|
|
8350
|
+
script,
|
|
8292
8351
|
context: this,
|
|
8293
|
-
args:
|
|
8352
|
+
args: helperAndHostSet
|
|
8294
8353
|
});
|
|
8295
|
-
processedVal =
|
|
8354
|
+
processedVal = result;
|
|
8296
8355
|
} catch (e) {
|
|
8297
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}
|
|
8356
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}: ${helperAndHostSet}`, e);
|
|
8298
8357
|
processedVal = newVal;
|
|
8299
8358
|
}
|
|
8300
8359
|
}
|
|
@@ -8309,9 +8368,12 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8309
8368
|
if (hostCustomEventMeta && newVal !== null) {
|
|
8310
8369
|
this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
|
|
8311
8370
|
}
|
|
8312
|
-
const
|
|
8313
|
-
if (
|
|
8314
|
-
for (const
|
|
8371
|
+
const metaList = attrChangeMap.get(name2);
|
|
8372
|
+
if (metaList && Array.isArray(metaList)) {
|
|
8373
|
+
for (const meta of metaList) {
|
|
8374
|
+
const convertedVal = convertAttributeValue(processedVal, meta.options.type);
|
|
8375
|
+
this[meta.propertyKey](convertedVal, old, name2, hSet);
|
|
8376
|
+
}
|
|
8315
8377
|
}
|
|
8316
8378
|
};
|
|
8317
8379
|
Object.defineProperty(constructor, "observedAttributes", {
|
|
@@ -8328,12 +8390,38 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8328
8390
|
|
|
8329
8391
|
// src/decorators/attribute.ts
|
|
8330
8392
|
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
8331
|
-
var
|
|
8393
|
+
var convertValue2 = (val, type) => {
|
|
8332
8394
|
if (val === null || val === void 0) return val;
|
|
8333
8395
|
if (type === Number) return Number(val);
|
|
8334
8396
|
if (type === Boolean) return val === "false" || val === "0" ? false : true;
|
|
8335
8397
|
return val;
|
|
8336
8398
|
};
|
|
8399
|
+
var getAttributeValue = (inst, attrName, options) => {
|
|
8400
|
+
const conf = getElementConfig(inst);
|
|
8401
|
+
const currentWin = inst._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8402
|
+
const targets = options?.selector ? resolveTargetEls(inst, options.selector, options, currentWin) : [inst];
|
|
8403
|
+
const primaryTarget = targets[0];
|
|
8404
|
+
if (primaryTarget && typeof primaryTarget.hasAttribute === "function" && primaryTarget.hasAttribute(attrName)) {
|
|
8405
|
+
let domVal = primaryTarget.getAttribute(attrName);
|
|
8406
|
+
const ae = new ActionExpression(domVal);
|
|
8407
|
+
const expr = ae.getFirstExpression("call-return");
|
|
8408
|
+
if (expr) {
|
|
8409
|
+
try {
|
|
8410
|
+
const result = FunctionUtils.executeReturn({
|
|
8411
|
+
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8412
|
+
context: inst,
|
|
8413
|
+
args: SwcUtils.getHelperAndHostSet(currentWin, inst)
|
|
8414
|
+
});
|
|
8415
|
+
return convertValue2(result, options?.type);
|
|
8416
|
+
} catch (e) {
|
|
8417
|
+
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8418
|
+
return convertValue2(domVal, options?.type);
|
|
8419
|
+
}
|
|
8420
|
+
}
|
|
8421
|
+
return convertValue2(domVal, options?.type);
|
|
8422
|
+
}
|
|
8423
|
+
return null;
|
|
8424
|
+
};
|
|
8337
8425
|
var resolveTargetEls = (inst, selector, options, currentWin) => {
|
|
8338
8426
|
const r = options.root || "auto";
|
|
8339
8427
|
const results = [];
|
|
@@ -8408,35 +8496,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8408
8496
|
Object.defineProperty(target, propertyKey, {
|
|
8409
8497
|
get() {
|
|
8410
8498
|
const attrName = options.name || String(propertyKey);
|
|
8411
|
-
const
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
let domVal = primaryTarget.getAttribute(attrName);
|
|
8419
|
-
const ae = new ActionExpression(domVal);
|
|
8420
|
-
const expr = ae.getFirstExpression("call-return");
|
|
8421
|
-
if (expr) {
|
|
8422
|
-
try {
|
|
8423
|
-
const result = FunctionUtils.executeReturn({
|
|
8424
|
-
script: ConvertUtils2.decodeHtmlEntity(expr.script, currentWin.document),
|
|
8425
|
-
context: this,
|
|
8426
|
-
args: SwcUtils.getHelperAndHostSet(currentWin, this)
|
|
8427
|
-
});
|
|
8428
|
-
return convertValue(result, targetType);
|
|
8429
|
-
} catch (e) {
|
|
8430
|
-
console.error(`[SWC] Failed to execute directive {{= ${expr.script} }}:`, e);
|
|
8431
|
-
return convertValue(domVal, targetType);
|
|
8432
|
-
}
|
|
8433
|
-
}
|
|
8434
|
-
return convertValue(domVal, targetType);
|
|
8435
|
-
}
|
|
8436
|
-
return null;
|
|
8437
|
-
}
|
|
8438
|
-
const data = convertValue(this[privateKey], targetType);
|
|
8439
|
-
return data;
|
|
8499
|
+
const mergedOptions = {
|
|
8500
|
+
...options,
|
|
8501
|
+
selector,
|
|
8502
|
+
type: options.type || designType
|
|
8503
|
+
};
|
|
8504
|
+
const result = getAttributeValue(this, attrName, mergedOptions);
|
|
8505
|
+
return result !== null ? result : this[privateKey];
|
|
8440
8506
|
},
|
|
8441
8507
|
set(nv) {
|
|
8442
8508
|
const attrName = options.name || String(propertyKey);
|
|
@@ -8549,14 +8615,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8549
8615
|
const res = original.apply(this, args);
|
|
8550
8616
|
const runApply = (target, val) => {
|
|
8551
8617
|
const pos = options.position || "beforeEnd";
|
|
8552
|
-
|
|
8553
|
-
if (v instanceof Node) return !t.contains(v);
|
|
8554
|
-
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
8555
|
-
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
8556
|
-
return true;
|
|
8557
|
-
};
|
|
8558
|
-
const activeFilter = options.filter || defaultFilter;
|
|
8559
|
-
if (activeFilter(target, val, hostSet)) {
|
|
8618
|
+
if (!options.filter || options.filter(target, val, { currentThis: this, helper: hostSet })) {
|
|
8560
8619
|
applyToDom(target, val, pos, currentDoc);
|
|
8561
8620
|
}
|
|
8562
8621
|
};
|
|
@@ -8628,81 +8687,91 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8628
8687
|
}
|
|
8629
8688
|
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
8630
8689
|
const original = descriptor.value;
|
|
8631
|
-
descriptor.value =
|
|
8690
|
+
descriptor.value = function(...args) {
|
|
8632
8691
|
ensureInit(this);
|
|
8633
|
-
const res =
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
}
|
|
8660
|
-
targetEls.forEach((targetEl) => {
|
|
8661
|
-
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
8662
|
-
if (action === "set") {
|
|
8663
|
-
let classes = "";
|
|
8664
|
-
if (classMap && typeof classMap === "string") {
|
|
8665
|
-
classes = resolvedRes ? classMap : "";
|
|
8666
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8667
|
-
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8668
|
-
} else {
|
|
8669
|
-
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8692
|
+
const res = original.apply(this, args);
|
|
8693
|
+
const handleResult = (resolvedValue) => {
|
|
8694
|
+
if (resolvedValue !== void 0) {
|
|
8695
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8696
|
+
const host2 = this;
|
|
8697
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8698
|
+
const r = finalOptions.root || "auto";
|
|
8699
|
+
const targetEls = [];
|
|
8700
|
+
const applyRoot = (t) => {
|
|
8701
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8702
|
+
targetEls.push(t);
|
|
8703
|
+
};
|
|
8704
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8705
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8706
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8707
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8708
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8709
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8710
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8711
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8712
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8713
|
+
else {
|
|
8714
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8715
|
+
if (targetRoot) {
|
|
8716
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8717
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8670
8718
|
}
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
if (
|
|
8674
|
-
|
|
8675
|
-
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8676
|
-
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8677
|
-
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8678
|
-
targetEl.classList.toggle(cls, isActive);
|
|
8679
|
-
});
|
|
8680
|
-
} else {
|
|
8681
|
-
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8682
|
-
if (action === "update") targetEl.classList.add(...classes);
|
|
8683
|
-
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8719
|
+
}
|
|
8720
|
+
targetEls.forEach((targetEl) => {
|
|
8721
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8722
|
+
return;
|
|
8684
8723
|
}
|
|
8685
|
-
|
|
8686
|
-
if (
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
if (
|
|
8700
|
-
|
|
8724
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8725
|
+
if (action === "set") {
|
|
8726
|
+
let classes = "";
|
|
8727
|
+
if (classMap && typeof classMap === "string") {
|
|
8728
|
+
classes = resolvedRes ? classMap : "";
|
|
8729
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8730
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
8731
|
+
} else {
|
|
8732
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
8733
|
+
}
|
|
8734
|
+
targetEl.className = classes;
|
|
8735
|
+
} else if (action === "update" || action === "toggle") {
|
|
8736
|
+
if (classMap && typeof classMap === "string") {
|
|
8737
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
8738
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8739
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8740
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8741
|
+
targetEl.classList.toggle(cls, isActive);
|
|
8742
|
+
});
|
|
8743
|
+
} else {
|
|
8744
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8745
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
8746
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
8747
|
+
}
|
|
8748
|
+
} else if (action === "add" || action === "remove") {
|
|
8749
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
8750
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
8751
|
+
else targetEl.classList.remove(classMap);
|
|
8752
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8753
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
8754
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
8755
|
+
if (shouldExecute) {
|
|
8756
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
8757
|
+
else targetEl.classList.remove(cls);
|
|
8758
|
+
}
|
|
8759
|
+
});
|
|
8760
|
+
} else {
|
|
8761
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
8762
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
8763
|
+
else targetEl.classList.remove(...classes);
|
|
8764
|
+
}
|
|
8701
8765
|
}
|
|
8702
|
-
}
|
|
8703
|
-
}
|
|
8766
|
+
});
|
|
8767
|
+
}
|
|
8768
|
+
return resolvedValue;
|
|
8769
|
+
};
|
|
8770
|
+
if (res instanceof Promise) {
|
|
8771
|
+
return res.then(handleResult);
|
|
8772
|
+
} else {
|
|
8773
|
+
return handleResult(res);
|
|
8704
8774
|
}
|
|
8705
|
-
return res;
|
|
8706
8775
|
};
|
|
8707
8776
|
return descriptor;
|
|
8708
8777
|
};
|
|
@@ -8748,67 +8817,77 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8748
8817
|
}
|
|
8749
8818
|
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
8750
8819
|
const original = descriptor.value;
|
|
8751
|
-
descriptor.value =
|
|
8820
|
+
descriptor.value = function(...args) {
|
|
8752
8821
|
ensureInit(this);
|
|
8753
|
-
const res =
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8822
|
+
const res = original.apply(this, args);
|
|
8823
|
+
const handleResult = (resolvedValue) => {
|
|
8824
|
+
if (resolvedValue !== void 0) {
|
|
8825
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8826
|
+
const host2 = this;
|
|
8827
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, host2);
|
|
8828
|
+
const r = options.root || "auto";
|
|
8829
|
+
const targetEls = [];
|
|
8830
|
+
const applyRoot = (t) => {
|
|
8831
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8832
|
+
targetEls.push(t);
|
|
8833
|
+
};
|
|
8834
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8835
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8836
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8837
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8838
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8839
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8840
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8841
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8842
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8843
|
+
else {
|
|
8844
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8845
|
+
if (targetRoot) {
|
|
8846
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8847
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8848
|
+
}
|
|
8778
8849
|
}
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
if (action === "set" || action === "update") {
|
|
8783
|
-
if (action === "set") targetEl.style.cssText = "";
|
|
8784
|
-
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8785
|
-
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8786
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8787
|
-
if (finalVal === null || finalVal === void 0) {
|
|
8788
|
-
targetEl.style.removeProperty(prop);
|
|
8789
|
-
} else {
|
|
8790
|
-
targetEl.style[prop] = String(finalVal);
|
|
8791
|
-
}
|
|
8792
|
-
});
|
|
8793
|
-
} else if (typeof resolvedRes === "string") {
|
|
8794
|
-
targetEl.style.cssText = resolvedRes;
|
|
8850
|
+
targetEls.forEach((targetEl) => {
|
|
8851
|
+
if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8852
|
+
return;
|
|
8795
8853
|
}
|
|
8796
|
-
|
|
8797
|
-
if (
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
targetEl
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8854
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8855
|
+
if (action === "set" || action === "update") {
|
|
8856
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
8857
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8858
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8859
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8860
|
+
if (finalVal === null || finalVal === void 0) {
|
|
8861
|
+
targetEl.style.removeProperty(prop);
|
|
8862
|
+
} else {
|
|
8863
|
+
targetEl.style[prop] = String(finalVal);
|
|
8864
|
+
}
|
|
8865
|
+
});
|
|
8866
|
+
} else if (typeof resolvedRes === "string") {
|
|
8867
|
+
targetEl.style.cssText = resolvedRes;
|
|
8868
|
+
}
|
|
8869
|
+
} else if (action === "remove") {
|
|
8870
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8871
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8872
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
8873
|
+
if (shouldRemove) {
|
|
8874
|
+
targetEl.style.removeProperty(prop);
|
|
8875
|
+
}
|
|
8876
|
+
});
|
|
8877
|
+
} else {
|
|
8878
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
8879
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
8880
|
+
}
|
|
8807
8881
|
}
|
|
8808
|
-
}
|
|
8809
|
-
}
|
|
8882
|
+
});
|
|
8883
|
+
}
|
|
8884
|
+
return resolvedValue;
|
|
8885
|
+
};
|
|
8886
|
+
if (res instanceof Promise) {
|
|
8887
|
+
return res.then(handleResult);
|
|
8888
|
+
} else {
|
|
8889
|
+
return handleResult(res);
|
|
8810
8890
|
}
|
|
8811
|
-
return res;
|
|
8812
8891
|
};
|
|
8813
8892
|
return descriptor;
|
|
8814
8893
|
};
|
|
@@ -8858,48 +8937,59 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8858
8937
|
options: { ...finalOptions, name: propertyName }
|
|
8859
8938
|
});
|
|
8860
8939
|
const original = descriptor.value;
|
|
8861
|
-
descriptor.value =
|
|
8940
|
+
descriptor.value = function(...args) {
|
|
8862
8941
|
ensureInit(this);
|
|
8863
|
-
const res =
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8942
|
+
const res = original.apply(this, args);
|
|
8943
|
+
const handleResult = (resolvedValue) => {
|
|
8944
|
+
if (resolvedValue !== void 0) {
|
|
8945
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
8946
|
+
const host2 = this;
|
|
8947
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
8948
|
+
const r = finalOptions.root || "auto";
|
|
8949
|
+
const targetEls = [];
|
|
8950
|
+
const applyRoot = (t) => {
|
|
8951
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
8952
|
+
targetEls.push(t);
|
|
8953
|
+
};
|
|
8954
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
8955
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
8956
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
8957
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
8958
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
8959
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
8960
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
8961
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
8962
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
8963
|
+
else {
|
|
8964
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
8965
|
+
if (targetRoot) {
|
|
8966
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
8967
|
+
if (found) targetEls.push(...Array.from(found));
|
|
8968
|
+
}
|
|
8888
8969
|
}
|
|
8970
|
+
targetEls.forEach((targetEl) => {
|
|
8971
|
+
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
8972
|
+
return;
|
|
8973
|
+
}
|
|
8974
|
+
const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
|
|
8975
|
+
if (propertyName) {
|
|
8976
|
+
targetEl[propertyName] = resolvedRes;
|
|
8977
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
8978
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
8979
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8980
|
+
targetEl[prop] = finalVal;
|
|
8981
|
+
});
|
|
8982
|
+
} else {
|
|
8983
|
+
targetEl.value = resolvedRes;
|
|
8984
|
+
}
|
|
8985
|
+
});
|
|
8889
8986
|
}
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
8897
|
-
targetEl[prop] = finalVal;
|
|
8898
|
-
});
|
|
8899
|
-
} else {
|
|
8900
|
-
targetEl.value = resolvedRes;
|
|
8901
|
-
}
|
|
8902
|
-
});
|
|
8987
|
+
return resolvedValue;
|
|
8988
|
+
};
|
|
8989
|
+
if (res instanceof Promise) {
|
|
8990
|
+
return res.then(handleResult);
|
|
8991
|
+
} else {
|
|
8992
|
+
return handleResult(res);
|
|
8903
8993
|
}
|
|
8904
8994
|
};
|
|
8905
8995
|
};
|