UNPKG

@chief-editor/runtime

Version:

React Runtime for Flow Editor

48 lines (47 loc) 1.95 kB
import { DomNode } from '@co-hooks/dom-node'; import { FunctionAny } from '@co-hooks/util'; import { CSSProperties, FC, ReactNode, SyntheticEvent } from 'react'; import { IBoardNodeType, IBrickInstance, IBrickNodeType, INodeType } from '@chief-editor/base'; import { BrickEnv } from '@chief-editor/types'; export declare type IRuntimeBrickRenderProps = Omit<IBrickNodeType, 'type'> & { node: DomNode<INodeType>; }; export interface IRuntimeBoardRenderProps extends IBoardNodeType { style?: CSSProperties; className?: string; children?: ReactNode; node: DomNode<INodeType>; } export interface IRuntimeBrickProps<V, DS, DP, CG, ST> extends Omit<IBrickInstance<V, DS, DP, CG, ST>, 'layout' | 'styles'> { styles: CSSProperties; layout: CSSProperties; setValue: (value: V) => void; setState: (value: Partial<ST>) => void; dispatchEvent(e: SyntheticEvent): void; dispatchEvent(name: string, param?: any): void; renderPart: (name: string, style?: CSSProperties, className?: string) => ReactNode; getDatasource: (data: unknown) => void; getHook: (name: string) => FunctionAny | null; getByExpression(...expression: Array<string | number>): any; } export interface IRuntimeBrickContainerRenderProps { brickId: string; style?: CSSProperties; className?: string; children?: ReactNode; node: DomNode<INodeType>; } export interface IRuntimeContext { BrickRender: FC<IRuntimeBrickRenderProps>; BrickContainerRender?: FC<IRuntimeBrickContainerRenderProps>; BrickContainers?: Record<string, FC<IRuntimeBrickContainerRenderProps>>; BoardRender: FC<IRuntimeBoardRenderProps>; Bricks: Record<string, FC<IRuntimeBrickPropsGlobal>>; env?: BrickEnv; } export interface IRuntimeDispatcherProps { node: DomNode<INodeType>; style?: CSSProperties; className?: string; } export declare type IRuntimeBrickPropsGlobal = IRuntimeBrickProps<any, any, any, any, any>;