From 8b69c603e89b195853849604809aef8b3e655633 Mon Sep 17 00:00:00 2001 From: Elia Lazzari Date: Fri, 29 Apr 2022 14:57:43 +0200 Subject: [PATCH] Increased version number and updated docs --- DOCS.md | 2 +- README.md | 25 +++ docs/FileManagerPopup.md | 156 ------------------ docs/FileSelectorPopup.md | 156 ++++++++++++++++++ examples/tcp_simulator.mjs | 4 +- package.json | 2 +- src/ConsoleGui.js | 4 +- ...leManagerPopup.js => FileSelectorPopup.js} | 54 +++--- src/components/widgets/index.js | 2 +- 9 files changed, 215 insertions(+), 190 deletions(-) delete mode 100644 docs/FileManagerPopup.md create mode 100644 docs/FileSelectorPopup.md rename src/components/widgets/{FileManagerPopup.js => FileSelectorPopup.js} (86%) diff --git a/DOCS.md b/DOCS.md index 0f8f3ad..58a4c45 100644 --- a/DOCS.md +++ b/DOCS.md @@ -9,6 +9,6 @@ To view the documentation for a specific component or class, click on the links * [ButtonPopup](docs/ButtonPopup.md) * [ConfirmPopup](docs/ConfirmPopup.md) * [CustomPopup](docs/CustomPopup.md) -* [FileManagerPopup](docs/FileManagerPopup.md) +* [FileSelectorPopup](docs/FileSelectorPopup.md) * [InputPopup](docs/InputPopup.md) * [OptionPopup](docs/OptionPopup.md) diff --git a/README.md b/README.md index 896b01b..7786276 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,31 @@ In the next steps I will add a new kind of components: InPageComponents, that wi That means that they allows to build a custom popup widget with components inside. ![Animation](https://user-images.githubusercontent.com/14907987/165717880-db959165-8c43-4780-b76c-190172de25d5.gif) + + +## To create a File Selector popup +```js +new FileSelectorPopup("popupFileManager", "File Manager", "./").show().on("confirm", (file) => { + GUI.warn(`File selected: ${file}`) + drawGui() +}) +``` +### Class FileSelectorPopup: +constructor(id, title, content, width) + - id: string + - title: string + - basePath: string - _The main path of the popup. re case sensitive._ + - limitToPath: boolean - _If true, the user can select a directory. Otherwise, only files are selectable. When true, to enter a directory, the user must press the space key instead of the enter key._ + - allowedExtensions: Array<string> - _The allowed extensions. If not set, all extensions are allowed. The extensions a can only select files in the path. If false, the user can select files in the path and parent directories._ + +>This class is used to create a popup with a file input to select a file or a directory. It will run a promise with fs.readdir to get the list of files and directories. The user can select a file or a directory and the popup will be closed. + +![FileSelectorPopup](https://user-images.githubusercontent.com/14907987/165938464-c1426102-b598-42bb-8597-6337f0bcb009.gif) + +Emits the following events: +- "confirm" when the user confirm the file or directory selection. The file or directory path is passed as parameter like this: {path: "path/to/file", name: "file.ext"} +- "cancel" when the user cancel the file or directory selection. +- "exit" when the user exit All class of components will be destroyed when the popup is closed. The event listeners are removed from the store. Then the garbage collector will clean the memory. diff --git a/docs/FileManagerPopup.md b/docs/FileManagerPopup.md deleted file mode 100644 index f1bf7b4..0000000 --- a/docs/FileManagerPopup.md +++ /dev/null @@ -1,156 +0,0 @@ -## Classes - -
-
FileManagerPopupEventEmitter
-
-
- -## Constants - -
-
CM : ConsoleManager
-

the instance of ConsoleManager (singleton)

-
-
- - - -## FileManagerPopup ⇐ EventEmitter -**Kind**: global class -**Extends**: EventEmitter - -* [FileManagerPopup](#FileManagerPopup) ⇐ EventEmitter - * [new FileManagerPopup(id, title, basePath, [limitToPath], [allowedExtensions], visible)](#new_FileManagerPopup_new) - * [.listDir(path)](#FileManagerPopup+listDir) ⇒ Promise.<Array.<object>> - * [.updateList(path)](#FileManagerPopup+updateList) - * [.keyListner(str, key)](#FileManagerPopup+keyListner) - * [.getSelected()](#FileManagerPopup+getSelected) ⇒ string \| number - * [.setSelected(selected)](#FileManagerPopup+setSelected) ⇒ [FileManagerPopup](#FileManagerPopup) - * [.show()](#FileManagerPopup+show) ⇒ [FileManagerPopup](#FileManagerPopup) - * [.hide()](#FileManagerPopup+hide) ⇒ [FileManagerPopup](#FileManagerPopup) - * [.isVisible()](#FileManagerPopup+isVisible) ⇒ boolean - * [.manageInput()](#FileManagerPopup+manageInput) ⇒ [FileManagerPopup](#FileManagerPopup) - * [.unManageInput()](#FileManagerPopup+unManageInput) ⇒ [FileManagerPopup](#FileManagerPopup) - * [.draw()](#FileManagerPopup+draw) ⇒ [FileManagerPopup](#FileManagerPopup) - - - -### new FileManagerPopup(id, title, basePath, [limitToPath], [allowedExtensions], visible) -This class is used to create a popup with a file input to select a file or a directory. It will run a promise with fs.readdir to get the list of files and directories. The user can select a file or a directory and the popup will be closed. ![FileManagerPopup](https://user-images.githubusercontent.com/14907987/165938464-c1426102-b598-42bb-8597-6337f0bcb009.gif) Emits the following events: - "confirm" when the user confirm the file or directory selection. The file or directory path is passed as parameter like this: {path: "path/to/file", name: "file.ext"} - "cancel" when the user cancel the file or directory selection. - "exit" when the user exit - - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| id | string | | The id of the popup. | -| title | string | | The title of the popup. | -| basePath | string | | The main path of the popup. re case sensitive. | -| [limitToPath] | boolean | false | If true, the user * @param {boolean} [selectDirectory=false] - If true, the user can select a directory. Otherwise, only files are selectable. When true, to enter a directory, the user must press the space key instead of the enter key. | -| [allowedExtensions] | Array.<string> | [] | The allowed extensions. If not set, all extensions are allowed. The extensions a can only select files in the path. If false, the user can select files in the path and parent directories. | -| visible | boolean | | If the popup is visible. Default is false (make it appears using show()). | - -**Example** -```js -const popup = new FileManagerPopup("popup1", "Choose the file", "./examples").show().on("confirm", (selected) => { console.log(selected) }) // show the popup and wait for the user to confirm -``` - - -### fileManagerPopup.listDir(path) ⇒ Promise.<Array.<object>> -This function is used to load the list of files and directories in the current path. it return a promise with the list of files and directories. The list is an array of objects like this: [{text: "📄 file.ext", name: "file.ext", type: "file", path: "path/to/file.ext"}, {text: "📁 dir/", name: "dir", type: "dir", path: "path/to/dir"}] - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: Promise.<Array.<object>> - The list of files and directories. - -| Param | Type | Description | -| --- | --- | --- | -| path | string | The path to load the list. | - - - -### fileManagerPopup.updateList(path) -This function calls the updateList function and store the result to this.options, it also refresh the list of files and directories. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) - -| Param | Type | Description | -| --- | --- | --- | -| path | string | The path to load the list. | - - - -### fileManagerPopup.keyListner(str, key) -This function is used to make the ConsoleManager handle the key events when the popup is showed. Inside this function are defined all the keys that can be pressed and the actions to do when they are pressed. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) - -| Param | Type | Description | -| --- | --- | --- | -| str | string | The string of the input. | -| key | Object | The key object. | - - - -### fileManagerPopup.getSelected() ⇒ string \| number -This function is used to get the selected option. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: string \| number - The selected value of the popup. - - -### fileManagerPopup.setSelected(selected) ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to change the selection of the popup. It also refresh the ConsoleManager. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - -| Param | Type | Description | -| --- | --- | --- | -| selected | string \| number | The new value of the selection. | - - - -### fileManagerPopup.show() ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to show the popup. It also register the key events and refresh the ConsoleManager. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - - -### fileManagerPopup.hide() ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - - -### fileManagerPopup.isVisible() ⇒ boolean -This function is used to get the visibility of the popup. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: boolean - The visibility of the popup. - - -### fileManagerPopup.manageInput() ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to add the FileManagerPopup key listener callback to te ConsoleManager. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - - -### fileManagerPopup.unManageInput() ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to remove the FileManagerPopup key listener callback to te ConsoleManager. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - - -### fileManagerPopup.draw() ⇒ [FileManagerPopup](#FileManagerPopup) -This function is used to draw the FileManagerPopup to the screen in the middle. - -**Kind**: instance method of [FileManagerPopup](#FileManagerPopup) -**Returns**: [FileManagerPopup](#FileManagerPopup) - The instance of the FileManagerPopup. - - -## CM : ConsoleManager -the instance of ConsoleManager (singleton) - -**Kind**: global constant diff --git a/docs/FileSelectorPopup.md b/docs/FileSelectorPopup.md new file mode 100644 index 0000000..8c9ae53 --- /dev/null +++ b/docs/FileSelectorPopup.md @@ -0,0 +1,156 @@ +## Classes + +
+
FileSelectorPopupEventEmitter
+
+
+ +## Constants + +
+
CM : ConsoleManager
+

the instance of ConsoleManager (singleton)

+
+
+ + + +## FileSelectorPopup ⇐ EventEmitter +**Kind**: global class +**Extends**: EventEmitter + +* [FileSelectorPopup](#FileSelectorPopup) ⇐ EventEmitter + * [new FileSelectorPopup(id, title, basePath, [limitToPath], [allowedExtensions], visible)](#new_FileSelectorPopup_new) + * [.listDir(path)](#FileSelectorPopup+listDir) ⇒ Promise.<Array.<object>> + * [.updateList(path)](#FileSelectorPopup+updateList) + * [.keyListner(str, key)](#FileSelectorPopup+keyListner) + * [.getSelected()](#FileSelectorPopup+getSelected) ⇒ string \| number + * [.setSelected(selected)](#FileSelectorPopup+setSelected) ⇒ [FileSelectorPopup](#FileSelectorPopup) + * [.show()](#FileSelectorPopup+show) ⇒ [FileSelectorPopup](#FileSelectorPopup) + * [.hide()](#FileSelectorPopup+hide) ⇒ [FileSelectorPopup](#FileSelectorPopup) + * [.isVisible()](#FileSelectorPopup+isVisible) ⇒ boolean + * [.manageInput()](#FileSelectorPopup+manageInput) ⇒ [FileSelectorPopup](#FileSelectorPopup) + * [.unManageInput()](#FileSelectorPopup+unManageInput) ⇒ [FileSelectorPopup](#FileSelectorPopup) + * [.draw()](#FileSelectorPopup+draw) ⇒ [FileSelectorPopup](#FileSelectorPopup) + + + +### new FileSelectorPopup(id, title, basePath, [limitToPath], [allowedExtensions], visible) +This class is used to create a popup with a file input to select a file or a directory. It will run a promise with fs.readdir to get the list of files and directories. The user can select a file or a directory and the popup will be closed. ![FileSelectorPopup](https://user-images.githubusercontent.com/14907987/165938464-c1426102-b598-42bb-8597-6337f0bcb009.gif) Emits the following events: - "confirm" when the user confirm the file or directory selection. The file or directory path is passed as parameter like this: {path: "path/to/file", name: "file.ext"} - "cancel" when the user cancel the file or directory selection. - "exit" when the user exit + + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| id | string | | The id of the popup. | +| title | string | | The title of the popup. | +| basePath | string | | The main path of the popup. re case sensitive. | +| [limitToPath] | boolean | false | If true, the user can select a directory. Otherwise, only files are selectable. When true, to enter a directory, the user must press the space key instead of the enter key. | +| [allowedExtensions] | Array.<string> | [] | The allowed extensions. If not set, all extensions are allowed. The extensions a can only select files in the path. If false, the user can select files in the path and parent directories. | +| visible | boolean | | If the popup is visible. Default is false (make it appears using show()). | + +**Example** +```js +const popup = new FileSelectorPopup("popup1", "Choose the file", "./examples").show().on("confirm", (selected) => { console.log(selected) }) // show the popup and wait for the user to confirm +``` + + +### fileSelectorPopup.listDir(path) ⇒ Promise.<Array.<object>> +This function is used to load the list of files and directories in the current path. it return a promise with the list of files and directories. The list is an array of objects like this: [{text: "📄 file.ext", name: "file.ext", type: "file", path: "path/to/file.ext"}, {text: "📁 dir/", name: "dir", type: "dir", path: "path/to/dir"}] + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: Promise.<Array.<object>> - The list of files and directories. + +| Param | Type | Description | +| --- | --- | --- | +| path | string | The path to load the list. | + + + +### fileSelectorPopup.updateList(path) +This function calls the updateList function and store the result to this.options, it also refresh the list of files and directories. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) + +| Param | Type | Description | +| --- | --- | --- | +| path | string | The path to load the list. | + + + +### fileSelectorPopup.keyListner(str, key) +This function is used to make the ConsoleManager handle the key events when the popup is showed. Inside this function are defined all the keys that can be pressed and the actions to do when they are pressed. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) + +| Param | Type | Description | +| --- | --- | --- | +| str | string | The string of the input. | +| key | Object | The key object. | + + + +### fileSelectorPopup.getSelected() ⇒ string \| number +This function is used to get the selected option. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: string \| number - The selected value of the popup. + + +### fileSelectorPopup.setSelected(selected) ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to change the selection of the popup. It also refresh the ConsoleManager. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + +| Param | Type | Description | +| --- | --- | --- | +| selected | string \| number | The new value of the selection. | + + + +### fileSelectorPopup.show() ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to show the popup. It also register the key events and refresh the ConsoleManager. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + + +### fileSelectorPopup.hide() ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + + +### fileSelectorPopup.isVisible() ⇒ boolean +This function is used to get the visibility of the popup. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: boolean - The visibility of the popup. + + +### fileSelectorPopup.manageInput() ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to add the FileSelectorPopup key listener callback to te ConsoleManager. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + + +### fileSelectorPopup.unManageInput() ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to remove the FileSelectorPopup key listener callback to te ConsoleManager. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + + +### fileSelectorPopup.draw() ⇒ [FileSelectorPopup](#FileSelectorPopup) +This function is used to draw the FileSelectorPopup to the screen in the middle. + +**Kind**: instance method of [FileSelectorPopup](#FileSelectorPopup) +**Returns**: [FileSelectorPopup](#FileSelectorPopup) - The instance of the FileSelectorPopup. + + +## CM : ConsoleManager +the instance of ConsoleManager (singleton) + +**Kind**: global constant diff --git a/examples/tcp_simulator.mjs b/examples/tcp_simulator.mjs index 08b3a11..741869b 100644 --- a/examples/tcp_simulator.mjs +++ b/examples/tcp_simulator.mjs @@ -12,7 +12,7 @@ const modeList = ["random", "linear"] const clientManager = new EventEmitter() -import { ConsoleManager, OptionPopup, InputPopup, PageBuilder, ButtonPopup, ConfirmPopup, CustomPopup, FileManagerPopup } from '../src/ConsoleGui.js' +import { ConsoleManager, OptionPopup, InputPopup, PageBuilder, ButtonPopup, ConfirmPopup, CustomPopup, FileSelectorPopup } from '../src/ConsoleGui.js' const GUI = new ConsoleManager({ title: 'TCP Simulator', // Title of the console logsPageSize: 8, // Number of lines to show in logs page @@ -202,7 +202,7 @@ GUI.on("keypressed", (key) => { new CustomPopup("popupCustom1", "See that values", p, 32).show() break case 'f': - new FileManagerPopup("popupFileManager", "File Manager", "./").show() + new FileSelectorPopup("popupFileManager", "File Manager", "./").show() break case 'q': new ConfirmPopup("popupQuit", "Are you sure you want to quit?").show().on("confirm", () => closeApp()) diff --git a/package.json b/package.json index ef36b2d..79e5dee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "console-gui-tools", - "version": "1.1.10", + "version": "1.1.11", "description": "A simple library to draw option menu, text popup or other widgets and layout on a Node.js console.", "main": "src/ConsoleGui.js", "type": "module", diff --git a/src/ConsoleGui.js b/src/ConsoleGui.js index 9a89830..595ab90 100644 --- a/src/ConsoleGui.js +++ b/src/ConsoleGui.js @@ -2,7 +2,7 @@ import { EventEmitter } from "events" import readline from 'readline'; import { PageBuilder, Screen } from './components/index.js'; import { DoubleLayout } from "./components/layout/index.js"; -import { InputPopup, OptionPopup, ButtonPopup, ConfirmPopup, CustomPopup, FileManagerPopup } from "./components/widgets/index.js"; +import { InputPopup, OptionPopup, ButtonPopup, ConfirmPopup, CustomPopup, FileSelectorPopup } from "./components/widgets/index.js"; /** * @class ConsoleManager @@ -286,5 +286,5 @@ export { ConfirmPopup, ButtonPopup, CustomPopup, - FileManagerPopup + FileSelectorPopup } \ No newline at end of file diff --git a/src/components/widgets/FileManagerPopup.js b/src/components/widgets/FileSelectorPopup.js similarity index 86% rename from src/components/widgets/FileManagerPopup.js rename to src/components/widgets/FileSelectorPopup.js index 218c309..096dc11 100644 --- a/src/components/widgets/FileManagerPopup.js +++ b/src/components/widgets/FileSelectorPopup.js @@ -4,13 +4,13 @@ import fs from "fs" import path from "path" /** - * @class FileManagerPopup + * @class FileSelectorPopup * @extends EventEmitter * @description This class is used to create a popup with a file input to select a file or a directory. * It will run a promise with fs.readdir to get the list of files and directories. * The user can select a file or a directory and the popup will be closed. * - * ![FileManagerPopup](https://user-images.githubusercontent.com/14907987/165938464-c1426102-b598-42bb-8597-6337f0bcb009.gif) + * ![FileSelectorPopup](https://user-images.githubusercontent.com/14907987/165938464-c1426102-b598-42bb-8597-6337f0bcb009.gif) * * Emits the following events: * - "confirm" when the user confirm the file or directory selection. The file or directory path is passed as parameter like this: {path: "path/to/file", name: "file.ext"} @@ -20,13 +20,13 @@ import path from "path" * @param {string} title - The title of the popup. * @param {string} basePath - The main path of the popup. re case sensitive. - * @param {boolean} [limitToPath=false] - If true, the user * @param {boolean} [selectDirectory=false] - If true, the user can select a directory. Otherwise, only files are selectable. When true, to enter a directory, the user must press the space key instead of the enter key. + * @param {boolean} [limitToPath=false] - If true, the user can select a directory. Otherwise, only files are selectable. When true, to enter a directory, the user must press the space key instead of the enter key. * @param {Array} [allowedExtensions=[]] - The allowed extensions. If not set, all extensions are allowed. The extensions a can only select files in the path. If false, the user can select files in the path and parent directories. * @param {boolean} visible - If the popup is visible. Default is false (make it appears using show()). * - * @example const popup = new FileManagerPopup("popup1", "Choose the file", "./examples").show().on("confirm", (selected) => { console.log(selected) }) // show the popup and wait for the user to confirm + * @example const popup = new FileSelectorPopup("popup1", "Choose the file", "./examples").show().on("confirm", (selected) => { console.log(selected) }) // show the popup and wait for the user to confirm */ -export class FileManagerPopup extends EventEmitter { +export class FileSelectorPopup extends EventEmitter { constructor(id, title, basePath, selectDirectory = false, allowedExtensions = [], limitToPath = false, visible = false) { super(); /** @const {ConsoleManager} CM the instance of ConsoleManager (singleton) */ @@ -44,7 +44,7 @@ export class FileManagerPopup extends EventEmitter { this.selected = { text: `../`, name: "../", type: "dir", path: path.join(basePath, "../") }; if (this.CM.widgetsCollection[this.id]) { this.CM.unRegisterWidget(this); - const message = `FileManagerPopup ${this.id} already exists.`; + const message = `FileSelectorPopup ${this.id} already exists.`; this.CM.error(message); throw new Error(message); } @@ -59,7 +59,7 @@ export class FileManagerPopup extends EventEmitter { * [{text: "📄 file.ext", name: "file.ext", type: "file", path: "path/to/file.ext"}, {text: "📁 dir/", name: "dir", type: "dir", path: "path/to/dir"}] * @param {string} path - The path to load the list. * @returns {Promise>} The list of files and directories. - * @memberof FileManagerPopup + * @memberof FileSelectorPopup */ listDir(dir) { return new Promise((resolve, reject) => { @@ -92,7 +92,7 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function calls the updateList function and store the result to this.options, it also refresh the list of files and directories. * @param {string} path - The path to load the list. - * @memberof FileManagerPopup + * @memberof FileSelectorPopup */ updateList(_path) { if (this.limitToPath) { @@ -117,7 +117,7 @@ export class FileManagerPopup extends EventEmitter { * Inside this function are defined all the keys that can be pressed and the actions to do when they are pressed. * @param {string} str - The string of the input. * @param {Object} key - The key object. - * @memberof FileManagerPopup + * @memberof FileSelectorPopup */ keyListner(str, key) { const ind = this.options.indexOf(this.selected) @@ -213,7 +213,7 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function is used to get the selected option. * @returns {string | number} The selected value of the popup. - * @memberof FileManagerPopup + * @memberof FileSelectorPopup */ getSelected() { return this.selected @@ -222,8 +222,8 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function is used to change the selection of the popup. It also refresh the ConsoleManager. * @param {string | number} selected - The new value of the selection. - * @memberof FileManagerPopup - * @returns {FileManagerPopup} The instance of the FileManagerPopup. + * @memberof FileSelectorPopup + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. */ setSelected(selected, refresh = true) { this.selected = selected @@ -233,8 +233,8 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function is used to show the popup. It also register the key events and refresh the ConsoleManager. - * @returns {FileManagerPopup} The instance of the FileManagerPopup. - * @memberof FileManagerPopup + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. + * @memberof FileSelectorPopup */ show() { if (!this.visible) { @@ -247,8 +247,8 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager. - * @returns {FileManagerPopup} The instance of the FileManagerPopup. - * @memberof FileManagerPopup + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. + * @memberof FileSelectorPopup */ hide() { if (this.visible) { @@ -262,16 +262,16 @@ export class FileManagerPopup extends EventEmitter { /** * @description This function is used to get the visibility of the popup. * @returns {boolean} The visibility of the popup. - * @memberof FileManagerPopup + * @memberof FileSelectorPopup */ isVisible() { return this.visible } /** - * @description This function is used to add the FileManagerPopup key listener callback to te ConsoleManager. - * @returns {FileManagerPopup} The instance of the FileManagerPopup. - * @memberof FileManagerPopup + * @description This function is used to add the FileSelectorPopup key listener callback to te ConsoleManager. + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. + * @memberof FileSelectorPopup */ manageInput() { // Add a command input listener to change mode @@ -280,9 +280,9 @@ export class FileManagerPopup extends EventEmitter { } /** - * @description This function is used to remove the FileManagerPopup key listener callback to te ConsoleManager. - * @returns {FileManagerPopup} The instance of the FileManagerPopup. - * @memberof FileManagerPopup + * @description This function is used to remove the FileSelectorPopup key listener callback to te ConsoleManager. + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. + * @memberof FileSelectorPopup */ unManageInput() { // Add a command input listener to change mode @@ -291,9 +291,9 @@ export class FileManagerPopup extends EventEmitter { } /** - * @description This function is used to draw the FileManagerPopup to the screen in the middle. - * @returns {FileManagerPopup} The instance of the FileManagerPopup. - * @memberof FileManagerPopup + * @description This function is used to draw the FileSelectorPopup to the screen in the middle. + * @returns {FileSelectorPopup} The instance of the FileSelectorPopup. + * @memberof FileSelectorPopup */ draw() { // Change start index if selected is not in the adaptOptions return array @@ -335,4 +335,4 @@ export class FileManagerPopup extends EventEmitter { } } -export default FileManagerPopup \ No newline at end of file +export default FileSelectorPopup \ No newline at end of file diff --git a/src/components/widgets/index.js b/src/components/widgets/index.js index 65cb038..a72876e 100644 --- a/src/components/widgets/index.js +++ b/src/components/widgets/index.js @@ -3,4 +3,4 @@ export * from './OptionPopup.js'; export * from './ButtonPopup.js'; export * from './ConfirmPopup.js'; export * from './CustomPopup.js'; -export * from './FileManagerPopup.js'; \ No newline at end of file +export * from './FileSelectorPopup.js'; \ No newline at end of file