@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.
Files changed (75) 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 +51 -23
  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 +44 -25
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/emitCustomEvent.js +61 -47
  16. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  17. package/dist/cjs/decorators/query.js +91 -56
  18. package/dist/cjs/decorators/query.js.map +2 -2
  19. package/dist/cjs/decorators/queryAll.js +104 -66
  20. package/dist/cjs/decorators/queryAll.js.map +2 -2
  21. package/dist/cjs/types/window.d.js.map +1 -1
  22. package/dist/esm/decorators/addEventListener.js.map +2 -2
  23. package/dist/esm/decorators/applyAttribute.js +36 -15
  24. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  25. package/dist/esm/decorators/applyClass.js +53 -22
  26. package/dist/esm/decorators/applyClass.js.map +2 -2
  27. package/dist/esm/decorators/applyNode.js +51 -23
  28. package/dist/esm/decorators/applyNode.js.map +2 -2
  29. package/dist/esm/decorators/applyProperty.js +38 -17
  30. package/dist/esm/decorators/applyProperty.js.map +2 -2
  31. package/dist/esm/decorators/applyStyle.js +53 -22
  32. package/dist/esm/decorators/applyStyle.js.map +2 -2
  33. package/dist/esm/decorators/elementDefine.js +44 -25
  34. package/dist/esm/decorators/elementDefine.js.map +2 -2
  35. package/dist/esm/decorators/emitCustomEvent.js +61 -47
  36. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  37. package/dist/esm/decorators/query.js +91 -56
  38. package/dist/esm/decorators/query.js.map +2 -2
  39. package/dist/esm/decorators/queryAll.js +104 -66
  40. package/dist/esm/decorators/queryAll.js.map +2 -2
  41. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +531 -293
  42. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  43. package/dist/types/decorators/addEventListener.d.ts +7 -6
  44. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  45. package/dist/types/decorators/applyAttribute.d.ts +12 -8
  46. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  47. package/dist/types/decorators/applyClass.d.ts +8 -7
  48. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  49. package/dist/types/decorators/applyNode.d.ts +18 -17
  50. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  51. package/dist/types/decorators/applyProperty.d.ts +13 -9
  52. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  53. package/dist/types/decorators/applyStyle.d.ts +6 -5
  54. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  55. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  56. package/dist/types/decorators/emitCustomEvent.d.ts +3 -2
  57. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  58. package/dist/types/decorators/query.d.ts +15 -5
  59. package/dist/types/decorators/query.d.ts.map +1 -1
  60. package/dist/types/decorators/queryAll.d.ts +15 -5
  61. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  62. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +531 -293
  63. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  64. package/package.json +3 -3
  65. package/src/decorators/addEventListener.ts +9 -7
  66. package/src/decorators/applyAttribute.ts +59 -27
  67. package/src/decorators/applyClass.ts +78 -32
  68. package/src/decorators/applyNode.ts +115 -72
  69. package/src/decorators/applyProperty.ts +62 -30
  70. package/src/decorators/applyStyle.ts +76 -30
  71. package/src/decorators/elementDefine.ts +49 -26
  72. package/src/decorators/emitCustomEvent.ts +63 -39
  73. package/src/decorators/query.ts +111 -49
  74. package/src/decorators/queryAll.ts +121 -61
  75. package/src/types/window.d.ts +3 -0
@@ -15,6 +15,8 @@ import {ElementApply} from "@dooboostore/core-web";
15
15
  */
16
16
  export type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove' | 'clearChildren';
17
17
 
18
+ export type ApplyNodeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);
19
+
18
20
  export interface ApplyNodeOptions {
19
21
  position?: ApplyNodePosition;
20
22
  root?: SwcRootType;
@@ -37,12 +39,39 @@ export interface ApplyNodeOptions {
37
39
 
38
40
  export interface ApplyNodeMetadata {
39
41
  propertyKey: string | symbol;
40
- selector: string;
42
+ selector: ApplyNodeSelector;
41
43
  options: ApplyNodeOptions;
42
44
  }
43
45
 
44
46
  export const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');
45
47
 
48
+ /**
49
+ * Resolve selector to string or elements
50
+ * Handles function-based selectors and returns elements if applicable
51
+ */
52
+ const resolveSelector = (selector: ApplyNodeSelector, inst: any, win: Window): string | HTMLElement | null => {
53
+ if (typeof selector === 'function') {
54
+ const hostSet = SwcUtils.getHelperAndHostSet(win, inst);
55
+ const result = selector(inst, hostSet);
56
+
57
+ if (result instanceof win.Element) {
58
+ return result as HTMLElement;
59
+ }
60
+ if (result instanceof win.NodeList) {
61
+ return result.length > 0 ? (result[0] as HTMLElement) : null;
62
+ }
63
+ if (Array.isArray(result)) {
64
+ return result.length > 0 ? (result[0] as HTMLElement) : null;
65
+ }
66
+ if (result === null) {
67
+ return null;
68
+ }
69
+ // result must be a string at this point
70
+ return result as unknown as string;
71
+ }
72
+ return selector as string;
73
+ };
74
+
46
75
  // const normalizeNodes = (res: any, doc: Document): Node[] => {
47
76
  // const items = Array.isArray(res) ? res : [res];
48
77
  // return items.map(it => {
@@ -110,14 +139,14 @@ const applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string,
110
139
  * - applyNode(selector, options) - Apply to specific selector
111
140
  * - applyNode(options) - Apply to $this (current element)
112
141
  */
113
- export function applyNode(selector: string, options?: ApplyNodeOptions): MethodDecorator;
142
+ export function applyNode(selector: ApplyNodeSelector, options?: ApplyNodeOptions): MethodDecorator;
114
143
  export function applyNode(options: ApplyNodeOptions): MethodDecorator;
115
- export function applyNode(selectorOrOptions: string | ApplyNodeOptions, maybeOptions?: ApplyNodeOptions): MethodDecorator {
144
+ export function applyNode(selectorOrOptions: ApplyNodeSelector | ApplyNodeOptions, maybeOptions?: ApplyNodeOptions): MethodDecorator {
116
145
  // Determine selector and options based on overload
117
- let selector: string;
146
+ let selector: ApplyNodeSelector;
118
147
  let options: ApplyNodeOptions;
119
148
 
120
- if (typeof selectorOrOptions === 'string') {
149
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
121
150
  // First overload: applyNode(selector, options)
122
151
  selector = selectorOrOptions;
123
152
  options = maybeOptions || {position: 'replaceChildren'};
@@ -156,15 +185,29 @@ export function applyNode(selectorOrOptions: string | ApplyNodeOptions, maybeOpt
156
185
  return t;
157
186
  };
158
187
 
159
- if (selector === '$this') return applyRoot(this);
160
- if (selector === '$host') return applyRoot(hostSet.$host);
161
- if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);
162
- if (selector === '$appHost') return applyRoot(hostSet.$appHost);
163
- if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);
164
- if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);
188
+ // Resolve selector if it's a function
189
+ const resolved = resolveSelector(selector, this, currentWin);
190
+
191
+ // If selector function returned an element directly, use it
192
+ if (resolved instanceof currentWin.Element) {
193
+ return applyRoot(resolved);
194
+ }
195
+ if (resolved === null) {
196
+ return null;
197
+ }
198
+
199
+ // Handle string selector
200
+ const stringSelector = resolved as string;
201
+
202
+ if (stringSelector === '$this') return applyRoot(this);
203
+ if (stringSelector === '$host') return applyRoot(hostSet.$host);
204
+ if (stringSelector === '$parentHost') return applyRoot(hostSet.$parentHost);
205
+ if (stringSelector === '$appHost') return applyRoot(hostSet.$appHost);
206
+ if (stringSelector === '$firstHost') return applyRoot(hostSet.$firstHost);
207
+ if (stringSelector === '$lastHost') return applyRoot(hostSet.$lastHost);
165
208
 
166
209
  const targetRoot = applyRoot(this);
167
- return targetRoot ? targetRoot.querySelector(selector) : null;
210
+ return targetRoot ? targetRoot.querySelector(stringSelector) : null;
168
211
  };
169
212
 
170
213
  const targetEl = getTarget();
@@ -233,17 +276,17 @@ export function applyNode(selectorOrOptions: string | ApplyNodeOptions, maybeOpt
233
276
  * - replaceChildrenNode(options) - Replace children of $this (current element)
234
277
  * - @replaceChildrenNode - Bare decorator, replaces children of $this
235
278
  */
236
- export function replaceChildren(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
279
+ export function replaceChildren(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
237
280
  export function replaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
238
281
  export function replaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
239
- export function replaceChildren(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
282
+ export function replaceChildren(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
240
283
  // Bare decorator usage: @replaceChildrenNode
241
284
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
242
285
  return applyNode({position: 'replaceChildren'})(selectorOrOptions, maybeOptions, descriptor);
243
286
  }
244
287
 
245
- if (typeof selectorOrOptions === 'string') {
246
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});
288
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
289
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});
247
290
  }
248
291
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'replaceChildren'});
249
292
  }
@@ -256,17 +299,17 @@ export function replaceChildren(selectorOrOptions?: string | Omit<ApplyNodeOptio
256
299
  * - clearChildrenNode(options) - Clear children of $this (current element)
257
300
  * - @clearChildrenNode - Bare decorator, clears children of $this
258
301
  */
259
- export function clearChildrenNode(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
302
+ export function clearChildrenNode(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
260
303
  export function clearChildrenNode(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
261
304
  export function clearChildrenNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
262
- export function clearChildrenNode(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
305
+ export function clearChildrenNode(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
263
306
  // Bare decorator usage: @clearChildrenNode
264
307
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
265
308
  return applyNode({position: 'clearChildren'})(selectorOrOptions, maybeOptions, descriptor);
266
309
  }
267
310
 
268
- if (typeof selectorOrOptions === 'string') {
269
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});
311
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
312
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});
270
313
  }
271
314
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'clearChildren'});
272
315
  }
@@ -282,17 +325,17 @@ export const clearNode = clearChildrenNode;
282
325
  * - innerHtmlNode(options) - Set innerHTML of $this (current element)
283
326
  * - @innerHtmlNode - Bare decorator, sets innerHTML of $this
284
327
  */
285
- export function innerHtml(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
328
+ export function innerHtml(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
286
329
  export function innerHtml(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
287
330
  export function innerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
288
- export function innerHtml(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
331
+ export function innerHtml(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
289
332
  // Bare decorator usage: @innerHtmlNode
290
333
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
291
334
  return applyNode({position: 'innerHtml'})(selectorOrOptions, maybeOptions, descriptor);
292
335
  }
293
336
 
294
- if (typeof selectorOrOptions === 'string') {
295
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});
337
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
338
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});
296
339
  }
297
340
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerHtml'});
298
341
  }
@@ -308,17 +351,17 @@ export function innerHtml(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'p
308
351
  * - innerHtmlLightNode(options) - Set innerHTML of $this in light DOM
309
352
  * - @innerHtmlLightNode - Bare decorator, sets innerHTML of $this in light DOM
310
353
  */
311
- export function innerHtmlLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
354
+ export function innerHtmlLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
312
355
  export function innerHtmlLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
313
356
  export function innerHtmlLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
314
- export function innerHtmlLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
357
+ export function innerHtmlLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
315
358
  // Bare decorator usage: @innerHtmlLightNode
316
359
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
317
360
  return applyNode({position: 'innerHtml', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
318
361
  }
319
362
 
320
- if (typeof selectorOrOptions === 'string') {
321
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});
363
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
364
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});
322
365
  }
323
366
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'light'});
324
367
  }
@@ -332,17 +375,17 @@ export function innerHtmlLight(selectorOrOptions?: string | Omit<ApplyNodeOption
332
375
  * - innerHtmlShadowNode(options) - Set innerHTML of $this in shadow DOM
333
376
  * - @innerHtmlShadowNode - Bare decorator, sets innerHTML of $this in shadow DOM
334
377
  */
335
- export function innerHtmlShadow(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
378
+ export function innerHtmlShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
336
379
  export function innerHtmlShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
337
380
  export function innerHtmlShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
338
- export function innerHtmlShadow(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
381
+ export function innerHtmlShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
339
382
  // Bare decorator usage: @innerHtmlShadowNode
340
383
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
341
384
  return applyNode({position: 'innerHtml', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);
342
385
  }
343
386
 
344
- if (typeof selectorOrOptions === 'string') {
345
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});
387
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
388
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});
346
389
  }
347
390
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerHtml', root: 'shadow'});
348
391
  }
@@ -356,17 +399,17 @@ export function innerHtmlShadow(selectorOrOptions?: string | Omit<ApplyNodeOptio
356
399
  * - innerTextNode(options) - Set innerText of $this (current element)
357
400
  * - @innerTextNode - Bare decorator, sets innerText of $this
358
401
  */
359
- export function innerText(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
402
+ export function innerText(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
360
403
  export function innerText(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
361
404
  export function innerText(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
362
- export function innerText(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
405
+ export function innerText(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
363
406
  // Bare decorator usage: @innerTextNode
364
407
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
365
408
  return applyNode({position: 'innerText'})(selectorOrOptions, maybeOptions, descriptor);
366
409
  }
367
410
 
368
- if (typeof selectorOrOptions === 'string') {
369
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});
411
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
412
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});
370
413
  }
371
414
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'innerText'});
372
415
  }
@@ -380,17 +423,17 @@ export function innerText(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'p
380
423
  * - innerTextLightNode(options) - Set innerText of $this in light DOM
381
424
  * - @innerTextLightNode - Bare decorator, sets innerText of $this in light DOM
382
425
  */
383
- export function innerTextLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
426
+ export function innerTextLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
384
427
  export function innerTextLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
385
428
  export function innerTextLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
386
- export function innerTextLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
429
+ export function innerTextLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
387
430
  // Bare decorator usage: @innerTextLightNode
388
431
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
389
432
  return applyNode({position: 'innerText', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
390
433
  }
391
434
 
392
- if (typeof selectorOrOptions === 'string') {
393
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});
435
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
436
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});
394
437
  }
395
438
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'light'});
396
439
  }
@@ -403,17 +446,17 @@ export function innerTextLight(selectorOrOptions?: string | Omit<ApplyNodeOption
403
446
  * - innerTextShadowNode(options) - Set innerText of $this in shadow DOM
404
447
  * - @innerTextShadowNode - Bare decorator, sets innerText of $this in shadow DOM
405
448
  */
406
- export function innerTextShadow(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
449
+ export function innerTextShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
407
450
  export function innerTextShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
408
451
  export function innerTextShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
409
- export function innerTextShadow(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
452
+ export function innerTextShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
410
453
  // Bare decorator usage: @innerTextShadowNode
411
454
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
412
455
  return applyNode({position: 'innerText', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);
413
456
  }
414
457
 
415
- if (typeof selectorOrOptions === 'string') {
416
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});
458
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
459
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});
417
460
  }
418
461
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'innerText', root: 'shadow'});
419
462
  }
@@ -426,17 +469,17 @@ export function innerTextShadow(selectorOrOptions?: string | Omit<ApplyNodeOptio
426
469
  * - beforeEndNode(options) - Append to $this (current element)
427
470
  * - @beforeEndNode - Bare decorator, appends to $this
428
471
  */
429
- export function insertBeforeEnd(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
472
+ export function insertBeforeEnd(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
430
473
  export function insertBeforeEnd(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
431
474
  export function insertBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
432
- export function insertBeforeEnd(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
475
+ export function insertBeforeEnd(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
433
476
  // Bare decorator usage: @beforeEndNode
434
477
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
435
478
  return applyNode({position: 'beforeEnd'})(selectorOrOptions, maybeOptions, descriptor);
436
479
  }
437
480
 
438
- if (typeof selectorOrOptions === 'string') {
439
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});
481
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
482
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});
440
483
  }
441
484
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'beforeEnd'});
442
485
  }
@@ -450,17 +493,17 @@ export function insertBeforeEnd(selectorOrOptions?: string | Omit<ApplyNodeOptio
450
493
  * - beforeEndLightNode(options) - Append to $this in light DOM
451
494
  * - @beforeEndLightNode - Bare decorator, appends to $this in light DOM
452
495
  */
453
- export function insertBeforeEndLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
496
+ export function insertBeforeEndLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
454
497
  export function insertBeforeEndLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
455
498
  export function insertBeforeEndLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
456
- export function insertBeforeEndLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
499
+ export function insertBeforeEndLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
457
500
  // Bare decorator usage: @beforeEndLightNode
458
501
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
459
502
  return applyNode({position: 'beforeEnd', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
460
503
  }
461
504
 
462
- if (typeof selectorOrOptions === 'string') {
463
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});
505
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
506
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});
464
507
  }
465
508
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'light'});
466
509
  }
@@ -474,17 +517,17 @@ export function insertBeforeEndLight(selectorOrOptions?: string | Omit<ApplyNode
474
517
  * - beforeEndShadowNode(options) - Append to $this in shadow DOM
475
518
  * - @beforeEndShadowNode - Bare decorator, appends to $this in shadow DOM
476
519
  */
477
- export function insertBeforeEndShadow(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
520
+ export function insertBeforeEndShadow(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
478
521
  export function insertBeforeEndShadow(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
479
522
  export function insertBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
480
- export function insertBeforeEndShadow(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
523
+ export function insertBeforeEndShadow(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
481
524
  // Bare decorator usage: @beforeEndShadowNode
482
525
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
483
526
  return applyNode({position: 'beforeEnd', root: 'shadow'})(selectorOrOptions, maybeOptions, descriptor);
484
527
  }
485
528
 
486
- if (typeof selectorOrOptions === 'string') {
487
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});
529
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
530
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});
488
531
  }
489
532
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'beforeEnd', root: 'shadow'});
490
533
  }
@@ -498,17 +541,17 @@ export function insertBeforeEndShadow(selectorOrOptions?: string | Omit<ApplyNod
498
541
  * - afterBeginNode(options) - Prepend to $this (current element)
499
542
  * - @afterBeginNode - Bare decorator, prepends to $this
500
543
  */
501
- export function insertAfterBegin(selector: string, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
544
+ export function insertAfterBegin(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
502
545
  export function insertAfterBegin(options?: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;
503
546
  export function insertAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
504
- export function insertAfterBegin(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
547
+ export function insertAfterBegin(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
505
548
  // Bare decorator usage: @afterBeginNode
506
549
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
507
550
  return applyNode({position: 'afterBegin'})(selectorOrOptions, maybeOptions, descriptor);
508
551
  }
509
552
 
510
- if (typeof selectorOrOptions === 'string') {
511
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});
553
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
554
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});
512
555
  }
513
556
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position'>, position: 'afterBegin'});
514
557
  }
@@ -522,17 +565,17 @@ export function insertAfterBegin(selectorOrOptions?: string | Omit<ApplyNodeOpti
522
565
  * - afterBeginLightNode(options) - Prepend to $this in light DOM
523
566
  * - @afterBeginLightNode - Bare decorator, prepends to $this in light DOM
524
567
  */
525
- export function insertAfterBeginLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
568
+ export function insertAfterBeginLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
526
569
  export function insertAfterBeginLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
527
570
  export function insertAfterBeginLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
528
- export function insertAfterBeginLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
571
+ export function insertAfterBeginLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
529
572
  // Bare decorator usage: @afterBeginLightNode
530
573
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
531
574
  return applyNode({position: 'afterBegin', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
532
575
  }
533
576
 
534
- if (typeof selectorOrOptions === 'string') {
535
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});
577
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
578
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});
536
579
  }
537
580
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'afterBegin', root: 'light'});
538
581
  }
@@ -546,17 +589,17 @@ export function insertAfterBeginLight(selectorOrOptions?: string | Omit<ApplyNod
546
589
  * - replaceChildrenLightNode(options) - Replace children of $this in light DOM
547
590
  * - @replaceChildrenLightNode - Bare decorator, replaces children of $this in light DOM
548
591
  */
549
- export function replaceChildrenLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
592
+ export function replaceChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
550
593
  export function replaceChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
551
594
  export function replaceChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
552
- export function replaceChildrenLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
595
+ export function replaceChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
553
596
  // Bare decorator usage: @replaceChildrenLightNode
554
597
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
555
598
  return applyNode({position: 'replaceChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
556
599
  }
557
600
 
558
- if (typeof selectorOrOptions === 'string') {
559
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});
601
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
602
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});
560
603
  }
561
604
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'replaceChildren', root: 'light'});
562
605
  }
@@ -569,17 +612,17 @@ export function replaceChildrenLight(selectorOrOptions?: string | Omit<ApplyNode
569
612
  * - clearChildrenLightNode(options) - Clear children of $this in light DOM
570
613
  * - @clearChildrenLightNode - Bare decorator, clears children of $this in light DOM
571
614
  */
572
- export function clearChildrenLight(selector: string, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
615
+ export function clearChildrenLight(selector: ApplyNodeSelector, options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
573
616
  export function clearChildrenLight(options?: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;
574
617
  export function clearChildrenLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
575
- export function clearChildrenLight(selectorOrOptions?: string | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
618
+ export function clearChildrenLight(selectorOrOptions?: ApplyNodeSelector | Omit<ApplyNodeOptions, 'position' | 'root'> | Object, maybeOptions?: Omit<ApplyNodeOptions, 'position' | 'root'> | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
576
619
  // Bare decorator usage: @clearChildrenLightNode
577
620
  if (descriptor !== undefined && (typeof maybeOptions === 'symbol' || typeof maybeOptions === 'string')) {
578
621
  return applyNode({position: 'clearChildren', root: 'light'})(selectorOrOptions, maybeOptions, descriptor);
579
622
  }
580
623
 
581
- if (typeof selectorOrOptions === 'string') {
582
- return applyNode(selectorOrOptions, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});
624
+ if (typeof selectorOrOptions === 'string' || typeof selectorOrOptions === 'function') {
625
+ return applyNode(selectorOrOptions as ApplyNodeSelector, {...maybeOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});
583
626
  }
584
627
  return applyNode({...selectorOrOptions as Omit<ApplyNodeOptions, 'position' | 'root'>, position: 'clearChildren', root: 'light'});
585
628
  }
@@ -34,9 +34,11 @@ export interface PropertyOptions extends SwcQueryOptions {
34
34
  valueKey?: symbol | string;
35
35
  }
36
36
 
37
+ export type PropertySelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);
38
+
37
39
  export interface PropertyMetadata {
38
40
  propertyKey: string | symbol;
39
- selector: string;
41
+ selector: PropertySelector;
40
42
  targetPropertyKey: string | symbol;
41
43
  options: PropertyOptions;
42
44
  type: 'property' | 'method';
@@ -50,15 +52,42 @@ export const PROPERTY_METADATA_KEY = Symbol.for('simple-web-component:property')
50
52
 
51
53
  /**
52
54
  * Resolve target elements based on selector and options
53
- * Handles special selectors ($this, $host, etc.) and CSS selectors
55
+ * Handles special selectors ($this, $host, etc.), CSS selectors, and function-based selectors
54
56
  * Returns HTMLElement[] but can include Window and Document for property access
55
57
  */
56
- export const resolvePropertyTargets = (inst: any, selector: string, options: PropertyOptions): any[] => {
58
+ export const resolvePropertyTargets = (inst: any, selector: PropertySelector, options: PropertyOptions): any[] => {
57
59
  const conf = getElementConfig(inst);
58
60
  const currentWin = conf.window;
59
61
  const r = options.root || 'auto';
60
62
  const results: any[] = [];
61
63
 
64
+ // Resolve selector if it's a function
65
+ let resolvedSelector: string | Element | NodeList | Element[] | null = selector as any;
66
+ if (typeof selector === 'function') {
67
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
68
+ resolvedSelector = selector(inst, hostSet);
69
+ }
70
+
71
+ // If selector function returned elements directly, use them
72
+ if (resolvedSelector instanceof currentWin.Element) {
73
+ results.push(resolvedSelector);
74
+ return results;
75
+ }
76
+ if (resolvedSelector instanceof currentWin.NodeList) {
77
+ results.push(...Array.from(resolvedSelector));
78
+ return results;
79
+ }
80
+ if (Array.isArray(resolvedSelector)) {
81
+ results.push(...resolvedSelector);
82
+ return results;
83
+ }
84
+ if (resolvedSelector === null) {
85
+ return results;
86
+ }
87
+
88
+ // Handle string selector
89
+ const stringSelector = resolvedSelector as string;
90
+
62
91
  const applyRoot = (target: any) => {
63
92
  if (!target) return;
64
93
  if (r === 'auto') {
@@ -69,37 +98,37 @@ export const resolvePropertyTargets = (inst: any, selector: string, options: Pro
69
98
  }
70
99
  };
71
100
 
72
- if (selector === '$this' || !selector) {
101
+ if (stringSelector === '$this' || !stringSelector) {
73
102
  applyRoot(inst);
74
- } else if (selector === '$window') {
103
+ } else if (stringSelector === '$window') {
75
104
  results.push(currentWin);
76
- } else if (selector === '$document') {
105
+ } else if (stringSelector === '$document') {
77
106
  results.push(currentWin.document);
78
107
  } else {
79
108
  const hostSet = SwcUtils.getHostSet(inst);
80
- if (selector === '$host') applyRoot(hostSet.$host);
81
- else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
82
- else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);
83
- else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
84
- else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
85
- else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
86
- else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
87
- else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);
88
- else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
109
+ if (stringSelector === '$host') applyRoot(hostSet.$host);
110
+ else if (stringSelector === '$parentHost') applyRoot(hostSet.$parentHost);
111
+ else if (stringSelector === '$appHost') applyRoot(hostSet.$appHost as any);
112
+ else if (stringSelector === '$firstHost') applyRoot(hostSet.$firstHost);
113
+ else if (stringSelector === '$lastHost') applyRoot(hostSet.$lastHost);
114
+ else if (stringSelector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
115
+ else if (stringSelector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
116
+ else if (stringSelector === '$hosts') hostSet.$hosts.forEach(applyRoot);
117
+ else if (stringSelector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);
89
118
  else {
90
119
  if (r === 'shadow') {
91
- const found = inst.shadowRoot?.querySelectorAll(selector);
120
+ const found = inst.shadowRoot?.querySelectorAll(stringSelector);
92
121
  if (found) results.push(...found);
93
122
  } else if (r === 'light') {
94
- const found = inst.querySelectorAll(selector);
123
+ const found = inst.querySelectorAll(stringSelector);
95
124
  if (found) results.push(...found);
96
125
  } else if (r === 'all') {
97
- const sMatch = inst.shadowRoot?.querySelectorAll(selector);
98
- const lMatch = inst.querySelectorAll(selector);
126
+ const sMatch = inst.shadowRoot?.querySelectorAll(stringSelector);
127
+ const lMatch = inst.querySelectorAll(stringSelector);
99
128
  if (sMatch) results.push(...sMatch);
100
129
  if (lMatch) results.push(...lMatch);
101
130
  } else {
102
- const found = (inst.shadowRoot || inst).querySelectorAll(selector);
131
+ const found = (inst.shadowRoot || inst).querySelectorAll(stringSelector);
103
132
  if (found) results.push(...found);
104
133
  }
105
134
  }
@@ -114,11 +143,12 @@ export const resolvePropertyTargets = (inst: any, selector: string, options: Pro
114
143
  * - @applyProperty('selector', 'propertyName') - Set property with explicit name
115
144
  * - @applyProperty('selector') - Use property name as target property name
116
145
  * - @applyProperty('selector', { name: 'propertyName' }) - Set property via options
146
+ * - @applyProperty((this, helper) => 'selector', 'propertyName') - Function-based selector
117
147
  * - Return null/undefined to skip setting
118
148
  */
119
- export function applyProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
120
- export function applyProperty(selector: string, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
121
- export function applyProperty(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {
149
+ export function applyProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
150
+ export function applyProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator & PropertyDecorator;
151
+ export function applyProperty(selector: PropertySelector, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {
122
152
  return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
123
153
  // ensureInit(target as any);
124
154
 
@@ -150,7 +180,7 @@ export function applyProperty(selector: string, targetPropertyKeyOrOptions?: str
150
180
  }
151
181
  metaList.push({
152
182
  propertyKey,
153
- selector,
183
+ selector: selector as PropertySelector,
154
184
  targetPropertyKey,
155
185
  options: finalOptions,
156
186
  type: metaType
@@ -266,14 +296,15 @@ export function applyProperty(selector: string, targetPropertyKeyOrOptions?: str
266
296
  * - @property('selector', 'propertyName') - Bind to specific property
267
297
  * - @property('selector') - Use field name as property name
268
298
  * - @property('selector', options) - Bind with options
299
+ * - @property((this, helper) => 'selector', 'propertyName') - Function-based selector
269
300
  * - @property - Bare decorator (binds to $this with field name)
270
301
  *
271
302
  * Note: This decorator is for FIELDS ONLY. For methods, use @setProperty.
272
303
  */
273
304
  export function property(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
274
- export function property(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): PropertyDecorator;
275
- export function property(selector: string, options?: PropertyOptions): PropertyDecorator;
276
- export function property(selectorOrTarget?: string | Object, targetPropertyKeyOrOptions?: any, optionsOrDescriptor?: any): any {
305
+ export function property(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): PropertyDecorator;
306
+ export function property(selector: PropertySelector, options?: PropertyOptions): PropertyDecorator;
307
+ export function property(selectorOrTarget?: PropertySelector | Object, targetPropertyKeyOrOptions?: any, optionsOrDescriptor?: any): any {
277
308
  // Bare decorator: @property
278
309
  if (optionsOrDescriptor !== undefined && (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol')) {
279
310
  return applyProperty('$this', undefined as any, {})(selectorOrTarget as Object, targetPropertyKeyOrOptions, optionsOrDescriptor as PropertyDescriptor);
@@ -293,6 +324,7 @@ export function property(selectorOrTarget?: string | Object, targetPropertyKeyOr
293
324
  * - @setProperty('selector', 'propertyName') - Set specific property
294
325
  * - @setProperty('selector') - Use method name as property name
295
326
  * - @setProperty('selector', options) - Set with options
327
+ * - @setProperty((this, helper) => 'selector', 'propertyName') - Function-based selector
296
328
  * - @setProperty - Bare decorator (sets on $this with method name)
297
329
  *
298
330
  * Note: This decorator is for METHODS ONLY. For fields, use @property.
@@ -303,9 +335,9 @@ export function property(selectorOrTarget?: string | Object, targetPropertyKeyOr
303
335
  * return true;
304
336
  * }
305
337
  */
306
- export function setProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;
307
- export function setProperty(selector: string, options?: PropertyOptions): MethodDecorator;
308
- export function setProperty(selectorOrOptions?: string | PropertyOptions, targetPropertyKeyOrOptions?: any, optionsOrUndefined?: PropertyOptions): MethodDecorator {
338
+ export function setProperty(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;
339
+ export function setProperty(selector: PropertySelector, options?: PropertyOptions): MethodDecorator;
340
+ export function setProperty(selectorOrOptions?: PropertySelector | PropertyOptions, targetPropertyKeyOrOptions?: any, optionsOrUndefined?: PropertyOptions): MethodDecorator {
309
341
  // With selector
310
342
  if (typeof selectorOrOptions === 'string') {
311
343
  return applyProperty(selectorOrOptions, targetPropertyKeyOrOptions as any, optionsOrUndefined as PropertyOptions) as MethodDecorator;