@dooboostore/simple-web-component 1.0.21 → 1.0.22

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 (151) hide show
  1. package/README.md +771 -95
  2. package/dist/cjs/decorators/addEventListener.js +4 -0
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/{appendChild.js → applyNode.js} +25 -17
  5. package/dist/cjs/decorators/applyNode.js.map +7 -0
  6. package/dist/cjs/decorators/attribute.js +31 -10
  7. package/dist/cjs/decorators/attribute.js.map +3 -3
  8. package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +6 -6
  9. package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
  10. package/dist/cjs/decorators/classList.js +11 -1
  11. package/dist/cjs/decorators/classList.js.map +2 -2
  12. package/dist/cjs/decorators/elementDefine.js +106 -55
  13. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  14. package/dist/cjs/decorators/emitCustomEvent.js +4 -3
  15. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  16. package/dist/cjs/decorators/index.js +2 -3
  17. package/dist/cjs/decorators/index.js.map +2 -2
  18. package/dist/cjs/decorators/lifecycles.js +4 -0
  19. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  20. package/dist/cjs/decorators/query.js +5 -1
  21. package/dist/cjs/decorators/query.js.map +2 -2
  22. package/dist/cjs/decorators/queryAll.js +5 -1
  23. package/dist/cjs/decorators/queryAll.js.map +2 -2
  24. package/dist/cjs/decorators/setAttribute.js +5 -1
  25. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  26. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  27. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  28. package/dist/cjs/elements/SwcAsync.js +2 -2
  29. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  30. package/dist/cjs/elements/SwcChoose.js +2 -2
  31. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  32. package/dist/cjs/elements/SwcIf.js +2 -2
  33. package/dist/cjs/elements/SwcIf.js.map +2 -2
  34. package/dist/cjs/elements/SwcLoop.js +2 -2
  35. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  36. package/dist/cjs/elements/register.js +6 -5
  37. package/dist/cjs/elements/register.js.map +2 -2
  38. package/dist/cjs/index.js +6 -18
  39. package/dist/cjs/index.js.map +2 -2
  40. package/dist/cjs/types.js.map +2 -2
  41. package/dist/esm/decorators/addEventListener.js +4 -0
  42. package/dist/esm/decorators/addEventListener.js.map +2 -2
  43. package/dist/esm/decorators/{appendChild.js → applyNode.js} +22 -14
  44. package/dist/esm/decorators/applyNode.js.map +7 -0
  45. package/dist/esm/decorators/attribute.js +31 -10
  46. package/dist/esm/decorators/attribute.js.map +3 -3
  47. package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +3 -3
  48. package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
  49. package/dist/esm/decorators/classList.js +11 -1
  50. package/dist/esm/decorators/classList.js.map +2 -2
  51. package/dist/esm/decorators/elementDefine.js +106 -55
  52. package/dist/esm/decorators/elementDefine.js.map +2 -2
  53. package/dist/esm/decorators/emitCustomEvent.js +4 -3
  54. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  55. package/dist/esm/decorators/index.js +2 -3
  56. package/dist/esm/decorators/index.js.map +2 -2
  57. package/dist/esm/decorators/lifecycles.js +4 -0
  58. package/dist/esm/decorators/lifecycles.js.map +2 -2
  59. package/dist/esm/decorators/query.js +5 -1
  60. package/dist/esm/decorators/query.js.map +2 -2
  61. package/dist/esm/decorators/queryAll.js +5 -1
  62. package/dist/esm/decorators/queryAll.js.map +2 -2
  63. package/dist/esm/decorators/setAttribute.js +5 -1
  64. package/dist/esm/decorators/setAttribute.js.map +2 -2
  65. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  66. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  67. package/dist/esm/elements/SwcAsync.js +2 -2
  68. package/dist/esm/elements/SwcAsync.js.map +2 -2
  69. package/dist/esm/elements/SwcChoose.js +2 -2
  70. package/dist/esm/elements/SwcChoose.js.map +2 -2
  71. package/dist/esm/elements/SwcIf.js +2 -2
  72. package/dist/esm/elements/SwcIf.js.map +2 -2
  73. package/dist/esm/elements/SwcLoop.js +2 -2
  74. package/dist/esm/elements/SwcLoop.js.map +2 -2
  75. package/dist/esm/elements/register.js +6 -5
  76. package/dist/esm/elements/register.js.map +2 -2
  77. package/dist/esm/index.js +6 -18
  78. package/dist/esm/index.js.map +2 -2
  79. package/dist/esm/types.js.map +2 -2
  80. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +195 -139
  81. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  82. package/dist/types/decorators/addEventListener.d.ts +6 -0
  83. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  84. package/dist/types/decorators/applyNode.d.ts +38 -0
  85. package/dist/types/decorators/applyNode.d.ts.map +1 -0
  86. package/dist/types/decorators/attribute.d.ts +6 -0
  87. package/dist/types/decorators/attribute.d.ts.map +1 -1
  88. package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
  89. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
  90. package/dist/types/decorators/classList.d.ts +25 -0
  91. package/dist/types/decorators/classList.d.ts.map +1 -1
  92. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  93. package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
  94. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  95. package/dist/types/decorators/index.d.ts +2 -3
  96. package/dist/types/decorators/index.d.ts.map +1 -1
  97. package/dist/types/decorators/lifecycles.d.ts +2 -0
  98. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  99. package/dist/types/decorators/query.d.ts +6 -0
  100. package/dist/types/decorators/query.d.ts.map +1 -1
  101. package/dist/types/decorators/queryAll.d.ts +6 -0
  102. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  103. package/dist/types/decorators/setAttribute.d.ts +5 -0
  104. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  105. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  106. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  107. package/dist/types/elements/register.d.ts +1 -1
  108. package/dist/types/elements/register.d.ts.map +1 -1
  109. package/dist/types/index.d.ts +3 -15
  110. package/dist/types/index.d.ts.map +1 -1
  111. package/dist/types/types.d.ts +2 -1
  112. package/dist/types/types.d.ts.map +1 -1
  113. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +195 -139
  114. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  115. package/package.json +3 -3
  116. package/src/decorators/addEventListener.ts +9 -0
  117. package/src/decorators/applyNode.ts +127 -0
  118. package/src/decorators/attribute.ts +46 -12
  119. package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +5 -1
  120. package/src/decorators/classList.ts +32 -0
  121. package/src/decorators/elementDefine.ts +130 -62
  122. package/src/decorators/emitCustomEvent.ts +13 -5
  123. package/src/decorators/index.ts +2 -3
  124. package/src/decorators/lifecycles.ts +3 -1
  125. package/src/decorators/query.ts +9 -0
  126. package/src/decorators/queryAll.ts +9 -0
  127. package/src/decorators/setAttribute.ts +8 -0
  128. package/src/elements/SwcAppEngine.ts +1 -0
  129. package/src/elements/SwcAppMixin.ts +2 -1
  130. package/src/elements/SwcAsync.ts +2 -2
  131. package/src/elements/SwcChoose.ts +2 -2
  132. package/src/elements/SwcIf.ts +2 -2
  133. package/src/elements/SwcLoop.ts +2 -2
  134. package/src/elements/register.ts +7 -5
  135. package/src/index.ts +8 -17
  136. package/src/types.ts +2 -1
  137. package/dist/cjs/decorators/appendChild.js.map +0 -7
  138. package/dist/cjs/decorators/changedAttribute.js.map +0 -7
  139. package/dist/cjs/decorators/replaceChildren.js +0 -79
  140. package/dist/cjs/decorators/replaceChildren.js.map +0 -7
  141. package/dist/esm/decorators/appendChild.js.map +0 -7
  142. package/dist/esm/decorators/changedAttribute.js.map +0 -7
  143. package/dist/esm/decorators/replaceChildren.js +0 -60
  144. package/dist/esm/decorators/replaceChildren.js.map +0 -7
  145. package/dist/types/decorators/appendChild.d.ts +0 -17
  146. package/dist/types/decorators/appendChild.d.ts.map +0 -1
  147. package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
  148. package/dist/types/decorators/replaceChildren.d.ts +0 -9
  149. package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
  150. package/src/decorators/appendChild.ts +0 -86
  151. package/src/decorators/replaceChildren.ts +0 -64
@@ -1,7 +1,8 @@
1
1
  import { ReflectUtils } from '@dooboostore/core';
2
- import { ON_ATTRIBUTE_CHANGED_METADATA_KEY } from './changedAttribute';
2
+ import { ON_ATTRIBUTE_CHANGED_METADATA_KEY } from './changedAttributeHost';
3
3
  import { SET_ATTRIBUTE_METADATA_KEY } from './setAttribute';
4
4
 
5
+ export const ON_CONSTRUCTOR_METADATA_KEY = Symbol('simple-web-component:on-constructor');
5
6
  export const ON_BEFORE_CONNECTED_METADATA_KEY = Symbol('simple-web-component:on-before-connected');
6
7
  export const ON_AFTER_CONNECTED_METADATA_KEY = Symbol('simple-web-component:on-after-connected');
7
8
  export const ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol('simple-web-component:on-before-disconnected');
@@ -24,6 +25,7 @@ function createLifecycleDecorator(metadataKey: symbol): MethodDecorator {
24
25
  };
25
26
  }
26
27
 
28
+ export const onConstructor = createLifecycleDecorator(ON_CONSTRUCTOR_METADATA_KEY);
27
29
  export const onBeforeConnected = createLifecycleDecorator(ON_BEFORE_CONNECTED_METADATA_KEY);
28
30
  export const onAfterConnected = createLifecycleDecorator(ON_AFTER_CONNECTED_METADATA_KEY);
29
31
  export const onConnected = onAfterConnected;
@@ -108,3 +108,12 @@ export const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {
108
108
  const constructor = target instanceof Function ? target : target.constructor;
109
109
  return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
110
110
  };
111
+
112
+ /**
113
+ * @hostQuery decorator - simplified version of @query for :host selector
114
+ * Usage: @hostQuery()
115
+ * Usage: @hostQuery({ root: 'shadow' })
116
+ */
117
+ export function queryHost(options?: SwcQueryOptions): PropertyDecorator {
118
+ return query(':host', options);
119
+ }
@@ -107,3 +107,12 @@ export const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined
107
107
  const constructor = target instanceof Function ? target : target.constructor;
108
108
  return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
109
109
  };
110
+
111
+ /**
112
+ * @hostQueryAll decorator - simplified version of @queryAll for :host selector
113
+ * Usage: @hostQueryAll()
114
+ * Usage: @hostQueryAll({ root: 'shadow' })
115
+ */
116
+ export function queryAllHost(options?: SwcQueryOptions): PropertyDecorator {
117
+ return queryAll(':host', options);
118
+ }
@@ -103,3 +103,11 @@ export const findAllSetAttributeMetadata = (target: any): Map<string | symbol, S
103
103
  });
104
104
  return result;
105
105
  };
106
+
107
+ /**
108
+ * @setAttributeHost decorator - simplified version of @setAttribute for :host selector
109
+ * Usage: @setAttributeHost('aria-disabled')
110
+ */
111
+ export function setAttributeHost(name: string, options?: SwcQueryOptions): MethodDecorator {
112
+ return setAttribute(':host', name, options);
113
+ }
@@ -88,6 +88,7 @@ export class SwcAppEngine {
88
88
  // Rendering
89
89
  const data = this.simpleApplication.sim(_config.rootRouter);
90
90
  if (data instanceof Node) {
91
+ // console.warn('[SWC-APP-ENGINE] Rendering failed: Root element is not a DocumentFragment.', data);
91
92
  if (this.host.shadowRoot) this.host.shadowRoot.replaceChildren(data);
92
93
  else this.host.replaceChildren(data);
93
94
  }
@@ -1,7 +1,8 @@
1
1
  import { SwcAppEngine, SwcAttributeConfigType } from './SwcAppEngine';
2
+ import {SwcAppInterface} from "../types";
2
3
 
3
4
  export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Base: T) {
4
- return class extends Base {
5
+ return class extends Base implements SwcAppInterface{
5
6
  __swc_engine = new SwcAppEngine(this as any);
6
7
 
7
8
  get simpleApplication() {
@@ -1,4 +1,4 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
3
  import { FunctionUtils } from '@dooboostore/core';
4
4
 
@@ -28,7 +28,7 @@ export class SwcAsync extends HTMLTemplateElement {
28
28
  FunctionUtils.execute({ script, context: this, args });
29
29
  }
30
30
 
31
- @changedAttribute('on-get-value')
31
+ @changedAttributeHost('on-get-value')
32
32
  private refresh() {
33
33
  const script = this.getAttribute('on-get-value');
34
34
  if (!script) return;
@@ -1,4 +1,4 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
3
  import { FunctionUtils } from '@dooboostore/core';
4
4
 
@@ -36,7 +36,7 @@ export class SwcChoose extends HTMLTemplateElement {
36
36
  FunctionUtils.execute({ script, context: this, args });
37
37
  }
38
38
 
39
- @changedAttribute('on-get-value')
39
+ @changedAttributeHost('on-get-value')
40
40
  private refresh() {
41
41
  const script = this.getAttribute('on-get-value');
42
42
  if (!script) {
@@ -1,4 +1,4 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
3
  import { FunctionUtils } from '@dooboostore/core';
4
4
 
@@ -36,7 +36,7 @@ export class SwcIf extends HTMLTemplateElement {
36
36
  FunctionUtils.execute({ script, context: this, args });
37
37
  }
38
38
 
39
- @changedAttribute('on-get-value')
39
+ @changedAttributeHost('on-get-value')
40
40
  private refreshValue() {
41
41
  const script = this.getAttribute('on-get-value');
42
42
  if (!script) {
@@ -1,4 +1,4 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
3
  import { FunctionUtils } from '@dooboostore/core';
4
4
 
@@ -41,7 +41,7 @@ export class SwcLoop extends HTMLTemplateElement {
41
41
  this._nodeGroups = [];
42
42
  }
43
43
 
44
- @changedAttribute('on-get-value')
44
+ @changedAttributeHost('on-get-value')
45
45
  private refreshValue() {
46
46
  const script = this.getAttribute('on-get-value');
47
47
  if (!script) {
@@ -2,7 +2,7 @@ import { elementDefine } from '../decorators/elementDefine';
2
2
  import { SwcAppMixin } from './SwcAppMixin';
3
3
  import { SwcUtils } from '../utils/Utils';
4
4
  import { FunctionUtils } from '@dooboostore/core';
5
- import { changedAttribute } from '../decorators/changedAttribute';
5
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
6
6
 
7
7
  export const registerAllElements = (w: any) => {
8
8
  const {
@@ -179,7 +179,7 @@ export const registerAllElements = (w: any) => {
179
179
  FunctionUtils.execute({ script, context: this, args });
180
180
  }
181
181
 
182
- @changedAttribute('on-get-value')
182
+ @changedAttributeHost('on-get-value')
183
183
  private refreshValue() {
184
184
  const script = this.getAttribute('on-get-value');
185
185
  if (!script) {
@@ -294,7 +294,7 @@ export const registerAllElements = (w: any) => {
294
294
  this._nodeGroups = [];
295
295
  }
296
296
 
297
- @changedAttribute('on-get-value')
297
+ @changedAttributeHost('on-get-value')
298
298
  private refreshValue() {
299
299
  const script = this.getAttribute('on-get-value');
300
300
  if (!script) {
@@ -405,7 +405,7 @@ export const registerAllElements = (w: any) => {
405
405
  FunctionUtils.execute({ script, context: this, args });
406
406
  }
407
407
 
408
- @changedAttribute('on-get-value')
408
+ @changedAttributeHost('on-get-value')
409
409
  private refresh() {
410
410
  const script = this.getAttribute('on-get-value');
411
411
  if (!script) {
@@ -496,7 +496,7 @@ export const registerAllElements = (w: any) => {
496
496
  FunctionUtils.execute({ script, context: this, args });
497
497
  }
498
498
 
499
- @changedAttribute('on-get-value')
499
+ @changedAttributeHost('on-get-value')
500
500
  private refresh() {
501
501
  const script = this.getAttribute('on-get-value');
502
502
  if (!script) return;
@@ -732,4 +732,6 @@ export const registerAllElements = (w: any) => {
732
732
  @elementDefine('swc-app-body', { extends: 'body', window: w })
733
733
  class SwcAppBody extends SwcAppMixin(HTMLBodyElement) {}
734
734
 
735
+
736
+ return []
735
737
  };
package/src/index.ts CHANGED
@@ -1,21 +1,9 @@
1
1
  import 'reflect-metadata';
2
2
  import { registerAllElements } from './elements/register';
3
+ import {ConstructorType} from "@dooboostore/core";
3
4
 
4
5
  // Decorators
5
- export * from './decorators/elementDefine';
6
- export * from './decorators/attribute';
7
- export * from './decorators/setAttribute';
8
- export * from './decorators/changedAttribute';
9
- export { onConnectedInnerHtml } from './decorators/onConnectedInnerHtml';
10
- export * from './decorators/replaceChildren';
11
- export * from './decorators/appendChild';
12
- export * from './decorators/classList';
13
- export * from './decorators/style';
14
- export * from './decorators/emitCustomEvent';
15
- export * from './decorators/lifecycles';
16
- export * from './decorators/query';
17
- export * from './decorators/queryAll';
18
- export * from './decorators/addEventListener';
6
+ export * from './decorators';
19
7
 
20
8
  // Types
21
9
  export * from './types';
@@ -28,9 +16,12 @@ export * from './utils/TemplateUtils';
28
16
  export * from './config/config';
29
17
 
30
18
  // Registration Factory
31
- export default (w: Window, other?: ((w: Window) => void)[]): void => {
19
+ export default (w: Window, other?: ((w: Window) => ConstructorType<any>)[]): ConstructorType<any>[] => {
32
20
  registerAllElements(w);
33
- other?.forEach(fn => {
34
- fn(w);
21
+ const r = other?.map(fn => {
22
+ const a = fn(w);
23
+ // console.log('l', fn, a)
24
+ return a;
35
25
  });
26
+ return r??[];
36
27
  };
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
2
2
  import { Router } from '@dooboostore/core-web';
3
+ import {SwcAttributeConfigType} from "./elements/SwcAppEngine";
3
4
 
4
5
  export enum InjectSituationType {
5
6
  HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',
@@ -45,6 +46,6 @@ export type HelperHostSet = HelperSet & HostSet;
45
46
  export interface SwcAppInterface extends HTMLElement {
46
47
  simpleApplication?: SimpleApplication;
47
48
  router?: Router;
48
- connect(config?: any): Promise<void>;
49
+ connect(config?: SwcAttributeConfigType): Promise<void>;
49
50
  routing(path: string): Promise<void>;
50
51
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/appendChild.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\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 * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_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 (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\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 findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_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;;;;;;;kBAA6B;AAC7B,2BAA6C;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,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;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,+BAAa,eAAe,2BAA2B,UAAU,WAAW;IAC9E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,2CAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;QACtE;AAEA,YAAI,UAAU;AACZ,gBAAM,QAAQ,eAAe,KAAK,UAAU;AAC5C,gBAAM,MAAM,QAAQ,YAAY;AAEhC,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,yBAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/changedAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,+BAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,yBAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
- "names": []
7
- }
@@ -1,79 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var replaceChildren_exports = {};
19
- __export(replaceChildren_exports, {
20
- REPLACE_CHILDREN_METADATA_KEY: () => REPLACE_CHILDREN_METADATA_KEY,
21
- findAllReplaceChildrenMetadata: () => findAllReplaceChildrenMetadata,
22
- getReplaceChildrenMetadata: () => getReplaceChildrenMetadata,
23
- replaceChildren: () => replaceChildren
24
- });
25
- module.exports = __toCommonJS(replaceChildren_exports);
26
- var import_core = require("@dooboostore/core");
27
- var import_elementDefine = require("./elementDefine");
28
- const REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
29
- function replaceChildren(selector) {
30
- return (target, propertyKey, descriptor) => {
31
- const constructor = target.constructor;
32
- let meta = import_core.ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
33
- if (!meta) {
34
- meta = /* @__PURE__ */ new Map();
35
- import_core.ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
36
- }
37
- meta.set(propertyKey, selector);
38
- const original = descriptor.value;
39
- descriptor.value = async function(...args) {
40
- (0, import_elementDefine.ensureInit)(this);
41
- const res = await original.apply(this, args);
42
- if (res !== void 0) {
43
- const conf = (0, import_elementDefine.getElementConfig)(this);
44
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
45
- const currentDoc = currentWin.document;
46
- let targetEl = null;
47
- if (selector === ":host" || !selector) {
48
- targetEl = this;
49
- } else {
50
- targetEl = (this.shadowRoot || this).querySelector(selector);
51
- }
52
- if (targetEl) {
53
- if (typeof res === "string") {
54
- targetEl.textContent = res;
55
- } else {
56
- const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
57
- targetEl.replaceChildren(...nodes);
58
- }
59
- }
60
- }
61
- return res;
62
- };
63
- };
64
- }
65
- const getReplaceChildrenMetadata = (target) => {
66
- const constructor = target instanceof Function ? target : target.constructor;
67
- return import_core.ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
68
- };
69
- const findAllReplaceChildrenMetadata = (target) => {
70
- const result = /* @__PURE__ */ new Map();
71
- const maps = import_core.ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
72
- maps.forEach((map) => {
73
- if (map instanceof Map) {
74
- map.forEach((v, k) => result.set(k, v));
75
- }
76
- });
77
- return result;
78
- };
79
- //# sourceMappingURL=replaceChildren.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/replaceChildren.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');\n\n/**\n * @replaceChildren decorator to surgically replace children of a target element.\n * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }\n */\nexport function replaceChildren(selector: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;\n if (!meta) {\n meta = new Map<string | symbol, string>();\n ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);\n }\n meta.set(propertyKey, selector);\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: Element | 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 if (typeof res === 'string') {\n targetEl.textContent = res;\n } else {\n const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];\n (targetEl as any).replaceChildren(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);\n};\n\nexport const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {\n const result = new Map<string | symbol, string>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_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,kBAA6B;AAC7B,2BAA6C;AAEtC,MAAM,gCAAgC,OAAO,uCAAuC;AAMpF,SAAS,gBAAgB,UAAmC;AACjE,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,+BAA+B,WAAW;AACjF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAA6B;AACxC,+BAAa,eAAe,+BAA+B,MAAM,WAAW;AAAA,IAC9E;AACA,SAAK,IAAI,aAAa,QAAQ;AAE9B,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAa;AACjD,2CAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA2B;AAC/B,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;AAAA,QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAAA,QACtE;AAEA,YAAI,UAAU;AACZ,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,cAAc;AAAA,UACzB,OAAO;AACL,kBAAM,QAAgB,MAAM,QAAQ,GAAG,IAAI,IAAI,IAAI,OAAM,OAAO,MAAM,WAAW,WAAW,eAAe,CAAC,IAAI,CAAE,IAAI,CAAC,GAAW;AAClI,YAAC,SAAiB,gBAAgB,GAAG,KAAK;AAAA,UAC5C;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,+BAA+B,WAAW;AAC5E;AAEO,MAAM,iCAAiC,CAAC,WAA8C;AAC3F,QAAM,SAAS,oBAAI,IAA6B;AAChD,QAAM,OAAO,yBAAa,gBAA8C,+BAA+B,MAAM;AAC7G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/appendChild.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\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 * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_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 (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\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 findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,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;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,mBAAa,eAAe,2BAA2B,UAAU,WAAW;IAC9E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;QACtE;AAEA,YAAI,UAAU;AACZ,gBAAM,QAAQ,eAAe,KAAK,UAAU;AAC5C,gBAAM,MAAM,QAAQ,YAAY;AAEhC,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,aAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/changedAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,mBAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,aAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
- "names": []
7
- }
@@ -1,60 +0,0 @@
1
- import { ReflectUtils } from "@dooboostore/core";
2
- import { ensureInit, getElementConfig } from "./elementDefine.js";
3
- const REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
4
- function replaceChildren(selector) {
5
- return (target, propertyKey, descriptor) => {
6
- const constructor = target.constructor;
7
- let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
8
- if (!meta) {
9
- meta = /* @__PURE__ */ new Map();
10
- ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
11
- }
12
- meta.set(propertyKey, selector);
13
- const original = descriptor.value;
14
- descriptor.value = async function(...args) {
15
- ensureInit(this);
16
- const res = await original.apply(this, args);
17
- if (res !== void 0) {
18
- const conf = getElementConfig(this);
19
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
20
- const currentDoc = currentWin.document;
21
- let targetEl = null;
22
- if (selector === ":host" || !selector) {
23
- targetEl = this;
24
- } else {
25
- targetEl = (this.shadowRoot || this).querySelector(selector);
26
- }
27
- if (targetEl) {
28
- if (typeof res === "string") {
29
- targetEl.textContent = res;
30
- } else {
31
- const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
32
- targetEl.replaceChildren(...nodes);
33
- }
34
- }
35
- }
36
- return res;
37
- };
38
- };
39
- }
40
- const getReplaceChildrenMetadata = (target) => {
41
- const constructor = target instanceof Function ? target : target.constructor;
42
- return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
43
- };
44
- const findAllReplaceChildrenMetadata = (target) => {
45
- const result = /* @__PURE__ */ new Map();
46
- const maps = ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
47
- maps.forEach((map) => {
48
- if (map instanceof Map) {
49
- map.forEach((v, k) => result.set(k, v));
50
- }
51
- });
52
- return result;
53
- };
54
- export {
55
- REPLACE_CHILDREN_METADATA_KEY,
56
- findAllReplaceChildrenMetadata,
57
- getReplaceChildrenMetadata,
58
- replaceChildren
59
- };
60
- //# sourceMappingURL=replaceChildren.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/replaceChildren.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');\n\n/**\n * @replaceChildren decorator to surgically replace children of a target element.\n * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }\n */\nexport function replaceChildren(selector: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;\n if (!meta) {\n meta = new Map<string | symbol, string>();\n ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);\n }\n meta.set(propertyKey, selector);\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: Element | 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 if (typeof res === 'string') {\n targetEl.textContent = res;\n } else {\n const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];\n (targetEl as any).replaceChildren(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);\n};\n\nexport const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {\n const result = new Map<string | symbol, string>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAEtC,MAAM,gCAAgC,OAAO,uCAAuC;AAMpF,SAAS,gBAAgB,UAAmC;AACjE,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,+BAA+B,WAAW;AACjF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAA6B;AACxC,mBAAa,eAAe,+BAA+B,MAAM,WAAW;AAAA,IAC9E;AACA,SAAK,IAAI,aAAa,QAAQ;AAE9B,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAa;AACjD,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA2B;AAC/B,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;AAAA,QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;AAAA,QACtE;AAEA,YAAI,UAAU;AACZ,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,cAAc;AAAA,UACzB,OAAO;AACL,kBAAM,QAAgB,MAAM,QAAQ,GAAG,IAAI,IAAI,IAAI,OAAM,OAAO,MAAM,WAAW,WAAW,eAAe,CAAC,IAAI,CAAE,IAAI,CAAC,GAAW;AAClI,YAAC,SAAiB,gBAAgB,GAAG,KAAK;AAAA,UAC5C;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,+BAA+B,WAAW;AAC5E;AAEO,MAAM,iCAAiC,CAAC,WAA8C;AAC3F,QAAM,SAAS,oBAAI,IAA6B;AAChD,QAAM,OAAO,aAAa,gBAA8C,+BAA+B,MAAM;AAC7G,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,17 +0,0 @@
1
- export type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';
2
- export interface AppendChildOptions {
3
- position?: AppendChildPosition;
4
- }
5
- export interface AppendChildMetadata {
6
- propertyKey: string | symbol;
7
- selector: string;
8
- options: AppendChildOptions;
9
- }
10
- export declare const APPEND_CHILD_METADATA_KEY: unique symbol;
11
- /**
12
- * @appendChild decorator to surgically add nodes to a target element.
13
- * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }
14
- */
15
- export declare function appendChild(selector: string, options?: AppendChildOptions): MethodDecorator;
16
- export declare const findAllAppendChildMetadata: (target: any) => Map<string | symbol, AppendChildMetadata>;
17
- //# sourceMappingURL=appendChild.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appendChild.d.ts","sourceRoot":"","sources":["../../../src/decorators/appendChild.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAE1F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,eAAO,MAAM,yBAAyB,eAA8C,CAAC;AAUrF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,kBAA8C,GAAG,eAAe,CA6CtH;AAED,eAAO,MAAM,0BAA0B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,mBAAmB,CAShG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"changedAttribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/changedAttribute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,eAAsD,CAAC;AAErG,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,eAAe,CAiBxE;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,SAG5F,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAE5F,CAAC"}
@@ -1,9 +0,0 @@
1
- export declare const REPLACE_CHILDREN_METADATA_KEY: unique symbol;
2
- /**
3
- * @replaceChildren decorator to surgically replace children of a target element.
4
- * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }
5
- */
6
- export declare function replaceChildren(selector: string): MethodDecorator;
7
- export declare const getReplaceChildrenMetadata: (target: any) => Map<string | symbol, string> | undefined;
8
- export declare const findAllReplaceChildrenMetadata: (target: any) => Map<string | symbol, string>;
9
- //# sourceMappingURL=replaceChildren.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replaceChildren.d.ts","sourceRoot":"","sources":["../../../src/decorators/replaceChildren.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B,eAAkD,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAsCjE;AAED,eAAO,MAAM,0BAA0B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,SAGvF,CAAC;AAEF,eAAO,MAAM,8BAA8B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CASvF,CAAC"}
@@ -1,86 +0,0 @@
1
- import { ReflectUtils } from '@dooboostore/core';
2
- import { ensureInit, getElementConfig } from './elementDefine';
3
-
4
- export type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';
5
-
6
- export interface AppendChildOptions {
7
- position?: AppendChildPosition;
8
- }
9
-
10
- export interface AppendChildMetadata {
11
- propertyKey: string | symbol;
12
- selector: string;
13
- options: AppendChildOptions;
14
- }
15
-
16
- export const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');
17
-
18
- const normalizeNodes = (res: any, doc: Document): Node[] => {
19
- const items = Array.isArray(res) ? res : [res];
20
- return items.map(it => {
21
- if (it instanceof Node) return it;
22
- return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');
23
- });
24
- };
25
-
26
- /**
27
- * @appendChild decorator to surgically add nodes to a target element.
28
- * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }
29
- */
30
- export function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {
31
- return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
32
- const constructor = target.constructor;
33
- let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;
34
- if (!metaList) {
35
- metaList = new Map<string | symbol, AppendChildMetadata>();
36
- ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
37
- }
38
- metaList.set(propertyKey, { propertyKey, selector, options });
39
-
40
- const original = descriptor.value;
41
- descriptor.value = async function (...args: any[]) {
42
- ensureInit(this);
43
- const res = await original.apply(this, args);
44
- if (res !== undefined) {
45
- const conf = getElementConfig(this);
46
- const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
47
- const currentDoc = currentWin.document;
48
-
49
- let targetEl: HTMLElement | null = null;
50
- if (selector === ':host' || !selector) {
51
- targetEl = this as any;
52
- } else {
53
- targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
54
- }
55
-
56
- if (targetEl) {
57
- const nodes = normalizeNodes(res, currentDoc);
58
- const pos = options.position || 'beforeEnd';
59
-
60
- if (typeof res === 'string') {
61
- targetEl.insertAdjacentText(pos as InsertPosition, res);
62
- } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {
63
- targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));
64
- } else {
65
- if (pos === 'beforeEnd') targetEl.append(...nodes);
66
- else if (pos === 'afterBegin') targetEl.prepend(...nodes);
67
- else if (pos === 'beforeBegin') targetEl.before(...nodes);
68
- else if (pos === 'afterEnd') targetEl.after(...nodes);
69
- }
70
- }
71
- }
72
- return res;
73
- };
74
- };
75
- }
76
-
77
- export const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {
78
- const result = new Map<string | symbol, AppendChildMetadata>();
79
- const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);
80
- maps.forEach(map => {
81
- if (map instanceof Map) {
82
- map.forEach((v, k) => result.set(k, v));
83
- }
84
- });
85
- return result;
86
- };