@inquirer/select 2.3.10 → 2.4.0
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 +8 -8
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/types/index.d.mts +1 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -64,14 +64,14 @@ const answer = await select({
|
|
|
64
64
|
|
|
65
65
|
## Options
|
|
66
66
|
|
|
67
|
-
| Property | Type
|
|
68
|
-
| -------- |
|
|
69
|
-
| message | `string`
|
|
70
|
-
| choices | `Array<{ value: string, name?: string, description?: string, disabled?: boolean \| string } \| Separator>` | yes | List of the available choices. The `value` will be returned as the answer, and used as display if no `name` is defined. Choices who're `disabled` will be displayed, but not selectable. The `description` will be displayed under the prompt when the cursor land over the choice. |
|
|
71
|
-
| default | `string`
|
|
72
|
-
| pageSize | `number`
|
|
73
|
-
| loop | `boolean`
|
|
74
|
-
| theme | [See Theming](#Theming)
|
|
67
|
+
| Property | Type | Required | Description |
|
|
68
|
+
| -------- | -------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| message | `string` | yes | The question to ask |
|
|
70
|
+
| choices | `Array<{ value: string, name?: string, short?: string, description?: string, disabled?: boolean \| string } \| Separator>` | yes | List of the available choices. The `value` will be returned as the answer, and used as display if no `name` is defined. Choices who're `disabled` will be displayed, but not selectable. The `description` will be displayed under the prompt when the cursor land over the choice. `short` if defined will be used instead of `name` once submitted. |
|
|
71
|
+
| default | `string` | no | Defines in front of which item the cursor will initially appear. When omitted, the cursor will appear on the first selectable item. |
|
|
72
|
+
| pageSize | `number` | no | By default, lists of choice longer than 7 will be paginated. Use this option to control how many choices will appear on the screen at once. |
|
|
73
|
+
| 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. |
|
|
74
|
+
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
|
|
75
75
|
|
|
76
76
|
The `Separator` object can be used 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.
|
|
77
77
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,6 +17,7 @@ function isSelectable(item) {
|
|
|
17
17
|
return !core_1.Separator.isSeparator(item) && !item.disabled;
|
|
18
18
|
}
|
|
19
19
|
exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
20
|
+
var _a, _b;
|
|
20
21
|
const { choices: items, loop = true, pageSize = 7 } = config;
|
|
21
22
|
const firstRender = (0, core_1.useRef)(true);
|
|
22
23
|
const theme = (0, core_1.makeTheme)(selectTheme, config.theme);
|
|
@@ -120,9 +121,9 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
120
121
|
loop,
|
|
121
122
|
});
|
|
122
123
|
if (status === 'done') {
|
|
123
|
-
const answer = selectedChoice.name
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const answer = (_b = (_a = selectedChoice.short) !== null && _a !== void 0 ? _a : selectedChoice.name) !== null && _b !== void 0 ? _b :
|
|
125
|
+
// TODO: Could we enforce that at the type level? Name should be defined for non-string values.
|
|
126
|
+
String(selectedChoice.value);
|
|
126
127
|
return `${prefix} ${message} ${theme.style.answer(answer)}`;
|
|
127
128
|
}
|
|
128
129
|
const choiceDescription = selectedChoice.description
|
package/dist/esm/index.mjs
CHANGED
|
@@ -114,7 +114,8 @@ export default createPrompt((config, done) => {
|
|
|
114
114
|
loop,
|
|
115
115
|
});
|
|
116
116
|
if (status === 'done') {
|
|
117
|
-
const answer = selectedChoice.
|
|
117
|
+
const answer = selectedChoice.short ??
|
|
118
|
+
selectedChoice.name ??
|
|
118
119
|
// TODO: Could we enforce that at the type level? Name should be defined for non-string values.
|
|
119
120
|
String(selectedChoice.value);
|
|
120
121
|
return `${prefix} ${message} ${theme.style.answer(answer)}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/select",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Inquirer select/list prompt",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/select/README.md",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@inquirer/core": "^9.0.
|
|
58
|
-
"@inquirer/figures": "^1.0.
|
|
59
|
-
"@inquirer/type": "^1.
|
|
57
|
+
"@inquirer/core": "^9.0.3",
|
|
58
|
+
"@inquirer/figures": "^1.0.4",
|
|
59
|
+
"@inquirer/type": "^1.5.0",
|
|
60
60
|
"ansi-escapes": "^4.3.2",
|
|
61
61
|
"yoctocolors-cjs": "^2.1.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@inquirer/testing": "^2.1.
|
|
64
|
+
"@inquirer/testing": "^2.1.26"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
|
|
68
68
|
"tsc:esm": "rm -rf dist/esm && tsc -p ./tsconfig.json",
|
|
69
69
|
"tsc:cjs": "rm -rf dist/cjs && tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs",
|
|
70
|
-
"
|
|
70
|
+
"tsc:watch": "tsc -p ./tsconfig.json --watch",
|
|
71
71
|
"attw": "attw --pack"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"sideEffects": false,
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "6e2ddec8ca97ee176f080efd2cba76e39b5b9628"
|
|
93
93
|
}
|