UNPKG

jjb-lc-designable

Version:

基于alibaba-designable源码二次封装的表单设计器。

50 lines (43 loc) 926 B
import { observable, define, action } from 'jjb-lc-formily/reactive' import { Operation } from './Operation' import { TreeNode } from './TreeNode' import { HoverNodeEvent } from '../events' export interface IHoverProps { operation: Operation } export class Hover { node: TreeNode = null operation: Operation constructor(props?: IHoverProps) { this.operation = props?.operation this.makeObservable() } setHover(node?: TreeNode) { if (node) { this.node = node } else { this.node = null } this.trigger() } clear() { this.node = null } trigger() { if (this.operation) { return this.operation.dispatch( new HoverNodeEvent({ target: this.operation.tree, source: this.node, }) ) } } makeObservable() { define(this, { node: observable.ref, setHover: action, clear: action, }) } }