Type DND store and update store import aliases
This commit is contained in:
parent
a541603267
commit
790ca4737c
|
@ -1,10 +1,6 @@
|
|||
import { createAPIClient } from "@budibase/frontend-core"
|
||||
import { authStore } from "../stores/auth"
|
||||
import {
|
||||
notificationStore,
|
||||
devToolsEnabled,
|
||||
devToolsStore,
|
||||
} from "../stores/index"
|
||||
import { notificationStore, devToolsEnabled, devToolsStore } from "../stores"
|
||||
import { get } from "svelte/store"
|
||||
|
||||
export const API = createAPIClient({
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Constants, CookieUtils } from "@budibase/frontend-core"
|
||||
import { getThemeClassNames } from "@budibase/shared-core"
|
||||
import Component from "./Component.svelte"
|
||||
import SDK from "sdk"
|
||||
import SDK from "@/sdk"
|
||||
import {
|
||||
featuresStore,
|
||||
createContextStore,
|
||||
|
@ -22,26 +22,26 @@
|
|||
environmentStore,
|
||||
sidePanelStore,
|
||||
modalStore,
|
||||
} from "stores"
|
||||
import NotificationDisplay from "components/overlay/NotificationDisplay.svelte"
|
||||
import ConfirmationDisplay from "components/overlay/ConfirmationDisplay.svelte"
|
||||
import PeekScreenDisplay from "components/overlay/PeekScreenDisplay.svelte"
|
||||
import UserBindingsProvider from "components/context/UserBindingsProvider.svelte"
|
||||
import DeviceBindingsProvider from "components/context/DeviceBindingsProvider.svelte"
|
||||
import StateBindingsProvider from "components/context/StateBindingsProvider.svelte"
|
||||
import RowSelectionProvider from "components/context/RowSelectionProvider.svelte"
|
||||
import QueryParamsProvider from "components/context/QueryParamsProvider.svelte"
|
||||
import SettingsBar from "components/preview/SettingsBar.svelte"
|
||||
import SelectionIndicator from "components/preview/SelectionIndicator.svelte"
|
||||
import HoverIndicator from "components/preview/HoverIndicator.svelte"
|
||||
} from "@/stores"
|
||||
import NotificationDisplay from "./overlay/NotificationDisplay.svelte"
|
||||
import ConfirmationDisplay from "./overlay/ConfirmationDisplay.svelte"
|
||||
import PeekScreenDisplay from "./overlay/PeekScreenDisplay.svelte"
|
||||
import UserBindingsProvider from "./context/UserBindingsProvider.svelte"
|
||||
import DeviceBindingsProvider from "./context/DeviceBindingsProvider.svelte"
|
||||
import StateBindingsProvider from "./context/StateBindingsProvider.svelte"
|
||||
import RowSelectionProvider from "./context/RowSelectionProvider.svelte"
|
||||
import QueryParamsProvider from "./context/QueryParamsProvider.svelte"
|
||||
import SettingsBar from "./preview/SettingsBar.svelte"
|
||||
import SelectionIndicator from "./preview/SelectionIndicator.svelte"
|
||||
import HoverIndicator from "./preview/HoverIndicator.svelte"
|
||||
import CustomThemeWrapper from "./CustomThemeWrapper.svelte"
|
||||
import DNDHandler from "components/preview/DNDHandler.svelte"
|
||||
import GridDNDHandler from "components/preview/GridDNDHandler.svelte"
|
||||
import KeyboardManager from "components/preview/KeyboardManager.svelte"
|
||||
import DevToolsHeader from "components/devtools/DevToolsHeader.svelte"
|
||||
import DevTools from "components/devtools/DevTools.svelte"
|
||||
import FreeFooter from "components/FreeFooter.svelte"
|
||||
import MaintenanceScreen from "components/MaintenanceScreen.svelte"
|
||||
import DNDHandler from "./preview/DNDHandler.svelte"
|
||||
import GridDNDHandler from "./preview/GridDNDHandler.svelte"
|
||||
import KeyboardManager from "./preview/KeyboardManager.svelte"
|
||||
import DevToolsHeader from "./devtools/DevToolsHeader.svelte"
|
||||
import DevTools from "./devtools/DevTools.svelte"
|
||||
import FreeFooter from "./FreeFooter.svelte"
|
||||
import MaintenanceScreen from "./MaintenanceScreen.svelte"
|
||||
import SnippetsProvider from "./context/SnippetsProvider.svelte"
|
||||
import EmbedProvider from "./context/EmbedProvider.svelte"
|
||||
import DNDSelectionIndicators from "./preview/DNDSelectionIndicators.svelte"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
appStore,
|
||||
dndComponentPath,
|
||||
dndIsDragging,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
||||
import EmptyPlaceholder from "components/app/EmptyPlaceholder.svelte"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { themeStore } from "stores"
|
||||
import { themeStore } from "@/stores"
|
||||
import { setContext } from "svelte"
|
||||
import { Context } from "@budibase/bbui"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { setContext, getContext, onMount } from "svelte"
|
||||
import Router, { querystring } from "svelte-spa-router"
|
||||
import { routeStore, stateStore } from "stores"
|
||||
import { routeStore, stateStore } from "@/stores"
|
||||
import Screen from "./Screen.svelte"
|
||||
import { get } from "svelte/store"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { screenStore, routeStore, builderStore } from "stores"
|
||||
import { screenStore, routeStore, builderStore } from "@/stores"
|
||||
import { get } from "svelte/store"
|
||||
import Component from "./Component.svelte"
|
||||
import Provider from "./context/Provider.svelte"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// because it functions similarly to one
|
||||
import { getContext, onMount } from "svelte"
|
||||
import { get, derived, readable } from "svelte/store"
|
||||
import { featuresStore } from "stores"
|
||||
import { featuresStore } from "@/stores"
|
||||
import { Grid } from "@budibase/frontend-core"
|
||||
import { processStringSync } from "@budibase/string-templates"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import BlockComponent from "components/BlockComponent.svelte"
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
import { getContext, setContext } from "svelte"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
import { Utils } from "@budibase/frontend-core"
|
||||
import FormBlockWrapper from "./form/FormBlockWrapper.svelte"
|
||||
import { get, writable } from "svelte/store"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { onMount, onDestroy } from "svelte"
|
||||
import { themeStore } from "stores"
|
||||
import { themeStore } from "@/stores"
|
||||
|
||||
let width = window.innerWidth
|
||||
let height = window.innerHeight
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { getContext, setContext, onDestroy } from "svelte"
|
||||
import { dataSourceStore, createContextStore } from "stores"
|
||||
import { dataSourceStore, createContextStore } from "@/stores"
|
||||
import { ActionTypes } from "constants"
|
||||
import { generate } from "shortid"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { routeStore } from "stores"
|
||||
import { routeStore } from "@/stores"
|
||||
</script>
|
||||
|
||||
<Provider key="query" data={$routeStore.queryParams}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { rowSelectionStore } from "stores"
|
||||
import { rowSelectionStore } from "@/stores"
|
||||
</script>
|
||||
|
||||
<Provider key="rowSelection" data={$rowSelectionStore}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { snippets } from "stores"
|
||||
import { snippets } from "@/stores"
|
||||
</script>
|
||||
|
||||
<Provider key="snippets" data={$snippets}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { stateStore } from "stores"
|
||||
import { stateStore } from "@/stores"
|
||||
</script>
|
||||
|
||||
<Provider key="state" data={$stateStore}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import Provider from "./Provider.svelte"
|
||||
import { authStore, currentRole } from "stores"
|
||||
import { authStore, currentRole } from "@/stores"
|
||||
import { ActionTypes } from "constants"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import { Layout, Heading, Tabs, Tab, Icon } from "@budibase/bbui"
|
||||
import DevToolsStatsTab from "./DevToolsStatsTab.svelte"
|
||||
import DevToolsComponentTab from "./DevToolsComponentTab.svelte"
|
||||
import { devToolsStore } from "stores"
|
||||
import { devToolsStore } from "@/stores"
|
||||
|
||||
const context = getContext("context")
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Layout, Select, Body } from "@budibase/bbui"
|
||||
import { componentStore } from "stores/index.js"
|
||||
import { componentStore } from "stores/index.ts"
|
||||
import DevToolsStat from "./DevToolsStat.svelte"
|
||||
|
||||
const ReadableBindingMap = {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Layout, Toggle } from "@budibase/bbui"
|
||||
import { getSettingsDefinition } from "@budibase/frontend-core"
|
||||
import DevToolsStat from "./DevToolsStat.svelte"
|
||||
import { componentStore } from "stores/index.js"
|
||||
import { componentStore } from "stores/index.ts"
|
||||
|
||||
let showEnrichedSettings = true
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Body, Layout, Heading, Button, Tabs, Tab } from "@budibase/bbui"
|
||||
import { builderStore, devToolsStore, componentStore } from "stores"
|
||||
import { builderStore, devToolsStore, componentStore } from "@/stores"
|
||||
import DevToolsStat from "./DevToolsStat.svelte"
|
||||
import DevToolsComponentSettingsTab from "./DevToolsComponentSettingsTab.svelte"
|
||||
import DevToolsComponentContextTab from "./DevToolsComponentContextTab.svelte"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Heading, Select, ActionButton } from "@budibase/bbui"
|
||||
import { devToolsStore, appStore } from "../../stores"
|
||||
import { devToolsStore, appStore } from "stores"
|
||||
import { getContext, onMount } from "svelte"
|
||||
import { API } from "api"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
import { notificationStore } from "stores"
|
||||
import { notificationStore } from "@/stores"
|
||||
|
||||
export let label
|
||||
export let value
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Layout } from "@budibase/bbui"
|
||||
import { authStore, appStore, screenStore, componentStore } from "stores"
|
||||
import { authStore, appStore, screenStore, componentStore } from "@/stores"
|
||||
import DevToolsStat from "./DevToolsStat.svelte"
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { confirmationStore } from "stores"
|
||||
import { confirmationStore } from "@/stores"
|
||||
import { Modal, ModalContent } from "@budibase/bbui"
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { notificationStore } from "stores"
|
||||
import { notificationStore } from "@/stores"
|
||||
import { Notification } from "@budibase/bbui"
|
||||
import { fly } from "svelte/transition"
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
notificationStore,
|
||||
routeStore,
|
||||
stateStore,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { Modal, ModalContent, ActionButton } from "@budibase/bbui"
|
||||
import { onDestroy } from "svelte"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
dndSource,
|
||||
dndIsDragging,
|
||||
isGridScreen,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { Utils } from "@budibase/frontend-core"
|
||||
import { findComponentById } from "@/utils/components.js"
|
||||
import { isGridEvent } from "@/utils/grid"
|
||||
|
@ -266,7 +266,7 @@
|
|||
source.type,
|
||||
drop.parent,
|
||||
drop.index,
|
||||
$dndStore.meta.newComponentProps
|
||||
$dndStore.source?.props
|
||||
)
|
||||
dropping = false
|
||||
stopDragging()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { isGridScreen, dndParent, dndSource, dndIsDragging } from "@/stores"
|
||||
import { isGridScreen, dndParent, dndSource, dndIsDragging } from "stores"
|
||||
import { DNDPlaceholderID } from "@/constants"
|
||||
import IndicatorSet from "./IndicatorSet.svelte"
|
||||
</script>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
dndStore,
|
||||
dndSource,
|
||||
isGridScreen,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { Utils, memo } from "@budibase/frontend-core"
|
||||
import { DNDPlaceholderID, GridRowHeight } from "@/constants"
|
||||
import {
|
||||
|
@ -54,7 +54,7 @@
|
|||
// real component to render in the new position before updating the DND
|
||||
// store, preventing the green DND overlay from being out of position
|
||||
if ($dndSource?.isNew && styles) {
|
||||
dndStore.actions.updateNewComponentProps({
|
||||
dndStore.actions.updateSourceProps({
|
||||
_styles: {
|
||||
normal: styles,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { onDestroy, getContext } from "svelte"
|
||||
import { builderStore, componentStore, screenStore } from "stores"
|
||||
import { builderStore, componentStore, screenStore } from "@/stores"
|
||||
import { Utils, memo } from "@budibase/frontend-core"
|
||||
import { GridRowHeight } from "constants"
|
||||
import { GridParams, getGridVar, Devices } from "utils/grid"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Icon } from "@budibase/bbui"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
|
||||
export let style
|
||||
export let value
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { onMount, onDestroy } from "svelte"
|
||||
import { get } from "svelte/store"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
|
||||
onMount(() => {
|
||||
if (get(builderStore).inBuilder) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { dndIsDragging, builderStore } from "@/stores"
|
||||
import { dndIsDragging, builderStore } from "stores"
|
||||
import IndicatorSet from "./IndicatorSet.svelte"
|
||||
|
||||
$: color = $builderStore.editMode
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import GridStylesButton from "./GridStylesButton.svelte"
|
||||
import SettingsColorPicker from "./SettingsColorPicker.svelte"
|
||||
import SettingsPicker from "./SettingsPicker.svelte"
|
||||
import { builderStore, componentStore, dndIsDragging } from "stores"
|
||||
import { builderStore, componentStore, dndIsDragging } from "@/stores"
|
||||
import { Utils, shouldDisplaySetting } from "@budibase/frontend-core"
|
||||
import { getGridVar, GridParams, Devices } from "utils/grid"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Icon } from "@budibase/bbui"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
import { createEventDispatcher } from "svelte"
|
||||
|
||||
export let prop
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { ColorPicker } from "@budibase/bbui"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
|
||||
export let prop
|
||||
export let component
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { Select } from "@budibase/bbui"
|
||||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
|
||||
export let prop
|
||||
export let options
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
eventStore,
|
||||
hoverStore,
|
||||
stateStore,
|
||||
} from "@/stores"
|
||||
} from "stores"
|
||||
import { get } from "svelte/store"
|
||||
import { initWebsocket } from "@/websocket"
|
||||
import { APIClient } from "@budibase/frontend-core"
|
||||
|
@ -163,12 +163,7 @@ const loadBudibase = async () => {
|
|||
} else if (type === "dragging-new-component") {
|
||||
const { dragging, component } = data
|
||||
if (dragging) {
|
||||
const definition =
|
||||
componentStore.actions.getComponentDefinition(component)
|
||||
dndStore.actions.startDraggingNewComponent({
|
||||
component,
|
||||
definition,
|
||||
})
|
||||
dndStore.actions.startDraggingNewComponent(component)
|
||||
} else {
|
||||
dndStore.actions.reset()
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
appStore,
|
||||
stateStore,
|
||||
createContextStore,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { styleable } from "utils/styleable"
|
||||
import { linkable } from "utils/linkable"
|
||||
import { getAction } from "utils/getAction"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { derived } from "svelte/store"
|
||||
import { findComponentPathById } from "utils/components.js"
|
||||
import { dndParent } from "../dnd.js"
|
||||
import { dndParent } from "../dnd.ts"
|
||||
import { screenStore } from "../screens.js"
|
||||
|
||||
export const dndComponentPath = derived(
|
||||
|
|
|
@ -1,54 +1,65 @@
|
|||
import { writable, get } from "svelte/store"
|
||||
import { derivedMemo } from "@budibase/frontend-core"
|
||||
import { screenStore, isGridScreen } from "@/stores"
|
||||
import { screenStore, isGridScreen, componentStore } from "stores/index"
|
||||
import { ScreenslotID } from "@/constants"
|
||||
import { ComponentDefinition } from "@budibase/types"
|
||||
|
||||
interface DNDSource {
|
||||
id?: string
|
||||
parent?: string
|
||||
index?: number
|
||||
bounds: {
|
||||
height: number
|
||||
width: number
|
||||
}
|
||||
name: string
|
||||
icon: string
|
||||
type: string
|
||||
isNew: boolean
|
||||
props?: Record<string, any>
|
||||
}
|
||||
|
||||
interface DNDTarget {
|
||||
id: string
|
||||
parent: string
|
||||
empty: boolean
|
||||
acceptsChildren: boolean
|
||||
node?: Node
|
||||
}
|
||||
|
||||
interface DNDDrop {
|
||||
parent: string
|
||||
index: number
|
||||
}
|
||||
|
||||
interface DNDState {
|
||||
source?: DNDSource
|
||||
target?: DNDTarget
|
||||
drop?: DNDDrop
|
||||
}
|
||||
|
||||
const createDndStore = () => {
|
||||
const initialState = {
|
||||
// Info about the dragged component
|
||||
source: null,
|
||||
const store = writable<DNDState>({})
|
||||
|
||||
// Info about the target component being hovered over
|
||||
target: null,
|
||||
|
||||
// Info about where the component would be dropped
|
||||
drop: null,
|
||||
|
||||
// Metadata about the event
|
||||
meta: {
|
||||
newComponentProps: null,
|
||||
},
|
||||
}
|
||||
const store = writable(initialState)
|
||||
|
||||
const startDraggingExistingComponent = ({
|
||||
id,
|
||||
parent,
|
||||
bounds,
|
||||
index,
|
||||
name,
|
||||
icon,
|
||||
}) => {
|
||||
const startDraggingExistingComponent = (source: Omit<DNDSource, "isNew">) => {
|
||||
store.set({
|
||||
...initialState,
|
||||
source: { id, parent, bounds, index, name, icon, isNew: false },
|
||||
source: {
|
||||
...source,
|
||||
isNew: false,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const startDraggingNewComponent = ({ component, definition }) => {
|
||||
if (!component) {
|
||||
return
|
||||
}
|
||||
|
||||
const startDraggingNewComponent = (type: string) => {
|
||||
// On grid screens, we already know exactly where to insert the component
|
||||
let target, drop
|
||||
const screen = get(screenStore)?.activeScreen
|
||||
let target: DNDTarget | undefined = undefined
|
||||
let drop: DNDDrop | undefined = undefined
|
||||
if (get(isGridScreen)) {
|
||||
const id = screen?.props?._id
|
||||
const screen = get(screenStore)?.activeScreen
|
||||
const id = screen.props._id
|
||||
target = {
|
||||
id,
|
||||
parent: ScreenslotID,
|
||||
node: null,
|
||||
empty: false,
|
||||
acceptsChildren: true,
|
||||
}
|
||||
|
@ -59,52 +70,55 @@ const createDndStore = () => {
|
|||
}
|
||||
|
||||
// Get size of new component so we can show a properly sized placeholder
|
||||
const definition: ComponentDefinition =
|
||||
componentStore.actions.getComponentDefinition(type)
|
||||
const width = definition?.size?.width || 128
|
||||
const height = definition?.size?.height || 64
|
||||
|
||||
store.set({
|
||||
...initialState,
|
||||
source: {
|
||||
id: null,
|
||||
parent: null,
|
||||
bounds: { height, width },
|
||||
index: null,
|
||||
type: component,
|
||||
type,
|
||||
isNew: true,
|
||||
name: `New ${definition.name}`,
|
||||
icon: definition.icon,
|
||||
name: `New ${definition?.name || "component"}`,
|
||||
icon: definition?.icon || "Selection",
|
||||
},
|
||||
target,
|
||||
drop,
|
||||
})
|
||||
}
|
||||
|
||||
const updateTarget = ({ id, parent, node, empty, acceptsChildren }) => {
|
||||
const updateTarget = (target: DNDTarget) => {
|
||||
store.update(state => {
|
||||
state.target = { id, parent, node, empty, acceptsChildren }
|
||||
state.target = target
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
const updateDrop = ({ parent, index }) => {
|
||||
const updateDrop = (drop: DNDDrop) => {
|
||||
store.update(state => {
|
||||
state.drop = { parent, index }
|
||||
state.drop = drop
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
const reset = () => {
|
||||
store.set(initialState)
|
||||
store.set({})
|
||||
}
|
||||
|
||||
const updateNewComponentProps = newComponentProps => {
|
||||
store.update(state => ({
|
||||
...state,
|
||||
meta: {
|
||||
...state.meta,
|
||||
newComponentProps,
|
||||
},
|
||||
}))
|
||||
const updateSourceProps = (props: Record<string, any>) => {
|
||||
store.update(state => {
|
||||
if (!state.source) {
|
||||
return state
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
source: {
|
||||
...state.source,
|
||||
props,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -115,7 +129,7 @@ const createDndStore = () => {
|
|||
updateTarget,
|
||||
updateDrop,
|
||||
reset,
|
||||
updateNewComponentProps,
|
||||
updateSourceProps,
|
||||
},
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ import { routeStore } from "./routes"
|
|||
import { builderStore } from "./builder"
|
||||
import { appStore } from "./app"
|
||||
import { orgStore } from "./org"
|
||||
import { dndIndex, dndParent, dndSource } from "./dnd.js"
|
||||
import { dndIndex, dndParent, dndSource } from "./dnd.ts"
|
||||
import { RoleUtils } from "@budibase/frontend-core"
|
||||
import { findComponentById, findComponentParent } from "../utils/components.js"
|
||||
import { Helpers } from "@budibase/bbui"
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
rowSelectionStore,
|
||||
sidePanelStore,
|
||||
modalStore,
|
||||
} from "stores"
|
||||
} from "@/stores"
|
||||
import { API } from "api"
|
||||
import { ActionTypes } from "constants"
|
||||
import { enrichDataBindings } from "./enrichDataBinding"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { builderStore } from "stores"
|
||||
import { builderStore } from "@/stores"
|
||||
|
||||
/**
|
||||
* Helper to build a CSS string from a style object.
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
builderStore,
|
||||
environmentStore,
|
||||
notificationStore,
|
||||
} from "./stores/index.js"
|
||||
import { builderStore, environmentStore, notificationStore } from "stores"
|
||||
import { get } from "svelte/store"
|
||||
import { createWebsocket } from "@budibase/frontend-core"
|
||||
|
||||
|
|
|
@ -23,6 +23,11 @@ export interface ComponentDefinition {
|
|||
legalDirectChildren: string[]
|
||||
requiredAncestors?: string[]
|
||||
illegalChildren: string[]
|
||||
icon?: string
|
||||
size?: {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface ComponentSetting {
|
||||
|
|
Loading…
Reference in New Issue