import {ComponentEvent, PropType} from "@peryl/react-compose"; import {iTreeProps} from "./TreeCore.type"; import {iTreeNode} from "./createTreeNode"; import {PlainObject} from "@peryl/utils/event"; export const TreePropsOptions = { data: { type: Array as PropType }, keyField: { type: [String, Function] as PropType, required: true }, labelField: { type: [String, Function] as PropType, required: true }, childrenField: { type: [String, Function] as PropType, required: true }, setChildrenData: { type: Function as PropType }, isCheckAble: { type: Function as PropType }, isLeaf: { type: Function as PropType }, filterMethod: { type: Function as PropType }, lazy: { type: Boolean as PropType }, getChildrenData: { type: Function as PropType }, current: { type: String as PropType }, disableCurrent: { type: Boolean as PropType }, multiple: { type: Boolean as PropType }, singleValueType: { type: String as PropType }, checkLast: { type: Boolean as PropType, default: null }, checkStrictly: { type: Boolean as PropType }, according: { type: Boolean as PropType }, autoExpandParent: { type: Boolean as PropType, default: true }, autoCollapseChildren: { type: Boolean as PropType, default: true }, autoCheckChildren: { type: Boolean as PropType, default: true }, autoCheckParent: { type: Boolean as PropType, default: true }, expandOnClickNode: { type: Boolean as PropType }, checkOnClickNode: { type: Boolean as PropType }, defaultExpandAll: { type: Boolean as PropType }, getNodeIcon: { type: Function as PropType }, draggable: { type: Boolean as PropType }, customDraggier: { type: Boolean as PropType }, isAllowDraggable: { type: Function as PropType }, isAllowDroppable: { type: Function as PropType }, leafIcon: { type: [String, Function] as PropType, default: 'pi-drive-file' as string }, folderCollapseIcon: { type: String as PropType, default: 'pi-caret-right' as string }, folderExpandIcon: { type: String as PropType, default: 'pi-down' as string }, expanderCover: { type: Boolean as PropType, default: true }, loading: { type: Boolean as PropType, }, filterText: { type: String as PropType, }, virtual: { type: Boolean as PropType }, virtualSize: { type: Number as PropType }, size: { type: String as PropType }, virtualDynamicSize: { type: Boolean as PropType }, noMatchText: { type: String as PropType }, noDataText: { type: String as PropType }, nodeIcon: { type: Function as PropType }, } as const; export const TreeEmitOptions = { onUpdateModelValue: (val: any) => true, onUpdateExpand: (val: any[] | undefined) => true, onUpdateCurrent: (val?: string) => true, onUpdateData: (val?: any[] | undefined | null) => true, onDragChange: (data: iTreeDragChangeData) => true, } as const; export type iTreeEvent = ComponentEvent export interface iTreeDragChangeData { data: any, // 拖拽的节点数据 newParent: PlainObject | null, // 拖拽放置位置的父节点数据,如果放置的位置是根列表,则父节点为null oldParent: PlainObject | null, // 拖拽放置前,节点的父节点数据 node: iTreeNode, // 拖拽的节点信息 newParentNode: iTreeNode | null, // 拖拽放置位置的父节点对象信息 oldParentNode: iTreeNode | null, // 拖拽放置之前,节点的父节点对象信息 newSiblings: any[], // 拖拽放置之后,节点所在数组对象 newSiblingsBak: any[], // 拖拽之前,newSiblings数据的备份 oldSiblings: any[], // 拖拽放置之前,节点所在数组对象 oldSiblingsBak: any[], // 拖拽之前, oldSiblings的数据备份 undo: () => void, // 撤销本次拖拽动作 }