@inquirer/input 1.2.10 → 1.2.12
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/dist/cjs/index.js
CHANGED
|
@@ -8,10 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
const core_1 = require("@inquirer/core");
|
|
13
|
-
const chalk_1 = require("chalk");
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
17
|
exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
18
|
+
const { validate = () => true } = config;
|
|
15
19
|
const [status, setStatus] = (0, core_1.useState)('pending');
|
|
16
20
|
const [defaultValue = '', setDefaultValue] = (0, core_1.useState)(config.default);
|
|
17
21
|
const [errorMsg, setError] = (0, core_1.useState)(undefined);
|
|
@@ -26,7 +30,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
26
30
|
if ((0, core_1.isEnterKey)(key)) {
|
|
27
31
|
const answer = value || defaultValue;
|
|
28
32
|
setStatus('loading');
|
|
29
|
-
const isValid = yield
|
|
33
|
+
const isValid = yield validate(answer);
|
|
30
34
|
if (isValid === true) {
|
|
31
35
|
setValue(answer);
|
|
32
36
|
setStatus('done');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
default?: string;
|
|
4
|
-
transformer?: (value: string, { isFinal }: {
|
|
1
|
+
declare const _default: import("@inquirer/type").Prompt<string, {
|
|
2
|
+
message: string | Promise<string> | (() => Promise<string>);
|
|
3
|
+
default?: string | undefined;
|
|
4
|
+
transformer?: ((value: string, { isFinal }: {
|
|
5
5
|
isFinal: boolean;
|
|
6
|
-
}) => string;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
}) => string) | undefined;
|
|
7
|
+
validate?: ((value: string) => string | boolean | Promise<string | boolean>) | undefined;
|
|
8
|
+
}>;
|
|
9
9
|
export default _default;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createPrompt, useState, useKeypress, usePrefix, isEnterKey, isBackspaceKey, } from '@inquirer/core';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
export default createPrompt((config, done) => {
|
|
4
|
+
const { validate = () => true } = config;
|
|
4
5
|
const [status, setStatus] = useState('pending');
|
|
5
6
|
const [defaultValue = '', setDefaultValue] = useState(config.default);
|
|
6
7
|
const [errorMsg, setError] = useState(undefined);
|
|
@@ -15,7 +16,7 @@ export default createPrompt((config, done) => {
|
|
|
15
16
|
if (isEnterKey(key)) {
|
|
16
17
|
const answer = value || defaultValue;
|
|
17
18
|
setStatus('loading');
|
|
18
|
-
const isValid = await
|
|
19
|
+
const isValid = await validate(answer);
|
|
19
20
|
if (isValid === true) {
|
|
20
21
|
setValue(answer);
|
|
21
22
|
setStatus('done');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
default?: string;
|
|
4
|
-
transformer?: (value: string, { isFinal }: {
|
|
1
|
+
declare const _default: import("@inquirer/type").Prompt<string, {
|
|
2
|
+
message: string | Promise<string> | (() => Promise<string>);
|
|
3
|
+
default?: string | undefined;
|
|
4
|
+
transformer?: ((value: string, { isFinal }: {
|
|
5
5
|
isFinal: boolean;
|
|
6
|
-
}) => string;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
}) => string) | undefined;
|
|
7
|
+
validate?: ((value: string) => string | boolean | Promise<string | boolean>) | undefined;
|
|
8
|
+
}>;
|
|
9
9
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/input",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "Inquirer input text prompt",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/input/README.md",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@inquirer/core": "^
|
|
58
|
-
"@inquirer/type": "^1.1.
|
|
57
|
+
"@inquirer/core": "^5.0.1",
|
|
58
|
+
"@inquirer/type": "^1.1.5",
|
|
59
59
|
"chalk": "^4.1.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@inquirer/testing": "^2.1.
|
|
62
|
+
"@inquirer/testing": "^2.1.7"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "85784061d702778bc9dd48ca08f09ee9976b06ee"
|
|
88
88
|
}
|