@inquirer/rawlist 5.1.0 → 5.2.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 +4 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +14 -3
- package/package.json +19 -20
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ const answer = await rawlist({
|
|
|
72
72
|
| message | `string` | yes | The question to ask |
|
|
73
73
|
| choices | `Choice[]` | yes | List of the available choices. |
|
|
74
74
|
| loop | `boolean` | no | Defaults to `true`. When set to `false`, the cursor will be constrained to the top and bottom of the choice list without looping. |
|
|
75
|
-
| default | `Value` | no | The value of the choice to preselect. If the value is not found, no choice is preselected.
|
|
75
|
+
| default | `Value` | no | The value of the choice to preselect. If the value is not found, no choice is preselected. |
|
|
76
76
|
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
|
|
77
77
|
|
|
78
78
|
`Separator` objects can be used in the `choices` array to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (`new Separator('-- Dependencies --')`). This option is often used to add labels to groups within long list of options.
|
|
@@ -87,6 +87,7 @@ type Choice<Value> = {
|
|
|
87
87
|
name?: string;
|
|
88
88
|
short?: string;
|
|
89
89
|
key?: string;
|
|
90
|
+
description?: string;
|
|
90
91
|
};
|
|
91
92
|
```
|
|
92
93
|
|
|
@@ -96,6 +97,7 @@ Here's each property:
|
|
|
96
97
|
- `name`: This is the string displayed in the choice list.
|
|
97
98
|
- `short`: Once the prompt is done (press enter), we'll use `short` if defined to render next to the question. By default we'll use `name`.
|
|
98
99
|
- `key`: The key of the choice. Displayed as `key) name`.
|
|
100
|
+
- `description`: Option description which appears below the list when the choice is selected.
|
|
99
101
|
|
|
100
102
|
`choices` can also be an array of string, in which case the string will be used both as the `value` and the `name`.
|
|
101
103
|
|
|
@@ -115,6 +117,7 @@ type Theme = {
|
|
|
115
117
|
message: (text: string, status: 'idle' | 'done' | 'loading') => string;
|
|
116
118
|
error: (text: string) => string;
|
|
117
119
|
highlight: (text: string) => string;
|
|
120
|
+
description: (text: string) => string;
|
|
118
121
|
};
|
|
119
122
|
};
|
|
120
123
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { Separator, type Theme } from '@inquirer/core';
|
|
2
2
|
import type { PartialDeep } from '@inquirer/type';
|
|
3
|
+
type RawlistTheme = {
|
|
4
|
+
style: {
|
|
5
|
+
description: (text: string) => string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
3
8
|
type Choice<Value> = {
|
|
4
9
|
value: Value;
|
|
5
10
|
name?: string;
|
|
6
11
|
short?: string;
|
|
7
12
|
key?: string;
|
|
13
|
+
description?: string;
|
|
8
14
|
};
|
|
9
15
|
declare const _default: <Value>(config: {
|
|
10
16
|
message: string;
|
|
11
17
|
choices: readonly (Separator | Value | Choice<Value>)[];
|
|
12
18
|
loop?: boolean | undefined;
|
|
13
|
-
theme?: PartialDeep<Theme
|
|
19
|
+
theme?: PartialDeep<Theme<RawlistTheme>> | undefined;
|
|
14
20
|
default?: NoInfer<Value> | undefined;
|
|
15
21
|
}, context?: import("@inquirer/type").Context) => Promise<Value>;
|
|
16
22
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { createPrompt, useMemo, useState, useKeypress, usePrefix, isDownKey, isEnterKey, isUpKey, Separator, makeTheme, ValidationError, } from '@inquirer/core';
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
3
|
const numberRegex = /\d+/;
|
|
4
|
+
const rawlistTheme = {
|
|
5
|
+
style: {
|
|
6
|
+
description: (text) => styleText('cyan', text),
|
|
7
|
+
},
|
|
8
|
+
};
|
|
4
9
|
function isSelectableChoice(choice) {
|
|
5
10
|
return choice != null && !Separator.isSeparator(choice);
|
|
6
11
|
}
|
|
@@ -25,6 +30,7 @@ function normalizeChoices(choices) {
|
|
|
25
30
|
name,
|
|
26
31
|
short: choice.short ?? name,
|
|
27
32
|
key: choice.key ?? String(index),
|
|
33
|
+
description: choice.description,
|
|
28
34
|
};
|
|
29
35
|
});
|
|
30
36
|
}
|
|
@@ -53,7 +59,7 @@ export default createPrompt((config, done) => {
|
|
|
53
59
|
return defaultChoice?.key ?? '';
|
|
54
60
|
});
|
|
55
61
|
const [errorMsg, setError] = useState();
|
|
56
|
-
const theme = makeTheme(config.theme);
|
|
62
|
+
const theme = makeTheme(rawlistTheme, config.theme);
|
|
57
63
|
const prefix = usePrefix({ status, theme });
|
|
58
64
|
const bounds = useMemo(() => {
|
|
59
65
|
const first = choices.findIndex(isSelectableChoice);
|
|
@@ -113,7 +119,7 @@ export default createPrompt((config, done) => {
|
|
|
113
119
|
return ` ${choice.separator}`;
|
|
114
120
|
}
|
|
115
121
|
const line = ` ${choice.key}) ${choice.name}`;
|
|
116
|
-
if (choice.key === value
|
|
122
|
+
if (choice.key === value) {
|
|
117
123
|
return theme.style.highlight(line);
|
|
118
124
|
}
|
|
119
125
|
return line;
|
|
@@ -123,9 +129,14 @@ export default createPrompt((config, done) => {
|
|
|
123
129
|
if (errorMsg) {
|
|
124
130
|
error = theme.style.error(errorMsg);
|
|
125
131
|
}
|
|
132
|
+
const [selectedChoice] = getSelectedChoice(value, choices);
|
|
133
|
+
let description = '';
|
|
134
|
+
if (!errorMsg && selectedChoice?.description) {
|
|
135
|
+
description = theme.style.description(selectedChoice.description);
|
|
136
|
+
}
|
|
126
137
|
return [
|
|
127
138
|
`${prefix} ${message} ${value}`,
|
|
128
|
-
[choicesStr, error].filter(Boolean).join('\n'),
|
|
139
|
+
[choicesStr, error, description].filter(Boolean).join('\n'),
|
|
129
140
|
];
|
|
130
141
|
});
|
|
131
142
|
export { Separator } from '@inquirer/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/rawlist",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Inquirer rawlist prompt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -42,42 +42,38 @@
|
|
|
42
42
|
"zsh"
|
|
43
43
|
],
|
|
44
44
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/rawlist/README.md",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
45
47
|
"repository": {
|
|
46
48
|
"type": "git",
|
|
47
49
|
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
|
48
50
|
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
52
54
|
"type": "module",
|
|
55
|
+
"sideEffects": false,
|
|
53
56
|
"exports": {
|
|
54
|
-
"./package.json": "./package.json",
|
|
55
57
|
".": {
|
|
56
58
|
"types": "./dist/index.d.ts",
|
|
57
59
|
"default": "./dist/index.js"
|
|
58
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"./package.json": "./package.json"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
59
65
|
},
|
|
60
|
-
"files": [
|
|
61
|
-
"dist"
|
|
62
|
-
],
|
|
63
66
|
"scripts": {
|
|
64
67
|
"tsc": "tsc"
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
67
|
-
"@inquirer/core": "^11.1.
|
|
68
|
-
"@inquirer/type": "^4.0.
|
|
70
|
+
"@inquirer/core": "^11.1.2",
|
|
71
|
+
"@inquirer/type": "^4.0.3"
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"@inquirer/testing": "^3.0
|
|
72
|
-
"@repo/tsconfig": "0.0.0",
|
|
74
|
+
"@inquirer/testing": "^3.1.0",
|
|
73
75
|
"typescript": "^5.9.3"
|
|
74
76
|
},
|
|
75
|
-
"engines": {
|
|
76
|
-
"node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
|
|
77
|
-
},
|
|
78
|
-
"publishConfig": {
|
|
79
|
-
"access": "public"
|
|
80
|
-
},
|
|
81
77
|
"peerDependencies": {
|
|
82
78
|
"@types/node": ">=18"
|
|
83
79
|
},
|
|
@@ -86,7 +82,10 @@
|
|
|
86
82
|
"optional": true
|
|
87
83
|
}
|
|
88
84
|
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0"
|
|
87
|
+
},
|
|
89
88
|
"main": "./dist/index.js",
|
|
90
89
|
"types": "./dist/index.d.ts",
|
|
91
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "53dbf6c492883546f6f9f2d5b9a78cbc00bd434c"
|
|
92
91
|
}
|