@dooboostore/simple-web-component 1.0.44 → 1.0.45
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 +25 -25
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +36 -15
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +53 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +51 -23
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +38 -17
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +53 -22
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +44 -25
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +61 -47
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/query.js +91 -56
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +104 -66
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +36 -15
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +53 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +51 -23
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +38 -17
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +53 -22
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +44 -25
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +61 -47
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/query.js +91 -56
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +104 -66
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +531 -293
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +7 -6
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +12 -8
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +8 -7
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +18 -17
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +13 -9
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +6 -5
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +3 -2
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +15 -5
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +15 -5
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +531 -293
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +9 -7
- package/src/decorators/applyAttribute.ts +59 -27
- package/src/decorators/applyClass.ts +78 -32
- package/src/decorators/applyNode.ts +115 -72
- package/src/decorators/applyProperty.ts +62 -30
- package/src/decorators/applyStyle.ts +76 -30
- package/src/decorators/elementDefine.ts +49 -26
- package/src/decorators/emitCustomEvent.ts +63 -39
- package/src/decorators/query.ts +111 -49
- package/src/decorators/queryAll.ts +121 -61
- package/src/types/window.d.ts +3 -0
|
@@ -9162,7 +9162,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9162
9162
|
if (typeof selectorOrTarget === "object" && typeof typeOrPropertyKey === "string" && typeof optionsOrDescriptor === "object" && "value" in optionsOrDescriptor) {
|
|
9163
9163
|
throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);
|
|
9164
9164
|
}
|
|
9165
|
-
if (typeof selectorOrTarget === "string" && typeof typeOrPropertyKey === "string") {
|
|
9165
|
+
if ((typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") && typeof typeOrPropertyKey === "string") {
|
|
9166
9166
|
return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor);
|
|
9167
9167
|
}
|
|
9168
9168
|
if (typeof selectorOrTarget === "string" && typeOrPropertyKey !== "string") {
|
|
@@ -9195,58 +9195,72 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9195
9195
|
composed: fullOptions.composed,
|
|
9196
9196
|
cancelable: fullOptions.cancelable
|
|
9197
9197
|
});
|
|
9198
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9199
9198
|
const conf = getElementConfig(this);
|
|
9200
9199
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
9200
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
9201
9201
|
const eventTargets = [];
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
} else if (
|
|
9213
|
-
if (hostSet.$appHost)
|
|
9214
|
-
eventTargets.push(hostSet.$appHost);
|
|
9215
|
-
} else if (selector === "$firstHost") {
|
|
9216
|
-
if (hostSet.$firstHost)
|
|
9217
|
-
eventTargets.push(hostSet.$firstHost);
|
|
9218
|
-
} else if (selector === "$lastHost") {
|
|
9219
|
-
if (hostSet.$lastHost)
|
|
9220
|
-
eventTargets.push(hostSet.$lastHost);
|
|
9221
|
-
} else if (selector === "$firstAppHost") {
|
|
9222
|
-
if (hostSet.$firstAppHost)
|
|
9223
|
-
eventTargets.push(hostSet.$firstAppHost);
|
|
9224
|
-
} else if (selector === "$lastAppHost") {
|
|
9225
|
-
if (hostSet.$lastAppHost)
|
|
9226
|
-
eventTargets.push(hostSet.$lastAppHost);
|
|
9227
|
-
} else if (selector === "$hosts") {
|
|
9228
|
-
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
9229
|
-
} else if (selector === "$appHosts") {
|
|
9230
|
-
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
9231
|
-
} else if (selector === "$this" || !selector) {
|
|
9232
|
-
eventTargets.push(this);
|
|
9202
|
+
let resolvedSelector = selector;
|
|
9203
|
+
if (typeof selector === "function") {
|
|
9204
|
+
resolvedSelector = selector(this, hostSet);
|
|
9205
|
+
}
|
|
9206
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
9207
|
+
eventTargets.push(resolvedSelector);
|
|
9208
|
+
} else if (resolvedSelector instanceof currentWin.NodeList) {
|
|
9209
|
+
eventTargets.push(...Array.from(resolvedSelector));
|
|
9210
|
+
} else if (Array.isArray(resolvedSelector)) {
|
|
9211
|
+
eventTargets.push(...resolvedSelector);
|
|
9212
|
+
} else if (resolvedSelector === null) {
|
|
9233
9213
|
} else {
|
|
9234
|
-
const
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
else if (
|
|
9243
|
-
|
|
9244
|
-
|
|
9214
|
+
const stringSelector = resolvedSelector;
|
|
9215
|
+
if (stringSelector === "$window")
|
|
9216
|
+
eventTargets.push(currentWin);
|
|
9217
|
+
else if (stringSelector === "$document")
|
|
9218
|
+
eventTargets.push(currentWin.document);
|
|
9219
|
+
else if (stringSelector === "$host") {
|
|
9220
|
+
if (hostSet.$host)
|
|
9221
|
+
eventTargets.push(hostSet.$host);
|
|
9222
|
+
} else if (stringSelector === "$parentHost") {
|
|
9223
|
+
if (hostSet.$parentHost)
|
|
9224
|
+
eventTargets.push(hostSet.$parentHost);
|
|
9225
|
+
} else if (stringSelector === "$appHost") {
|
|
9226
|
+
if (hostSet.$appHost)
|
|
9227
|
+
eventTargets.push(hostSet.$appHost);
|
|
9228
|
+
} else if (stringSelector === "$firstHost") {
|
|
9229
|
+
if (hostSet.$firstHost)
|
|
9230
|
+
eventTargets.push(hostSet.$firstHost);
|
|
9231
|
+
} else if (stringSelector === "$lastHost") {
|
|
9232
|
+
if (hostSet.$lastHost)
|
|
9233
|
+
eventTargets.push(hostSet.$lastHost);
|
|
9234
|
+
} else if (stringSelector === "$firstAppHost") {
|
|
9235
|
+
if (hostSet.$firstAppHost)
|
|
9236
|
+
eventTargets.push(hostSet.$firstAppHost);
|
|
9237
|
+
} else if (stringSelector === "$lastAppHost") {
|
|
9238
|
+
if (hostSet.$lastAppHost)
|
|
9239
|
+
eventTargets.push(hostSet.$lastAppHost);
|
|
9240
|
+
} else if (stringSelector === "$hosts") {
|
|
9241
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
9242
|
+
} else if (stringSelector === "$appHosts") {
|
|
9243
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
9244
|
+
} else if (stringSelector === "$this" || !stringSelector) {
|
|
9245
|
+
eventTargets.push(this);
|
|
9246
|
+
} else {
|
|
9247
|
+
const r = fullOptions.root || "auto";
|
|
9248
|
+
const searchRoots = [];
|
|
9249
|
+
if (r === "auto")
|
|
9250
|
+
searchRoots.push(this.shadowRoot || this);
|
|
9251
|
+
else if (r === "light")
|
|
9252
|
+
searchRoots.push(this);
|
|
9253
|
+
else if (r === "shadow" && this.shadowRoot)
|
|
9245
9254
|
searchRoots.push(this.shadowRoot);
|
|
9255
|
+
else if (r === "all") {
|
|
9256
|
+
searchRoots.push(this);
|
|
9257
|
+
if (this.shadowRoot)
|
|
9258
|
+
searchRoots.push(this.shadowRoot);
|
|
9259
|
+
}
|
|
9260
|
+
searchRoots.forEach((sr) => {
|
|
9261
|
+
sr.querySelectorAll(stringSelector).forEach((el) => eventTargets.push(el));
|
|
9262
|
+
});
|
|
9246
9263
|
}
|
|
9247
|
-
searchRoots.forEach((sr) => {
|
|
9248
|
-
sr.querySelectorAll(selector).forEach((el) => eventTargets.push(el));
|
|
9249
|
-
});
|
|
9250
9264
|
}
|
|
9251
9265
|
eventTargets.forEach((t) => {
|
|
9252
9266
|
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
@@ -9322,7 +9336,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9322
9336
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9323
9337
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9324
9338
|
}
|
|
9325
|
-
if (typeof selectorOrTarget === "string") {
|
|
9339
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
9326
9340
|
return (targetObj, propertyKey, descriptor2) => {
|
|
9327
9341
|
if (descriptor2 !== void 0) {
|
|
9328
9342
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -9337,75 +9351,110 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9337
9351
|
Object.defineProperty(targetObj, propertyKey, {
|
|
9338
9352
|
get() {
|
|
9339
9353
|
ensureInit(this);
|
|
9340
|
-
const selector = selectorOrTarget;
|
|
9341
|
-
const r = optionsOrPropertyKey?.root || "auto";
|
|
9342
|
-
const applyRoot = (t) => {
|
|
9343
|
-
if (!t || !(t instanceof HTMLElement))
|
|
9344
|
-
return t;
|
|
9345
|
-
if (r === "auto")
|
|
9346
|
-
return t.shadowRoot || t;
|
|
9347
|
-
if (r === "shadow")
|
|
9348
|
-
return t.shadowRoot;
|
|
9349
|
-
if (r === "light")
|
|
9350
|
-
return t;
|
|
9351
|
-
if (r === "all")
|
|
9352
|
-
return t.shadowRoot || t;
|
|
9353
|
-
return t;
|
|
9354
|
-
};
|
|
9355
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9356
|
-
if (selector === "$this")
|
|
9357
|
-
return applyRoot(this);
|
|
9358
|
-
if (selector === "$host")
|
|
9359
|
-
return applyRoot(hostSet.$host);
|
|
9360
|
-
if (selector === "$parentHost")
|
|
9361
|
-
return applyRoot(hostSet.$parentHost);
|
|
9362
|
-
if (selector === "$appHost")
|
|
9363
|
-
return applyRoot(hostSet.$appHost);
|
|
9364
|
-
if (selector === "$firstHost")
|
|
9365
|
-
return applyRoot(hostSet.$firstHost);
|
|
9366
|
-
if (selector === "$lastHost")
|
|
9367
|
-
return applyRoot(hostSet.$lastHost);
|
|
9368
|
-
if (selector === "$firstAppHost")
|
|
9369
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
9370
|
-
if (selector === "$lastAppHost")
|
|
9371
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
9372
9354
|
const config = getElementConfig(this);
|
|
9373
9355
|
const win = config?.window || window;
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9356
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9357
|
+
let resolvedSelector;
|
|
9358
|
+
let resolvedElement = null;
|
|
9359
|
+
if (typeof selectorOrTarget === "function") {
|
|
9360
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9361
|
+
if (result instanceof win.Node || result instanceof win.Element) {
|
|
9362
|
+
resolvedElement = result instanceof win.HTMLElement ? result : null;
|
|
9363
|
+
} else if (result instanceof win.NodeList || Array.isArray(result)) {
|
|
9364
|
+
resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
|
|
9365
|
+
}
|
|
9366
|
+
} else {
|
|
9367
|
+
resolvedSelector = selectorOrTarget;
|
|
9368
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9369
|
+
const applyRoot = (t) => {
|
|
9370
|
+
if (!t || !(t instanceof HTMLElement))
|
|
9371
|
+
return t;
|
|
9372
|
+
if (r === "auto")
|
|
9373
|
+
return t.shadowRoot || t;
|
|
9374
|
+
if (r === "shadow")
|
|
9375
|
+
return t.shadowRoot;
|
|
9376
|
+
if (r === "light")
|
|
9377
|
+
return t;
|
|
9378
|
+
if (r === "all")
|
|
9379
|
+
return t.shadowRoot || t;
|
|
9380
|
+
return t;
|
|
9381
|
+
};
|
|
9382
|
+
if (resolvedSelector === "$this")
|
|
9383
|
+
resolvedElement = applyRoot(this);
|
|
9384
|
+
else if (resolvedSelector === "$host")
|
|
9385
|
+
resolvedElement = applyRoot(hostSet.$host);
|
|
9386
|
+
else if (resolvedSelector === "$parentHost")
|
|
9387
|
+
resolvedElement = applyRoot(hostSet.$parentHost);
|
|
9388
|
+
else if (resolvedSelector === "$appHost")
|
|
9389
|
+
resolvedElement = applyRoot(hostSet.$appHost);
|
|
9390
|
+
else if (resolvedSelector === "$firstHost")
|
|
9391
|
+
resolvedElement = applyRoot(hostSet.$firstHost);
|
|
9392
|
+
else if (resolvedSelector === "$lastHost")
|
|
9393
|
+
resolvedElement = applyRoot(hostSet.$lastHost);
|
|
9394
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
9395
|
+
resolvedElement = applyRoot(hostSet.$firstAppHost);
|
|
9396
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
9397
|
+
resolvedElement = applyRoot(hostSet.$lastAppHost);
|
|
9398
|
+
else if (resolvedSelector === "$window")
|
|
9399
|
+
return win;
|
|
9400
|
+
else if (resolvedSelector === "$document")
|
|
9401
|
+
return win.document;
|
|
9402
|
+
else {
|
|
9403
|
+
if (r === "shadow")
|
|
9404
|
+
resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
|
|
9405
|
+
else if (r === "light")
|
|
9406
|
+
resolvedElement = this.querySelector(resolvedSelector);
|
|
9407
|
+
else if (r === "all") {
|
|
9408
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
|
|
9409
|
+
resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
|
|
9410
|
+
} else
|
|
9411
|
+
resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
|
|
9412
|
+
}
|
|
9413
|
+
}
|
|
9414
|
+
if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
|
|
9415
|
+
const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
|
|
9416
|
+
if (!shouldInclude) {
|
|
9417
|
+
return null;
|
|
9418
|
+
}
|
|
9385
9419
|
}
|
|
9386
|
-
return
|
|
9420
|
+
return resolvedElement;
|
|
9387
9421
|
},
|
|
9388
9422
|
set(nv) {
|
|
9389
9423
|
ensureInit(this);
|
|
9390
9424
|
if (nv === null || nv === void 0) {
|
|
9391
|
-
const
|
|
9392
|
-
|
|
9425
|
+
const config = getElementConfig(this);
|
|
9426
|
+
const win = config?.window || window;
|
|
9427
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9428
|
+
if (typeof selectorOrTarget === "function") {
|
|
9429
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9430
|
+
if (result instanceof win.Element) {
|
|
9431
|
+
result.remove();
|
|
9432
|
+
} else if (result instanceof win.NodeList || Array.isArray(result)) {
|
|
9433
|
+
const el = result.length > 0 ? result[0] : null;
|
|
9434
|
+
if (el instanceof win.Element) {
|
|
9435
|
+
el.remove();
|
|
9436
|
+
}
|
|
9437
|
+
}
|
|
9438
|
+
return;
|
|
9439
|
+
}
|
|
9440
|
+
const resolvedSelector = selectorOrTarget;
|
|
9441
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
9393
9442
|
return;
|
|
9394
9443
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
9395
9444
|
const targets = [];
|
|
9396
9445
|
if (r === "shadow") {
|
|
9397
|
-
if (this.shadowRoot?.querySelector(
|
|
9398
|
-
targets.push(this.shadowRoot.querySelector(
|
|
9446
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
9447
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
9399
9448
|
} else if (r === "light") {
|
|
9400
|
-
if (this.querySelector(
|
|
9401
|
-
targets.push(this.querySelector(
|
|
9449
|
+
if (this.querySelector(resolvedSelector))
|
|
9450
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
9402
9451
|
} else if (r === "all") {
|
|
9403
|
-
if (this.shadowRoot?.querySelector(
|
|
9404
|
-
targets.push(this.shadowRoot.querySelector(
|
|
9405
|
-
if (this.querySelector(
|
|
9406
|
-
targets.push(this.querySelector(
|
|
9452
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
9453
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
9454
|
+
if (this.querySelector(resolvedSelector))
|
|
9455
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
9407
9456
|
} else {
|
|
9408
|
-
const el = (this.shadowRoot || this).querySelector(
|
|
9457
|
+
const el = (this.shadowRoot || this).querySelector(resolvedSelector);
|
|
9409
9458
|
if (el)
|
|
9410
9459
|
targets.push(el);
|
|
9411
9460
|
}
|
|
@@ -9430,7 +9479,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9430
9479
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9431
9480
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9432
9481
|
}
|
|
9433
|
-
if (typeof selectorOrTarget === "string") {
|
|
9482
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
9434
9483
|
return (targetObj, propertyKey, descriptor2) => {
|
|
9435
9484
|
if (descriptor2 !== void 0) {
|
|
9436
9485
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -9445,86 +9494,124 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9445
9494
|
Object.defineProperty(targetObj, propertyKey, {
|
|
9446
9495
|
get() {
|
|
9447
9496
|
ensureInit(this);
|
|
9448
|
-
const selector = selectorOrTarget;
|
|
9449
|
-
const r = optionsOrPropertyKey?.root || "auto";
|
|
9450
|
-
const applyRoot = (t) => {
|
|
9451
|
-
if (!t)
|
|
9452
|
-
return [];
|
|
9453
|
-
const items = Array.isArray(t) ? t : [t];
|
|
9454
|
-
const results = [];
|
|
9455
|
-
items.forEach((it) => {
|
|
9456
|
-
if (!(it instanceof HTMLElement)) {
|
|
9457
|
-
results.push(it);
|
|
9458
|
-
return;
|
|
9459
|
-
}
|
|
9460
|
-
if (r === "auto")
|
|
9461
|
-
results.push(it.shadowRoot || it);
|
|
9462
|
-
else {
|
|
9463
|
-
if (r === "light" || r === "all")
|
|
9464
|
-
results.push(it);
|
|
9465
|
-
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9466
|
-
results.push(it.shadowRoot);
|
|
9467
|
-
}
|
|
9468
|
-
});
|
|
9469
|
-
return results;
|
|
9470
|
-
};
|
|
9471
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9472
|
-
if (selector === "$hosts")
|
|
9473
|
-
return applyRoot(hostSet.$hosts);
|
|
9474
|
-
if (selector === "$appHosts")
|
|
9475
|
-
return applyRoot(hostSet.$appHosts);
|
|
9476
|
-
if (selector === "$host")
|
|
9477
|
-
return applyRoot(hostSet.$host);
|
|
9478
|
-
if (selector === "$parentHost")
|
|
9479
|
-
return applyRoot(hostSet.$parentHost);
|
|
9480
|
-
if (selector === "$appHost")
|
|
9481
|
-
return applyRoot(hostSet.$appHost);
|
|
9482
|
-
if (selector === "$firstHost")
|
|
9483
|
-
return applyRoot(hostSet.$firstHost);
|
|
9484
|
-
if (selector === "$lastHost")
|
|
9485
|
-
return applyRoot(hostSet.$lastHost);
|
|
9486
|
-
if (selector === "$firstAppHost")
|
|
9487
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
9488
|
-
if (selector === "$lastAppHost")
|
|
9489
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
9490
9497
|
const config = getElementConfig(this);
|
|
9491
9498
|
const win = config?.window || window;
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
const
|
|
9505
|
-
|
|
9499
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9500
|
+
let resolvedSelector;
|
|
9501
|
+
let resolvedElements = [];
|
|
9502
|
+
if (typeof selectorOrTarget === "function") {
|
|
9503
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9504
|
+
if (result instanceof win.NodeList) {
|
|
9505
|
+
resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
|
|
9506
|
+
} else if (Array.isArray(result)) {
|
|
9507
|
+
resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
|
|
9508
|
+
}
|
|
9509
|
+
} else {
|
|
9510
|
+
resolvedSelector = selectorOrTarget;
|
|
9511
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9512
|
+
const applyRoot = (t) => {
|
|
9513
|
+
if (!t)
|
|
9514
|
+
return [];
|
|
9515
|
+
const items = Array.isArray(t) ? t : [t];
|
|
9516
|
+
const results = [];
|
|
9517
|
+
items.forEach((it) => {
|
|
9518
|
+
if (!(it instanceof HTMLElement)) {
|
|
9519
|
+
results.push(it);
|
|
9520
|
+
return;
|
|
9521
|
+
}
|
|
9522
|
+
if (r === "auto")
|
|
9523
|
+
results.push(it.shadowRoot || it);
|
|
9524
|
+
else {
|
|
9525
|
+
if (r === "light" || r === "all")
|
|
9526
|
+
results.push(it);
|
|
9527
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9528
|
+
results.push(it.shadowRoot);
|
|
9529
|
+
}
|
|
9530
|
+
});
|
|
9531
|
+
return results;
|
|
9532
|
+
};
|
|
9533
|
+
if (resolvedSelector === "$hosts")
|
|
9534
|
+
resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
|
|
9535
|
+
else if (resolvedSelector === "$appHosts")
|
|
9536
|
+
resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
|
|
9537
|
+
else if (resolvedSelector === "$host")
|
|
9538
|
+
resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
|
|
9539
|
+
else if (resolvedSelector === "$parentHost")
|
|
9540
|
+
resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
|
|
9541
|
+
else if (resolvedSelector === "$appHost")
|
|
9542
|
+
resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
|
|
9543
|
+
else if (resolvedSelector === "$firstHost")
|
|
9544
|
+
resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
|
|
9545
|
+
else if (resolvedSelector === "$lastHost")
|
|
9546
|
+
resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
|
|
9547
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
9548
|
+
resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
|
|
9549
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
9550
|
+
resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
|
|
9551
|
+
else if (resolvedSelector === "$window")
|
|
9552
|
+
return [win];
|
|
9553
|
+
else if (resolvedSelector === "$document")
|
|
9554
|
+
return [win.document];
|
|
9555
|
+
else if (resolvedSelector === "$this")
|
|
9556
|
+
resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
|
|
9557
|
+
else {
|
|
9558
|
+
if (r === "shadow")
|
|
9559
|
+
resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9560
|
+
else if (r === "light")
|
|
9561
|
+
resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9562
|
+
else if (r === "all") {
|
|
9563
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9564
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9565
|
+
resolvedElements = [...sNodes, ...lNodes];
|
|
9566
|
+
} else
|
|
9567
|
+
resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
9568
|
+
}
|
|
9506
9569
|
}
|
|
9507
|
-
|
|
9508
|
-
|
|
9570
|
+
if (optionsOrPropertyKey?.filter) {
|
|
9571
|
+
resolvedElements = resolvedElements.filter((el) => {
|
|
9572
|
+
if (!(el instanceof win.HTMLElement))
|
|
9573
|
+
return true;
|
|
9574
|
+
return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
|
|
9575
|
+
});
|
|
9576
|
+
}
|
|
9577
|
+
return resolvedElements;
|
|
9509
9578
|
},
|
|
9510
9579
|
set(nv) {
|
|
9511
9580
|
ensureInit(this);
|
|
9512
9581
|
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
9513
|
-
const
|
|
9514
|
-
|
|
9582
|
+
const config = getElementConfig(this);
|
|
9583
|
+
const win = config?.window || window;
|
|
9584
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9585
|
+
if (typeof selectorOrTarget === "function") {
|
|
9586
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9587
|
+
if (result instanceof win.NodeList) {
|
|
9588
|
+
Array.from(result).forEach((el) => {
|
|
9589
|
+
if (el instanceof win.Element)
|
|
9590
|
+
el.remove();
|
|
9591
|
+
});
|
|
9592
|
+
} else if (Array.isArray(result)) {
|
|
9593
|
+
result.forEach((el) => {
|
|
9594
|
+
if (el instanceof win.Element)
|
|
9595
|
+
el.remove();
|
|
9596
|
+
});
|
|
9597
|
+
}
|
|
9598
|
+
return;
|
|
9599
|
+
}
|
|
9600
|
+
const resolvedSelector = selectorOrTarget;
|
|
9601
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
9515
9602
|
return;
|
|
9516
9603
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
9517
9604
|
let targets = [];
|
|
9518
9605
|
if (r === "shadow")
|
|
9519
|
-
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
9606
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9520
9607
|
else if (r === "light")
|
|
9521
|
-
targets = Array.from(this.querySelectorAll(
|
|
9608
|
+
targets = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9522
9609
|
else if (r === "all") {
|
|
9523
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
9524
|
-
const lNodes = Array.from(this.querySelectorAll(
|
|
9610
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9611
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9525
9612
|
targets = [...sNodes, ...lNodes];
|
|
9526
9613
|
} else {
|
|
9527
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(
|
|
9614
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
9528
9615
|
}
|
|
9529
9616
|
targets.forEach((t) => t.remove());
|
|
9530
9617
|
}
|
|
@@ -9724,6 +9811,27 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9724
9811
|
const currentWin = conf.window;
|
|
9725
9812
|
const r = options.root || "auto";
|
|
9726
9813
|
const results = [];
|
|
9814
|
+
let resolvedSelector = selector;
|
|
9815
|
+
if (typeof selector === "function") {
|
|
9816
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
9817
|
+
resolvedSelector = selector(inst, hostSet);
|
|
9818
|
+
}
|
|
9819
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
9820
|
+
results.push(resolvedSelector);
|
|
9821
|
+
return results;
|
|
9822
|
+
}
|
|
9823
|
+
if (resolvedSelector instanceof currentWin.NodeList) {
|
|
9824
|
+
results.push(...Array.from(resolvedSelector));
|
|
9825
|
+
return results;
|
|
9826
|
+
}
|
|
9827
|
+
if (Array.isArray(resolvedSelector)) {
|
|
9828
|
+
results.push(...resolvedSelector);
|
|
9829
|
+
return results;
|
|
9830
|
+
}
|
|
9831
|
+
if (resolvedSelector === null) {
|
|
9832
|
+
return results;
|
|
9833
|
+
}
|
|
9834
|
+
const stringSelector = resolvedSelector;
|
|
9727
9835
|
const applyRoot = (target) => {
|
|
9728
9836
|
if (!target) return;
|
|
9729
9837
|
if (r === "auto") {
|
|
@@ -9733,37 +9841,37 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9733
9841
|
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
9734
9842
|
}
|
|
9735
9843
|
};
|
|
9736
|
-
if (
|
|
9844
|
+
if (stringSelector === "$this" || !stringSelector) {
|
|
9737
9845
|
applyRoot(inst);
|
|
9738
|
-
} else if (
|
|
9846
|
+
} else if (stringSelector === "$window") {
|
|
9739
9847
|
results.push(currentWin);
|
|
9740
|
-
} else if (
|
|
9848
|
+
} else if (stringSelector === "$document") {
|
|
9741
9849
|
results.push(currentWin.document);
|
|
9742
9850
|
} else {
|
|
9743
9851
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
9744
|
-
if (
|
|
9745
|
-
else if (
|
|
9746
|
-
else if (
|
|
9747
|
-
else if (
|
|
9748
|
-
else if (
|
|
9749
|
-
else if (
|
|
9750
|
-
else if (
|
|
9751
|
-
else if (
|
|
9752
|
-
else if (
|
|
9852
|
+
if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
9853
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
9854
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
9855
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
9856
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
9857
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
9858
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
9859
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
9860
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
9753
9861
|
else {
|
|
9754
9862
|
if (r === "shadow") {
|
|
9755
|
-
const found = inst.shadowRoot?.querySelectorAll(
|
|
9863
|
+
const found = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
9756
9864
|
if (found) results.push(...found);
|
|
9757
9865
|
} else if (r === "light") {
|
|
9758
|
-
const found = inst.querySelectorAll(
|
|
9866
|
+
const found = inst.querySelectorAll(stringSelector);
|
|
9759
9867
|
if (found) results.push(...found);
|
|
9760
9868
|
} else if (r === "all") {
|
|
9761
|
-
const sMatch = inst.shadowRoot?.querySelectorAll(
|
|
9762
|
-
const lMatch = inst.querySelectorAll(
|
|
9869
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
9870
|
+
const lMatch = inst.querySelectorAll(stringSelector);
|
|
9763
9871
|
if (sMatch) results.push(...sMatch);
|
|
9764
9872
|
if (lMatch) results.push(...lMatch);
|
|
9765
9873
|
} else {
|
|
9766
|
-
const found = (inst.shadowRoot || inst).querySelectorAll(
|
|
9874
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
|
|
9767
9875
|
if (found) results.push(...found);
|
|
9768
9876
|
}
|
|
9769
9877
|
}
|
|
@@ -10188,7 +10296,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10188
10296
|
const delegateListeners = [];
|
|
10189
10297
|
const nonDelegateListeners = [];
|
|
10190
10298
|
addEventListenerList.forEach((meta) => {
|
|
10191
|
-
|
|
10299
|
+
const isStringSelector = typeof meta.selector === "string";
|
|
10300
|
+
if (meta.options.delegate && isStringSelector && meta.selector !== "$window" && meta.selector !== "$document" && meta.selector !== "$host" && meta.selector !== "$appHost" && meta.selector !== "$firstHost" && meta.selector !== "$lastHost" && meta.selector !== "$firstAppHost" && meta.selector !== "$lastAppHost" && meta.selector !== "$hosts" && meta.selector !== "$appHosts" && meta.selector !== "$this" && meta.selector !== "") {
|
|
10192
10301
|
delegateListeners.push(meta);
|
|
10193
10302
|
} else {
|
|
10194
10303
|
nonDelegateListeners.push(meta);
|
|
@@ -10251,6 +10360,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10251
10360
|
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
10252
10361
|
const bindTargets = [];
|
|
10253
10362
|
const r = options.root || "auto";
|
|
10363
|
+
let resolvedSelector = null;
|
|
10364
|
+
if (typeof selector === "function") {
|
|
10365
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
10366
|
+
const result = selector(this, hostSet);
|
|
10367
|
+
if (typeof result === "string") {
|
|
10368
|
+
resolvedSelector = result;
|
|
10369
|
+
} else if (result instanceof currentWin.Element) {
|
|
10370
|
+
bindTargets.push(result);
|
|
10371
|
+
} else if (result instanceof currentWin.NodeList) {
|
|
10372
|
+
bindTargets.push(...Array.from(result));
|
|
10373
|
+
} else if (Array.isArray(result)) {
|
|
10374
|
+
bindTargets.push(...result);
|
|
10375
|
+
}
|
|
10376
|
+
} else {
|
|
10377
|
+
resolvedSelector = selector;
|
|
10378
|
+
}
|
|
10254
10379
|
const applyRootOption = (target) => {
|
|
10255
10380
|
if (!target) return;
|
|
10256
10381
|
if (r === "auto") {
|
|
@@ -10260,30 +10385,32 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10260
10385
|
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
10261
10386
|
}
|
|
10262
10387
|
};
|
|
10263
|
-
if (
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10388
|
+
if (resolvedSelector) {
|
|
10389
|
+
if (resolvedSelector === "$window") bindTargets.push(currentWin);
|
|
10390
|
+
else if (resolvedSelector === "$document") bindTargets.push(currentWin.document);
|
|
10391
|
+
else if (resolvedSelector === "$host") applyRootOption(helperHostSet.$host);
|
|
10392
|
+
else if (resolvedSelector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
|
|
10393
|
+
else if (resolvedSelector === "$appHost") applyRootOption(helperHostSet.$appHost);
|
|
10394
|
+
else if (resolvedSelector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
|
|
10395
|
+
else if (resolvedSelector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
|
|
10396
|
+
else if (resolvedSelector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
|
|
10397
|
+
else if (resolvedSelector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
|
|
10398
|
+
else if (resolvedSelector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
|
|
10399
|
+
else if (resolvedSelector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
|
|
10400
|
+
else if (resolvedSelector === "$this" || !resolvedSelector) applyRootOption(this);
|
|
10401
|
+
else {
|
|
10402
|
+
const searchRoots = [];
|
|
10403
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
10404
|
+
else if (r === "light") searchRoots.push(this);
|
|
10405
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
10406
|
+
else if (r === "all") {
|
|
10407
|
+
searchRoots.push(this);
|
|
10408
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
10409
|
+
}
|
|
10410
|
+
searchRoots.forEach((sr) => {
|
|
10411
|
+
sr.querySelectorAll(resolvedSelector).forEach((el) => bindTargets.push(el));
|
|
10412
|
+
});
|
|
10283
10413
|
}
|
|
10284
|
-
searchRoots.forEach((sr) => {
|
|
10285
|
-
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
10286
|
-
});
|
|
10287
10414
|
}
|
|
10288
10415
|
bindTargets.forEach((t) => {
|
|
10289
10416
|
const handler = async (event2) => {
|
|
@@ -10298,7 +10425,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10298
10425
|
if (options.preventDefault) event2.preventDefault();
|
|
10299
10426
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
10300
10427
|
const args = { event: event2, ...currentHostSet, $el: t, $root: t };
|
|
10301
|
-
await this[meta.propertyKey](event2, { currentHostSet,
|
|
10428
|
+
await this[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, args);
|
|
10302
10429
|
};
|
|
10303
10430
|
const eventSubject = new Subject();
|
|
10304
10431
|
let eventStream = eventSubject;
|
|
@@ -10497,6 +10624,27 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10497
10624
|
const currentWin = conf.window;
|
|
10498
10625
|
const r = options.root || "auto";
|
|
10499
10626
|
const results = [];
|
|
10627
|
+
let resolvedSelector = selector;
|
|
10628
|
+
if (typeof selector === "function") {
|
|
10629
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
10630
|
+
resolvedSelector = selector(inst, hostSet);
|
|
10631
|
+
}
|
|
10632
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
10633
|
+
results.push(resolvedSelector);
|
|
10634
|
+
return results;
|
|
10635
|
+
}
|
|
10636
|
+
if (resolvedSelector instanceof currentWin.NodeList) {
|
|
10637
|
+
results.push(...Array.from(resolvedSelector));
|
|
10638
|
+
return results;
|
|
10639
|
+
}
|
|
10640
|
+
if (Array.isArray(resolvedSelector)) {
|
|
10641
|
+
results.push(...resolvedSelector);
|
|
10642
|
+
return results;
|
|
10643
|
+
}
|
|
10644
|
+
if (resolvedSelector === null) {
|
|
10645
|
+
return results;
|
|
10646
|
+
}
|
|
10647
|
+
const stringSelector = resolvedSelector;
|
|
10500
10648
|
const applyRoot = (target) => {
|
|
10501
10649
|
if (!target) return;
|
|
10502
10650
|
if (r === "auto") {
|
|
@@ -10506,33 +10654,33 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10506
10654
|
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
10507
10655
|
}
|
|
10508
10656
|
};
|
|
10509
|
-
if (
|
|
10657
|
+
if (stringSelector === "$this" || !stringSelector) {
|
|
10510
10658
|
applyRoot(inst);
|
|
10511
10659
|
} else {
|
|
10512
10660
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
10513
|
-
if (
|
|
10514
|
-
else if (
|
|
10515
|
-
else if (
|
|
10516
|
-
else if (
|
|
10517
|
-
else if (
|
|
10518
|
-
else if (
|
|
10519
|
-
else if (
|
|
10520
|
-
else if (
|
|
10521
|
-
else if (
|
|
10661
|
+
if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
10662
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10663
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10664
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10665
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10666
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10667
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10668
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10669
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10522
10670
|
else {
|
|
10523
10671
|
if (r === "shadow") {
|
|
10524
|
-
const found = inst.shadowRoot?.querySelectorAll(
|
|
10672
|
+
const found = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
10525
10673
|
if (found) results.push(...found);
|
|
10526
10674
|
} else if (r === "light") {
|
|
10527
|
-
const found = inst.querySelectorAll(
|
|
10675
|
+
const found = inst.querySelectorAll(stringSelector);
|
|
10528
10676
|
if (found) results.push(...found);
|
|
10529
10677
|
} else if (r === "all") {
|
|
10530
|
-
const sMatch = inst.shadowRoot?.querySelectorAll(
|
|
10531
|
-
const lMatch = inst.querySelectorAll(
|
|
10678
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
10679
|
+
const lMatch = inst.querySelectorAll(stringSelector);
|
|
10532
10680
|
if (sMatch) results.push(...sMatch);
|
|
10533
10681
|
if (lMatch) results.push(...lMatch);
|
|
10534
10682
|
} else {
|
|
10535
|
-
const found = (inst.shadowRoot || inst).querySelectorAll(
|
|
10683
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
|
|
10536
10684
|
if (found) results.push(...found);
|
|
10537
10685
|
}
|
|
10538
10686
|
}
|
|
@@ -10671,6 +10819,26 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10671
10819
|
|
|
10672
10820
|
// src/decorators/applyNode.ts
|
|
10673
10821
|
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
10822
|
+
var resolveSelector = (selector, inst, win) => {
|
|
10823
|
+
if (typeof selector === "function") {
|
|
10824
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
10825
|
+
const result = selector(inst, hostSet);
|
|
10826
|
+
if (result instanceof win.Element) {
|
|
10827
|
+
return result;
|
|
10828
|
+
}
|
|
10829
|
+
if (result instanceof win.NodeList) {
|
|
10830
|
+
return result.length > 0 ? result[0] : null;
|
|
10831
|
+
}
|
|
10832
|
+
if (Array.isArray(result)) {
|
|
10833
|
+
return result.length > 0 ? result[0] : null;
|
|
10834
|
+
}
|
|
10835
|
+
if (result === null) {
|
|
10836
|
+
return null;
|
|
10837
|
+
}
|
|
10838
|
+
return result;
|
|
10839
|
+
}
|
|
10840
|
+
return selector;
|
|
10841
|
+
};
|
|
10674
10842
|
var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
10675
10843
|
if (!targetEl) return;
|
|
10676
10844
|
if (pos === "clearChildren") {
|
|
@@ -10715,7 +10883,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10715
10883
|
function applyNode(selectorOrOptions, maybeOptions) {
|
|
10716
10884
|
let selector;
|
|
10717
10885
|
let options;
|
|
10718
|
-
if (typeof selectorOrOptions === "string") {
|
|
10886
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10719
10887
|
selector = selectorOrOptions;
|
|
10720
10888
|
options = maybeOptions || { position: "replaceChildren" };
|
|
10721
10889
|
} else {
|
|
@@ -10747,14 +10915,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10747
10915
|
if (r === "all") return t.shadowRoot || t;
|
|
10748
10916
|
return t;
|
|
10749
10917
|
};
|
|
10750
|
-
|
|
10751
|
-
if (
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
if (
|
|
10755
|
-
|
|
10918
|
+
const resolved = resolveSelector(selector, this, currentWin);
|
|
10919
|
+
if (resolved instanceof currentWin.Element) {
|
|
10920
|
+
return applyRoot(resolved);
|
|
10921
|
+
}
|
|
10922
|
+
if (resolved === null) {
|
|
10923
|
+
return null;
|
|
10924
|
+
}
|
|
10925
|
+
const stringSelector = resolved;
|
|
10926
|
+
if (stringSelector === "$this") return applyRoot(this);
|
|
10927
|
+
if (stringSelector === "$host") return applyRoot(hostSet.$host);
|
|
10928
|
+
if (stringSelector === "$parentHost") return applyRoot(hostSet.$parentHost);
|
|
10929
|
+
if (stringSelector === "$appHost") return applyRoot(hostSet.$appHost);
|
|
10930
|
+
if (stringSelector === "$firstHost") return applyRoot(hostSet.$firstHost);
|
|
10931
|
+
if (stringSelector === "$lastHost") return applyRoot(hostSet.$lastHost);
|
|
10756
10932
|
const targetRoot = applyRoot(this);
|
|
10757
|
-
return targetRoot ? targetRoot.querySelector(
|
|
10933
|
+
return targetRoot ? targetRoot.querySelector(stringSelector) : null;
|
|
10758
10934
|
};
|
|
10759
10935
|
const targetEl = getTarget();
|
|
10760
10936
|
const res = original.apply(this, args);
|
|
@@ -10796,7 +10972,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10796
10972
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10797
10973
|
return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10798
10974
|
}
|
|
10799
|
-
if (typeof selectorOrOptions === "string") {
|
|
10975
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10800
10976
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
|
|
10801
10977
|
}
|
|
10802
10978
|
return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
|
|
@@ -10805,7 +10981,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10805
10981
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10806
10982
|
return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10807
10983
|
}
|
|
10808
|
-
if (typeof selectorOrOptions === "string") {
|
|
10984
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10809
10985
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
|
|
10810
10986
|
}
|
|
10811
10987
|
return applyNode({ ...selectorOrOptions, position: "clearChildren" });
|
|
@@ -10815,7 +10991,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10815
10991
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10816
10992
|
return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10817
10993
|
}
|
|
10818
|
-
if (typeof selectorOrOptions === "string") {
|
|
10994
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10819
10995
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
|
|
10820
10996
|
}
|
|
10821
10997
|
return applyNode({ ...selectorOrOptions, position: "innerHtml" });
|
|
@@ -10824,7 +11000,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10824
11000
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10825
11001
|
return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10826
11002
|
}
|
|
10827
|
-
if (typeof selectorOrOptions === "string") {
|
|
11003
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10828
11004
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
|
|
10829
11005
|
}
|
|
10830
11006
|
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
|
|
@@ -10833,7 +11009,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10833
11009
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10834
11010
|
return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10835
11011
|
}
|
|
10836
|
-
if (typeof selectorOrOptions === "string") {
|
|
11012
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10837
11013
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
|
|
10838
11014
|
}
|
|
10839
11015
|
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
|
|
@@ -10842,7 +11018,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10842
11018
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10843
11019
|
return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10844
11020
|
}
|
|
10845
|
-
if (typeof selectorOrOptions === "string") {
|
|
11021
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10846
11022
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
|
|
10847
11023
|
}
|
|
10848
11024
|
return applyNode({ ...selectorOrOptions, position: "innerText" });
|
|
@@ -10851,7 +11027,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10851
11027
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10852
11028
|
return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10853
11029
|
}
|
|
10854
|
-
if (typeof selectorOrOptions === "string") {
|
|
11030
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10855
11031
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
|
|
10856
11032
|
}
|
|
10857
11033
|
return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
|
|
@@ -10860,7 +11036,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10860
11036
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10861
11037
|
return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10862
11038
|
}
|
|
10863
|
-
if (typeof selectorOrOptions === "string") {
|
|
11039
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10864
11040
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
|
|
10865
11041
|
}
|
|
10866
11042
|
return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
|
|
@@ -10869,7 +11045,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10869
11045
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10870
11046
|
return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10871
11047
|
}
|
|
10872
|
-
if (typeof selectorOrOptions === "string") {
|
|
11048
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10873
11049
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
|
|
10874
11050
|
}
|
|
10875
11051
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
|
|
@@ -10878,7 +11054,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10878
11054
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10879
11055
|
return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10880
11056
|
}
|
|
10881
|
-
if (typeof selectorOrOptions === "string") {
|
|
11057
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10882
11058
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
|
|
10883
11059
|
}
|
|
10884
11060
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
|
|
@@ -10887,7 +11063,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10887
11063
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10888
11064
|
return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10889
11065
|
}
|
|
10890
|
-
if (typeof selectorOrOptions === "string") {
|
|
11066
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10891
11067
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
|
|
10892
11068
|
}
|
|
10893
11069
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
|
|
@@ -10896,7 +11072,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10896
11072
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10897
11073
|
return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10898
11074
|
}
|
|
10899
|
-
if (typeof selectorOrOptions === "string") {
|
|
11075
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10900
11076
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
|
|
10901
11077
|
}
|
|
10902
11078
|
return applyNode({ ...selectorOrOptions, position: "afterBegin" });
|
|
@@ -10905,7 +11081,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10905
11081
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10906
11082
|
return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10907
11083
|
}
|
|
10908
|
-
if (typeof selectorOrOptions === "string") {
|
|
11084
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10909
11085
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
|
|
10910
11086
|
}
|
|
10911
11087
|
return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
|
|
@@ -10914,7 +11090,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10914
11090
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10915
11091
|
return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10916
11092
|
}
|
|
10917
|
-
if (typeof selectorOrOptions === "string") {
|
|
11093
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10918
11094
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
|
|
10919
11095
|
}
|
|
10920
11096
|
return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
|
|
@@ -10923,7 +11099,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10923
11099
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10924
11100
|
return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10925
11101
|
}
|
|
10926
|
-
if (typeof selectorOrOptions === "string") {
|
|
11102
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10927
11103
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
|
|
10928
11104
|
}
|
|
10929
11105
|
return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
|
|
@@ -10941,6 +11117,58 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10941
11117
|
|
|
10942
11118
|
// src/decorators/applyClass.ts
|
|
10943
11119
|
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
11120
|
+
var resolveSelector2 = (selector, inst, win) => {
|
|
11121
|
+
if (typeof selector === "function") {
|
|
11122
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11123
|
+
const result = selector(inst, hostSet);
|
|
11124
|
+
if (result instanceof win.Element) {
|
|
11125
|
+
return [result];
|
|
11126
|
+
}
|
|
11127
|
+
if (result instanceof win.NodeList) {
|
|
11128
|
+
return Array.from(result);
|
|
11129
|
+
}
|
|
11130
|
+
if (Array.isArray(result)) {
|
|
11131
|
+
return result;
|
|
11132
|
+
}
|
|
11133
|
+
if (result === null) {
|
|
11134
|
+
return [];
|
|
11135
|
+
}
|
|
11136
|
+
return result;
|
|
11137
|
+
}
|
|
11138
|
+
return selector;
|
|
11139
|
+
};
|
|
11140
|
+
var getTargetElements = (selector, inst, win, root) => {
|
|
11141
|
+
const resolved = resolveSelector2(selector, inst, win);
|
|
11142
|
+
if (Array.isArray(resolved)) {
|
|
11143
|
+
return resolved;
|
|
11144
|
+
}
|
|
11145
|
+
const stringSelector = resolved;
|
|
11146
|
+
const targetEls = [];
|
|
11147
|
+
const host = inst;
|
|
11148
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11149
|
+
const applyRoot = (t) => {
|
|
11150
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
11151
|
+
targetEls.push(t);
|
|
11152
|
+
};
|
|
11153
|
+
if (stringSelector === "$this" || !stringSelector) applyRoot(host);
|
|
11154
|
+
else if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
11155
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
11156
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
11157
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
11158
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
11159
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
11160
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
11161
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
11162
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
11163
|
+
else {
|
|
11164
|
+
const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
|
|
11165
|
+
if (targetRoot) {
|
|
11166
|
+
const found = targetRoot.querySelectorAll(stringSelector);
|
|
11167
|
+
if (found) targetEls.push(...Array.from(found));
|
|
11168
|
+
}
|
|
11169
|
+
}
|
|
11170
|
+
return targetEls;
|
|
11171
|
+
};
|
|
10944
11172
|
function createClassDecorator(action) {
|
|
10945
11173
|
return (selector, classMapOrOptions, options = {}) => {
|
|
10946
11174
|
return (target, propertyKey, descriptor) => {
|
|
@@ -10975,28 +11203,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10975
11203
|
const host = this;
|
|
10976
11204
|
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
10977
11205
|
const r = finalOptions.root || "auto";
|
|
10978
|
-
const targetEls =
|
|
10979
|
-
const applyRoot = (t) => {
|
|
10980
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
10981
|
-
targetEls.push(t);
|
|
10982
|
-
};
|
|
10983
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
10984
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
10985
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10986
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10987
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10988
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10989
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10990
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10991
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10992
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10993
|
-
else {
|
|
10994
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
10995
|
-
if (targetRoot) {
|
|
10996
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
10997
|
-
if (found) targetEls.push(...Array.from(found));
|
|
10998
|
-
}
|
|
10999
|
-
}
|
|
11206
|
+
const targetEls = getTargetElements(selector, this, win, r);
|
|
11000
11207
|
targetEls.forEach((targetEl) => {
|
|
11001
11208
|
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
11002
11209
|
return;
|
|
@@ -11128,6 +11335,58 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
11128
11335
|
|
|
11129
11336
|
// src/decorators/applyStyle.ts
|
|
11130
11337
|
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
11338
|
+
var resolveSelector3 = (selector, inst, win) => {
|
|
11339
|
+
if (typeof selector === "function") {
|
|
11340
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11341
|
+
const result = selector(inst, hostSet);
|
|
11342
|
+
if (result instanceof win.Element) {
|
|
11343
|
+
return [result];
|
|
11344
|
+
}
|
|
11345
|
+
if (result instanceof win.NodeList) {
|
|
11346
|
+
return Array.from(result);
|
|
11347
|
+
}
|
|
11348
|
+
if (Array.isArray(result)) {
|
|
11349
|
+
return result;
|
|
11350
|
+
}
|
|
11351
|
+
if (result === null) {
|
|
11352
|
+
return [];
|
|
11353
|
+
}
|
|
11354
|
+
return result;
|
|
11355
|
+
}
|
|
11356
|
+
return selector;
|
|
11357
|
+
};
|
|
11358
|
+
var getTargetElements2 = (selector, inst, win, root) => {
|
|
11359
|
+
const resolved = resolveSelector3(selector, inst, win);
|
|
11360
|
+
if (Array.isArray(resolved)) {
|
|
11361
|
+
return resolved;
|
|
11362
|
+
}
|
|
11363
|
+
const stringSelector = resolved;
|
|
11364
|
+
const targetEls = [];
|
|
11365
|
+
const host = inst;
|
|
11366
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11367
|
+
const applyRoot = (t) => {
|
|
11368
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
11369
|
+
targetEls.push(t);
|
|
11370
|
+
};
|
|
11371
|
+
if (stringSelector === "$this" || !stringSelector) applyRoot(host);
|
|
11372
|
+
else if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
11373
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
11374
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
11375
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
11376
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
11377
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
11378
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
11379
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
11380
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
11381
|
+
else {
|
|
11382
|
+
const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
|
|
11383
|
+
if (targetRoot) {
|
|
11384
|
+
const found = targetRoot.querySelectorAll(stringSelector);
|
|
11385
|
+
if (found) targetEls.push(...Array.from(found));
|
|
11386
|
+
}
|
|
11387
|
+
}
|
|
11388
|
+
return targetEls;
|
|
11389
|
+
};
|
|
11131
11390
|
function createStyleDecorator(action) {
|
|
11132
11391
|
return (selector, options = {}) => {
|
|
11133
11392
|
return (target, propertyKey, descriptor) => {
|
|
@@ -11155,28 +11414,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
11155
11414
|
const host = this;
|
|
11156
11415
|
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
11157
11416
|
const r = options.root || "auto";
|
|
11158
|
-
const targetEls =
|
|
11159
|
-
const applyRoot = (t) => {
|
|
11160
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
11161
|
-
targetEls.push(t);
|
|
11162
|
-
};
|
|
11163
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
11164
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
11165
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
11166
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
11167
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
11168
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
11169
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
11170
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
11171
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
11172
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
11173
|
-
else {
|
|
11174
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
11175
|
-
if (targetRoot) {
|
|
11176
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
11177
|
-
if (found) targetEls.push(...Array.from(found));
|
|
11178
|
-
}
|
|
11179
|
-
}
|
|
11417
|
+
const targetEls = getTargetElements2(selector, this, win, r);
|
|
11180
11418
|
targetEls.forEach((targetEl) => {
|
|
11181
11419
|
if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
11182
11420
|
return;
|