Split types

This commit is contained in:
Adria Navarro 2025-02-18 15:47:46 +01:00
parent 7c6e9644ca
commit e474a5ae23
4 changed files with 21 additions and 10 deletions

View File

@ -2,7 +2,7 @@
import { onMount } from "svelte"
import { Input, Label } from "@budibase/bbui"
import { previewStore, selectedScreen } from "@/stores/builder"
import type { ComponentContext } from "@budibase/types"
import type { AppContext, ComponentContext } from "@budibase/types"
export let baseRoute = ""
@ -31,7 +31,7 @@
// This function is needed to repopulate the test value from componentContext
// when a user navigates to another component and then back again
const updateTestValueFromContext = (context: ComponentContext | null) => {
const updateTestValueFromContext = (context: AppContext | null) => {
if (context?.url && !testValue) {
const { wild, ...urlParams } = context.url
const queryParams = context.query

View File

@ -1,6 +1,6 @@
import { get } from "svelte/store"
import { BudiStore } from "../BudiStore"
import { PreviewDevice, ComponentContext } from "@budibase/types"
import { PreviewDevice, ComponentContext, AppContext } from "@budibase/types"
type PreviewEventHandler = (name: string, payload?: any) => void
@ -8,7 +8,7 @@ interface PreviewState {
previewDevice: PreviewDevice
previewEventHandler: PreviewEventHandler | null
showPreview: boolean
selectedComponentContext: ComponentContext | null
selectedComponentContext: AppContext | null
}
const INITIAL_PREVIEW_STATE: PreviewState = {

View File

@ -58,17 +58,26 @@ export interface ComponentSetting {
self: boolean
}
}
interface ComponentAction {
type: string
suffix?: string
}
interface ComponentStaticContextValue {
label: string
key: string
type: string // technically this is a long list of options but there are too many to enumerate
}
export interface ComponentContext {
type: ComponentContextType
scope: ComponentContextScopes
actions: any[]
url?: Record<string, any>
query?: string
state?: Record<string, any>
scope?: ComponentContextScopes
actions?: ComponentAction[]
suffix?: string
values?: ComponentStaticContextValue[]
}
export type ComponentContextType = "context" | "action"
export type ComponentContextType = "action" | "static" | "schema" | "form"
export const enum ComponentContextScopes {
Local = "local",

View File

@ -1 +1,3 @@
export type PreviewDevice = "desktop" | "tablet" | "mobile"
export type AppContext = Record<string, any>