@dooboostore/simple-web-component 1.0.22 → 1.0.24

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 (105) hide show
  1. package/README.md +568 -32
  2. package/dist/cjs/decorators/applyNode.js +195 -26
  3. package/dist/cjs/decorators/applyNode.js.map +2 -2
  4. package/dist/cjs/decorators/attribute.js +21 -3
  5. package/dist/cjs/decorators/attribute.js.map +2 -2
  6. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  7. package/dist/cjs/decorators/classList.js +82 -19
  8. package/dist/cjs/decorators/classList.js.map +2 -2
  9. package/dist/cjs/decorators/elementDefine.js +1 -2
  10. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  11. package/dist/cjs/decorators/index.js +0 -1
  12. package/dist/cjs/decorators/index.js.map +2 -2
  13. package/dist/cjs/decorators/lifecycles.js +25 -0
  14. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  15. package/dist/cjs/decorators/query.js +77 -2
  16. package/dist/cjs/decorators/query.js.map +2 -2
  17. package/dist/cjs/decorators/queryAll.js +77 -2
  18. package/dist/cjs/decorators/queryAll.js.map +2 -2
  19. package/dist/cjs/decorators/setAttribute.js +4 -4
  20. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  21. package/dist/cjs/decorators/style.js +70 -13
  22. package/dist/cjs/decorators/style.js.map +2 -2
  23. package/dist/cjs/index.js +4 -4
  24. package/dist/cjs/index.js.map +2 -2
  25. package/dist/cjs/utils/Utils.js +140 -1
  26. package/dist/cjs/utils/Utils.js.map +2 -2
  27. package/dist/esm/decorators/applyNode.js +195 -26
  28. package/dist/esm/decorators/applyNode.js.map +2 -2
  29. package/dist/esm/decorators/attribute.js +21 -3
  30. package/dist/esm/decorators/attribute.js.map +2 -2
  31. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  32. package/dist/esm/decorators/classList.js +82 -19
  33. package/dist/esm/decorators/classList.js.map +2 -2
  34. package/dist/esm/decorators/elementDefine.js +1 -2
  35. package/dist/esm/decorators/elementDefine.js.map +2 -2
  36. package/dist/esm/decorators/index.js +0 -1
  37. package/dist/esm/decorators/index.js.map +2 -2
  38. package/dist/esm/decorators/lifecycles.js +25 -0
  39. package/dist/esm/decorators/lifecycles.js.map +2 -2
  40. package/dist/esm/decorators/query.js +77 -2
  41. package/dist/esm/decorators/query.js.map +2 -2
  42. package/dist/esm/decorators/queryAll.js +77 -2
  43. package/dist/esm/decorators/queryAll.js.map +2 -2
  44. package/dist/esm/decorators/setAttribute.js +4 -4
  45. package/dist/esm/decorators/setAttribute.js.map +2 -2
  46. package/dist/esm/decorators/style.js +70 -13
  47. package/dist/esm/decorators/style.js.map +2 -2
  48. package/dist/esm/index.js +4 -4
  49. package/dist/esm/index.js.map +2 -2
  50. package/dist/esm/utils/Utils.js +140 -1
  51. package/dist/esm/utils/Utils.js.map +2 -2
  52. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +678 -168
  53. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  54. package/dist/types/decorators/applyNode.d.ts +107 -2
  55. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  56. package/dist/types/decorators/attribute.d.ts +11 -4
  57. package/dist/types/decorators/attribute.d.ts.map +1 -1
  58. package/dist/types/decorators/classList.d.ts +22 -10
  59. package/dist/types/decorators/classList.d.ts.map +1 -1
  60. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  61. package/dist/types/decorators/index.d.ts +0 -1
  62. package/dist/types/decorators/index.d.ts.map +1 -1
  63. package/dist/types/decorators/lifecycles.d.ts +14 -0
  64. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  65. package/dist/types/decorators/query.d.ts +68 -7
  66. package/dist/types/decorators/query.d.ts.map +1 -1
  67. package/dist/types/decorators/queryAll.d.ts +70 -1
  68. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  69. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  70. package/dist/types/decorators/style.d.ts +37 -3
  71. package/dist/types/decorators/style.d.ts.map +1 -1
  72. package/dist/types/index.d.ts +1 -2
  73. package/dist/types/index.d.ts.map +1 -1
  74. package/dist/types/utils/Utils.d.ts +49 -0
  75. package/dist/types/utils/Utils.d.ts.map +1 -1
  76. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +678 -168
  77. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  78. package/package.json +2 -2
  79. package/src/decorators/applyNode.ts +319 -37
  80. package/src/decorators/attribute.ts +44 -11
  81. package/src/decorators/changedAttributeHost.ts +1 -1
  82. package/src/decorators/classList.ts +107 -22
  83. package/src/decorators/elementDefine.ts +1 -2
  84. package/src/decorators/index.ts +0 -1
  85. package/src/decorators/lifecycles.ts +40 -0
  86. package/src/decorators/query.ts +147 -7
  87. package/src/decorators/queryAll.ts +148 -2
  88. package/src/decorators/setAttribute.ts +6 -5
  89. package/src/decorators/style.ts +109 -13
  90. package/src/index.ts +6 -6
  91. package/src/utils/Utils.ts +144 -0
  92. package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
  93. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
  94. package/dist/cjs/utils/TemplateUtils.js +0 -103
  95. package/dist/cjs/utils/TemplateUtils.js.map +0 -7
  96. package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
  97. package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
  98. package/dist/esm/utils/TemplateUtils.js +0 -84
  99. package/dist/esm/utils/TemplateUtils.js.map +0 -7
  100. package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
  101. package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
  102. package/dist/types/utils/TemplateUtils.d.ts +0 -54
  103. package/dist/types/utils/TemplateUtils.d.ts.map +0 -1
  104. package/src/decorators/onConnectedInnerHtml.ts +0 -42
  105. package/src/utils/TemplateUtils.ts +0 -83
@@ -1,19 +1,23 @@
1
1
  import { ReflectUtils } from '@dooboostore/core';
2
2
  import { ensureInit } from './elementDefine';
3
3
  import { SwcUtils } from '../utils/Utils';
4
+ import { SwcQueryOptions } from '../types';
4
5
 
5
6
  export type StyleAction = 'set' | 'update' | 'remove';
6
7
 
8
+ export interface StyleOptions extends SwcQueryOptions {}
9
+
7
10
  export interface StyleMetadata {
8
11
  propertyKey: string | symbol;
9
12
  selector: string;
10
13
  action: StyleAction;
14
+ options: StyleOptions;
11
15
  }
12
16
 
13
17
  export const STYLE_METADATA_KEY = Symbol('simple-web-component:style');
14
18
 
15
19
  function createStyleDecorator(action: StyleAction) {
16
- return (selector: string): MethodDecorator => {
20
+ return (selector: string, options: StyleOptions = {}): MethodDecorator => {
17
21
  return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
18
22
  const constructor = target.constructor;
19
23
  let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;
@@ -21,21 +25,59 @@ function createStyleDecorator(action: StyleAction) {
21
25
  metaList = new Map<string | symbol, StyleMetadata>();
22
26
  ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
23
27
  }
24
- metaList.set(propertyKey, { propertyKey, selector, action });
28
+ metaList.set(propertyKey, { propertyKey, selector, action, options });
25
29
 
26
30
  const original = descriptor.value;
27
31
  descriptor.value = async function (...args: any[]) {
28
32
  ensureInit(this);
29
33
  const res = await original.apply(this, args);
30
34
  if (res !== undefined) {
35
+ const r = options.root || 'auto';
31
36
  const hostSet = SwcUtils.getHostSet(this as any);
32
- let targetEl: HTMLElement | null = null;
33
- if (selector === ':host' || !selector) targetEl = this as any;
34
- else if (selector === ':parentHost') targetEl = hostSet.$parentHost;
35
- else if (selector === ':appHost') targetEl = hostSet.$appHost;
36
- else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
37
+ const targetEls: HTMLElement[] = [];
38
+
39
+ const applyRoot = (t: any) => {
40
+ if (!t || !(t instanceof HTMLElement)) return;
41
+ if (r === 'auto') {
42
+ // Styles belong to the ELEMENT, not the ShadowRoot.
43
+ targetEls.push(t);
44
+ } else {
45
+ if (r === 'light' || r === 'all') targetEls.push(t);
46
+ if ((r === 'shadow' || r === 'all') && t.shadowRoot) {
47
+ // ShadowRoot doesn't have a style property, so we skip it.
48
+ }
49
+ }
50
+ };
51
+
52
+ if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
53
+ else if (selector === ':appHost') applyRoot(hostSet.$appHost);
54
+ else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
55
+ else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
56
+ else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
57
+ else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
58
+ else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
59
+ else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
60
+ else if (selector === ':host' || !selector) applyRoot(this);
61
+ else {
62
+ if (r === 'shadow') {
63
+ const found = this.shadowRoot?.querySelectorAll(selector);
64
+ if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
65
+ } else if (r === 'light') {
66
+ const found = (this as any).querySelectorAll(selector);
67
+ if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
68
+ } else if (r === 'all') {
69
+ const sFound = this.shadowRoot?.querySelectorAll(selector);
70
+ const lFound = (this as any).querySelectorAll(selector);
71
+ if (sFound) targetEls.push(...(Array.from(sFound) as HTMLElement[]));
72
+ if (lFound) targetEls.push(...(Array.from(lFound) as HTMLElement[]));
73
+ } else {
74
+ // auto
75
+ const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);
76
+ if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));
77
+ }
78
+ }
37
79
 
38
- if (targetEl) {
80
+ targetEls.forEach(targetEl => {
39
81
  if (action === 'set') {
40
82
  targetEl.style.cssText = '';
41
83
  if (typeof res === 'object' && res !== null) {
@@ -49,9 +91,9 @@ function createStyleDecorator(action: StyleAction) {
49
91
  }
50
92
  } else if (action === 'remove') {
51
93
  const props = Array.isArray(res) ? res : [res];
52
- props.forEach(p => targetEl!.style.removeProperty(String(p)));
94
+ props.forEach(p => targetEl.style.removeProperty(String(p)));
53
95
  }
54
- }
96
+ });
55
97
  }
56
98
  return res;
57
99
  };
@@ -62,20 +104,74 @@ function createStyleDecorator(action: StyleAction) {
62
104
  /**
63
105
  * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).
64
106
  * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }
107
+ * Usage: @setStyle('#box', { root: 'shadow' }) getStyles() { return { color: 'red' }; }
108
+ */
109
+ export const setStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('set')(selector, options);
110
+
111
+ /**
112
+ * @setStyleHost decorator - simplified version of @setStyle for :host selector.
113
+ * Usage: @setStyleHost setHostStyle() { return { color: 'red' }; }
114
+ * Usage: @setStyleHost() setHostStyle() { return { color: 'red' }; }
115
+ * Usage: @setStyleHost({ ... }) setHostStyle() { return { color: 'red' }; }
65
116
  */
66
- export const setStyle = createStyleDecorator('set');
117
+ export function setStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
118
+ export function setStyleHost(): MethodDecorator;
119
+ export function setStyleHost(options: StyleOptions): MethodDecorator;
120
+ export function setStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
121
+ if (propertyKey !== undefined) {
122
+ const decorator = createStyleDecorator('set')(':host', {});
123
+ return decorator(targetOrOptions, propertyKey, descriptor);
124
+ }
125
+ return createStyleDecorator('set')(':host', (targetOrOptions as StyleOptions) || {});
126
+ }
67
127
 
68
128
  /**
69
129
  * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).
70
130
  * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }
131
+ * Usage: @updateStyle('#box', { root: 'shadow' }) updateStyles() { return { color: 'blue' }; }
132
+ */
133
+ export const updateStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('update')(selector, options);
134
+
135
+ /**
136
+ * @updateStyleHost decorator - simplified version of @updateStyle for :host selector.
137
+ * Usage: @updateStyleHost updateStyles() { return { color: 'blue' }; }
138
+ * Usage: @updateStyleHost() updateStyles() { return { color: 'blue' }; }
139
+ * Usage: @updateStyleHost({ ... }) updateStyles() { return { color: 'blue' }; }
71
140
  */
72
- export const updateStyle = createStyleDecorator('update');
141
+ export function updateStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
142
+ export function updateStyleHost(): MethodDecorator;
143
+ export function updateStyleHost(options: StyleOptions): MethodDecorator;
144
+ export function updateStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
145
+ if (propertyKey !== undefined) {
146
+ const decorator = createStyleDecorator('update')(':host', {});
147
+ return decorator(targetOrOptions, propertyKey, descriptor);
148
+ }
149
+ return createStyleDecorator('update')(':host', (targetOrOptions as StyleOptions) || {});
150
+ }
73
151
 
74
152
  /**
75
153
  * @removeStyle decorator to surgically remove styles from a target element.
76
154
  * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }
155
+ * Usage: @removeStyle('#box', { root: 'shadow' }) clearStyles() { return ['color']; }
77
156
  */
78
- export const removeStyle = createStyleDecorator('remove');
157
+ export const removeStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('remove')(selector, options);
158
+
159
+ /**
160
+ * @removeStyleHost decorator - simplified version of @removeStyle for :host selector.
161
+ * Usage: @removeStyleHost clearStyles() { return ['color']; }
162
+ * Usage: @removeStyleHost() clearStyles() { return ['color']; }
163
+ * Usage: @removeStyleHost({ ... }) clearStyles() { return ['color']; }
164
+ */
165
+ export function removeStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;
166
+ export function removeStyleHost(): MethodDecorator;
167
+ export function removeStyleHost(options: StyleOptions): MethodDecorator;
168
+ export function removeStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {
169
+ if (propertyKey !== undefined) {
170
+ const decorator = createStyleDecorator('remove')(':host', {});
171
+ return decorator(targetOrOptions, propertyKey, descriptor);
172
+ }
173
+ return createStyleDecorator('remove')(':host', (targetOrOptions as StyleOptions) || {});
174
+ }
79
175
 
80
176
  export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {
81
177
  const result = new Map<string | symbol, StyleMetadata>();
package/src/index.ts CHANGED
@@ -10,18 +10,18 @@ export * from './types';
10
10
 
11
11
  // Utilities
12
12
  export * from './utils/Utils';
13
- export * from './utils/TemplateUtils';
14
13
 
15
14
  // Config
16
15
  export * from './config/config';
17
16
 
18
17
  // Registration Factory
19
- export default (w: Window, other?: ((w: Window) => ConstructorType<any>)[]): ConstructorType<any>[] => {
18
+ export default (w: Window, other?: (((w: Window) => ConstructorType<any>) | any) []) => {
20
19
  registerAllElements(w);
21
20
  const r = other?.map(fn => {
22
- const a = fn(w);
23
- // console.log('l', fn, a)
24
- return a;
21
+ if (typeof fn === 'function') {
22
+ const a = fn(w);
23
+ } else {
24
+ }
25
25
  });
26
- return r??[];
26
+ // return r??[];
27
27
  };
@@ -3,6 +3,150 @@ import {getElementConfig} from "../decorators";
3
3
 
4
4
  export const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');
5
5
 
6
+ // DOM Creation Utilities
7
+ export const htmlFragment = (html: string, doc?: Document): DocumentFragment => {
8
+ const d = doc || (typeof document !== 'undefined' ? document : undefined);
9
+ if (!d) throw new Error('Document is not available');
10
+ const template = d.createElement('template');
11
+ template.innerHTML = html.trim();
12
+ return template.content;
13
+ };
14
+
15
+ export const textNode = (text: string | any, doc?: Document): Text => {
16
+ const d = doc || (typeof document !== 'undefined' ? document : undefined);
17
+ if (!d) throw new Error('Document is not available');
18
+ return d.createTextNode(text !== undefined && text !== null ? String(text) : '');
19
+ };
20
+
21
+ export const commentNode = (comment: string | any, doc?: Document): Comment => {
22
+ const d = doc || (typeof document !== 'undefined' ? document : undefined);
23
+ if (!d) throw new Error('Document is not available');
24
+ return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');
25
+ };
26
+
27
+ export const createElement = <T extends HTMLElement>(
28
+ tagName: string,
29
+ options?: { html?: string; attrs?: Record<string, any>; doc?: Document }
30
+ ): T => {
31
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
32
+ if (!d) throw new Error('Document is not available');
33
+ const el = d.createElement(tagName) as T;
34
+ if (options?.html) el.innerHTML = options.html;
35
+ if (options?.attrs) {
36
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
37
+ }
38
+ return el;
39
+ };
40
+
41
+ // Element factory functions
42
+ export const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {
43
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
44
+ if (!d) throw new Error('Document is not available');
45
+ const el = d.createElement('div') as HTMLDivElement;
46
+ el.innerHTML = html.trim();
47
+ if (options?.attrs) {
48
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
49
+ }
50
+ return el;
51
+ };
52
+
53
+ export const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {
54
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
55
+ if (!d) throw new Error('Document is not available');
56
+ const el = d.createElement('span') as HTMLSpanElement;
57
+ el.innerHTML = html.trim();
58
+ if (options?.attrs) {
59
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
60
+ }
61
+ return el;
62
+ };
63
+
64
+ export const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {
65
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
66
+ if (!d) throw new Error('Document is not available');
67
+ const el = d.createElement('button') as HTMLButtonElement;
68
+ el.innerHTML = html.trim();
69
+ if (options?.attrs) {
70
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
71
+ }
72
+ return el;
73
+ };
74
+
75
+ export const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {
76
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
77
+ if (!d) throw new Error('Document is not available');
78
+ const el = d.createElement('ul') as HTMLUListElement;
79
+ if (options?.attrs) {
80
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
81
+ }
82
+ return el;
83
+ };
84
+
85
+ export const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {
86
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
87
+ if (!d) throw new Error('Document is not available');
88
+ const el = d.createElement('li') as HTMLLIElement;
89
+ el.innerHTML = html.trim();
90
+ if (options?.attrs) {
91
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
92
+ }
93
+ return el;
94
+ };
95
+
96
+ export const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {
97
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
98
+ if (!d) throw new Error('Document is not available');
99
+ const el = d.createElement('a') as HTMLAnchorElement;
100
+ el.innerHTML = html.trim();
101
+ if (options?.href) el.href = options.href;
102
+ if (options?.attrs) {
103
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
104
+ }
105
+ return el;
106
+ };
107
+
108
+ export const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {
109
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
110
+ if (!d) throw new Error('Document is not available');
111
+ const el = d.createElement('p') as HTMLParagraphElement;
112
+ el.innerHTML = html.trim();
113
+ if (options?.attrs) {
114
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
115
+ }
116
+ return el;
117
+ };
118
+
119
+ export const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {
120
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
121
+ if (!d) throw new Error('Document is not available');
122
+ const el = d.createElement(`h${level}`) as HTMLHeadingElement;
123
+ el.innerHTML = html.trim();
124
+ if (options?.attrs) {
125
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
126
+ }
127
+ return el;
128
+ };
129
+
130
+ export const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {
131
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
132
+ if (!d) throw new Error('Document is not available');
133
+ const el = d.createElement('section');
134
+ if (options?.attrs) {
135
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
136
+ }
137
+ return el;
138
+ };
139
+
140
+ export const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {
141
+ const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);
142
+ if (!d) throw new Error('Document is not available');
143
+ const el = d.createElement('article');
144
+ if (options?.attrs) {
145
+ Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
146
+ }
147
+ return el;
148
+ };
149
+
6
150
  export namespace SwcUtils {
7
151
  export const getHelperSet = (win: Window): HelperSet => {
8
152
  const doc: Document = win.document;
@@ -1,48 +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 onConnectedInnerHtml_exports = {};
19
- __export(onConnectedInnerHtml_exports, {
20
- INNER_HTML_METADATA_KEY: () => INNER_HTML_METADATA_KEY,
21
- getOnConnectedInnerHtmlMetadata: () => getOnConnectedInnerHtmlMetadata,
22
- onConnectedInnerHtml: () => onConnectedInnerHtml
23
- });
24
- module.exports = __toCommonJS(onConnectedInnerHtml_exports);
25
- var import_core = require("@dooboostore/core");
26
- const INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
27
- function onConnectedInnerHtml(arg1, arg2, arg3) {
28
- const decorator = (options, target, propertyKey) => {
29
- const constructor = target.constructor;
30
- let list = import_core.ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
31
- if (!list) {
32
- list = [];
33
- import_core.ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
34
- }
35
- list.push({ propertyKey, options });
36
- };
37
- if (arg2) {
38
- return decorator({}, arg1, arg2);
39
- }
40
- return (target, propertyKey) => {
41
- decorator(arg1 || {}, target, propertyKey);
42
- };
43
- }
44
- const getOnConnectedInnerHtmlMetadata = (target) => {
45
- const constructor = target instanceof Function ? target : target.constructor;
46
- return import_core.ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
47
- };
48
- //# sourceMappingURL=onConnectedInnerHtml.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/onConnectedInnerHtml.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nexport const INNER_HTML_METADATA_KEY = Symbol('simple-web-component:inner-html');\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAWtB,MAAM,0BAA0B,OAAO,iCAAiC;AAOxE,SAAS,qBAAqB,MAAkC,MAAwB,MAAmD;AAChJ,QAAM,YAAY,CAAC,SAA2B,QAAgB,gBAAiC;AAC7F,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,YAAiC,yBAAyB,WAAW;AAC7F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,yBAAyB,MAAM,WAAW;AAAA,IACxE;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AAEA,MAAI,MAAM;AACR,WAAO,UAAU,CAAC,GAAG,MAAO,IAAI;AAAA,EAClC;AAEA,SAAO,CAAC,QAAgB,gBAAiC;AACvD,cAAW,QAA6B,CAAC,GAAG,QAAQ,WAAW;AAAA,EACjE;AACF;AAEO,MAAM,kCAAkC,CAAC,WAAiD;AAC/F,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,yBAAyB,WAAW;AACtE;",
6
- "names": []
7
- }
@@ -1,103 +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 TemplateUtils_exports = {};
19
- __export(TemplateUtils_exports, {
20
- TemplateUtils: () => TemplateUtils,
21
- createElement: () => createElement,
22
- htmlAElement: () => htmlAElement,
23
- htmlArticleElement: () => htmlArticleElement,
24
- htmlButtonElement: () => htmlButtonElement,
25
- htmlDivElement: () => htmlDivElement,
26
- htmlFragment: () => htmlFragment,
27
- htmlH1Element: () => htmlH1Element,
28
- htmlH2Element: () => htmlH2Element,
29
- htmlH3Element: () => htmlH3Element,
30
- htmlH4Element: () => htmlH4Element,
31
- htmlH5Element: () => htmlH5Element,
32
- htmlH6Element: () => htmlH6Element,
33
- htmlInputElement: () => htmlInputElement,
34
- htmlLiElement: () => htmlLiElement,
35
- htmlPElement: () => htmlPElement,
36
- htmlSectionElement: () => htmlSectionElement,
37
- htmlSpanElement: () => htmlSpanElement,
38
- htmlUlElement: () => htmlUlElement,
39
- textNode: () => textNode
40
- });
41
- module.exports = __toCommonJS(TemplateUtils_exports);
42
- var TemplateUtils;
43
- ((TemplateUtils2) => {
44
- TemplateUtils2.htmlFragment = (strings, ...values) => {
45
- const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
46
- const template = document.createElement("template");
47
- template.innerHTML = raw.trim();
48
- return template.content;
49
- };
50
- TemplateUtils2.textNode = (strings, ...values) => {
51
- const raw = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
52
- return document.createTextNode(raw);
53
- };
54
- TemplateUtils2.createElement = (info, attrs = {}) => {
55
- const el = document.createElement(info.tagName);
56
- if (info.innerHtml !== void 0) el.innerHTML = info.innerHtml;
57
- Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
58
- return el;
59
- };
60
- const createTagFunction = (tagName) => {
61
- return (strings, ...values) => {
62
- const el = document.createElement(tagName);
63
- el.innerHTML = strings.reduce((acc, str, i) => acc + str + (values[i] !== void 0 ? values[i] : ""), "");
64
- return el;
65
- };
66
- };
67
- TemplateUtils2.htmlDivElement = createTagFunction("div");
68
- TemplateUtils2.htmlSpanElement = createTagFunction("span");
69
- TemplateUtils2.htmlButtonElement = createTagFunction("button");
70
- TemplateUtils2.htmlUlElement = createTagFunction("ul");
71
- TemplateUtils2.htmlLiElement = createTagFunction("li");
72
- TemplateUtils2.htmlInputElement = createTagFunction("input");
73
- TemplateUtils2.htmlAElement = createTagFunction("a");
74
- TemplateUtils2.htmlPElement = createTagFunction("p");
75
- TemplateUtils2.htmlH1Element = createTagFunction("h1");
76
- TemplateUtils2.htmlH2Element = createTagFunction("h2");
77
- TemplateUtils2.htmlH3Element = createTagFunction("h3");
78
- TemplateUtils2.htmlH4Element = createTagFunction("h4");
79
- TemplateUtils2.htmlH5Element = createTagFunction("h5");
80
- TemplateUtils2.htmlH6Element = createTagFunction("h6");
81
- TemplateUtils2.htmlSectionElement = createTagFunction("section");
82
- TemplateUtils2.htmlArticleElement = createTagFunction("article");
83
- })(TemplateUtils || (TemplateUtils = {}));
84
- const htmlFragment = TemplateUtils.htmlFragment;
85
- const textNode = TemplateUtils.textNode;
86
- const createElement = TemplateUtils.createElement;
87
- const htmlDivElement = TemplateUtils.htmlDivElement;
88
- const htmlSpanElement = TemplateUtils.htmlSpanElement;
89
- const htmlButtonElement = TemplateUtils.htmlButtonElement;
90
- const htmlUlElement = TemplateUtils.htmlUlElement;
91
- const htmlLiElement = TemplateUtils.htmlLiElement;
92
- const htmlInputElement = TemplateUtils.htmlInputElement;
93
- const htmlAElement = TemplateUtils.htmlAElement;
94
- const htmlPElement = TemplateUtils.htmlPElement;
95
- const htmlH1Element = TemplateUtils.htmlH1Element;
96
- const htmlH2Element = TemplateUtils.htmlH2Element;
97
- const htmlH3Element = TemplateUtils.htmlH3Element;
98
- const htmlH4Element = TemplateUtils.htmlH4Element;
99
- const htmlH5Element = TemplateUtils.htmlH5Element;
100
- const htmlH6Element = TemplateUtils.htmlH6Element;
101
- const htmlSectionElement = TemplateUtils.htmlSectionElement;
102
- const htmlArticleElement = TemplateUtils.htmlArticleElement;
103
- //# sourceMappingURL=TemplateUtils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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": "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",
6
- "names": ["TemplateUtils"]
7
- }
@@ -1,29 +0,0 @@
1
- import { ReflectUtils } from "@dooboostore/core";
2
- const INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
3
- function onConnectedInnerHtml(arg1, arg2, arg3) {
4
- const decorator = (options, target, propertyKey) => {
5
- const constructor = target.constructor;
6
- let list = ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
7
- if (!list) {
8
- list = [];
9
- ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);
10
- }
11
- list.push({ propertyKey, options });
12
- };
13
- if (arg2) {
14
- return decorator({}, arg1, arg2);
15
- }
16
- return (target, propertyKey) => {
17
- decorator(arg1 || {}, target, propertyKey);
18
- };
19
- }
20
- const getOnConnectedInnerHtmlMetadata = (target) => {
21
- const constructor = target instanceof Function ? target : target.constructor;
22
- return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);
23
- };
24
- export {
25
- INNER_HTML_METADATA_KEY,
26
- getOnConnectedInnerHtmlMetadata,
27
- onConnectedInnerHtml
28
- };
29
- //# sourceMappingURL=onConnectedInnerHtml.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/onConnectedInnerHtml.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport interface InnerHtmlOptions {\n useShadow?: boolean;\n}\n\nexport interface InnerHtmlMetadata {\n propertyKey: string | symbol;\n options: InnerHtmlOptions;\n}\n\nexport const INNER_HTML_METADATA_KEY = Symbol('simple-web-component:inner-html');\n\n/**\n * @onConnectedInnerHtml decorator to define the initial HTML content when connected.\n */\nexport function onConnectedInnerHtml(options: InnerHtmlOptions): MethodDecorator;\nexport function onConnectedInnerHtml(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function onConnectedInnerHtml(arg1?: InnerHtmlOptions | Object, arg2?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {\n const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let list = ReflectUtils.getMetadata<InnerHtmlMetadata[]>(INNER_HTML_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(INNER_HTML_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n\n if (arg2) {\n return decorator({}, arg1!, arg2);\n }\n\n return (target: Object, propertyKey: string | symbol) => {\n decorator((arg1 as InnerHtmlOptions) || {}, target, propertyKey);\n };\n}\n\nexport const getOnConnectedInnerHtmlMetadata = (target: any): InnerHtmlMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(INNER_HTML_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAWtB,MAAM,0BAA0B,OAAO,iCAAiC;AAOxE,SAAS,qBAAqB,MAAkC,MAAwB,MAAmD;AAChJ,QAAM,YAAY,CAAC,SAA2B,QAAgB,gBAAiC;AAC7F,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,YAAiC,yBAAyB,WAAW;AAC7F,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,yBAAyB,MAAM,WAAW;AAAA,IACxE;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AAEA,MAAI,MAAM;AACR,WAAO,UAAU,CAAC,GAAG,MAAO,IAAI;AAAA,EAClC;AAEA,SAAO,CAAC,QAAgB,gBAAiC;AACvD,cAAW,QAA6B,CAAC,GAAG,QAAQ,WAAW;AAAA,EACjE;AACF;AAEO,MAAM,kCAAkC,CAAC,WAAiD;AAC/F,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,yBAAyB,WAAW;AACtE;",
6
- "names": []
7
- }