@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
|
@@ -8953,7 +8953,7 @@ function emitCustomEvent(selectorOrTarget, typeOrPropertyKey, optionsOrDescripto
|
|
|
8953
8953
|
if (typeof selectorOrTarget === "object" && typeof typeOrPropertyKey === "string" && typeof optionsOrDescriptor === "object" && "value" in optionsOrDescriptor) {
|
|
8954
8954
|
throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);
|
|
8955
8955
|
}
|
|
8956
|
-
if (typeof selectorOrTarget === "string" && typeof typeOrPropertyKey === "string") {
|
|
8956
|
+
if ((typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") && typeof typeOrPropertyKey === "string") {
|
|
8957
8957
|
return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor);
|
|
8958
8958
|
}
|
|
8959
8959
|
if (typeof selectorOrTarget === "string" && typeOrPropertyKey !== "string") {
|
|
@@ -8986,58 +8986,72 @@ function createEmitDecorator(selector, type, options) {
|
|
|
8986
8986
|
composed: fullOptions.composed,
|
|
8987
8987
|
cancelable: fullOptions.cancelable
|
|
8988
8988
|
});
|
|
8989
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
8990
8989
|
const conf = getElementConfig(this);
|
|
8991
8990
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
8991
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
8992
8992
|
const eventTargets = [];
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
} else if (
|
|
9004
|
-
if (hostSet.$appHost)
|
|
9005
|
-
eventTargets.push(hostSet.$appHost);
|
|
9006
|
-
} else if (selector === "$firstHost") {
|
|
9007
|
-
if (hostSet.$firstHost)
|
|
9008
|
-
eventTargets.push(hostSet.$firstHost);
|
|
9009
|
-
} else if (selector === "$lastHost") {
|
|
9010
|
-
if (hostSet.$lastHost)
|
|
9011
|
-
eventTargets.push(hostSet.$lastHost);
|
|
9012
|
-
} else if (selector === "$firstAppHost") {
|
|
9013
|
-
if (hostSet.$firstAppHost)
|
|
9014
|
-
eventTargets.push(hostSet.$firstAppHost);
|
|
9015
|
-
} else if (selector === "$lastAppHost") {
|
|
9016
|
-
if (hostSet.$lastAppHost)
|
|
9017
|
-
eventTargets.push(hostSet.$lastAppHost);
|
|
9018
|
-
} else if (selector === "$hosts") {
|
|
9019
|
-
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
9020
|
-
} else if (selector === "$appHosts") {
|
|
9021
|
-
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
9022
|
-
} else if (selector === "$this" || !selector) {
|
|
9023
|
-
eventTargets.push(this);
|
|
8993
|
+
let resolvedSelector = selector;
|
|
8994
|
+
if (typeof selector === "function") {
|
|
8995
|
+
resolvedSelector = selector(this, hostSet);
|
|
8996
|
+
}
|
|
8997
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
8998
|
+
eventTargets.push(resolvedSelector);
|
|
8999
|
+
} else if (resolvedSelector instanceof currentWin.NodeList) {
|
|
9000
|
+
eventTargets.push(...Array.from(resolvedSelector));
|
|
9001
|
+
} else if (Array.isArray(resolvedSelector)) {
|
|
9002
|
+
eventTargets.push(...resolvedSelector);
|
|
9003
|
+
} else if (resolvedSelector === null) {
|
|
9024
9004
|
} else {
|
|
9025
|
-
const
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
else if (
|
|
9034
|
-
|
|
9035
|
-
|
|
9005
|
+
const stringSelector = resolvedSelector;
|
|
9006
|
+
if (stringSelector === "$window")
|
|
9007
|
+
eventTargets.push(currentWin);
|
|
9008
|
+
else if (stringSelector === "$document")
|
|
9009
|
+
eventTargets.push(currentWin.document);
|
|
9010
|
+
else if (stringSelector === "$host") {
|
|
9011
|
+
if (hostSet.$host)
|
|
9012
|
+
eventTargets.push(hostSet.$host);
|
|
9013
|
+
} else if (stringSelector === "$parentHost") {
|
|
9014
|
+
if (hostSet.$parentHost)
|
|
9015
|
+
eventTargets.push(hostSet.$parentHost);
|
|
9016
|
+
} else if (stringSelector === "$appHost") {
|
|
9017
|
+
if (hostSet.$appHost)
|
|
9018
|
+
eventTargets.push(hostSet.$appHost);
|
|
9019
|
+
} else if (stringSelector === "$firstHost") {
|
|
9020
|
+
if (hostSet.$firstHost)
|
|
9021
|
+
eventTargets.push(hostSet.$firstHost);
|
|
9022
|
+
} else if (stringSelector === "$lastHost") {
|
|
9023
|
+
if (hostSet.$lastHost)
|
|
9024
|
+
eventTargets.push(hostSet.$lastHost);
|
|
9025
|
+
} else if (stringSelector === "$firstAppHost") {
|
|
9026
|
+
if (hostSet.$firstAppHost)
|
|
9027
|
+
eventTargets.push(hostSet.$firstAppHost);
|
|
9028
|
+
} else if (stringSelector === "$lastAppHost") {
|
|
9029
|
+
if (hostSet.$lastAppHost)
|
|
9030
|
+
eventTargets.push(hostSet.$lastAppHost);
|
|
9031
|
+
} else if (stringSelector === "$hosts") {
|
|
9032
|
+
hostSet.$hosts.forEach((h) => eventTargets.push(h));
|
|
9033
|
+
} else if (stringSelector === "$appHosts") {
|
|
9034
|
+
hostSet.$appHosts.forEach((h) => eventTargets.push(h));
|
|
9035
|
+
} else if (stringSelector === "$this" || !stringSelector) {
|
|
9036
|
+
eventTargets.push(this);
|
|
9037
|
+
} else {
|
|
9038
|
+
const r = fullOptions.root || "auto";
|
|
9039
|
+
const searchRoots = [];
|
|
9040
|
+
if (r === "auto")
|
|
9041
|
+
searchRoots.push(this.shadowRoot || this);
|
|
9042
|
+
else if (r === "light")
|
|
9043
|
+
searchRoots.push(this);
|
|
9044
|
+
else if (r === "shadow" && this.shadowRoot)
|
|
9036
9045
|
searchRoots.push(this.shadowRoot);
|
|
9046
|
+
else if (r === "all") {
|
|
9047
|
+
searchRoots.push(this);
|
|
9048
|
+
if (this.shadowRoot)
|
|
9049
|
+
searchRoots.push(this.shadowRoot);
|
|
9050
|
+
}
|
|
9051
|
+
searchRoots.forEach((sr) => {
|
|
9052
|
+
sr.querySelectorAll(stringSelector).forEach((el) => eventTargets.push(el));
|
|
9053
|
+
});
|
|
9037
9054
|
}
|
|
9038
|
-
searchRoots.forEach((sr) => {
|
|
9039
|
-
sr.querySelectorAll(selector).forEach((el) => eventTargets.push(el));
|
|
9040
|
-
});
|
|
9041
9055
|
}
|
|
9042
9056
|
eventTargets.forEach((t) => {
|
|
9043
9057
|
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
@@ -9113,7 +9127,7 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
9113
9127
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9114
9128
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9115
9129
|
}
|
|
9116
|
-
if (typeof selectorOrTarget === "string") {
|
|
9130
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
9117
9131
|
return (targetObj, propertyKey, descriptor2) => {
|
|
9118
9132
|
if (descriptor2 !== void 0) {
|
|
9119
9133
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -9128,75 +9142,110 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
9128
9142
|
Object.defineProperty(targetObj, propertyKey, {
|
|
9129
9143
|
get() {
|
|
9130
9144
|
ensureInit(this);
|
|
9131
|
-
const selector = selectorOrTarget;
|
|
9132
|
-
const r = optionsOrPropertyKey?.root || "auto";
|
|
9133
|
-
const applyRoot = (t) => {
|
|
9134
|
-
if (!t || !(t instanceof HTMLElement))
|
|
9135
|
-
return t;
|
|
9136
|
-
if (r === "auto")
|
|
9137
|
-
return t.shadowRoot || t;
|
|
9138
|
-
if (r === "shadow")
|
|
9139
|
-
return t.shadowRoot;
|
|
9140
|
-
if (r === "light")
|
|
9141
|
-
return t;
|
|
9142
|
-
if (r === "all")
|
|
9143
|
-
return t.shadowRoot || t;
|
|
9144
|
-
return t;
|
|
9145
|
-
};
|
|
9146
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9147
|
-
if (selector === "$this")
|
|
9148
|
-
return applyRoot(this);
|
|
9149
|
-
if (selector === "$host")
|
|
9150
|
-
return applyRoot(hostSet.$host);
|
|
9151
|
-
if (selector === "$parentHost")
|
|
9152
|
-
return applyRoot(hostSet.$parentHost);
|
|
9153
|
-
if (selector === "$appHost")
|
|
9154
|
-
return applyRoot(hostSet.$appHost);
|
|
9155
|
-
if (selector === "$firstHost")
|
|
9156
|
-
return applyRoot(hostSet.$firstHost);
|
|
9157
|
-
if (selector === "$lastHost")
|
|
9158
|
-
return applyRoot(hostSet.$lastHost);
|
|
9159
|
-
if (selector === "$firstAppHost")
|
|
9160
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
9161
|
-
if (selector === "$lastAppHost")
|
|
9162
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
9163
9145
|
const config = getElementConfig(this);
|
|
9164
9146
|
const win = config?.window || window;
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9147
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9148
|
+
let resolvedSelector;
|
|
9149
|
+
let resolvedElement = null;
|
|
9150
|
+
if (typeof selectorOrTarget === "function") {
|
|
9151
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9152
|
+
if (result instanceof win.Node || result instanceof win.Element) {
|
|
9153
|
+
resolvedElement = result instanceof win.HTMLElement ? result : null;
|
|
9154
|
+
} else if (result instanceof win.NodeList || Array.isArray(result)) {
|
|
9155
|
+
resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
|
|
9156
|
+
}
|
|
9157
|
+
} else {
|
|
9158
|
+
resolvedSelector = selectorOrTarget;
|
|
9159
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9160
|
+
const applyRoot = (t) => {
|
|
9161
|
+
if (!t || !(t instanceof HTMLElement))
|
|
9162
|
+
return t;
|
|
9163
|
+
if (r === "auto")
|
|
9164
|
+
return t.shadowRoot || t;
|
|
9165
|
+
if (r === "shadow")
|
|
9166
|
+
return t.shadowRoot;
|
|
9167
|
+
if (r === "light")
|
|
9168
|
+
return t;
|
|
9169
|
+
if (r === "all")
|
|
9170
|
+
return t.shadowRoot || t;
|
|
9171
|
+
return t;
|
|
9172
|
+
};
|
|
9173
|
+
if (resolvedSelector === "$this")
|
|
9174
|
+
resolvedElement = applyRoot(this);
|
|
9175
|
+
else if (resolvedSelector === "$host")
|
|
9176
|
+
resolvedElement = applyRoot(hostSet.$host);
|
|
9177
|
+
else if (resolvedSelector === "$parentHost")
|
|
9178
|
+
resolvedElement = applyRoot(hostSet.$parentHost);
|
|
9179
|
+
else if (resolvedSelector === "$appHost")
|
|
9180
|
+
resolvedElement = applyRoot(hostSet.$appHost);
|
|
9181
|
+
else if (resolvedSelector === "$firstHost")
|
|
9182
|
+
resolvedElement = applyRoot(hostSet.$firstHost);
|
|
9183
|
+
else if (resolvedSelector === "$lastHost")
|
|
9184
|
+
resolvedElement = applyRoot(hostSet.$lastHost);
|
|
9185
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
9186
|
+
resolvedElement = applyRoot(hostSet.$firstAppHost);
|
|
9187
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
9188
|
+
resolvedElement = applyRoot(hostSet.$lastAppHost);
|
|
9189
|
+
else if (resolvedSelector === "$window")
|
|
9190
|
+
return win;
|
|
9191
|
+
else if (resolvedSelector === "$document")
|
|
9192
|
+
return win.document;
|
|
9193
|
+
else {
|
|
9194
|
+
if (r === "shadow")
|
|
9195
|
+
resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
|
|
9196
|
+
else if (r === "light")
|
|
9197
|
+
resolvedElement = this.querySelector(resolvedSelector);
|
|
9198
|
+
else if (r === "all") {
|
|
9199
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
|
|
9200
|
+
resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
|
|
9201
|
+
} else
|
|
9202
|
+
resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
|
|
9203
|
+
}
|
|
9204
|
+
}
|
|
9205
|
+
if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
|
|
9206
|
+
const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
|
|
9207
|
+
if (!shouldInclude) {
|
|
9208
|
+
return null;
|
|
9209
|
+
}
|
|
9176
9210
|
}
|
|
9177
|
-
return
|
|
9211
|
+
return resolvedElement;
|
|
9178
9212
|
},
|
|
9179
9213
|
set(nv) {
|
|
9180
9214
|
ensureInit(this);
|
|
9181
9215
|
if (nv === null || nv === void 0) {
|
|
9182
|
-
const
|
|
9183
|
-
|
|
9216
|
+
const config = getElementConfig(this);
|
|
9217
|
+
const win = config?.window || window;
|
|
9218
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9219
|
+
if (typeof selectorOrTarget === "function") {
|
|
9220
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9221
|
+
if (result instanceof win.Element) {
|
|
9222
|
+
result.remove();
|
|
9223
|
+
} else if (result instanceof win.NodeList || Array.isArray(result)) {
|
|
9224
|
+
const el = result.length > 0 ? result[0] : null;
|
|
9225
|
+
if (el instanceof win.Element) {
|
|
9226
|
+
el.remove();
|
|
9227
|
+
}
|
|
9228
|
+
}
|
|
9229
|
+
return;
|
|
9230
|
+
}
|
|
9231
|
+
const resolvedSelector = selectorOrTarget;
|
|
9232
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
9184
9233
|
return;
|
|
9185
9234
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
9186
9235
|
const targets = [];
|
|
9187
9236
|
if (r === "shadow") {
|
|
9188
|
-
if (this.shadowRoot?.querySelector(
|
|
9189
|
-
targets.push(this.shadowRoot.querySelector(
|
|
9237
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
9238
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
9190
9239
|
} else if (r === "light") {
|
|
9191
|
-
if (this.querySelector(
|
|
9192
|
-
targets.push(this.querySelector(
|
|
9240
|
+
if (this.querySelector(resolvedSelector))
|
|
9241
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
9193
9242
|
} else if (r === "all") {
|
|
9194
|
-
if (this.shadowRoot?.querySelector(
|
|
9195
|
-
targets.push(this.shadowRoot.querySelector(
|
|
9196
|
-
if (this.querySelector(
|
|
9197
|
-
targets.push(this.querySelector(
|
|
9243
|
+
if (this.shadowRoot?.querySelector(resolvedSelector))
|
|
9244
|
+
targets.push(this.shadowRoot.querySelector(resolvedSelector));
|
|
9245
|
+
if (this.querySelector(resolvedSelector))
|
|
9246
|
+
targets.push(this.querySelector(resolvedSelector));
|
|
9198
9247
|
} else {
|
|
9199
|
-
const el = (this.shadowRoot || this).querySelector(
|
|
9248
|
+
const el = (this.shadowRoot || this).querySelector(resolvedSelector);
|
|
9200
9249
|
if (el)
|
|
9201
9250
|
targets.push(el);
|
|
9202
9251
|
}
|
|
@@ -9221,7 +9270,7 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
9221
9270
|
if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
|
|
9222
9271
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
|
|
9223
9272
|
}
|
|
9224
|
-
if (typeof selectorOrTarget === "string") {
|
|
9273
|
+
if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
|
|
9225
9274
|
return (targetObj, propertyKey, descriptor2) => {
|
|
9226
9275
|
if (descriptor2 !== void 0) {
|
|
9227
9276
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
@@ -9236,86 +9285,124 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
|
|
|
9236
9285
|
Object.defineProperty(targetObj, propertyKey, {
|
|
9237
9286
|
get() {
|
|
9238
9287
|
ensureInit(this);
|
|
9239
|
-
const selector = selectorOrTarget;
|
|
9240
|
-
const r = optionsOrPropertyKey?.root || "auto";
|
|
9241
|
-
const applyRoot = (t) => {
|
|
9242
|
-
if (!t)
|
|
9243
|
-
return [];
|
|
9244
|
-
const items = Array.isArray(t) ? t : [t];
|
|
9245
|
-
const results = [];
|
|
9246
|
-
items.forEach((it) => {
|
|
9247
|
-
if (!(it instanceof HTMLElement)) {
|
|
9248
|
-
results.push(it);
|
|
9249
|
-
return;
|
|
9250
|
-
}
|
|
9251
|
-
if (r === "auto")
|
|
9252
|
-
results.push(it.shadowRoot || it);
|
|
9253
|
-
else {
|
|
9254
|
-
if (r === "light" || r === "all")
|
|
9255
|
-
results.push(it);
|
|
9256
|
-
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9257
|
-
results.push(it.shadowRoot);
|
|
9258
|
-
}
|
|
9259
|
-
});
|
|
9260
|
-
return results;
|
|
9261
|
-
};
|
|
9262
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
9263
|
-
if (selector === "$hosts")
|
|
9264
|
-
return applyRoot(hostSet.$hosts);
|
|
9265
|
-
if (selector === "$appHosts")
|
|
9266
|
-
return applyRoot(hostSet.$appHosts);
|
|
9267
|
-
if (selector === "$host")
|
|
9268
|
-
return applyRoot(hostSet.$host);
|
|
9269
|
-
if (selector === "$parentHost")
|
|
9270
|
-
return applyRoot(hostSet.$parentHost);
|
|
9271
|
-
if (selector === "$appHost")
|
|
9272
|
-
return applyRoot(hostSet.$appHost);
|
|
9273
|
-
if (selector === "$firstHost")
|
|
9274
|
-
return applyRoot(hostSet.$firstHost);
|
|
9275
|
-
if (selector === "$lastHost")
|
|
9276
|
-
return applyRoot(hostSet.$lastHost);
|
|
9277
|
-
if (selector === "$firstAppHost")
|
|
9278
|
-
return applyRoot(hostSet.$firstAppHost);
|
|
9279
|
-
if (selector === "$lastAppHost")
|
|
9280
|
-
return applyRoot(hostSet.$lastAppHost);
|
|
9281
9288
|
const config = getElementConfig(this);
|
|
9282
9289
|
const win = config?.window || window;
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
const
|
|
9296
|
-
|
|
9290
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9291
|
+
let resolvedSelector;
|
|
9292
|
+
let resolvedElements = [];
|
|
9293
|
+
if (typeof selectorOrTarget === "function") {
|
|
9294
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9295
|
+
if (result instanceof win.NodeList) {
|
|
9296
|
+
resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
|
|
9297
|
+
} else if (Array.isArray(result)) {
|
|
9298
|
+
resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
|
|
9299
|
+
}
|
|
9300
|
+
} else {
|
|
9301
|
+
resolvedSelector = selectorOrTarget;
|
|
9302
|
+
const r = optionsOrPropertyKey?.root || "auto";
|
|
9303
|
+
const applyRoot = (t) => {
|
|
9304
|
+
if (!t)
|
|
9305
|
+
return [];
|
|
9306
|
+
const items = Array.isArray(t) ? t : [t];
|
|
9307
|
+
const results = [];
|
|
9308
|
+
items.forEach((it) => {
|
|
9309
|
+
if (!(it instanceof HTMLElement)) {
|
|
9310
|
+
results.push(it);
|
|
9311
|
+
return;
|
|
9312
|
+
}
|
|
9313
|
+
if (r === "auto")
|
|
9314
|
+
results.push(it.shadowRoot || it);
|
|
9315
|
+
else {
|
|
9316
|
+
if (r === "light" || r === "all")
|
|
9317
|
+
results.push(it);
|
|
9318
|
+
if ((r === "shadow" || r === "all") && it.shadowRoot)
|
|
9319
|
+
results.push(it.shadowRoot);
|
|
9320
|
+
}
|
|
9321
|
+
});
|
|
9322
|
+
return results;
|
|
9323
|
+
};
|
|
9324
|
+
if (resolvedSelector === "$hosts")
|
|
9325
|
+
resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
|
|
9326
|
+
else if (resolvedSelector === "$appHosts")
|
|
9327
|
+
resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
|
|
9328
|
+
else if (resolvedSelector === "$host")
|
|
9329
|
+
resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
|
|
9330
|
+
else if (resolvedSelector === "$parentHost")
|
|
9331
|
+
resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
|
|
9332
|
+
else if (resolvedSelector === "$appHost")
|
|
9333
|
+
resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
|
|
9334
|
+
else if (resolvedSelector === "$firstHost")
|
|
9335
|
+
resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
|
|
9336
|
+
else if (resolvedSelector === "$lastHost")
|
|
9337
|
+
resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
|
|
9338
|
+
else if (resolvedSelector === "$firstAppHost")
|
|
9339
|
+
resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
|
|
9340
|
+
else if (resolvedSelector === "$lastAppHost")
|
|
9341
|
+
resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
|
|
9342
|
+
else if (resolvedSelector === "$window")
|
|
9343
|
+
return [win];
|
|
9344
|
+
else if (resolvedSelector === "$document")
|
|
9345
|
+
return [win.document];
|
|
9346
|
+
else if (resolvedSelector === "$this")
|
|
9347
|
+
resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
|
|
9348
|
+
else {
|
|
9349
|
+
if (r === "shadow")
|
|
9350
|
+
resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9351
|
+
else if (r === "light")
|
|
9352
|
+
resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9353
|
+
else if (r === "all") {
|
|
9354
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9355
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9356
|
+
resolvedElements = [...sNodes, ...lNodes];
|
|
9357
|
+
} else
|
|
9358
|
+
resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
9359
|
+
}
|
|
9297
9360
|
}
|
|
9298
|
-
|
|
9299
|
-
|
|
9361
|
+
if (optionsOrPropertyKey?.filter) {
|
|
9362
|
+
resolvedElements = resolvedElements.filter((el) => {
|
|
9363
|
+
if (!(el instanceof win.HTMLElement))
|
|
9364
|
+
return true;
|
|
9365
|
+
return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
|
|
9366
|
+
});
|
|
9367
|
+
}
|
|
9368
|
+
return resolvedElements;
|
|
9300
9369
|
},
|
|
9301
9370
|
set(nv) {
|
|
9302
9371
|
ensureInit(this);
|
|
9303
9372
|
if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
|
|
9304
|
-
const
|
|
9305
|
-
|
|
9373
|
+
const config = getElementConfig(this);
|
|
9374
|
+
const win = config?.window || window;
|
|
9375
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, this);
|
|
9376
|
+
if (typeof selectorOrTarget === "function") {
|
|
9377
|
+
const result = selectorOrTarget(this, hostSet);
|
|
9378
|
+
if (result instanceof win.NodeList) {
|
|
9379
|
+
Array.from(result).forEach((el) => {
|
|
9380
|
+
if (el instanceof win.Element)
|
|
9381
|
+
el.remove();
|
|
9382
|
+
});
|
|
9383
|
+
} else if (Array.isArray(result)) {
|
|
9384
|
+
result.forEach((el) => {
|
|
9385
|
+
if (el instanceof win.Element)
|
|
9386
|
+
el.remove();
|
|
9387
|
+
});
|
|
9388
|
+
}
|
|
9389
|
+
return;
|
|
9390
|
+
}
|
|
9391
|
+
const resolvedSelector = selectorOrTarget;
|
|
9392
|
+
if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
|
|
9306
9393
|
return;
|
|
9307
9394
|
const r = optionsOrPropertyKey?.root || "auto";
|
|
9308
9395
|
let targets = [];
|
|
9309
9396
|
if (r === "shadow")
|
|
9310
|
-
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
9397
|
+
targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9311
9398
|
else if (r === "light")
|
|
9312
|
-
targets = Array.from(this.querySelectorAll(
|
|
9399
|
+
targets = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9313
9400
|
else if (r === "all") {
|
|
9314
|
-
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(
|
|
9315
|
-
const lNodes = Array.from(this.querySelectorAll(
|
|
9401
|
+
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
|
|
9402
|
+
const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
|
|
9316
9403
|
targets = [...sNodes, ...lNodes];
|
|
9317
9404
|
} else {
|
|
9318
|
-
targets = Array.from((this.shadowRoot || this).querySelectorAll(
|
|
9405
|
+
targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
|
|
9319
9406
|
}
|
|
9320
9407
|
targets.forEach((t) => t.remove());
|
|
9321
9408
|
}
|
|
@@ -9515,6 +9602,27 @@ var resolvePropertyTargets = (inst, selector, options) => {
|
|
|
9515
9602
|
const currentWin = conf.window;
|
|
9516
9603
|
const r = options.root || "auto";
|
|
9517
9604
|
const results = [];
|
|
9605
|
+
let resolvedSelector = selector;
|
|
9606
|
+
if (typeof selector === "function") {
|
|
9607
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
9608
|
+
resolvedSelector = selector(inst, hostSet);
|
|
9609
|
+
}
|
|
9610
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
9611
|
+
results.push(resolvedSelector);
|
|
9612
|
+
return results;
|
|
9613
|
+
}
|
|
9614
|
+
if (resolvedSelector instanceof currentWin.NodeList) {
|
|
9615
|
+
results.push(...Array.from(resolvedSelector));
|
|
9616
|
+
return results;
|
|
9617
|
+
}
|
|
9618
|
+
if (Array.isArray(resolvedSelector)) {
|
|
9619
|
+
results.push(...resolvedSelector);
|
|
9620
|
+
return results;
|
|
9621
|
+
}
|
|
9622
|
+
if (resolvedSelector === null) {
|
|
9623
|
+
return results;
|
|
9624
|
+
}
|
|
9625
|
+
const stringSelector = resolvedSelector;
|
|
9518
9626
|
const applyRoot = (target) => {
|
|
9519
9627
|
if (!target) return;
|
|
9520
9628
|
if (r === "auto") {
|
|
@@ -9524,37 +9632,37 @@ var resolvePropertyTargets = (inst, selector, options) => {
|
|
|
9524
9632
|
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
9525
9633
|
}
|
|
9526
9634
|
};
|
|
9527
|
-
if (
|
|
9635
|
+
if (stringSelector === "$this" || !stringSelector) {
|
|
9528
9636
|
applyRoot(inst);
|
|
9529
|
-
} else if (
|
|
9637
|
+
} else if (stringSelector === "$window") {
|
|
9530
9638
|
results.push(currentWin);
|
|
9531
|
-
} else if (
|
|
9639
|
+
} else if (stringSelector === "$document") {
|
|
9532
9640
|
results.push(currentWin.document);
|
|
9533
9641
|
} else {
|
|
9534
9642
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
9535
|
-
if (
|
|
9536
|
-
else if (
|
|
9537
|
-
else if (
|
|
9538
|
-
else if (
|
|
9539
|
-
else if (
|
|
9540
|
-
else if (
|
|
9541
|
-
else if (
|
|
9542
|
-
else if (
|
|
9543
|
-
else if (
|
|
9643
|
+
if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
9644
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
9645
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
9646
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
9647
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
9648
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
9649
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
9650
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
9651
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
9544
9652
|
else {
|
|
9545
9653
|
if (r === "shadow") {
|
|
9546
|
-
const found = inst.shadowRoot?.querySelectorAll(
|
|
9654
|
+
const found = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
9547
9655
|
if (found) results.push(...found);
|
|
9548
9656
|
} else if (r === "light") {
|
|
9549
|
-
const found = inst.querySelectorAll(
|
|
9657
|
+
const found = inst.querySelectorAll(stringSelector);
|
|
9550
9658
|
if (found) results.push(...found);
|
|
9551
9659
|
} else if (r === "all") {
|
|
9552
|
-
const sMatch = inst.shadowRoot?.querySelectorAll(
|
|
9553
|
-
const lMatch = inst.querySelectorAll(
|
|
9660
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
9661
|
+
const lMatch = inst.querySelectorAll(stringSelector);
|
|
9554
9662
|
if (sMatch) results.push(...sMatch);
|
|
9555
9663
|
if (lMatch) results.push(...lMatch);
|
|
9556
9664
|
} else {
|
|
9557
|
-
const found = (inst.shadowRoot || inst).querySelectorAll(
|
|
9665
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
|
|
9558
9666
|
if (found) results.push(...found);
|
|
9559
9667
|
}
|
|
9560
9668
|
}
|
|
@@ -9979,7 +10087,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
9979
10087
|
const delegateListeners = [];
|
|
9980
10088
|
const nonDelegateListeners = [];
|
|
9981
10089
|
addEventListenerList.forEach((meta) => {
|
|
9982
|
-
|
|
10090
|
+
const isStringSelector = typeof meta.selector === "string";
|
|
10091
|
+
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 !== "") {
|
|
9983
10092
|
delegateListeners.push(meta);
|
|
9984
10093
|
} else {
|
|
9985
10094
|
nonDelegateListeners.push(meta);
|
|
@@ -10042,6 +10151,22 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10042
10151
|
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
10043
10152
|
const bindTargets = [];
|
|
10044
10153
|
const r = options.root || "auto";
|
|
10154
|
+
let resolvedSelector = null;
|
|
10155
|
+
if (typeof selector === "function") {
|
|
10156
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
10157
|
+
const result = selector(this, hostSet);
|
|
10158
|
+
if (typeof result === "string") {
|
|
10159
|
+
resolvedSelector = result;
|
|
10160
|
+
} else if (result instanceof currentWin.Element) {
|
|
10161
|
+
bindTargets.push(result);
|
|
10162
|
+
} else if (result instanceof currentWin.NodeList) {
|
|
10163
|
+
bindTargets.push(...Array.from(result));
|
|
10164
|
+
} else if (Array.isArray(result)) {
|
|
10165
|
+
bindTargets.push(...result);
|
|
10166
|
+
}
|
|
10167
|
+
} else {
|
|
10168
|
+
resolvedSelector = selector;
|
|
10169
|
+
}
|
|
10045
10170
|
const applyRootOption = (target) => {
|
|
10046
10171
|
if (!target) return;
|
|
10047
10172
|
if (r === "auto") {
|
|
@@ -10051,30 +10176,32 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10051
10176
|
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
10052
10177
|
}
|
|
10053
10178
|
};
|
|
10054
|
-
if (
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10179
|
+
if (resolvedSelector) {
|
|
10180
|
+
if (resolvedSelector === "$window") bindTargets.push(currentWin);
|
|
10181
|
+
else if (resolvedSelector === "$document") bindTargets.push(currentWin.document);
|
|
10182
|
+
else if (resolvedSelector === "$host") applyRootOption(helperHostSet.$host);
|
|
10183
|
+
else if (resolvedSelector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
|
|
10184
|
+
else if (resolvedSelector === "$appHost") applyRootOption(helperHostSet.$appHost);
|
|
10185
|
+
else if (resolvedSelector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
|
|
10186
|
+
else if (resolvedSelector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
|
|
10187
|
+
else if (resolvedSelector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
|
|
10188
|
+
else if (resolvedSelector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
|
|
10189
|
+
else if (resolvedSelector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
|
|
10190
|
+
else if (resolvedSelector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
|
|
10191
|
+
else if (resolvedSelector === "$this" || !resolvedSelector) applyRootOption(this);
|
|
10192
|
+
else {
|
|
10193
|
+
const searchRoots = [];
|
|
10194
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
10195
|
+
else if (r === "light") searchRoots.push(this);
|
|
10196
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
10197
|
+
else if (r === "all") {
|
|
10198
|
+
searchRoots.push(this);
|
|
10199
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
10200
|
+
}
|
|
10201
|
+
searchRoots.forEach((sr) => {
|
|
10202
|
+
sr.querySelectorAll(resolvedSelector).forEach((el) => bindTargets.push(el));
|
|
10203
|
+
});
|
|
10074
10204
|
}
|
|
10075
|
-
searchRoots.forEach((sr) => {
|
|
10076
|
-
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
10077
|
-
});
|
|
10078
10205
|
}
|
|
10079
10206
|
bindTargets.forEach((t) => {
|
|
10080
10207
|
const handler = async (event2) => {
|
|
@@ -10089,7 +10216,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
|
|
|
10089
10216
|
if (options.preventDefault) event2.preventDefault();
|
|
10090
10217
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
10091
10218
|
const args = { event: event2, ...currentHostSet, $el: t, $root: t };
|
|
10092
|
-
await this[meta.propertyKey](event2, { currentHostSet,
|
|
10219
|
+
await this[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, args);
|
|
10093
10220
|
};
|
|
10094
10221
|
const eventSubject = new Subject();
|
|
10095
10222
|
let eventStream = eventSubject;
|
|
@@ -10288,6 +10415,27 @@ var resolveAttributeTargets = (inst, selector, options) => {
|
|
|
10288
10415
|
const currentWin = conf.window;
|
|
10289
10416
|
const r = options.root || "auto";
|
|
10290
10417
|
const results = [];
|
|
10418
|
+
let resolvedSelector = selector;
|
|
10419
|
+
if (typeof selector === "function") {
|
|
10420
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
|
|
10421
|
+
resolvedSelector = selector(inst, hostSet);
|
|
10422
|
+
}
|
|
10423
|
+
if (resolvedSelector instanceof currentWin.Element) {
|
|
10424
|
+
results.push(resolvedSelector);
|
|
10425
|
+
return results;
|
|
10426
|
+
}
|
|
10427
|
+
if (resolvedSelector instanceof currentWin.NodeList) {
|
|
10428
|
+
results.push(...Array.from(resolvedSelector));
|
|
10429
|
+
return results;
|
|
10430
|
+
}
|
|
10431
|
+
if (Array.isArray(resolvedSelector)) {
|
|
10432
|
+
results.push(...resolvedSelector);
|
|
10433
|
+
return results;
|
|
10434
|
+
}
|
|
10435
|
+
if (resolvedSelector === null) {
|
|
10436
|
+
return results;
|
|
10437
|
+
}
|
|
10438
|
+
const stringSelector = resolvedSelector;
|
|
10291
10439
|
const applyRoot = (target) => {
|
|
10292
10440
|
if (!target) return;
|
|
10293
10441
|
if (r === "auto") {
|
|
@@ -10297,33 +10445,33 @@ var resolveAttributeTargets = (inst, selector, options) => {
|
|
|
10297
10445
|
if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
|
|
10298
10446
|
}
|
|
10299
10447
|
};
|
|
10300
|
-
if (
|
|
10448
|
+
if (stringSelector === "$this" || !stringSelector) {
|
|
10301
10449
|
applyRoot(inst);
|
|
10302
10450
|
} else {
|
|
10303
10451
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
10304
|
-
if (
|
|
10305
|
-
else if (
|
|
10306
|
-
else if (
|
|
10307
|
-
else if (
|
|
10308
|
-
else if (
|
|
10309
|
-
else if (
|
|
10310
|
-
else if (
|
|
10311
|
-
else if (
|
|
10312
|
-
else if (
|
|
10452
|
+
if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
10453
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10454
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10455
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10456
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10457
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10458
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10459
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10460
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10313
10461
|
else {
|
|
10314
10462
|
if (r === "shadow") {
|
|
10315
|
-
const found = inst.shadowRoot?.querySelectorAll(
|
|
10463
|
+
const found = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
10316
10464
|
if (found) results.push(...found);
|
|
10317
10465
|
} else if (r === "light") {
|
|
10318
|
-
const found = inst.querySelectorAll(
|
|
10466
|
+
const found = inst.querySelectorAll(stringSelector);
|
|
10319
10467
|
if (found) results.push(...found);
|
|
10320
10468
|
} else if (r === "all") {
|
|
10321
|
-
const sMatch = inst.shadowRoot?.querySelectorAll(
|
|
10322
|
-
const lMatch = inst.querySelectorAll(
|
|
10469
|
+
const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
|
|
10470
|
+
const lMatch = inst.querySelectorAll(stringSelector);
|
|
10323
10471
|
if (sMatch) results.push(...sMatch);
|
|
10324
10472
|
if (lMatch) results.push(...lMatch);
|
|
10325
10473
|
} else {
|
|
10326
|
-
const found = (inst.shadowRoot || inst).querySelectorAll(
|
|
10474
|
+
const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
|
|
10327
10475
|
if (found) results.push(...found);
|
|
10328
10476
|
}
|
|
10329
10477
|
}
|
|
@@ -10462,6 +10610,26 @@ var findAllAttributeApplyMetadata = (target) => {
|
|
|
10462
10610
|
|
|
10463
10611
|
// src/decorators/applyNode.ts
|
|
10464
10612
|
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
10613
|
+
var resolveSelector = (selector, inst, win) => {
|
|
10614
|
+
if (typeof selector === "function") {
|
|
10615
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
10616
|
+
const result = selector(inst, hostSet);
|
|
10617
|
+
if (result instanceof win.Element) {
|
|
10618
|
+
return result;
|
|
10619
|
+
}
|
|
10620
|
+
if (result instanceof win.NodeList) {
|
|
10621
|
+
return result.length > 0 ? result[0] : null;
|
|
10622
|
+
}
|
|
10623
|
+
if (Array.isArray(result)) {
|
|
10624
|
+
return result.length > 0 ? result[0] : null;
|
|
10625
|
+
}
|
|
10626
|
+
if (result === null) {
|
|
10627
|
+
return null;
|
|
10628
|
+
}
|
|
10629
|
+
return result;
|
|
10630
|
+
}
|
|
10631
|
+
return selector;
|
|
10632
|
+
};
|
|
10465
10633
|
var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
10466
10634
|
if (!targetEl) return;
|
|
10467
10635
|
if (pos === "clearChildren") {
|
|
@@ -10506,7 +10674,7 @@ var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
|
|
|
10506
10674
|
function applyNode(selectorOrOptions, maybeOptions) {
|
|
10507
10675
|
let selector;
|
|
10508
10676
|
let options;
|
|
10509
|
-
if (typeof selectorOrOptions === "string") {
|
|
10677
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10510
10678
|
selector = selectorOrOptions;
|
|
10511
10679
|
options = maybeOptions || { position: "replaceChildren" };
|
|
10512
10680
|
} else {
|
|
@@ -10538,14 +10706,22 @@ function applyNode(selectorOrOptions, maybeOptions) {
|
|
|
10538
10706
|
if (r === "all") return t.shadowRoot || t;
|
|
10539
10707
|
return t;
|
|
10540
10708
|
};
|
|
10541
|
-
|
|
10542
|
-
if (
|
|
10543
|
-
|
|
10544
|
-
|
|
10545
|
-
if (
|
|
10546
|
-
|
|
10709
|
+
const resolved = resolveSelector(selector, this, currentWin);
|
|
10710
|
+
if (resolved instanceof currentWin.Element) {
|
|
10711
|
+
return applyRoot(resolved);
|
|
10712
|
+
}
|
|
10713
|
+
if (resolved === null) {
|
|
10714
|
+
return null;
|
|
10715
|
+
}
|
|
10716
|
+
const stringSelector = resolved;
|
|
10717
|
+
if (stringSelector === "$this") return applyRoot(this);
|
|
10718
|
+
if (stringSelector === "$host") return applyRoot(hostSet.$host);
|
|
10719
|
+
if (stringSelector === "$parentHost") return applyRoot(hostSet.$parentHost);
|
|
10720
|
+
if (stringSelector === "$appHost") return applyRoot(hostSet.$appHost);
|
|
10721
|
+
if (stringSelector === "$firstHost") return applyRoot(hostSet.$firstHost);
|
|
10722
|
+
if (stringSelector === "$lastHost") return applyRoot(hostSet.$lastHost);
|
|
10547
10723
|
const targetRoot = applyRoot(this);
|
|
10548
|
-
return targetRoot ? targetRoot.querySelector(
|
|
10724
|
+
return targetRoot ? targetRoot.querySelector(stringSelector) : null;
|
|
10549
10725
|
};
|
|
10550
10726
|
const targetEl = getTarget();
|
|
10551
10727
|
const res = original.apply(this, args);
|
|
@@ -10587,7 +10763,7 @@ function replaceChildren(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10587
10763
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10588
10764
|
return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10589
10765
|
}
|
|
10590
|
-
if (typeof selectorOrOptions === "string") {
|
|
10766
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10591
10767
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
|
|
10592
10768
|
}
|
|
10593
10769
|
return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
|
|
@@ -10596,7 +10772,7 @@ function clearChildrenNode(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10596
10772
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10597
10773
|
return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10598
10774
|
}
|
|
10599
|
-
if (typeof selectorOrOptions === "string") {
|
|
10775
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10600
10776
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
|
|
10601
10777
|
}
|
|
10602
10778
|
return applyNode({ ...selectorOrOptions, position: "clearChildren" });
|
|
@@ -10606,7 +10782,7 @@ function innerHtml(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10606
10782
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10607
10783
|
return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10608
10784
|
}
|
|
10609
|
-
if (typeof selectorOrOptions === "string") {
|
|
10785
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10610
10786
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
|
|
10611
10787
|
}
|
|
10612
10788
|
return applyNode({ ...selectorOrOptions, position: "innerHtml" });
|
|
@@ -10615,7 +10791,7 @@ function innerHtmlLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10615
10791
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10616
10792
|
return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10617
10793
|
}
|
|
10618
|
-
if (typeof selectorOrOptions === "string") {
|
|
10794
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10619
10795
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
|
|
10620
10796
|
}
|
|
10621
10797
|
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
|
|
@@ -10624,7 +10800,7 @@ function innerHtmlShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10624
10800
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10625
10801
|
return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10626
10802
|
}
|
|
10627
|
-
if (typeof selectorOrOptions === "string") {
|
|
10803
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10628
10804
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
|
|
10629
10805
|
}
|
|
10630
10806
|
return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
|
|
@@ -10633,7 +10809,7 @@ function innerText(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10633
10809
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10634
10810
|
return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10635
10811
|
}
|
|
10636
|
-
if (typeof selectorOrOptions === "string") {
|
|
10812
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10637
10813
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
|
|
10638
10814
|
}
|
|
10639
10815
|
return applyNode({ ...selectorOrOptions, position: "innerText" });
|
|
@@ -10642,7 +10818,7 @@ function innerTextLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10642
10818
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10643
10819
|
return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10644
10820
|
}
|
|
10645
|
-
if (typeof selectorOrOptions === "string") {
|
|
10821
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10646
10822
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
|
|
10647
10823
|
}
|
|
10648
10824
|
return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
|
|
@@ -10651,7 +10827,7 @@ function innerTextShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10651
10827
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10652
10828
|
return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10653
10829
|
}
|
|
10654
|
-
if (typeof selectorOrOptions === "string") {
|
|
10830
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10655
10831
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
|
|
10656
10832
|
}
|
|
10657
10833
|
return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
|
|
@@ -10660,7 +10836,7 @@ function insertBeforeEnd(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10660
10836
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10661
10837
|
return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10662
10838
|
}
|
|
10663
|
-
if (typeof selectorOrOptions === "string") {
|
|
10839
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10664
10840
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
|
|
10665
10841
|
}
|
|
10666
10842
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
|
|
@@ -10669,7 +10845,7 @@ function insertBeforeEndLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10669
10845
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10670
10846
|
return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10671
10847
|
}
|
|
10672
|
-
if (typeof selectorOrOptions === "string") {
|
|
10848
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10673
10849
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
|
|
10674
10850
|
}
|
|
10675
10851
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
|
|
@@ -10678,7 +10854,7 @@ function insertBeforeEndShadow(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10678
10854
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10679
10855
|
return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10680
10856
|
}
|
|
10681
|
-
if (typeof selectorOrOptions === "string") {
|
|
10857
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10682
10858
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
|
|
10683
10859
|
}
|
|
10684
10860
|
return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
|
|
@@ -10687,7 +10863,7 @@ function insertAfterBegin(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10687
10863
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10688
10864
|
return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10689
10865
|
}
|
|
10690
|
-
if (typeof selectorOrOptions === "string") {
|
|
10866
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10691
10867
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
|
|
10692
10868
|
}
|
|
10693
10869
|
return applyNode({ ...selectorOrOptions, position: "afterBegin" });
|
|
@@ -10696,7 +10872,7 @@ function insertAfterBeginLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10696
10872
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10697
10873
|
return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10698
10874
|
}
|
|
10699
|
-
if (typeof selectorOrOptions === "string") {
|
|
10875
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10700
10876
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
|
|
10701
10877
|
}
|
|
10702
10878
|
return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
|
|
@@ -10705,7 +10881,7 @@ function replaceChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10705
10881
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10706
10882
|
return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10707
10883
|
}
|
|
10708
|
-
if (typeof selectorOrOptions === "string") {
|
|
10884
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10709
10885
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
|
|
10710
10886
|
}
|
|
10711
10887
|
return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
|
|
@@ -10714,7 +10890,7 @@ function clearChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
|
|
|
10714
10890
|
if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
|
|
10715
10891
|
return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
|
|
10716
10892
|
}
|
|
10717
|
-
if (typeof selectorOrOptions === "string") {
|
|
10893
|
+
if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
|
|
10718
10894
|
return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
|
|
10719
10895
|
}
|
|
10720
10896
|
return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
|
|
@@ -10732,6 +10908,58 @@ var findAllApplyNodeMetadata = (target) => {
|
|
|
10732
10908
|
|
|
10733
10909
|
// src/decorators/applyClass.ts
|
|
10734
10910
|
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
10911
|
+
var resolveSelector2 = (selector, inst, win) => {
|
|
10912
|
+
if (typeof selector === "function") {
|
|
10913
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
10914
|
+
const result = selector(inst, hostSet);
|
|
10915
|
+
if (result instanceof win.Element) {
|
|
10916
|
+
return [result];
|
|
10917
|
+
}
|
|
10918
|
+
if (result instanceof win.NodeList) {
|
|
10919
|
+
return Array.from(result);
|
|
10920
|
+
}
|
|
10921
|
+
if (Array.isArray(result)) {
|
|
10922
|
+
return result;
|
|
10923
|
+
}
|
|
10924
|
+
if (result === null) {
|
|
10925
|
+
return [];
|
|
10926
|
+
}
|
|
10927
|
+
return result;
|
|
10928
|
+
}
|
|
10929
|
+
return selector;
|
|
10930
|
+
};
|
|
10931
|
+
var getTargetElements = (selector, inst, win, root) => {
|
|
10932
|
+
const resolved = resolveSelector2(selector, inst, win);
|
|
10933
|
+
if (Array.isArray(resolved)) {
|
|
10934
|
+
return resolved;
|
|
10935
|
+
}
|
|
10936
|
+
const stringSelector = resolved;
|
|
10937
|
+
const targetEls = [];
|
|
10938
|
+
const host = inst;
|
|
10939
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
10940
|
+
const applyRoot = (t) => {
|
|
10941
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
10942
|
+
targetEls.push(t);
|
|
10943
|
+
};
|
|
10944
|
+
if (stringSelector === "$this" || !stringSelector) applyRoot(host);
|
|
10945
|
+
else if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
10946
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10947
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10948
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10949
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10950
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10951
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10952
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10953
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10954
|
+
else {
|
|
10955
|
+
const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
|
|
10956
|
+
if (targetRoot) {
|
|
10957
|
+
const found = targetRoot.querySelectorAll(stringSelector);
|
|
10958
|
+
if (found) targetEls.push(...Array.from(found));
|
|
10959
|
+
}
|
|
10960
|
+
}
|
|
10961
|
+
return targetEls;
|
|
10962
|
+
};
|
|
10735
10963
|
function createClassDecorator(action) {
|
|
10736
10964
|
return (selector, classMapOrOptions, options = {}) => {
|
|
10737
10965
|
return (target, propertyKey, descriptor) => {
|
|
@@ -10766,28 +10994,7 @@ function createClassDecorator(action) {
|
|
|
10766
10994
|
const host = this;
|
|
10767
10995
|
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
10768
10996
|
const r = finalOptions.root || "auto";
|
|
10769
|
-
const targetEls =
|
|
10770
|
-
const applyRoot = (t) => {
|
|
10771
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
10772
|
-
targetEls.push(t);
|
|
10773
|
-
};
|
|
10774
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
10775
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
10776
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10777
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10778
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10779
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10780
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10781
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10782
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10783
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10784
|
-
else {
|
|
10785
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
10786
|
-
if (targetRoot) {
|
|
10787
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
10788
|
-
if (found) targetEls.push(...Array.from(found));
|
|
10789
|
-
}
|
|
10790
|
-
}
|
|
10997
|
+
const targetEls = getTargetElements(selector, this, win, r);
|
|
10791
10998
|
targetEls.forEach((targetEl) => {
|
|
10792
10999
|
if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
10793
11000
|
return;
|
|
@@ -10919,6 +11126,58 @@ var findAllClassMetadata = (target) => {
|
|
|
10919
11126
|
|
|
10920
11127
|
// src/decorators/applyStyle.ts
|
|
10921
11128
|
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
11129
|
+
var resolveSelector3 = (selector, inst, win) => {
|
|
11130
|
+
if (typeof selector === "function") {
|
|
11131
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11132
|
+
const result = selector(inst, hostSet);
|
|
11133
|
+
if (result instanceof win.Element) {
|
|
11134
|
+
return [result];
|
|
11135
|
+
}
|
|
11136
|
+
if (result instanceof win.NodeList) {
|
|
11137
|
+
return Array.from(result);
|
|
11138
|
+
}
|
|
11139
|
+
if (Array.isArray(result)) {
|
|
11140
|
+
return result;
|
|
11141
|
+
}
|
|
11142
|
+
if (result === null) {
|
|
11143
|
+
return [];
|
|
11144
|
+
}
|
|
11145
|
+
return result;
|
|
11146
|
+
}
|
|
11147
|
+
return selector;
|
|
11148
|
+
};
|
|
11149
|
+
var getTargetElements2 = (selector, inst, win, root) => {
|
|
11150
|
+
const resolved = resolveSelector3(selector, inst, win);
|
|
11151
|
+
if (Array.isArray(resolved)) {
|
|
11152
|
+
return resolved;
|
|
11153
|
+
}
|
|
11154
|
+
const stringSelector = resolved;
|
|
11155
|
+
const targetEls = [];
|
|
11156
|
+
const host = inst;
|
|
11157
|
+
const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
|
|
11158
|
+
const applyRoot = (t) => {
|
|
11159
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
11160
|
+
targetEls.push(t);
|
|
11161
|
+
};
|
|
11162
|
+
if (stringSelector === "$this" || !stringSelector) applyRoot(host);
|
|
11163
|
+
else if (stringSelector === "$host") applyRoot(hostSet.$host);
|
|
11164
|
+
else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
11165
|
+
else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
|
|
11166
|
+
else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
11167
|
+
else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
11168
|
+
else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
11169
|
+
else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
11170
|
+
else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
11171
|
+
else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
11172
|
+
else {
|
|
11173
|
+
const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
|
|
11174
|
+
if (targetRoot) {
|
|
11175
|
+
const found = targetRoot.querySelectorAll(stringSelector);
|
|
11176
|
+
if (found) targetEls.push(...Array.from(found));
|
|
11177
|
+
}
|
|
11178
|
+
}
|
|
11179
|
+
return targetEls;
|
|
11180
|
+
};
|
|
10922
11181
|
function createStyleDecorator(action) {
|
|
10923
11182
|
return (selector, options = {}) => {
|
|
10924
11183
|
return (target, propertyKey, descriptor) => {
|
|
@@ -10946,28 +11205,7 @@ function createStyleDecorator(action) {
|
|
|
10946
11205
|
const host = this;
|
|
10947
11206
|
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
|
|
10948
11207
|
const r = options.root || "auto";
|
|
10949
|
-
const targetEls =
|
|
10950
|
-
const applyRoot = (t) => {
|
|
10951
|
-
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
10952
|
-
targetEls.push(t);
|
|
10953
|
-
};
|
|
10954
|
-
if (selector === "$this" || !selector) applyRoot(host);
|
|
10955
|
-
else if (selector === "$host") applyRoot(hostSet.$host);
|
|
10956
|
-
else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
|
|
10957
|
-
else if (selector === "$appHost") applyRoot(hostSet.$appHost);
|
|
10958
|
-
else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
|
|
10959
|
-
else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
|
|
10960
|
-
else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
10961
|
-
else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
10962
|
-
else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
|
|
10963
|
-
else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
10964
|
-
else {
|
|
10965
|
-
const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
|
|
10966
|
-
if (targetRoot) {
|
|
10967
|
-
const found = targetRoot.querySelectorAll(selector);
|
|
10968
|
-
if (found) targetEls.push(...Array.from(found));
|
|
10969
|
-
}
|
|
10970
|
-
}
|
|
11208
|
+
const targetEls = getTargetElements2(selector, this, win, r);
|
|
10971
11209
|
targetEls.forEach((targetEl) => {
|
|
10972
11210
|
if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
|
|
10973
11211
|
return;
|