Move utils and types
This commit is contained in:
parent
141fc902c3
commit
ea2b7b8791
|
@ -32,6 +32,8 @@ import {
|
||||||
import { BudiStore } from "../BudiStore"
|
import { BudiStore } from "../BudiStore"
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
import {
|
import {
|
||||||
|
ComponentDefinition,
|
||||||
|
ComponentSetting,
|
||||||
Component as ComponentType,
|
Component as ComponentType,
|
||||||
FieldType,
|
FieldType,
|
||||||
Screen,
|
Screen,
|
||||||
|
@ -53,30 +55,6 @@ export interface ComponentState {
|
||||||
selectedScreenId?: string | null
|
selectedScreenId?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComponentDefinition {
|
|
||||||
component: string
|
|
||||||
name: string
|
|
||||||
friendlyName?: string
|
|
||||||
hasChildren?: boolean
|
|
||||||
settings?: ComponentSetting[]
|
|
||||||
features?: Record<string, boolean>
|
|
||||||
typeSupportPresets?: Record<string, any>
|
|
||||||
legalDirectChildren: string[]
|
|
||||||
requiredAncestors?: string[]
|
|
||||||
illegalChildren: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ComponentSetting {
|
|
||||||
key: string
|
|
||||||
type: string
|
|
||||||
section?: string
|
|
||||||
name?: string
|
|
||||||
defaultValue?: any
|
|
||||||
selectAllFields?: boolean
|
|
||||||
resetOn?: string | string[]
|
|
||||||
settings?: ComponentSetting[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const INITIAL_COMPONENTS_STATE: ComponentState = {
|
export const INITIAL_COMPONENTS_STATE: ComponentState = {
|
||||||
components: {},
|
components: {},
|
||||||
customComponents: [],
|
customComponents: [],
|
||||||
|
|
|
@ -97,26 +97,3 @@ export const propsUseBinding = (props, bindingKey) => {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the definition of this component's settings from the manifest
|
|
||||||
*/
|
|
||||||
export const getSettingsDefinition = definition => {
|
|
||||||
if (!definition) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
let settings = []
|
|
||||||
definition.settings?.forEach(setting => {
|
|
||||||
if (setting.section) {
|
|
||||||
settings = settings.concat(
|
|
||||||
(setting.settings || [])?.map(childSetting => ({
|
|
||||||
...childSetting,
|
|
||||||
sectionDependsOn: setting.dependsOn,
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
settings.push(setting)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return settings
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { ComponentDefinition, ComponentSetting } from "@budibase/types"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the definition of this component's settings from the manifest
|
||||||
|
*/
|
||||||
|
export const getSettingsDefinition = (
|
||||||
|
definition: ComponentDefinition
|
||||||
|
): ComponentSetting[] => {
|
||||||
|
if (!definition) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let settings: ComponentSetting[] = []
|
||||||
|
definition.settings?.forEach(setting => {
|
||||||
|
if (setting.section) {
|
||||||
|
settings = settings.concat(
|
||||||
|
(setting.settings || [])?.map(childSetting => ({
|
||||||
|
...childSetting,
|
||||||
|
sectionDependsOn: setting.dependsOn,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
settings.push(setting)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return settings
|
||||||
|
}
|
|
@ -13,3 +13,4 @@ export * from "./download"
|
||||||
export * from "./settings"
|
export * from "./settings"
|
||||||
export * from "./relatedColumns"
|
export * from "./relatedColumns"
|
||||||
export * from "./table"
|
export * from "./table"
|
||||||
|
export * from "./components"
|
||||||
|
|
|
@ -1,3 +1,33 @@
|
||||||
export * from "./sidepanel"
|
export * from "./sidepanel"
|
||||||
export * from "./codeEditor"
|
export * from "./codeEditor"
|
||||||
export * from "./errors"
|
export * from "./errors"
|
||||||
|
|
||||||
|
export interface ComponentDefinition {
|
||||||
|
component: string
|
||||||
|
name: string
|
||||||
|
friendlyName?: string
|
||||||
|
hasChildren?: boolean
|
||||||
|
settings?: ComponentSetting[]
|
||||||
|
features?: Record<string, boolean>
|
||||||
|
typeSupportPresets?: Record<string, any>
|
||||||
|
legalDirectChildren: string[]
|
||||||
|
requiredAncestors?: string[]
|
||||||
|
illegalChildren: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ComponentSetting {
|
||||||
|
key: string
|
||||||
|
type: string
|
||||||
|
section?: string
|
||||||
|
name?: string
|
||||||
|
defaultValue?: any
|
||||||
|
selectAllFields?: boolean
|
||||||
|
resetOn?: string | string[]
|
||||||
|
settings?: ComponentSetting[]
|
||||||
|
dependsOn?:
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
setting: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue