@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.
- package/README.md +568 -32
- package/dist/cjs/decorators/applyNode.js +195 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +21 -3
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/classList.js +82 -19
- package/dist/cjs/decorators/classList.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +1 -2
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/index.js +0 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +25 -0
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +77 -2
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +77 -2
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setAttribute.js +4 -4
- package/dist/cjs/decorators/setAttribute.js.map +2 -2
- package/dist/cjs/decorators/style.js +70 -13
- package/dist/cjs/decorators/style.js.map +2 -2
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/utils/Utils.js +140 -1
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +195 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/attribute.js +21 -3
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/classList.js +82 -19
- package/dist/esm/decorators/classList.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +1 -2
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/index.js +0 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +25 -0
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +77 -2
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +77 -2
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setAttribute.js +4 -4
- package/dist/esm/decorators/setAttribute.js.map +2 -2
- package/dist/esm/decorators/style.js +70 -13
- package/dist/esm/decorators/style.js.map +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/utils/Utils.js +140 -1
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +678 -168
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/applyNode.d.ts +107 -2
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +11 -4
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/classList.d.ts +22 -10
- package/dist/types/decorators/classList.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +0 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +14 -0
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +68 -7
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +70 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setAttribute.d.ts.map +1 -1
- package/dist/types/decorators/style.d.ts +37 -3
- package/dist/types/decorators/style.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +49 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +678 -168
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +2 -2
- package/src/decorators/applyNode.ts +319 -37
- package/src/decorators/attribute.ts +44 -11
- package/src/decorators/changedAttributeHost.ts +1 -1
- package/src/decorators/classList.ts +107 -22
- package/src/decorators/elementDefine.ts +1 -2
- package/src/decorators/index.ts +0 -1
- package/src/decorators/lifecycles.ts +40 -0
- package/src/decorators/query.ts +147 -7
- package/src/decorators/queryAll.ts +148 -2
- package/src/decorators/setAttribute.ts +6 -5
- package/src/decorators/style.ts +109 -13
- package/src/index.ts +6 -6
- package/src/utils/Utils.ts +144 -0
- package/dist/cjs/decorators/onConnectedInnerHtml.js +0 -48
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/cjs/utils/TemplateUtils.js +0 -103
- package/dist/cjs/utils/TemplateUtils.js.map +0 -7
- package/dist/esm/decorators/onConnectedInnerHtml.js +0 -29
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +0 -7
- package/dist/esm/utils/TemplateUtils.js +0 -84
- package/dist/esm/utils/TemplateUtils.js.map +0 -7
- package/dist/types/decorators/onConnectedInnerHtml.d.ts +0 -15
- package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +0 -1
- package/dist/types/utils/TemplateUtils.d.ts +0 -54
- package/dist/types/utils/TemplateUtils.d.ts.map +0 -1
- package/src/decorators/onConnectedInnerHtml.ts +0 -42
- package/src/utils/TemplateUtils.ts +0 -83
|
@@ -18,6 +18,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var queryAll_exports = {};
|
|
19
19
|
__export(queryAll_exports, {
|
|
20
20
|
QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
|
|
21
|
+
allAppHost: () => allAppHost,
|
|
22
|
+
allFirstAppHost: () => allFirstAppHost,
|
|
23
|
+
allFirstHost: () => allFirstHost,
|
|
24
|
+
allHost: () => allHost,
|
|
25
|
+
allLastAppHost: () => allLastAppHost,
|
|
26
|
+
allLastHost: () => allLastHost,
|
|
27
|
+
allParentHost: () => allParentHost,
|
|
21
28
|
getQueryAllMetadata: () => getQueryAllMetadata,
|
|
22
29
|
queryAll: () => queryAll,
|
|
23
30
|
queryAllHost: () => queryAllHost
|
|
@@ -121,7 +128,75 @@ const getQueryAllMetadata = (target) => {
|
|
|
121
128
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
122
129
|
return import_core.ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
|
|
123
130
|
};
|
|
124
|
-
function queryAllHost(
|
|
125
|
-
|
|
131
|
+
function queryAllHost(targetOrOptions, propertyKey) {
|
|
132
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
133
|
+
return queryAll(":host", {})(targetOrOptions, propertyKey);
|
|
134
|
+
}
|
|
135
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
136
|
+
return queryAll(":host", targetOrOptions);
|
|
137
|
+
} else {
|
|
138
|
+
return queryAll(":host", {});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const allHost = queryAllHost;
|
|
142
|
+
function allParentHost(targetOrOptions, propertyKey) {
|
|
143
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
144
|
+
return queryAll(":parentHost", {})(targetOrOptions, propertyKey);
|
|
145
|
+
}
|
|
146
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
147
|
+
return queryAll(":parentHost", targetOrOptions);
|
|
148
|
+
} else {
|
|
149
|
+
return queryAll(":parentHost", {});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function allAppHost(targetOrOptions, propertyKey) {
|
|
153
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
154
|
+
return queryAll(":appHost", {})(targetOrOptions, propertyKey);
|
|
155
|
+
}
|
|
156
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
157
|
+
return queryAll(":appHost", targetOrOptions);
|
|
158
|
+
} else {
|
|
159
|
+
return queryAll(":appHost", {});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function allFirstHost(targetOrOptions, propertyKey) {
|
|
163
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
164
|
+
return queryAll(":firstHost", {})(targetOrOptions, propertyKey);
|
|
165
|
+
}
|
|
166
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
167
|
+
return queryAll(":firstHost", targetOrOptions);
|
|
168
|
+
} else {
|
|
169
|
+
return queryAll(":firstHost", {});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function allLastHost(targetOrOptions, propertyKey) {
|
|
173
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
174
|
+
return queryAll(":lastHost", {})(targetOrOptions, propertyKey);
|
|
175
|
+
}
|
|
176
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
177
|
+
return queryAll(":lastHost", targetOrOptions);
|
|
178
|
+
} else {
|
|
179
|
+
return queryAll(":lastHost", {});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function allFirstAppHost(targetOrOptions, propertyKey) {
|
|
183
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
184
|
+
return queryAll(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
185
|
+
}
|
|
186
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
187
|
+
return queryAll(":firstAppHost", targetOrOptions);
|
|
188
|
+
} else {
|
|
189
|
+
return queryAll(":firstAppHost", {});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function allLastAppHost(targetOrOptions, propertyKey) {
|
|
193
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
194
|
+
return queryAll(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
195
|
+
}
|
|
196
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
197
|
+
return queryAll(":lastAppHost", targetOrOptions);
|
|
198
|
+
} else {
|
|
199
|
+
return queryAll(":lastAppHost", {});
|
|
200
|
+
}
|
|
126
201
|
}
|
|
127
202
|
//# sourceMappingURL=queryAll.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/queryAll.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');\n\nexport function queryAll(target: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.root || 'auto';\n const applyRoot = (t: any): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === ':hosts') return applyRoot(hostSet.$hosts);\n if (selector === ':appHosts') return applyRoot(hostSet.$appHosts);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === ':window') return [win];\n if (selector === ':document') return [win.document];\n if (selector === ':host') return applyRoot(this);\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n if (r === 'light') return Array.from(this.querySelectorAll(selector));\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n const root = this.shadowRoot || this;\n return Array.from(root.querySelectorAll(selector));\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const selector = selectorOrTarget;\n if (selector.startsWith(':') && selector !== ':host') return;\n\n const r = options.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n\n/**\n * @hostQueryAll decorator - simplified version of @queryAll for :host selector\n * Usage: @hostQueryAll()\n * Usage: @hostQueryAll({ root: 'shadow' })\n */\nexport function queryAllHost(options?: SwcQueryOptions): PropertyDecorator {\n return queryAll(':host', options);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { getElementConfig, ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SpecialSelector, SwcQueryOptions } from '../types';\n\nexport interface QueryAllMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');\n\nexport function queryAll(target: SpecialSelector): PropertyDecorator;\nexport function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n */\nexport function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n Object.defineProperty(targetObj, propertyKey, {\n get(this: HTMLElement) {\n ensureInit(this);\n const selector = selectorOrTarget;\n\n const r = options.root || 'auto';\n const applyRoot = (t: any): any[] => {\n if (!t) return [];\n const items = Array.isArray(t) ? t : [t];\n const results: any[] = [];\n items.forEach(it => {\n if (!(it instanceof HTMLElement)) {\n results.push(it);\n return;\n }\n if (r === 'auto') results.push(it.shadowRoot || it);\n else {\n if (r === 'light' || r === 'all') results.push(it);\n if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);\n }\n });\n return results;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === ':hosts') return applyRoot(hostSet.$hosts);\n if (selector === ':appHosts') return applyRoot(hostSet.$appHosts);\n\n // --- Special Selectors: Env ---\n const config = getElementConfig(this);\n const win = config?.window || window;\n if (selector === ':window') return [win];\n if (selector === ':document') return [win.document];\n if (selector === ':host') return applyRoot(this);\n\n // --- Standard Selectors ---\n if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n if (r === 'light') return Array.from(this.querySelectorAll(selector));\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n const root = this.shadowRoot || this;\n return Array.from(root.querySelectorAll(selector));\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {\n const selector = selectorOrTarget;\n if (selector.startsWith(':') && selector !== ':host') return;\n\n const r = options.root || 'auto';\n let targets: (Element | Node)[] = [];\n if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n else if (r === 'light') targets = Array.from(this.querySelectorAll(selector));\n else if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n targets = [...sNodes, ...lNodes];\n } else {\n targets = Array.from((this.shadowRoot || this).querySelectorAll(selector));\n }\n targets.forEach(t => (t as Element).remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n\n/**\n * @hostQueryAll decorator - simplified version of @queryAll for :host selector\n * Usage: @hostQueryAll()\n * Usage: @hostQueryAll({ root: 'shadow' })\n */\n/**\n * @queryAllHost decorator - simplified version of @queryAll for :host selector\n * Usage: @queryAllHost items: HTMLElement[];\n * Usage: @queryAllHost() items: HTMLElement[];\n * Usage: @queryAllHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport function queryAllHost(target: Object, propertyKey: string | symbol): void;\nexport function queryAllHost(): PropertyDecorator;\nexport function queryAllHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryAllHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryAllHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryAllHost() or @queryAllHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':host', {});\n }\n}\n\n/**\n * @allHost - Alias for @queryAllHost decorator\n * Usage: @allHost items: HTMLElement[];\n * Usage: @allHost() items: HTMLElement[];\n * Usage: @allHost({ root: 'shadow' }) items: HTMLElement[];\n */\nexport const allHost = queryAllHost;\n/**\n * @allParentHost - Query all :parentHost (All parent SWC components)\n * Usage: @allParentHost parents: HTMLElement[];\n * Usage: @allParentHost() parents: HTMLElement[];\n * Usage: @allParentHost({ root: 'shadow' }) parents: HTMLElement[];\n */\nexport function allParentHost(target: Object, propertyKey: string | symbol): void;\nexport function allParentHost(): PropertyDecorator;\nexport function allParentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allParentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':parentHost', {});\n }\n}\n\n/**\n * @allAppHost - Query all :appHost (All <swc-app> instances)\n * Usage: @allAppHost apps: SwcAppInterface[];\n * Usage: @allAppHost() apps: SwcAppInterface[];\n * Usage: @allAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allAppHost(): PropertyDecorator;\nexport function allAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':appHost', {});\n }\n}\n\n/**\n * @allFirstHost - Query all :firstHost (All first components in hierarchy)\n * Usage: @allFirstHost firsts: HTMLElement[];\n * Usage: @allFirstHost() firsts: HTMLElement[];\n * Usage: @allFirstHost({ root: 'shadow' }) firsts: HTMLElement[];\n */\nexport function allFirstHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstHost(): PropertyDecorator;\nexport function allFirstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstHost', {});\n }\n}\n\n/**\n * @allLastHost - Query all :lastHost (All last components in hierarchy)\n * Usage: @allLastHost lasts: HTMLElement[];\n * Usage: @allLastHost() lasts: HTMLElement[];\n * Usage: @allLastHost({ root: 'shadow' }) lasts: HTMLElement[];\n */\nexport function allLastHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastHost(): PropertyDecorator;\nexport function allLastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastHost', {});\n }\n}\n\n/**\n * @allFirstAppHost - Query all :firstAppHost (All first <swc-app> in hierarchy)\n * Usage: @allFirstAppHost apps: SwcAppInterface[];\n * Usage: @allFirstAppHost() apps: SwcAppInterface[];\n * Usage: @allFirstAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allFirstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allFirstAppHost(): PropertyDecorator;\nexport function allFirstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allFirstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':firstAppHost', {});\n }\n}\n\n/**\n * @allLastAppHost - Query all :lastAppHost (All last <swc-app> in hierarchy)\n * Usage: @allLastAppHost apps: SwcAppInterface[];\n * Usage: @allLastAppHost() apps: SwcAppInterface[];\n * Usage: @allLastAppHost({ root: 'shadow' }) apps: SwcAppInterface[];\n */\nexport function allLastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function allLastAppHost(): PropertyDecorator;\nexport function allLastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function allLastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return queryAll(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return queryAll(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return queryAll(':lastAppHost', {});\n }\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AASlB,MAAM,yBAAyB,OAAO,gCAAgC;AAOvE,SAAU,SAAS,kBAA0B,UAAe,CAAA,GAAE;AAClE,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;IACnG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,yBAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,+BAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAEjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,6CAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAiB;AAClC,cAAI,CAAC;AAAG,mBAAO,CAAA;AACf,gBAAM,QAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACvC,gBAAM,UAAiB,CAAA;AACvB,gBAAM,Q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ACrG,WAAO,SAAS,iBAAiB,CAAA,CAAE,EAAE,iBAAiB,WAAW;EACnE;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,SAAS,iBAAiB,eAAkC;EACrE,OAAO;AACL,WAAO,SAAS,iBAAiB,CAAA,CAAE;EACrC;AACF;AAWM,SAAU,eAAe,iBAAuB,aAA6B;AACjF,MAAI,gBAAgB,WAAc,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACrG,WAAO,SAAS,gBAAgB,CAAA,CAAE,EAAE,iBAAiB,WAAW;EAClE;AACA,MAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,WAAO,SAAS,gBAAgB,eAAkC;EACpE,OAAO;AACL,WAAO,SAAS,gBAAgB,CAAA,CAAE;EACpC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -50,11 +50,11 @@ function setAttribute(selector, name, options = {}) {
|
|
|
50
50
|
const applyRoot = (t) => {
|
|
51
51
|
if (!t) return;
|
|
52
52
|
if (r === "auto") {
|
|
53
|
-
targetEls.push(t
|
|
54
|
-
|
|
53
|
+
targetEls.push(t);
|
|
54
|
+
} else {
|
|
55
|
+
if (r === "light" || r === "all") targetEls.push(t);
|
|
56
|
+
if ((r === "shadow" || r === "all") && t.shadowRoot) targetEls.push(t.shadowRoot);
|
|
55
57
|
}
|
|
56
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
57
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) targetEls.push(t.shadowRoot);
|
|
58
58
|
};
|
|
59
59
|
if (selector === ":window") targetEls.push(currentWin);
|
|
60
60
|
else if (selector === ":document") targetEls.push(currentWin.document);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/setAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface SetAttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n name: string;\n options: SwcQueryOptions;\n}\n\nexport const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');\n\n/**\n * @setAttribute decorator to surgically update an attribute of a target element.\n * Usage: @setAttribute(':host', 'count')\n * Usage: @setAttribute('#child', 'disabled')\n */\nexport function setAttribute(selector: string, name: string): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options: SwcQueryOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, SetAttributeMetadata>();\n ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, name, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const targetEls: any[] = [];\n const r = options.root || 'auto';\n\n const applyRoot = (t: any) => {\n if (!t) return;\n if (r === 'auto') {\n targetEls.push(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AAUlB,MAAM,6BAA6B,OAAO,oCAAoC;AAS9E,SAAS,aAAa,UAAkB,MAAc,UAA2B,CAAC,GAAoB;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,4BAA4B,WAAW;AAClF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA2C;AAC1D,+BAAa,eAAe,4BAA4B,UAAU,WAAW;AAAA,IAC/E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,MAAM,QAAQ,CAAC;AAElE,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,UAAU,sBAAS,WAAW,IAAW;AAC/C,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AAEtG,cAAM,YAAmB,CAAC;AAC1B,cAAM,IAAI,QAAQ,QAAQ;AAE1B,cAAM,YAAY,CAAC,MAAW;AAC5B,cAAI,CAAC,EAAG;AACR,cAAI,MAAM,QAAQ;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface SetAttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n name: string;\n options: SwcQueryOptions;\n}\n\nexport const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');\n\n/**\n * @setAttribute decorator to surgically update an attribute of a target element.\n * Usage: @setAttribute(':host', 'count')\n * Usage: @setAttribute('#child', 'disabled')\n */\nexport function setAttribute(selector: string, name: string): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;\nexport function setAttribute(selector: string, name: string, options: SwcQueryOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, SetAttributeMetadata>();\n ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, name, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n\n const targetEls: any[] = [];\n const r = options.root || 'auto';\n\n const applyRoot = (t: any) => {\n if (!t) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n targetEls.push(t);\n } else {\n if (r === 'light' || r === 'all') targetEls.push(t);\n if ((r === 'shadow' || r === 'all') && (t as any).shadowRoot) targetEls.push((t as any).shadowRoot);\n }\n };\n\n if (selector === ':window') targetEls.push(currentWin);\n else if (selector === ':document') targetEls.push(currentWin.document as any);\n else if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(this);\n else {\n const roots: any[] = [];\n if (r === 'shadow') {\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else if (r === 'light') {\n roots.push(this as any);\n } else if (r === 'all') {\n roots.push(this as any);\n if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);\n } else {\n roots.push((this as any).shadowRoot || (this as any));\n }\n roots.forEach(root => targetEls.push(...root.querySelectorAll(selector)));\n }\n\n targetEls.forEach(targetEl => {\n if (!targetEl || typeof (targetEl as any).setAttribute !== 'function') return;\n if (res === null) (targetEl as any).removeAttribute(name);\n else (targetEl as any).setAttribute(name, String(res));\n });\n }\n return res;\n };\n };\n}\n\nexport const getSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);\n};\n\nexport const findAllSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> => {\n const result = new Map<string | symbol, SetAttributeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, SetAttributeMetadata>>(SET_ATTRIBUTE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\n/**\n * @setAttributeHost decorator - simplified version of @setAttribute for :host selector\n * Usage: @setAttributeHost('aria-disabled')\n */\nexport function setAttributeHost(name: string, options?: SwcQueryOptions): MethodDecorator {\n return setAttribute(':host', name, options);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AAUlB,MAAM,6BAA6B,OAAO,oCAAoC;AAS9E,SAAS,aAAa,UAAkB,MAAc,UAA2B,CAAC,GAAoB;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,4BAA4B,WAAW;AAClF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAA2C;AAC1D,+BAAa,eAAe,4BAA4B,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
|
|
|
20
20
|
STYLE_METADATA_KEY: () => STYLE_METADATA_KEY,
|
|
21
21
|
findAllStyleMetadata: () => findAllStyleMetadata,
|
|
22
22
|
removeStyle: () => removeStyle,
|
|
23
|
+
removeStyleHost: () => removeStyleHost,
|
|
23
24
|
setStyle: () => setStyle,
|
|
24
|
-
|
|
25
|
+
setStyleHost: () => setStyleHost,
|
|
26
|
+
updateStyle: () => updateStyle,
|
|
27
|
+
updateStyleHost: () => updateStyleHost
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(style_exports);
|
|
27
30
|
var import_core = require("@dooboostore/core");
|
|
@@ -29,7 +32,7 @@ var import_elementDefine = require("./elementDefine");
|
|
|
29
32
|
var import_Utils = require("../utils/Utils");
|
|
30
33
|
const STYLE_METADATA_KEY = Symbol("simple-web-component:style");
|
|
31
34
|
function createStyleDecorator(action) {
|
|
32
|
-
return (selector) => {
|
|
35
|
+
return (selector, options = {}) => {
|
|
33
36
|
return (target, propertyKey, descriptor) => {
|
|
34
37
|
const constructor = target.constructor;
|
|
35
38
|
let metaList = import_core.ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor);
|
|
@@ -37,19 +40,52 @@ function createStyleDecorator(action) {
|
|
|
37
40
|
metaList = /* @__PURE__ */ new Map();
|
|
38
41
|
import_core.ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
|
|
39
42
|
}
|
|
40
|
-
metaList.set(propertyKey, { propertyKey, selector, action });
|
|
43
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options });
|
|
41
44
|
const original = descriptor.value;
|
|
42
45
|
descriptor.value = async function(...args) {
|
|
43
46
|
(0, import_elementDefine.ensureInit)(this);
|
|
44
47
|
const res = await original.apply(this, args);
|
|
45
48
|
if (res !== void 0) {
|
|
49
|
+
const r = options.root || "auto";
|
|
46
50
|
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const targetEls = [];
|
|
52
|
+
const applyRoot = (t) => {
|
|
53
|
+
if (!t || !(t instanceof HTMLElement)) return;
|
|
54
|
+
if (r === "auto") {
|
|
55
|
+
targetEls.push(t);
|
|
56
|
+
} else {
|
|
57
|
+
if (r === "light" || r === "all") targetEls.push(t);
|
|
58
|
+
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
63
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
64
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
65
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
66
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
67
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
68
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
69
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
70
|
+
else if (selector === ":host" || !selector) applyRoot(this);
|
|
71
|
+
else {
|
|
72
|
+
if (r === "shadow") {
|
|
73
|
+
const found = this.shadowRoot?.querySelectorAll(selector);
|
|
74
|
+
if (found) targetEls.push(...Array.from(found));
|
|
75
|
+
} else if (r === "light") {
|
|
76
|
+
const found = this.querySelectorAll(selector);
|
|
77
|
+
if (found) targetEls.push(...Array.from(found));
|
|
78
|
+
} else if (r === "all") {
|
|
79
|
+
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
80
|
+
const lFound = this.querySelectorAll(selector);
|
|
81
|
+
if (sFound) targetEls.push(...Array.from(sFound));
|
|
82
|
+
if (lFound) targetEls.push(...Array.from(lFound));
|
|
83
|
+
} else {
|
|
84
|
+
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
85
|
+
if (found) targetEls.push(...Array.from(found));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
targetEls.forEach((targetEl) => {
|
|
53
89
|
if (action === "set") {
|
|
54
90
|
targetEl.style.cssText = "";
|
|
55
91
|
if (typeof res === "object" && res !== null) {
|
|
@@ -65,16 +101,37 @@ function createStyleDecorator(action) {
|
|
|
65
101
|
const props = Array.isArray(res) ? res : [res];
|
|
66
102
|
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
67
103
|
}
|
|
68
|
-
}
|
|
104
|
+
});
|
|
69
105
|
}
|
|
70
106
|
return res;
|
|
71
107
|
};
|
|
72
108
|
};
|
|
73
109
|
};
|
|
74
110
|
}
|
|
75
|
-
const setStyle = createStyleDecorator("set");
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
const setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
|
|
112
|
+
function setStyleHost(targetOrOptions, propertyKey, descriptor) {
|
|
113
|
+
if (propertyKey !== void 0) {
|
|
114
|
+
const decorator = createStyleDecorator("set")(":host", {});
|
|
115
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
116
|
+
}
|
|
117
|
+
return createStyleDecorator("set")(":host", targetOrOptions || {});
|
|
118
|
+
}
|
|
119
|
+
const updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
|
|
120
|
+
function updateStyleHost(targetOrOptions, propertyKey, descriptor) {
|
|
121
|
+
if (propertyKey !== void 0) {
|
|
122
|
+
const decorator = createStyleDecorator("update")(":host", {});
|
|
123
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
124
|
+
}
|
|
125
|
+
return createStyleDecorator("update")(":host", targetOrOptions || {});
|
|
126
|
+
}
|
|
127
|
+
const removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
|
|
128
|
+
function removeStyleHost(targetOrOptions, propertyKey, descriptor) {
|
|
129
|
+
if (propertyKey !== void 0) {
|
|
130
|
+
const decorator = createStyleDecorator("remove")(":host", {});
|
|
131
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
132
|
+
}
|
|
133
|
+
return createStyleDecorator("remove")(":host", targetOrOptions || {});
|
|
134
|
+
}
|
|
78
135
|
const findAllStyleMetadata = (target) => {
|
|
79
136
|
const result = /* @__PURE__ */ new Map();
|
|
80
137
|
const maps = import_core.ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/style.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const hostSet = SwcUtils.getHostSet(this as any);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport type StyleAction = 'set' | 'update' | 'remove';\n\nexport interface StyleOptions extends SwcQueryOptions {}\n\nexport interface StyleMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: StyleAction;\n options: StyleOptions;\n}\n\nexport const STYLE_METADATA_KEY = Symbol('simple-web-component:style');\n\nfunction createStyleDecorator(action: StyleAction) {\n return (selector: string, options: StyleOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, StyleMetadata>();\n ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const r = options.root || 'auto';\n const hostSet = SwcUtils.getHostSet(this as any);\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return;\n if (r === 'auto') {\n // Styles belong to the ELEMENT, not the ShadowRoot.\n targetEls.push(t);\n } else {\n if (r === 'light' || r === 'all') targetEls.push(t);\n if ((r === 'shadow' || r === 'all') && t.shadowRoot) {\n // ShadowRoot doesn't have a style property, so we skip it.\n }\n }\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(this);\n else {\n if (r === 'shadow') {\n const found = this.shadowRoot?.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n } else if (r === 'light') {\n const found = (this as any).querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n } else if (r === 'all') {\n const sFound = this.shadowRoot?.querySelectorAll(selector);\n const lFound = (this as any).querySelectorAll(selector);\n if (sFound) targetEls.push(...(Array.from(sFound) as HTMLElement[]));\n if (lFound) targetEls.push(...(Array.from(lFound) as HTMLElement[]));\n } else {\n // auto\n const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n if (action === 'set') {\n targetEl.style.cssText = '';\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n } else if (typeof res === 'string') {\n targetEl.style.cssText = res;\n }\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null) {\n Object.assign(targetEl.style, res);\n }\n } else if (action === 'remove') {\n const props = Array.isArray(res) ? res : [res];\n props.forEach(p => targetEl.style.removeProperty(String(p)));\n }\n });\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setStyle decorator to surgically set styles on a target element (replaces all existing styles).\n * Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }\n * Usage: @setStyle('#box', { root: 'shadow' }) getStyles() { return { color: 'red' }; }\n */\nexport const setStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('set')(selector, options);\n\n/**\n * @setStyleHost decorator - simplified version of @setStyle for :host selector.\n * Usage: @setStyleHost setHostStyle() { return { color: 'red' }; }\n * Usage: @setStyleHost() setHostStyle() { return { color: 'red' }; }\n * Usage: @setStyleHost({ ... }) setHostStyle() { return { color: 'red' }; }\n */\nexport function setStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function setStyleHost(): MethodDecorator;\nexport function setStyleHost(options: StyleOptions): MethodDecorator;\nexport function setStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('set')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('set')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\n/**\n * @updateStyle decorator to surgically update styles on a target element (merges with existing styles).\n * Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyle('#box', { root: 'shadow' }) updateStyles() { return { color: 'blue' }; }\n */\nexport const updateStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('update')(selector, options);\n\n/**\n * @updateStyleHost decorator - simplified version of @updateStyle for :host selector.\n * Usage: @updateStyleHost updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyleHost() updateStyles() { return { color: 'blue' }; }\n * Usage: @updateStyleHost({ ... }) updateStyles() { return { color: 'blue' }; }\n */\nexport function updateStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function updateStyleHost(): MethodDecorator;\nexport function updateStyleHost(options: StyleOptions): MethodDecorator;\nexport function updateStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('update')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('update')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\n/**\n * @removeStyle decorator to surgically remove styles from a target element.\n * Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }\n * Usage: @removeStyle('#box', { root: 'shadow' }) clearStyles() { return ['color']; }\n */\nexport const removeStyle = (selector: string, options: StyleOptions = {}) => createStyleDecorator('remove')(selector, options);\n\n/**\n * @removeStyleHost decorator - simplified version of @removeStyle for :host selector.\n * Usage: @removeStyleHost clearStyles() { return ['color']; }\n * Usage: @removeStyleHost() clearStyles() { return ['color']; }\n * Usage: @removeStyleHost({ ... }) clearStyles() { return ['color']; }\n */\nexport function removeStyleHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function removeStyleHost(): MethodDecorator;\nexport function removeStyleHost(options: StyleOptions): MethodDecorator;\nexport function removeStyleHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createStyleDecorator('remove')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createStyleDecorator('remove')(':host', (targetOrOptions as StyleOptions) || {});\n}\n\nexport const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {\n const result = new Map<string | symbol, StyleMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleMetadata>>(STYLE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAclB,MAAM,qBAAqB,OAAO,4BAA4B;AAErE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,UAAwB,CAAC,MAAuB;AACxE,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,oBAAoB,WAAW;AAC1E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAoC;AACnD,iCAAa,eAAe,oBAAoB,UAAU,WAAW;AAAA,MACvE;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAA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AqB,KAAK,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACrF;AAOO,MAAM,cAAc,CAAC,UAAkB,UAAwB,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAWtH,SAAS,gBAAgB,iBAAuB,aAA+B,YAAsC;AAC1H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,qBAAqB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5D,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,qBAAqB,QAAQ,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACxF;AAOO,MAAM,cAAc,CAAC,UAAkB,UAAwB,CAAC,MAAM,qBAAqB,QAAQ,EAAE,UAAU,OAAO;AAWtH,SAAS,gBAAgB,iBAAuB,aAA+B,YAAsC;AAC1H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,qBAAqB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5D,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,qBAAqB,QAAQ,EAAE,SAAU,mBAAoC,CAAC,CAAC;AACxF;AAEO,MAAM,uBAAuB,CAAC,WAAqD;AACxF,QAAM,SAAS,oBAAI,IAAoC;AACvD,QAAM,OAAO,yBAAa,gBAAqD,oBAAoB,MAAM;AACzG,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -26,14 +26,14 @@ var import_register = require("./elements/register");
|
|
|
26
26
|
__reExport(src_exports, require("./decorators"), module.exports);
|
|
27
27
|
__reExport(src_exports, require("./types"), module.exports);
|
|
28
28
|
__reExport(src_exports, require("./utils/Utils"), module.exports);
|
|
29
|
-
__reExport(src_exports, require("./utils/TemplateUtils"), module.exports);
|
|
30
29
|
__reExport(src_exports, require("./config/config"), module.exports);
|
|
31
30
|
var src_default = (w, other) => {
|
|
32
31
|
(0, import_register.registerAllElements)(w);
|
|
33
32
|
const r = other?.map((fn) => {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (typeof fn === "function") {
|
|
34
|
+
const a = fn(w);
|
|
35
|
+
} else {
|
|
36
|
+
}
|
|
36
37
|
});
|
|
37
|
-
return r ?? [];
|
|
38
38
|
};
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import 'reflect-metadata';\nimport { registerAllElements } from './elements/register';\nimport {ConstructorType} from \"@dooboostore/core\";\n\n// Decorators\nexport * from './decorators';\n\n// Types\nexport * from './types';\n\n// Utilities\nexport * from './utils/Utils';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAO;AACP,sBAAoC;AAIpC,wBAAc,yBALd;AAQA,wBAAc,oBARd;AAWA,wBAAc,0BAXd;
|
|
4
|
+
"sourcesContent": ["import 'reflect-metadata';\nimport { registerAllElements } from './elements/register';\nimport {ConstructorType} from \"@dooboostore/core\";\n\n// Decorators\nexport * from './decorators';\n\n// Types\nexport * from './types';\n\n// Utilities\nexport * from './utils/Utils';\n\n// Config\nexport * from './config/config';\n\n// Registration Factory\nexport default (w: Window, other?: (((w: Window) => ConstructorType<any>) | any) []) => {\n registerAllElements(w);\n const r = other?.map(fn => {\n if (typeof fn === 'function') {\n const a = fn(w);\n } else {\n }\n });\n // return r??[];\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAO;AACP,sBAAoC;AAIpC,wBAAc,yBALd;AAQA,wBAAc,oBARd;AAWA,wBAAc,0BAXd;AAcA,wBAAc,4BAdd;AAiBA,IAAO,cAAQ,CAAC,GAAW,UAA6D;AACtF,2CAAoB,CAAC;AACrB,QAAM,IAAI,OAAO,IAAI,QAAM;AACzB,QAAI,OAAO,OAAO,YAAY;AAC5B,YAAM,IAAI,GAAG,CAAC;AAAA,IAChB,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AAEH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/utils/Utils.js
CHANGED
|
@@ -18,11 +18,150 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var Utils_exports = {};
|
|
19
19
|
__export(Utils_exports, {
|
|
20
20
|
SWC_NOT_FOUND: () => SWC_NOT_FOUND,
|
|
21
|
-
SwcUtils: () => SwcUtils
|
|
21
|
+
SwcUtils: () => SwcUtils,
|
|
22
|
+
commentNode: () => commentNode,
|
|
23
|
+
createElement: () => createElement,
|
|
24
|
+
htmlAElement: () => htmlAElement,
|
|
25
|
+
htmlArticleElement: () => htmlArticleElement,
|
|
26
|
+
htmlButtonElement: () => htmlButtonElement,
|
|
27
|
+
htmlDivElement: () => htmlDivElement,
|
|
28
|
+
htmlFragment: () => htmlFragment,
|
|
29
|
+
htmlHeadingElement: () => htmlHeadingElement,
|
|
30
|
+
htmlLiElement: () => htmlLiElement,
|
|
31
|
+
htmlPElement: () => htmlPElement,
|
|
32
|
+
htmlSectionElement: () => htmlSectionElement,
|
|
33
|
+
htmlSpanElement: () => htmlSpanElement,
|
|
34
|
+
htmlUlElement: () => htmlUlElement,
|
|
35
|
+
textNode: () => textNode
|
|
22
36
|
});
|
|
23
37
|
module.exports = __toCommonJS(Utils_exports);
|
|
24
38
|
var import_decorators = require("../decorators");
|
|
25
39
|
const SWC_NOT_FOUND = Symbol("SWC_NOT_FOUND");
|
|
40
|
+
const htmlFragment = (html, doc) => {
|
|
41
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
42
|
+
if (!d) throw new Error("Document is not available");
|
|
43
|
+
const template = d.createElement("template");
|
|
44
|
+
template.innerHTML = html.trim();
|
|
45
|
+
return template.content;
|
|
46
|
+
};
|
|
47
|
+
const textNode = (text, doc) => {
|
|
48
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
49
|
+
if (!d) throw new Error("Document is not available");
|
|
50
|
+
return d.createTextNode(text !== void 0 && text !== null ? String(text) : "");
|
|
51
|
+
};
|
|
52
|
+
const commentNode = (comment, doc) => {
|
|
53
|
+
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
54
|
+
if (!d) throw new Error("Document is not available");
|
|
55
|
+
return d.createComment(comment !== void 0 && comment !== null ? String(comment) : "");
|
|
56
|
+
};
|
|
57
|
+
const createElement = (tagName, options) => {
|
|
58
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
59
|
+
if (!d) throw new Error("Document is not available");
|
|
60
|
+
const el = d.createElement(tagName);
|
|
61
|
+
if (options?.html) el.innerHTML = options.html;
|
|
62
|
+
if (options?.attrs) {
|
|
63
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
64
|
+
}
|
|
65
|
+
return el;
|
|
66
|
+
};
|
|
67
|
+
const htmlDivElement = (html, options) => {
|
|
68
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
69
|
+
if (!d) throw new Error("Document is not available");
|
|
70
|
+
const el = d.createElement("div");
|
|
71
|
+
el.innerHTML = html.trim();
|
|
72
|
+
if (options?.attrs) {
|
|
73
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
74
|
+
}
|
|
75
|
+
return el;
|
|
76
|
+
};
|
|
77
|
+
const htmlSpanElement = (html, options) => {
|
|
78
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
79
|
+
if (!d) throw new Error("Document is not available");
|
|
80
|
+
const el = d.createElement("span");
|
|
81
|
+
el.innerHTML = html.trim();
|
|
82
|
+
if (options?.attrs) {
|
|
83
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
84
|
+
}
|
|
85
|
+
return el;
|
|
86
|
+
};
|
|
87
|
+
const htmlButtonElement = (html, options) => {
|
|
88
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
89
|
+
if (!d) throw new Error("Document is not available");
|
|
90
|
+
const el = d.createElement("button");
|
|
91
|
+
el.innerHTML = html.trim();
|
|
92
|
+
if (options?.attrs) {
|
|
93
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
94
|
+
}
|
|
95
|
+
return el;
|
|
96
|
+
};
|
|
97
|
+
const htmlUlElement = (options) => {
|
|
98
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
99
|
+
if (!d) throw new Error("Document is not available");
|
|
100
|
+
const el = d.createElement("ul");
|
|
101
|
+
if (options?.attrs) {
|
|
102
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
103
|
+
}
|
|
104
|
+
return el;
|
|
105
|
+
};
|
|
106
|
+
const htmlLiElement = (html, options) => {
|
|
107
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
108
|
+
if (!d) throw new Error("Document is not available");
|
|
109
|
+
const el = d.createElement("li");
|
|
110
|
+
el.innerHTML = html.trim();
|
|
111
|
+
if (options?.attrs) {
|
|
112
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
113
|
+
}
|
|
114
|
+
return el;
|
|
115
|
+
};
|
|
116
|
+
const htmlAElement = (html, options) => {
|
|
117
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
118
|
+
if (!d) throw new Error("Document is not available");
|
|
119
|
+
const el = d.createElement("a");
|
|
120
|
+
el.innerHTML = html.trim();
|
|
121
|
+
if (options?.href) el.href = options.href;
|
|
122
|
+
if (options?.attrs) {
|
|
123
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
124
|
+
}
|
|
125
|
+
return el;
|
|
126
|
+
};
|
|
127
|
+
const htmlPElement = (html, options) => {
|
|
128
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
129
|
+
if (!d) throw new Error("Document is not available");
|
|
130
|
+
const el = d.createElement("p");
|
|
131
|
+
el.innerHTML = html.trim();
|
|
132
|
+
if (options?.attrs) {
|
|
133
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
134
|
+
}
|
|
135
|
+
return el;
|
|
136
|
+
};
|
|
137
|
+
const htmlHeadingElement = (level, html, options) => {
|
|
138
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
139
|
+
if (!d) throw new Error("Document is not available");
|
|
140
|
+
const el = d.createElement(`h${level}`);
|
|
141
|
+
el.innerHTML = html.trim();
|
|
142
|
+
if (options?.attrs) {
|
|
143
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
144
|
+
}
|
|
145
|
+
return el;
|
|
146
|
+
};
|
|
147
|
+
const htmlSectionElement = (options) => {
|
|
148
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
149
|
+
if (!d) throw new Error("Document is not available");
|
|
150
|
+
const el = d.createElement("section");
|
|
151
|
+
if (options?.attrs) {
|
|
152
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
153
|
+
}
|
|
154
|
+
return el;
|
|
155
|
+
};
|
|
156
|
+
const htmlArticleElement = (options) => {
|
|
157
|
+
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
158
|
+
if (!d) throw new Error("Document is not available");
|
|
159
|
+
const el = d.createElement("article");
|
|
160
|
+
if (options?.attrs) {
|
|
161
|
+
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
162
|
+
}
|
|
163
|
+
return el;
|
|
164
|
+
};
|
|
26
165
|
var SwcUtils;
|
|
27
166
|
((SwcUtils2) => {
|
|
28
167
|
SwcUtils2.getHelperSet = (win) => {
|