@dooboostore/simple-web-component 1.0.47 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +223 -27
  2. package/dist/cjs/config/config.js +1 -1
  3. package/dist/cjs/config/config.js.map +2 -2
  4. package/dist/cjs/decorators/addEventListener.js +412 -16
  5. package/dist/cjs/decorators/addEventListener.js.map +3 -3
  6. package/dist/cjs/decorators/applyAttribute.js +25 -0
  7. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  8. package/dist/cjs/decorators/applyClass.js +49 -18
  9. package/dist/cjs/decorators/applyClass.js.map +3 -3
  10. package/dist/cjs/decorators/applyNode.js +67 -1
  11. package/dist/cjs/decorators/applyNode.js.map +3 -3
  12. package/dist/cjs/decorators/applyProperty.js +101 -3
  13. package/dist/cjs/decorators/applyProperty.js.map +2 -2
  14. package/dist/cjs/decorators/applyStyle.js +36 -5
  15. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  16. package/dist/cjs/decorators/changedAttribute.js +39 -0
  17. package/dist/cjs/decorators/changedAttribute.js.map +2 -2
  18. package/dist/cjs/decorators/elementDefine.js +244 -225
  19. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  20. package/dist/cjs/decorators/emitCustomEvent.js +55 -0
  21. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  22. package/dist/cjs/decorators/index.js +5 -1
  23. package/dist/cjs/decorators/index.js.map +2 -2
  24. package/dist/cjs/decorators/intersectionObserver.js +209 -0
  25. package/dist/cjs/decorators/intersectionObserver.js.map +7 -0
  26. package/dist/cjs/decorators/mutationObserver.js +244 -0
  27. package/dist/cjs/decorators/mutationObserver.js.map +7 -0
  28. package/dist/cjs/decorators/query.js +129 -102
  29. package/dist/cjs/decorators/query.js.map +2 -2
  30. package/dist/cjs/decorators/resizeObserver.js +191 -0
  31. package/dist/cjs/decorators/resizeObserver.js.map +7 -0
  32. package/dist/cjs/decorators/setInterval.js +82 -0
  33. package/dist/cjs/decorators/setInterval.js.map +7 -0
  34. package/dist/cjs/decorators/setTimeout.js +82 -0
  35. package/dist/cjs/decorators/setTimeout.js.map +7 -0
  36. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
  37. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  38. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
  39. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  40. package/dist/cjs/examples/RxJSOperatorsExample.js +285 -0
  41. package/dist/cjs/examples/RxJSOperatorsExample.js.map +7 -0
  42. package/dist/cjs/types/index.js.map +1 -1
  43. package/dist/esm/config/config.js +1 -1
  44. package/dist/esm/config/config.js.map +2 -2
  45. package/dist/esm/decorators/addEventListener.js +413 -16
  46. package/dist/esm/decorators/addEventListener.js.map +3 -3
  47. package/dist/esm/decorators/applyAttribute.js +25 -0
  48. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  49. package/dist/esm/decorators/applyClass.js +49 -18
  50. package/dist/esm/decorators/applyClass.js.map +3 -3
  51. package/dist/esm/decorators/applyNode.js +67 -1
  52. package/dist/esm/decorators/applyNode.js.map +3 -3
  53. package/dist/esm/decorators/applyProperty.js +101 -3
  54. package/dist/esm/decorators/applyProperty.js.map +2 -2
  55. package/dist/esm/decorators/applyStyle.js +36 -5
  56. package/dist/esm/decorators/applyStyle.js.map +2 -2
  57. package/dist/esm/decorators/changedAttribute.js +40 -0
  58. package/dist/esm/decorators/changedAttribute.js.map +2 -2
  59. package/dist/esm/decorators/elementDefine.js +249 -230
  60. package/dist/esm/decorators/elementDefine.js.map +3 -3
  61. package/dist/esm/decorators/emitCustomEvent.js +55 -0
  62. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  63. package/dist/esm/decorators/index.js +5 -1
  64. package/dist/esm/decorators/index.js.map +2 -2
  65. package/dist/esm/decorators/intersectionObserver.js +191 -0
  66. package/dist/esm/decorators/intersectionObserver.js.map +7 -0
  67. package/dist/esm/decorators/mutationObserver.js +226 -0
  68. package/dist/esm/decorators/mutationObserver.js.map +7 -0
  69. package/dist/esm/decorators/query.js +129 -102
  70. package/dist/esm/decorators/query.js.map +2 -2
  71. package/dist/esm/decorators/resizeObserver.js +173 -0
  72. package/dist/esm/decorators/resizeObserver.js.map +7 -0
  73. package/dist/esm/decorators/setInterval.js +64 -0
  74. package/dist/esm/decorators/setInterval.js.map +7 -0
  75. package/dist/esm/decorators/setTimeout.js +64 -0
  76. package/dist/esm/decorators/setTimeout.js.map +7 -0
  77. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +9 -0
  78. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +2 -2
  79. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +9 -0
  80. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  81. package/dist/esm/examples/RxJSOperatorsExample.js +266 -0
  82. package/dist/esm/examples/RxJSOperatorsExample.js.map +7 -0
  83. package/dist/esm/types/index.js.map +1 -1
  84. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2413 -889
  85. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  86. package/dist/types/config/config.d.ts.map +1 -1
  87. package/dist/types/decorators/addEventListener.d.ts +93 -23
  88. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  89. package/dist/types/decorators/applyAttribute.d.ts +22 -34
  90. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  91. package/dist/types/decorators/applyClass.d.ts +34 -34
  92. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  93. package/dist/types/decorators/applyNode.d.ts +30 -20
  94. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  95. package/dist/types/decorators/applyProperty.d.ts +57 -34
  96. package/dist/types/decorators/applyProperty.d.ts.map +1 -1
  97. package/dist/types/decorators/applyStyle.d.ts +25 -12
  98. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  99. package/dist/types/decorators/changedAttribute.d.ts +11 -0
  100. package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
  101. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  102. package/dist/types/decorators/emitCustomEvent.d.ts +28 -4
  103. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  104. package/dist/types/decorators/index.d.ts +5 -1
  105. package/dist/types/decorators/index.d.ts.map +1 -1
  106. package/dist/types/decorators/intersectionObserver.d.ts +49 -0
  107. package/dist/types/decorators/intersectionObserver.d.ts.map +1 -0
  108. package/dist/types/decorators/mutationObserver.d.ts +46 -0
  109. package/dist/types/decorators/mutationObserver.d.ts.map +1 -0
  110. package/dist/types/decorators/query.d.ts +63 -8
  111. package/dist/types/decorators/query.d.ts.map +1 -1
  112. package/dist/types/decorators/resizeObserver.d.ts +48 -0
  113. package/dist/types/decorators/resizeObserver.d.ts.map +1 -0
  114. package/dist/types/decorators/setInterval.d.ts +29 -0
  115. package/dist/types/decorators/setInterval.d.ts.map +1 -0
  116. package/dist/types/decorators/setTimeout.d.ts +29 -0
  117. package/dist/types/decorators/setTimeout.d.ts.map +1 -0
  118. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +7 -1
  119. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  120. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +6 -0
  121. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  122. package/dist/types/examples/RxJSOperatorsExample.d.ts +94 -0
  123. package/dist/types/examples/RxJSOperatorsExample.d.ts.map +1 -0
  124. package/dist/types/types/index.d.ts +104 -0
  125. package/dist/types/types/index.d.ts.map +1 -1
  126. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2413 -889
  127. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  128. package/package.json +8 -6
  129. package/src/config/config.ts +1 -1
  130. package/src/decorators/addEventListener.ts +426 -23
  131. package/src/decorators/applyAttribute.ts +50 -36
  132. package/src/decorators/applyClass.ts +76 -26
  133. package/src/decorators/applyNode.ts +114 -36
  134. package/src/decorators/applyProperty.ts +152 -40
  135. package/src/decorators/applyStyle.ts +64 -17
  136. package/src/decorators/changedAttribute.ts +46 -0
  137. package/src/decorators/elementDefine.ts +301 -317
  138. package/src/decorators/emitCustomEvent.ts +73 -5
  139. package/src/decorators/index.ts +5 -1
  140. package/src/decorators/intersectionObserver.ts +259 -0
  141. package/src/decorators/mutationObserver.ts +304 -0
  142. package/src/decorators/query.ts +182 -117
  143. package/src/decorators/resizeObserver.ts +235 -0
  144. package/src/decorators/setInterval.ts +80 -0
  145. package/src/decorators/setTimeout.ts +80 -0
  146. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +17 -0
  147. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +19 -0
  148. package/src/examples/RxJSOperatorsExample.ts +279 -0
  149. package/src/types/index.ts +141 -0
  150. package/dist/cjs/decorators/queryAll.js +0 -181
  151. package/dist/cjs/decorators/queryAll.js.map +0 -7
  152. package/dist/cjs/elements/tt/SwcAppMixin.js +0 -1
  153. package/dist/cjs/elements/tt/SwcAppMixin.js.map +0 -7
  154. package/dist/cjs/elements/tt/SwcAsync.js +0 -1
  155. package/dist/cjs/elements/tt/SwcAsync.js.map +0 -7
  156. package/dist/cjs/elements/tt/SwcAsyncTemplate.js +0 -1
  157. package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +0 -7
  158. package/dist/cjs/elements/tt/SwcChoose.js +0 -1
  159. package/dist/cjs/elements/tt/SwcChoose.js.map +0 -7
  160. package/dist/cjs/elements/tt/SwcChooseTemplate.js +0 -1
  161. package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +0 -7
  162. package/dist/cjs/elements/tt/SwcIf.js +0 -1
  163. package/dist/cjs/elements/tt/SwcIf.js.map +0 -7
  164. package/dist/cjs/elements/tt/SwcIfTemplate.js +0 -1
  165. package/dist/cjs/elements/tt/SwcIfTemplate.js.map +0 -7
  166. package/dist/cjs/elements/tt/SwcLoop.js +0 -1
  167. package/dist/cjs/elements/tt/SwcLoop.js.map +0 -7
  168. package/dist/cjs/elements/tt/SwcLoopTemplate.js +0 -1
  169. package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +0 -7
  170. package/dist/cjs/elements/tt/SwcSubTemplates.js +0 -1
  171. package/dist/cjs/elements/tt/SwcSubTemplates.js.map +0 -7
  172. package/dist/cjs/elements/tt/register.js +0 -1
  173. package/dist/cjs/elements/tt/register.js.map +0 -7
  174. package/dist/esm/decorators/queryAll.js +0 -162
  175. package/dist/esm/decorators/queryAll.js.map +0 -7
  176. package/dist/esm/elements/tt/SwcAppMixin.js +0 -1
  177. package/dist/esm/elements/tt/SwcAppMixin.js.map +0 -7
  178. package/dist/esm/elements/tt/SwcAsync.js +0 -1
  179. package/dist/esm/elements/tt/SwcAsync.js.map +0 -7
  180. package/dist/esm/elements/tt/SwcAsyncTemplate.js +0 -1
  181. package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +0 -7
  182. package/dist/esm/elements/tt/SwcChoose.js +0 -1
  183. package/dist/esm/elements/tt/SwcChoose.js.map +0 -7
  184. package/dist/esm/elements/tt/SwcChooseTemplate.js +0 -1
  185. package/dist/esm/elements/tt/SwcChooseTemplate.js.map +0 -7
  186. package/dist/esm/elements/tt/SwcIf.js +0 -1
  187. package/dist/esm/elements/tt/SwcIf.js.map +0 -7
  188. package/dist/esm/elements/tt/SwcIfTemplate.js +0 -1
  189. package/dist/esm/elements/tt/SwcIfTemplate.js.map +0 -7
  190. package/dist/esm/elements/tt/SwcLoop.js +0 -1
  191. package/dist/esm/elements/tt/SwcLoop.js.map +0 -7
  192. package/dist/esm/elements/tt/SwcLoopTemplate.js +0 -1
  193. package/dist/esm/elements/tt/SwcLoopTemplate.js.map +0 -7
  194. package/dist/esm/elements/tt/SwcSubTemplates.js +0 -1
  195. package/dist/esm/elements/tt/SwcSubTemplates.js.map +0 -7
  196. package/dist/esm/elements/tt/register.js +0 -1
  197. package/dist/esm/elements/tt/register.js.map +0 -7
  198. package/dist/types/decorators/queryAll.d.ts +0 -22
  199. package/dist/types/decorators/queryAll.d.ts.map +0 -1
  200. package/dist/types/elements/tt/SwcAppMixin.d.ts +0 -1
  201. package/dist/types/elements/tt/SwcAppMixin.d.ts.map +0 -1
  202. package/dist/types/elements/tt/SwcAsync.d.ts +0 -1
  203. package/dist/types/elements/tt/SwcAsync.d.ts.map +0 -1
  204. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +0 -1
  205. package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +0 -1
  206. package/dist/types/elements/tt/SwcChoose.d.ts +0 -1
  207. package/dist/types/elements/tt/SwcChoose.d.ts.map +0 -1
  208. package/dist/types/elements/tt/SwcChooseTemplate.d.ts +0 -1
  209. package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +0 -1
  210. package/dist/types/elements/tt/SwcIf.d.ts +0 -1
  211. package/dist/types/elements/tt/SwcIf.d.ts.map +0 -1
  212. package/dist/types/elements/tt/SwcIfTemplate.d.ts +0 -1
  213. package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +0 -1
  214. package/dist/types/elements/tt/SwcLoop.d.ts +0 -1
  215. package/dist/types/elements/tt/SwcLoop.d.ts.map +0 -1
  216. package/dist/types/elements/tt/SwcLoopTemplate.d.ts +0 -1
  217. package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +0 -1
  218. package/dist/types/elements/tt/SwcSubTemplates.d.ts +0 -1
  219. package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +0 -1
  220. package/dist/types/elements/tt/register.d.ts +0 -1
  221. package/dist/types/elements/tt/register.d.ts.map +0 -1
  222. package/src/decorators/queryAll.ts +0 -186
  223. package/src/elements/tt/SwcAppMixin.ts +0 -13
  224. package/src/elements/tt/SwcAsync.ts +0 -139
  225. package/src/elements/tt/SwcAsyncTemplate.ts +0 -126
  226. package/src/elements/tt/SwcChoose.ts +0 -182
  227. package/src/elements/tt/SwcChooseTemplate.ts +0 -229
  228. package/src/elements/tt/SwcIf.ts +0 -145
  229. package/src/elements/tt/SwcIfTemplate.ts +0 -158
  230. package/src/elements/tt/SwcLoop.ts +0 -222
  231. package/src/elements/tt/SwcLoopTemplate.ts +0 -255
  232. package/src/elements/tt/SwcSubTemplates.ts +0 -6
  233. package/src/elements/tt/register.ts +0 -720
@@ -1,229 +0,0 @@
1
- // import {changedAttributeThis} from '../../decorators/changedAttributeThis';
2
- // import {SwcUtils} from '../../utils/Utils';
3
- // import {FunctionUtils, ActionExpression} from '@dooboostore/core';
4
- // import {ConvertUtils} from '@dooboostore/core-web';
5
- // import {SwcChooseInterface} from '../../types';
6
- // import {attributeThis, getAttributeValue, getElementConfig} from '../../decorators';
7
- //
8
- // export class SwcChooseTemplate extends HTMLTemplateElement implements SwcChooseInterface {
9
- // _value: any;
10
- //
11
- // @attributeThis('replace-wrap-start')
12
- // _replaceWrapStart: string | null;
13
- // @attributeThis('replace-wrap-end')
14
- // _replaceWrapEnd: string | null;
15
- //
16
- // private _nodes: Node[] = [];
17
- // private _previousTemplate: HTMLTemplateElement | null = null;
18
- //
19
- // get value(): any {
20
- // return this._value;
21
- // }
22
- //
23
- // set value(nv: any) {
24
- // this._value = nv;
25
- // this.refresh(this._value);
26
- // }
27
- //
28
- // constructor() {
29
- // super();
30
- // // console.log('swc chooooooooooooooooooooooooose constructor called!');
31
- // // console.log('swc cccccccss', this.getAttribute('value'));
32
- // }
33
- //
34
- // static get observedAttributes() {
35
- // return ['value'];
36
- // }
37
- //
38
- // attributeChangedCallback(na, o, n) {
39
- // // console.log('-----------------choooooooose attr origin', na, o, n);
40
- // }
41
- //
42
- // connectedCallback() {
43
- // // console.log('------choooooooose connectedCallback called!------');
44
- // if (!this.id) {
45
- // throw new Error('[SWC] SwcChoose must have an "id" attribute for reliable cleanup.');
46
- // }
47
- // if (this.hasAttribute('value')) {
48
- // this.refresh();
49
- // }
50
- // }
51
- //
52
- // @changedAttributeThis('value')
53
- // private setValue(value: any, o: string, n: string) {
54
- // if (!this.id) return;
55
- // // console.log('chooooooose value', value)
56
- // this._value = value;
57
- // this.refresh(this._value);
58
- // }
59
- //
60
- // // @changedAttributeThis('replace-wrap')
61
- // // private setReplaceWrap(replaceWrapAttr?: string | null) {
62
- // // this.refresh();
63
- // // }
64
- //
65
- // private replaceExpressions(html: string, groupArgs: any, context: any, wrap: { start: string, end: string }): string {
66
- // let config: any = undefined;
67
- // if (wrap) {
68
- // config = {
69
- // expression: {
70
- // replace: {start: `${wrap.start}`, end: `${wrap.end}`},
71
- // callReturn: {start: `${wrap.start}=`, end: `${wrap.end}`},
72
- // call: {start: `${wrap.start}@`, end: `${wrap.end}`}
73
- // }
74
- // };
75
- // }
76
- // const ae = new ActionExpression(html, config);
77
- // const win = this.ownerDocument?.defaultView || window;
78
- //
79
- // // @ts-ignore
80
- // for (const expr of ae.getExpressions('replace')) {
81
- // try {
82
- // const value = FunctionUtils.executeReturn({
83
- // script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
84
- // context,
85
- // args: groupArgs
86
- // });
87
- // ae.replace(expr, String(value));
88
- // } catch (e) {
89
- // console.error(`[SWC] Failed to execute ${expr.original}:`, e);
90
- // }
91
- // }
92
- // return ae.getUnprocessedTemplate();
93
- // }
94
- //
95
- // refresh(value?: any) {
96
- // if (!this.id) return;
97
- // value = value ?? getAttributeValue(this, 'value') ?? this._value;
98
- // // console.log('[DEBUG] SwcChoose.refresh called, value:', value);
99
- // const portal = SwcUtils.getParentContainer(this);
100
- // if (!portal) {
101
- // // console.log('[DEBUG] SwcChoose portal is null!');
102
- // return;
103
- // }
104
- //
105
- // const win = (getElementConfig(this).window ?? this.ownerDocument?.defaultView) || window;
106
- // const helperSet = SwcUtils.getHelperAndHostSet(win, this);
107
- // const groupArgs = {...helperSet, $value: value, $templateHost: this};
108
- //
109
- // const templates = Array.from(this.content.querySelectorAll('template'));
110
- // let selected: HTMLTemplateElement | null = null;
111
- //
112
- // for (const t of templates) {
113
- // if (t.getAttribute('is') === 'swc-when') {
114
- // const attrVal = t.getAttribute('test') || '';
115
- // let matches = false;
116
- //
117
- //
118
- // const result = FunctionUtils.executeReturn({
119
- // script: attrVal,
120
- // context: t,
121
- // args: groupArgs
122
- // });
123
- // matches = !!result;
124
- // // Use ActionExpression to parse and extract script from value attribute
125
- // // const ae = new ActionExpression(attrVal);
126
- // // const expr = ae.getFirstExpression('replace');
127
- //
128
- // // if (expr) {
129
- // // const decodedScript = ConvertUtils.decodeHtmlEntity(expr.script, win.document);
130
- // // const result = FunctionUtils.executeReturn({
131
- // // script: decodedScript,
132
- // // context: t,
133
- // // args: groupArgs
134
- // // });
135
- // // matches = !!result;
136
- // // } else {
137
- // // matches = String(attrVal) === String(value);
138
- // // }
139
- //
140
- // if (matches) {
141
- // selected = t;
142
- // break;
143
- // }
144
- // }
145
- // }
146
- //
147
- // const target = selected || (this.content.querySelector('template[is="swc-otherwise"]') as HTMLTemplateElement);
148
- //
149
- // const skipValue = target?.getAttribute?.('skip-if-same');
150
- // const skipValue2 = this._previousTemplate?.getAttribute?.('skip-if-same');
151
- // const hasSkipIfSame = target?.hasAttribute?.('skip-if-same');
152
- // const isSame = this._previousTemplate === target;
153
- // // console.log('---rrrr---', this._previousTemplate, target, hasSkipIfSame, isSame, skipValue, skipValue2);
154
- // if (hasSkipIfSame && isSame) {
155
- // return;
156
- // }
157
- //
158
- // this.cleanup();
159
- // this._previousTemplate = target;
160
- //
161
- // if (target) {
162
- // let htmlString = target.innerHTML;
163
- // htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start: this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
164
- //
165
- // const result = this.ownerDocument?.createElement('template') || document.createElement('template');
166
- // result.innerHTML = htmlString;
167
- // const processedFragment = result.content;
168
- //
169
- // // console.log('[DEBUG] SwcChoose processedFragment children:', processedFragment._childNodesInternal?.length);
170
- // this._nodes = Array.from(processedFragment.childNodes);
171
- //
172
- // const setTemplateHost = (element: HTMLElement) => {
173
- // (element as any).__swc_template_host = this;
174
- // Array.from(element.children).forEach((child: any) => {
175
- // if (child instanceof HTMLElement) {
176
- // setTemplateHost(child);
177
- // }
178
- // });
179
- // };
180
- //
181
- // this._nodes.forEach((node: any) => {
182
- // if (node instanceof HTMLElement) {
183
- // setTemplateHost(node as HTMLElement);
184
- // }
185
- // });
186
- //
187
- // // console.log(`[DEBUG] SwcChoose before insertBefore, portal: ${portal?.tagName}, isConnected: ${(portal as any)?.isConnected}`);
188
- //
189
- // // Add endpoint comment node
190
- // const endpoint = this.ownerDocument?.createComment(`swc-choose endpoint id:${this.id}`) || document.createComment(`swc-choose endpoint id:${this.id}`);
191
- // processedFragment.appendChild(endpoint);
192
- // this._nodes.push(endpoint);
193
- //
194
- // portal.insertBefore(processedFragment, this.nextSibling);
195
- // // console.log('[DEBUG] SwcChoose after insertBefore');
196
- // }
197
- // }
198
- //
199
- // private cleanup() {
200
- // if (this.id) {
201
- // const portal = SwcUtils.getParentContainer(this);
202
- // if (portal) {
203
- // const endpointText = `swc-choose endpoint id:${this.id}`;
204
- // let current = this.nextSibling;
205
- // const toRemove: Node[] = [];
206
- //
207
- // while (current) {
208
- // toRemove.push(current);
209
- // if (current.nodeType === 8 && (current as Comment).data === endpointText) {
210
- // // Found the endpoint!
211
- // toRemove.forEach(n => {
212
- // const realNode = (n as any).__upgraded_instance || n;
213
- // if (realNode.parentElement) {
214
- // realNode.parentElement.removeChild(realNode);
215
- // }
216
- // });
217
- // break;
218
- // }
219
- // current = current.nextSibling;
220
- // }
221
- // }
222
- // }
223
- // this._nodes = [];
224
- // }
225
- //
226
- // disconnectedCallback() {
227
- // this.cleanup();
228
- // }
229
- // }
@@ -1,145 +0,0 @@
1
- // import {SwcUtils} from '../../utils/Utils';
2
- // import {ActionExpression, FunctionUtils} from '@dooboostore/core';
3
- // import {ConvertUtils} from '@dooboostore/core-web';
4
- // import {elementDefine, getAttributeValue} from '../../decorators';
5
- //
6
- // export default async (w: Window) => {
7
- // const tagName = 'swc-if';
8
- // const existing = w.customElements.get(tagName);
9
- // if (existing) return existing;
10
- // @elementDefine(tagName, { window: w })
11
- // class SwcIf extends w.HTMLElement {
12
- //
13
- // private _value: any;
14
- // private _replaceWrapStart: string | null = null;
15
- // private _replaceWrapEnd: string | null = null;
16
- // private _skipIfSame: string | null = null;
17
- // private _nodes: Node[] = [];
18
- //
19
- // static get observedAttributes() {
20
- // return ['value', 'replace-wrap-start', 'replace-wrap-end', 'skip-if-same'];
21
- // }
22
- //
23
- // get value(): boolean {
24
- // return this._value;
25
- // }
26
- //
27
- // set value(nv: any) {
28
- // this.refresh(nv);
29
- // }
30
- //
31
- // connectedCallback() {
32
- // if (!this.id) {
33
- // throw new Error('[SWC] SwcIf must have an "id" attribute for reliable cleanup.');
34
- // }
35
- // if (this.hasAttribute('value')) {
36
- // this.refresh();
37
- // }
38
- // }
39
- //
40
- // attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
41
- // switch (name) {
42
- // case 'value':
43
- // this._value = newValue;
44
- // this.refresh(this._value);
45
- // break;
46
- // case 'replace-wrap-start':
47
- // this._replaceWrapStart = newValue;
48
- // break;
49
- // case 'replace-wrap-end':
50
- // this._replaceWrapEnd = newValue;
51
- // break;
52
- // case 'skip-if-same':
53
- // this._skipIfSame = newValue;
54
- // break;
55
- // }
56
- // }
57
- //
58
- // private replaceExpressions(html: string, groupArgs: any, context: any, wrap: { start: string, end: string }): string {
59
- // let config: any = undefined;
60
- // if (wrap) {
61
- // config = {
62
- // expression: {
63
- // replace: {start: `${wrap.start}`, end: `${wrap.end}`},
64
- // callReturn: {start: `${wrap.start}=`, end: `${wrap.end}`},
65
- // call: {start: `${wrap.start}@`, end: `${wrap.end}`}
66
- // }
67
- // };
68
- // }
69
- // const ae = new ActionExpression(html, config);
70
- // const win = this.ownerDocument?.defaultView || window;
71
- // for (const expr of ae.getExpressions('replace')) {
72
- // try {
73
- // const value = FunctionUtils.executeReturn({
74
- // script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
75
- // context,
76
- // args: groupArgs
77
- // });
78
- // ae.replace(expr, String(value));
79
- // } catch (e) {
80
- // console.error(`[SWC] Failed to execute ${expr.original}:`, e);
81
- // }
82
- // }
83
- // return ae.getUnprocessedTemplate();
84
- // }
85
- //
86
- // refresh(value?: any) {
87
- // if (!this.id) return;
88
- // const targetValue = value !== undefined ? value : (getAttributeValue(this, 'value') ?? this._value);
89
- // if (this.hasAttribute('skip-if-same') && this._value === targetValue && (this._nodes.length > 0 || this.nextSibling)) {
90
- // if (this._value === targetValue && this._nodes.length > 0) return;
91
- // }
92
- // this.cleanup();
93
- // this._value = targetValue;
94
- // const portal = this.parentElement;
95
- // if (!portal || !this._value) return;
96
- // const win = this.ownerDocument?.defaultView || window;
97
- // const helperSet = SwcUtils.getHelperAndHostSet(win, this);
98
- // let htmlString = this.innerHTML;
99
- // const groupArgs = {...helperSet, $value: this._value, $templateHost: this};
100
- // htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start: this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
101
- // const result = this.ownerDocument?.createElement('template') || document.createElement('template');
102
- // result.innerHTML = htmlString;
103
- // const processedFragment = result.content;
104
- // this._nodes = Array.from(processedFragment.childNodes);
105
- // this._nodes.forEach((node: any) => {
106
- // if (node instanceof HTMLElement) (node as any).__swc_template_host = this;
107
- // });
108
- // const endpointText = `swc-if endpoint id:${this.id}`;
109
- // const endpoint = this.ownerDocument?.createComment(endpointText) || document.createComment(endpointText);
110
- // processedFragment.appendChild(endpoint);
111
- // this._nodes.push(endpoint);
112
- // portal.insertBefore(processedFragment, this.nextSibling);
113
- // }
114
- //
115
- // private cleanup() {
116
- // if (this.id) {
117
- // const portal = this.parentElement;
118
- // if (portal) {
119
- // const endpointText = `swc-if endpoint id:${this.id}`;
120
- // let current = this.nextSibling;
121
- // const toRemove: Node[] = [];
122
- // while (current) {
123
- // toRemove.push(current);
124
- // if (current.nodeType === 8 && (current as Comment).data === endpointText) {
125
- // toRemove.forEach(n => {
126
- // const realNode = (n as any).__upgraded_instance || n;
127
- // if (realNode.parentElement) {
128
- // realNode.parentElement.removeChild(realNode);
129
- // }
130
- // });
131
- // break;
132
- // }
133
- // current = current.nextSibling;
134
- // }
135
- // }
136
- // }
137
- // this._nodes = [];
138
- // }
139
- //
140
- // disconnectedCallback() {
141
- // this.cleanup();
142
- // }
143
- // }
144
- //
145
- // }
@@ -1,158 +0,0 @@
1
- // import { changedAttributeThis } from '../../decorators/changedAttributeThis';
2
- // import { SwcUtils } from '../../utils/Utils';
3
- // import { FunctionUtils, ActionExpression } from '@dooboostore/core';
4
- // import { ConvertUtils } from '@dooboostore/core-web';
5
- // import { SwcIfInterface } from '../../types';
6
- // import { attributeThis, getAttributeValue } from '../../decorators';
7
- //
8
- // export class SwcIfTemplate extends HTMLTemplateElement implements SwcIfInterface {
9
- // // id =
10
- // // @attributeThis('value')
11
- // _value: any;
12
- //
13
- // @attributeThis('replace-wrap-start')
14
- // _replaceWrapStart: string | null;
15
- // @attributeThis('replace-wrap-end')
16
- // _replaceWrapEnd: string | null;
17
- //
18
- // @attributeThis('skip-if-same')
19
- // _skipIfSame: string | null;
20
- //
21
- // private _nodes: Node[] = [];
22
- //
23
- // get value(): boolean {
24
- // return this._value;
25
- // }
26
- //
27
- // set value(nv: any) {
28
- // // this._value = nv;
29
- // this.refresh(nv);
30
- // }
31
- //
32
- // constructor() {
33
- // super();
34
- // }
35
- //
36
- // connectedCallback() {
37
- // if (!this.id) {
38
- // throw new Error('[SWC] SwcIf must have an "id" attribute for reliable cleanup.');
39
- // }
40
- // if (this.hasAttribute('value')) {
41
- // this.refresh();
42
- // }
43
- // }
44
- //
45
- // @changedAttributeThis('value')
46
- // private setValue(value: any, o: string, n: string) {
47
- // if (!this.id) return;
48
- // this._value = value;
49
- // this.refresh(this._value);
50
- // }
51
- //
52
- // // @changedAttributeThis('replace-wrap')
53
- // // private setReplaceWrap(replaceWrapAttr?: string | null) {
54
- // // this.refresh();
55
- // // }
56
- //
57
- // private replaceExpressions(html: string, groupArgs: any, context: any, wrap: {start: string, end: string}): string {
58
- // let config: any = undefined;
59
- // if (wrap) {
60
- // config = {
61
- // expression: {
62
- // replace: { start: `${wrap.start}`, end: `${wrap.end}` },
63
- // callReturn: { start: `${wrap.start}=`, end: `${wrap.end}` },
64
- // call: { start: `${wrap.start}@`, end: `${wrap.end}` }
65
- // }
66
- // };
67
- // }
68
- // const ae = new ActionExpression(html, config);
69
- // const win = this.ownerDocument?.defaultView || window;
70
- //
71
- // // @ts-ignore
72
- // for (const expr of ae.getExpressions('replace')) {
73
- // try {
74
- // const value = FunctionUtils.executeReturn({
75
- // script: ConvertUtils.decodeHtmlEntity(expr.script, win.document),
76
- // context,
77
- // args: groupArgs
78
- // });
79
- // ae.replace(expr, String(value));
80
- // } catch (e) {
81
- // console.error(`[SWC] Failed to execute ${expr.original}:`, e);
82
- // }
83
- // }
84
- // return ae.getUnprocessedTemplate();
85
- // }
86
- //
87
- // refresh(value?: any) {
88
- // if (!this.id) return;
89
- // const targetValue = value !== undefined ? value : (getAttributeValue(this, 'value') ?? this._value);
90
- //
91
- // // skip-if-same 속성이 존재하고(true/빈 문자열), 이전 값과 새로운 값이 완전히 동일하면 렌더링 스킵!
92
- // if (this.hasAttribute('skip-if-same') && this._value === targetValue && (this._nodes.length > 0 || this.nextSibling)) {
93
- // if (this._value === targetValue && this._nodes.length > 0) return;
94
- // }
95
- //
96
- // this.cleanup();
97
- // this._value = targetValue;
98
- //
99
- // const portal = this.parentElement;
100
- // if (!portal || !this._value) return;
101
- //
102
- // const win = this.ownerDocument?.defaultView || window;
103
- // const helperSet = SwcUtils.getHelperAndHostSet(win, this);
104
- //
105
- // let htmlString = this.innerHTML;
106
- // const groupArgs = { ...helperSet, $value: this._value, $templateHost: this };
107
- //
108
- // htmlString = this.replaceExpressions(htmlString, groupArgs, this, {start:this._replaceWrapStart ?? '{#{', end: this._replaceWrapEnd ?? '}#}'});
109
- //
110
- // const result = this.ownerDocument?.createElement('template') || document.createElement('template');
111
- // result.innerHTML = htmlString;
112
- // const processedFragment = result.content;
113
- //
114
- // this._nodes = Array.from(processedFragment.childNodes);
115
- // this._nodes.forEach((node: any) => {
116
- // if (node instanceof HTMLElement) (node as any).__swc_template_host = this;
117
- // });
118
- //
119
- // // Add endpoint comment node
120
- // const endpointText = `swc-if endpoint id:${this.id}`;
121
- // const endpoint = this.ownerDocument?.createComment(endpointText) || document.createComment(endpointText);
122
- // processedFragment.appendChild(endpoint);
123
- // this._nodes.push(endpoint);
124
- //
125
- // portal.insertBefore(processedFragment, this.nextSibling);
126
- // }
127
- //
128
- // private cleanup() {
129
- // if (this.id) {
130
- // const portal = this.parentElement;
131
- // if (portal) {
132
- // const endpointText = `swc-if endpoint id:${this.id}`;
133
- // let current = this.nextSibling;
134
- // const toRemove: Node[] = [];
135
- //
136
- // while (current) {
137
- // toRemove.push(current);
138
- // if (current.nodeType === 8 && (current as Comment).data === endpointText) {
139
- // // Found the endpoint!
140
- // toRemove.forEach(n => {
141
- // const realNode = (n as any).__upgraded_instance || n;
142
- // if (realNode.parentElement) {
143
- // realNode.parentElement.removeChild(realNode);
144
- // }
145
- // });
146
- // break;
147
- // }
148
- // current = current.nextSibling;
149
- // }
150
- // }
151
- // }
152
- // this._nodes = [];
153
- // }
154
- //
155
- // disconnectedCallback() {
156
- // this.cleanup();
157
- // }
158
- // }