@libs-ui/services-dynamic-component 0.2.290 → 0.2.291
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/esm2022/index.mjs +3 -1
- package/esm2022/inputs.type.mjs +2 -0
- package/esm2022/set-inputs.mjs +4 -0
- package/fesm2022/libs-ui-services-dynamic-component.mjs +5 -1
- package/fesm2022/libs-ui-services-dynamic-component.mjs.map +1 -1
- package/index.d.ts +2 -0
- package/inputs.type.d.ts +14 -0
- package/package.json +2 -2
- package/set-inputs.d.ts +3 -0
package/esm2022/index.mjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from './dynamic-component.service';
|
|
2
|
-
|
|
2
|
+
export * from './inputs.type';
|
|
3
|
+
export * from './set-inputs';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzLXVpL3NlcnZpY2VzL2R5bmFtaWMtY29tcG9uZW50L3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9keW5hbWljLWNvbXBvbmVudC5zZXJ2aWNlJztcbmV4cG9ydCAqIGZyb20gJy4vaW5wdXRzLnR5cGUnO1xuZXhwb3J0ICogZnJvbSAnLi9zZXQtaW5wdXRzJzsiXX0=
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXRzLnR5cGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6Wy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GluIGtleW9mIFQgYXMgVFtLXSBleHRlbmRzIElucHV0U2lnbmFsPGluZmVyIFU+ID8gKHVuZGVmaW5lZCBleHRlbmRzIFUgPyBLIDogbmV2ZXIpIDogbmV2ZXJdPzogVW53cmFwSW5wdXRTaWduYWw8VCwgSz47XG59O1xuXG4vLyBNYWluIHR5cGUgxJHhu4MgZXh0cmFjdCB04bqldCBj4bqjIGlucHV0cyB04burIGNvbXBvbmVudFxudHlwZSBFeHRyYWN0SW5wdXRzPFQ+ID0gUmVxdWlyZWRJbnB1dFByb3BlcnRpZXM8VD4gJiBPcHRpb25hbElucHV0UHJvcGVydGllczxUPjtcbmV4cG9ydCB0eXBlIElucHV0czxUPiA9IFBhcnRpYWw8VW53cmFwU2lnbmFsczxUPj4gJiBFeHRyYWN0SW5wdXRzPFQ+O1xuIl19
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const setInputs = (componentRef, inputs) => {
|
|
2
|
+
Object.entries(inputs).forEach(([key, value]) => componentRef.setInput(key, value));
|
|
3
|
+
};
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0LWlucHV0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2xpYnMtdWkvc2VydmljZXMvZHluYW1pYy1jb21wb25lbnQvc3JjL3NldC1pbnB1dHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsTUFBTSxDQUFDLE1BQU0sU0FBUyxHQUFHLENBQUksWUFBNkIsRUFBRSxNQUFpQixFQUFRLEVBQUU7SUFDckYsTUFBTSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsRUFBRSxFQUFFLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxHQUFHLEVBQUUsS0FBSyxDQUFDLENBQUMsQ0FBQztBQUN0RixDQUFDLENBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb21wb25lbnRSZWYgfSBmcm9tIFwiQGFuZ3VsYXIvY29yZVwiO1xuaW1wb3J0IHsgSW5wdXRzIH0gZnJvbSBcIi4vaW5wdXRzLnR5cGVcIjtcblxuZXhwb3J0IGNvbnN0IHNldElucHV0cyA9IDxUPihjb21wb25lbnRSZWY6IENvbXBvbmVudFJlZjxUPiwgaW5wdXRzOiBJbnB1dHM8VD4pOiB2b2lkID0+IHtcbiAgT2JqZWN0LmVudHJpZXMoaW5wdXRzKS5mb3JFYWNoKChba2V5LCB2YWx1ZV0pID0+IGNvbXBvbmVudFJlZi5zZXRJbnB1dChrZXksIHZhbHVlKSk7XG59Il19
|
|
@@ -103,9 +103,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
103
103
|
}]
|
|
104
104
|
}] });
|
|
105
105
|
|
|
106
|
+
const setInputs = (componentRef, inputs) => {
|
|
107
|
+
Object.entries(inputs).forEach(([key, value]) => componentRef.setInput(key, value));
|
|
108
|
+
};
|
|
109
|
+
|
|
106
110
|
/**
|
|
107
111
|
* Generated bundle index. Do not edit.
|
|
108
112
|
*/
|
|
109
113
|
|
|
110
|
-
export { LibsUiDynamicComponentService };
|
|
114
|
+
export { LibsUiDynamicComponentService, setInputs };
|
|
111
115
|
//# sourceMappingURL=libs-ui-services-dynamic-component.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libs-ui-services-dynamic-component.mjs","sources":["../../../../../libs-ui/services/dynamic-component/src/dynamic-component.service.ts","../../../../../libs-ui/services/dynamic-component/src/libs-ui-services-dynamic-component.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ApplicationRef, ComponentRef, EmbeddedViewRef, Injectable, createComponent, inject } from '@angular/core';\nimport { uuid } from '@libs-ui/utils';\n@Injectable({\n providedIn: 'root'\n})\n\nexport class LibsUiDynamicComponentService {\n private elementLayoutContent:Map<string, HTMLElement> = new Map();\n private elementBody!: HTMLElement | null;\n private mapStylesToParentDocument: Map<string, Array<Node>> = new Map();\n private appRef = inject(ApplicationRef);\n private idElementLayoutContentDefault = 'libs-ui-layout-content';\n\n public set IdElementLayoutContentDefault(id: string) {\n this.idElementLayoutContentDefault = id;\n }\n\n public resolveComponentFactory(component: any): ComponentRef<any> {\n return createComponent(component, { environmentInjector: this.appRef.injector });\n }\n\n public addToBody(componentRef: any, isAddParentDocument?: boolean): string {\n if (!componentRef || !componentRef.hostView) {\n return '';\n }\n\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n if (isAddParentDocument) {\n window.parent.document.body.appendChild(domElem);\n\n return this.updateStyleToParentDocument();\n }\n if (!this.elementBody) {\n this.elementBody = document.body;\n }\n this.elementBody.appendChild(domElem);\n\n return '';\n }\n\n public addToElement(componentRef: any, elementAdd: any) {\n if (!componentRef || !componentRef.hostView || !elementAdd) {\n return;\n }\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n return elementAdd.appendChild(domElem);\n }\n\n public addToElementLayoutContentDefault(componentRef: any, id: string = this.idElementLayoutContentDefault) {\n this.addToIdAttributeElement(componentRef, id);\n }\n\n\n public addToIdAttributeElement(componentRef: any, id: string) {\n if (!this.elementLayoutContent.has(id)) {\n this.elementLayoutContent.set(id, document.getElementById(id) as HTMLElement);\n }\n if (!componentRef || !componentRef.hostView) {\n return;\n }\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n return this.elementLayoutContent.get(id)?.appendChild(domElem);\n }\n\n public remove(componentRef: any, frameId = '', ignoreDestroyComponent?: boolean) {\n if (!componentRef) {\n return;\n }\n this.removeStyleToParentDocument(frameId);\n if (componentRef.hostView) {\n this.appRef.detachView(componentRef.hostView);\n }\n if (!ignoreDestroyComponent && componentRef.destroy) {\n componentRef.destroy();\n }\n }\n\n private updateStyleToParentDocument(): string {\n const frameId = uuid();\n const documentParent = window.parent.document;\n\n if (documentParent && !this.mapStylesToParentDocument.has(frameId)) {\n const styleTags = new Array<Node>();\n\n Array.from(document.head.querySelectorAll(\"style\")).forEach(styleTag => {\n const cloneStyleTag = styleTag.cloneNode(true);\n\n styleTags.push(cloneStyleTag);\n documentParent?.head.appendChild(cloneStyleTag);\n });\n this.mapStylesToParentDocument.set(frameId, styleTags);\n }\n\n return frameId;\n }\n\n private removeStyleToParentDocument(frameId: string) {\n if (!frameId) {\n return;\n }\n const styleTagsPopup = this.mapStylesToParentDocument.get(frameId);\n const documentParent = window.parent.document;\n\n if (!styleTagsPopup || !styleTagsPopup.length || !documentParent) {\n return;\n }\n styleTagsPopup.forEach(styleTag => {\n documentParent?.head.removeChild(styleTag);\n });\n this.mapStylesToParentDocument.delete(frameId);\n }\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;MAOa,6BAA6B,CAAA;AAChC,IAAA,oBAAoB,GAA4B,IAAI,GAAG,EAAE;AACzD,IAAA,WAAW;AACX,IAAA,yBAAyB,GAA6B,IAAI,GAAG,EAAE;AAC/D,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;IAC/B,6BAA6B,GAAG,wBAAwB;IAEhE,IAAW,6BAA6B,CAAC,EAAU,EAAA;AACjD,QAAA,IAAI,CAAC,6BAA6B,GAAG,EAAE;;AAGlC,IAAA,uBAAuB,CAAC,SAAc,EAAA;AAC3C,QAAA,OAAO,eAAe,CAAC,SAAS,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;;IAG3E,SAAS,CAAC,YAAiB,EAAE,mBAA6B,EAAA;QAC/D,IAAI,CAAC,YAA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,gBAAA,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;AACjD,aAAC,CAAC;YACF,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC;;AAGxD,QAAA,OAAO,OAAO;;AAGR,IAAA,2BAA2B,CAAC,OAAe,EAAA;QACjD,IAAI,CAAC,OAAO,EAAE;YACZ;;QAEF,MAAM,cAAc,GAAG,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,OAAO,CAAC;AAClE,QAAA,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ;QAE7C,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE;YAChE;;AAEF,QAAA,cAAc,CAAC,OAAO,CAAC,QAAQ,IAAG;AAChC,YAAA,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;AAC5C,SAAC,CAAC;AACF,QAAA,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,OAAO,CAAC;;wGA7GrC,6BAA6B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAA7B,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,6BAA6B,cAH5B,MAAM,EAAA,CAAA;;4FAGP,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAJzC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;
|
|
1
|
+
{"version":3,"file":"libs-ui-services-dynamic-component.mjs","sources":["../../../../../libs-ui/services/dynamic-component/src/dynamic-component.service.ts","../../../../../libs-ui/services/dynamic-component/src/set-inputs.ts","../../../../../libs-ui/services/dynamic-component/src/libs-ui-services-dynamic-component.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ApplicationRef, ComponentRef, EmbeddedViewRef, Injectable, createComponent, inject } from '@angular/core';\nimport { uuid } from '@libs-ui/utils';\n@Injectable({\n providedIn: 'root'\n})\n\nexport class LibsUiDynamicComponentService {\n private elementLayoutContent:Map<string, HTMLElement> = new Map();\n private elementBody!: HTMLElement | null;\n private mapStylesToParentDocument: Map<string, Array<Node>> = new Map();\n private appRef = inject(ApplicationRef);\n private idElementLayoutContentDefault = 'libs-ui-layout-content';\n\n public set IdElementLayoutContentDefault(id: string) {\n this.idElementLayoutContentDefault = id;\n }\n\n public resolveComponentFactory(component: any): ComponentRef<any> {\n return createComponent(component, { environmentInjector: this.appRef.injector });\n }\n\n public addToBody(componentRef: any, isAddParentDocument?: boolean): string {\n if (!componentRef || !componentRef.hostView) {\n return '';\n }\n\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n if (isAddParentDocument) {\n window.parent.document.body.appendChild(domElem);\n\n return this.updateStyleToParentDocument();\n }\n if (!this.elementBody) {\n this.elementBody = document.body;\n }\n this.elementBody.appendChild(domElem);\n\n return '';\n }\n\n public addToElement(componentRef: any, elementAdd: any) {\n if (!componentRef || !componentRef.hostView || !elementAdd) {\n return;\n }\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n return elementAdd.appendChild(domElem);\n }\n\n public addToElementLayoutContentDefault(componentRef: any, id: string = this.idElementLayoutContentDefault) {\n this.addToIdAttributeElement(componentRef, id);\n }\n\n\n public addToIdAttributeElement(componentRef: any, id: string) {\n if (!this.elementLayoutContent.has(id)) {\n this.elementLayoutContent.set(id, document.getElementById(id) as HTMLElement);\n }\n if (!componentRef || !componentRef.hostView) {\n return;\n }\n this.appRef.attachView(componentRef.hostView);\n const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;\n\n return this.elementLayoutContent.get(id)?.appendChild(domElem);\n }\n\n public remove(componentRef: any, frameId = '', ignoreDestroyComponent?: boolean) {\n if (!componentRef) {\n return;\n }\n this.removeStyleToParentDocument(frameId);\n if (componentRef.hostView) {\n this.appRef.detachView(componentRef.hostView);\n }\n if (!ignoreDestroyComponent && componentRef.destroy) {\n componentRef.destroy();\n }\n }\n\n private updateStyleToParentDocument(): string {\n const frameId = uuid();\n const documentParent = window.parent.document;\n\n if (documentParent && !this.mapStylesToParentDocument.has(frameId)) {\n const styleTags = new Array<Node>();\n\n Array.from(document.head.querySelectorAll(\"style\")).forEach(styleTag => {\n const cloneStyleTag = styleTag.cloneNode(true);\n\n styleTags.push(cloneStyleTag);\n documentParent?.head.appendChild(cloneStyleTag);\n });\n this.mapStylesToParentDocument.set(frameId, styleTags);\n }\n\n return frameId;\n }\n\n private removeStyleToParentDocument(frameId: string) {\n if (!frameId) {\n return;\n }\n const styleTagsPopup = this.mapStylesToParentDocument.get(frameId);\n const documentParent = window.parent.document;\n\n if (!styleTagsPopup || !styleTagsPopup.length || !documentParent) {\n return;\n }\n styleTagsPopup.forEach(styleTag => {\n documentParent?.head.removeChild(styleTag);\n });\n this.mapStylesToParentDocument.delete(frameId);\n }\n}","import { ComponentRef } from \"@angular/core\";\nimport { Inputs } from \"./inputs.type\";\n\nexport const setInputs = <T>(componentRef: ComponentRef<T>, inputs: Inputs<T>): void => {\n Object.entries(inputs).forEach(([key, value]) => componentRef.setInput(key, value));\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;MAOa,6BAA6B,CAAA;AAChC,IAAA,oBAAoB,GAA4B,IAAI,GAAG,EAAE;AACzD,IAAA,WAAW;AACX,IAAA,yBAAyB,GAA6B,IAAI,GAAG,EAAE;AAC/D,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;IAC/B,6BAA6B,GAAG,wBAAwB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AM,EAAA,CAAA;;4FAGP,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAJzC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;MCFY,SAAS,GAAG,CAAI,YAA6B,EAAE,MAAiB,KAAU;IACrF,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACrF;;ACLA;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
package/inputs.type.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InputSignal, Signal } from "@angular/core";
|
|
2
|
+
type UnwrapInputSignal<T, K extends keyof T> = T[K] extends InputSignal<infer U> ? U : never;
|
|
3
|
+
type UnwrapSignals<T> = {
|
|
4
|
+
[K in keyof T]: T[K] extends Signal<infer U> ? U : T[K];
|
|
5
|
+
};
|
|
6
|
+
type RequiredInputProperties<T> = {
|
|
7
|
+
[K in keyof T as T[K] extends InputSignal<infer U> ? (undefined extends U ? never : K) : never]: UnwrapInputSignal<T, K>;
|
|
8
|
+
};
|
|
9
|
+
type OptionalInputProperties<T> = {
|
|
10
|
+
[K in keyof T as T[K] extends InputSignal<infer U> ? (undefined extends U ? K : never) : never]?: UnwrapInputSignal<T, K>;
|
|
11
|
+
};
|
|
12
|
+
type ExtractInputs<T> = RequiredInputProperties<T> & OptionalInputProperties<T>;
|
|
13
|
+
export type Inputs<T> = Partial<UnwrapSignals<T>> & ExtractInputs<T>;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/services-dynamic-component",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.291",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/core": ">=18.0.0",
|
|
6
|
-
"@libs-ui/utils": "0.2.
|
|
6
|
+
"@libs-ui/utils": "0.2.291"
|
|
7
7
|
},
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"module": "fesm2022/libs-ui-services-dynamic-component.mjs",
|
package/set-inputs.d.ts
ADDED