@dooboostore/simple-web-component 1.0.23 → 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 +238 -44
- package/dist/cjs/decorators/applyNode.js +129 -34
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +21 -2
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/classList.js +60 -17
- package/dist/cjs/decorators/classList.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 +46 -15
- 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 +129 -34
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/attribute.js +21 -2
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/classList.js +60 -17
- package/dist/esm/decorators/classList.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 +46 -15
- 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 +542 -155
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/applyNode.d.ts +49 -27
- 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 +15 -5
- package/dist/types/decorators/classList.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +68 -4
- 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 +17 -8
- 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 +542 -155
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/applyNode.ts +179 -60
- package/src/decorators/attribute.ts +43 -10
- package/src/decorators/changedAttributeHost.ts +1 -1
- package/src/decorators/classList.ts +79 -17
- package/src/decorators/query.ts +147 -5
- package/src/decorators/queryAll.ts +148 -2
- package/src/decorators/setAttribute.ts +6 -5
- package/src/decorators/style.ts +67 -22
- package/src/index.ts +6 -6
- package/src/utils/Utils.ts +144 -0
- package/dist/cjs/utils/TemplateUtils.js +0 -109
- package/dist/cjs/utils/TemplateUtils.js.map +0 -7
- package/dist/esm/utils/TemplateUtils.js +0 -90
- package/dist/esm/utils/TemplateUtils.js.map +0 -7
- package/dist/types/utils/TemplateUtils.d.ts +0 -59
- package/dist/types/utils/TemplateUtils.d.ts.map +0 -1
- package/src/utils/TemplateUtils.ts +0 -92
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/applyNode.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcRootType } from '../types';\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n\n const getTargetRoot = () => {\n if (r === 'shadow') return this.shadowRoot;\n if (r === 'light') return this as any;\n if (r === 'all') return this.shadowRoot || (this as any);\n return this.shadowRoot || (this as any); // auto\n };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = getTargetRoot();\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n if (selector === ':host' || !selector) {\n if (r === 'shadow') {\n targetEl = this.shadowRoot; // Target shadow DOM root\n } else {\n targetEl = this as any; // Target the component itself\n }\n } else {\n const targetRoot = getTargetRoot();\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\n/**\n * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return applyNode(':host', options);\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport const applyBeforeBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport const applyAfterBeginNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport const applyBeforeEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport const applyAfterEndNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport const applyReplaceNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport const applyReplaceChildrenNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport const applyInnerHtmlNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport const applyInnerTextNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport const applyRemoveNode = (selector: string, options: ApplyNodeOptions = {}) => \n applyNode(selector, { ...options, position: 'remove' });\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport const applyBeforeBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeBegin' });\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */\nexport const applyAfterBeginNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterBegin' });\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */\nexport const applyBeforeEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'beforeEnd' });\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */\nexport const applyAfterEndNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'afterEnd' });\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */\nexport const applyReplaceNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replace' });\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */\nexport const applyReplaceChildrenNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'replaceChildren' });\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */\nexport const applyInnerHtmlNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerHtml' });\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */\nexport const applyInnerTextNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'innerText' });\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */\nexport const applyRemoveNodeHost = (options: ApplyNodeOptions = {}) => \n applyNode(':host', { ...options, position: 'remove' });\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;kBAA6B;AAC7B,2BAA6C;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcRootType } from '../types';\nimport {SwcUtils} from \"../utils/Utils\";\n\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; // query only returns one, so shadow preferred\n return t;\n };\n\n const hostSet = SwcUtils.getHostSet(this);\n // const getTargetRoot = () => {\n // if (r === 'shadow') return this.shadowRoot;\n // if (r === 'light') return this as any;\n // if (r === 'all') return this.shadowRoot || (this as any);\n // return this.shadowRoot || (this as any); // auto\n // };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = applyRoot(this);\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n\n if (selector === ':host') {\n targetEl = applyRoot(this)\n } else if (selector === ':parentHost') {\n targetEl = applyRoot(hostSet.$parentHost)\n } else if (selector === ':appHost') {\n targetEl = applyRoot(hostSet.$appHost)\n } else if (selector === ':firstHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastHost') {\n targetEl = applyRoot(hostSet.$lastHost)\n } else if (selector === ':firstAppHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastAppHost') {\n targetEl = applyRoot(hostSet.$lastAppHost);\n } else {\n const targetRoot = applyRoot(this);\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\n/**\n * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(): MethodDecorator;\nexport function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @applyNodeHost (no parentheses)\n console.log('vvvvv')\n if (propertyKey !== undefined && typeof propertyKey === 'string' || typeof propertyKey === 'symbol') {\n return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n }\n\n // @applyNodeHost() or @applyNodeHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n const options = targetOrOptions as ApplyNodeOptions;\n return applyNode(':host', { ...options, position: options.position || 'beforeEnd' });\n } else {\n // @applyNodeHost() - use default position\n return applyNode(':host', { position: 'beforeEnd' });\n }\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport function applyBeforeBeginNode(selector: string): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport function applyAfterBeginNode(selector: string): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport function applyBeforeEndNode(selector: string): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport function applyAfterEndNode(selector: string): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport function applyReplaceNode(selector: string): MethodDecorator;\nexport function applyReplaceNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport function applyReplaceChildrenNode(selector: string): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport function applyInnerHtmlNode(selector: string): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport function applyInnerTextNode(selector: string): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport function applyRemoveNode(selector: string): MethodDecorator;\nexport function applyRemoveNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'remove' });\n}\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport function applyBeforeBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function applyBeforeBeginNodeHost(): MethodDecorator;\nexport function applyBeforeBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeBegin' });\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(targetOrOptions as ApplyNodeOptions || {}), position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */export function applyAfterBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterBeginNodeHost(): MethodDecorator;\nexport function applyAfterBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterBegin' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */export function applyBeforeEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyBeforeEndNodeHost(): MethodDecorator;\nexport function applyBeforeEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */export function applyAfterEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterEndNodeHost(): MethodDecorator;\nexport function applyAfterEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */export function applyReplaceNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceNodeHost(): MethodDecorator;\nexport function applyReplaceNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replace' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */export function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceChildrenNodeHost(): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replaceChildren' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */export function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerHtmlNodeHost(): MethodDecorator;\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerHtml' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */export function applyInnerTextNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerTextNodeHost(): MethodDecorator;\nexport function applyInnerTextNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerText' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerText' });\n}\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */export function applyRemoveNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyRemoveNodeHost(): MethodDecorator;\nexport function applyRemoveNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'remove' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'remove' });\n}\n"],
|
|
5
|
+
"mappings": ";;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7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,uBAAuB,iBAA0C,aAA+B,YAA+B;AAC7I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,oBAAoB,iBAA0C,aAA+B,YAA+B;AAC1I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,SAAQ,CAAE;AAC3D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,SAAQ,CAAE;AAClG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -155,7 +155,26 @@ function attribute(selector, options = {}) {
|
|
|
155
155
|
const findAllAttributeMetadata = (target) => {
|
|
156
156
|
return import_core.ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
|
|
157
157
|
};
|
|
158
|
-
function attributeHost(
|
|
159
|
-
|
|
158
|
+
function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
159
|
+
if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
160
|
+
const fieldName = String(propertyKeyOrOptions);
|
|
161
|
+
return attribute(":host", { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
162
|
+
}
|
|
163
|
+
if (typeof targetOrAttrOrOptions === "string") {
|
|
164
|
+
const attrName = targetOrAttrOrOptions;
|
|
165
|
+
const options = typeof propertyKeyOrOptions === "object" ? propertyKeyOrOptions : {};
|
|
166
|
+
return attribute(":host", { ...options, name: attrName });
|
|
167
|
+
} else if (typeof targetOrAttrOrOptions === "object") {
|
|
168
|
+
const options = targetOrAttrOrOptions;
|
|
169
|
+
return (target, propertyKey) => {
|
|
170
|
+
const fieldName = String(propertyKey);
|
|
171
|
+
return attribute(":host", { ...options, name: fieldName })(target, propertyKey);
|
|
172
|
+
};
|
|
173
|
+
} else {
|
|
174
|
+
return (target, propertyKey) => {
|
|
175
|
+
const fieldName = String(propertyKey);
|
|
176
|
+
return attribute(":host", { name: fieldName })(target, propertyKey);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
160
179
|
}
|
|
161
180
|
//# sourceMappingURL=attribute.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/attribute.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\nimport {ensureInit, getElementConfig} from './elementDefine';\nimport {SwcUtils} from '../utils/Utils';\nimport {SpecialSelector, SwcQueryOptions} from '../types';\n\nexport interface AttributeOptions extends SwcQueryOptions {\n name?: string;\n connectedInitialize?: boolean;\n type?: typeof Number | typeof Boolean | typeof String;\n}\n\nexport interface AttributeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AttributeOptions;\n privateKey: symbol; // Added to bypass getter during initialization\n}\n\nexport const ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:attribute');\n\n/**\n * Helper to perform type conversion from string to target type\n */\nconst convertValue = (val: string | null, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * Helper to resolve target elements based on selector and root options\n */\nexport const resolveTargetEls = (inst: any, selector: string, options: AttributeOptions, currentWin: any): HTMLElement[] => {\n const r = options.root || 'auto';\n const results: HTMLElement[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n // Attributes belong to the ELEMENT, not the ShadowRoot.\n // So for :host and direct attribute sync, we mostly want the element itself.\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === ':host' || !selector) {\n applyRoot(inst);\n } else if (selector === ':window') {\n results.push(currentWin);\n } else if (selector === ':document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @attribute decorator to sync a field value with an element's attribute.\n */\nexport function attribute(selector: string, options: AttributeOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const privateKey = Symbol(String(propertyKey));\n\n const designType = (Reflect as any).getMetadata('design:type', target, propertyKey);\n\n let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_METADATA_KEY, constructor) as AttributeMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ATTRIBUTE_METADATA_KEY, metaList, constructor);\n }\n metaList.push({propertyKey, selector, options, privateKey});\n\n // Helper function to apply setAttribute to targets\n const applySetAttribute = (inst: any, targets: HTMLElement[], attrName: string, nv: any) => {\n targets.forEach(it => {\n console.log('----->', it)\n if (it && typeof (it as any).setAttribute === 'function') {\n if (nv === null) {\n (it as any).removeAttribute(attrName);\n } else {\n (it as any).setAttribute(attrName, String(nv));\n }\n } else {\n inst[privateKey] = nv;\n }\n });\n };\n\n Object.defineProperty(target, propertyKey, {\n get(this: any) {\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n const targetType = options.type || designType;\n\n console.log('type-->', propertyKey, targetType);\n // During early init phase, if syncing memory to DOM, return memory.\n if (this.__swc_syncing_init || (options.connectedInitialize && !this.__swc_connected)) {\n return convertValue(this[privateKey], targetType);\n }\n\n const targets = resolveTargetEls(this, selector, options, currentWin);\n const primaryTarget = targets[0];\n\n if (primaryTarget && typeof (primaryTarget as any).hasAttribute === 'function') {\n if ((primaryTarget as any).hasAttribute(attrName)) {\n const domVal = (primaryTarget as any).getAttribute(attrName);\n return convertValue(domVal, targetType);\n }\n return null;\n }\n\n return convertValue(this[privateKey], targetType);\n },\n set(this: any, nv: any) {\n const targetType = options.type || designType;\n // console.log('---set', propertyKey, targetType, nv, this, this.__swc_syncing_init);\n\n const attrName = options.name || String(propertyKey);\n const conf = getElementConfig(this);\n const currentWin = this._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // During initialization/syncing phase\n if (this.__swc_syncing_init) {\n // If connectedInitialize is enabled, force setAttribute (JS -> DOM)\n if (options.connectedInitialize === true) {\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n } else {\n // Otherwise just update memory\n this[privateKey] = nv;\n }\n return;\n }\n\n // Before connected, save to memory only\n if (!this.__swc_connected) {\n this[privateKey] = nv;\n return;\n }\n\n // After connected, normal setAttribute\n const targets = resolveTargetEls(this, selector, options, currentWin);\n applySetAttribute(this, targets, attrName, nv);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const findAllAttributeMetadata = (target: any): AttributeMetadata[] => {\n return ReflectUtils.findAllMetadata<AttributeMetadata[]>(ATTRIBUTE_METADATA_KEY, target).flat();\n};\n\n/**\n * @attributeHost decorator - simplified version of @attribute for :host selector\n * Usage: @attributeHost - uses field name as attribute name\n * Usage: @attributeHost() - uses field name as attribute name\n * Usage: @attributeHost('data-id') - uses custom attribute name\n * Usage: @attributeHost({ type: Boolean }) - uses field name with options\n * Usage: @attributeHost('data-id', { type: Boolean }) - uses custom name with options\n */\nexport function attributeHost(target: Object, propertyKey: string | symbol): void;\nexport function attributeHost(): PropertyDecorator;\nexport function attributeHost(options: AttributeOptions): PropertyDecorator;\nexport function attributeHost(attrName: string): PropertyDecorator;\nexport function attributeHost(attrName: string, options: AttributeOptions): PropertyDecorator;\nexport function attributeHost(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {\n // Direct decorator usage: @attributeHost (no parentheses)\n if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n const fieldName = String(propertyKeyOrOptions);\n return attribute(':host', { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);\n }\n\n // @attributeHost() or @attributeHost(options) or @attributeHost('name')\n if (typeof targetOrAttrOrOptions === 'string') {\n // @attributeHost('customName') or @attributeHost('customName', options)\n const attrName = targetOrAttrOrOptions;\n const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeOptions;\n return attribute(':host', { ...options, name: attrName });\n } else if (typeof targetOrAttrOrOptions === 'object') {\n // @attributeHost(options) - use field name as attribute name\n const options = targetOrAttrOrOptions as AttributeOptions;\n return (target: Object, propertyKey: string | symbol) => {\n const fieldName = String(propertyKey);\n return attribute(':host', { ...options, name: fieldName })(target, propertyKey);\n };\n } else {\n // @attributeHost() - use field name as attribute name\n return (target: Object, propertyKey: string | symbol) => {\n const fieldName = String(propertyKey);\n return attribute(':host', { name: fieldName })(target, propertyKey);\n };\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAC3B,2BAA2C;AAC3C,mBAAuB;AAgBhB,MAAM,yBAAyB,OAAO,gCAAgC;AAK7E,MAAM,eAAe,CAAC,KAAoB,SAAmB;AAC3D,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAKO,MAAM,mBAAmB,CAAC,MAAW,UAAkB,SAA2B,eAAmC;AAC1H,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAyB,CAAC;AAEhC,QAAM,YAAY,CAAC,WAAgB;AACjC,QAAI,CAAC,OAAQ;AACb,QAAI,MAAM,QAAQ;AAGhB,cAAQ,KAAK,MAAM;AAAA,IACrB,OAAO;AACL,UAAI,MAAM,WAAW,MAAM,MAAO,SAAQ,KAAK,MAAM;AACrD,WAAK,MAAM,YAAY,MAAM,UAAU,OAAO,WAAY,SAAQ,KAAK,OAAO,UAAU;AAAA,IAC1F;AAAA,EACF;AAEA,MAAI,aAAa,WAAW,CAAC,UAAU;AACrC,cAAU,IAAI;AAAA,EAChB,WAAW,aAAa,WAAW;AACjC,YAAQ,KAAK,UAAU;AAAA,EACzB,WAAW,aAAa,aAAa;AACnC,YAAQ,KAAK,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AY,OAAO,WAAW;AACpC,aAAO,UAAU,SAAS,EAAE,GAAG,SAAS,MAAM,UAAU,CAAC,EAAE,QAAQ,WAAW;AAAA,IAChF;AAAA,EACF,OAAO;AAEL,WAAO,CAAC,QAAgB,gBAAiC;AACvD,YAAM,YAAY,OAAO,WAAW;AACpC,aAAO,UAAU,SAAS,EAAE,MAAM,UAAU,CAAC,EAAE,QAAQ,WAAW;AAAA,IACpE;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["targets"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/changedAttributeHost.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n */\nexport function changedAttributeHost(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAEpB,MAAM,oCAAoC,OAAO,2CAA2C;AAM5F,SAAS,qBAAqB,eAAyC;AAC5E,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,+BAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,yBAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -53,27 +53,40 @@ function createClassListDecorator(action) {
|
|
|
53
53
|
const r = options.root || "auto";
|
|
54
54
|
const hostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
55
55
|
const targetEls = [];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
const applyRoot = (t) => {
|
|
57
|
+
if (!t || !(t instanceof HTMLElement)) return;
|
|
58
|
+
if (r === "auto") {
|
|
59
|
+
targetEls.push(t);
|
|
60
|
+
} else {
|
|
61
|
+
if (r === "light" || r === "all") targetEls.push(t);
|
|
62
|
+
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
67
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
68
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
69
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
70
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
71
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
72
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
73
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
74
|
+
else if (selector === ":host" || !selector) applyRoot(this);
|
|
75
|
+
else {
|
|
63
76
|
if (r === "shadow") {
|
|
64
77
|
const found = this.shadowRoot?.querySelectorAll(selector);
|
|
65
|
-
if (found) targetEls.push(...found);
|
|
78
|
+
if (found) targetEls.push(...Array.from(found));
|
|
66
79
|
} else if (r === "light") {
|
|
67
80
|
const found = this.querySelectorAll(selector);
|
|
68
|
-
if (found) targetEls.push(...found);
|
|
81
|
+
if (found) targetEls.push(...Array.from(found));
|
|
69
82
|
} else if (r === "all") {
|
|
70
83
|
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
71
84
|
const lFound = this.querySelectorAll(selector);
|
|
72
|
-
if (sFound) targetEls.push(...sFound);
|
|
73
|
-
if (lFound) targetEls.push(...lFound);
|
|
85
|
+
if (sFound) targetEls.push(...Array.from(sFound));
|
|
86
|
+
if (lFound) targetEls.push(...Array.from(lFound));
|
|
74
87
|
} else {
|
|
75
88
|
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
76
|
-
if (found) targetEls.push(...found);
|
|
89
|
+
if (found) targetEls.push(...Array.from(found));
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
targetEls.forEach((targetEl) => {
|
|
@@ -116,11 +129,41 @@ const updateClassList = (selector, options = {}) => createClassListDecorator("up
|
|
|
116
129
|
const addClassList = (selector, options = {}) => createClassListDecorator("add")(selector, options);
|
|
117
130
|
const removeClassList = (selector, options = {}) => createClassListDecorator("remove")(selector, options);
|
|
118
131
|
const toggleClassList = (selector, options = {}) => createClassListDecorator("toggle")(selector, options);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
function setClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
133
|
+
if (propertyKey !== void 0) {
|
|
134
|
+
const decorator = createClassListDecorator("set")(":host", {});
|
|
135
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
136
|
+
}
|
|
137
|
+
return createClassListDecorator("set")(":host", targetOrOptions || {});
|
|
138
|
+
}
|
|
139
|
+
function updateClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
140
|
+
if (propertyKey !== void 0) {
|
|
141
|
+
const decorator = createClassListDecorator("update")(":host", {});
|
|
142
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
143
|
+
}
|
|
144
|
+
return createClassListDecorator("update")(":host", targetOrOptions || {});
|
|
145
|
+
}
|
|
146
|
+
function addClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
147
|
+
if (propertyKey !== void 0) {
|
|
148
|
+
const decorator = createClassListDecorator("add")(":host", {});
|
|
149
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
150
|
+
}
|
|
151
|
+
return createClassListDecorator("add")(":host", targetOrOptions || {});
|
|
152
|
+
}
|
|
153
|
+
function removeClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
154
|
+
if (propertyKey !== void 0) {
|
|
155
|
+
const decorator = createClassListDecorator("remove")(":host", {});
|
|
156
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
157
|
+
}
|
|
158
|
+
return createClassListDecorator("remove")(":host", targetOrOptions || {});
|
|
159
|
+
}
|
|
160
|
+
function toggleClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
161
|
+
if (propertyKey !== void 0) {
|
|
162
|
+
const decorator = createClassListDecorator("toggle")(":host", {});
|
|
163
|
+
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
164
|
+
}
|
|
165
|
+
return createClassListDecorator("toggle")(":host", targetOrOptions || {});
|
|
166
|
+
}
|
|
124
167
|
const findAllClassListMetadata = (target) => {
|
|
125
168
|
const result = /* @__PURE__ */ new Map();
|
|
126
169
|
const maps = import_core.ReflectUtils.findAllMetadata(CLASS_LIST_METADATA_KEY, target);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/classList.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport const CLASS_LIST_METADATA_KEY = Symbol('simple-web-component:class-list');\n\nexport type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';\n\nexport interface ClassListMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: ClassListAction;\n options: SwcQueryOptions;\n}\n\nfunction createClassListDecorator(action: ClassListAction) {\n return (selector: string, options: SwcQueryOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor) as Map<string | symbol, ClassListMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ClassListMetadata>();\n ReflectUtils.defineMetadata(CLASS_LIST_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, { propertyKey, selector, action, options });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\n const r = options.root || 'auto';\n const hostSet = SwcUtils.getHostSet(this as any);\n const targetEls: HTMLElement[] = [];\n\n if (selector === ':host' || !selector) {\n targetEls.push(this as any);\n } else if (selector === ':parentHost') {\n if (hostSet.$parentHost) targetEls.push(hostSet.$parentHost);\n } else if (selector === ':appHost') {\n if (hostSet.$appHost) targetEls.push(hostSet.$appHost);\n } else {\n if (r === 'shadow') {\n const found = this.shadowRoot?.querySelectorAll(selector);\n if (found) targetEls.push(...found);\n } else if (r === 'light') {\n const found = (this as any).querySelectorAll(selector);\n if (found) targetEls.push(...found);\n } else if (r === 'all') {\n const sFound = this.shadowRoot?.querySelectorAll(selector);\n const lFound = (this as any).querySelectorAll(selector);\n if (sFound) targetEls.push(...sFound);\n if (lFound) targetEls.push(...lFound);\n } else {\n // auto\n const found = (this.shadowRoot || (this as any)).querySelectorAll(selector);\n if (found) targetEls.push(...found);\n }\n }\n\n targetEls.forEach(targetEl => {\n if (action === 'set') {\n let classes = '';\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n classes = Object.entries(res)\n .filter(([_, force]) => !!force)\n .map(([cls]) => cls)\n .join(' ');\n } else {\n classes = Array.isArray(res) ? res.join(' ') : String(res);\n }\n targetEl.className = classes;\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n Object.entries(res).forEach(([cls, force]) => {\n targetEl.classList.toggle(cls, !!force);\n });\n } else if (res !== undefined && res !== null) {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n }\n } else if (action === 'add') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n } else if (action === 'remove') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.remove(...classes);\n } else if (action === 'toggle') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n classes.forEach(c => targetEl.classList.toggle(c));\n }\n });\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setClassList decorator to surgically replace all classes on a target element.\n * Returns: string | string[]\n */\nexport const setClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('set')(selector, options);\n\n/**\n * @updateClassList decorator to surgically update specific classes.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport const updateClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('update')(selector, options);\n\n/**\n * @addClassList decorator to surgically add classes to a target element.\n * Returns: string | string[]\n */\nexport const addClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('add')(selector, options);\n\n/**\n * @removeClassList decorator to surgically remove classes from a target element.\n * Returns: string | string[]\n */\nexport const removeClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('remove')(selector, options);\n\n/**\n * @toggleClassList decorator to surgically toggle classes on a target element.\n * Returns: string | string[]\n */\nexport const toggleClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('toggle')(selector, options);\n\n// Host-specific versions (for :host selector)\n\n/**\n * @setClassListHost decorator to set classes on :host element.\n * Returns: string | string[]\n */\nexport const setClassListHost = (options: SwcQueryOptions = {}) => createClassListDecorator('set')(':host', options);\n\n/**\n * @updateClassListHost decorator to update specific classes on :host.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport const updateClassListHost = (options: SwcQueryOptions = {}) => createClassListDecorator('update')(':host', options);\n\n/**\n * @addClassListHost decorator to add classes to :host element.\n * Returns: string | string[]\n */\nexport const addClassListHost = (options: SwcQueryOptions = {}) => createClassListDecorator('add')(':host', options);\n\n/**\n * @removeClassListHost decorator to remove classes from :host element.\n * Returns: string | string[]\n */\nexport const removeClassListHost = (options: SwcQueryOptions = {}) => createClassListDecorator('remove')(':host', options);\n\n/**\n * @toggleClassListHost decorator to toggle classes on :host element.\n * Returns: string | string[]\n */\nexport const toggleClassListHost = (options: SwcQueryOptions = {}) => createClassListDecorator('toggle')(':host', options);\n\nexport const findAllClassListMetadata = (target: any): Map<string | symbol, ClassListMetadata> => {\n const result = new Map<string | symbol, ClassListMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassListMetadata>>(CLASS_LIST_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;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAGlB,MAAM,0BAA0B,OAAO,iCAAiC;AAW/E,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,UAAkB,UAA2B,CAAC,MAAuB;AAC3E,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,yBAAyB,WAAW;AAC/E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAwC;AACvD,iCAAa,eAAe,yBAAyB,UAAU,WAAW;AAAA,MAC5E;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,YAAI,QAAQ,QAAW;AACrB,gBAAM,IAAI,QAAQ,QAAQ;AAC1B,gBAAM,UAAU,sBAAS,WAAW,IAAW;AAC/C,gBAAM,YAA2B,CAAC;AAElC,
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport const CLASS_LIST_METADATA_KEY = Symbol('simple-web-component:class-list');\n\nexport type ClassListAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';\n\nexport interface ClassListMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: ClassListAction;\n options: SwcQueryOptions;\n}\n\nfunction createClassListDecorator(action: ClassListAction) {\n return (selector: string, options: SwcQueryOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(CLASS_LIST_METADATA_KEY, constructor) as Map<string | symbol, ClassListMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ClassListMetadata>();\n ReflectUtils.defineMetadata(CLASS_LIST_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 // Classes 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 // Technically ShadowRoot doesn't have classList, but user might have specified it.\n // We'll skip adding shadowRoot to targetEls for class operations.\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 let classes = '';\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n classes = Object.entries(res)\n .filter(([_, force]) => !!force)\n .map(([cls]) => cls)\n .join(' ');\n } else {\n classes = Array.isArray(res) ? res.join(' ') : String(res);\n }\n targetEl.className = classes;\n } else if (action === 'update') {\n if (typeof res === 'object' && res !== null && !Array.isArray(res)) {\n Object.entries(res).forEach(([cls, force]) => {\n targetEl.classList.toggle(cls, !!force);\n });\n } else if (res !== undefined && res !== null) {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n }\n } else if (action === 'add') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.add(...classes);\n } else if (action === 'remove') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n targetEl.classList.remove(...classes);\n } else if (action === 'toggle') {\n const classes = Array.isArray(res) ? res.map(String) : [String(res)];\n classes.forEach(c => targetEl.classList.toggle(c));\n }\n });\n }\n return res;\n };\n };\n };\n}\n\n/**\n * @setClassList decorator to surgically replace all classes on a target element.\n * Returns: string | string[]\n */\nexport const setClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('set')(selector, options);\n\n/**\n * @updateClassList decorator to surgically update specific classes.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport const updateClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('update')(selector, options);\n\n/**\n * @addClassList decorator to surgically add classes to a target element.\n * Returns: string | string[]\n */\nexport const addClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('add')(selector, options);\n\n/**\n * @removeClassList decorator to surgically remove classes from a target element.\n * Returns: string | string[]\n */\nexport const removeClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('remove')(selector, options);\n\n/**\n * @toggleClassList decorator to surgically toggle classes on a target element.\n * Returns: string | string[]\n */\nexport const toggleClassList = (selector: string, options: SwcQueryOptions = {}) => createClassListDecorator('toggle')(selector, options);\n\n// Host-specific versions (for :host selector)\n\n/**\n * @setClassListHost decorator to set classes on :host element.\n * Returns: string | string[]\n */\nexport function setClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function setClassListHost(): MethodDecorator;\nexport function setClassListHost(options: SwcQueryOptions): MethodDecorator;\nexport function setClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createClassListDecorator('set')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createClassListDecorator('set')(':host', (targetOrOptions as SwcQueryOptions) || {});\n}\n\n/**\n * @updateClassListHost decorator to update specific classes on :host.\n * Returns: Record<string, boolean> (toggle with force) | string | string[] (add)\n */\nexport function updateClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function updateClassListHost(): MethodDecorator;\nexport function updateClassListHost(options: SwcQueryOptions): MethodDecorator;\nexport function updateClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createClassListDecorator('update')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createClassListDecorator('update')(':host', (targetOrOptions as SwcQueryOptions) || {});\n}\n\n/**\n * @addClassListHost decorator to add classes to :host element.\n * Returns: string | string[]\n */\nexport function addClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function addClassListHost(): MethodDecorator;\nexport function addClassListHost(options: SwcQueryOptions): MethodDecorator;\nexport function addClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createClassListDecorator('add')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createClassListDecorator('add')(':host', (targetOrOptions as SwcQueryOptions) || {});\n}\n\n/**\n * @removeClassListHost decorator to remove classes from :host element.\n * Returns: string | string[]\n */\nexport function removeClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function removeClassListHost(): MethodDecorator;\nexport function removeClassListHost(options: SwcQueryOptions): MethodDecorator;\nexport function removeClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createClassListDecorator('remove')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createClassListDecorator('remove')(':host', (targetOrOptions as SwcQueryOptions) || {});\n}\n\n/**\n * @toggleClassListHost decorator to toggle classes on :host element.\n * Returns: string | string[]\n */\nexport function toggleClassListHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function toggleClassListHost(): MethodDecorator;\nexport function toggleClassListHost(options: SwcQueryOptions): MethodDecorator;\nexport function toggleClassListHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = createClassListDecorator('toggle')(':host', {});\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return createClassListDecorator('toggle')(':host', (targetOrOptions as SwcQueryOptions) || {});\n}\n\nexport const findAllClassListMetadata = (target: any): Map<string | symbol, ClassListMetadata> => {\n const result = new Map<string | symbol, ClassListMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassListMetadata>>(CLASS_LIST_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;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAC7B,2BAA2B;AAC3B,mBAAyB;AAGlB,MAAM,0BAA0B,OAAO,iCAAiC;AAW/E,SAAS,yBAAyB,QAAyB;AACzD,SAAO,CAAC,UAAkB,UAA2B,CAAC,MAAuB;AAC3E,WAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,YAAM,cAAc,OAAO;AAC3B,UAAI,WAAW,yBAAa,eAAe,yBAAyB,WAAW;AAC/E,UAAI,CAAC,UAAU;AACb,mBAAW,oBAAI,IAAwC;AACvD,iCAAa,eAAe,yBAAyB,UAAU,WAAW;AAAA,MAC5E;AACA,eAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAQ,QAAQ,CAAC;AAEpE,YAAM,WAAW,WAAW;AAC5B,iBAAW,QAAQ,kBAAmB,MAAa;AACjD,6CAAW,IAAI;AACf,cAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,YAAI,QAAQ,QAAW;AACrB,gBAAM,IAAI,QAAQ,QAAQ;AAC1B,gBAAM,UAAU,sBAAS,WAAW,IAAW;AAC/C,gBAAM,YAA2B,CAAC;AAElC,gBAAM,YAAY,CAAC,MAAW;AAC5B,gBAAI,CAAC,KAAK,EAAE,aAAa,aAAc;AACvC,gBAAI,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AAiB,iBAAuB,aAA+B,YAAsC;AAC3H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,yBAAyB,KAAK,EAAE,SAAS,CAAC,CAAC;AAC7D,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,yBAAyB,KAAK,EAAE,SAAU,mBAAuC,CAAC,CAAC;AAC5F;AASO,SAAS,oBAAoB,iBAAuB,aAA+B,YAAsC;AAC9H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,yBAAyB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAChE,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,yBAAyB,QAAQ,EAAE,SAAU,mBAAuC,CAAC,CAAC;AAC/F;AASO,SAAS,oBAAoB,iBAAuB,aAA+B,YAAsC;AAC9H,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,yBAAyB,QAAQ,EAAE,SAAS,CAAC,CAAC;AAChE,WAAO,UAAU,iBAAiB,aAAa,UAAU;AAAA,EAC3D;AACA,SAAO,yBAAyB,QAAQ,EAAE,SAAU,mBAAuC,CAAC,CAAC;AAC/F;AAEO,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,QAAM,OAAO,yBAAa,gBAAyD,yBAAyB,MAAM;AAClH,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
|
}
|
|
@@ -18,7 +18,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var query_exports = {};
|
|
19
19
|
__export(query_exports, {
|
|
20
20
|
QUERY_METADATA_KEY: () => QUERY_METADATA_KEY,
|
|
21
|
+
appHost: () => appHost,
|
|
22
|
+
firstAppHost: () => firstAppHost,
|
|
23
|
+
firstHost: () => firstHost,
|
|
21
24
|
getQueryMetadata: () => getQueryMetadata,
|
|
25
|
+
host: () => host,
|
|
26
|
+
lastAppHost: () => lastAppHost,
|
|
27
|
+
lastHost: () => lastHost,
|
|
28
|
+
parentHost: () => parentHost,
|
|
22
29
|
query: () => query,
|
|
23
30
|
queryHost: () => queryHost
|
|
24
31
|
});
|
|
@@ -124,7 +131,75 @@ const getQueryMetadata = (target) => {
|
|
|
124
131
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
125
132
|
return import_core.ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
|
|
126
133
|
};
|
|
127
|
-
function queryHost(
|
|
128
|
-
|
|
134
|
+
function queryHost(targetOrOptions, propertyKey) {
|
|
135
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
136
|
+
return query(":host", {})(targetOrOptions, propertyKey);
|
|
137
|
+
}
|
|
138
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
139
|
+
return query(":host", targetOrOptions);
|
|
140
|
+
} else {
|
|
141
|
+
return query(":host", {});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const host = queryHost;
|
|
145
|
+
function parentHost(targetOrOptions, propertyKey) {
|
|
146
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
147
|
+
return query(":parentHost", {})(targetOrOptions, propertyKey);
|
|
148
|
+
}
|
|
149
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
150
|
+
return query(":parentHost", targetOrOptions);
|
|
151
|
+
} else {
|
|
152
|
+
return query(":parentHost", {});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function appHost(targetOrOptions, propertyKey) {
|
|
156
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
157
|
+
return query(":appHost", {})(targetOrOptions, propertyKey);
|
|
158
|
+
}
|
|
159
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
160
|
+
return query(":appHost", targetOrOptions);
|
|
161
|
+
} else {
|
|
162
|
+
return query(":appHost", {});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function firstHost(targetOrOptions, propertyKey) {
|
|
166
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
167
|
+
return query(":firstHost", {})(targetOrOptions, propertyKey);
|
|
168
|
+
}
|
|
169
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
170
|
+
return query(":firstHost", targetOrOptions);
|
|
171
|
+
} else {
|
|
172
|
+
return query(":firstHost", {});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function lastHost(targetOrOptions, propertyKey) {
|
|
176
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
177
|
+
return query(":lastHost", {})(targetOrOptions, propertyKey);
|
|
178
|
+
}
|
|
179
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
180
|
+
return query(":lastHost", targetOrOptions);
|
|
181
|
+
} else {
|
|
182
|
+
return query(":lastHost", {});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function firstAppHost(targetOrOptions, propertyKey) {
|
|
186
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
187
|
+
return query(":firstAppHost", {})(targetOrOptions, propertyKey);
|
|
188
|
+
}
|
|
189
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
190
|
+
return query(":firstAppHost", targetOrOptions);
|
|
191
|
+
} else {
|
|
192
|
+
return query(":firstAppHost", {});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function lastAppHost(targetOrOptions, propertyKey) {
|
|
196
|
+
if (propertyKey !== void 0 && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
|
|
197
|
+
return query(":lastAppHost", {})(targetOrOptions, propertyKey);
|
|
198
|
+
}
|
|
199
|
+
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
200
|
+
return query(":lastAppHost", targetOrOptions);
|
|
201
|
+
} else {
|
|
202
|
+
return query(":lastAppHost", {});
|
|
203
|
+
}
|
|
129
204
|
}
|
|
130
205
|
//# sourceMappingURL=query.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/query.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 QueryMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_METADATA_KEY = Symbol('simple-web-component:query');\n\nexport function query(target: SpecialSelector): PropertyDecorator;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n // const propertyType = Reflect.getMetadata(\"design:type\", targetObj, propertyKey);\n // console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);\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) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; // query only returns one, so shadow preferred\n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === ':appHost') return applyRoot(hostSet.$appHost);\n if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);\n if (selector === ':firstAppHost') return applyRoot(hostSet.$firstAppHost);\n if (selector === ':lastAppHost') return applyRoot(hostSet.$lastAppHost);\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 ? this.shadowRoot.querySelector(selector) : null;\n if (r === 'light') return this.querySelector(selector);\n if (r === 'all') {\n const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n return shadowMatch || this.querySelector(selector);\n }\n return (this.shadowRoot || this).querySelector(selector);\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined) {\n const selector = selectorOrTarget;\n if (selector.startsWith(':') && selector !== ':host') return;\n\n const r = options.root || 'auto';\n const targets: Element[] = [];\n\n if (r === 'shadow') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n } else if (r === 'light') {\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else if (r === 'all') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else {\n const el = (this.shadowRoot || this).querySelector(selector);\n if (el) targets.push(el);\n }\n\n targets.forEach(t => t.remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};\n\n/**\n * @hostQuery decorator - simplified version of @query for :host selector\n * Usage: @hostQuery()\n * Usage: @hostQuery({ root: 'shadow' })\n */\nexport function queryHost(options?: SwcQueryOptions): PropertyDecorator {\n return query(':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 QueryMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: SwcQueryOptions;\n}\n\nexport const QUERY_METADATA_KEY = Symbol('simple-web-component:query');\n\nexport function query(target: SpecialSelector): PropertyDecorator;\nexport function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;\n/**\n * @query decorator to inject a single element into a class property.\n */\nexport function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = targetObj.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ propertyKey, selector: selectorOrTarget, options });\n\n // const propertyType = Reflect.getMetadata(\"design:type\", targetObj, propertyKey);\n // console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);\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) => {\n if (!t || !(t instanceof HTMLElement)) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t; // query only returns one, so shadow preferred\n return t;\n };\n\n // --- Special Selectors: HostSet ---\n const hostSet = SwcUtils.getHostSet(this);\n if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === ':appHost') return applyRoot(hostSet.$appHost);\n if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);\n if (selector === ':firstAppHost') return applyRoot(hostSet.$firstAppHost);\n if (selector === ':lastAppHost') return applyRoot(hostSet.$lastAppHost);\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 ? this.shadowRoot.querySelector(selector) : null;\n if (r === 'light') return this.querySelector(selector);\n if (r === 'all') {\n const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n return shadowMatch || this.querySelector(selector);\n }\n return (this.shadowRoot || this).querySelector(selector);\n },\n set(this: HTMLElement, nv: any) {\n ensureInit(this);\n if (nv === null || nv === undefined) {\n const selector = selectorOrTarget;\n if (selector.startsWith(':') && selector !== ':host') return;\n\n const r = options.root || 'auto';\n const targets: Element[] = [];\n\n if (r === 'shadow') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n } else if (r === 'light') {\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else if (r === 'all') {\n if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);\n if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);\n } else {\n const el = (this.shadowRoot || this).querySelector(selector);\n if (el) targets.push(el);\n }\n\n targets.forEach(t => t.remove());\n }\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};\n\n/**\n * @queryHost decorator - simplified version of @query for :host selector\n * Usage: @queryHost testzzs: HTMLElement | undefined;\n * Usage: @queryHost() testzzs: HTMLElement | undefined;\n * Usage: @queryHost({ root: 'shadow' }) testzzs: HTMLElement | undefined;\n */\nexport function queryHost(target: Object, propertyKey: string | symbol): void;\nexport function queryHost(): PropertyDecorator;\nexport function queryHost(options: SwcQueryOptions): PropertyDecorator;\nexport function queryHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n // Direct decorator usage: @queryHost (no parentheses)\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':host', {})(targetOrOptions, propertyKey);\n }\n\n // @queryHost() or @queryHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':host', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':host', {});\n }\n}\n\n/**\n * @host - Alias for @queryHost decorator\n * Usage: @host element: HTMLElement | undefined;\n * Usage: @host() element: HTMLElement | undefined;\n * Usage: @host({ root: 'shadow' }) element: HTMLElement | undefined;\n */\nexport const host = queryHost;\n\n/**\n * @parentHost - Query :parentHost (Direct parent SWC component)\n * Usage: @parentHost parent: HTMLElement | undefined;\n * Usage: @parentHost() parent: HTMLElement | undefined;\n * Usage: @parentHost({ root: 'shadow' }) parent: HTMLElement | undefined;\n */\nexport function parentHost(target: Object, propertyKey: string | symbol): void;\nexport function parentHost(): PropertyDecorator;\nexport function parentHost(options: SwcQueryOptions): PropertyDecorator;\nexport function parentHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':parentHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':parentHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':parentHost', {});\n }\n}\n\n/**\n * @appHost - Query :appHost (Nearest <swc-app>)\n * Usage: @appHost app: SwcAppInterface | undefined;\n * Usage: @appHost() app: SwcAppInterface | undefined;\n * Usage: @appHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function appHost(target: Object, propertyKey: string | symbol): void;\nexport function appHost(): PropertyDecorator;\nexport function appHost(options: SwcQueryOptions): PropertyDecorator;\nexport function appHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':appHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':appHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':appHost', {});\n }\n}\n\n/**\n * @firstHost - Query :firstHost (First component in hierarchy)\n * Usage: @firstHost first: HTMLElement | undefined;\n * Usage: @firstHost() first: HTMLElement | undefined;\n * Usage: @firstHost({ root: 'shadow' }) first: HTMLElement | undefined;\n */\nexport function firstHost(target: Object, propertyKey: string | symbol): void;\nexport function firstHost(): PropertyDecorator;\nexport function firstHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstHost', {});\n }\n}\n\n/**\n * @lastHost - Query :lastHost (Last component in hierarchy)\n * Usage: @lastHost last: HTMLElement | undefined;\n * Usage: @lastHost() last: HTMLElement | undefined;\n * Usage: @lastHost({ root: 'shadow' }) last: HTMLElement | undefined;\n */\nexport function lastHost(target: Object, propertyKey: string | symbol): void;\nexport function lastHost(): PropertyDecorator;\nexport function lastHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastHost', {});\n }\n}\n\n/**\n * @firstAppHost - Query :firstAppHost (First <swc-app> in hierarchy)\n * Usage: @firstAppHost app: SwcAppInterface | undefined;\n * Usage: @firstAppHost() app: SwcAppInterface | undefined;\n * Usage: @firstAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function firstAppHost(target: Object, propertyKey: string | symbol): void;\nexport function firstAppHost(): PropertyDecorator;\nexport function firstAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function firstAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':firstAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':firstAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':firstAppHost', {});\n }\n}\n\n/**\n * @lastAppHost - Query :lastAppHost (Last <swc-app> in hierarchy)\n * Usage: @lastAppHost app: SwcAppInterface | undefined;\n * Usage: @lastAppHost() app: SwcAppInterface | undefined;\n * Usage: @lastAppHost({ root: 'shadow' }) app: SwcAppInterface | undefined;\n */\nexport function lastAppHost(target: Object, propertyKey: string | symbol): void;\nexport function lastAppHost(): PropertyDecorator;\nexport function lastAppHost(options: SwcQueryOptions): PropertyDecorator;\nexport function lastAppHost(targetOrOptions?: any, propertyKey?: string | symbol): any {\n if (propertyKey !== undefined && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return query(':lastAppHost', {})(targetOrOptions, propertyKey);\n }\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n return query(':lastAppHost', targetOrOptions as SwcQueryOptions);\n } else {\n return query(':lastAppHost', {});\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;kBAA6B;AAC7B,2BAA6C;AAC7C,mBAAyB;AASlB,MAAM,qBAAqB,OAAO,4BAA4B;AAO/D,SAAU,MAAM,kBAA0B,UAAe,CAAA,GAAE;AAC/D,SAAO,CAAC,WAAmB,aAA8B,eAA4B;AACnF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,UAAU;AAC9B,QAAI,UAAU,yBAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,+BAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,aAAa,UAAU,kBAAkB,QAAO,CAAE;AAIjE,WAAO,eAAe,WAAW,aAAa;MAC5C,MAAG;AACD,6CAAW,IAAI;AACf,cAAM,WAAW;AAEjB,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAU;AAC3B,cAAI,CAAC,KAAK,EAAE,aAAa;AAAc,mBAAO;AAC9C,cAAI,MAAM;AAAQ,mBAAO,EAAE,cAAc;AACzC,cAAI,MAAM;AAAU,mBAAO,EAAE;AAC7B,cAAI,MAAM;AAAS,mBAAO;AAC1B,cAAI,MAAM;AAAO,mBAAO,EAAE,cAAc;AACxC,iBAAO;QACT;AAGA,cAAM,UAAU,sBAAS,WAAW,IAAI;AACxC,YAAI,aAAa;AAAe,iBAAO,UAAU,QAAQ,WAAW;AACpE,YAAI,aAAa;AAAY,iBAAO,UAAU,QAAQ,QAAQ;AAC9D,YAAI,aAAa;AAAc,iBAAO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