@dooboostore/simple-web-component 1.0.24 → 1.0.26

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 (130) hide show
  1. package/README.md +162 -33
  2. package/dist/cjs/decorators/addEventListener.js +1 -1
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +148 -0
  5. package/dist/cjs/decorators/applyAttribute.js.map +7 -0
  6. package/dist/cjs/decorators/applyClass.js +164 -0
  7. package/dist/cjs/decorators/applyClass.js.map +7 -0
  8. package/dist/cjs/decorators/applyNode.js +87 -194
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
  11. package/dist/cjs/decorators/applyStyle.js.map +7 -0
  12. package/dist/cjs/decorators/attribute.js +10 -16
  13. package/dist/cjs/decorators/attribute.js.map +2 -2
  14. package/dist/cjs/decorators/changedAttributeHost.js +1 -1
  15. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  16. package/dist/cjs/decorators/elementDefine.js +14 -23
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +5 -2
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/index.js +3 -3
  21. package/dist/cjs/decorators/index.js.map +2 -2
  22. package/dist/cjs/decorators/lifecycles.js +9 -9
  23. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  24. package/dist/cjs/decorators/query.js +1 -1
  25. package/dist/cjs/decorators/query.js.map +2 -2
  26. package/dist/cjs/decorators/queryAll.js +1 -1
  27. package/dist/cjs/decorators/queryAll.js.map +2 -2
  28. package/dist/cjs/elements/SwcAppEngine.js +19 -4
  29. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  30. package/dist/cjs/elements/SwcAppMixin.js +2 -0
  31. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  32. package/dist/cjs/utils/Utils.js +1 -1
  33. package/dist/cjs/utils/Utils.js.map +2 -2
  34. package/dist/esm/decorators/addEventListener.js +1 -1
  35. package/dist/esm/decorators/addEventListener.js.map +2 -2
  36. package/dist/esm/decorators/applyAttribute.js +129 -0
  37. package/dist/esm/decorators/applyAttribute.js.map +7 -0
  38. package/dist/esm/decorators/applyClass.js +145 -0
  39. package/dist/esm/decorators/applyClass.js.map +7 -0
  40. package/dist/esm/decorators/applyNode.js +87 -194
  41. package/dist/esm/decorators/applyNode.js.map +2 -2
  42. package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
  43. package/dist/esm/decorators/applyStyle.js.map +7 -0
  44. package/dist/esm/decorators/attribute.js +10 -16
  45. package/dist/esm/decorators/attribute.js.map +2 -2
  46. package/dist/esm/decorators/changedAttributeHost.js +1 -1
  47. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  48. package/dist/esm/decorators/elementDefine.js +14 -23
  49. package/dist/esm/decorators/elementDefine.js.map +2 -2
  50. package/dist/esm/decorators/emitCustomEvent.js +5 -2
  51. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  52. package/dist/esm/decorators/index.js +3 -3
  53. package/dist/esm/decorators/index.js.map +1 -1
  54. package/dist/esm/decorators/lifecycles.js +9 -9
  55. package/dist/esm/decorators/lifecycles.js.map +2 -2
  56. package/dist/esm/decorators/query.js +1 -1
  57. package/dist/esm/decorators/query.js.map +2 -2
  58. package/dist/esm/decorators/queryAll.js +1 -1
  59. package/dist/esm/decorators/queryAll.js.map +2 -2
  60. package/dist/esm/elements/SwcAppEngine.js +19 -4
  61. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  62. package/dist/esm/elements/SwcAppMixin.js +2 -0
  63. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  64. package/dist/esm/utils/Utils.js +1 -1
  65. package/dist/esm/utils/Utils.js.map +2 -2
  66. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
  67. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  68. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  69. package/dist/types/decorators/applyAttribute.d.ts +22 -0
  70. package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
  71. package/dist/types/decorators/applyClass.d.ts +65 -0
  72. package/dist/types/decorators/applyClass.d.ts.map +1 -0
  73. package/dist/types/decorators/applyNode.d.ts +15 -123
  74. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  75. package/dist/types/decorators/applyStyle.d.ts +21 -0
  76. package/dist/types/decorators/applyStyle.d.ts.map +1 -0
  77. package/dist/types/decorators/attribute.d.ts +10 -19
  78. package/dist/types/decorators/attribute.d.ts.map +1 -1
  79. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  80. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  81. package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
  82. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  83. package/dist/types/decorators/index.d.ts +3 -3
  84. package/dist/types/decorators/index.d.ts.map +1 -1
  85. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  86. package/dist/types/decorators/query.d.ts.map +1 -1
  87. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  88. package/dist/types/elements/SwcAppEngine.d.ts +7 -0
  89. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  90. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  91. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  92. package/dist/types/utils/Utils.d.ts.map +1 -1
  93. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
  94. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  95. package/package.json +2 -2
  96. package/src/decorators/addEventListener.ts +1 -1
  97. package/src/decorators/applyAttribute.ts +147 -0
  98. package/src/decorators/applyClass.ts +158 -0
  99. package/src/decorators/applyNode.ts +112 -330
  100. package/src/decorators/applyStyle.ts +128 -0
  101. package/src/decorators/attribute.ts +21 -55
  102. package/src/decorators/changedAttributeHost.ts +1 -1
  103. package/src/decorators/elementDefine.ts +18 -39
  104. package/src/decorators/emitCustomEvent.ts +6 -3
  105. package/src/decorators/index.ts +3 -3
  106. package/src/decorators/lifecycles.ts +9 -11
  107. package/src/decorators/query.ts +1 -1
  108. package/src/decorators/queryAll.ts +1 -1
  109. package/src/elements/SwcAppEngine.ts +32 -4
  110. package/src/elements/SwcAppMixin.ts +2 -0
  111. package/src/utils/Utils.ts +2 -1
  112. package/dist/cjs/decorators/classList.js +0 -177
  113. package/dist/cjs/decorators/classList.js.map +0 -7
  114. package/dist/cjs/decorators/setAttribute.js +0 -111
  115. package/dist/cjs/decorators/setAttribute.js.map +0 -7
  116. package/dist/cjs/decorators/style.js.map +0 -7
  117. package/dist/esm/decorators/classList.js +0 -158
  118. package/dist/esm/decorators/classList.js.map +0 -7
  119. package/dist/esm/decorators/setAttribute.js +0 -92
  120. package/dist/esm/decorators/setAttribute.js.map +0 -7
  121. package/dist/esm/decorators/style.js.map +0 -7
  122. package/dist/types/decorators/classList.d.ts +0 -71
  123. package/dist/types/decorators/classList.d.ts.map +0 -1
  124. package/dist/types/decorators/setAttribute.d.ts +0 -23
  125. package/dist/types/decorators/setAttribute.d.ts.map +0 -1
  126. package/dist/types/decorators/style.d.ts +0 -58
  127. package/dist/types/decorators/style.d.ts.map +0 -1
  128. package/src/decorators/classList.ts +0 -234
  129. package/src/decorators/setAttribute.ts +0 -114
  130. package/src/decorators/style.ts +0 -185
@@ -1,92 +0,0 @@
1
- import { ReflectUtils } from "@dooboostore/core";
2
- import { ensureInit, getElementConfig } from "./elementDefine.js";
3
- import { SwcUtils } from "../utils/Utils.js";
4
- const SET_ATTRIBUTE_METADATA_KEY = Symbol("simple-web-component:set-attribute");
5
- function setAttribute(selector, name, options = {}) {
6
- return (target, propertyKey, descriptor) => {
7
- const constructor = target.constructor;
8
- let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
9
- if (!metaList) {
10
- metaList = /* @__PURE__ */ new Map();
11
- ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);
12
- }
13
- metaList.set(propertyKey, { propertyKey, selector, name, options });
14
- const original = descriptor.value;
15
- descriptor.value = async function(...args) {
16
- ensureInit(this);
17
- const res = await original.apply(this, args);
18
- if (res !== void 0) {
19
- const hostSet = SwcUtils.getHostSet(this);
20
- const conf = getElementConfig(this);
21
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
22
- const targetEls = [];
23
- const r = options.root || "auto";
24
- const applyRoot = (t) => {
25
- if (!t) return;
26
- if (r === "auto") {
27
- targetEls.push(t);
28
- } else {
29
- if (r === "light" || r === "all") targetEls.push(t);
30
- if ((r === "shadow" || r === "all") && t.shadowRoot) targetEls.push(t.shadowRoot);
31
- }
32
- };
33
- if (selector === ":window") targetEls.push(currentWin);
34
- else if (selector === ":document") targetEls.push(currentWin.document);
35
- else if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
36
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
37
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
38
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
39
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
40
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
41
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
42
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
43
- else if (selector === ":host" || !selector) applyRoot(this);
44
- else {
45
- const roots = [];
46
- if (r === "shadow") {
47
- if (this.shadowRoot) roots.push(this.shadowRoot);
48
- } else if (r === "light") {
49
- roots.push(this);
50
- } else if (r === "all") {
51
- roots.push(this);
52
- if (this.shadowRoot) roots.push(this.shadowRoot);
53
- } else {
54
- roots.push(this.shadowRoot || this);
55
- }
56
- roots.forEach((root) => targetEls.push(...root.querySelectorAll(selector)));
57
- }
58
- targetEls.forEach((targetEl) => {
59
- if (!targetEl || typeof targetEl.setAttribute !== "function") return;
60
- if (res === null) targetEl.removeAttribute(name);
61
- else targetEl.setAttribute(name, String(res));
62
- });
63
- }
64
- return res;
65
- };
66
- };
67
- }
68
- const getSetAttributeMetadata = (target) => {
69
- const constructor = target instanceof Function ? target : target.constructor;
70
- return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
71
- };
72
- const findAllSetAttributeMetadata = (target) => {
73
- const result = /* @__PURE__ */ new Map();
74
- const maps = ReflectUtils.findAllMetadata(SET_ATTRIBUTE_METADATA_KEY, target);
75
- maps.forEach((map) => {
76
- if (map instanceof Map) {
77
- map.forEach((v, k) => result.set(k, v));
78
- }
79
- });
80
- return result;
81
- };
82
- function setAttributeHost(name, options) {
83
- return setAttribute(":host", name, options);
84
- }
85
- export {
86
- SET_ATTRIBUTE_METADATA_KEY,
87
- findAllSetAttributeMetadata,
88
- getSetAttributeMetadata,
89
- setAttribute,
90
- setAttributeHost
91
- };
92
- //# sourceMappingURL=setAttribute.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/setAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface SetAttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n name: string;\n options: SwcQueryOptions;\n}\n\nexport const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');\n\n/**\n * @setAttribute decorator to surgically update an attribute of a target element.\n * Usage: @setAttribute(':host', 'count')\n * Usage: @setAttribute('#child', 'disabled')\n */\nexport function setAttribute(selector: string, name: string): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options: SwcQueryOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, SetAttributeMetadata>();\n ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, name, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const targetEls: any[] = [];\n const r = options.root || 'auto';\n\n const applyRoot = (t: any) => {\n if (!t) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n targetEls.push(t);\n } else {\n if (r === 'light' || r === 'all') targetEls.push(t);\n if ((r === 'shadow' || r === 'all') && (t as any).shadowRoot) targetEls.push((t as any).shadowRoot);\n }\n };\n\n if (selector === ':window') targetEls.push(currentWin);\n else if (selector === ':document') targetEls.push(currentWin.document as any);\n else if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(this);\n else {\n const roots: any[] = [];\n if (r === 'shadow') {\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else if (r === 'light') {\n roots.push(this as any);\n } else if (r === 'all') {\n roots.push(this as any);\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else {\n roots.push((this as any).shadowRoot || (this as any));\n }\n roots.forEach(root => targetEls.push(...root.querySelectorAll(selector)));\n }\n\n targetEls.forEach(targetEl => {\n if (!targetEl || typeof (targetEl as any).setAttribute !== 'function') return;\n if (res === null) (targetEl as any).removeAttribute(name);\n else (targetEl as any).setAttribute(name, String(res));\n });\n }\n return res;\n };\n };\n}\n\nexport const getSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);\n};\n\nexport const findAllSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> => {\n const result = new Map<string | symbol, SetAttributeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, SetAttributeMetadata>>(SET_ATTRIBUTE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\n/**\n * @setAttributeHost decorator - simplified version of @setAttribute for :host selector\n * Usage: @setAttributeHost('aria-disabled')\n */\nexport function setAttributeHost(name: string, options?: SwcQueryOptions): MethodDecorator {\n return setAttribute(':host', name, options);\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAC7C,SAAS,gBAAgB;AAUlB,MAAM,6BAA6B,OAAO,oCAAoC;AAS9E,SAAS,aAAa,UAAkB,MAAc,UAA2B,CAAC,GAAoB;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,4BAA4B,WAAW;AAClF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA2C;AAC1D,mBAAa,eAAe,4BAA4B,UAAU,WAAW;AAAA,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ourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleOptions extends SwcQueryOptions {}\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const r = options.root || 'auto';\n const hostSet = SwcUtils.getHostSet(this as any);\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return;\n if (r === 'auto') {\n // Styles belong to the ELEMENT, not the ShadowRoot.\n targetEls.push(t);\n } else {\n if (r === 'light' || r === 'all') targetEls.push(t);\n if ((r === 'shadow' || r === 'all') && t.shadowRoot) {\n // ShadowRoot doesn't have a style property, so we skip it.\n }\n }\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(this);\n else {\n if (r === 'shadow') {\n const found = this.shadowRoot?.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n } else if (r === 'light') {\n const found = (this as any).querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n } else if (r === 'all') {\n const sFound = this.shadowRoot?.querySelectorAll(selector);\n const lFound = (this as any).querySelectorAll(selector);\n if (sFound) targetEls.push(...(Array.from(sFound) as HTMLElement[]));\n if (lFound) targetEls.push(...(Array.from(lFound) as HTMLElement[]));\n } else {\n // auto\n const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (action === 'set') {\n targetEl.style.cssText = '';\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n } else if (typeof res === 'string') {\n targetEl.style.cssText = res;\n }\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n }\n } else if (action === 'remove') {\n const props = Array.isArray(res) ? res : [res];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n });\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).\n * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }\n * Usage: @setStyle('#box', { root: 'shadow' }) getStyles() { return { color: 'red' }; }\n */\nexport const setStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('set')(selector, options);\n\n/**\n * @setStyleHost decorator - simplified version of @setStyle for :host selector.\n * Usage: @setStyleHost setHostStyle() { return { color: 'red' }; }\n * Usage: @setStyleHost() setHostStyle() { return { color: 'red' }; }\n * Usage: @setStyleHost({ ... }) setHostStyle() { return { color: 'red' }; }\n */\nexport function setStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function setStyleHost(): MethodDecorator;\nexport function setStyleHost(options: StyleOptions): MethodDecorator;\nexport function setStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('set')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('set')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\n/**\n * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).\n * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyle('#box', { root: 'shadow' }) updateStyles() { return { color: 'blue' }; }\n */\nexport const updateStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('update')(selector, options);\n\n/**\n * @updateStyleHost decorator - simplified version of @updateStyle for :host selector.\n * Usage: @updateStyleHost updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyleHost() updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyleHost({ ... }) updateStyles() { return { color: 'blue' }; }\n */\nexport function updateStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function updateStyleHost(): MethodDecorator;\nexport function updateStyleHost(options: StyleOptions): MethodDecorator;\nexport function updateStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('update')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('update')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\n/**\n * @removeStyle decorator to surgically remove styles from a target element.\n * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }\n * Usage: @removeStyle('#box', { root: 'shadow' }) clearStyles() { return ['color']; }\n */\nexport const removeStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n/**\n * @removeStyleHost decorator - simplified version of @removeStyle for :host selector.\n * Usage: @removeStyleHost clearStyles() { return ['color']; }\n * Usage: @removeStyleHost() clearStyles() { return ['color']; }\n * Usage: @removeStyleHost({ ... }) clearStyles() { return ['color']; }\n */\nexport function removeStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function removeStyleHost(): MethodDecorator;\nexport function removeStyleHost(options: StyleOptions): MethodDecorator;\nexport function removeStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('remove')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('remove')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {\n const result = new Map<string | symbol, StyleMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAclB,MAAM,qBAAqB,OAAO,4BAA4B;AAErE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,UAAwB,CAAC,MAAuB;AACxE,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,aAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAoC;AACnD,qBAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,mBAAW,IAAI;AACf,c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,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACrF;AAOO,MAAM,cAAc,CAAC,UAAkB,UAAwB,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAWtH,SAAS,gBAAgB,iBAAuB,aAA+B,YAAsC;AAC1H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,qBAAqB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5D,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,qBAAqB,QAAQ,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACxF;AAOO,MAAM,cAAc,CAAC,UAAkB,UAAwB,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAWtH,SAAS,gBAAgB,iBAAuB,aAA+B,YAAsC;AAC1H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,qBAAqB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5D,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,qBAAqB,QAAQ,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACxF;AAEO,MAAM,uBAAuB,CAAC,WAAqD;AACxF,QAAM,SAAS,oBAAI,IAAoC;AACvD,QAAM,OAAO,aAAa,gBAAqD,oBAAoB,MAAM;AACzG,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,71 +0,0 @@
1
- import { SwcQueryOptions } from '../types';
2
- export declare const CLASS_LIST_METADATA_KEY: unique symbol;
3
- export type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';
4
- export interface ClassListMetadata {
5
- propertyKey: string | symbol;
6
- selector: string;
7
- action: ClassListAction;
8
- options: SwcQueryOptions;
9
- }
10
- /**
11
- * @setClassList decorator to surgically replace all classes on a target element.
12
- * Returns: string | string[]
13
- */
14
- export declare const setClassList: (selector: string, options?: SwcQueryOptions) => MethodDecorator;
15
- /**
16
- * @updateClassList decorator to surgically update specific classes.
17
- * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)
18
- */
19
- export declare const updateClassList: (selector: string, options?: SwcQueryOptions) => MethodDecorator;
20
- /**
21
- * @addClassList decorator to surgically add classes to a target element.
22
- * Returns: string | string[]
23
- */
24
- export declare const addClassList: (selector: string, options?: SwcQueryOptions) => MethodDecorator;
25
- /**
26
- * @removeClassList decorator to surgically remove classes from a target element.
27
- * Returns: string | string[]
28
- */
29
- export declare const removeClassList: (selector: string, options?: SwcQueryOptions) => MethodDecorator;
30
- /**
31
- * @toggleClassList decorator to surgically toggle classes on a target element.
32
- * Returns: string | string[]
33
- */
34
- export declare const toggleClassList: (selector: string, options?: SwcQueryOptions) => MethodDecorator;
35
- /**
36
- * @setClassListHost decorator to set classes on :host element.
37
- * Returns: string | string[]
38
- */
39
- export declare function setClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
40
- export declare function setClassListHost(): MethodDecorator;
41
- export declare function setClassListHost(options: SwcQueryOptions): MethodDecorator;
42
- /**
43
- * @updateClassListHost decorator to update specific classes on :host.
44
- * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)
45
- */
46
- export declare function updateClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
47
- export declare function updateClassListHost(): MethodDecorator;
48
- export declare function updateClassListHost(options: SwcQueryOptions): MethodDecorator;
49
- /**
50
- * @addClassListHost decorator to add classes to :host element.
51
- * Returns: string | string[]
52
- */
53
- export declare function addClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
54
- export declare function addClassListHost(): MethodDecorator;
55
- export declare function addClassListHost(options: SwcQueryOptions): MethodDecorator;
56
- /**
57
- * @removeClassListHost decorator to remove classes from :host element.
58
- * Returns: string | string[]
59
- */
60
- export declare function removeClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
61
- export declare function removeClassListHost(): MethodDecorator;
62
- export declare function removeClassListHost(options: SwcQueryOptions): MethodDecorator;
63
- /**
64
- * @toggleClassListHost decorator to toggle classes on :host element.
65
- * Returns: string | string[]
66
- */
67
- export declare function toggleClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
68
- export declare function toggleClassListHost(): MethodDecorator;
69
- export declare function toggleClassListHost(options: SwcQueryOptions): MethodDecorator;
70
- export declare const findAllClassListMetadata: (target: any) => Map<string | symbol, ClassListMetadata>;
71
- //# sourceMappingURL=classList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"classList.d.ts","sourceRoot":"","sources":["../../../src/decorators/classList.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,uBAAuB,eAA4C,CAAC;AAEjF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7E,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAuGD;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,UAAS,eAAoB,oBAAuD,CAAC;AAEpI;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,UAAS,eAAoB,oBAA0D,CAAC;AAE1I;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,UAAS,eAAoB,oBAAuD,CAAC;AAEpI;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,UAAS,eAAoB,oBAA0D,CAAC;AAE1I;;;GA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B,IAAI,eAAe,CAAC;AACvD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CAAC;AAS/E,eAAO,MAAM,wBAAwB,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,iBAAiB,CAS5F,CAAC"}
@@ -1,23 +0,0 @@
1
- import { SwcQueryOptions } from '../types';
2
- export interface SetAttributeMetadata {
3
- propertyKey: string | symbol;
4
- selector: string;
5
- name: string;
6
- options: SwcQueryOptions;
7
- }
8
- export declare const SET_ATTRIBUTE_METADATA_KEY: unique symbol;
9
- /**
10
- * @setAttribute decorator to surgically update an attribute of a target element.
11
- * Usage: @setAttribute(':host', 'count')
12
- * Usage: @setAttribute('#child', 'disabled')
13
- */
14
- export declare function setAttribute(selector: string, name: string): MethodDecorator;
15
- export declare function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;
16
- export declare const getSetAttributeMetadata: (target: any) => Map<string | symbol, SetAttributeMetadata> | undefined;
17
- export declare const findAllSetAttributeMetadata: (target: any) => Map<string | symbol, SetAttributeMetadata>;
18
- /**
19
- * @setAttributeHost decorator - simplified version of @setAttribute for :host selector
20
- * Usage: @setAttributeHost('aria-disabled')
21
- */
22
- export declare function setAttributeHost(name: string, options?: SwcQueryOptions): MethodDecorator;
23
- //# sourceMappingURL=setAttribute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setAttribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/setAttribute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,eAAO,MAAM,0BAA0B,eAA+C,CAAC;AAEvF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;AAC9E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;AAuEzG,eAAO,MAAM,uBAAuB,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAGlG,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,oBAAoB,CASlG,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,eAAe,CAEzF"}
@@ -1,58 +0,0 @@
1
- import { SwcQueryOptions } from '../types';
2
- export type StyleAction = 'set' | 'update' | 'remove';
3
- export interface StyleOptions extends SwcQueryOptions {
4
- }
5
- export interface StyleMetadata {
6
- propertyKey: string | symbol;
7
- selector: string;
8
- action: StyleAction;
9
- options: StyleOptions;
10
- }
11
- export declare const STYLE_METADATA_KEY: unique symbol;
12
- /**
13
- * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).
14
- * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }
15
- * Usage: @setStyle('#box', { root: 'shadow' }) getStyles() { return { color: 'red' }; }
16
- */
17
- export declare const setStyle: (selector: string, options?: StyleOptions) => MethodDecorator;
18
- /**
19
- * @setStyleHost decorator - simplified version of @setStyle for :host selector.
20
- * Usage: @setStyleHost setHostStyle() { return { color: 'red' }; }
21
- * Usage: @setStyleHost() setHostStyle() { return { color: 'red' }; }
22
- * Usage: @setStyleHost({ ... }) setHostStyle() { return { color: 'red' }; }
23
- */
24
- export declare function setStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
25
- export declare function setStyleHost(): MethodDecorator;
26
- export declare function setStyleHost(options: StyleOptions): MethodDecorator;
27
- /**
28
- * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).
29
- * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }
30
- * Usage: @updateStyle('#box', { root: 'shadow' }) updateStyles() { return { color: 'blue' }; }
31
- */
32
- export declare const updateStyle: (selector: string, options?: StyleOptions) => MethodDecorator;
33
- /**
34
- * @updateStyleHost decorator - simplified version of @updateStyle for :host selector.
35
- * Usage: @updateStyleHost updateStyles() { return { color: 'blue' }; }
36
- * Usage: @updateStyleHost() updateStyles() { return { color: 'blue' }; }
37
- * Usage: @updateStyleHost({ ... }) updateStyles() { return { color: 'blue' }; }
38
- */
39
- export declare function updateStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
40
- export declare function updateStyleHost(): MethodDecorator;
41
- export declare function updateStyleHost(options: StyleOptions): MethodDecorator;
42
- /**
43
- * @removeStyle decorator to surgically remove styles from a target element.
44
- * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }
45
- * Usage: @removeStyle('#box', { root: 'shadow' }) clearStyles() { return ['color']; }
46
- */
47
- export declare const removeStyle: (selector: string, options?: StyleOptions) => MethodDecorator;
48
- /**
49
- * @removeStyleHost decorator - simplified version of @removeStyle for :host selector.
50
- * Usage: @removeStyleHost clearStyles() { return ['color']; }
51
- * Usage: @removeStyleHost() clearStyles() { return ['color']; }
52
- * Usage: @removeStyleHost({ ... }) clearStyles() { return ['color']; }
53
- */
54
- export declare function removeStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
55
- export declare function removeStyleHost(): MethodDecorator;
56
- export declare function removeStyleHost(options: StyleOptions): MethodDecorator;
57
- export declare const findAllStyleMetadata: (target: any) => Map<string | symbol, StyleMetadata>;
58
- //# sourceMappingURL=style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/decorators/style.ts"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,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,GAAG,CAAC;AACnH,wBAAgB,eAAe,IAAI,eAAe,CAAC;AACnD,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,CAAC;AASxE,eAAO,MAAM,oBAAoB,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,aAAa,CASpF,CAAC"}
@@ -1,234 +0,0 @@
1
- import { ReflectUtils } from '@dooboostore/core';
2
- import { ensureInit } from './elementDefine';
3
- import { SwcUtils } from '../utils/Utils';
4
- import { SwcQueryOptions } from '../types';
5
-
6
- export const CLASS_LIST_METADATA_KEY = Symbol('simple-web-component:class-list');
7
-
8
- export type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';
9
-
10
- export interface ClassListMetadata {
11
- propertyKey: string | symbol;
12
- selector: string;
13
- action: ClassListAction;
14
- options: SwcQueryOptions;
15
- }
16
-
17
- function createClassListDecorator(action: ClassListAction) {
18
- return (selector: string, options: SwcQueryOptions = {}): MethodDecorator => {
19
- return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
20
- const constructor = target.constructor;
21
- let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor) as Map<string | symbol, ClassListMetadata>;
22
- if (!metaList) {
23
- metaList = new Map<string | symbol, ClassListMetadata>();
24
- ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);
25
- }
26
- metaList.set(propertyKey, { propertyKey, selector, action, options });
27
-
28
- const original = descriptor.value;
29
- descriptor.value = async function (...args: any[]) {
30
- ensureInit(this);
31
- const res = await original.apply(this, args);
32
- if (res !== undefined) {
33
- const r = options.root || 'auto';
34
- const hostSet = SwcUtils.getHostSet(this as any);
35
- const targetEls: HTMLElement[] = [];
36
-
37
- const applyRoot = (t: any) => {
38
- if (!t || !(t instanceof HTMLElement)) return;
39
- if (r === 'auto') {
40
- // Classes belong to the ELEMENT, not the ShadowRoot.
41
- targetEls.push(t);
42
- } else {
43
- if (r === 'light' || r === 'all') targetEls.push(t);
44
- if ((r === 'shadow' || r === 'all') && t.shadowRoot) {
45
- // Technically ShadowRoot doesn't have classList, but user might have specified it.
46
- // We'll skip adding shadowRoot to targetEls for class operations.
47
- }
48
- }
49
- };
50
-
51
- if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
52
- else if (selector === ':appHost') applyRoot(hostSet.$appHost);
53
- else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
54
- else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
55
- else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
56
- else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
57
- else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
58
- else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
59
- else if (selector === ':host' || !selector) applyRoot(this);
60
- else {
61
- if (r === 'shadow') {
62
- const found = this.shadowRoot?.querySelectorAll(selector);
63
- if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
64
- } else if (r === 'light') {
65
- const found = (this as any).querySelectorAll(selector);
66
- if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
67
- } else if (r === 'all') {
68
- const sFound = this.shadowRoot?.querySelectorAll(selector);
69
- const lFound = (this as any).querySelectorAll(selector);
70
- if (sFound) targetEls.push(...(Array.from(sFound) as HTMLElement[]));
71
- if (lFound) targetEls.push(...(Array.from(lFound) as HTMLElement[]));
72
- } else {
73
- // auto
74
- const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);
75
- if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
76
- }
77
- }
78
-
79
- targetEls.forEach(targetEl => {
80
- if (action === 'set') {
81
- let classes = '';
82
- if (typeof res === 'object' && res !== null && !Array.isArray(res)) {
83
- classes = Object.entries(res)
84
- .filter(([_, force]) => !!force)
85
- .map(([cls]) => cls)
86
- .join(' ');
87
- } else {
88
- classes = Array.isArray(res) ? res.join(' ') : String(res);
89
- }
90
- targetEl.className = classes;
91
- } else if (action === 'update') {
92
- if (typeof res === 'object' && res !== null && !Array.isArray(res)) {
93
- Object.entries(res).forEach(([cls, force]) => {
94
- targetEl.classList.toggle(cls, !!force);
95
- });
96
- } else if (res !== undefined && res !== null) {
97
- const classes = Array.isArray(res) ? res.map(String) : [String(res)];
98
- targetEl.classList.add(...classes);
99
- }
100
- } else if (action === 'add') {
101
- const classes = Array.isArray(res) ? res.map(String) : [String(res)];
102
- targetEl.classList.add(...classes);
103
- } else if (action === 'remove') {
104
- const classes = Array.isArray(res) ? res.map(String) : [String(res)];
105
- targetEl.classList.remove(...classes);
106
- } else if (action === 'toggle') {
107
- const classes = Array.isArray(res) ? res.map(String) : [String(res)];
108
- classes.forEach(c => targetEl.classList.toggle(c));
109
- }
110
- });
111
- }
112
- return res;
113
- };
114
- };
115
- };
116
- }
117
-
118
- /**
119
- * @setClassList decorator to surgically replace all classes on a target element.
120
- * Returns: string | string[]
121
- */
122
- export const setClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('set')(selector, options);
123
-
124
- /**
125
- * @updateClassList decorator to surgically update specific classes.
126
- * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)
127
- */
128
- export const updateClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('update')(selector, options);
129
-
130
- /**
131
- * @addClassList decorator to surgically add classes to a target element.
132
- * Returns: string | string[]
133
- */
134
- export const addClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('add')(selector, options);
135
-
136
- /**
137
- * @removeClassList decorator to surgically remove classes from a target element.
138
- * Returns: string | string[]
139
- */
140
- export const removeClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('remove')(selector, options);
141
-
142
- /**
143
- * @toggleClassList decorator to surgically toggle classes on a target element.
144
- * Returns: string | string[]
145
- */
146
- export const toggleClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('toggle')(selector, options);
147
-
148
- // Host-specific versions (for :host selector)
149
-
150
- /**
151
- * @setClassListHost decorator to set classes on :host element.
152
- * Returns: string | string[]
153
- */
154
- export function setClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
155
- export function setClassListHost(): MethodDecorator;
156
- export function setClassListHost(options: SwcQueryOptions): MethodDecorator;
157
- export function setClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
158
- if (propertyKey !== undefined) {
159
- const decorator = createClassListDecorator('set')(':host', {});
160
- return decorator(targetOrOptions, propertyKey, descriptor);
161
- }
162
- return createClassListDecorator('set')(':host', (targetOrOptions as SwcQueryOptions) || {});
163
- }
164
-
165
- /**
166
- * @updateClassListHost decorator to update specific classes on :host.
167
- * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)
168
- */
169
- export function updateClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
170
- export function updateClassListHost(): MethodDecorator;
171
- export function updateClassListHost(options: SwcQueryOptions): MethodDecorator;
172
- export function updateClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
173
- if (propertyKey !== undefined) {
174
- const decorator = createClassListDecorator('update')(':host', {});
175
- return decorator(targetOrOptions, propertyKey, descriptor);
176
- }
177
- return createClassListDecorator('update')(':host', (targetOrOptions as SwcQueryOptions) || {});
178
- }
179
-
180
- /**
181
- * @addClassListHost decorator to add classes to :host element.
182
- * Returns: string | string[]
183
- */
184
- export function addClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
185
- export function addClassListHost(): MethodDecorator;
186
- export function addClassListHost(options: SwcQueryOptions): MethodDecorator;
187
- export function addClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
188
- if (propertyKey !== undefined) {
189
- const decorator = createClassListDecorator('add')(':host', {});
190
- return decorator(targetOrOptions, propertyKey, descriptor);
191
- }
192
- return createClassListDecorator('add')(':host', (targetOrOptions as SwcQueryOptions) || {});
193
- }
194
-
195
- /**
196
- * @removeClassListHost decorator to remove classes from :host element.
197
- * Returns: string | string[]
198
- */
199
- export function removeClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
200
- export function removeClassListHost(): MethodDecorator;
201
- export function removeClassListHost(options: SwcQueryOptions): MethodDecorator;
202
- export function removeClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
203
- if (propertyKey !== undefined) {
204
- const decorator = createClassListDecorator('remove')(':host', {});
205
- return decorator(targetOrOptions, propertyKey, descriptor);
206
- }
207
- return createClassListDecorator('remove')(':host', (targetOrOptions as SwcQueryOptions) || {});
208
- }
209
-
210
- /**
211
- * @toggleClassListHost decorator to toggle classes on :host element.
212
- * Returns: string | string[]
213
- */
214
- export function toggleClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
215
- export function toggleClassListHost(): MethodDecorator;
216
- export function toggleClassListHost(options: SwcQueryOptions): MethodDecorator;
217
- export function toggleClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
218
- if (propertyKey !== undefined) {
219
- const decorator = createClassListDecorator('toggle')(':host', {});
220
- return decorator(targetOrOptions, propertyKey, descriptor);
221
- }
222
- return createClassListDecorator('toggle')(':host', (targetOrOptions as SwcQueryOptions) || {});
223
- }
224
-
225
- export const findAllClassListMetadata = (target: any): Map<string | symbol, ClassListMetadata> => {
226
- const result = new Map<string | symbol, ClassListMetadata>();
227
- const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassListMetadata>>(CLASS_LIST_METADATA_KEY, target);
228
- maps.forEach(map => {
229
- if (map instanceof Map) {
230
- map.forEach((v, k) => result.set(k, v));
231
- }
232
- });
233
- return result;
234
- };