import { ReactElement, CSSProperties, ReactNode, JSX } from 'react'; type ItemSelector = { index: number; zone?: string; }; type FieldOption = { label: string; value: string | number | boolean | undefined | null | object; }; type FieldOptions = Array | ReadonlyArray; type BaseField = { label?: string; labelIcon?: ReactElement; metadata?: Metadata; visible?: boolean; }; type TextField = BaseField & { type: "text"; placeholder?: string; contentEditable?: boolean; }; type NumberField = BaseField & { type: "number"; placeholder?: string; min?: number; max?: number; step?: number; }; type TextareaField = BaseField & { type: "textarea"; placeholder?: string; contentEditable?: boolean; }; type SelectField = BaseField & { type: "select"; options: FieldOptions; }; type RadioField = BaseField & { type: "radio"; options: FieldOptions; }; type ArrayField = BaseField & { type: "array"; arrayFields: { [SubPropName in keyof Props[0]]: UserField extends { type: PropertyKey; } ? Field | UserField : Field; }; defaultItemProps?: Props[0]; getItemSummary?: (item: Props[0], index?: number) => string; max?: number; min?: number; }; type ObjectField = BaseField & { type: "object"; objectFields: { [SubPropName in keyof Props]: UserField extends { type: PropertyKey; } ? Field | UserField : Field; }; }; type Adaptor = {}, PropShape = TableShape> = { name: string; fetchList: (adaptorParams?: AdaptorParams) => Promise; mapProp?: (value: TableShape) => PropShape; }; type NotUndefined = T extends undefined ? never : T; type ExternalFieldWithAdaptor = BaseField & { type: "external"; placeholder?: string; adaptor: Adaptor; adaptorParams?: object; getItemSummary: (item: NotUndefined, index?: number) => string; }; type ExternalField = BaseField & { type: "external"; placeholder?: string; fetchList: (params: { query: string; filters: Record; }) => Promise; mapProp?: (value: any) => Props; mapRow?: (value: any) => Record; getItemSummary?: (item: NotUndefined, index?: number) => string; showSearch?: boolean; renderFooter?: (props: { items: any[]; }) => ReactElement; initialQuery?: string; filterFields?: Record; initialFilters?: Record; }; type CustomFieldRender = (props: { field: CustomField; name: string; id: string; value: Value; onChange: (value: Value) => void; readOnly?: boolean; }) => ReactElement; type CustomField = BaseField & { type: "custom"; render: CustomFieldRender; contentEditable?: boolean; }; type SlotField = BaseField & { type: "slot"; allow?: string[]; disallow?: string[]; }; type Field = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField | ObjectField | ExternalField | ExternalFieldWithAdaptor | CustomField | SlotField; type Fields = { [PropName in keyof Omit]: UserField extends { type: PropertyKey; } ? Field | UserField : Field; }; type FieldProps, ValueType = any> = { field: F; value: ValueType; id?: string; onChange: (value: ValueType, uiState?: Partial) => void; readOnly?: boolean; }; type DropZoneProps = { zone: string; allow?: string[]; disallow?: string[]; style?: CSSProperties; minEmptyHeight?: number; className?: string; collisionAxis?: DragAxis; }; type PuckContext = { renderDropZone: React.FC; metadata: Metadata; isEditing: boolean; dragRef: ((element: Element | null) => void) | null; }; type DefaultRootFieldProps = { title?: string; }; type DefaultRootRenderProps = WithPuckProps>; type DefaultRootProps = DefaultRootRenderProps; type DefaultComponentProps = { [key: string]: any; }; type WithId = Props & { id: string; }; type WithPuckProps = Props & { puck: PuckContext; editMode?: boolean; }; type AsFieldProps = Omit; type WithChildren = Props & { children: ReactNode; }; type UserGenerics = ExtractConfigParams, UserData extends Data | Data = Data, UserAppState extends PrivateAppState = PrivateAppState, UserPublicAppState extends AppState = AppState, UserComponentData extends ComponentData = UserData["content"][0]> = { UserConfig: UserConfig; UserParams: UserParams; UserProps: UserParams["props"]; UserRootProps: UserParams["rootProps"] & DefaultRootFieldProps; UserData: UserData; UserAppState: UserAppState; UserPublicAppState: UserPublicAppState; UserComponentData: UserComponentData; UserField: UserParams["field"]; }; type ExtractField = Extract; type SlotComponent = (props?: Omit) => ReactNode; type PuckComponent = (props: WithId; }>>) => JSX.Element; type ResolveDataTrigger = "insert" | "replace" | "load" | "force"; type WithPartialProps = Omit & { props?: Partial; }; type ComponentConfigInternal, "type">, // NB this doesn't include AllProps, so types will not contain deep slot types. To fix, we require a breaking change. UserField extends BaseField = {}> = { render: PuckComponent; label?: string; defaultProps?: FieldProps; fields?: Fields; permissions?: Partial; inline?: boolean; resolveFields?: (data: DataShape, params: { changed: Partial & { id: string; }>; fields: Fields; lastFields: Fields; lastData: DataShape | null; appState: AppState; parent: ComponentData | null; }) => Promise> | Fields; resolveData?: (data: DataShape, params: { changed: Partial & { id: string; }>; lastData: DataShape | null; metadata: Metadata; trigger: ResolveDataTrigger; }) => Promise> | WithPartialProps; resolvePermissions?: (data: DataShape, params: { changed: Partial & { id: string; }>; lastPermissions: Partial; permissions: Partial; appState: AppState; lastData: DataShape | null; }) => Promise> | Partial; metadata?: Metadata; }; type ComponentConfig = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends { props: any; } ? RenderPropsOrParams["props"] : RenderPropsOrParams, DataShape = Omit, "type">> = RenderPropsOrParams extends ComponentConfigParams ? ComponentConfigInternal : RenderPropsOrParams extends ComponentConfigParams ? ComponentConfigInternal : ComponentConfigInternal; type RootConfigInternal = Partial, AsFieldProps, RootData>, UserField>>; type RootConfig = DefaultComponentProps> = RootPropsOrParams extends ComponentConfigParams ? Partial, {}>> : RootPropsOrParams extends ComponentConfigParams ? Partial, UserFields[keyof UserFields] & BaseField>> : Partial>>; type Category = { components?: ComponentName[]; title?: string; visible?: boolean; defaultExpanded?: boolean; }; type ConfigInternal = { categories?: Record> & { other?: Category; }; components: { [ComponentName in keyof Props]: Omit, "type">, UserField>, "type">; }; root?: RootConfigInternal; }; type DefaultComponents = Record; type Config = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams ? ConfigInternal : PropsOrParams extends ConfigParams ? ConfigInternal : PropsOrParams extends ConfigParams ? ConfigInternal : ConfigInternal; type ExtractConfigParams = UserConfig extends ConfigInternal ? { props: PropsOrParams; rootProps: RootProps & DefaultRootFieldProps; categoryNames: CategoryName; field: UserField extends { type: string; } ? UserField : Field; } : never; type BaseData = { readOnly?: Partial>; }; type RootDataWithProps = BaseData & { props: Props; }; type RootDataWithoutProps = Props; type RootData = Partial>> & Partial>; type ComponentData = Record> = { type: Name; props: WithDeepSlots, Content>; } & BaseData; type ComponentDataOptionalId = { type: Name; props: Props & { id?: string; }; } & BaseData; type MappedItem = ComponentData; type ComponentDataMap = { [K in keyof Components]: ComponentData; }[keyof Components]; type Content = ComponentDataMap[]; type Data = { root: WithDeepSlots, Content>; content: Content; zones?: Record>; }; type Metadata = { [key: string]: any; }; type ItemWithId = { _arrayId: string; _originalIndex: number; }; type ArrayState = { items: ItemWithId[]; openId: string; }; type UiState = { leftSideBarVisible: boolean; rightSideBarVisible: boolean; leftSideBarWidth?: number | null; rightSideBarWidth?: number | null; itemSelector: ItemSelector | null; arrayState: Record; previewMode: "interactive" | "edit"; componentList: Record; isDragging: boolean; viewports: { current: { width: number; height: number | "auto"; }; controlsVisible: boolean; options: Viewport[]; }; field: { focus?: string | null; }; }; type AppState = { data: UserData; ui: UiState; }; type ZoneType = "root" | "dropzone" | "slot"; type PuckNodeData = { data: ComponentData; flatData: ComponentData; parentId: string | null; zone: string; path: string[]; }; type PuckZoneData = { contentIds: string[]; type: ZoneType; }; type NodeIndex = Record; type ZoneIndex = Record; type PrivateAppState = AppState & { indexes: { nodes: NodeIndex; zones: ZoneIndex; }; }; type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined; /** * Recursively walk T and replace Slots with SlotComponents */ type WithDeepSlots = T extends Slot ? SlotType : T extends (infer U)[] ? Array> : T extends (infer U)[] ? WithDeepSlots[] : T extends BuiltinTypes ? T : T extends object ? { [K in keyof T]: WithDeepSlots; } : T; type ConfigParams = { components?: Components; root?: RootProps; categories?: CategoryNames; fields?: AssertHasValue; }; type FieldsExtension = { [Type in string]: { type: Type; }; }; type ComponentConfigParams = { props: Props; fields?: AssertHasValue; }; type Exact = Record, never>; type LeftOrExactRight = (Left & Union extends Right ? Exact : Left) | (Right & Exact); type AssertHasValue = [keyof T] extends [ never ] ? False : True; type MapFnParams = { value: any; parentId: string; propName: string; field: ThisField; propPath: string; }; type FieldTransformFnParams = Omit, "parentId"> & { isReadOnly: boolean; componentId: string; }; type FieldTransformFn = (params: FieldTransformFnParams) => any; type FieldTransforms, // Setting fields: {} helps TS choose default field types G extends UserGenerics = UserGenerics, UserField extends { type: string; } = Field | G["UserField"]> = Partial<{ [Type in UserField["type"]]: FieldTransformFn>; }>; type RenderFunc = (props: Props) => ReactElement; declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"]; type OverrideKey = (typeof overrideKeys)[number]; type OverridesGeneric = Shape; type Overrides = OverridesGeneric<{ fieldTypes: Partial>; header: RenderFunc<{ actions: ReactNode; children: ReactNode; }>; actionBar: RenderFunc<{ label?: string; children: ReactNode; parentAction: ReactNode; }>; headerActions: RenderFunc<{ children: ReactNode; }>; preview: RenderFunc; fields: RenderFunc<{ children: ReactNode; isLoading: boolean; itemSelector?: ItemSelector | null; }>; fieldLabel: RenderFunc<{ children?: ReactNode; icon?: ReactNode; label: string; el?: "label" | "div"; readOnly?: boolean; className?: string; }>; components: RenderFunc; componentItem: RenderFunc<{ children: ReactNode; name: string; }>; drawer: RenderFunc; drawerItem: RenderFunc<{ children: ReactNode; name: string; }>; iframe: RenderFunc<{ children: ReactNode; document?: Document; }>; outline: RenderFunc; componentOverlay: RenderFunc<{ children: ReactNode; hover: boolean; isSelected: boolean; componentId: string; componentType: string; }>; puck: RenderFunc; }>; type FieldRenderFunctions = UserGenerics, UserField extends { type: string; } = Field | G["UserField"]> = Omit<{ [Type in UserField["type"]]: React.FunctionComponent, any> & { children: ReactNode; name: string; }>; }, "custom">; type Direction = "left" | "right" | "up" | "down" | null; type DragAxis = "dynamic" | "y" | "x"; type iconTypes = "Smartphone" | "Monitor" | "Tablet"; type Viewport = { width: number; height?: number | "auto"; label?: string; icon?: iconTypes | ReactNode; }; type Viewports = Viewport[]; type Permissions = { drag: boolean; duplicate: boolean; delete: boolean; edit: boolean; insert: boolean; } & Record; type IframeConfig = { enabled?: boolean; waitForStyles?: boolean; }; type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void; type Plugin = { overrides?: Partial>; fieldTransforms?: FieldTransforms; }; type History = { state: D; id?: string; }; type InitialHistoryAppend> = { histories: History[]; index?: number; appendData?: true; }; type InitialHistoryNoAppend> = { histories: [History, ...History[]]; index?: number; appendData?: false; }; type InitialHistory> = InitialHistoryAppend | InitialHistoryNoAppend; type Slot = { [K in keyof Props]: ComponentDataOptionalId; }[keyof Props][]; type WithSlotProps, Components extends DefaultComponents = DefaultComponents, SlotType extends Content = Content> = WithDeepSlots; type InsertAction = { type: "insert"; componentType: string; destinationIndex: number; destinationZone: string; id?: string; }; type DuplicateAction = { type: "duplicate"; sourceIndex: number; sourceZone: string; }; type ReplaceAction = { type: "replace"; destinationIndex: number; destinationZone: string; data: ComponentData; ui?: Partial["ui"]>; }; type ReplaceRootAction = { type: "replaceRoot"; root: RootData; ui?: Partial["ui"]>; }; type ReorderAction = { type: "reorder"; sourceIndex: number; destinationIndex: number; destinationZone: string; }; type MoveAction = { type: "move"; sourceIndex: number; sourceZone: string; destinationIndex: number; destinationZone: string; }; type RemoveAction = { type: "remove"; index: number; zone: string; }; type SetUiAction = { type: "setUi"; ui: Partial | ((previous: UiState) => Partial); }; type SetDataAction = { type: "setData"; data: Partial | ((previous: Data) => Partial); }; type SetAction = { type: "set"; state: Partial> | ((previous: PrivateAppState) => Partial>); }; type RegisterZoneAction = { type: "registerZone"; zone: string; }; type UnregisterZoneAction = { type: "unregisterZone"; zone: string; }; type PuckAction = { recordHistory?: boolean; } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction); type MigrationOptions = { migrateDynamicZonesForComponent?: { [ComponentName in keyof UserConfig["components"]]: (props: WithId["UserProps"][ComponentName]>, zones: Record) => ComponentData["props"]; }; }; declare function migrate(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions): Data; type PropTransform = Partial<{ [ComponentName in keyof Components]: (props: Components[ComponentName] & { [key: string]: any; }) => Components[ComponentName]; } & { root: (props: RootProps & { [key: string]: any; }) => RootProps; }>; declare function transformProps(data: Partial, propTransforms: PropTransform, config?: Config): Data; declare function resolveAllData = DefaultRootFieldProps>(data: Partial, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise>; type WalkTreeOptions = { parentId: string; propName: string; }; declare function walkTree = UserGenerics>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T; export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type ExternalField as a9, type CustomFieldRender as aa, type CustomField as ab, type SlotField as ac, type PuckContext as ad, type DefaultRootFieldProps as ae, type DefaultRootRenderProps as af, type DefaultRootProps as ag, type DefaultComponentProps as ah, type WithId as ai, type WithPuckProps as aj, type AsFieldProps as ak, type WithChildren as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };