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

View File

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

View File

@ -58,17 +58,26 @@ export interface ComponentSetting {
self: boolean 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 { export interface ComponentContext {
type: ComponentContextType type: ComponentContextType
scope: ComponentContextScopes scope?: ComponentContextScopes
actions: any[] actions?: ComponentAction[]
url?: Record<string, any> suffix?: string
query?: string values?: ComponentStaticContextValue[]
state?: Record<string, any>
} }
export type ComponentContextType = "context" | "action" export type ComponentContextType = "action" | "static" | "schema" | "form"
export const enum ComponentContextScopes { export const enum ComponentContextScopes {
Local = "local", Local = "local",

View File

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