-
-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathHideTextBox.ts
More file actions
53 lines (42 loc) · 1.49 KB
/
HideTextBox.ts
File metadata and controls
53 lines (42 loc) · 1.49 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
import Action from './../lib/Action';
import type TextBox from './../components/text-box';
import { ActionApplyResult, ActionRevertResult } from '../lib/types';
export class HideTextBox extends Action {
static override id = 'Hide::TextBox';
static override async setup(): Promise<void> {
this.engine.state({
textboxHidden: false
});
}
static override async reset(): Promise<void> {
this.engine.state({
textboxHidden: false
});
}
static override async onLoad(): Promise<void> {
if (this.engine.state('textboxHidden') === true) {
const textBox = this.engine.element().find('[data-component="text-box"]').get(0) as TextBox | undefined;
textBox?.setState({ hidden: true });
}
}
static override matchString([hide, type]: string[]): boolean {
return hide === 'hide' && type === 'textbox';
}
override async apply(): Promise<void> {
const textBox = this.engine.element().find('[data-component="text-box"]').get(0) as TextBox | undefined;
textBox?.setState({ hidden: true });
}
override async didApply(): Promise<ActionApplyResult> {
this.engine.state({ textboxHidden: true });
return { advance: true };
}
override async revert(): Promise<void> {
const textBox = this.engine.element().find('[data-component="text-box"]').get(0) as TextBox | undefined;
textBox?.setState({ hidden: false });
}
override async didRevert(): Promise<ActionRevertResult> {
this.engine.state({ textboxHidden: false });
return { advance: true, step: true };
}
}
export default HideTextBox;