Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
976 B

import { writable, get } from "svelte/store"
import { getAppId } from "@budibase/component-sdk"
import Router from "../components/Router.svelte"
const createComponentStore = () => {
const store = writable({})
/**
* Loads the component library from the server
*/
const loadComponentLibrary = async () => {
const appId = getAppId()
const library = await import(
`/componentlibrary?library=@budibase/standard-components&appId=${appId}`
)
store.set(library)
}
/**
* Fetches a Svelte component from the standard-components library.
*/
const getComponent = componentName => {
if (!componentName) {
return null
}
// Edge case for screen slot
if (componentName === "screenslot") {
return Router
}
return get(store)[componentName]
}
// Attach actions to the store
store.actions = { getComponent, loadComponentLibrary }
return store
}
export const componentStore = createComponentStore()