diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/dndStore.js b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/dndStore.js index 2361abce89..a7b3b0d9ea 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/dndStore.js +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ComponentList/dndStore.js @@ -1,12 +1,7 @@ import { writable, get } from "svelte/store" import { findComponentParent, findComponentPath } from "@/helpers/components" import { selectedScreen, componentStore } from "@/stores/builder" - -export const DropPosition = { - ABOVE: "above", - BELOW: "below", - INSIDE: "inside", -} +import { DropPosition } from "@budibase/types" const initialState = { source: null, diff --git a/packages/client/src/stores/builder.ts b/packages/client/src/stores/builder.ts index 2a5d616f39..0c2577ebab 100644 --- a/packages/client/src/stores/builder.ts +++ b/packages/client/src/stores/builder.ts @@ -2,7 +2,7 @@ import { writable, get } from "svelte/store" import { API } from "api" import { devToolsStore } from "./devTools.js" import { eventStore } from "./events.js" -import { PreviewDevice } from "@budibase/types" +import { DropPosition, PreviewDevice } from "@budibase/types" interface BuilderStore { inBuilder: boolean @@ -58,19 +58,23 @@ const createBuilderStore = () => { devToolsStore.actions.setAllowSelection(false) eventStore.actions.dispatchEvent("select-component", { id }) }, - updateProp: (prop, value) => { + updateProp: (prop: string, value: any) => { eventStore.actions.dispatchEvent("update-prop", { prop, value }) }, - updateStyles: async (styles, id) => { + updateStyles: async (styles: Record, id: string) => { await eventStore.actions.dispatchEvent("update-styles", { styles, id, }) }, - keyDown: (key, ctrlKey) => { + keyDown: (key: string, ctrlKey: boolean) => { eventStore.actions.dispatchEvent("key-down", { key, ctrlKey }) }, - duplicateComponent: (id, mode = "below", selectComponent = true) => { + duplicateComponent: ( + id: string, + mode = DropPosition.BELOW, + selectComponent = true + ) => { eventStore.actions.dispatchEvent("duplicate-component", { id, mode, @@ -136,7 +140,7 @@ const createBuilderStore = () => { // Notify the builder so we can reload component definitions eventStore.actions.dispatchEvent("reload-plugin") }, - addParentComponent: (componentId, parentType) => { + addParentComponent: (componentId: any, parentType: any) => { eventStore.actions.dispatchEvent("add-parent-component", { componentId, parentType, diff --git a/packages/types/src/ui/stores/misc.ts b/packages/types/src/ui/stores/misc.ts index 275b388e9f..055ed85288 100644 --- a/packages/types/src/ui/stores/misc.ts +++ b/packages/types/src/ui/stores/misc.ts @@ -1,2 +1,8 @@ // type purely to capture structures that the type is unknown, but maybe known later export type UIObject = Record + +export const enum DropPosition { + ABOVE = "above", + BELOW = "below", + INSIDE = "inside", +}