forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrag-object.ts
More file actions
34 lines (28 loc) · 973 Bytes
/
drag-object.ts
File metadata and controls
34 lines (28 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { dragObjectSymbol } from '../symbols';
import { IPublicModelDragObject, IPublicModelDragObject as InnerDragObject, IPublicTypeDragNodeDataObject, IPublicTypeNodeSchema } from '@alilc/lowcode-types';
import { Node } from './node';
export class DragObject implements IPublicModelDragObject {
private readonly [dragObjectSymbol]: InnerDragObject;
constructor(dragObject: InnerDragObject) {
this[dragObjectSymbol] = dragObject;
}
static create(dragObject: InnerDragObject | null): IPublicModelDragObject | null {
if (!dragObject) {
return null;
}
return new DragObject(dragObject);
}
get type() {
return this[dragObjectSymbol].type;
}
get nodes() {
const { nodes } = this[dragObjectSymbol];
if (!nodes) {
return null;
}
return nodes.map(Node.create);
}
get data(): IPublicTypeNodeSchema | IPublicTypeNodeSchema[] {
return (this[dragObjectSymbol] as IPublicTypeDragNodeDataObject).data;
}
}