forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdrag-object.ts
More file actions
39 lines (33 loc) · 983 Bytes
/
drag-object.ts
File metadata and controls
39 lines (33 loc) · 983 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
35
36
37
38
39
import { dragObjectSymbol } from '../symbols';
import {
IPublicModelDragObject,
IPublicModelDragObject as InnerDragObject,
IPublicTypeDragNodeDataObject,
IPublicTypeNodeSchema,
} from '@felce/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;
}
}