@dooboostore/simple-web-component 1.0.22 → 1.0.23

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 (71) hide show
  1. package/README.md +361 -19
  2. package/dist/cjs/decorators/applyNode.js +98 -24
  3. package/dist/cjs/decorators/applyNode.js.map +2 -2
  4. package/dist/cjs/decorators/attribute.js +0 -1
  5. package/dist/cjs/decorators/attribute.js.map +2 -2
  6. package/dist/cjs/decorators/classList.js +39 -19
  7. package/dist/cjs/decorators/classList.js.map +2 -2
  8. package/dist/cjs/decorators/elementDefine.js +1 -2
  9. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  10. package/dist/cjs/decorators/index.js +0 -1
  11. package/dist/cjs/decorators/index.js.map +2 -2
  12. package/dist/cjs/decorators/lifecycles.js +25 -0
  13. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  14. package/dist/cjs/decorators/query.js.map +2 -2
  15. package/dist/cjs/decorators/style.js +39 -13
  16. package/dist/cjs/decorators/style.js.map +2 -2
  17. package/dist/cjs/utils/TemplateUtils.js +6 -0
  18. package/dist/cjs/utils/TemplateUtils.js.map +2 -2
  19. package/dist/esm/decorators/applyNode.js +98 -24
  20. package/dist/esm/decorators/applyNode.js.map +2 -2
  21. package/dist/esm/decorators/attribute.js +0 -1
  22. package/dist/esm/decorators/attribute.js.map +2 -2
  23. package/dist/esm/decorators/classList.js +39 -19
  24. package/dist/esm/decorators/classList.js.map +2 -2
  25. package/dist/esm/decorators/elementDefine.js +1 -2
  26. package/dist/esm/decorators/elementDefine.js.map +2 -2
  27. package/dist/esm/decorators/index.js +0 -1
  28. package/dist/esm/decorators/index.js.map +2 -2
  29. package/dist/esm/decorators/lifecycles.js +25 -0
  30. package/dist/esm/decorators/lifecycles.js.map +2 -2
  31. package/dist/esm/decorators/query.js.map +2 -2
  32. package/dist/esm/decorators/style.js +39 -13
  33. package/dist/esm/decorators/style.js.map +2 -2
  34. package/dist/esm/utils/TemplateUtils.js +6 -0
  35. package/dist/esm/utils/TemplateUtils.js.map +2 -2
  36. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +204 -81
  37. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  38. package/dist/types/decorators/applyNode.d.ts +84 -1
  39. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  40. package/dist/types/decorators/classList.d.ts +12 -10
  41. package/dist/types/decorators/classList.d.ts.map +1 -1
  42. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  43. package/dist/types/decorators/index.d.ts +0 -1
  44. package/dist/types/decorators/index.d.ts.map +1 -1
  45. package/dist/types/decorators/lifecycles.d.ts +14 -0
  46. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  47. package/dist/types/decorators/query.d.ts +0 -3
  48. package/dist/types/decorators/query.d.ts.map +1 -1
  49. package/dist/types/decorators/style.d.ts +28 -3
  50. package/dist/types/decorators/style.d.ts.map +1 -1
  51. package/dist/types/utils/TemplateUtils.d.ts +5 -0
  52. package/dist/types/utils/TemplateUtils.d.ts.map +1 -1
  53. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +204 -81
  54. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  55. package/package.json +3 -3
  56. package/src/decorators/applyNode.ts +199 -36
  57. package/src/decorators/attribute.ts +1 -1
  58. package/src/decorators/classList.ts +45 -22
  59. package/src/decorators/elementDefine.ts +1 -2
  60. package/src/decorators/index.ts +0 -1
  61. package/src/decorators/lifecycles.ts +40 -0
  62. package/src/decorators/query.ts +0 -2
  63. package/src/decorators/style.ts +64 -13
  64. package/src/utils/TemplateUtils.ts +9 -0
  65. package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
  66. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
  67. package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
  68. package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
  69. package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
  70. package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
  71. package/src/decorators/onConnectedInnerHtml.ts +0 -42
@@ -20,8 +20,11 @@ __export(style_exports, {
20
20
  STYLE_METADATA_KEY: () => STYLE_METADATA_KEY,
21
21
  findAllStyleMetadata: () => findAllStyleMetadata,
22
22
  removeStyle: () => removeStyle,
23
+ removeStyleHost: () => removeStyleHost,
23
24
  setStyle: () => setStyle,
24
- updateStyle: () => updateStyle
25
+ setStyleHost: () => setStyleHost,
26
+ updateStyle: () => updateStyle,
27
+ updateStyleHost: () => updateStyleHost
25
28
  });
26
29
  module.exports = __toCommonJS(style_exports);
27
30
  var import_core = require("@dooboostore/core");
@@ -29,7 +32,7 @@ var import_elementDefine = require("./elementDefine");
29
32
  var import_Utils = require("../utils/Utils");
30
33
  const STYLE_METADATA_KEY = Symbol("simple-web-component:style");
31
34
  function createStyleDecorator(action) {
32
- return (selector) => {
35
+ return (selector, options = {}) => {
33
36
  return (target, propertyKey, descriptor) => {
34
37
  const constructor = target.constructor;
35
38
  let metaList = import_core.ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor);
@@ -37,19 +40,39 @@ function createStyleDecorator(action) {
37
40
  metaList = /* @__PURE__ */ new Map();
38
41
  import_core.ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
39
42
  }
40
- metaList.set(propertyKey, { propertyKey, selector, action });
43
+ metaList.set(propertyKey, { propertyKey, selector, action, options });
41
44
  const original = descriptor.value;
42
45
  descriptor.value = async function(...args) {
43
46
  (0, import_elementDefine.ensureInit)(this);
44
47
  const res = await original.apply(this, args);
45
48
  if (res !== void 0) {
49
+ const r = options.root || "auto";
46
50
  const hostSet = import_Utils.SwcUtils.getHostSet(this);
47
- let targetEl = null;
48
- if (selector === ":host" || !selector) targetEl = this;
49
- else if (selector === ":parentHost") targetEl = hostSet.$parentHost;
50
- else if (selector === ":appHost") targetEl = hostSet.$appHost;
51
- else targetEl = (this.shadowRoot || this).querySelector(selector);
52
- if (targetEl) {
51
+ const targetEls = [];
52
+ if (selector === ":host" || !selector) {
53
+ targetEls.push(this);
54
+ } else if (selector === ":parentHost") {
55
+ if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);
56
+ } else if (selector === ":appHost") {
57
+ if (hostSet.$appHost) targetEls.push(hostSet.$appHost);
58
+ } else {
59
+ if (r === "shadow") {
60
+ const found = this.shadowRoot?.querySelectorAll(selector);
61
+ if (found) targetEls.push(...found);
62
+ } else if (r === "light") {
63
+ const found = this.querySelectorAll(selector);
64
+ if (found) targetEls.push(...found);
65
+ } else if (r === "all") {
66
+ const sFound = this.shadowRoot?.querySelectorAll(selector);
67
+ const lFound = this.querySelectorAll(selector);
68
+ if (sFound) targetEls.push(...sFound);
69
+ if (lFound) targetEls.push(...lFound);
70
+ } else {
71
+ const found = (this.shadowRoot || this).querySelectorAll(selector);
72
+ if (found) targetEls.push(...found);
73
+ }
74
+ }
75
+ targetEls.forEach((targetEl) => {
53
76
  if (action === "set") {
54
77
  targetEl.style.cssText = "";
55
78
  if (typeof res === "object" && res !== null) {
@@ -65,16 +88,19 @@ function createStyleDecorator(action) {
65
88
  const props = Array.isArray(res) ? res : [res];
66
89
  props.forEach((p) => targetEl.style.removeProperty(String(p)));
67
90
  }
68
- }
91
+ });
69
92
  }
70
93
  return res;
71
94
  };
72
95
  };
73
96
  };
74
97
  }
75
- const setStyle = createStyleDecorator("set");
76
- const updateStyle = createStyleDecorator("update");
77
- const removeStyle = createStyleDecorator("remove");
98
+ const setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
99
+ const setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
100
+ const updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
101
+ const updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
102
+ const removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
103
+ const removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
78
104
  const findAllStyleMetadata = (target) => {
79
105
  const result = /* @__PURE__ */ new Map();
80
106
  const maps = import_core.ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/style.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string): 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 });\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 let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) targetEl = this as any;\n else if (selector === ':parentHost') targetEl = hostSet.$parentHost;\n else if (selector === ':appHost') targetEl = hostSet.$appHost;\n else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n\n if (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 */\nexport const setStyle = createStyleDecorator('set');\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 */\nexport const updateStyle = createStyleDecorator('update');\n\n/**\n * @removeStyle decorator to surgically remove styles from a target element.\n * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }\n */\nexport const removeStyle = createStyleDecorator('remove');\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAUlB,MAAM,qBAAqB,OAAO,4BAA4B;AAErE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,aAAsC;AAC5C,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAoC;AACnD,iCAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,OAAO,CAAC;AAE3D,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAAI;AACf,cAAM,MAAM,M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;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
4
+ "sourcesContent": ["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}\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 if (selector === ':host' || !selector) {\n targetEls.push(this as any);\n } else if (selector === ':parentHost') {\n if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);\n } else if (selector === ':appHost') {\n if (hostSet.$appHost) targetEls.push(hostSet.$appHost);\n } else {\n if (r === 'shadow') {\n const found = this.shadowRoot?.querySelectorAll(selector);\n if (found) targetEls.push(...found);\n } else if (r === 'light') {\n const found = (this as any).querySelectorAll(selector);\n if (found) targetEls.push(...found);\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(...sFound);\n if (lFound) targetEls.push(...lFound);\n } else {\n // auto\n const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);\n if (found) targetEls.push(...found);\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 getStyles() { return { color: 'red', display: 'block' }; }\n * Usage: @setStyleHost({ root: 'shadow' }) getStyles() { return { color: 'red' }; }\n */\nexport const setStyleHost = (options: StyleOptions = {}) => createStyleDecorator('set')(':host', options);\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({ root: 'shadow' }) updateStyles() { return { color: 'blue' }; }\n */\nexport const updateStyleHost = (options: StyleOptions = {}) => createStyleDecorator('update')(':host', options);\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', 'display']; }\n * Usage: @removeStyleHost({ root: 'shadow' }) clearStyles() { return ['color']; }\n */\nexport const removeStyleHost = (options: StyleOptions = {}) => createStyleDecorator('remove')(':host', options);\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAelB,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,yBAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAoC;AACnD,iCAAa,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,6CAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AA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_exports, {
20
20
  TemplateUtils: () => TemplateUtils,
21
+ commentNode: () => commentNode,
21
22
  createElement: () => createElement,
22
23
  htmlAElement: () => htmlAElement,
23
24
  htmlArticleElement: () => htmlArticleElement,
@@ -51,6 +52,10 @@ var TemplateUtils;
51
52
  const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
52
53
  return document.createTextNode(raw);
53
54
  };
55
+ TemplateUtils2.commentNode = (strings, ...values) => {
56
+ const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
57
+ return document.createComment(raw);
58
+ };
54
59
  TemplateUtils2.createElement = (info, attrs = {}) => {
55
60
  const el = document.createElement(info.tagName);
56
61
  if (info.innerHtml !== void 0) el.innerHTML = info.innerHtml;
@@ -83,6 +88,7 @@ var TemplateUtils;
83
88
  })(TemplateUtils || (TemplateUtils = {}));
84
89
  const htmlFragment = TemplateUtils.htmlFragment;
85
90
  const textNode = TemplateUtils.textNode;
91
+ const commentNode = TemplateUtils.commentNode;
86
92
  const createElement = TemplateUtils.createElement;
87
93
  const htmlDivElement = TemplateUtils.htmlDivElement;
88
94
  const htmlSpanElement = TemplateUtils.htmlSpanElement;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/TemplateUtils.ts"],
4
- "sourcesContent": ["export interface CreateElementInfo {\n tagName: string;\n innerHtml?: string;\n}\n\nexport namespace TemplateUtils {\n /**\n * Tagged template function to create a DocumentFragment from HTML string.\n */\n export const htmlFragment = (strings: TemplateStringsArray, ...values: any[]): DocumentFragment => {\n const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n const template = document.createElement('template');\n template.innerHTML = raw.trim();\n return template.content;\n };\n\n /**\n * Tagged template function to create a Text node from string.\n */\n export const textNode = (strings: TemplateStringsArray, ...values: any[]): Text => {\n const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n return document.createTextNode(raw);\n };\n\n /**\n * Generic element creator using a configuration object and attribute map.\n */\n export const createElement = <T extends HTMLElement>(info: CreateElementInfo, attrs: Record<string, any> = {}): T => {\n const el = document.createElement(info.tagName) as T;\n if (info.innerHtml !== undefined) el.innerHTML = info.innerHtml;\n Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n return el;\n };\n\n /**\n * Internal factory to create tagged template functions for specific HTML elements.\n */\n const createTagFunction = <T extends HTMLElement>(tagName: string) => {\n return (strings: TemplateStringsArray, ...values: any[]): T => {\n const el = document.createElement(tagName) as T;\n el.innerHTML = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n return el;\n };\n };\n\n // Specific Element Factories\n export const htmlDivElement = createTagFunction<HTMLDivElement>('div');\n export const htmlSpanElement = createTagFunction<HTMLSpanElement>('span');\n export const htmlButtonElement = createTagFunction<HTMLButtonElement>('button');\n export const htmlUlElement = createTagFunction<HTMLUListElement>('ul');\n export const htmlLiElement = createTagFunction<HTMLLIElement>('li');\n export const htmlInputElement = createTagFunction<HTMLInputElement>('input');\n export const htmlAElement = createTagFunction<HTMLAnchorElement>('a');\n export const htmlPElement = createTagFunction<HTMLParagraphElement>('p');\n export const htmlH1Element = createTagFunction<HTMLHeadingElement>('h1');\n export const htmlH2Element = createTagFunction<HTMLHeadingElement>('h2');\n export const htmlH3Element = createTagFunction<HTMLHeadingElement>('h3');\n export const htmlH4Element = createTagFunction<HTMLHeadingElement>('h4');\n export const htmlH5Element = createTagFunction<HTMLHeadingElement>('h5');\n export const htmlH6Element = createTagFunction<HTMLHeadingElement>('h6');\n export const htmlSectionElement = createTagFunction<HTMLElement>('section');\n export const htmlArticleElement = createTagFunction<HTMLElement>('article');\n}\n\nexport const htmlFragment = TemplateUtils.htmlFragment;\nexport const textNode = TemplateUtils.textNode;\nexport const createElement = TemplateUtils.createElement;\nexport const htmlDivElement = TemplateUtils.htmlDivElement;\nexport const htmlSpanElement = TemplateUtils.htmlSpanElement;\nexport const htmlButtonElement = TemplateUtils.htmlButtonElement;\nexport const htmlUlElement = TemplateUtils.htmlUlElement;\nexport const htmlLiElement = TemplateUtils.htmlLiElement;\nexport const htmlInputElement = TemplateUtils.htmlInputElement;\nexport const htmlAElement = TemplateUtils.htmlAElement;\nexport const htmlPElement = TemplateUtils.htmlPElement;\nexport const htmlH1Element = TemplateUtils.htmlH1Element;\nexport const htmlH2Element = TemplateUtils.htmlH2Element;\nexport const htmlH3Element = TemplateUtils.htmlH3Element;\nexport const htmlH4Element = TemplateUtils.htmlH4Element;\nexport const htmlH5Element = TemplateUtils.htmlH5Element;\nexport const htmlH6Element = TemplateUtils.htmlH6Element;\nexport const htmlSectionElement = TemplateUtils.htmlSectionElement;\nexport const htmlArticleElement = TemplateUtils.htmlArticleElement;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAU;AAAA,CAAV,CAAUA,mBAAV;AAIE,EAAMA,eAAA,eAAe,CAAC,YAAkC,WAAoC;AACjG,UAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,KAAK,MAAM,MAAM,OAAO,OAAO,CAAC,MAAM,SAAY,OAAO,CAAC,IAAI,KAAK,EAAE;AACtG,UAAM,WAAW,SAAS,cAAc,UAAU;AAClD,aAAS,YAAY,IAAI,KAAK;AAC9B,WAAO,SAAS;AAAA,EAClB;AAKO,EAAMA,eAAA,WAAW,CAAC,YAAkC,WAAwB;AACjF,UAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,KAAK,MAAM,MAAM,OAAO,OAAO,CAAC,MAAM,SAAY,OAAO,CAAC,IAAI,KAAK,EAAE;AACtG,WAAO,SAAS,eAAe,GAAG;AAAA,EACpC;AAKO,EAAMA,eAAA,gBAAgB,CAAwB,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MAAM,WAAW,cAAc;AAC/B,MAAM,gBAAgB,cAAc;AACpC,MAAM,iBAAiB,cAAc;AACrC,MAAM,kBAAkB,cAAc;AACtC,MAAM,oBAAoB,cAAc;AACxC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,mBAAmB,cAAc;AACvC,MAAM,eAAe,cAAc;AACnC,MAAM,eAAe,cAAc;AACnC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,qBAAqB,cAAc;AACzC,MAAM,qBAAqB,cAAc;",
4
+ "sourcesContent": ["export interface CreateElementInfo {\n tagName: string;\n innerHtml?: string;\n}\n\nexport namespace TemplateUtils {\n /**\n * Tagged template function to create a DocumentFragment from HTML string.\n */\n export const htmlFragment = (strings: TemplateStringsArray, ...values: any[]): DocumentFragment => {\n const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n const template = document.createElement('template');\n template.innerHTML = raw.trim();\n return template.content;\n };\n\n /**\n * Tagged template function to create a Text node from string.\n */\n export const textNode = (strings: TemplateStringsArray, ...values: any[]): Text => {\n const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n return document.createTextNode(raw);\n };\n\n /**\n * Tagged template function to create a Comment node from string.\n */\n export const commentNode = (strings: TemplateStringsArray, ...values: any[]): Comment => {\n const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n return document.createComment(raw);\n };\n\n /**\n * Generic element creator using a configuration object and attribute map.\n */\n export const createElement = <T extends HTMLElement>(info: CreateElementInfo, attrs: Record<string, any> = {}): T => {\n const el = document.createElement(info.tagName) as T;\n if (info.innerHtml !== undefined) el.innerHTML = info.innerHtml;\n Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n return el;\n };\n\n /**\n * Internal factory to create tagged template functions for specific HTML elements.\n */\n const createTagFunction = <T extends HTMLElement>(tagName: string) => {\n return (strings: TemplateStringsArray, ...values: any[]): T => {\n const el = document.createElement(tagName) as T;\n el.innerHTML = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? values[i] : ''), '');\n return el;\n };\n };\n\n // Specific Element Factories\n export const htmlDivElement = createTagFunction<HTMLDivElement>('div');\n export const htmlSpanElement = createTagFunction<HTMLSpanElement>('span');\n export const htmlButtonElement = createTagFunction<HTMLButtonElement>('button');\n export const htmlUlElement = createTagFunction<HTMLUListElement>('ul');\n export const htmlLiElement = createTagFunction<HTMLLIElement>('li');\n export const htmlInputElement = createTagFunction<HTMLInputElement>('input');\n export const htmlAElement = createTagFunction<HTMLAnchorElement>('a');\n export const htmlPElement = createTagFunction<HTMLParagraphElement>('p');\n export const htmlH1Element = createTagFunction<HTMLHeadingElement>('h1');\n export const htmlH2Element = createTagFunction<HTMLHeadingElement>('h2');\n export const htmlH3Element = createTagFunction<HTMLHeadingElement>('h3');\n export const htmlH4Element = createTagFunction<HTMLHeadingElement>('h4');\n export const htmlH5Element = createTagFunction<HTMLHeadingElement>('h5');\n export const htmlH6Element = createTagFunction<HTMLHeadingElement>('h6');\n export const htmlSectionElement = createTagFunction<HTMLElement>('section');\n export const htmlArticleElement = createTagFunction<HTMLElement>('article');\n}\n\nexport const htmlFragment = TemplateUtils.htmlFragment;\nexport const textNode = TemplateUtils.textNode;\nexport const commentNode = TemplateUtils.commentNode;\nexport const createElement = TemplateUtils.createElement;\nexport const htmlDivElement = TemplateUtils.htmlDivElement;\nexport const htmlSpanElement = TemplateUtils.htmlSpanElement;\nexport const htmlButtonElement = TemplateUtils.htmlButtonElement;\nexport const htmlUlElement = TemplateUtils.htmlUlElement;\nexport const htmlLiElement = TemplateUtils.htmlLiElement;\nexport const htmlInputElement = TemplateUtils.htmlInputElement;\nexport const htmlAElement = TemplateUtils.htmlAElement;\nexport const htmlPElement = TemplateUtils.htmlPElement;\nexport const htmlH1Element = TemplateUtils.htmlH1Element;\nexport const htmlH2Element = TemplateUtils.htmlH2Element;\nexport const htmlH3Element = TemplateUtils.htmlH3Element;\nexport const htmlH4Element = TemplateUtils.htmlH4Element;\nexport const htmlH5Element = TemplateUtils.htmlH5Element;\nexport const htmlH6Element = TemplateUtils.htmlH6Element;\nexport const htmlSectionElement = TemplateUtils.htmlSectionElement;\nexport const htmlArticleElement = TemplateUtils.htmlArticleElement;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,IAAU;AAAA,CAAV,CAAUA,mBAAV;AAIE,EAAMA,eAAA,eAAe,CAAC,YAAkC,WAAoC;AACjG,UAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,KAAK,MAAM,MAAM,OAAO,OAAO,CAAC,MAAM,SAAY,OAAO,CAAC,IAAI,KAAK,EAAE;AACtG,UAAM,WAAW,SAAS,cAAc,UAAU;AAClD,aAAS,YAAY,IAAI,KAAK;AAC9B,WAAO,SAAS;AAAA,EAClB;AAKO,EAAMA,eAAA,WAAW,CAAC,YAAkC,WAAwB;AACjF,UAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,KAAK,MAAM,MAAM,OAAO,OAAO,CAAC,MAAM,SAAY,OAAO,CAAC,IAAI,KAAK,EAAE;AACtG,WAAO,SAAS,eAAe,GAAG;AAAA,EACpC;AAKO,EAAMA,eAAA,cAAc,CAAC,YAAkC,WAA2B;AACvF,UAAM,MAAM,QAAQ,OAAO,CAAC,KAAK,KAAK,MAAM,MAAM,OAAO,OAAO,CAAC,MAAM,SAAY,OAAO,CAAC,IAAI,KAAK,EAAE;AACtG,WAAO,SAAS,cAAc,GAAG;AAAA,EACnC;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3D;AAmEV,MAAM,eAAe,cAAc;AACnC,MAAM,WAAW,cAAc;AAC/B,MAAM,cAAc,cAAc;AAClC,MAAM,gBAAgB,cAAc;AACpC,MAAM,iBAAiB,cAAc;AACrC,MAAM,kBAAkB,cAAc;AACtC,MAAM,oBAAoB,cAAc;AACxC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,mBAAmB,cAAc;AACvC,MAAM,eAAe,cAAc;AACnC,MAAM,eAAe,cAAc;AACnC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,gBAAgB,cAAc;AACpC,MAAM,qBAAqB,cAAc;AACzC,MAAM,qBAAqB,cAAc;",
6
6
  "names": ["TemplateUtils"]
7
7
  }
@@ -26,32 +26,70 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
26
26
  const conf = getElementConfig(this);
27
27
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
28
28
  const currentDoc = currentWin.document;
29
- let targetEl = null;
30
- if (selector === ":host" || !selector) {
31
- targetEl = this;
29
+ const pos = options.position || "beforeEnd";
30
+ const r = options.root || "auto";
31
+ const getTargetRoot = () => {
32
+ if (r === "shadow")
33
+ return this.shadowRoot;
34
+ if (r === "light")
35
+ return this;
36
+ if (r === "all")
37
+ return this.shadowRoot || this;
38
+ return this.shadowRoot || this;
39
+ };
40
+ if (pos === "remove") {
41
+ if (res) {
42
+ if (selector === ":host" || !selector) {
43
+ if (r === "shadow" && this.shadowRoot) {
44
+ this.shadowRoot.replaceChildren();
45
+ } else {
46
+ this.remove();
47
+ }
48
+ } else {
49
+ const targetRoot = getTargetRoot();
50
+ if (targetRoot) {
51
+ const targets = targetRoot.querySelectorAll(selector);
52
+ targets.forEach((el) => el.remove());
53
+ }
54
+ }
55
+ }
32
56
  } else {
33
- targetEl = (this.shadowRoot || this).querySelector(selector);
34
- }
35
- if (targetEl) {
36
- const nodes = normalizeNodes(res, currentDoc);
37
- const pos = options.position || "beforeEnd";
38
- if (pos === "replace") {
39
- targetEl.replaceWith(...nodes);
40
- } else if (pos === "replaceChildren") {
41
- targetEl.replaceChildren(...nodes);
42
- } else if (pos === "innerHtml") {
43
- targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
44
- } else if (pos === "innerText") {
45
- targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
57
+ let targetEl = null;
58
+ if (selector === ":host" || !selector) {
59
+ if (r === "shadow") {
60
+ targetEl = this.shadowRoot;
61
+ } else {
62
+ targetEl = this;
63
+ }
46
64
  } else {
47
- if (pos === "beforeEnd")
48
- targetEl.append(...nodes);
49
- else if (pos === "afterBegin")
50
- targetEl.prepend(...nodes);
51
- else if (pos === "beforeBegin")
52
- targetEl.before(...nodes);
53
- else if (pos === "afterEnd")
54
- targetEl.after(...nodes);
65
+ const targetRoot = getTargetRoot();
66
+ targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
67
+ }
68
+ if (targetEl) {
69
+ const isShadowRoot = targetEl instanceof ShadowRoot;
70
+ const nodes = normalizeNodes(res, currentDoc);
71
+ if (pos === "replace") {
72
+ if (!isShadowRoot) {
73
+ targetEl.replaceWith(...nodes);
74
+ }
75
+ } else if (pos === "replaceChildren") {
76
+ targetEl.replaceChildren(...nodes);
77
+ } else if (pos === "innerHtml") {
78
+ targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
79
+ } else if (pos === "innerText") {
80
+ if (targetEl.innerText !== void 0) {
81
+ targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
82
+ }
83
+ } else {
84
+ if (pos === "beforeEnd")
85
+ targetEl.append(...nodes);
86
+ else if (pos === "afterBegin")
87
+ targetEl.prepend(...nodes);
88
+ else if (pos === "beforeBegin" && !isShadowRoot)
89
+ targetEl.before(...nodes);
90
+ else if (pos === "afterEnd" && !isShadowRoot)
91
+ targetEl.after(...nodes);
92
+ }
55
93
  }
56
94
  }
57
95
  }
@@ -72,10 +110,46 @@ const findAllApplyNodeMetadata = (target) => {
72
110
  function applyNodeHost(options = { position: "beforeEnd" }) {
73
111
  return applyNode(":host", options);
74
112
  }
113
+ const applyBeforeBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeBegin" });
114
+ const applyAfterBeginNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterBegin" });
115
+ const applyBeforeEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "beforeEnd" });
116
+ const applyAfterEndNode = (selector, options = {}) => applyNode(selector, { ...options, position: "afterEnd" });
117
+ const applyReplaceNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replace" });
118
+ const applyReplaceChildrenNode = (selector, options = {}) => applyNode(selector, { ...options, position: "replaceChildren" });
119
+ const applyInnerHtmlNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerHtml" });
120
+ const applyInnerTextNode = (selector, options = {}) => applyNode(selector, { ...options, position: "innerText" });
121
+ const applyRemoveNode = (selector, options = {}) => applyNode(selector, { ...options, position: "remove" });
122
+ const applyBeforeBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeBegin" });
123
+ const applyAfterBeginNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterBegin" });
124
+ const applyBeforeEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "beforeEnd" });
125
+ const applyAfterEndNodeHost = (options = {}) => applyNode(":host", { ...options, position: "afterEnd" });
126
+ const applyReplaceNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replace" });
127
+ const applyReplaceChildrenNodeHost = (options = {}) => applyNode(":host", { ...options, position: "replaceChildren" });
128
+ const applyInnerHtmlNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerHtml" });
129
+ const applyInnerTextNodeHost = (options = {}) => applyNode(":host", { ...options, position: "innerText" });
130
+ const applyRemoveNodeHost = (options = {}) => applyNode(":host", { ...options, position: "remove" });
75
131
  export {
76
132
  APPLY_NODE_METADATA_KEY,
133
+ applyAfterBeginNode,
134
+ applyAfterBeginNodeHost,
135
+ applyAfterEndNode,
136
+ applyAfterEndNodeHost,
137
+ applyBeforeBeginNode,
138
+ applyBeforeBeginNodeHost,
139
+ applyBeforeEndNode,
140
+ applyBeforeEndNodeHost,
141
+ applyInnerHtmlNode,
142
+ applyInnerHtmlNodeHost,
143
+ applyInnerTextNode,
144
+ applyInnerTextNodeHost,
77
145
  applyNode,
78
146
  applyNodeHost,
147
+ applyRemoveNode,
148
+ applyRemoveNodeHost,
149
+ applyReplaceChildrenNode,
150
+ applyReplaceChildrenNodeHost,
151
+ applyReplaceNode,
152
+ applyReplaceNodeHost,
79
153
  findAllApplyNodeMetadata
80
154
  };
81
155
  //# sourceMappingURL=applyNode.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyNode.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, 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 conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (pos === 'replace') {\n // Replace the entire target element with new nodes\n targetEl.replaceWith(...nodes);\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_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 * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return applyNode(':host', options);\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AActC,MAAM,0BAA0B,OAAO,iCAAiC;AAE/E,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AAqBM,SAAU,UAAU,UAAkB,UAA4B,EAAE,UAAU,YAAW,GAAE;AAC/F,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3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;AACF;AAEO,MAAM,2BAA2B,CAAC,WAAwD;AAC/F,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,aAAa,gBAAyD,yBAAyB,MAAM;AAClH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;AAOM,SAAU,cAAc,UAA4B,EAAE,UAAU,YAAW,GAAE;AACjF,SAAO,UAAU,SAAS,OAAO;AACnC;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcRootType } from '../types';\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, 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 conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n\n const getTargetRoot = () => {\n if (r === 'shadow') return this.shadowRoot;\n if (r === 'light') return this as any;\n if (r === 'all') return this.shadowRoot || (this as any);\n return this.shadowRoot || (this as any); // auto\n };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = getTargetRoot();\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n if (selector === ':host' || !selector) {\n if (r === 'shadow') {\n targetEl = this.shadowRoot; // Target shadow DOM root\n } else {\n targetEl = this as any; // Target the component itself\n }\n } else {\n const targetRoot = getTargetRoot();\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_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 * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return applyNode(':host', options);\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport const applyBeforeBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport const applyAfterBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport const applyBeforeEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport const applyAfterEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport const applyReplaceNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport const applyReplaceChildrenNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport const applyInnerHtmlNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport const applyInnerTextNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport const applyRemoveNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'remove' });\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport const applyBeforeBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */\nexport const applyAfterBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */\nexport const applyBeforeEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */\nexport const applyAfterEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */\nexport const applyReplaceNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */\nexport const applyReplaceChildrenNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */\nexport const applyInnerHtmlNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */\nexport const applyInnerTextNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */\nexport const applyRemoveNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'remove' });\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAgBtC,MAAM,0BAA0B,OAAO,iCAAiC;AAE/E,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,Q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AAU,cAAa,CAAE;AAKrD,MAAM,0BAA0B,CAAC,UAA4B,CAAA,MAClE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,aAAY,CAAE;AAKpD,MAAM,yBAAyB,CAAC,UAA4B,CAAA,MACjE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,YAAW,CAAE;AAKnD,MAAM,wBAAwB,CAAC,UAA4B,CAAA,MAChE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,WAAU,CAAE;AAKlD,MAAM,uBAAuB,CAAC,UAA4B,CAAA,MAC/D,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,UAAS,CAAE;AAKjD,MAAM,+BAA+B,CAAC,UAA4B,CAAA,MACvE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,kBAAiB,CAAE;AAKzD,MAAM,yBAAyB,CAAC,UAA4B,CAAA,MACjE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,YAAW,CAAE;AAKnD,MAAM,yBAAyB,CAAC,UAA4B,CAAA,MACjE,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,YAAW,CAAE;AAKnD,MAAM,sBAAsB,CAAC,UAA4B,CAAA,MAC9D,UAAU,SAAS,EAAE,GAAG,SAAS,UAAU,SAAQ,CAAE;",
6
6
  "names": []
7
7
  }
@@ -102,7 +102,6 @@ function attribute(selector, options = {}) {
102
102
  },
103
103
  set(nv) {
104
104
  const targetType = options.type || designType;
105
- console.log("---set", propertyKey, targetType, nv, this, this.__swc_syncing_init);
106
105
  const attrName = options.name || String(propertyKey);
107
106
  const conf = getElementConfig(this);
108
107
  const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/attribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\n */\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, selector, options, privateKey });\n\n // Helper function to apply setAttribute to targets\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n inst[privateKey] = nv;\n }\n });\n };\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n console.log('---set', propertyKey, targetType, nv, this, this.__swc_syncing_init);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // During initialization/syncing phase\n if (this.__swc_syncing_init) {\n // If connectedInitialize is enabled, force setAttribute (JS -> DOM)\n if (options.connectedInitialize === true) {\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n } else {\n // Otherwise just update memory\n this[privateKey] = nv;\n }\n return;\n }\n\n // Before connected, save to memory only\n if (!this.__swc_connected) {\n this[privateKey] = nv;\n return;\n }\n\n // After connected, normal setAttribute\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n\n/**\n * @hostAttribute decorator - simplified version of @attribute for :host selector\n * Usage: @hostAttribute('data-product-id')\n * Usage: @hostAttribute('disabled', { type: Boolean })\n */\nexport function attributeHost(attrName: string, options: AttributeOptions = {}): PropertyDecorator {\n return attribute(':host', { ...options, name: attrName });\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAqB,wBAAwB;AAC7C,SAAS,gBAAgB;AAgBlB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WA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AA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,SAAO,aAAa,gBAAqC,wBAAwB,MAAM,EAAE,KAAK;AAChG;AAOO,SAAS,cAAc,UAAkB,UAA4B,CAAC,GAAsB;AACjG,SAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAC1D;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\n */\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({ propertyKey, selector, options, privateKey });\n\n // Helper function to apply setAttribute to targets\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n inst[privateKey] = nv;\n }\n });\n };\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n // console.log('---set', propertyKey, targetType, nv, this, this.__swc_syncing_init);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // During initialization/syncing phase\n if (this.__swc_syncing_init) {\n // If connectedInitialize is enabled, force setAttribute (JS -> DOM)\n if (options.connectedInitialize === true) {\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n } else {\n // Otherwise just update memory\n this[privateKey] = nv;\n }\n return;\n }\n\n // Before connected, save to memory only\n if (!this.__swc_connected) {\n this[privateKey] = nv;\n return;\n }\n\n // After connected, normal setAttribute\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n\n/**\n * @hostAttribute decorator - simplified version of @attribute for :host selector\n * Usage: @hostAttribute('data-product-id')\n * Usage: @hostAttribute('disabled', { type: Boolean })\n */\nexport function attributeHost(attrName: string, options: AttributeOptions = {}): PropertyDecorator {\n return attribute(':host', { ...options, name: attrName });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAqB,wBAAwB;AAC7C,SAAS,gBAAgB;AAgBlB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAKO,MAAM,mBAAmB,CAAC,MAAW,UAAkB,SAA2B,eAAmC;AAC1H,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAyB,CAAC;AAEhC,QAAM,YAAY,CAAC,WAAgB;AACjC,QAAI,CAAC,OAAQ;AACb,QAAI,MAAM,QAAQ;AAGhB,cAAQ,KAAK,MAAM;AAAA,IACrB,OAAO;AACL,UAAI,MAAM,WAAW,MAAM,MAAO,SAAQ,KAAK,MAAM;AACrD,WAAK,MAAM,YAAY,MAAM,UAAU,OAAO,WAAY,SAAQ,KAAK,OAAO,UAAU;AAAA,IAC1F;AAAA,EACF;AAEA,MAAI,aAAa,WAAW,CAAC,UAAU;AACrC,cAAU,IAAI;AAAA,EAChB,WAAW,aAAa,WAAW;AACjC,YAAQ,KAAK,UAAU;AAAA,EACzB,WAAW,aAAa,aAAa;AACnC,YAAQ,KAAK,WAAW,QAAQ;AAAA,EAClC,OAAO;AACL,UAAM,UAAU,SAAS,WAAW,IAAI;AACxC,QAAI,aAAa,cAAe,WAAU,QAAQ,WAAW;AAAA,aACpD,aAAa,WAAY,WAAU,QAAQ,QAAe;AAAA,aAC1D,aAAa,aAAc,WAAU,QAAQ,UAAU;AAAA,aACvD,aAAa,YAAa,WAAU,QAAQ,SAAS;AAAA,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WAAU,iBAAiB,MAAM,UAAU,SAAS,UAAU;AACpE,8BAAkB,MAAMA,UAAS,UAAU,EAAE;AAAA,UAC/C,OAAO;AAEL,iBAAK,UAAU,IAAI;AAAA,UACrB;AACA;AAAA,QACF;AAGA,YAAI,CAAC,KAAK,iBAAiB;AACzB,eAAK,UAAU,IAAI;AACnB;AAAA,QACF;AAGA,cAAM,UAAU,iBAAiB,MAAM,UAAU,SAAS,UAAU;AACpE,0BAAkB,MAAM,SAAS,UAAU,EAAE;AAAA,MAC/C;AAAA,MACA,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,2BAA2B,CAAC,WAAqC;AAC5E,SAAO,aAAa,gBAAqC,wBAAwB,MAAM,EAAE,KAAK;AAChG;AAOO,SAAS,cAAc,UAAkB,UAA4B,CAAC,GAAsB;AACjG,SAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAC1D;",
6
6
  "names": ["targets"]
7
7
  }
@@ -3,7 +3,7 @@ import { ensureInit } from "./elementDefine.js";
3
3
  import { SwcUtils } from "../utils/Utils.js";
4
4
  const CLASS_LIST_METADATA_KEY = Symbol("simple-web-component:class-list");
5
5
  function createClassListDecorator(action) {
6
- return (selector) => {
6
+ return (selector, options = {}) => {
7
7
  return (target, propertyKey, descriptor) => {
8
8
  const constructor = target.constructor;
9
9
  let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor);
@@ -11,19 +11,39 @@ function createClassListDecorator(action) {
11
11
  metaList = /* @__PURE__ */ new Map();
12
12
  ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);
13
13
  }
14
- metaList.set(propertyKey, { propertyKey, selector, action });
14
+ metaList.set(propertyKey, { propertyKey, selector, action, options });
15
15
  const original = descriptor.value;
16
16
  descriptor.value = async function(...args) {
17
17
  ensureInit(this);
18
18
  const res = await original.apply(this, args);
19
19
  if (res !== void 0) {
20
+ const r = options.root || "auto";
20
21
  const hostSet = SwcUtils.getHostSet(this);
21
- let targetEl = null;
22
- if (selector === ":host" || !selector) targetEl = this;
23
- else if (selector === ":parentHost") targetEl = hostSet.$parentHost;
24
- else if (selector === ":appHost") targetEl = hostSet.$appHost;
25
- else targetEl = (this.shadowRoot || this).querySelector(selector);
26
- if (targetEl) {
22
+ const targetEls = [];
23
+ if (selector === ":host" || !selector) {
24
+ targetEls.push(this);
25
+ } else if (selector === ":parentHost") {
26
+ if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);
27
+ } else if (selector === ":appHost") {
28
+ if (hostSet.$appHost) targetEls.push(hostSet.$appHost);
29
+ } else {
30
+ if (r === "shadow") {
31
+ const found = this.shadowRoot?.querySelectorAll(selector);
32
+ if (found) targetEls.push(...found);
33
+ } else if (r === "light") {
34
+ const found = this.querySelectorAll(selector);
35
+ if (found) targetEls.push(...found);
36
+ } else if (r === "all") {
37
+ const sFound = this.shadowRoot?.querySelectorAll(selector);
38
+ const lFound = this.querySelectorAll(selector);
39
+ if (sFound) targetEls.push(...sFound);
40
+ if (lFound) targetEls.push(...lFound);
41
+ } else {
42
+ const found = (this.shadowRoot || this).querySelectorAll(selector);
43
+ if (found) targetEls.push(...found);
44
+ }
45
+ }
46
+ targetEls.forEach((targetEl) => {
27
47
  if (action === "set") {
28
48
  let classes = "";
29
49
  if (typeof res === "object" && res !== null && !Array.isArray(res)) {
@@ -51,23 +71,23 @@ function createClassListDecorator(action) {
51
71
  const classes = Array.isArray(res) ? res.map(String) : [String(res)];
52
72
  classes.forEach((c) => targetEl.classList.toggle(c));
53
73
  }
54
- }
74
+ });
55
75
  }
56
76
  return res;
57
77
  };
58
78
  };
59
79
  };
60
80
  }
61
- const setClassList = createClassListDecorator("set");
62
- const updateClassList = createClassListDecorator("update");
63
- const addClassList = createClassListDecorator("add");
64
- const removeClassList = createClassListDecorator("remove");
65
- const toggleClassList = createClassListDecorator("toggle");
66
- const setClassListHost = createClassListDecorator("set").bind(null, ":host");
67
- const updateClassListHost = createClassListDecorator("update").bind(null, ":host");
68
- const addClassListHost = createClassListDecorator("add").bind(null, ":host");
69
- const removeClassListHost = createClassListDecorator("remove").bind(null, ":host");
70
- const toggleClassListHost = createClassListDecorator("toggle").bind(null, ":host");
81
+ const setClassList = (selector, options = {}) => createClassListDecorator("set")(selector, options);
82
+ const updateClassList = (selector, options = {}) => createClassListDecorator("update")(selector, options);
83
+ const addClassList = (selector, options = {}) => createClassListDecorator("add")(selector, options);
84
+ const removeClassList = (selector, options = {}) => createClassListDecorator("remove")(selector, options);
85
+ const toggleClassList = (selector, options = {}) => createClassListDecorator("toggle")(selector, options);
86
+ const setClassListHost = (options = {}) => createClassListDecorator("set")(":host", options);
87
+ const updateClassListHost = (options = {}) => createClassListDecorator("update")(":host", options);
88
+ const addClassListHost = (options = {}) => createClassListDecorator("add")(":host", options);
89
+ const removeClassListHost = (options = {}) => createClassListDecorator("remove")(":host", options);
90
+ const toggleClassListHost = (options = {}) => createClassListDecorator("toggle")(":host", options);
71
91
  const findAllClassListMetadata = (target) => {
72
92
  const result = /* @__PURE__ */ new Map();
73
93
  const maps = ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);