Füge Docker- und Babel-Konfigurationen hinzu, aktualisiere Svelte- und Esbuild-Setups, erweitere Typdefinitionen und aktualisiere die README-Datei

This commit is contained in:
2025-03-27 13:52:13 +00:00
parent 77cb64b260
commit 7a6a2cbd22
16 changed files with 447 additions and 84 deletions

45
frontend/src/admin.ts Normal file
View File

@@ -0,0 +1,45 @@
import type { SvelteComponent } from "svelte"
function getRenderedElement(
component: typeof SvelteComponent,
options?: { props: { [key: string]: any }; addCss?: string[] },
nestedElements?: { tagName: string; className?: string }[]
) {
const el = document.createElement("div")
el.attachShadow({ mode: "open" })
const body = document.createElement("body")
// build nested divs with css classes
let target: HTMLElement = body
nestedElements?.forEach((e) => {
const newElement = document.createElement(e.tagName)
if (e.className) {
newElement.className = e.className
}
target.appendChild(newElement)
target = newElement
})
el.shadowRoot.appendChild(body)
options?.addCss?.forEach((css) => {
const link = document.createElement("link")
link.rel = "stylesheet"
link.href = css
link.type = "text/css"
el.shadowRoot.appendChild(link)
})
new component({
target: target,
props: options?.props,
})
return el
}
export {
getRenderedElement,
// pass also required svelte components here
}