forked from Araxeus/custom-electron-prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c96ea3
commit c7b6558
Showing
1 changed file
with
53 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Custom Electron Prompt | ||
|
||
[![NPM Version](https://img.shields.io/npm/v/custom-electron-prompt)](https://www.npmjs.com/package/custom-electron-prompt) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Araxeus/custom-electron-prompt/blob/main/LICENSE) | ||
[![NPM Version](https://img.shields.io/npm/v/custom-electron-prompt)](https://www.npmjs.com/package/custom-electron-prompt) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Araxeus/custom-electron-prompt/blob/main/LICENSE) | ||
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/Araxeus/custom-electron-prompt) | ||
[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://araxeus.github.io/custom-electron-prompt) | ||
|
||
|
@@ -19,7 +19,7 @@ There is also an option for a button with user-defined `onclick` function. | |
|
||
## Usage | ||
|
||
* 1: Install the npm package to your project directory with | ||
* 1: Install the npm package to your project directory with | ||
```bash | ||
npm install custom-electron-prompt | ||
``` | ||
|
@@ -29,19 +29,19 @@ There is also an option for a button with user-defined `onclick` function. | |
``` | ||
|
||
* 2: Import prompt | ||
|
||
```javascript | ||
const prompt = require('custom-electron-prompt') | ||
``` | ||
|
||
* 3: Create a prompt | ||
|
||
```javascript | ||
prompt([options, parentBrowserWindow]) | ||
``` | ||
|
||
calling the prompt function returns a Promise | ||
|
||
Promise resolve returns the input or returns null if prompt was canceled | ||
|
||
On error, Prompise reject returns custom error message | ||
|
@@ -87,15 +87,15 @@ keybindOptions: [ | |
] | ||
``` | ||
|
||
Return an array made of objects in format | ||
Return an array made of objects in format | ||
|
||
`{value: "copyAccelerator", accelerator: "Ctrl+Shift+Insert"}` | ||
`{value: "copyAccelerator", accelerator: "Ctrl+Shift+Insert"}` | ||
|
||
where `accelerator` is the input for the `value` you registered | ||
|
||
<details> | ||
<summary> Code Example </summary> | ||
|
||
```javascript | ||
const kb = ($value, $label, $default) => { return { value: $value, label: $label, default: $default } }; | ||
prompt({ | ||
|
@@ -119,7 +119,7 @@ prompt({ | |
.catch(console.error) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary> Screenshots </summary> | ||
|
||
|
@@ -150,7 +150,7 @@ counterOptions: { | |
|
||
<details> | ||
<summary> Code Example </summary> | ||
|
||
```javascript | ||
prompt({ | ||
title: "Counter", | ||
|
@@ -165,7 +165,7 @@ prompt({ | |
}, win).then(input => console.log(`input == ${input}`)).catch(console.error) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary> Screenshots </summary> | ||
|
||
|
@@ -193,7 +193,7 @@ Must specify selectOptions with valid entries in **one** of the following format | |
|
||
<details> | ||
<summary> Code Example </summary> | ||
|
||
```javascript | ||
prompt({ | ||
title: "Select", | ||
|
@@ -209,7 +209,7 @@ prompt({ | |
}, win).then(input => console.log(`input == ${input}`)).catch(console.error) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary> Screenshots </summary> | ||
|
||
|
@@ -237,48 +237,51 @@ Must specify multiInputOptions with valid entries in the following format: | |
|
||
<details> | ||
<summary> Code Example </summary> | ||
|
||
```javascript | ||
prompt({ | ||
title: "credentials", | ||
label: "Please enter username and password", | ||
type: "multiInput", | ||
multiInputOptions: | ||
[{ | ||
inputAttrs: | ||
{ | ||
type: "email", | ||
required: true, | ||
placeholder: "email" | ||
} | ||
}, | ||
{ | ||
value: "2", | ||
selectOptions: ["thisReturn0", "thisReturn1", "imSelected", "thisReturn3"], | ||
// selectOptions: {0: "thisReturn0", 1: "thisReturn1", 2: "imSelected" , potato: "thisReturnPotato"}, | ||
}, | ||
{ | ||
inputAttrs: | ||
{ | ||
type: "password", | ||
placeholder: "password" | ||
} | ||
}], | ||
resizable: true, | ||
height: 150, | ||
width: 300, | ||
title: "credentials", | ||
label: "Login Info:", | ||
type: "multiInput", | ||
multiInputOptions: | ||
[ | ||
{ | ||
inputAttrs: | ||
{ | ||
type: "email", | ||
required: true, | ||
placeholder: "email" | ||
} | ||
}, | ||
{ | ||
inputAttrs: | ||
{ | ||
type: "password", | ||
placeholder: "password" | ||
} | ||
}, | ||
{ | ||
selectOptions: { na: "North America", eu: "Europe", other: "Other" }, | ||
value: "2" | ||
} | ||
], | ||
resizable: true, | ||
width: 300, | ||
height: 225, | ||
}, win).then(input => console.log(`input == ${input}`)).catch(console.error) | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary> Screenshots </summary> | ||
|
||
![](https://github.com/amunim/custom-electron-prompt/blob/main/screenshots/multiInput/button.PNG) | ||
|
||
|
||
This screenshot also contains a custom button. | ||
|
||
|
||
![](screenshots/multiInput/multiInputSelect.PNG) | ||
|
||
</details> | ||
|
||
---- | ||
|
@@ -345,8 +348,8 @@ Adds an extra/custom button with special functionalities other than success or e | |
|
||
<details> | ||
<summary> Code Example </summary> | ||
|
||
|
||
```javascript | ||
await prompt({ | ||
title: 'Login credentials', | ||
|
@@ -378,7 +381,7 @@ await prompt({ | |
button: | ||
{ | ||
label: "Autofill", | ||
click: () => | ||
click: () => | ||
{ | ||
document.querySelectorAll("#data")[0].value = "[email protected]"; | ||
document.querySelectorAll("#data")[1].value = "mysecretrecipe"; | ||
|
@@ -395,8 +398,8 @@ await prompt({ | |
|
||
<details> | ||
<summary> Screenshots </summary> | ||
|
||
|
||
![](https://github.com/amunim/custom-electron-prompt/blob/main/screenshots/multiInput/button.PNG) | ||
</details> | ||
|
||
|