@dodona/papyros 3.0.2 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -72
- package/dist/Components.d.ts +4 -0
- package/dist/Components.js +5 -0
- package/dist/Components.js.map +1 -0
- package/dist/Papyros.d.ts +18 -127
- package/dist/Papyros.js +39 -211
- package/dist/Papyros.js.map +1 -1
- package/dist/{Backend.d.ts → backend/Backend.d.ts} +3 -12
- package/dist/{Backend.js → backend/Backend.js} +4 -17
- package/dist/backend/Backend.js.map +1 -0
- package/dist/{workers → backend/workers}/javascript/JavaScriptWorker.js +1 -1
- package/dist/backend/workers/javascript/JavaScriptWorker.js.map +1 -0
- package/dist/backend/workers/javascript/worker.js.map +1 -0
- package/dist/{workers → backend/workers}/python/PythonWorker.d.ts +2 -2
- package/dist/{workers → backend/workers}/python/PythonWorker.js +2 -2
- package/dist/backend/workers/python/PythonWorker.js.map +1 -0
- package/dist/backend/workers/python/python_package.tar.gz.load_by_url +0 -0
- package/dist/backend/workers/python/worker.js.map +1 -0
- package/dist/communication/BackendEvent.js.map +1 -0
- package/dist/{BackendEventQueue.d.ts → communication/BackendEventQueue.d.ts} +1 -36
- package/dist/{BackendEventQueue.js → communication/BackendEventQueue.js} +2 -45
- package/dist/communication/BackendEventQueue.js.map +1 -0
- package/dist/{BackendManager.d.ts → communication/BackendManager.d.ts} +2 -2
- package/dist/{BackendManager.js → communication/BackendManager.js} +4 -4
- package/dist/communication/BackendManager.js.map +1 -0
- package/dist/communication/InputServiceWorker.js +37 -0
- package/dist/communication/InputServiceWorker.js.map +1 -0
- package/dist/communication/InputWorker.js.map +1 -0
- package/dist/frontend/components/CodeRunner.d.ts +9 -0
- package/dist/frontend/components/CodeRunner.js +60 -0
- package/dist/frontend/components/CodeRunner.js.map +1 -0
- package/dist/frontend/components/Debugger.d.ts +7 -0
- package/dist/frontend/components/Debugger.js +62 -0
- package/dist/frontend/components/Debugger.js.map +1 -0
- package/dist/frontend/components/Input.d.ts +17 -0
- package/dist/frontend/components/Input.js +73 -0
- package/dist/frontend/components/Input.js.map +1 -0
- package/dist/frontend/components/Output.d.ts +14 -0
- package/dist/frontend/components/Output.js +154 -0
- package/dist/frontend/components/Output.js.map +1 -0
- package/dist/frontend/components/PapyrosElement.d.ts +8 -0
- package/dist/frontend/components/PapyrosElement.js +24 -0
- package/dist/frontend/components/PapyrosElement.js.map +1 -0
- package/dist/frontend/components/app/App.d.ts +24 -0
- package/dist/frontend/components/app/App.js +204 -0
- package/dist/frontend/components/app/App.js.map +1 -0
- package/dist/frontend/components/app/ExamplePicker.d.ts +7 -0
- package/dist/frontend/components/app/ExamplePicker.js +35 -0
- package/dist/frontend/components/app/ExamplePicker.js.map +1 -0
- package/dist/frontend/components/app/LanguagePicker.d.ts +7 -0
- package/dist/frontend/components/app/LanguagePicker.js +35 -0
- package/dist/frontend/components/app/LanguagePicker.js.map +1 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.d.ts +7 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.js +39 -0
- package/dist/frontend/components/app/ProgrammingLanguagePicker.js.map +1 -0
- package/dist/frontend/components/app/examples/JavaScriptExamples.js.map +1 -0
- package/dist/frontend/components/app/examples/PythonExamples.js.map +1 -0
- package/dist/frontend/components/app/themes/ThemePicker.d.ts +11 -0
- package/dist/frontend/components/app/themes/ThemePicker.js +47 -0
- package/dist/frontend/components/app/themes/ThemePicker.js.map +1 -0
- package/dist/frontend/components/app/themes/ThemedButton.d.ts +9 -0
- package/dist/frontend/components/app/themes/ThemedButton.js +43 -0
- package/dist/frontend/components/app/themes/ThemedButton.js.map +1 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.d.ts +8 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.js +54 -0
- package/dist/frontend/components/code_mirror/BatchInputEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/CodeEditor.d.ts +24 -0
- package/dist/frontend/components/code_mirror/CodeEditor.js +206 -0
- package/dist/frontend/components/code_mirror/CodeEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.d.ts +20 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.js +99 -0
- package/dist/frontend/components/code_mirror/CodeMirrorEditor.js.map +1 -0
- package/dist/frontend/components/code_mirror/Extensions.d.ts +15 -0
- package/dist/frontend/components/code_mirror/Extensions.js +169 -0
- package/dist/frontend/components/code_mirror/Extensions.js.map +1 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.d.ts +5 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.js +109 -0
- package/dist/frontend/components/code_mirror/MaterialTheme.js.map +1 -0
- package/dist/frontend/components/code_runner/ButtonLint.d.ts +9 -0
- package/dist/frontend/components/code_runner/ButtonLint.js +76 -0
- package/dist/frontend/components/code_runner/ButtonLint.js.map +1 -0
- package/dist/frontend/components/code_runner/Code.d.ts +7 -0
- package/dist/frontend/components/code_runner/Code.js +46 -0
- package/dist/frontend/components/code_runner/Code.js.map +1 -0
- package/dist/frontend/components/code_runner/RunState.d.ts +7 -0
- package/dist/frontend/components/code_runner/RunState.js +41 -0
- package/dist/frontend/components/code_runner/RunState.js.map +1 -0
- package/dist/frontend/components/input/BatchInput.d.ts +19 -0
- package/dist/frontend/components/input/BatchInput.js +92 -0
- package/dist/frontend/components/input/BatchInput.js.map +1 -0
- package/dist/frontend/components/input/InteractiveInput.d.ts +13 -0
- package/dist/frontend/components/input/InteractiveInput.js +73 -0
- package/dist/frontend/components/input/InteractiveInput.js.map +1 -0
- package/dist/frontend/state/Constants.d.ts +38 -0
- package/dist/frontend/state/Constants.js +108 -0
- package/dist/frontend/state/Constants.js.map +1 -0
- package/dist/frontend/state/Debugger.d.ts +23 -0
- package/dist/frontend/state/Debugger.js +80 -0
- package/dist/frontend/state/Debugger.js.map +1 -0
- package/dist/frontend/state/Examples.d.ts +11 -0
- package/dist/frontend/state/Examples.js +36 -0
- package/dist/frontend/state/Examples.js.map +1 -0
- package/dist/frontend/state/I18n.d.ts +16 -0
- package/dist/frontend/state/I18n.js +75 -0
- package/dist/frontend/state/I18n.js.map +1 -0
- package/dist/frontend/state/InputOutput.d.ts +55 -0
- package/dist/frontend/state/InputOutput.js +93 -0
- package/dist/frontend/state/InputOutput.js.map +1 -0
- package/dist/frontend/state/Runner.d.ts +118 -0
- package/dist/frontend/state/Runner.js +334 -0
- package/dist/frontend/state/Runner.js.map +1 -0
- package/dist/frontend/state/Test.d.ts +11 -0
- package/dist/frontend/state/Test.js +59 -0
- package/dist/frontend/state/Test.js.map +1 -0
- package/dist/frontend/state/Translations.d.ts +178 -0
- package/dist/frontend/state/Translations.js +188 -0
- package/dist/frontend/state/Translations.js.map +1 -0
- package/dist/frontend/state/themes/blue-dark.d.ts +2 -0
- package/dist/frontend/state/themes/blue-dark.js +55 -0
- package/dist/frontend/state/themes/blue-dark.js.map +1 -0
- package/dist/frontend/state/themes/blue-light.d.ts +2 -0
- package/dist/frontend/state/themes/blue-light.js +55 -0
- package/dist/frontend/state/themes/blue-light.js.map +1 -0
- package/dist/frontend/state/themes/green-dark.d.ts +2 -0
- package/dist/frontend/state/themes/green-dark.js +55 -0
- package/dist/frontend/state/themes/green-dark.js.map +1 -0
- package/dist/frontend/state/themes/green-light.d.ts +2 -0
- package/dist/frontend/state/themes/green-light.js +55 -0
- package/dist/frontend/state/themes/green-light.js.map +1 -0
- package/dist/frontend/state/themes/red-dark.d.ts +2 -0
- package/dist/frontend/state/themes/red-dark.js +55 -0
- package/dist/frontend/state/themes/red-dark.js.map +1 -0
- package/dist/frontend/state/themes/red-light.d.ts +2 -0
- package/dist/frontend/state/themes/red-light.js +55 -0
- package/dist/frontend/state/themes/red-light.js.map +1 -0
- package/dist/util/Util.d.ts +1 -4
- package/dist/util/Util.js +7 -8
- package/dist/util/Util.js.map +1 -1
- package/package.json +13 -21
- package/dist/App.d.ts +0 -1
- package/dist/App.js +0 -76
- package/dist/App.js.map +0 -1
- package/dist/Backend.js.map +0 -1
- package/dist/BackendEvent.js.map +0 -1
- package/dist/BackendEventQueue.js.map +0 -1
- package/dist/BackendManager.js.map +0 -1
- package/dist/CodeRunner.d.ts +0 -188
- package/dist/CodeRunner.js +0 -548
- package/dist/CodeRunner.js.map +0 -1
- package/dist/Constants.d.ts +0 -31
- package/dist/Constants.js +0 -36
- package/dist/Constants.js.map +0 -1
- package/dist/Debugger.d.ts +0 -18
- package/dist/Debugger.js +0 -86
- package/dist/Debugger.js.map +0 -1
- package/dist/InputManager.d.ts +0 -38
- package/dist/InputManager.js +0 -101
- package/dist/InputManager.js.map +0 -1
- package/dist/InputServiceWorker.js.map +0 -1
- package/dist/Library.d.ts +0 -12
- package/dist/Library.js +0 -9
- package/dist/Library.js.map +0 -1
- package/dist/OutputManager.d.ts +0 -90
- package/dist/OutputManager.js +0 -172
- package/dist/OutputManager.js.map +0 -1
- package/dist/Papyros.css +0 -657
- package/dist/Translations.d.ts +0 -180
- package/dist/Translations.js +0 -191
- package/dist/Translations.js.map +0 -1
- package/dist/editor/BatchInputEditor.d.ts +0 -41
- package/dist/editor/BatchInputEditor.js +0 -80
- package/dist/editor/BatchInputEditor.js.map +0 -1
- package/dist/editor/CodeEditor.d.ts +0 -81
- package/dist/editor/CodeEditor.js +0 -213
- package/dist/editor/CodeEditor.js.map +0 -1
- package/dist/editor/CodeMirrorEditor.d.ts +0 -133
- package/dist/editor/CodeMirrorEditor.js +0 -169
- package/dist/editor/CodeMirrorEditor.js.map +0 -1
- package/dist/editor/DarkTheme.d.ts +0 -1
- package/dist/editor/DarkTheme.js +0 -72
- package/dist/editor/DarkTheme.js.map +0 -1
- package/dist/editor/DebugExtension.d.ts +0 -11
- package/dist/editor/DebugExtension.js +0 -70
- package/dist/editor/DebugExtension.js.map +0 -1
- package/dist/editor/Gutters.d.ts +0 -109
- package/dist/editor/Gutters.js +0 -201
- package/dist/editor/Gutters.js.map +0 -1
- package/dist/editor/LineEffectExtension.d.ts +0 -13
- package/dist/editor/LineEffectExtension.js +0 -48
- package/dist/editor/LineEffectExtension.js.map +0 -1
- package/dist/editor/TestCodeExtension.d.ts +0 -21
- package/dist/editor/TestCodeExtension.js +0 -134
- package/dist/editor/TestCodeExtension.js.map +0 -1
- package/dist/examples/Examples.d.ts +0 -6
- package/dist/examples/Examples.js +0 -23
- package/dist/examples/Examples.js.map +0 -1
- package/dist/examples/JavaScriptExamples.js.map +0 -1
- package/dist/examples/PythonExamples.js.map +0 -1
- package/dist/input/BatchInputHandler.d.ts +0 -55
- package/dist/input/BatchInputHandler.js +0 -131
- package/dist/input/BatchInputHandler.js.map +0 -1
- package/dist/input/InteractiveInputHandler.d.ts +0 -27
- package/dist/input/InteractiveInputHandler.js +0 -89
- package/dist/input/InteractiveInputHandler.js.map +0 -1
- package/dist/input/UserInputHandler.d.ts +0 -68
- package/dist/input/UserInputHandler.js +0 -39
- package/dist/input/UserInputHandler.js.map +0 -1
- package/dist/util/HTMLShapes.d.ts +0 -15
- package/dist/util/HTMLShapes.js +0 -25
- package/dist/util/HTMLShapes.js.map +0 -1
- package/dist/util/Rendering.d.ts +0 -120
- package/dist/util/Rendering.js +0 -142
- package/dist/util/Rendering.js.map +0 -1
- package/dist/workers/input/InputWorker.js.map +0 -1
- package/dist/workers/javascript/JavaScriptWorker.js.map +0 -1
- package/dist/workers/javascript/worker.js.map +0 -1
- package/dist/workers/python/PythonWorker.js.map +0 -1
- package/dist/workers/python/python_package.tar.gz.load_by_url +0 -0
- package/dist/workers/python/worker.js.map +0 -1
- /package/dist/{workers → backend/workers}/javascript/JavaScriptWorker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/javascript/worker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/javascript/worker.js +0 -0
- /package/dist/{workers → backend/workers}/python/worker.d.ts +0 -0
- /package/dist/{workers → backend/workers}/python/worker.js +0 -0
- /package/dist/{BackendEvent.d.ts → communication/BackendEvent.d.ts} +0 -0
- /package/dist/{BackendEvent.js → communication/BackendEvent.js} +0 -0
- /package/dist/{InputServiceWorker.d.ts → communication/InputServiceWorker.d.ts} +0 -0
- /package/dist/{workers/input → communication}/InputWorker.d.ts +0 -0
- /package/dist/{workers/input → communication}/InputWorker.js +0 -0
- /package/dist/{examples → frontend/components/app/examples}/JavaScriptExamples.d.ts +0 -0
- /package/dist/{examples → frontend/components/app/examples}/JavaScriptExamples.js +0 -0
- /package/dist/{examples → frontend/components/app/examples}/PythonExamples.d.ts +0 -0
- /package/dist/{examples → frontend/components/app/examples}/PythonExamples.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JavaScriptExamples.js","sourceRoot":"","sources":["../../src/examples/JavaScriptExamples.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,cAAc,EAAE,iCAAiC;IACjD,OAAO,EACH;kCAC0B;IAC9B,WAAW,EACP;;;;;;;;;CASP;CACA,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PythonExamples.js","sourceRoot":"","sources":["../../src/examples/PythonExamples.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,eAAe,EAAE,wBAAwB;IACzC,OAAO,EACH;yBACiB;IACrB,WAAW,EACP;;;yCAGiC;IACrC,UAAU,EACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDP;IACG,OAAO,EACH;;;;;;;;;;;;;;;CAeP;IACG,WAAW,EACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BP;IACG,SAAS,EACL;;;;CAIP;IACG,OAAO,EACH;;;;;;;CAOP;IACG,YAAY,EACR;;;;;;;;;;;;;;;;;;CAkBP;IACG,OAAO,EAAE;;;;;;;;CAQZ;IACG,UAAU,EAAE;;;;;;;;CAQf;IACG,WAAW,EAAE;;;;CAIhB;CACA,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { InputManagerRenderOptions, InputMode } from "../InputManager";
|
|
2
|
-
import { UserInputHandler } from "./UserInputHandler";
|
|
3
|
-
import { BatchInputEditor } from "../editor/BatchInputEditor";
|
|
4
|
-
export declare class BatchInputHandler extends UserInputHandler {
|
|
5
|
-
/**
|
|
6
|
-
* The index of the next line in lines to send
|
|
7
|
-
*/
|
|
8
|
-
private lineNr;
|
|
9
|
-
/**
|
|
10
|
-
* Messages used when asking for user input
|
|
11
|
-
*/
|
|
12
|
-
private prompts;
|
|
13
|
-
/**
|
|
14
|
-
* Whether a run is occurring
|
|
15
|
-
*/
|
|
16
|
-
private running;
|
|
17
|
-
/**
|
|
18
|
-
* Editor containing the input of the user
|
|
19
|
-
*/
|
|
20
|
-
readonly batchEditor: BatchInputEditor;
|
|
21
|
-
/**
|
|
22
|
-
* The previous input of the user
|
|
23
|
-
* Is restored upon switching back to InputMode.Batch
|
|
24
|
-
*/
|
|
25
|
-
private previousInput;
|
|
26
|
-
debugMode: boolean;
|
|
27
|
-
private debugLine;
|
|
28
|
-
/**
|
|
29
|
-
* Construct a new BatchInputHandler
|
|
30
|
-
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
31
|
-
*/
|
|
32
|
-
constructor(inputCallback: (line: string) => void);
|
|
33
|
-
/**
|
|
34
|
-
* Handle new input, potentially sending it to the awaiting receiver
|
|
35
|
-
* @param {string} newInput The new user input
|
|
36
|
-
*/
|
|
37
|
-
private handleInputChanged;
|
|
38
|
-
toggle(active: boolean): void;
|
|
39
|
-
getInputMode(): InputMode;
|
|
40
|
-
/**
|
|
41
|
-
* Retrieve the lines of input that the user has given so far
|
|
42
|
-
* @return {Array<string>} The entered lines
|
|
43
|
-
*/
|
|
44
|
-
protected get lines(): Array<string>;
|
|
45
|
-
hasNext(): boolean;
|
|
46
|
-
private highlight;
|
|
47
|
-
next(): string;
|
|
48
|
-
reset(): void;
|
|
49
|
-
onRunStart(): void;
|
|
50
|
-
onRunEnd(): void;
|
|
51
|
-
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
52
|
-
protected setPlaceholder(placeholderValue: string): void;
|
|
53
|
-
focus(): void;
|
|
54
|
-
protected _render(options: InputManagerRenderOptions): void;
|
|
55
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { InputMode } from "../InputManager";
|
|
2
|
-
import { UserInputHandler } from "./UserInputHandler";
|
|
3
|
-
import { t } from "../util/Util";
|
|
4
|
-
import { BatchInputEditor } from "../editor/BatchInputEditor";
|
|
5
|
-
import { BackendManager } from "../BackendManager";
|
|
6
|
-
import { BackendEventType } from "../BackendEvent";
|
|
7
|
-
export class BatchInputHandler extends UserInputHandler {
|
|
8
|
-
/**
|
|
9
|
-
* Construct a new BatchInputHandler
|
|
10
|
-
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
11
|
-
*/
|
|
12
|
-
constructor(inputCallback) {
|
|
13
|
-
super(inputCallback);
|
|
14
|
-
this.debugMode = false;
|
|
15
|
-
this.debugLine = 0;
|
|
16
|
-
this.lineNr = 0;
|
|
17
|
-
this.previousInput = "";
|
|
18
|
-
this.running = false;
|
|
19
|
-
this.prompts = [];
|
|
20
|
-
this.batchEditor = new BatchInputEditor();
|
|
21
|
-
this.batchEditor.onChange({
|
|
22
|
-
onChange: this.handleInputChanged.bind(this),
|
|
23
|
-
delay: 0
|
|
24
|
-
});
|
|
25
|
-
BackendManager.subscribe(BackendEventType.FrameChange, e => {
|
|
26
|
-
this.debugLine = e.data.inputs;
|
|
27
|
-
this.highlight(this.running);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Handle new input, potentially sending it to the awaiting receiver
|
|
32
|
-
* @param {string} newInput The new user input
|
|
33
|
-
*/
|
|
34
|
-
handleInputChanged(newInput) {
|
|
35
|
-
const newLines = newInput ? newInput.split("\n") : [];
|
|
36
|
-
if (newLines.length < this.lineNr) {
|
|
37
|
-
this.lineNr = newLines.length;
|
|
38
|
-
}
|
|
39
|
-
if (this.waiting && newLines.length > this.lineNr + 1) {
|
|
40
|
-
// Require explicitly pressing enter
|
|
41
|
-
this.inputCallback(this.next());
|
|
42
|
-
}
|
|
43
|
-
this.highlight(this.running);
|
|
44
|
-
this.previousInput = newInput;
|
|
45
|
-
}
|
|
46
|
-
toggle(active) {
|
|
47
|
-
if (active) {
|
|
48
|
-
this.batchEditor.setText(this.previousInput);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
this.previousInput = this.batchEditor.getText();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
getInputMode() {
|
|
55
|
-
return InputMode.Batch;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Retrieve the lines of input that the user has given so far
|
|
59
|
-
* @return {Array<string>} The entered lines
|
|
60
|
-
*/
|
|
61
|
-
get lines() {
|
|
62
|
-
return this.batchEditor.getLines();
|
|
63
|
-
}
|
|
64
|
-
hasNext() {
|
|
65
|
-
return this.lineNr < this.lines.length;
|
|
66
|
-
}
|
|
67
|
-
highlight(running) {
|
|
68
|
-
const whichLines = (index) => {
|
|
69
|
-
if (this.debugMode) {
|
|
70
|
-
return index < this.debugLine;
|
|
71
|
-
}
|
|
72
|
-
return index < this.lineNr;
|
|
73
|
-
};
|
|
74
|
-
this.batchEditor.highlight({
|
|
75
|
-
running,
|
|
76
|
-
getInfo: (lineNr) => {
|
|
77
|
-
let message = t("Papyros.used_input");
|
|
78
|
-
const index = lineNr - 1;
|
|
79
|
-
const shouldShow = whichLines(index);
|
|
80
|
-
if (index < this.prompts.length && this.prompts[index]) {
|
|
81
|
-
message = t("Papyros.used_input_with_prompt", { prompt: this.prompts[index] });
|
|
82
|
-
}
|
|
83
|
-
return { lineNr, on: shouldShow, title: message };
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
next() {
|
|
88
|
-
const nextLine = this.lines[this.lineNr];
|
|
89
|
-
this.lineNr += 1;
|
|
90
|
-
this.highlight(true);
|
|
91
|
-
return nextLine;
|
|
92
|
-
}
|
|
93
|
-
reset() {
|
|
94
|
-
super.reset();
|
|
95
|
-
this.lineNr = 0;
|
|
96
|
-
this.debugLine = 0;
|
|
97
|
-
this.prompts = [];
|
|
98
|
-
this.highlight(this.running);
|
|
99
|
-
}
|
|
100
|
-
onRunStart() {
|
|
101
|
-
this.running = true;
|
|
102
|
-
this.reset();
|
|
103
|
-
}
|
|
104
|
-
onRunEnd() {
|
|
105
|
-
this.running = false;
|
|
106
|
-
this.highlight(false);
|
|
107
|
-
}
|
|
108
|
-
waitWithPrompt(waiting, prompt) {
|
|
109
|
-
super.waitWithPrompt(waiting, prompt);
|
|
110
|
-
if (this.waiting) {
|
|
111
|
-
this.prompts.push(prompt || "");
|
|
112
|
-
if (this.hasNext()) {
|
|
113
|
-
this.inputCallback(this.next());
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
setPlaceholder(placeholderValue) {
|
|
118
|
-
this.batchEditor.setPlaceholder(placeholderValue);
|
|
119
|
-
}
|
|
120
|
-
focus() {
|
|
121
|
-
this.batchEditor.focus();
|
|
122
|
-
}
|
|
123
|
-
_render(options) {
|
|
124
|
-
this.batchEditor.render(options);
|
|
125
|
-
if (options.inputStyling) {
|
|
126
|
-
this.batchEditor.setStyling(options.inputStyling);
|
|
127
|
-
}
|
|
128
|
-
this.highlight(this.running);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=BatchInputHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BatchInputHandler.js","sourceRoot":"","sources":["../../src/input/BatchInputHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC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ACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YAChC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;gBACjB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;IACL,CAAC;IAES,cAAc,CAAC,gBAAwB;QAC7C,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEkB,OAAO,CAAC,OAAkC;QACzD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACJ"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { InputMode } from "../InputManager";
|
|
2
|
-
import { UserInputHandler } from "./UserInputHandler";
|
|
3
|
-
import { RenderOptions } from "../util/Rendering";
|
|
4
|
-
/**
|
|
5
|
-
* Input handler that takes input from the user in an interactive fashion
|
|
6
|
-
*/
|
|
7
|
-
export declare class InteractiveInputHandler extends UserInputHandler {
|
|
8
|
-
/**
|
|
9
|
-
* Retrieve the button that users can click to send their input
|
|
10
|
-
*/
|
|
11
|
-
private get sendButton();
|
|
12
|
-
/**
|
|
13
|
-
* Retrieve the HTMLInputElement for this InputHandler
|
|
14
|
-
*/
|
|
15
|
-
private get inputArea();
|
|
16
|
-
getInputMode(): InputMode;
|
|
17
|
-
hasNext(): boolean;
|
|
18
|
-
next(): string;
|
|
19
|
-
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
20
|
-
protected setPlaceholder(placeholder: string): void;
|
|
21
|
-
focus(): void;
|
|
22
|
-
toggle(): void;
|
|
23
|
-
onRunStart(): void;
|
|
24
|
-
onRunEnd(): void;
|
|
25
|
-
protected _render(options: RenderOptions): void;
|
|
26
|
-
reset(): void;
|
|
27
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { INPUT_TA_ID, SEND_INPUT_BTN_ID } from "../Constants";
|
|
2
|
-
import { InputMode } from "../InputManager";
|
|
3
|
-
import { addListener, getElement, t } from "../util/Util";
|
|
4
|
-
import { UserInputHandler } from "./UserInputHandler";
|
|
5
|
-
import { renderButton, renderWithOptions } from "../util/Rendering";
|
|
6
|
-
/**
|
|
7
|
-
* Input handler that takes input from the user in an interactive fashion
|
|
8
|
-
*/
|
|
9
|
-
export class InteractiveInputHandler extends UserInputHandler {
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve the button that users can click to send their input
|
|
12
|
-
*/
|
|
13
|
-
get sendButton() {
|
|
14
|
-
return getElement(SEND_INPUT_BTN_ID);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Retrieve the HTMLInputElement for this InputHandler
|
|
18
|
-
*/
|
|
19
|
-
get inputArea() {
|
|
20
|
-
return getElement(INPUT_TA_ID);
|
|
21
|
-
}
|
|
22
|
-
getInputMode() {
|
|
23
|
-
return InputMode.Interactive;
|
|
24
|
-
}
|
|
25
|
-
hasNext() {
|
|
26
|
-
return this.waiting; // Allow sending empty lines when the user does this explicitly
|
|
27
|
-
}
|
|
28
|
-
next() {
|
|
29
|
-
const value = this.inputArea.value;
|
|
30
|
-
this.reset();
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
waitWithPrompt(waiting, prompt) {
|
|
34
|
-
this.waiting = waiting;
|
|
35
|
-
this.sendButton.disabled = !waiting;
|
|
36
|
-
this.inputArea.disabled = !waiting;
|
|
37
|
-
super.waitWithPrompt(waiting, prompt);
|
|
38
|
-
}
|
|
39
|
-
setPlaceholder(placeholder) {
|
|
40
|
-
if (this.waiting) {
|
|
41
|
-
this.inputArea.setAttribute("placeholder", placeholder);
|
|
42
|
-
this.inputArea.setAttribute("title", "");
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.inputArea.setAttribute("placeholder", "");
|
|
46
|
-
this.inputArea.setAttribute("title", t("Papyros.input_disabled"));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
focus() {
|
|
50
|
-
this.inputArea.focus();
|
|
51
|
-
}
|
|
52
|
-
toggle() {
|
|
53
|
-
this.reset();
|
|
54
|
-
}
|
|
55
|
-
onRunStart() {
|
|
56
|
-
this.reset();
|
|
57
|
-
}
|
|
58
|
-
onRunEnd() {
|
|
59
|
-
// Intentionally empty
|
|
60
|
-
}
|
|
61
|
-
_render(options) {
|
|
62
|
-
const buttonHTML = renderButton({
|
|
63
|
-
id: SEND_INPUT_BTN_ID,
|
|
64
|
-
classNames: "btn-secondary",
|
|
65
|
-
buttonText: t("Papyros.enter")
|
|
66
|
-
});
|
|
67
|
-
renderWithOptions(options, `
|
|
68
|
-
<div class="_tw-flex _tw-flex-row _tw-my-1">
|
|
69
|
-
<input id="${INPUT_TA_ID}" type="text"
|
|
70
|
-
class="_tw-border _tw-w-full _tw-mr-0.5 _tw-px-1 _tw-rounded-lg
|
|
71
|
-
dark:_tw-border-dark-mode-content dark:_tw-bg-dark-mode-bg
|
|
72
|
-
placeholder:_tw-text-placeholder-grey disabled:_tw-cursor-not-allowed
|
|
73
|
-
focus:_tw-outline-none focus:_tw-ring-1 focus:_tw-ring-blue-500">
|
|
74
|
-
</input>
|
|
75
|
-
${buttonHTML}
|
|
76
|
-
</div>`);
|
|
77
|
-
addListener(SEND_INPUT_BTN_ID, () => this.inputCallback(this.next()), "click");
|
|
78
|
-
this.inputArea.addEventListener("keydown", (ev) => {
|
|
79
|
-
if (this.waiting && ev.key && ev.key.toLowerCase() === "enter") {
|
|
80
|
-
this.inputCallback(this.next());
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
reset() {
|
|
85
|
-
super.reset();
|
|
86
|
-
this.inputArea.value = "";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=InteractiveInputHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InteractiveInputHandler.js","sourceRoot":"","sources":["../../src/input/InteractiveInputHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACH,YAAY,EACG,iBAAiB,EACnC,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,gBAAgB;IACzD;;OAEG;IACH,IAAY,UAAU;QAClB,OAAO,UAAU,CAAoB,iBAAiB,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,IAAY,SAAS;QACjB,OAAO,UAAU,CAAmB,WAAW,CAAC,CAAC;IACrD,CAAC;IAEe,YAAY;QACxB,OAAO,SAAS,CAAC,WAAW,CAAC;IACjC,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,+DAA+D;IACxF,CAAC;IAEe,IAAI;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;IAEe,cAAc,CAAC,OAAgB,EAAE,MAAe;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,OAA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C,SAAS,EAAE,CAAC,EAAiB,EAAE,EAAE;YAC7D,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;gBAC7D,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACpC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,KAAK;QACR,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;IAC9B,CAAC;CACJ"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { InputManagerRenderOptions, InputMode } from "../InputManager";
|
|
2
|
-
import { Renderable } from "../util/Rendering";
|
|
3
|
-
/**
|
|
4
|
-
* Base class for components that handle input from the user
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class UserInputHandler extends Renderable<InputManagerRenderOptions> {
|
|
7
|
-
/**
|
|
8
|
-
* Whether we are waiting for the user to input data
|
|
9
|
-
*/
|
|
10
|
-
protected waiting: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Function to call when the user provided new input
|
|
13
|
-
*/
|
|
14
|
-
protected inputCallback: (line: string) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Construct a new UserInputHandler
|
|
17
|
-
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
18
|
-
*/
|
|
19
|
-
constructor(inputCallback: (line: string) => void);
|
|
20
|
-
/**
|
|
21
|
-
* Whether this handler has input ready
|
|
22
|
-
*/
|
|
23
|
-
abstract hasNext(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Consume and return the next input value
|
|
26
|
-
*
|
|
27
|
-
* Assumes hasNext() has been called and returned true,
|
|
28
|
-
* otherwise behaviour can produce incorrect results
|
|
29
|
-
* @return {string} The next value
|
|
30
|
-
*/
|
|
31
|
-
abstract next(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Method to call when a new run has started
|
|
34
|
-
*/
|
|
35
|
-
abstract onRunStart(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Method to call when the run ended
|
|
38
|
-
*/
|
|
39
|
-
abstract onRunEnd(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Retrieve the InputMode corresponding to this handler
|
|
42
|
-
* @return {InputMode} The InputMode enum value
|
|
43
|
-
*/
|
|
44
|
-
abstract getInputMode(): InputMode;
|
|
45
|
-
/**
|
|
46
|
-
* Enable or disable this UserInputHandler
|
|
47
|
-
* @param {boolean} active Whether this component is active
|
|
48
|
-
*/
|
|
49
|
-
abstract toggle(active: boolean): void;
|
|
50
|
-
/**
|
|
51
|
-
* @param {string} placeholder The placeholder to show
|
|
52
|
-
*/
|
|
53
|
-
protected abstract setPlaceholder(placeholder: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Focus the area in which the user enters input
|
|
56
|
-
*/
|
|
57
|
-
abstract focus(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Wait for input of the user for a certain prompt
|
|
60
|
-
* @param {boolean} waiting Whether we are waiting for input
|
|
61
|
-
* @param {string} prompt Optional message to display if waiting
|
|
62
|
-
*/
|
|
63
|
-
waitWithPrompt(waiting: boolean, prompt?: string): void;
|
|
64
|
-
/**
|
|
65
|
-
* Helper method to reset internal state
|
|
66
|
-
*/
|
|
67
|
-
reset(): void;
|
|
68
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { t } from "../util/Util";
|
|
2
|
-
import { Renderable } from "../util/Rendering";
|
|
3
|
-
/**
|
|
4
|
-
* Base class for components that handle input from the user
|
|
5
|
-
*/
|
|
6
|
-
export class UserInputHandler extends Renderable {
|
|
7
|
-
/**
|
|
8
|
-
* Construct a new UserInputHandler
|
|
9
|
-
* @param {function()} inputCallback Callback for when the user has entered a value
|
|
10
|
-
*/
|
|
11
|
-
constructor(inputCallback) {
|
|
12
|
-
super();
|
|
13
|
-
this.waiting = false;
|
|
14
|
-
this.inputCallback = inputCallback;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Wait for input of the user for a certain prompt
|
|
18
|
-
* @param {boolean} waiting Whether we are waiting for input
|
|
19
|
-
* @param {string} prompt Optional message to display if waiting
|
|
20
|
-
*/
|
|
21
|
-
waitWithPrompt(waiting, prompt = "") {
|
|
22
|
-
this.waiting = waiting;
|
|
23
|
-
this.setPlaceholder(prompt || t(`Papyros.input_placeholder.${this.getInputMode()}`));
|
|
24
|
-
if (this.waiting) {
|
|
25
|
-
// Focusing is a rendering operation
|
|
26
|
-
// Subclasses can execute code after this operation, skipping the rendering
|
|
27
|
-
// Using setTimeout ensures rendering will be done when the main thread has time
|
|
28
|
-
// More info here: https://stackoverflow.com/questions/1096436/document-getelementbyidid-focus-is-not-working-for-firefox-or-chrome
|
|
29
|
-
setTimeout(() => this.focus(), 0);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Helper method to reset internal state
|
|
34
|
-
*/
|
|
35
|
-
reset() {
|
|
36
|
-
this.waiting = false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=UserInputHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserInputHandler.js","sourceRoot":"","sources":["../../src/input/UserInputHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,UAAqC;IAUhF;;;OAGG;IACH,YAAY,aAAqC;QAC7C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IA6CD;;;;OAIG;IACI,cAAc,CAAC,OAAgB,EAAE,MAAM,GAAG,EAAE;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,6BAA6B,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;QACrF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,oCAAoC;YACpC,2EAA2E;YAC3E,gFAAgF;YAEhF,mIAAmI;YACnI,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Draw a spinning circle to represent a loading animation
|
|
3
|
-
* @param {string} id HTML id for this element
|
|
4
|
-
* @param {string} borderColors The tailwind color classes for the borders of the circle
|
|
5
|
-
* @return {string} A string representation of the circle
|
|
6
|
-
*/
|
|
7
|
-
export declare function renderSpinningCircle(id: string, borderColors: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Wrap text (best a single character) in a circle to provide information to the user
|
|
10
|
-
* @param {string} content The symbol in the circle, e.g. ? of !
|
|
11
|
-
* @param {string} title The information to display when hovering over the element
|
|
12
|
-
* @param {string} colorClasses The classes to color the content
|
|
13
|
-
* @return {string} A string representation of the circle with content
|
|
14
|
-
*/
|
|
15
|
-
export declare function renderInCircle(content: string, title: string, colorClasses: string): string;
|
package/dist/util/HTMLShapes.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Draw a spinning circle to represent a loading animation
|
|
3
|
-
* @param {string} id HTML id for this element
|
|
4
|
-
* @param {string} borderColors The tailwind color classes for the borders of the circle
|
|
5
|
-
* @return {string} A string representation of the circle
|
|
6
|
-
*/
|
|
7
|
-
export function renderSpinningCircle(id, borderColors) {
|
|
8
|
-
return `
|
|
9
|
-
<div id="${id}" class="_tw-animate-spin _tw-rounded-full ${borderColors}
|
|
10
|
-
_tw-border-2 _tw-h-[20px] _tw-w-[20px] _tw-mr-3"></div>`;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Wrap text (best a single character) in a circle to provide information to the user
|
|
14
|
-
* @param {string} content The symbol in the circle, e.g. ? of !
|
|
15
|
-
* @param {string} title The information to display when hovering over the element
|
|
16
|
-
* @param {string} colorClasses The classes to color the content
|
|
17
|
-
* @return {string} A string representation of the circle with content
|
|
18
|
-
*/
|
|
19
|
-
export function renderInCircle(content, title, colorClasses) {
|
|
20
|
-
const htmlTitle = title ? `title="${title}"` : "";
|
|
21
|
-
return `<span ${htmlTitle} class="_tw-display-block _tw-font-bold _tw-text-center
|
|
22
|
-
_tw-w-[10px] _tw-h-[10px] _tw-rounded-full _tw-px-1 _tw-mx-1
|
|
23
|
-
_tw-bg-white-500 _tw-border-2 ${colorClasses}">${content}</span>`;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=HTMLShapes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLShapes.js","sourceRoot":"","sources":["../../src/util/HTMLShapes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAU,EAAE,YAAoB;IACjE,OAAO;WACA,EAAE,8CAA8C,YAAY;yDACd,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,KAAa,EAAE,YAAoB;IAC/E,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,OAAO,SAAS,SAAS;;oCAEO,YAAY,KAAK,OAAO,SAAS,CAAC;AACtE,CAAC"}
|
package/dist/util/Rendering.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Useful options for rendering an element
|
|
3
|
-
*/
|
|
4
|
-
export interface RenderOptions {
|
|
5
|
-
/**
|
|
6
|
-
* String identifier for the parent in which the element will be rendered
|
|
7
|
-
*/
|
|
8
|
-
parentElementId: string;
|
|
9
|
-
/**
|
|
10
|
-
* Names of HTML classes to be added to the element, separated by 1 space
|
|
11
|
-
*/
|
|
12
|
-
classNames?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Extra attributes to add to the element, such as style or data
|
|
15
|
-
*/
|
|
16
|
-
attributes?: Map<string, string>;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to render in dark mode
|
|
19
|
-
*/
|
|
20
|
-
darkMode?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Helper method to append classes to the class attribute of an HTMLElement
|
|
24
|
-
* as consecutive whitespace is not allowed
|
|
25
|
-
* @param {Object} options Object containing classNames
|
|
26
|
-
* @param {string} classNames The classes to append
|
|
27
|
-
*/
|
|
28
|
-
export declare function appendClasses(options: {
|
|
29
|
-
classNames?: string;
|
|
30
|
-
}, classNames: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Helper method to add attributes to options with a possibly undefined attribute Map
|
|
33
|
-
* @param {Object} options Object containing attributes
|
|
34
|
-
* @param {Map<string, string>} attributes The attributes to add
|
|
35
|
-
*/
|
|
36
|
-
export declare function addAttributes(options: {
|
|
37
|
-
attributes?: Map<string, string>;
|
|
38
|
-
}, attributes: Map<string, string>): void;
|
|
39
|
-
/**
|
|
40
|
-
* Renders an element with the given options
|
|
41
|
-
* @param {RenderOptions} options Options to be used while rendering
|
|
42
|
-
* @param {string | HTMLElement} content What to fill the parent with.
|
|
43
|
-
* If the content is a string, it should be properly formatted HTML
|
|
44
|
-
* @return {HTMLElement} The parent with the new child
|
|
45
|
-
*/
|
|
46
|
-
export declare function renderWithOptions(options: RenderOptions, content: string | HTMLElement): HTMLElement;
|
|
47
|
-
/**
|
|
48
|
-
* Interface for options to use while rendering a button element
|
|
49
|
-
*/
|
|
50
|
-
export interface ButtonOptions {
|
|
51
|
-
/**
|
|
52
|
-
* The HTML id of the button
|
|
53
|
-
*/
|
|
54
|
-
id: string;
|
|
55
|
-
/**
|
|
56
|
-
* The text to display in the button, can also be HTML
|
|
57
|
-
*/
|
|
58
|
-
buttonText: string;
|
|
59
|
-
/**
|
|
60
|
-
* Optional classes to apply to the button
|
|
61
|
-
*/
|
|
62
|
-
classNames?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Optional icon to display in the button
|
|
65
|
-
*/
|
|
66
|
-
icon?: string;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Construct a HTML button string from the given options
|
|
70
|
-
* @param {ButtonOptions} options The options for the button
|
|
71
|
-
* @return {string} HTML string for the button
|
|
72
|
-
*/
|
|
73
|
-
export declare function renderButton(options: ButtonOptions): string;
|
|
74
|
-
/**
|
|
75
|
-
* Constructs the options for use within an HTML select element
|
|
76
|
-
* @param {Array<T>} options All options to display in the list
|
|
77
|
-
* @param {function(T):string} optionText Function to convert the elements to a string
|
|
78
|
-
* @param {T} selected The initially selected element in the list, if any
|
|
79
|
-
* @return {string} The string representation of the select options
|
|
80
|
-
*/
|
|
81
|
-
export declare function renderSelectOptions<T extends string>(options: Array<T>, optionText: (option: T) => string, selected?: T): string;
|
|
82
|
-
/**
|
|
83
|
-
* Build a string representation of an HTML label element
|
|
84
|
-
* @param {string} labelText Optional text to display in a label
|
|
85
|
-
* If not provided, no label is created
|
|
86
|
-
* @param {string} forElement The id of the element this label is for
|
|
87
|
-
* @return {string} The HTML string of the label
|
|
88
|
-
*/
|
|
89
|
-
export declare function renderLabel(labelText: string | undefined, forElement: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Constructs an HTML select element
|
|
92
|
-
* @param {string} selectId The HTML id for the element
|
|
93
|
-
* @param {Array<T>} options to display in the list
|
|
94
|
-
* @param {function(T):string} optionText to convert elements to a string
|
|
95
|
-
* @param {T} selected The initially selected element in the list, if any
|
|
96
|
-
* @param {string} labelText Optional text to display in a label
|
|
97
|
-
* @return {string} The string representation of the select element
|
|
98
|
-
*/
|
|
99
|
-
export declare function renderSelect<T extends string>(selectId: string, options: Array<T>, optionText: (option: T) => string, selected?: T, labelText?: string): string;
|
|
100
|
-
/**
|
|
101
|
-
* Helper superclass to handle storing options used during rendering
|
|
102
|
-
* to allow re-rendering without needing to explicitly store used options each time
|
|
103
|
-
*/
|
|
104
|
-
export declare abstract class Renderable<Options = RenderOptions> extends EventTarget {
|
|
105
|
-
/**
|
|
106
|
-
* The options to render with
|
|
107
|
-
*/
|
|
108
|
-
private _renderOptions?;
|
|
109
|
-
protected get renderOptions(): Options;
|
|
110
|
-
/**
|
|
111
|
-
* Render this component into the DOM
|
|
112
|
-
* @param {Options} options Optional options to render with. If omitted, stored options are used
|
|
113
|
-
*/
|
|
114
|
-
render(options?: Options): void;
|
|
115
|
-
/**
|
|
116
|
-
* Internal method to actually perform the rendering
|
|
117
|
-
* @param {Options} options The options to render with
|
|
118
|
-
*/
|
|
119
|
-
protected abstract _render(options: Options): void;
|
|
120
|
-
}
|