@dooboostore/simple-web-component 1.0.47 → 1.0.49

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 (233) hide show
  1. package/README.md +223 -27
  2. package/dist/cjs/config/config.js +1 -1
  3. package/dist/cjs/config/config.js.map +2 -2
  4. package/dist/cjs/decorators/addEventListener.js +412 -16
  5. package/dist/cjs/decorators/addEventListener.js.map +3 -3
  6. package/dist/cjs/decorators/applyAttribute.js +25 -0
  7. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  8. package/dist/cjs/decorators/applyClass.js +49 -18
  9. package/dist/cjs/decorators/applyClass.js.map +3 -3
  10. package/dist/cjs/decorators/applyNode.js +67 -1
  11. package/dist/cjs/decorators/applyNode.js.map +3 -3
  12. package/dist/cjs/decorators/applyProperty.js +101 -3
  13. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  14. package/dist/cjs/decorators/applyStyle.js +36 -5
  15. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  16. package/dist/cjs/decorators/changedAttribute.js +39 -0
  17. package/dist/cjs/decorators/changedAttribute.js.map +2 -2
  18. package/dist/cjs/decorators/elementDefine.js +244 -225
  19. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  20. package/dist/cjs/decorators/emitCustomEvent.js +55 -0
  21. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  22. package/dist/cjs/decorators/index.js +5 -1
  23. package/dist/cjs/decorators/index.js.map +2 -2
  24. package/dist/cjs/decorators/intersectionObserver.js +209 -0
  25. package/dist/cjs/decorators/intersectionObserver.js.map +7 -0
  26. package/dist/cjs/decorators/mutationObserver.js +244 -0
  27. package/dist/cjs/decorators/mutationObserver.js.map +7 -0
  28. package/dist/cjs/decorators/query.js +129 -102
  29. package/dist/cjs/decorators/query.js.map +2 -2
  30. package/dist/cjs/decorators/resizeObserver.js +191 -0
  31. package/dist/cjs/decorators/resizeObserver.js.map +7 -0
  32. package/dist/cjs/decorators/setInterval.js +82 -0
  33. package/dist/cjs/decorators/setInterval.js.map +7 -0
  34. package/dist/cjs/decorators/setTimeout.js +82 -0
  35. package/dist/cjs/decorators/setTimeout.js.map +7 -0
  36. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
  37. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  38. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
  39. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  40. package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
  41. package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
  42. package/dist/cjs/types/index.js.map +1 -1
  43. package/dist/esm/config/config.js +1 -1
  44. package/dist/esm/config/config.js.map +2 -2
  45. package/dist/esm/decorators/addEventListener.js +413 -16
  46. package/dist/esm/decorators/addEventListener.js.map +3 -3
  47. package/dist/esm/decorators/applyAttribute.js +25 -0
  48. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  49. package/dist/esm/decorators/applyClass.js +49 -18
  50. package/dist/esm/decorators/applyClass.js.map +3 -3
  51. package/dist/esm/decorators/applyNode.js +67 -1
  52. package/dist/esm/decorators/applyNode.js.map +3 -3
  53. package/dist/esm/decorators/applyProperty.js +101 -3
  54. package/dist/esm/decorators/applyProperty.js.map +2 -2
  55. package/dist/esm/decorators/applyStyle.js +36 -5
  56. package/dist/esm/decorators/applyStyle.js.map +2 -2
  57. package/dist/esm/decorators/changedAttribute.js +40 -0
  58. package/dist/esm/decorators/changedAttribute.js.map +2 -2
  59. package/dist/esm/decorators/elementDefine.js +249 -230
  60. package/dist/esm/decorators/elementDefine.js.map +3 -3
  61. package/dist/esm/decorators/emitCustomEvent.js +55 -0
  62. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  63. package/dist/esm/decorators/index.js +5 -1
  64. package/dist/esm/decorators/index.js.map +2 -2
  65. package/dist/esm/decorators/intersectionObserver.js +191 -0
  66. package/dist/esm/decorators/intersectionObserver.js.map +7 -0
  67. package/dist/esm/decorators/mutationObserver.js +226 -0
  68. package/dist/esm/decorators/mutationObserver.js.map +7 -0
  69. package/dist/esm/decorators/query.js +129 -102
  70. package/dist/esm/decorators/query.js.map +2 -2
  71. package/dist/esm/decorators/resizeObserver.js +173 -0
  72. package/dist/esm/decorators/resizeObserver.js.map +7 -0
  73. package/dist/esm/decorators/setInterval.js +64 -0
  74. package/dist/esm/decorators/setInterval.js.map +7 -0
  75. package/dist/esm/decorators/setTimeout.js +64 -0
  76. package/dist/esm/decorators/setTimeout.js.map +7 -0
  77. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
  78. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  79. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
  80. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  81. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  82. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  83. package/dist/esm/types/index.js.map +1 -1
  84. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2413 -889
  85. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  86. package/dist/types/config/config.d.ts.map +1 -1
  87. package/dist/types/decorators/addEventListener.d.ts +93 -23
  88. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  89. package/dist/types/decorators/applyAttribute.d.ts +22 -34
  90. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  91. package/dist/types/decorators/applyClass.d.ts +34 -34
  92. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  93. package/dist/types/decorators/applyNode.d.ts +30 -20
  94. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  95. package/dist/types/decorators/applyProperty.d.ts +57 -34
  96. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  97. package/dist/types/decorators/applyStyle.d.ts +25 -12
  98. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  99. package/dist/types/decorators/changedAttribute.d.ts +11 -0
  100. package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
  101. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  102. package/dist/types/decorators/emitCustomEvent.d.ts +28 -4
  103. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  104. package/dist/types/decorators/index.d.ts +5 -1
  105. package/dist/types/decorators/index.d.ts.map +1 -1
  106. package/dist/types/decorators/intersectionObserver.d.ts +49 -0
  107. package/dist/types/decorators/intersectionObserver.d.ts.map +1 -0
  108. package/dist/types/decorators/mutationObserver.d.ts +46 -0
  109. package/dist/types/decorators/mutationObserver.d.ts.map +1 -0
  110. package/dist/types/decorators/query.d.ts +63 -8
  111. package/dist/types/decorators/query.d.ts.map +1 -1
  112. package/dist/types/decorators/resizeObserver.d.ts +48 -0
  113. package/dist/types/decorators/resizeObserver.d.ts.map +1 -0
  114. package/dist/types/decorators/setInterval.d.ts +29 -0
  115. package/dist/types/decorators/setInterval.d.ts.map +1 -0
  116. package/dist/types/decorators/setTimeout.d.ts +29 -0
  117. package/dist/types/decorators/setTimeout.d.ts.map +1 -0
  118. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +7 -1
  119. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  120. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +6 -0
  121. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  122. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  123. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  124. package/dist/types/types/index.d.ts +104 -0
  125. package/dist/types/types/index.d.ts.map +1 -1
  126. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2413 -889
  127. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  128. package/package.json +8 -6
  129. package/src/config/config.ts +1 -1
  130. package/src/decorators/addEventListener.ts +426 -23
  131. package/src/decorators/applyAttribute.ts +50 -36
  132. package/src/decorators/applyClass.ts +76 -26
  133. package/src/decorators/applyNode.ts +114 -36
  134. package/src/decorators/applyProperty.ts +152 -40
  135. package/src/decorators/applyStyle.ts +64 -17
  136. package/src/decorators/changedAttribute.ts +46 -0
  137. package/src/decorators/elementDefine.ts +301 -317
  138. package/src/decorators/emitCustomEvent.ts +73 -5
  139. package/src/decorators/index.ts +5 -1
  140. package/src/decorators/intersectionObserver.ts +259 -0
  141. package/src/decorators/mutationObserver.ts +304 -0
  142. package/src/decorators/query.ts +182 -117
  143. package/src/decorators/resizeObserver.ts +235 -0
  144. package/src/decorators/setInterval.ts +80 -0
  145. package/src/decorators/setTimeout.ts +80 -0
  146. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +17 -0
  147. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +19 -0
  148. package/src/examples/RxJSOperatorsExample.ts +279 -0
  149. package/src/types/index.ts +141 -0
  150. package/dist/cjs/decorators/queryAll.js +0 -181
  151. package/dist/cjs/decorators/queryAll.js.map +0 -7
  152. package/dist/cjs/elements/tt/SwcAppMixin.js +0 -1
  153. package/dist/cjs/elements/tt/SwcAppMixin.js.map +0 -7
  154. package/dist/cjs/elements/tt/SwcAsync.js +0 -1
  155. package/dist/cjs/elements/tt/SwcAsync.js.map +0 -7
  156. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +0 -1
  157. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +0 -7
  158. package/dist/cjs/elements/tt/SwcChoose.js +0 -1
  159. package/dist/cjs/elements/tt/SwcChoose.js.map +0 -7
  160. package/dist/cjs/elements/tt/SwcChooseTemplate.js +0 -1
  161. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +0 -7
  162. package/dist/cjs/elements/tt/SwcIf.js +0 -1
  163. package/dist/cjs/elements/tt/SwcIf.js.map +0 -7
  164. package/dist/cjs/elements/tt/SwcIfTemplate.js +0 -1
  165. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +0 -7
  166. package/dist/cjs/elements/tt/SwcLoop.js +0 -1
  167. package/dist/cjs/elements/tt/SwcLoop.js.map +0 -7
  168. package/dist/cjs/elements/tt/SwcLoopTemplate.js +0 -1
  169. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +0 -7
  170. package/dist/cjs/elements/tt/SwcSubTemplates.js +0 -1
  171. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +0 -7
  172. package/dist/cjs/elements/tt/register.js +0 -1
  173. package/dist/cjs/elements/tt/register.js.map +0 -7
  174. package/dist/esm/decorators/queryAll.js +0 -162
  175. package/dist/esm/decorators/queryAll.js.map +0 -7
  176. package/dist/esm/elements/tt/SwcAppMixin.js +0 -1
  177. package/dist/esm/elements/tt/SwcAppMixin.js.map +0 -7
  178. package/dist/esm/elements/tt/SwcAsync.js +0 -1
  179. package/dist/esm/elements/tt/SwcAsync.js.map +0 -7
  180. package/dist/esm/elements/tt/SwcAsyncTemplate.js +0 -1
  181. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +0 -7
  182. package/dist/esm/elements/tt/SwcChoose.js +0 -1
  183. package/dist/esm/elements/tt/SwcChoose.js.map +0 -7
  184. package/dist/esm/elements/tt/SwcChooseTemplate.js +0 -1
  185. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +0 -7
  186. package/dist/esm/elements/tt/SwcIf.js +0 -1
  187. package/dist/esm/elements/tt/SwcIf.js.map +0 -7
  188. package/dist/esm/elements/tt/SwcIfTemplate.js +0 -1
  189. package/dist/esm/elements/tt/SwcIfTemplate.js.map +0 -7
  190. package/dist/esm/elements/tt/SwcLoop.js +0 -1
  191. package/dist/esm/elements/tt/SwcLoop.js.map +0 -7
  192. package/dist/esm/elements/tt/SwcLoopTemplate.js +0 -1
  193. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +0 -7
  194. package/dist/esm/elements/tt/SwcSubTemplates.js +0 -1
  195. package/dist/esm/elements/tt/SwcSubTemplates.js.map +0 -7
  196. package/dist/esm/elements/tt/register.js +0 -1
  197. package/dist/esm/elements/tt/register.js.map +0 -7
  198. package/dist/types/decorators/queryAll.d.ts +0 -22
  199. package/dist/types/decorators/queryAll.d.ts.map +0 -1
  200. package/dist/types/elements/tt/SwcAppMixin.d.ts +0 -1
  201. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +0 -1
  202. package/dist/types/elements/tt/SwcAsync.d.ts +0 -1
  203. package/dist/types/elements/tt/SwcAsync.d.ts.map +0 -1
  204. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +0 -1
  205. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +0 -1
  206. package/dist/types/elements/tt/SwcChoose.d.ts +0 -1
  207. package/dist/types/elements/tt/SwcChoose.d.ts.map +0 -1
  208. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +0 -1
  209. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +0 -1
  210. package/dist/types/elements/tt/SwcIf.d.ts +0 -1
  211. package/dist/types/elements/tt/SwcIf.d.ts.map +0 -1
  212. package/dist/types/elements/tt/SwcIfTemplate.d.ts +0 -1
  213. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +0 -1
  214. package/dist/types/elements/tt/SwcLoop.d.ts +0 -1
  215. package/dist/types/elements/tt/SwcLoop.d.ts.map +0 -1
  216. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +0 -1
  217. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +0 -1
  218. package/dist/types/elements/tt/SwcSubTemplates.d.ts +0 -1
  219. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +0 -1
  220. package/dist/types/elements/tt/register.d.ts +0 -1
  221. package/dist/types/elements/tt/register.d.ts.map +0 -1
  222. package/src/decorators/queryAll.ts +0 -186
  223. package/src/elements/tt/SwcAppMixin.ts +0 -13
  224. package/src/elements/tt/SwcAsync.ts +0 -139
  225. package/src/elements/tt/SwcAsyncTemplate.ts +0 -126
  226. package/src/elements/tt/SwcChoose.ts +0 -182
  227. package/src/elements/tt/SwcChooseTemplate.ts +0 -229
  228. package/src/elements/tt/SwcIf.ts +0 -145
  229. package/src/elements/tt/SwcIfTemplate.ts +0 -158
  230. package/src/elements/tt/SwcLoop.ts +0 -222
  231. package/src/elements/tt/SwcLoopTemplate.ts +0 -255
  232. package/src/elements/tt/SwcSubTemplates.ts +0 -6
  233. package/src/elements/tt/register.ts +0 -720
@@ -1,46 +1,33 @@
1
1
  import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';
2
2
  import {ensureInit, getElementConfig} from './elementDefine';
3
3
  import {SwcUtils} from '../utils/Utils';
4
- import {SwcQueryOptions, HelperHostSet} from '../types';
4
+ import {SwcQueryOptions, HelperHostSet, SwcFnSelector, SwcSelector} from '../types';
5
5
  import {ConvertUtils} from '@dooboostore/core-web';
6
6
 
7
7
  // ============================================
8
8
  // Types & Interfaces
9
9
  // ============================================
10
10
 
11
- export interface AttributeOptions extends SwcQueryOptions {
11
+ // 공통 옵션 — root 없음
12
+ export interface AttributeBaseOptions {
12
13
  name?: string;
13
14
  type?: typeof Number | typeof Boolean | typeof String;
14
15
  filter?: (target: HTMLElement, value: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;
15
- /**
16
- * Custom key to extract value from return object.
17
- * If not provided, uses ATTRIBUTE_METADATA_KEY by default.
18
- * Useful when multiple @setAttribute decorators are on the same method.
19
- *
20
- * Example:
21
- * @setAttribute('selector1', { valueKey: 'attr1' })
22
- * @setAttribute('selector2', { valueKey: 'attr2' })
23
- * myMethod() {
24
- * return {
25
- * attr1: 'value1',
26
- * attr2: 'value2'
27
- * };
28
- * }
29
- *
30
- * Or with symbols:
31
- * @setAttribute('selector1', { valueKey: Symbol.for('attr1') })
32
- * @setAttribute('selector2', { valueKey: Symbol.for('attr2') })
33
- * myMethod() {
34
- * return {
35
- * [Symbol.for('attr1')]: 'value1',
36
- * [Symbol.for('attr2')]: 'value2'
37
- * };
38
- * }
39
- */
40
16
  valueKey?: symbol | string;
41
17
  }
42
18
 
43
- export type AttributeSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);
19
+ // 문자열 셀렉터 전용 — root 허용 (컴포넌트 DOM 트리 안에서 탐색)
20
+ export type AttributeQueryOptions = AttributeBaseOptions & SwcQueryOptions;
21
+ // 함수 셀렉터 전용 — root 금지 (이미 요소를 직접 반환)
22
+ export type AttributeNonQueryOptions = AttributeBaseOptions;
23
+ // 내부 저장/해석용 — root optional이라 두 종류 모두 저장 가능
24
+ export type AttributeOptions = AttributeQueryOptions;
25
+
26
+ export type AttributeFnSelector = SwcFnSelector;
27
+ export type AttributeSelector = SwcSelector;
28
+
29
+ // 셀렉터 종류에 따라 옵션 타입 분기
30
+ export type AttributeOptionsOf<S extends AttributeSelector> = S extends string ? AttributeQueryOptions : AttributeNonQueryOptions;
44
31
 
45
32
  export interface AttributeMetadata {
46
33
  propertyKey: string | symbol;
@@ -143,7 +130,7 @@ export const resolveAttributeTargets = (inst: any, selector: AttributeSelector,
143
130
  const results: HTMLElement[] = [];
144
131
 
145
132
  // Resolve selector if it's a function
146
- let resolvedSelector: string | Element | NodeList | Element[] | null = selector as any;
133
+ let resolvedSelector: string | Node | Element | NodeList | Element[] | null = selector as any;
147
134
  if (typeof selector === 'function') {
148
135
  const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
149
136
  resolvedSelector = selector(inst, hostSet);
@@ -223,9 +210,9 @@ export const resolveAttributeTargets = (inst: any, selector: AttributeSelector,
223
210
  * - @applyAttribute((this, helper) => 'selector', 'attrName') - Function-based selector
224
211
  * - Return null to remove attribute
225
212
  */
226
- export function applyAttribute(selector: AttributeSelector, targetAttributeName: string, options?: AttributeOptions): MethodDecorator & PropertyDecorator;
227
- export function applyAttribute(selector: AttributeSelector, options?: AttributeOptions): MethodDecorator & PropertyDecorator;
228
- export function applyAttribute(selector: AttributeSelector, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator & PropertyDecorator {
213
+ export function applyAttribute<S extends AttributeSelector>(selector: S, targetAttributeName: string, options?: AttributeOptionsOf<S>): MethodDecorator & PropertyDecorator;
214
+ export function applyAttribute<S extends AttributeSelector>(selector: S, options?: AttributeOptionsOf<S>): MethodDecorator & PropertyDecorator;
215
+ export function applyAttribute(selector: AttributeSelector, targetAttributeNameOrOptions?: string | AttributeOptions, options?: AttributeOptions): MethodDecorator {
229
216
  return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {
230
217
  // ensureInit(target as any);
231
218
 
@@ -383,8 +370,9 @@ export function applyAttribute(selector: AttributeSelector, targetAttributeNameO
383
370
  */
384
371
  export function attribute(target: Object, propertyKey: string | symbol): void;
385
372
  export function attribute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
386
- export function attribute(attributeName: string, options?: AttributeOptions): PropertyDecorator;
387
- export function attribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): PropertyDecorator;
373
+ export function attribute(attributeName: string, options?: AttributeQueryOptions): PropertyDecorator;
374
+ export function attribute(selector: string, attributeName: string, options?: AttributeQueryOptions): PropertyDecorator;
375
+ export function attribute(selector: AttributeFnSelector, attributeName: string, options?: AttributeNonQueryOptions): PropertyDecorator;
388
376
  export function attribute(selectorOrAttributeOrTarget?: AttributeSelector | Object, attributeNameOrOptions?: any, optionsOrDescriptor?: any): any {
389
377
  // Bare decorator: @attribute
390
378
  if (optionsOrDescriptor !== undefined && (typeof attributeNameOrOptions === 'string' || typeof attributeNameOrOptions === 'symbol')) {
@@ -434,9 +422,14 @@ export function attribute(selectorOrAttributeOrTarget?: AttributeSelector | Obje
434
422
  * return 'active';
435
423
  * }
436
424
  */
437
- export function setAttribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): MethodDecorator;
438
- export function setAttribute(attributeName: string, options?: AttributeOptions): MethodDecorator;
425
+ export function setAttribute(selector: string, attributeName: string, options?: AttributeQueryOptions): MethodDecorator;
426
+ export function setAttribute(selector: AttributeFnSelector, attributeName: string, options?: AttributeNonQueryOptions): MethodDecorator;
427
+ export function setAttribute(attributeName: string, options?: AttributeQueryOptions): MethodDecorator;
439
428
  export function setAttribute(selectorOrAttributeOrOptions?: AttributeSelector | AttributeOptions, attributeNameOrOptions?: any, optionsOrUndefined?: AttributeOptions): MethodDecorator {
429
+ // Function selector: @setAttribute((c, helper) => ..., 'attr', options?)
430
+ if (typeof selectorOrAttributeOrOptions === 'function') {
431
+ return applyAttribute(selectorOrAttributeOrOptions as AttributeSelector, attributeNameOrOptions as any, optionsOrUndefined as AttributeOptions) as MethodDecorator;
432
+ }
440
433
  // With string as first parameter
441
434
  if (typeof selectorOrAttributeOrOptions === 'string') {
442
435
  // Check if first parameter is a CSS selector or attribute name
@@ -477,5 +470,26 @@ export const findAllAttributeApplyMetadata = (target: any): Map<string | symbol,
477
470
  return result;
478
471
  };
479
472
 
473
+ // ─── Aliases ───
474
+ // attribute(필드) / setAttribute(메서드)와 구분되는 일반 데코레이터 단축명
475
+ export const attr = applyAttribute;
476
+
477
+ // ─── 편의 헬퍼 (selector/root 생략) ───
478
+
479
+ export function attrThis(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator {
480
+ return applyAttribute('$this', targetAttributeName, options);
481
+ }
482
+ export function attrAppHost(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator {
483
+ return applyAttribute('$appHost', targetAttributeName, options);
484
+ }
485
+ export function attrLight(selector: string, targetAttributeName?: string, options?: Omit<AttributeQueryOptions, 'root'>): MethodDecorator {
486
+ return applyAttribute(selector, targetAttributeName, {...options ?? {}, root: 'light'});
487
+ }
488
+ export function attrShadow(selector: string, targetAttributeName?: string, options?: Omit<AttributeQueryOptions, 'root'>): MethodDecorator {
489
+ return applyAttribute(selector, targetAttributeName, {...options ?? {}, root: 'shadow'});
490
+ }
491
+ export function attrAll(selector: string, targetAttributeName?: string, options?: Omit<AttributeQueryOptions, 'root'>): MethodDecorator {
492
+ return applyAttribute(selector, targetAttributeName, {...options ?? {}, root: 'all'});
493
+ }
480
494
 
481
495
  export default applyAttribute;
@@ -1,7 +1,7 @@
1
1
  import { ReflectUtils } from '@dooboostore/core';
2
2
  import { ensureInit } from './elementDefine';
3
3
  import { SwcUtils } from '../utils/Utils';
4
- import { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';
4
+ import { SpecialSelector, SwcQueryOptions, SwcFnSelector, SwcSelector, HelperHostSet } from '../types';
5
5
 
6
6
  export const CLASS_METADATA_KEY = Symbol.for('simple-web-component:class');
7
7
 
@@ -28,6 +28,9 @@ const resolveSelector = (selector: ClassSelector, inst: any, win: Window): strin
28
28
  if (result === null) {
29
29
  return [];
30
30
  }
31
+ if (result instanceof win.Node) {
32
+ return [];
33
+ }
31
34
  return result as string;
32
35
  }
33
36
  return selector as string;
@@ -74,17 +77,24 @@ const getTargetElements = (selector: ClassSelector, inst: any, win: Window, root
74
77
  return targetEls;
75
78
  };
76
79
 
77
- export interface ClassApplyOptions extends SwcQueryOptions {
80
+ // 공통 옵션 — root 없음
81
+ export interface ClassBaseOptions {
78
82
  filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;
79
- /**
80
- * Custom key to extract value from return object.
81
- * If not provided, uses CLASS_METADATA_KEY by default.
82
- * Useful when multiple @applyClass decorators are on the same method.
83
- */
84
83
  valueKey?: symbol | string;
85
84
  }
86
85
 
87
- export type ClassSelector = string | ((currentThis: any, helper: HelperHostSet) => NodeList | Element | Element[] | null);
86
+ // 문자열 셀렉터 전용 — root 허용 (classMapOrOptions 판별을 위해 root 필요)
87
+ export type ClassQueryOptions = ClassBaseOptions & SwcQueryOptions;
88
+ // 함수 셀렉터 전용 — root 금지. 단, classMapOrOptions의 options 자리에 올 수 없음(root가 없어 classMap과 판별 불가)
89
+ export type ClassNonQueryOptions = ClassBaseOptions;
90
+ export type ClassApplyOptions = ClassQueryOptions;
91
+
92
+ export type ClassFnSelector = SwcFnSelector;
93
+ export type ClassSelector = SwcSelector;
94
+ export type ClassMapType = { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean };
95
+
96
+ // 셀렉터 종류에 따라 옵션 타입 분기
97
+ export type ClassOptionsOf<S extends ClassSelector> = S extends string ? ClassQueryOptions : ClassNonQueryOptions;
88
98
 
89
99
  export interface ClassApplyMetadata {
90
100
  propertyKey: string | symbol;
@@ -210,14 +220,15 @@ function createClassDecorator(action: ClassAction) {
210
220
  }
211
221
 
212
222
  export function applyClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
213
- export function applyClass(selector: ClassSelector, action?: ClassAction, options?: ClassApplyOptions): MethodDecorator;
223
+ export function applyClass(selector: string, action?: ClassAction, options?: ClassQueryOptions): MethodDecorator;
224
+ export function applyClass(selector: ClassFnSelector, action?: ClassAction, options?: ClassNonQueryOptions): MethodDecorator;
214
225
  export function applyClass(selectorOrTarget?: any, actionOrPropertyKey?: any, optionsOrDescriptor?: any): any {
215
226
  // Bare decorator: @applyClass
216
- if (optionsOrDescriptor !== undefined && (typeof actionOrPropertyKey === 'string' || typeof actionOrPropertyKey === 'symbol')) {
227
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof actionOrPropertyKey === 'string' || typeof actionOrPropertyKey === 'symbol')) {
217
228
  return createClassDecorator('update')('$this', {})(selectorOrTarget as Object, actionOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
218
229
  }
219
230
  // With selector
220
- if (typeof selectorOrTarget === 'string') {
231
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
221
232
  const action = (typeof actionOrPropertyKey === 'string' ? actionOrPropertyKey : 'update') as ClassAction;
222
233
  const options = (typeof actionOrPropertyKey === 'object' ? actionOrPropertyKey : optionsOrDescriptor) as ClassApplyOptions | undefined;
223
234
  return createClassDecorator(action)(selectorOrTarget, options);
@@ -229,14 +240,15 @@ export function applyClass(selectorOrTarget?: any, actionOrPropertyKey?: any, op
229
240
  }
230
241
 
231
242
  export function setClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
232
- export function setClass(selector: ClassSelector, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options?: ClassApplyOptions): MethodDecorator;
243
+ export function setClass(selector: string, classMapOrOptions?: string | ClassMapType | ClassQueryOptions, options?: ClassQueryOptions): MethodDecorator;
244
+ export function setClass(selector: ClassFnSelector, classMap: string | ClassMapType): MethodDecorator;
233
245
  export function setClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?: any, optionsOrDescriptor?: any): any {
234
246
  // Bare decorator: @setClass
235
- if (optionsOrDescriptor !== undefined && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
247
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
236
248
  return createClassDecorator('set')('$this', {})(selectorOrTarget as Object, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
237
249
  }
238
250
  // With selector
239
- if (typeof selectorOrTarget === 'string') {
251
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
240
252
  return createClassDecorator('set')(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as ClassApplyOptions);
241
253
  }
242
254
  // Without selector (defaults to $this)
@@ -244,14 +256,15 @@ export function setClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?
244
256
  }
245
257
 
246
258
  export function updateClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
247
- export function updateClass(selector: ClassSelector, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options?: ClassApplyOptions): MethodDecorator;
259
+ export function updateClass(selector: string, classMapOrOptions?: string | ClassMapType | ClassQueryOptions, options?: ClassQueryOptions): MethodDecorator;
260
+ export function updateClass(selector: ClassFnSelector, classMap: string | ClassMapType): MethodDecorator;
248
261
  export function updateClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?: any, optionsOrDescriptor?: any): any {
249
262
  // Bare decorator: @updateClass
250
- if (optionsOrDescriptor !== undefined && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
263
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
251
264
  return createClassDecorator('update')('$this', {})(selectorOrTarget as Object, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
252
265
  }
253
266
  // With selector
254
- if (typeof selectorOrTarget === 'string') {
267
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
255
268
  return createClassDecorator('update')(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as ClassApplyOptions);
256
269
  }
257
270
  // Without selector (defaults to $this)
@@ -259,14 +272,15 @@ export function updateClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyK
259
272
  }
260
273
 
261
274
  export function addClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
262
- export function addClass(selector: ClassSelector, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options?: ClassApplyOptions): MethodDecorator;
275
+ export function addClass(selector: string, classMapOrOptions?: string | ClassMapType | ClassQueryOptions, options?: ClassQueryOptions): MethodDecorator;
276
+ export function addClass(selector: ClassFnSelector, classMap: string | ClassMapType): MethodDecorator;
263
277
  export function addClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?: any, optionsOrDescriptor?: any): any {
264
278
  // Bare decorator: @addClass
265
- if (optionsOrDescriptor !== undefined && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
279
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
266
280
  return createClassDecorator('add')('$this', {})(selectorOrTarget as Object, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
267
281
  }
268
282
  // With selector
269
- if (typeof selectorOrTarget === 'string') {
283
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
270
284
  return createClassDecorator('add')(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as ClassApplyOptions);
271
285
  }
272
286
  // Without selector (defaults to $this)
@@ -274,14 +288,15 @@ export function addClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?
274
288
  }
275
289
 
276
290
  export function removeClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
277
- export function removeClass(selector: ClassSelector, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options?: ClassApplyOptions): MethodDecorator;
291
+ export function removeClass(selector: string, classMapOrOptions?: string | ClassMapType | ClassQueryOptions, options?: ClassQueryOptions): MethodDecorator;
292
+ export function removeClass(selector: ClassFnSelector, classMap: string | ClassMapType): MethodDecorator;
278
293
  export function removeClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?: any, optionsOrDescriptor?: any): any {
279
294
  // Bare decorator: @removeClass
280
- if (optionsOrDescriptor !== undefined && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
295
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
281
296
  return createClassDecorator('remove')('$this', {})(selectorOrTarget as Object, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
282
297
  }
283
298
  // With selector
284
- if (typeof selectorOrTarget === 'string') {
299
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
285
300
  return createClassDecorator('remove')(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as ClassApplyOptions);
286
301
  }
287
302
  // Without selector (defaults to $this)
@@ -289,20 +304,55 @@ export function removeClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyK
289
304
  }
290
305
 
291
306
  export function toggleClass(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
292
- export function toggleClass(selector: ClassSelector, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options?: ClassApplyOptions): MethodDecorator;
307
+ export function toggleClass(selector: string, classMapOrOptions?: string | ClassMapType | ClassQueryOptions, options?: ClassQueryOptions): MethodDecorator;
308
+ export function toggleClass(selector: ClassFnSelector, classMap: string | ClassMapType): MethodDecorator;
293
309
  export function toggleClass(selectorOrTarget?: any, classMapOrOptionsOrPropertyKey?: any, optionsOrDescriptor?: any): any {
294
310
  // Bare decorator: @toggleClass
295
- if (optionsOrDescriptor !== undefined && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
311
+ if (optionsOrDescriptor !== undefined && typeof selectorOrTarget !== 'string' && typeof selectorOrTarget !== 'function' && (typeof classMapOrOptionsOrPropertyKey === 'string' || typeof classMapOrOptionsOrPropertyKey === 'symbol')) {
296
312
  return createClassDecorator('toggle')('$this', {})(selectorOrTarget as Object, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as PropertyDescriptor);
297
313
  }
298
314
  // With selector
299
- if (typeof selectorOrTarget === 'string') {
315
+ if (typeof selectorOrTarget === 'string' || typeof selectorOrTarget === 'function') {
300
316
  return createClassDecorator('toggle')(selectorOrTarget, classMapOrOptionsOrPropertyKey, optionsOrDescriptor as ClassApplyOptions);
301
317
  }
302
318
  // Without selector (defaults to $this)
303
319
  return createClassDecorator('toggle')('$this', selectorOrTarget as ClassApplyOptions);
304
320
  }
305
321
 
322
+ // ─── Aliases ───
323
+ // class는 예약어라 cls 사용
324
+ export const cls = applyClass;
325
+
326
+ // ─── 편의 헬퍼 (selector/root 생략) ───
327
+
328
+ export function clsThis(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator {
329
+ return applyClass('$this', action, options);
330
+ }
331
+ export function clsAppHost(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator {
332
+ return applyClass('$appHost', action, options);
333
+ }
334
+ export function clsLight(selector: string, action?: ClassAction, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
335
+ export function clsLight(selector: string, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
336
+ export function clsLight(selector: string, actionOrOptions?: ClassAction | Omit<ClassQueryOptions, 'root'>, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator {
337
+ const action = (typeof actionOrOptions === 'string' ? actionOrOptions : undefined) as ClassAction | undefined;
338
+ const opts = (typeof actionOrOptions === 'object' ? actionOrOptions : options) as Omit<ClassQueryOptions, 'root'> | undefined;
339
+ return applyClass(selector, action, {...opts ?? {}, root: 'light'});
340
+ }
341
+ export function clsShadow(selector: string, action?: ClassAction, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
342
+ export function clsShadow(selector: string, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
343
+ export function clsShadow(selector: string, actionOrOptions?: ClassAction | Omit<ClassQueryOptions, 'root'>, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator {
344
+ const action = (typeof actionOrOptions === 'string' ? actionOrOptions : undefined) as ClassAction | undefined;
345
+ const opts = (typeof actionOrOptions === 'object' ? actionOrOptions : options) as Omit<ClassQueryOptions, 'root'> | undefined;
346
+ return applyClass(selector, action, {...opts ?? {}, root: 'shadow'});
347
+ }
348
+ export function clsAll(selector: string, action?: ClassAction, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
349
+ export function clsAll(selector: string, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
350
+ export function clsAll(selector: string, actionOrOptions?: ClassAction | Omit<ClassQueryOptions, 'root'>, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator {
351
+ const action = (typeof actionOrOptions === 'string' ? actionOrOptions : undefined) as ClassAction | undefined;
352
+ const opts = (typeof actionOrOptions === 'object' ? actionOrOptions : options) as Omit<ClassQueryOptions, 'root'> | undefined;
353
+ return applyClass(selector, action, {...opts ?? {}, root: 'all'});
354
+ }
355
+
306
356
  export const findAllClassMetadata = (target: any): Map<string | symbol, ClassApplyMetadata> => {
307
357
  const result = new Map<string | symbol, ClassApplyMetadata>();
308
358
  const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassApplyMetadata>>(CLASS_METADATA_KEY, target);