-
-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathShowTextBox.ts
More file actions
34 lines (26 loc) · 1.04 KB
/
ShowTextBox.ts
File metadata and controls
34 lines (26 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
import Action from './../lib/Action';
import type TextBox from './../components/text-box';
import { ActionApplyResult, ActionRevertResult } from '../lib/types';
export class ShowTextBox extends Action {
static override id = 'Show::TextBox';
static override matchString([show, type]: string[]): boolean {
return show === 'show' && 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: false });
}
override async didApply(): Promise<ActionApplyResult> {
this.engine.state({ textboxHidden: false });
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: true });
}
override async didRevert(): Promise<ActionRevertResult> {
this.engine.state({ textboxHidden: true });
return { advance: true, step: true };
}
}
export default ShowTextBox;