@dooboostore/simple-web-component 1.0.44 → 1.0.46

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.
Files changed (95) hide show
  1. package/README.md +25 -25
  2. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  3. package/dist/cjs/decorators/applyAttribute.js +36 -15
  4. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  5. package/dist/cjs/decorators/applyClass.js +53 -22
  6. package/dist/cjs/decorators/applyClass.js.map +2 -2
  7. package/dist/cjs/decorators/applyNode.js +54 -24
  8. package/dist/cjs/decorators/applyNode.js.map +2 -2
  9. package/dist/cjs/decorators/applyProperty.js +38 -17
  10. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  11. package/dist/cjs/decorators/applyStyle.js +53 -22
  12. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  13. package/dist/cjs/decorators/elementDefine.js +49 -33
  14. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  15. package/dist/cjs/decorators/emitCustomEvent.js +61 -47
  16. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +11 -36
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/query.js +91 -56
  20. package/dist/cjs/decorators/query.js.map +2 -2
  21. package/dist/cjs/decorators/queryAll.js +104 -66
  22. package/dist/cjs/decorators/queryAll.js.map +2 -2
  23. package/dist/cjs/elements/SwcAppMixin.js +6 -2
  24. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  25. package/dist/cjs/types/window.d.js.map +1 -1
  26. package/dist/esm/decorators/addEventListener.js.map +2 -2
  27. package/dist/esm/decorators/applyAttribute.js +36 -15
  28. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  29. package/dist/esm/decorators/applyClass.js +53 -22
  30. package/dist/esm/decorators/applyClass.js.map +2 -2
  31. package/dist/esm/decorators/applyNode.js +54 -24
  32. package/dist/esm/decorators/applyNode.js.map +2 -2
  33. package/dist/esm/decorators/applyProperty.js +38 -17
  34. package/dist/esm/decorators/applyProperty.js.map +2 -2
  35. package/dist/esm/decorators/applyStyle.js +53 -22
  36. package/dist/esm/decorators/applyStyle.js.map +2 -2
  37. package/dist/esm/decorators/elementDefine.js +50 -34
  38. package/dist/esm/decorators/elementDefine.js.map +2 -2
  39. package/dist/esm/decorators/emitCustomEvent.js +61 -47
  40. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  41. package/dist/esm/decorators/lifecycles.js +11 -36
  42. package/dist/esm/decorators/lifecycles.js.map +2 -2
  43. package/dist/esm/decorators/query.js +91 -56
  44. package/dist/esm/decorators/query.js.map +2 -2
  45. package/dist/esm/decorators/queryAll.js +104 -66
  46. package/dist/esm/decorators/queryAll.js.map +2 -2
  47. package/dist/esm/elements/SwcAppMixin.js +6 -2
  48. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  49. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +572 -320
  50. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  51. package/dist/types/decorators/addEventListener.d.ts +7 -6
  52. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  53. package/dist/types/decorators/applyAttribute.d.ts +13 -8
  54. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  55. package/dist/types/decorators/applyClass.d.ts +8 -7
  56. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  57. package/dist/types/decorators/applyNode.d.ts +18 -17
  58. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  59. package/dist/types/decorators/applyProperty.d.ts +14 -9
  60. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  61. package/dist/types/decorators/applyStyle.d.ts +6 -5
  62. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  63. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  64. package/dist/types/decorators/emitCustomEvent.d.ts +3 -2
  65. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  66. package/dist/types/decorators/lifecycles.d.ts +12 -13
  67. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  68. package/dist/types/decorators/query.d.ts +15 -5
  69. package/dist/types/decorators/query.d.ts.map +1 -1
  70. package/dist/types/decorators/queryAll.d.ts +15 -5
  71. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  72. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  73. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +572 -320
  74. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  75. package/package.json +3 -3
  76. package/src/decorators/addEventListener.ts +9 -7
  77. package/src/decorators/applyAttribute.ts +60 -27
  78. package/src/decorators/applyClass.ts +78 -32
  79. package/src/decorators/applyNode.ts +118 -73
  80. package/src/decorators/applyProperty.ts +63 -30
  81. package/src/decorators/applyStyle.ts +76 -30
  82. package/src/decorators/elementDefine.ts +57 -37
  83. package/src/decorators/emitCustomEvent.ts +63 -39
  84. package/src/decorators/lifecycles.ts +53 -52
  85. package/src/decorators/query.ts +111 -49
  86. package/src/decorators/queryAll.ts +121 -61
  87. package/src/elements/SwcAppMixin.ts +7 -3
  88. package/src/types/window.d.ts +3 -0
  89. package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
  90. package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
  91. package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
  92. package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
  93. package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
  94. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
  95. package/src/examples/RxJSOperatorsExample.ts +0 -279
@@ -1167,11 +1167,11 @@ var ValidUtils;
1167
1167
  ValidUtils22.isNullOrUndefined = (data) => {
1168
1168
  return data == null || void 0 === data;
1169
1169
  };
1170
- ValidUtils22.isConstructor = (obj) => {
1171
- return typeof obj === "function" && obj.prototype !== void 0 && obj.prototype.constructor === obj;
1170
+ ValidUtils22.isClassType = (obj) => {
1171
+ return typeof obj === "function" && /^\s*class\s+/.test(obj.toString());
1172
1172
  };
1173
- ValidUtils22.isFunction = (obj) => {
1174
- return typeof obj === "function" && !(0, ValidUtils22.isConstructor)(obj);
1173
+ ValidUtils22.isFunctionType = (obj) => {
1174
+ return typeof obj === "function";
1175
1175
  };
1176
1176
  ValidUtils22.isNullish = (data) => {
1177
1177
  return ValidUtils22.isNotNullish(data);
@@ -1320,6 +1320,13 @@ var ValidUtils;
1320
1320
  // ../core/dist/esm/array/ArrayUtils.js
1321
1321
  var ArrayUtils;
1322
1322
  ((ArrayUtils2) => {
1323
+ ArrayUtils2.split = (data, length) => {
1324
+ const result = [];
1325
+ for (let i = 0; i < data.length; i += length) {
1326
+ result.push(data.slice(i, i + length));
1327
+ }
1328
+ return result;
1329
+ };
1323
1330
  ArrayUtils2.create2DArray = (rows, cols, initialValue) => {
1324
1331
  const array = [];
1325
1332
  for (let row = 0; row < rows; row++) {
@@ -4090,6 +4097,10 @@ var MathUtil;
4090
4097
  const rotatedY = translatedX * Math.sin(angleInRadians) + translatedY * Math.cos(angleInRadians);
4091
4098
  return new Point2D(rotatedX + center.x, rotatedY + center.y);
4092
4099
  };
4100
+ MathUtil2.quadraticBezier = (p0, p1, p2, t) => {
4101
+ const mt = 1 - t;
4102
+ return mt * mt * p0 + 2 * mt * t * p1 + t * t * p2;
4103
+ };
4093
4104
  })(MathUtil || (MathUtil = {}));
4094
4105
 
4095
4106
  // ../core/dist/esm/convert/ConvertUtils.js
@@ -5045,7 +5056,7 @@ var Promises;
5045
5056
  } catch (e) {
5046
5057
  const targetHas = Array.isArray(has) ? has : [has];
5047
5058
  for (let ha of targetHas) {
5048
- if (ValidUtils.isConstructor(ha)) {
5059
+ if (ValidUtils.isFunctionType(ha)) {
5049
5060
  if (e instanceof ha) {
5050
5061
  return e;
5051
5062
  }
@@ -6500,7 +6511,7 @@ var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-aft
6500
6511
  var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
6501
6512
  var ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
6502
6513
  var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
6503
- var ON_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component");
6514
+ var ON_CONNECTED_BODY_METADATA_KEY = Symbol.for("simple-web-component:on-connected-body");
6504
6515
  var ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for("simple-web-component:on-connected-swc-app");
6505
6516
  var ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for("simple-web-component:on-completed");
6506
6517
  var ATTRIBUTE_CHANGED_WILDCARD = "*";
@@ -6586,14 +6597,14 @@ function onConnectedCompleted(optionOrTarget, propertyKey) {
6586
6597
  }
6587
6598
  var decorator = (options, target, propertyKey) => {
6588
6599
  const constructor = target.constructor;
6589
- let list = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor);
6600
+ let list = ReflectUtils.getMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor);
6590
6601
  if (!list) {
6591
6602
  list = [];
6592
- ReflectUtils.defineMetadata(ON_CONNECTED_METADATA_KEY, list, constructor);
6603
+ ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);
6593
6604
  }
6594
6605
  list.push({ propertyKey, options });
6595
6606
  };
6596
- function onConnectedShadow(optionOrTarget, propertyKey, arg3) {
6607
+ function onConnectedBodyShadow(optionOrTarget, propertyKey, arg3) {
6597
6608
  if (propertyKey) {
6598
6609
  return decorator({ useShadow: true }, optionOrTarget, propertyKey);
6599
6610
  }
@@ -6601,7 +6612,7 @@ function onConnectedShadow(optionOrTarget, propertyKey, arg3) {
6601
6612
  decorator({ ...optionOrTarget ?? {}, useShadow: true }, target, propertyKey2);
6602
6613
  };
6603
6614
  }
6604
- function onConnectedLight(optionOrTarget, propertyKey, arg3) {
6615
+ function onConnectedBodyLight(optionOrTarget, propertyKey, arg3) {
6605
6616
  if (propertyKey) {
6606
6617
  return decorator({ useShadow: false }, optionOrTarget, propertyKey);
6607
6618
  }
@@ -6609,7 +6620,7 @@ function onConnectedLight(optionOrTarget, propertyKey, arg3) {
6609
6620
  decorator({ ...optionOrTarget ?? {}, useShadow: false }, target, propertyKey2);
6610
6621
  };
6611
6622
  }
6612
- function onConnected(optionOrTarget, propertyKey, arg3) {
6623
+ function onConnectedBody(optionOrTarget, propertyKey, arg3) {
6613
6624
  if (propertyKey) {
6614
6625
  return decorator({}, optionOrTarget, propertyKey);
6615
6626
  }
@@ -6624,7 +6635,7 @@ var findAllLifecycleMetadata = (target, metadataKey) => {
6624
6635
  };
6625
6636
  var findAllOnConnectedMetadata = (target) => {
6626
6637
  const constructor = target instanceof Function ? target : target.constructor;
6627
- const results = ReflectUtils.getMetadata(ON_CONNECTED_METADATA_KEY, constructor) ?? [];
6638
+ const results = ReflectUtils.getMetadata(ON_CONNECTED_BODY_METADATA_KEY, constructor) ?? [];
6628
6639
  return [...results].sort((a, b) => {
6629
6640
  const orderA = a.options?.order ?? 0;
6630
6641
  const orderB = b.options?.order ?? 0;
@@ -8953,7 +8964,7 @@ function emitCustomEvent(selectorOrTarget, typeOrPropertyKey, optionsOrDescripto
8953
8964
  if (typeof selectorOrTarget === "object" && typeof typeOrPropertyKey === "string" && typeof optionsOrDescriptor === "object" && "value" in optionsOrDescriptor) {
8954
8965
  throw new Error(`@emitCustomEvent decorator cannot be used on properties. (Property: ${String(typeOrPropertyKey)})`);
8955
8966
  }
8956
- if (typeof selectorOrTarget === "string" && typeof typeOrPropertyKey === "string") {
8967
+ if ((typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") && typeof typeOrPropertyKey === "string") {
8957
8968
  return createEmitDecorator(selectorOrTarget, typeOrPropertyKey, optionsOrDescriptor);
8958
8969
  }
8959
8970
  if (typeof selectorOrTarget === "string" && typeOrPropertyKey !== "string") {
@@ -8986,58 +8997,72 @@ function createEmitDecorator(selector, type, options) {
8986
8997
  composed: fullOptions.composed,
8987
8998
  cancelable: fullOptions.cancelable
8988
8999
  });
8989
- const hostSet = SwcUtils.getHostSet(this);
8990
9000
  const conf = getElementConfig(this);
8991
9001
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
9002
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
8992
9003
  const eventTargets = [];
8993
- if (selector === "$window")
8994
- eventTargets.push(currentWin);
8995
- else if (selector === "$document")
8996
- eventTargets.push(currentWin.document);
8997
- else if (selector === "$host") {
8998
- if (hostSet.$host)
8999
- eventTargets.push(hostSet.$host);
9000
- } else if (selector === "$parentHost") {
9001
- if (hostSet.$parentHost)
9002
- eventTargets.push(hostSet.$parentHost);
9003
- } else if (selector === "$appHost") {
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);
9004
+ let resolvedSelector = selector;
9005
+ if (typeof selector === "function") {
9006
+ resolvedSelector = selector(this, hostSet);
9007
+ }
9008
+ if (resolvedSelector instanceof currentWin.Element) {
9009
+ eventTargets.push(resolvedSelector);
9010
+ } else if (resolvedSelector instanceof currentWin.NodeList) {
9011
+ eventTargets.push(...Array.from(resolvedSelector));
9012
+ } else if (Array.isArray(resolvedSelector)) {
9013
+ eventTargets.push(...resolvedSelector);
9014
+ } else if (resolvedSelector === null) {
9024
9015
  } else {
9025
- const r = fullOptions.root || "auto";
9026
- const searchRoots = [];
9027
- if (r === "auto")
9028
- searchRoots.push(this.shadowRoot || this);
9029
- else if (r === "light")
9030
- searchRoots.push(this);
9031
- else if (r === "shadow" && this.shadowRoot)
9032
- searchRoots.push(this.shadowRoot);
9033
- else if (r === "all") {
9034
- searchRoots.push(this);
9035
- if (this.shadowRoot)
9016
+ const stringSelector = resolvedSelector;
9017
+ if (stringSelector === "$window")
9018
+ eventTargets.push(currentWin);
9019
+ else if (stringSelector === "$document")
9020
+ eventTargets.push(currentWin.document);
9021
+ else if (stringSelector === "$host") {
9022
+ if (hostSet.$host)
9023
+ eventTargets.push(hostSet.$host);
9024
+ } else if (stringSelector === "$parentHost") {
9025
+ if (hostSet.$parentHost)
9026
+ eventTargets.push(hostSet.$parentHost);
9027
+ } else if (stringSelector === "$appHost") {
9028
+ if (hostSet.$appHost)
9029
+ eventTargets.push(hostSet.$appHost);
9030
+ } else if (stringSelector === "$firstHost") {
9031
+ if (hostSet.$firstHost)
9032
+ eventTargets.push(hostSet.$firstHost);
9033
+ } else if (stringSelector === "$lastHost") {
9034
+ if (hostSet.$lastHost)
9035
+ eventTargets.push(hostSet.$lastHost);
9036
+ } else if (stringSelector === "$firstAppHost") {
9037
+ if (hostSet.$firstAppHost)
9038
+ eventTargets.push(hostSet.$firstAppHost);
9039
+ } else if (stringSelector === "$lastAppHost") {
9040
+ if (hostSet.$lastAppHost)
9041
+ eventTargets.push(hostSet.$lastAppHost);
9042
+ } else if (stringSelector === "$hosts") {
9043
+ hostSet.$hosts.forEach((h) => eventTargets.push(h));
9044
+ } else if (stringSelector === "$appHosts") {
9045
+ hostSet.$appHosts.forEach((h) => eventTargets.push(h));
9046
+ } else if (stringSelector === "$this" || !stringSelector) {
9047
+ eventTargets.push(this);
9048
+ } else {
9049
+ const r = fullOptions.root || "auto";
9050
+ const searchRoots = [];
9051
+ if (r === "auto")
9052
+ searchRoots.push(this.shadowRoot || this);
9053
+ else if (r === "light")
9054
+ searchRoots.push(this);
9055
+ else if (r === "shadow" && this.shadowRoot)
9036
9056
  searchRoots.push(this.shadowRoot);
9057
+ else if (r === "all") {
9058
+ searchRoots.push(this);
9059
+ if (this.shadowRoot)
9060
+ searchRoots.push(this.shadowRoot);
9061
+ }
9062
+ searchRoots.forEach((sr) => {
9063
+ sr.querySelectorAll(stringSelector).forEach((el) => eventTargets.push(el));
9064
+ });
9037
9065
  }
9038
- searchRoots.forEach((sr) => {
9039
- sr.querySelectorAll(selector).forEach((el) => eventTargets.push(el));
9040
- });
9041
9066
  }
9042
9067
  eventTargets.forEach((t) => {
9043
9068
  if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
@@ -9113,7 +9138,7 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9113
9138
  if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9114
9139
  throw new Error(`@query decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9115
9140
  }
9116
- if (typeof selectorOrTarget === "string") {
9141
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9117
9142
  return (targetObj, propertyKey, descriptor2) => {
9118
9143
  if (descriptor2 !== void 0) {
9119
9144
  throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
@@ -9128,75 +9153,110 @@ function query(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9128
9153
  Object.defineProperty(targetObj, propertyKey, {
9129
9154
  get() {
9130
9155
  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
9156
  const config = getElementConfig(this);
9164
9157
  const win = config?.window || window;
9165
- if (selector === "$window")
9166
- return win;
9167
- if (selector === "$document")
9168
- return win.document;
9169
- if (r === "shadow")
9170
- return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9171
- if (r === "light")
9172
- return this.querySelector(selector);
9173
- if (r === "all") {
9174
- const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
9175
- return shadowMatch || this.querySelector(selector);
9158
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9159
+ let resolvedSelector;
9160
+ let resolvedElement = null;
9161
+ if (typeof selectorOrTarget === "function") {
9162
+ const result = selectorOrTarget(this, hostSet);
9163
+ if (result instanceof win.Node || result instanceof win.Element) {
9164
+ resolvedElement = result instanceof win.HTMLElement ? result : null;
9165
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9166
+ resolvedElement = result.length > 0 && result[0] instanceof win.HTMLElement ? result[0] : null;
9167
+ }
9168
+ } else {
9169
+ resolvedSelector = selectorOrTarget;
9170
+ const r = optionsOrPropertyKey?.root || "auto";
9171
+ const applyRoot = (t) => {
9172
+ if (!t || !(t instanceof HTMLElement))
9173
+ return t;
9174
+ if (r === "auto")
9175
+ return t.shadowRoot || t;
9176
+ if (r === "shadow")
9177
+ return t.shadowRoot;
9178
+ if (r === "light")
9179
+ return t;
9180
+ if (r === "all")
9181
+ return t.shadowRoot || t;
9182
+ return t;
9183
+ };
9184
+ if (resolvedSelector === "$this")
9185
+ resolvedElement = applyRoot(this);
9186
+ else if (resolvedSelector === "$host")
9187
+ resolvedElement = applyRoot(hostSet.$host);
9188
+ else if (resolvedSelector === "$parentHost")
9189
+ resolvedElement = applyRoot(hostSet.$parentHost);
9190
+ else if (resolvedSelector === "$appHost")
9191
+ resolvedElement = applyRoot(hostSet.$appHost);
9192
+ else if (resolvedSelector === "$firstHost")
9193
+ resolvedElement = applyRoot(hostSet.$firstHost);
9194
+ else if (resolvedSelector === "$lastHost")
9195
+ resolvedElement = applyRoot(hostSet.$lastHost);
9196
+ else if (resolvedSelector === "$firstAppHost")
9197
+ resolvedElement = applyRoot(hostSet.$firstAppHost);
9198
+ else if (resolvedSelector === "$lastAppHost")
9199
+ resolvedElement = applyRoot(hostSet.$lastAppHost);
9200
+ else if (resolvedSelector === "$window")
9201
+ return win;
9202
+ else if (resolvedSelector === "$document")
9203
+ return win.document;
9204
+ else {
9205
+ if (r === "shadow")
9206
+ resolvedElement = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9207
+ else if (r === "light")
9208
+ resolvedElement = this.querySelector(resolvedSelector);
9209
+ else if (r === "all") {
9210
+ const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(resolvedSelector) : null;
9211
+ resolvedElement = shadowMatch || this.querySelector(resolvedSelector);
9212
+ } else
9213
+ resolvedElement = (this.shadowRoot || this).querySelector(resolvedSelector);
9214
+ }
9215
+ }
9216
+ if (resolvedElement instanceof win.HTMLElement && optionsOrPropertyKey?.filter) {
9217
+ const shouldInclude = optionsOrPropertyKey.filter(resolvedElement, { currentThis: this, helper: hostSet });
9218
+ if (!shouldInclude) {
9219
+ return null;
9220
+ }
9176
9221
  }
9177
- return (this.shadowRoot || this).querySelector(selector);
9222
+ return resolvedElement;
9178
9223
  },
9179
9224
  set(nv) {
9180
9225
  ensureInit(this);
9181
9226
  if (nv === null || nv === void 0) {
9182
- const selector = selectorOrTarget;
9183
- if (selector.startsWith("$") && selector !== "$this")
9227
+ const config = getElementConfig(this);
9228
+ const win = config?.window || window;
9229
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9230
+ if (typeof selectorOrTarget === "function") {
9231
+ const result = selectorOrTarget(this, hostSet);
9232
+ if (result instanceof win.Element) {
9233
+ result.remove();
9234
+ } else if (result instanceof win.NodeList || Array.isArray(result)) {
9235
+ const el = result.length > 0 ? result[0] : null;
9236
+ if (el instanceof win.Element) {
9237
+ el.remove();
9238
+ }
9239
+ }
9240
+ return;
9241
+ }
9242
+ const resolvedSelector = selectorOrTarget;
9243
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9184
9244
  return;
9185
9245
  const r = optionsOrPropertyKey?.root || "auto";
9186
9246
  const targets = [];
9187
9247
  if (r === "shadow") {
9188
- if (this.shadowRoot?.querySelector(selector))
9189
- targets.push(this.shadowRoot.querySelector(selector));
9248
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9249
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9190
9250
  } else if (r === "light") {
9191
- if (this.querySelector(selector))
9192
- targets.push(this.querySelector(selector));
9251
+ if (this.querySelector(resolvedSelector))
9252
+ targets.push(this.querySelector(resolvedSelector));
9193
9253
  } else if (r === "all") {
9194
- if (this.shadowRoot?.querySelector(selector))
9195
- targets.push(this.shadowRoot.querySelector(selector));
9196
- if (this.querySelector(selector))
9197
- targets.push(this.querySelector(selector));
9254
+ if (this.shadowRoot?.querySelector(resolvedSelector))
9255
+ targets.push(this.shadowRoot.querySelector(resolvedSelector));
9256
+ if (this.querySelector(resolvedSelector))
9257
+ targets.push(this.querySelector(resolvedSelector));
9198
9258
  } else {
9199
- const el = (this.shadowRoot || this).querySelector(selector);
9259
+ const el = (this.shadowRoot || this).querySelector(resolvedSelector);
9200
9260
  if (el)
9201
9261
  targets.push(el);
9202
9262
  }
@@ -9221,7 +9281,7 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9221
9281
  if (descriptor !== void 0 && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol")) {
9222
9282
  throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(optionsOrPropertyKey)})`);
9223
9283
  }
9224
- if (typeof selectorOrTarget === "string") {
9284
+ if (typeof selectorOrTarget === "string" || typeof selectorOrTarget === "function") {
9225
9285
  return (targetObj, propertyKey, descriptor2) => {
9226
9286
  if (descriptor2 !== void 0) {
9227
9287
  throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
@@ -9236,86 +9296,124 @@ function queryAll(selectorOrTarget, optionsOrPropertyKey, descriptor) {
9236
9296
  Object.defineProperty(targetObj, propertyKey, {
9237
9297
  get() {
9238
9298
  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
9299
  const config = getElementConfig(this);
9282
9300
  const win = config?.window || window;
9283
- if (selector === "$window")
9284
- return [win];
9285
- if (selector === "$document")
9286
- return [win.document];
9287
- if (selector === "$this")
9288
- return applyRoot(this);
9289
- if (r === "shadow")
9290
- return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9291
- if (r === "light")
9292
- return Array.from(this.querySelectorAll(selector));
9293
- if (r === "all") {
9294
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9295
- const lNodes = Array.from(this.querySelectorAll(selector));
9296
- return [...sNodes, ...lNodes];
9301
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9302
+ let resolvedSelector;
9303
+ let resolvedElements = [];
9304
+ if (typeof selectorOrTarget === "function") {
9305
+ const result = selectorOrTarget(this, hostSet);
9306
+ if (result instanceof win.NodeList) {
9307
+ resolvedElements = Array.from(result).filter((el) => el instanceof win.HTMLElement);
9308
+ } else if (Array.isArray(result)) {
9309
+ resolvedElements = result.filter((el) => el instanceof win.HTMLElement);
9310
+ }
9311
+ } else {
9312
+ resolvedSelector = selectorOrTarget;
9313
+ const r = optionsOrPropertyKey?.root || "auto";
9314
+ const applyRoot = (t) => {
9315
+ if (!t)
9316
+ return [];
9317
+ const items = Array.isArray(t) ? t : [t];
9318
+ const results = [];
9319
+ items.forEach((it) => {
9320
+ if (!(it instanceof HTMLElement)) {
9321
+ results.push(it);
9322
+ return;
9323
+ }
9324
+ if (r === "auto")
9325
+ results.push(it.shadowRoot || it);
9326
+ else {
9327
+ if (r === "light" || r === "all")
9328
+ results.push(it);
9329
+ if ((r === "shadow" || r === "all") && it.shadowRoot)
9330
+ results.push(it.shadowRoot);
9331
+ }
9332
+ });
9333
+ return results;
9334
+ };
9335
+ if (resolvedSelector === "$hosts")
9336
+ resolvedElements = applyRoot(hostSet.$hosts).filter((el) => el instanceof HTMLElement);
9337
+ else if (resolvedSelector === "$appHosts")
9338
+ resolvedElements = applyRoot(hostSet.$appHosts).filter((el) => el instanceof HTMLElement);
9339
+ else if (resolvedSelector === "$host")
9340
+ resolvedElements = applyRoot(hostSet.$host).filter((el) => el instanceof HTMLElement);
9341
+ else if (resolvedSelector === "$parentHost")
9342
+ resolvedElements = applyRoot(hostSet.$parentHost).filter((el) => el instanceof HTMLElement);
9343
+ else if (resolvedSelector === "$appHost")
9344
+ resolvedElements = applyRoot(hostSet.$appHost).filter((el) => el instanceof HTMLElement);
9345
+ else if (resolvedSelector === "$firstHost")
9346
+ resolvedElements = applyRoot(hostSet.$firstHost).filter((el) => el instanceof HTMLElement);
9347
+ else if (resolvedSelector === "$lastHost")
9348
+ resolvedElements = applyRoot(hostSet.$lastHost).filter((el) => el instanceof HTMLElement);
9349
+ else if (resolvedSelector === "$firstAppHost")
9350
+ resolvedElements = applyRoot(hostSet.$firstAppHost).filter((el) => el instanceof HTMLElement);
9351
+ else if (resolvedSelector === "$lastAppHost")
9352
+ resolvedElements = applyRoot(hostSet.$lastAppHost).filter((el) => el instanceof HTMLElement);
9353
+ else if (resolvedSelector === "$window")
9354
+ return [win];
9355
+ else if (resolvedSelector === "$document")
9356
+ return [win.document];
9357
+ else if (resolvedSelector === "$this")
9358
+ resolvedElements = applyRoot(this).filter((el) => el instanceof HTMLElement);
9359
+ else {
9360
+ if (r === "shadow")
9361
+ resolvedElements = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9362
+ else if (r === "light")
9363
+ resolvedElements = Array.from(this.querySelectorAll(resolvedSelector));
9364
+ else if (r === "all") {
9365
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9366
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9367
+ resolvedElements = [...sNodes, ...lNodes];
9368
+ } else
9369
+ resolvedElements = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9370
+ }
9297
9371
  }
9298
- const root = this.shadowRoot || this;
9299
- return Array.from(root.querySelectorAll(selector));
9372
+ if (optionsOrPropertyKey?.filter) {
9373
+ resolvedElements = resolvedElements.filter((el) => {
9374
+ if (!(el instanceof win.HTMLElement))
9375
+ return true;
9376
+ return optionsOrPropertyKey.filter(el, { currentThis: this, helper: hostSet });
9377
+ });
9378
+ }
9379
+ return resolvedElements;
9300
9380
  },
9301
9381
  set(nv) {
9302
9382
  ensureInit(this);
9303
9383
  if (nv === null || nv === void 0 || Array.isArray(nv) && nv.length === 0) {
9304
- const selector = selectorOrTarget;
9305
- if (selector.startsWith("$") && selector !== "$this")
9384
+ const config = getElementConfig(this);
9385
+ const win = config?.window || window;
9386
+ const hostSet = SwcUtils.getHelperAndHostSet(win, this);
9387
+ if (typeof selectorOrTarget === "function") {
9388
+ const result = selectorOrTarget(this, hostSet);
9389
+ if (result instanceof win.NodeList) {
9390
+ Array.from(result).forEach((el) => {
9391
+ if (el instanceof win.Element)
9392
+ el.remove();
9393
+ });
9394
+ } else if (Array.isArray(result)) {
9395
+ result.forEach((el) => {
9396
+ if (el instanceof win.Element)
9397
+ el.remove();
9398
+ });
9399
+ }
9400
+ return;
9401
+ }
9402
+ const resolvedSelector = selectorOrTarget;
9403
+ if (resolvedSelector.startsWith("$") && resolvedSelector !== "$this")
9306
9404
  return;
9307
9405
  const r = optionsOrPropertyKey?.root || "auto";
9308
9406
  let targets = [];
9309
9407
  if (r === "shadow")
9310
- targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9408
+ targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9311
9409
  else if (r === "light")
9312
- targets = Array.from(this.querySelectorAll(selector));
9410
+ targets = Array.from(this.querySelectorAll(resolvedSelector));
9313
9411
  else if (r === "all") {
9314
- const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
9315
- const lNodes = Array.from(this.querySelectorAll(selector));
9412
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(resolvedSelector)) : [];
9413
+ const lNodes = Array.from(this.querySelectorAll(resolvedSelector));
9316
9414
  targets = [...sNodes, ...lNodes];
9317
9415
  } else {
9318
- targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));
9416
+ targets = Array.from((this.shadowRoot || this).querySelectorAll(resolvedSelector));
9319
9417
  }
9320
9418
  targets.forEach((t) => t.remove());
9321
9419
  }
@@ -9515,6 +9613,27 @@ var resolvePropertyTargets = (inst, selector, options) => {
9515
9613
  const currentWin = conf.window;
9516
9614
  const r = options.root || "auto";
9517
9615
  const results = [];
9616
+ let resolvedSelector = selector;
9617
+ if (typeof selector === "function") {
9618
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
9619
+ resolvedSelector = selector(inst, hostSet);
9620
+ }
9621
+ if (resolvedSelector instanceof currentWin.Element) {
9622
+ results.push(resolvedSelector);
9623
+ return results;
9624
+ }
9625
+ if (resolvedSelector instanceof currentWin.NodeList) {
9626
+ results.push(...Array.from(resolvedSelector));
9627
+ return results;
9628
+ }
9629
+ if (Array.isArray(resolvedSelector)) {
9630
+ results.push(...resolvedSelector);
9631
+ return results;
9632
+ }
9633
+ if (resolvedSelector === null) {
9634
+ return results;
9635
+ }
9636
+ const stringSelector = resolvedSelector;
9518
9637
  const applyRoot = (target) => {
9519
9638
  if (!target) return;
9520
9639
  if (r === "auto") {
@@ -9524,37 +9643,37 @@ var resolvePropertyTargets = (inst, selector, options) => {
9524
9643
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
9525
9644
  }
9526
9645
  };
9527
- if (selector === "$this" || !selector) {
9646
+ if (stringSelector === "$this" || !stringSelector) {
9528
9647
  applyRoot(inst);
9529
- } else if (selector === "$window") {
9648
+ } else if (stringSelector === "$window") {
9530
9649
  results.push(currentWin);
9531
- } else if (selector === "$document") {
9650
+ } else if (stringSelector === "$document") {
9532
9651
  results.push(currentWin.document);
9533
9652
  } else {
9534
9653
  const hostSet = SwcUtils.getHostSet(inst);
9535
- if (selector === "$host") applyRoot(hostSet.$host);
9536
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
9537
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
9538
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
9539
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
9540
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9541
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9542
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9543
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9654
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
9655
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
9656
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
9657
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
9658
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
9659
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
9660
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
9661
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
9662
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
9544
9663
  else {
9545
9664
  if (r === "shadow") {
9546
- const found = inst.shadowRoot?.querySelectorAll(selector);
9665
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
9547
9666
  if (found) results.push(...found);
9548
9667
  } else if (r === "light") {
9549
- const found = inst.querySelectorAll(selector);
9668
+ const found = inst.querySelectorAll(stringSelector);
9550
9669
  if (found) results.push(...found);
9551
9670
  } else if (r === "all") {
9552
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
9553
- const lMatch = inst.querySelectorAll(selector);
9671
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
9672
+ const lMatch = inst.querySelectorAll(stringSelector);
9554
9673
  if (sMatch) results.push(...sMatch);
9555
9674
  if (lMatch) results.push(...lMatch);
9556
9675
  } else {
9557
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
9676
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
9558
9677
  if (found) results.push(...found);
9559
9678
  }
9560
9679
  }
@@ -9919,10 +10038,10 @@ var elementDefine = (name, config = {}) => (constructor) => {
9919
10038
  }
9920
10039
  const conf = getElementConfig(this);
9921
10040
  const currentWin = this._resolveWindow(conf);
9922
- const bMethods = findAllOnConnectedBeforeMetadata(this).filter((it) => useSsr ? !it.options.ssrFirst : true);
10041
+ const bMethods = findAllOnConnectedBeforeMetadata(this);
9923
10042
  for (const m of bMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
9924
10043
  this._executeSwcScript("swc-on-before-connected", helperHostSet);
9925
- const targetConnectedList = findAllOnConnectedMetadata(constructor).filter((it) => useSsr ? !it.options.ssrFirst : true);
10044
+ const targetConnectedList = useSsr ? [] : findAllOnConnectedMetadata(constructor);
9926
10045
  const shadowMode = conf?.useShadow || targetConnectedList.find((it) => it.options.useShadow)?.options.useShadow;
9927
10046
  if (shadowMode && !this.shadowRoot) {
9928
10047
  const mode = shadowMode === true ? "open" : shadowMode;
@@ -9979,7 +10098,8 @@ var elementDefine = (name, config = {}) => (constructor) => {
9979
10098
  const delegateListeners = [];
9980
10099
  const nonDelegateListeners = [];
9981
10100
  addEventListenerList.forEach((meta) => {
9982
- if (meta.options.delegate && 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 !== "") {
10101
+ const isStringSelector = typeof meta.selector === "string";
10102
+ 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
10103
  delegateListeners.push(meta);
9984
10104
  } else {
9985
10105
  nonDelegateListeners.push(meta);
@@ -10015,7 +10135,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
10015
10135
  const unifiedHandler = async (event2) => {
10016
10136
  for (const meta of sortedMetaList) {
10017
10137
  const { selector, options } = meta;
10018
- const matchedEl = event2.target.closest(selector);
10138
+ const matchedEl = event2.target?.closest(selector);
10019
10139
  if (matchedEl && br.contains(matchedEl)) {
10020
10140
  if (options.filter) {
10021
10141
  const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
@@ -10042,6 +10162,22 @@ var elementDefine = (name, config = {}) => (constructor) => {
10042
10162
  const opts = { capture: options.capture, once: options.once, passive: options.passive };
10043
10163
  const bindTargets = [];
10044
10164
  const r = options.root || "auto";
10165
+ let resolvedSelector = null;
10166
+ if (typeof selector === "function") {
10167
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
10168
+ const result = selector(this, hostSet);
10169
+ if (typeof result === "string") {
10170
+ resolvedSelector = result;
10171
+ } else if (result instanceof currentWin.Element) {
10172
+ bindTargets.push(result);
10173
+ } else if (result instanceof currentWin.NodeList) {
10174
+ bindTargets.push(...Array.from(result));
10175
+ } else if (Array.isArray(result)) {
10176
+ bindTargets.push(...result);
10177
+ }
10178
+ } else {
10179
+ resolvedSelector = selector;
10180
+ }
10045
10181
  const applyRootOption = (target) => {
10046
10182
  if (!target) return;
10047
10183
  if (r === "auto") {
@@ -10051,30 +10187,32 @@ var elementDefine = (name, config = {}) => (constructor) => {
10051
10187
  if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
10052
10188
  }
10053
10189
  };
10054
- if (selector === "$window") bindTargets.push(currentWin);
10055
- else if (selector === "$document") bindTargets.push(currentWin.document);
10056
- else if (selector === "$host") applyRootOption(helperHostSet.$host);
10057
- else if (selector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
10058
- else if (selector === "$appHost") applyRootOption(helperHostSet.$appHost);
10059
- else if (selector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
10060
- else if (selector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
10061
- else if (selector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
10062
- else if (selector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
10063
- else if (selector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
10064
- else if (selector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
10065
- else if (selector === "$this" || !selector) applyRootOption(this);
10066
- else {
10067
- const searchRoots = [];
10068
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
10069
- else if (r === "light") searchRoots.push(this);
10070
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
10071
- else if (r === "all") {
10072
- searchRoots.push(this);
10073
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10190
+ if (resolvedSelector) {
10191
+ if (resolvedSelector === "$window") bindTargets.push(currentWin);
10192
+ else if (resolvedSelector === "$document") bindTargets.push(currentWin.document);
10193
+ else if (resolvedSelector === "$host") applyRootOption(helperHostSet.$host);
10194
+ else if (resolvedSelector === "$parentHost") applyRootOption(helperHostSet.$parentHost);
10195
+ else if (resolvedSelector === "$appHost") applyRootOption(helperHostSet.$appHost);
10196
+ else if (resolvedSelector === "$firstHost") applyRootOption(helperHostSet.$firstHost);
10197
+ else if (resolvedSelector === "$lastHost") applyRootOption(helperHostSet.$lastHost);
10198
+ else if (resolvedSelector === "$firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
10199
+ else if (resolvedSelector === "$lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
10200
+ else if (resolvedSelector === "$hosts") helperHostSet.$hosts.forEach(applyRootOption);
10201
+ else if (resolvedSelector === "$appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
10202
+ else if (resolvedSelector === "$this" || !resolvedSelector) applyRootOption(this);
10203
+ else {
10204
+ const searchRoots = [];
10205
+ if (r === "auto") searchRoots.push(this.shadowRoot || this);
10206
+ else if (r === "light") searchRoots.push(this);
10207
+ else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
10208
+ else if (r === "all") {
10209
+ searchRoots.push(this);
10210
+ if (this.shadowRoot) searchRoots.push(this.shadowRoot);
10211
+ }
10212
+ searchRoots.forEach((sr) => {
10213
+ sr.querySelectorAll(resolvedSelector).forEach((el) => bindTargets.push(el));
10214
+ });
10074
10215
  }
10075
- searchRoots.forEach((sr) => {
10076
- sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
10077
- });
10078
10216
  }
10079
10217
  bindTargets.forEach((t) => {
10080
10218
  const handler = async (event2) => {
@@ -10089,7 +10227,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
10089
10227
  if (options.preventDefault) event2.preventDefault();
10090
10228
  const currentHostSet = SwcUtils.getHostSet(this);
10091
10229
  const args = { event: event2, ...currentHostSet, $el: t, $root: t };
10092
- await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
10230
+ await this[meta.propertyKey](event2, { currentHostSet, $matchedElement: event2.currentTarget }, args);
10093
10231
  };
10094
10232
  const eventSubject = new Subject();
10095
10233
  let eventStream = eventSubject;
@@ -10120,9 +10258,7 @@ var elementDefine = (name, config = {}) => (constructor) => {
10120
10258
  });
10121
10259
  });
10122
10260
  if (originalConnected) await originalConnected.apply(this);
10123
- const aMethods = findAllOnConnectedAfterMetadata(this).filter((it) => {
10124
- return useSsr ? !it.options.ssrFirst : true;
10125
- });
10261
+ const aMethods = findAllOnConnectedAfterMetadata(this);
10126
10262
  for (const m of aMethods) await this._invokeLifecycleMethod(m.propertyKey, helperHostSet);
10127
10263
  this._executeSwcScript("swc-on-connected", helperHostSet);
10128
10264
  this._executeSwcScript("swc-on-after-connected", helperHostSet);
@@ -10288,6 +10424,27 @@ var resolveAttributeTargets = (inst, selector, options) => {
10288
10424
  const currentWin = conf.window;
10289
10425
  const r = options.root || "auto";
10290
10426
  const results = [];
10427
+ let resolvedSelector = selector;
10428
+ if (typeof selector === "function") {
10429
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
10430
+ resolvedSelector = selector(inst, hostSet);
10431
+ }
10432
+ if (resolvedSelector instanceof currentWin.Element) {
10433
+ results.push(resolvedSelector);
10434
+ return results;
10435
+ }
10436
+ if (resolvedSelector instanceof currentWin.NodeList) {
10437
+ results.push(...Array.from(resolvedSelector));
10438
+ return results;
10439
+ }
10440
+ if (Array.isArray(resolvedSelector)) {
10441
+ results.push(...resolvedSelector);
10442
+ return results;
10443
+ }
10444
+ if (resolvedSelector === null) {
10445
+ return results;
10446
+ }
10447
+ const stringSelector = resolvedSelector;
10291
10448
  const applyRoot = (target) => {
10292
10449
  if (!target) return;
10293
10450
  if (r === "auto") {
@@ -10297,33 +10454,33 @@ var resolveAttributeTargets = (inst, selector, options) => {
10297
10454
  if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
10298
10455
  }
10299
10456
  };
10300
- if (selector === "$this" || !selector) {
10457
+ if (stringSelector === "$this" || !stringSelector) {
10301
10458
  applyRoot(inst);
10302
10459
  } else {
10303
10460
  const hostSet = SwcUtils.getHostSet(inst);
10304
- if (selector === "$host") applyRoot(hostSet.$host);
10305
- else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
10306
- else if (selector === "$appHost") applyRoot(hostSet.$appHost);
10307
- else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
10308
- else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
10309
- else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10310
- else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10311
- else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10312
- else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10461
+ if (stringSelector === "$host") applyRoot(hostSet.$host);
10462
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
10463
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
10464
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
10465
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
10466
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10467
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10468
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10469
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10313
10470
  else {
10314
10471
  if (r === "shadow") {
10315
- const found = inst.shadowRoot?.querySelectorAll(selector);
10472
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
10316
10473
  if (found) results.push(...found);
10317
10474
  } else if (r === "light") {
10318
- const found = inst.querySelectorAll(selector);
10475
+ const found = inst.querySelectorAll(stringSelector);
10319
10476
  if (found) results.push(...found);
10320
10477
  } else if (r === "all") {
10321
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
10322
- const lMatch = inst.querySelectorAll(selector);
10478
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
10479
+ const lMatch = inst.querySelectorAll(stringSelector);
10323
10480
  if (sMatch) results.push(...sMatch);
10324
10481
  if (lMatch) results.push(...lMatch);
10325
10482
  } else {
10326
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
10483
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
10327
10484
  if (found) results.push(...found);
10328
10485
  }
10329
10486
  }
@@ -10462,6 +10619,26 @@ var findAllAttributeApplyMetadata = (target) => {
10462
10619
 
10463
10620
  // src/decorators/applyNode.ts
10464
10621
  var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
10622
+ var resolveSelector = (selector, inst, win) => {
10623
+ if (typeof selector === "function") {
10624
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10625
+ const result = selector(inst, hostSet);
10626
+ if (result instanceof win.Element) {
10627
+ return result;
10628
+ }
10629
+ if (result instanceof win.NodeList) {
10630
+ return result.length > 0 ? result[0] : null;
10631
+ }
10632
+ if (Array.isArray(result)) {
10633
+ return result.length > 0 ? result[0] : null;
10634
+ }
10635
+ if (result === null) {
10636
+ return null;
10637
+ }
10638
+ return result;
10639
+ }
10640
+ return selector;
10641
+ };
10465
10642
  var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10466
10643
  if (!targetEl) return;
10467
10644
  if (pos === "clearChildren") {
@@ -10472,7 +10649,9 @@ var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10472
10649
  const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
10473
10650
  const id = currentThis._swcId;
10474
10651
  const nodes = [];
10475
- if (typeof res === "string" && pos === "innerHtml") {
10652
+ if (res instanceof win.Node) {
10653
+ nodes.push(res);
10654
+ } else if (typeof res === "string" && pos === "innerHtml") {
10476
10655
  const t = win.document.createElement("template");
10477
10656
  t.innerHTML = res;
10478
10657
  nodes.push(...Array.from(t.content.childNodes));
@@ -10506,7 +10685,7 @@ var applyToDom = (currentThis, targetEl, res, pos, win, host) => {
10506
10685
  function applyNode(selectorOrOptions, maybeOptions) {
10507
10686
  let selector;
10508
10687
  let options;
10509
- if (typeof selectorOrOptions === "string") {
10688
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10510
10689
  selector = selectorOrOptions;
10511
10690
  options = maybeOptions || { position: "replaceChildren" };
10512
10691
  } else {
@@ -10538,14 +10717,22 @@ function applyNode(selectorOrOptions, maybeOptions) {
10538
10717
  if (r === "all") return t.shadowRoot || t;
10539
10718
  return t;
10540
10719
  };
10541
- if (selector === "$this") return applyRoot(this);
10542
- if (selector === "$host") return applyRoot(hostSet.$host);
10543
- if (selector === "$parentHost") return applyRoot(hostSet.$parentHost);
10544
- if (selector === "$appHost") return applyRoot(hostSet.$appHost);
10545
- if (selector === "$firstHost") return applyRoot(hostSet.$firstHost);
10546
- if (selector === "$lastHost") return applyRoot(hostSet.$lastHost);
10720
+ const resolved = resolveSelector(selector, this, currentWin);
10721
+ if (resolved instanceof currentWin.Element) {
10722
+ return applyRoot(resolved);
10723
+ }
10724
+ if (resolved === null) {
10725
+ return null;
10726
+ }
10727
+ const stringSelector = resolved;
10728
+ if (stringSelector === "$this") return applyRoot(this);
10729
+ if (stringSelector === "$host") return applyRoot(hostSet.$host);
10730
+ if (stringSelector === "$parentHost") return applyRoot(hostSet.$parentHost);
10731
+ if (stringSelector === "$appHost") return applyRoot(hostSet.$appHost);
10732
+ if (stringSelector === "$firstHost") return applyRoot(hostSet.$firstHost);
10733
+ if (stringSelector === "$lastHost") return applyRoot(hostSet.$lastHost);
10547
10734
  const targetRoot = applyRoot(this);
10548
- return targetRoot ? targetRoot.querySelector(selector) : null;
10735
+ return targetRoot ? targetRoot.querySelector(stringSelector) : null;
10549
10736
  };
10550
10737
  const targetEl = getTarget();
10551
10738
  const res = original.apply(this, args);
@@ -10587,7 +10774,7 @@ function replaceChildren(selectorOrOptions, maybeOptions, descriptor) {
10587
10774
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10588
10775
  return applyNode({ position: "replaceChildren" })(selectorOrOptions, maybeOptions, descriptor);
10589
10776
  }
10590
- if (typeof selectorOrOptions === "string") {
10777
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10591
10778
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren" });
10592
10779
  }
10593
10780
  return applyNode({ ...selectorOrOptions, position: "replaceChildren" });
@@ -10596,7 +10783,7 @@ function clearChildrenNode(selectorOrOptions, maybeOptions, descriptor) {
10596
10783
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10597
10784
  return applyNode({ position: "clearChildren" })(selectorOrOptions, maybeOptions, descriptor);
10598
10785
  }
10599
- if (typeof selectorOrOptions === "string") {
10786
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10600
10787
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren" });
10601
10788
  }
10602
10789
  return applyNode({ ...selectorOrOptions, position: "clearChildren" });
@@ -10606,7 +10793,7 @@ function innerHtml(selectorOrOptions, maybeOptions, descriptor) {
10606
10793
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10607
10794
  return applyNode({ position: "innerHtml" })(selectorOrOptions, maybeOptions, descriptor);
10608
10795
  }
10609
- if (typeof selectorOrOptions === "string") {
10796
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10610
10797
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml" });
10611
10798
  }
10612
10799
  return applyNode({ ...selectorOrOptions, position: "innerHtml" });
@@ -10615,7 +10802,7 @@ function innerHtmlLight(selectorOrOptions, maybeOptions, descriptor) {
10615
10802
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10616
10803
  return applyNode({ position: "innerHtml", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10617
10804
  }
10618
- if (typeof selectorOrOptions === "string") {
10805
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10619
10806
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "light" });
10620
10807
  }
10621
10808
  return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "light" });
@@ -10624,7 +10811,7 @@ function innerHtmlShadow(selectorOrOptions, maybeOptions, descriptor) {
10624
10811
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10625
10812
  return applyNode({ position: "innerHtml", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10626
10813
  }
10627
- if (typeof selectorOrOptions === "string") {
10814
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10628
10815
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerHtml", root: "shadow" });
10629
10816
  }
10630
10817
  return applyNode({ ...selectorOrOptions, position: "innerHtml", root: "shadow" });
@@ -10633,7 +10820,7 @@ function innerText(selectorOrOptions, maybeOptions, descriptor) {
10633
10820
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10634
10821
  return applyNode({ position: "innerText" })(selectorOrOptions, maybeOptions, descriptor);
10635
10822
  }
10636
- if (typeof selectorOrOptions === "string") {
10823
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10637
10824
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText" });
10638
10825
  }
10639
10826
  return applyNode({ ...selectorOrOptions, position: "innerText" });
@@ -10642,7 +10829,7 @@ function innerTextLight(selectorOrOptions, maybeOptions, descriptor) {
10642
10829
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10643
10830
  return applyNode({ position: "innerText", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10644
10831
  }
10645
- if (typeof selectorOrOptions === "string") {
10832
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10646
10833
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "light" });
10647
10834
  }
10648
10835
  return applyNode({ ...selectorOrOptions, position: "innerText", root: "light" });
@@ -10651,7 +10838,7 @@ function innerTextShadow(selectorOrOptions, maybeOptions, descriptor) {
10651
10838
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10652
10839
  return applyNode({ position: "innerText", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10653
10840
  }
10654
- if (typeof selectorOrOptions === "string") {
10841
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10655
10842
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "innerText", root: "shadow" });
10656
10843
  }
10657
10844
  return applyNode({ ...selectorOrOptions, position: "innerText", root: "shadow" });
@@ -10660,7 +10847,7 @@ function insertBeforeEnd(selectorOrOptions, maybeOptions, descriptor) {
10660
10847
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10661
10848
  return applyNode({ position: "beforeEnd" })(selectorOrOptions, maybeOptions, descriptor);
10662
10849
  }
10663
- if (typeof selectorOrOptions === "string") {
10850
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10664
10851
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd" });
10665
10852
  }
10666
10853
  return applyNode({ ...selectorOrOptions, position: "beforeEnd" });
@@ -10669,7 +10856,7 @@ function insertBeforeEndLight(selectorOrOptions, maybeOptions, descriptor) {
10669
10856
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10670
10857
  return applyNode({ position: "beforeEnd", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10671
10858
  }
10672
- if (typeof selectorOrOptions === "string") {
10859
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10673
10860
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "light" });
10674
10861
  }
10675
10862
  return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "light" });
@@ -10678,7 +10865,7 @@ function insertBeforeEndShadow(selectorOrOptions, maybeOptions, descriptor) {
10678
10865
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10679
10866
  return applyNode({ position: "beforeEnd", root: "shadow" })(selectorOrOptions, maybeOptions, descriptor);
10680
10867
  }
10681
- if (typeof selectorOrOptions === "string") {
10868
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10682
10869
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "beforeEnd", root: "shadow" });
10683
10870
  }
10684
10871
  return applyNode({ ...selectorOrOptions, position: "beforeEnd", root: "shadow" });
@@ -10687,7 +10874,7 @@ function insertAfterBegin(selectorOrOptions, maybeOptions, descriptor) {
10687
10874
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10688
10875
  return applyNode({ position: "afterBegin" })(selectorOrOptions, maybeOptions, descriptor);
10689
10876
  }
10690
- if (typeof selectorOrOptions === "string") {
10877
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10691
10878
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin" });
10692
10879
  }
10693
10880
  return applyNode({ ...selectorOrOptions, position: "afterBegin" });
@@ -10696,7 +10883,7 @@ function insertAfterBeginLight(selectorOrOptions, maybeOptions, descriptor) {
10696
10883
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10697
10884
  return applyNode({ position: "afterBegin", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10698
10885
  }
10699
- if (typeof selectorOrOptions === "string") {
10886
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10700
10887
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "afterBegin", root: "light" });
10701
10888
  }
10702
10889
  return applyNode({ ...selectorOrOptions, position: "afterBegin", root: "light" });
@@ -10705,7 +10892,7 @@ function replaceChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
10705
10892
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10706
10893
  return applyNode({ position: "replaceChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10707
10894
  }
10708
- if (typeof selectorOrOptions === "string") {
10895
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10709
10896
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "replaceChildren", root: "light" });
10710
10897
  }
10711
10898
  return applyNode({ ...selectorOrOptions, position: "replaceChildren", root: "light" });
@@ -10714,7 +10901,7 @@ function clearChildrenLight(selectorOrOptions, maybeOptions, descriptor) {
10714
10901
  if (descriptor !== void 0 && (typeof maybeOptions === "symbol" || typeof maybeOptions === "string")) {
10715
10902
  return applyNode({ position: "clearChildren", root: "light" })(selectorOrOptions, maybeOptions, descriptor);
10716
10903
  }
10717
- if (typeof selectorOrOptions === "string") {
10904
+ if (typeof selectorOrOptions === "string" || typeof selectorOrOptions === "function") {
10718
10905
  return applyNode(selectorOrOptions, { ...maybeOptions, position: "clearChildren", root: "light" });
10719
10906
  }
10720
10907
  return applyNode({ ...selectorOrOptions, position: "clearChildren", root: "light" });
@@ -10732,6 +10919,58 @@ var findAllApplyNodeMetadata = (target) => {
10732
10919
 
10733
10920
  // src/decorators/applyClass.ts
10734
10921
  var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
10922
+ var resolveSelector2 = (selector, inst, win) => {
10923
+ if (typeof selector === "function") {
10924
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10925
+ const result = selector(inst, hostSet);
10926
+ if (result instanceof win.Element) {
10927
+ return [result];
10928
+ }
10929
+ if (result instanceof win.NodeList) {
10930
+ return Array.from(result);
10931
+ }
10932
+ if (Array.isArray(result)) {
10933
+ return result;
10934
+ }
10935
+ if (result === null) {
10936
+ return [];
10937
+ }
10938
+ return result;
10939
+ }
10940
+ return selector;
10941
+ };
10942
+ var getTargetElements = (selector, inst, win, root) => {
10943
+ const resolved = resolveSelector2(selector, inst, win);
10944
+ if (Array.isArray(resolved)) {
10945
+ return resolved;
10946
+ }
10947
+ const stringSelector = resolved;
10948
+ const targetEls = [];
10949
+ const host = inst;
10950
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
10951
+ const applyRoot = (t) => {
10952
+ if (!t || !(t instanceof win.HTMLElement)) return;
10953
+ targetEls.push(t);
10954
+ };
10955
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
10956
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
10957
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
10958
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
10959
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
10960
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
10961
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
10962
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
10963
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
10964
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
10965
+ else {
10966
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
10967
+ if (targetRoot) {
10968
+ const found = targetRoot.querySelectorAll(stringSelector);
10969
+ if (found) targetEls.push(...Array.from(found));
10970
+ }
10971
+ }
10972
+ return targetEls;
10973
+ };
10735
10974
  function createClassDecorator(action) {
10736
10975
  return (selector, classMapOrOptions, options = {}) => {
10737
10976
  return (target, propertyKey, descriptor) => {
@@ -10766,28 +11005,7 @@ function createClassDecorator(action) {
10766
11005
  const host = this;
10767
11006
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
10768
11007
  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
- }
11008
+ const targetEls = getTargetElements(selector, this, win, r);
10791
11009
  targetEls.forEach((targetEl) => {
10792
11010
  if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
10793
11011
  return;
@@ -10919,6 +11137,58 @@ var findAllClassMetadata = (target) => {
10919
11137
 
10920
11138
  // src/decorators/applyStyle.ts
10921
11139
  var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
11140
+ var resolveSelector3 = (selector, inst, win) => {
11141
+ if (typeof selector === "function") {
11142
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11143
+ const result = selector(inst, hostSet);
11144
+ if (result instanceof win.Element) {
11145
+ return [result];
11146
+ }
11147
+ if (result instanceof win.NodeList) {
11148
+ return Array.from(result);
11149
+ }
11150
+ if (Array.isArray(result)) {
11151
+ return result;
11152
+ }
11153
+ if (result === null) {
11154
+ return [];
11155
+ }
11156
+ return result;
11157
+ }
11158
+ return selector;
11159
+ };
11160
+ var getTargetElements2 = (selector, inst, win, root) => {
11161
+ const resolved = resolveSelector3(selector, inst, win);
11162
+ if (Array.isArray(resolved)) {
11163
+ return resolved;
11164
+ }
11165
+ const stringSelector = resolved;
11166
+ const targetEls = [];
11167
+ const host = inst;
11168
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
11169
+ const applyRoot = (t) => {
11170
+ if (!t || !(t instanceof win.HTMLElement)) return;
11171
+ targetEls.push(t);
11172
+ };
11173
+ if (stringSelector === "$this" || !stringSelector) applyRoot(host);
11174
+ else if (stringSelector === "$host") applyRoot(hostSet.$host);
11175
+ else if (stringSelector === "$parentHost") applyRoot(hostSet.$parentHost);
11176
+ else if (stringSelector === "$appHost") applyRoot(hostSet.$appHost);
11177
+ else if (stringSelector === "$firstHost") applyRoot(hostSet.$firstHost);
11178
+ else if (stringSelector === "$lastHost") applyRoot(hostSet.$lastHost);
11179
+ else if (stringSelector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
11180
+ else if (stringSelector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
11181
+ else if (stringSelector === "$hosts") hostSet.$hosts.forEach(applyRoot);
11182
+ else if (stringSelector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
11183
+ else {
11184
+ const targetRoot = root === "auto" ? host.shadowRoot || host : root === "shadow" ? host.shadowRoot : host;
11185
+ if (targetRoot) {
11186
+ const found = targetRoot.querySelectorAll(stringSelector);
11187
+ if (found) targetEls.push(...Array.from(found));
11188
+ }
11189
+ }
11190
+ return targetEls;
11191
+ };
10922
11192
  function createStyleDecorator(action) {
10923
11193
  return (selector, options = {}) => {
10924
11194
  return (target, propertyKey, descriptor) => {
@@ -10946,28 +11216,7 @@ function createStyleDecorator(action) {
10946
11216
  const host = this;
10947
11217
  const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };
10948
11218
  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
- }
11219
+ const targetEls = getTargetElements2(selector, this, win, r);
10971
11220
  targetEls.forEach((targetEl) => {
10972
11221
  if (options.filter && !options.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
10973
11222
  return;
@@ -11891,7 +12140,7 @@ var SimstanceManager = class _SimstanceManager {
11891
12140
  otherStorage,
11892
12141
  newInstanceCarrier
11893
12142
  });
11894
- const r = ValidUtils.isFunction(target) && !target.prototype ? target(...parameters) : new target(...parameters);
12143
+ const r = ValidUtils.isFunctionType(target) && !target.prototype ? target(...parameters) : new target(...parameters);
11895
12144
  let p = this.proxy(r);
11896
12145
  const config = getSim(target);
11897
12146
  if (config?.proxy) {
@@ -12047,7 +12296,7 @@ var SimstanceManager = class _SimstanceManager {
12047
12296
  }
12048
12297
  }
12049
12298
  if (inject.proxy && obj) {
12050
- if (ValidUtils.isConstructor(inject.proxy)) {
12299
+ if (ValidUtils.isClassType(inject.proxy)) {
12051
12300
  const handler = getSim(inject.proxy) ? this.getOrNewSim({ target: inject.proxy }) : new inject.proxy();
12052
12301
  if (handler) {
12053
12302
  obj = new Proxy(obj, handler);
@@ -13626,7 +13875,8 @@ function SwcAppMixin(Base) {
13626
13875
  }
13627
13876
  }
13628
13877
  } finally {
13629
- if (this.config?.ssr) {
13878
+ const isBrowser = ValidUtils2.isBrowser();
13879
+ if (!isBrowser && this.config?.ssr) {
13630
13880
  setSSRAttribute(instance);
13631
13881
  } else {
13632
13882
  removeSSRAttribute(instance);
@@ -13671,7 +13921,9 @@ function SwcAppMixin(Base) {
13671
13921
  throw e;
13672
13922
  }
13673
13923
  }
13674
- if (this.config?.ssr) {
13924
+ const isBrowser = ValidUtils2.isBrowser();
13925
+ console.log("------>", isBrowser, this.config?.ssr);
13926
+ if (!isBrowser && this.config?.ssr) {
13675
13927
  setSSRAttribute(instance);
13676
13928
  } else {
13677
13929
  removeSSRAttribute(instance);
@@ -13996,8 +14248,8 @@ export {
13996
14248
  ON_BEFORE_ADOPTED_METADATA_KEY,
13997
14249
  ON_BEFORE_CONNECTED_METADATA_KEY,
13998
14250
  ON_BEFORE_DISCONNECTED_METADATA_KEY,
14251
+ ON_CONNECTED_BODY_METADATA_KEY,
13999
14252
  ON_CONNECTED_COMPLETED_METADATA_KEY,
14000
- ON_CONNECTED_METADATA_KEY,
14001
14253
  ON_CONNECTED_SWC_APP_METADATA_KEY,
14002
14254
  ON_INITIALIZE_METADATA_KEY,
14003
14255
  PROPERTY_METADATA_KEY,
@@ -14123,12 +14375,12 @@ export {
14123
14375
  onAdopted,
14124
14376
  onAdoptedAfter,
14125
14377
  onAdoptedBefore,
14126
- onConnected,
14127
14378
  onConnectedAfter,
14128
14379
  onConnectedBefore,
14380
+ onConnectedBody,
14381
+ onConnectedBodyLight,
14382
+ onConnectedBodyShadow,
14129
14383
  onConnectedCompleted,
14130
- onConnectedLight,
14131
- onConnectedShadow,
14132
14384
  onConnectedSwcApp,
14133
14385
  onDisconnected,
14134
14386
  onDisconnectedAfter,