forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstage.ts
More file actions
54 lines (42 loc) · 1.04 KB
/
Copy pathstage.ts
File metadata and controls
54 lines (42 loc) · 1.04 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// import { uniqueId } from '@alilc/lowcode-utils';
import Widget from './widget';
import { Skeleton } from '../skeleton';
import { WidgetConfig } from '../types';
export interface StageConfig extends WidgetConfig {
isRoot?: boolean;
}
export class Stage extends Widget {
readonly isRoot: boolean;
private previous?: Stage;
private refer?: {
stage?: Stage;
direction?: 'right' | 'left';
};
constructor(skeleton: Skeleton, config: StageConfig) {
super(skeleton, config);
this.isRoot = config.isRoot || false;
}
setPrevious(stage: Stage) {
this.previous = stage;
}
getPrevious() {
return this.previous;
}
hasBack(): boolean {
return !!(this.previous && !this.isRoot);
}
setRefer(stage: Stage, direction: 'right' | 'left') {
this.refer = { stage, direction };
}
setReferRight(stage: Stage) {
this.setRefer(stage, 'right');
}
setReferLeft(stage: Stage) {
this.setRefer(stage, 'left');
}
getRefer() {
const { refer } = this;
this.refer = undefined;
return refer;
}
}