@inquirer/select 2.4.0 → 2.4.2
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 +54 -10
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.mjs +6 -3
- package/dist/esm/types/index.d.mts +1 -0
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -14,6 +14,25 @@ Simple interactive command line prompt to display a list of choices (single sele
|
|
|
14
14
|
<tr>
|
|
15
15
|
<td>
|
|
16
16
|
|
|
17
|
+
```sh
|
|
18
|
+
npm install @inquirer/prompts
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</td>
|
|
22
|
+
<td>
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
yarn add @inquirer/prompts
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
</td>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td colSpan="2" align="center">Or</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>
|
|
35
|
+
|
|
17
36
|
```sh
|
|
18
37
|
npm install @inquirer/select
|
|
19
38
|
```
|
|
@@ -32,7 +51,9 @@ yarn add @inquirer/select
|
|
|
32
51
|
# Usage
|
|
33
52
|
|
|
34
53
|
```js
|
|
35
|
-
import select,
|
|
54
|
+
import { select, Separator } from '@inquirer/prompts';
|
|
55
|
+
// Or
|
|
56
|
+
// import select, { Separator } from '@inquirer/select';
|
|
36
57
|
|
|
37
58
|
const answer = await select({
|
|
38
59
|
message: 'Select a package manager',
|
|
@@ -64,16 +85,38 @@ const answer = await select({
|
|
|
64
85
|
|
|
65
86
|
## Options
|
|
66
87
|
|
|
67
|
-
| Property | Type
|
|
68
|
-
| -------- |
|
|
69
|
-
| message | `string`
|
|
70
|
-
| choices | `
|
|
71
|
-
| default | `string`
|
|
72
|
-
| pageSize | `number`
|
|
73
|
-
| loop | `boolean`
|
|
74
|
-
| theme | [See Theming](#Theming)
|
|
88
|
+
| Property | Type | Required | Description |
|
|
89
|
+
| -------- | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
90
|
+
| message | `string` | yes | The question to ask |
|
|
91
|
+
| choices | `Choice[]` | yes | List of the available choices. |
|
|
92
|
+
| 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. |
|
|
93
|
+
| 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. |
|
|
94
|
+
| 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. |
|
|
95
|
+
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
|
|
96
|
+
|
|
97
|
+
`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.
|
|
98
|
+
|
|
99
|
+
### `Choice` object
|
|
100
|
+
|
|
101
|
+
The `Choice` object is typed as
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
type Choice<Value> = {
|
|
105
|
+
value: Value;
|
|
106
|
+
name?: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
short?: string;
|
|
109
|
+
disabled?: boolean | string;
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Here's each property:
|
|
75
114
|
|
|
76
|
-
|
|
115
|
+
- `value`: The value is what will be returned by `await select()`.
|
|
116
|
+
- `name`: This is the string displayed in the choice list.
|
|
117
|
+
- `description`: Option for a longer description string that'll appear under the list when the cursor highlight a given choice.
|
|
118
|
+
- `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`.
|
|
119
|
+
- `disabled`: Disallow the option from being selected. If `disabled` is a string, it'll be used as a help tip explaining why the choice isn't available.
|
|
77
120
|
|
|
78
121
|
## Theming
|
|
79
122
|
|
|
@@ -92,6 +135,7 @@ type Theme = {
|
|
|
92
135
|
error: (text: string) => string;
|
|
93
136
|
help: (text: string) => string;
|
|
94
137
|
highlight: (text: string) => string;
|
|
138
|
+
description: (text: string) => string;
|
|
95
139
|
disabled: (text: string) => string;
|
|
96
140
|
};
|
|
97
141
|
icon: {
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,7 +10,10 @@ const figures_1 = __importDefault(require("@inquirer/figures"));
|
|
|
10
10
|
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
11
11
|
const selectTheme = {
|
|
12
12
|
icon: { cursor: figures_1.default.pointer },
|
|
13
|
-
style: {
|
|
13
|
+
style: {
|
|
14
|
+
disabled: (text) => yoctocolors_cjs_1.default.dim(`- ${text}`),
|
|
15
|
+
description: (text) => yoctocolors_cjs_1.default.cyan(text),
|
|
16
|
+
},
|
|
14
17
|
helpMode: 'auto',
|
|
15
18
|
};
|
|
16
19
|
function isSelectable(item) {
|
|
@@ -127,9 +130,9 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
127
130
|
return `${prefix} ${message} ${theme.style.answer(answer)}`;
|
|
128
131
|
}
|
|
129
132
|
const choiceDescription = selectedChoice.description
|
|
130
|
-
? `\n${selectedChoice.description}`
|
|
133
|
+
? `\n${theme.style.description(selectedChoice.description)}`
|
|
131
134
|
: ``;
|
|
132
|
-
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${
|
|
135
|
+
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${helpTipBottom}${choiceDescription}${ansi_escapes_1.default.cursorHide}`;
|
|
133
136
|
});
|
|
134
137
|
var core_2 = require("@inquirer/core");
|
|
135
138
|
Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return core_2.Separator; } });
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4,7 +4,10 @@ import figures from '@inquirer/figures';
|
|
|
4
4
|
import ansiEscapes from 'ansi-escapes';
|
|
5
5
|
const selectTheme = {
|
|
6
6
|
icon: { cursor: figures.pointer },
|
|
7
|
-
style: {
|
|
7
|
+
style: {
|
|
8
|
+
disabled: (text) => colors.dim(`- ${text}`),
|
|
9
|
+
description: (text) => colors.cyan(text),
|
|
10
|
+
},
|
|
8
11
|
helpMode: 'auto',
|
|
9
12
|
};
|
|
10
13
|
function isSelectable(item) {
|
|
@@ -121,8 +124,8 @@ export default createPrompt((config, done) => {
|
|
|
121
124
|
return `${prefix} ${message} ${theme.style.answer(answer)}`;
|
|
122
125
|
}
|
|
123
126
|
const choiceDescription = selectedChoice.description
|
|
124
|
-
? `\n${selectedChoice.description}`
|
|
127
|
+
? `\n${theme.style.description(selectedChoice.description)}`
|
|
125
128
|
: ``;
|
|
126
|
-
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${
|
|
129
|
+
return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
127
130
|
});
|
|
128
131
|
export { Separator } from '@inquirer/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/select",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Inquirer select/list prompt",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -52,22 +52,21 @@
|
|
|
52
52
|
],
|
|
53
53
|
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
54
54
|
"license": "MIT",
|
|
55
|
-
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/
|
|
55
|
+
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/select/README.md",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@inquirer/core": "^9.0.
|
|
58
|
-
"@inquirer/figures": "^1.0.
|
|
59
|
-
"@inquirer/type": "^1.5.
|
|
57
|
+
"@inquirer/core": "^9.0.5",
|
|
58
|
+
"@inquirer/figures": "^1.0.5",
|
|
59
|
+
"@inquirer/type": "^1.5.1",
|
|
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.28"
|
|
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
|
-
"tsc:watch": "tsc -p ./tsconfig.json --watch",
|
|
71
70
|
"attw": "attw --pack"
|
|
72
71
|
},
|
|
73
72
|
"publishConfig": {
|
|
@@ -89,5 +88,5 @@
|
|
|
89
88
|
}
|
|
90
89
|
},
|
|
91
90
|
"sideEffects": false,
|
|
92
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "92eb67edb388404a6d737c0605648ac797c84fb6"
|
|
93
92
|
}
|