import { ReactElement } from 'react'; import { IPublicTypeNodeSchema, IPublicTypePropsMap, IPublicTypePropsList, IPublicTypeNodeData, IPublicTypeI18nData, IPublicTypeSlotSchema, IPublicTypePageSchema, IPublicTypeComponentSchema, IPublicTypeCompositeValue, GlobalEvent, IPublicModelNode, IPublicEnumTransformStage, IPublicTypeDisposable, IBaseModelNode } from '@alilc/lowcode-types'; import type { ISettingTopEntry } from '@alilc/lowcode-designer'; import { Props, IProps } from './props/props'; import type { IDocumentModel } from '../document-model'; import { INodeChildren } from './node-children'; import type { IProp } from './props/prop'; import type { IComponentMeta } from '../../component-meta'; import type { IExclusiveGroup } from './exclusive-group'; import { NodeRemoveOptions } from '../../types'; export interface NodeStatus { locking: boolean; pseudo: boolean; inPlaceEditing: boolean; } export interface IBaseNode extends Node { } /** * 基础节点 * * [Node Properties] * componentName: Page/Block/Component * props * children * * [Directives] * loop * loopArgs * condition * ------- addition support ----- * conditionGroup use for condition, for exclusive * title display on outline * ignored ignore this node will not publish to render, but will store * isLocked can not select/hover/ item on canvas and outline * hidden not visible on canvas * slotArgs like loopArgs, for slot node * * 根容器节点 * * [Node Properties] * componentName: Page/Block/Component * props * children * * [Root Container Extra Properties] * fileName * meta * state * defaultProps * dataSource * lifeCycles * methods * css * * [Directives **not used**] * loop * loopArgs * condition * ------- future support ----- * conditionGroup * title * ignored * isLocked * hidden */ export declare class Node implements Omit, 'isRoot' | 'isPage' | 'isComponent' | 'isModal' | 'isSlot' | 'isParental' | 'isLeaf' | 'settingEntry' | 'getExtraPropValue' | 'setExtraPropValue' | 'exportSchema' | 'visible' | 'importSchema' | 'isContainer' | 'isEmpty'> { readonly document: IDocumentModel; private emitter; /** * 是节点实例 */ readonly isNode = true; /** * 节点 id */ readonly id: string; /** * 节点组件类型 * 特殊节点: * * Page 页面 * * Block 区块 * * Component 组件/元件 * * Fragment 碎片节点,无 props,有指令 * * Leaf 文字节点 | 表达式节点,无 props,无指令? * * Slot 插槽节点,无 props,正常 children,有 slotArgs,有指令 */ readonly componentName: string; /** * 属性抽象 */ props: IProps; protected _children?: INodeChildren; /** * @deprecated */ private _addons; private _parent; /** * 父级节点 */ get parent(): INode | null; /** * 当前节点子集 */ get children(): INodeChildren | null; /** * 当前节点深度 */ get zLevel(): number; get title(): string | IPublicTypeI18nData | ReactElement; get icon(): import("@alilc/lowcode-types").IPublicTypeIconType; isInited: boolean; _settingEntry?: ISettingTopEntry; get settingEntry(): ISettingTopEntry; private autoruns?; private _isRGLContainer; set isRGLContainer(status: boolean); get isRGLContainer(): boolean; set isRGLContainerNode(status: boolean); get isRGLContainerNode(): boolean; get isEmptyNode(): boolean; private _slotFor?; _slots: INode[]; get slots(): INode[]; private _conditionGroup; get conditionGroup(): IExclusiveGroup | null; private purged; /** * 是否已销毁 */ get isPurged(): boolean; private purging; /** * 是否正在销毁 */ get isPurging(): boolean; status: NodeStatus; constructor(document: IDocumentModel, nodeSchema: Schema); /** * 节点初始化期间就把内置的一些 prop 初始化好,避免后续不断构造实例导致 reaction 执行多次 */ private initBuiltinProps; private initProps; private upgradeProps; private setupAutoruns; private initialChildren; isContainer(): boolean; get isContainerNode(): boolean; isModal(): boolean; get isModalNode(): boolean; isRoot(): boolean; get isRootNode(): boolean; isPage(): boolean; get isPageNode(): boolean; isComponent(): boolean; get isComponentNode(): boolean; isSlot(): boolean; get isSlotNode(): boolean; /** * 是否一个父亲类节点 */ isParental(): boolean; get isParentalNode(): boolean; /** * 终端节点,内容一般为 文字 或者 表达式 */ isLeaf(): boolean; get isLeafNode(): boolean; internalSetWillPurge(): void; didDropIn(dragment: INode): void; didDropOut(dragment: INode): void; /** * 内部方法,请勿使用 * @param useMutator 是否触发联动逻辑 */ internalSetParent(parent: INode | null, useMutator?: boolean): void; internalSetSlotFor(slotFor: IProp | null | undefined): void; internalToShellNode(): IPublicModelNode | null; /** * 关联属性 */ get slotFor(): IProp | null | undefined; /** * 移除当前节点 */ remove(useMutator?: boolean, purge?: boolean, options?: NodeRemoveOptions): void; /** * 锁住当前节点 */ lock(flag?: boolean): void; /** * 获取当前节点的锁定状态 */ get isLocked(): boolean; canSelect(): boolean; /** * 选择当前节点 */ select(): void; /** * 悬停高亮 */ hover(flag?: boolean): void; /** * 节点组件描述 */ get componentMeta(): IComponentMeta; get propsData(): IPublicTypePropsMap | IPublicTypePropsList | null; hasSlots(): boolean; setConditionGroup(grp: IExclusiveGroup | string | null): void; isConditionalVisible(): boolean | undefined; setConditionalVisible(): void; hasCondition(): boolean; /** * has loop when 1. loop is validArray with length > 1 ; OR 2. loop is variable object * @return boolean, has loop config or not */ hasLoop(): boolean; wrapWith(schema: Schema): any; replaceWith(schema: Schema, migrate?: boolean): any; /** * 替换子节点 * * @param {INode} node * @param {object} data */ replaceChild(node: INode, data: any): INode | null; setVisible(flag: boolean): void; getVisible(): boolean; onVisibleChange(func: (flag: boolean) => any): () => void; getProp(path: string, createIfNone?: boolean): IProp | null; getExtraProp(key: string, createIfNone?: boolean): IProp | null; setExtraProp(key: string, value: IPublicTypeCompositeValue): void; /** * 获取单个属性值 */ getPropValue(path: string): any; /** * 设置单个属性值 */ setPropValue(path: string, value: any): void; /** * 清除已设置的值 */ clearPropValue(path: string): void; /** * 设置多个属性值,和原有值合并 */ mergeProps(props: IPublicTypePropsMap): void; /** * 设置多个属性值,替换原有值 */ setProps(props?: IPublicTypePropsMap | IPublicTypePropsList | Props | null): void; /** * 获取节点在父容器中的索引 */ get index(): number | undefined; /** * 获取下一个兄弟节点 */ get nextSibling(): INode | null | undefined; /** * 获取上一个兄弟节点 */ get prevSibling(): INode | null | undefined; /** * 获取符合搭建协议-节点 schema 结构 */ get schema(): Schema; set schema(data: Schema); import(data: Schema, checkId?: boolean): void; toData(): IPublicTypeNodeSchema; /** * 导出 schema */ export(stage?: IPublicEnumTransformStage, options?: any): T; /** * 判断是否包含特定节点 */ contains(node: INode): boolean; /** * 获取特定深度的父亲节点 */ getZLevelTop(zLevel: number): INode | null; /** * 判断与其它节点的位置关系 * * 16 thisNode contains otherNode * 8 thisNode contained_by otherNode * 2 thisNode before or after otherNode * 0 thisNode same as otherNode */ comparePosition(otherNode: INode): PositionNO; unlinkSlot(slotNode: INode): boolean; /** * 删除一个Slot节点 */ removeSlot(slotNode: INode): boolean; addSlot(slotNode: INode): void; /** * 当前node对应组件是否已注册可用 */ isValidComponent(): boolean; /** * 删除一个节点 * @param node */ removeChild(node: INode): void; /** * 销毁 */ purge(): void; internalPurgeStart(): void; /** * 是否可执行某 action */ canPerformAction(actionName: string): boolean; isEmpty(): boolean; getChildren(): INodeChildren; getComponentName(): string; insert(node: INode, ref?: INode, useMutator?: boolean): void; insertBefore(node: INode, ref?: INode, useMutator?: boolean): void; insertAfter(node: any, ref?: INode, useMutator?: boolean): void; getParent(): INode; getId(): string; getIndex(): number; getNode(): this; getRoot(): IRootNode; getProps(): IProps; onChildrenChange(fn: (param?: { type: string; node: INode; }) => void): IPublicTypeDisposable | undefined; mergeChildren(remover: (node: INode, idx: number) => any, adder: (children: INode[]) => IPublicTypeNodeData[] | null, sorter: (firstNode: INode, secondNode: INode) => any): void; /** * @deprecated */ getStatus(field?: keyof NodeStatus): boolean | NodeStatus; /** * @deprecated */ setStatus(field: keyof NodeStatus, flag: boolean): void; /** * @deprecated */ getDOMNode(): any; /** * @deprecated */ getPage(): IDocumentModel; /** * 获取磁贴相关信息 */ getRGL(): { isContainerNode: boolean; isEmptyNode: boolean; isRGLContainerNode: boolean; isRGLNode: boolean; isRGL: boolean; rglNode: Node | null; }; /** * @deprecated no one is using this, will be removed in a future release */ getSuitablePlace(node: INode, ref: any): any; /** * @deprecated */ getAddonData(key: string): any; /** * @deprecated */ registerAddon(key: string, exportData: () => any, isProp?: boolean): void; getRect(): DOMRect | null; /** * @deprecated */ getPrototype(): any; /** * @deprecated */ setPrototype(proto: any): void; getIcon(): import("@alilc/lowcode-types").IPublicTypeIconType; toString(): string; emitPropChange(val: IPublicTypePropChangeOptions): void; onPropChange(func: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable; } export interface LeafNode extends Node { readonly children: null; } export type IPublicTypePropChangeOptions = Omit; export interface ISlotNode extends Node { } export interface IPageNode extends Node { } export interface IComponentNode extends Node { } export interface IRootNode extends Node { } export interface INode extends Node { } export declare function isRootNode(node: INode): node is IRootNode; export declare function isLowCodeComponent(node: INode): node is IComponentNode; export declare function getZLevelTop(child: INode, zLevel: number): INode | null; /** * 测试两个节点是否为包含关系 * @param node1 测试的父节点 * @param node2 测试的被包含节点 * @returns 是否包含 */ export declare function contains(node1: INode, node2: INode): boolean; export declare enum PositionNO { Contains = 16, ContainedBy = 8, BeforeOrAfter = 2, TheSame = 0 } export declare function comparePosition(node1: INode, node2: INode): PositionNO; export declare function insertChild(container: INode, thing: INode | IPublicTypeNodeData, at?: number | null, copy?: boolean): INode | null; export declare function insertChildren(container: INode, nodes: INode[] | IPublicTypeNodeData[] | IPublicModelNode[], at?: number | null, copy?: boolean): INode[];