@inquirer/password 2.2.0 → 3.0.1

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 CHANGED
@@ -73,14 +73,14 @@ You can theme a prompt by passing a `theme` object option. The theme object only
73
73
 
74
74
  ```ts
75
75
  type Theme = {
76
- prefix: string;
76
+ prefix: string | { idle: string; done: string };
77
77
  spinner: {
78
78
  interval: number;
79
79
  frames: string[];
80
80
  };
81
81
  style: {
82
82
  answer: (text: string) => string;
83
- message: (text: string) => string;
83
+ message: (text: string, status: 'idle' | 'done' | 'loading') => string;
84
84
  error: (text: string) => string;
85
85
  help: (text: string) => string;
86
86
  };
package/dist/cjs/index.js CHANGED
@@ -17,14 +17,13 @@ const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
17
17
  exports.default = (0, core_1.createPrompt)((config, done) => {
18
18
  const { validate = () => true } = config;
19
19
  const theme = (0, core_1.makeTheme)(config.theme);
20
- const [status, setStatus] = (0, core_1.useState)('pending');
20
+ const [status, setStatus] = (0, core_1.useState)('idle');
21
21
  const [errorMsg, setError] = (0, core_1.useState)();
22
22
  const [value, setValue] = (0, core_1.useState)('');
23
- const isLoading = status === 'loading';
24
- const prefix = (0, core_1.usePrefix)({ isLoading, theme });
23
+ const prefix = (0, core_1.usePrefix)({ status, theme });
25
24
  (0, core_1.useKeypress)((key, rl) => __awaiter(void 0, void 0, void 0, function* () {
26
25
  // Ignore keypress while our prompt is doing other processing.
27
- if (status !== 'pending') {
26
+ if (status !== 'idle') {
28
27
  return;
29
28
  }
30
29
  if ((0, core_1.isEnterKey)(key)) {
@@ -41,7 +40,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
41
40
  // get cleared, forcing the user to re-enter the value instead of fixing it.
42
41
  rl.write(value);
43
42
  setError(isValid || 'You must provide a valid value');
44
- setStatus('pending');
43
+ setStatus('idle');
45
44
  }
46
45
  }
47
46
  else {
@@ -49,7 +48,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
49
48
  setError(undefined);
50
49
  }
51
50
  }));
52
- const message = theme.style.message(config.message);
51
+ const message = theme.style.message(config.message, status);
53
52
  let formattedValue = '';
54
53
  let helpTip;
55
54
  if (config.mask) {
@@ -3,14 +3,13 @@ import ansiEscapes from 'ansi-escapes';
3
3
  export default createPrompt((config, done) => {
4
4
  const { validate = () => true } = config;
5
5
  const theme = makeTheme(config.theme);
6
- const [status, setStatus] = useState('pending');
6
+ const [status, setStatus] = useState('idle');
7
7
  const [errorMsg, setError] = useState();
8
8
  const [value, setValue] = useState('');
9
- const isLoading = status === 'loading';
10
- const prefix = usePrefix({ isLoading, theme });
9
+ const prefix = usePrefix({ status, theme });
11
10
  useKeypress(async (key, rl) => {
12
11
  // Ignore keypress while our prompt is doing other processing.
13
- if (status !== 'pending') {
12
+ if (status !== 'idle') {
14
13
  return;
15
14
  }
16
15
  if (isEnterKey(key)) {
@@ -27,7 +26,7 @@ export default createPrompt((config, done) => {
27
26
  // get cleared, forcing the user to re-enter the value instead of fixing it.
28
27
  rl.write(value);
29
28
  setError(isValid || 'You must provide a valid value');
30
- setStatus('pending');
29
+ setStatus('idle');
31
30
  }
32
31
  }
33
32
  else {
@@ -35,7 +34,7 @@ export default createPrompt((config, done) => {
35
34
  setError(undefined);
36
35
  }
37
36
  });
38
- const message = theme.style.message(config.message);
37
+ const message = theme.style.message(config.message, status);
39
38
  let formattedValue = '';
40
39
  let helpTip;
41
40
  if (config.mask) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/password",
3
- "version": "2.2.0",
3
+ "version": "3.0.1",
4
4
  "engines": {
5
5
  "node": ">=18"
6
6
  },
@@ -57,12 +57,12 @@
57
57
  "license": "MIT",
58
58
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/password/README.md",
59
59
  "dependencies": {
60
- "@inquirer/core": "^9.1.0",
61
- "@inquirer/type": "^1.5.3",
60
+ "@inquirer/core": "^9.2.1",
61
+ "@inquirer/type": "^2.0.0",
62
62
  "ansi-escapes": "^4.3.2"
63
63
  },
64
64
  "devDependencies": {
65
- "@inquirer/testing": "^2.1.32"
65
+ "@inquirer/testing": "^2.1.34"
66
66
  },
67
67
  "scripts": {
68
68
  "tsc": "yarn run tsc:esm && yarn run tsc:cjs",
@@ -86,5 +86,5 @@
86
86
  }
87
87
  },
88
88
  "sideEffects": false,
89
- "gitHead": "0c039599ef88fe9eb804fe083ee386ec906a856f"
89
+ "gitHead": "9e29035c2efc78f44aed3c7732aee46ab1d64ca2"
90
90
  }