Automatically type getContext response
This commit is contained in:
parent
fa930de15e
commit
0b73f53974
|
@ -14,7 +14,6 @@
|
||||||
GroupUserDatasource,
|
GroupUserDatasource,
|
||||||
DataFetchOptions,
|
DataFetchOptions,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { SDK, Component } from "../../index"
|
|
||||||
|
|
||||||
type ProviderDatasource = Exclude<
|
type ProviderDatasource = Exclude<
|
||||||
DataFetchDatasource,
|
DataFetchDatasource,
|
||||||
|
@ -29,8 +28,8 @@
|
||||||
export let paginate: boolean
|
export let paginate: boolean
|
||||||
export let autoRefresh: number
|
export let autoRefresh: number
|
||||||
|
|
||||||
const { styleable, Provider, ActionTypes, API } = getContext<SDK>("sdk")
|
const { styleable, Provider, ActionTypes, API } = getContext("sdk")
|
||||||
const component = getContext<Component>("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
let interval: ReturnType<typeof setInterval>
|
let interval: ReturnType<typeof setInterval>
|
||||||
let queryExtensions: Record<string, any> = {}
|
let queryExtensions: Record<string, any> = {}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
import FormBlockWrapper from "./FormBlockWrapper.svelte"
|
import FormBlockWrapper from "./FormBlockWrapper.svelte"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Component, Context, SDK } from "../../../../index"
|
|
||||||
import { TableSchema, UIDatasource } from "@budibase/types"
|
import { TableSchema, UIDatasource } from "@budibase/types"
|
||||||
|
|
||||||
type Field = { name: string; active: boolean }
|
type Field = { name: string; active: boolean }
|
||||||
|
@ -34,9 +33,9 @@
|
||||||
export let saveButtonLabel: boolean
|
export let saveButtonLabel: boolean
|
||||||
export let deleteButtonLabel: boolean
|
export let deleteButtonLabel: boolean
|
||||||
|
|
||||||
const { fetchDatasourceSchema, generateGoldenSample } = getContext<SDK>("sdk")
|
const { fetchDatasourceSchema, generateGoldenSample } = getContext("sdk")
|
||||||
const component = getContext<Component>("component")
|
const component = getContext("component")
|
||||||
const context = getContext<Context>("context")
|
const context = getContext("context")
|
||||||
|
|
||||||
let schema: TableSchema
|
let schema: TableSchema
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,14 @@
|
||||||
import { Icon } from "@budibase/bbui"
|
import { Icon } from "@budibase/bbui"
|
||||||
import MissingRequiredSetting from "./MissingRequiredSetting.svelte"
|
import MissingRequiredSetting from "./MissingRequiredSetting.svelte"
|
||||||
import MissingRequiredAncestor from "./MissingRequiredAncestor.svelte"
|
import MissingRequiredAncestor from "./MissingRequiredAncestor.svelte"
|
||||||
import { Component, SDK } from "../../index"
|
|
||||||
|
|
||||||
export let missingRequiredSettings:
|
export let missingRequiredSettings:
|
||||||
| { key: string; label: string }[]
|
| { key: string; label: string }[]
|
||||||
| undefined
|
| undefined
|
||||||
export let missingRequiredAncestors: string[] | undefined
|
export let missingRequiredAncestors: string[] | undefined
|
||||||
|
|
||||||
const component = getContext<Component>("component")
|
const component = getContext("component")
|
||||||
const { styleable, builderStore } = getContext<SDK>("sdk")
|
const { styleable, builderStore } = getContext("sdk")
|
||||||
|
|
||||||
$: styles = { ...$component.styles, normal: {}, custom: null, empty: true }
|
$: styles = { ...$component.styles, normal: {}, custom: null, empty: true }
|
||||||
$: requiredSetting = missingRequiredSettings?.[0]
|
$: requiredSetting = missingRequiredSettings?.[0]
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { Component, Context, SDK } from "."
|
||||||
|
|
||||||
|
declare module "svelte" {
|
||||||
|
function getContext(name: "sdk"): SDK
|
||||||
|
function getContext(name: "component"): Component
|
||||||
|
function getContext(name: "context"): Context
|
||||||
|
}
|
Loading…
Reference in New Issue