-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
CountdownInputPrompt.tsx
57 lines (47 loc) 路 1.08 KB
/
CountdownInputPrompt.tsx
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
55
56
57
/*
* Copyright (c) 2022-2023 Datalayer Inc. All rights reserved.
*
* MIT License
*/
import { ReactWidget } from '@jupyterlab/apputils';
import { IInputPrompt } from '@jupyterlab/cells';
import { Countdown } from './Countdown';
const INPUT_PROMPT_CLASS = 'jp-InputPrompt';
export class CountdownInputPrompt extends ReactWidget implements IInputPrompt {
private _executionCount: string | null = null;
private state = {
count: 100
}
constructor() {
super();
this.addClass(INPUT_PROMPT_CLASS);
}
/** @override */
render() {
return <Countdown count={this.state.count} />
}
get executionCount(): string | null {
return this._executionCount;
}
set executionCount(value: string | null) {
this._executionCount = value;
if (value === null) {
this.state = {
count: 0
};
} else {
if (value === '*') {
this.state = {
count: 0
};
}
else {
this.state = {
count: Number(value)
};
this.update();
}
}
}
}
export default CountdownInputPrompt;