budibase/packages/client/src/store/builder.js

30 lines
579 B
JavaScript
Raw Normal View History

import { writable } from "svelte/store"
const createBuilderStore = () => {
const initialState = {
inBuilder: false,
appId: null,
layout: null,
screen: null,
selectedComponentId: null,
previewId: null,
previewType: null,
}
const store = writable(initialState)
const actions = {
2021-05-03 09:31:09 +02:00
selectComponent: (id) => {
if (id) {
window.dispatchEvent(
new CustomEvent("bb-select-component", { detail: id })
)
}
},
}
return {
...store,
actions,
}
}
export const builderStore = createBuilderStore()