| 
									
										
										
										
											2023-01-17 18:31:51 +01:00
										 |  |  | import BaseUIElement from "../BaseUIElement" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 13:10:57 +01:00
										 |  |  | import { SvelteComponentTyped } from "svelte" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-22 20:59:50 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * The SvelteUIComponent serves as a translating class which which wraps a SvelteElement into the BaseUIElement framework. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2023-01-29 13:10:57 +01:00
										 |  |  | export default class SvelteUIElement< | 
					
						
							|  |  |  |     Props extends Record<string, any> = any, | 
					
						
							|  |  |  |     Events extends Record<string, any> = any, | 
					
						
							|  |  |  |     Slots extends Record<string, any> = any | 
					
						
							|  |  |  | > extends BaseUIElement { | 
					
						
							|  |  |  |     private readonly _svelteComponent: { | 
					
						
							|  |  |  |         new (args: { | 
					
						
							|  |  |  |             target: HTMLElement | 
					
						
							|  |  |  |             props: Props | 
					
						
							|  |  |  |             events?: Events | 
					
						
							|  |  |  |             slots?: Slots | 
					
						
							|  |  |  |         }): SvelteComponentTyped<Props, Events, Slots> | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     private readonly _props: Props | 
					
						
							| 
									
										
										
										
											2023-01-17 18:31:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 13:10:57 +01:00
										 |  |  |     constructor(svelteElement, props: Props) { | 
					
						
							| 
									
										
										
										
											2023-01-17 18:31:51 +01:00
										 |  |  |         super() | 
					
						
							|  |  |  |         this._svelteComponent = svelteElement | 
					
						
							|  |  |  |         this._props = props | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected InnerConstructElement(): HTMLElement { | 
					
						
							|  |  |  |         const el = document.createElement("div") | 
					
						
							|  |  |  |         new this._svelteComponent({ | 
					
						
							|  |  |  |             target: el, | 
					
						
							|  |  |  |             props: this._props, | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         return el | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |