@inquirer/select 2.4.1 → 2.4.3

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
@@ -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, { Separator } from '@inquirer/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 | 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. |
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
- 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.
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: { disabled: (text) => yoctocolors_cjs_1.default.dim(`- ${text}`) },
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}${choiceDescription}${helpTipBottom}${ansi_escapes_1.default.cursorHide}`;
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; } });
@@ -6,6 +6,7 @@ type SelectTheme = {
6
6
  };
7
7
  style: {
8
8
  disabled: (text: string) => string;
9
+ description: (text: string) => string;
9
10
  };
10
11
  helpMode: 'always' | 'never' | 'auto';
11
12
  };
@@ -20,10 +21,10 @@ type Choice<Value> = {
20
21
  declare const _default: <Value>(config: {
21
22
  message: string;
22
23
  choices: readonly (Separator | Choice<Value>)[];
23
- pageSize?: number;
24
- loop?: boolean;
24
+ pageSize?: number | undefined;
25
+ loop?: boolean | undefined;
25
26
  default?: unknown;
26
- theme?: PartialDeep<Theme<SelectTheme>>;
27
+ theme?: PartialDeep<Theme<SelectTheme>> | undefined;
27
28
  }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
28
29
  export default _default;
29
30
  export { Separator } from '@inquirer/core';
@@ -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: { disabled: (text) => colors.dim(`- ${text}`) },
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}${choiceDescription}${helpTipBottom}${ansiEscapes.cursorHide}`;
129
+ return `${[prefix, message, helpTipTop].filter(Boolean).join(' ')}\n${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
127
130
  });
128
131
  export { Separator } from '@inquirer/core';
@@ -6,6 +6,7 @@ type SelectTheme = {
6
6
  };
7
7
  style: {
8
8
  disabled: (text: string) => string;
9
+ description: (text: string) => string;
9
10
  };
10
11
  helpMode: 'always' | 'never' | 'auto';
11
12
  };
@@ -20,10 +21,10 @@ type Choice<Value> = {
20
21
  declare const _default: <Value>(config: {
21
22
  message: string;
22
23
  choices: readonly (Separator | Choice<Value>)[];
23
- pageSize?: number;
24
- loop?: boolean;
24
+ pageSize?: number | undefined;
25
+ loop?: boolean | undefined;
25
26
  default?: unknown;
26
- theme?: PartialDeep<Theme<SelectTheme>>;
27
+ theme?: PartialDeep<Theme<SelectTheme>> | undefined;
27
28
  }, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
28
29
  export default _default;
29
30
  export { Separator } from '@inquirer/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/select",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
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,19 @@
54
54
  "license": "MIT",
55
55
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/select/README.md",
56
56
  "dependencies": {
57
- "@inquirer/core": "^9.0.4",
58
- "@inquirer/figures": "^1.0.4",
59
- "@inquirer/type": "^1.5.0",
57
+ "@inquirer/core": "^9.0.6",
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.27"
64
+ "@inquirer/testing": "^2.1.29"
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": "f2c4983dd390c6244fb4668a8e87c9e786e4326f"
91
+ "gitHead": "7a061f13e053dd64ef7373b08e8a10130131ea59"
93
92
  }