@inquirer/select 2.3.11 → 2.4.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
@@ -64,14 +64,14 @@ const answer = await select({
64
64
 
65
65
  ## Options
66
66
 
67
- | Property | Type | Required | Description |
68
- | -------- | ---------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
- | message | `string` | yes | The question to ask |
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` | 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. |
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
- // TODO: Could we enforce that at the type level? Name should be defined for non-string values.
125
- String(selectedChoice.value);
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
@@ -13,6 +13,7 @@ type Choice<Value> = {
13
13
  value: Value;
14
14
  name?: string;
15
15
  description?: string;
16
+ short?: string;
16
17
  disabled?: boolean | string;
17
18
  type?: never;
18
19
  };
@@ -114,7 +114,8 @@ export default createPrompt((config, done) => {
114
114
  loop,
115
115
  });
116
116
  if (status === 'done') {
117
- const answer = selectedChoice.name ||
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)}`;
@@ -13,6 +13,7 @@ type Choice<Value> = {
13
13
  value: Value;
14
14
  name?: string;
15
15
  description?: string;
16
+ short?: string;
16
17
  disabled?: boolean | string;
17
18
  type?: never;
18
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/select",
3
- "version": "2.3.11",
3
+ "version": "2.4.1",
4
4
  "description": "Inquirer select/list prompt",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "typings": "./dist/cjs/types/index.d.ts",
@@ -52,16 +52,16 @@
52
52
  ],
53
53
  "author": "Simon Boudrias <admin@simonboudrias.com>",
54
54
  "license": "MIT",
55
- "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/select/README.md",
55
+ "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/select/README.md",
56
56
  "dependencies": {
57
- "@inquirer/core": "^9.0.3",
57
+ "@inquirer/core": "^9.0.4",
58
58
  "@inquirer/figures": "^1.0.4",
59
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.26"
64
+ "@inquirer/testing": "^2.1.27"
65
65
  },
66
66
  "scripts": {
67
67
  "tsc": "yarn run tsc:esm && yarn run tsc:cjs",
@@ -89,5 +89,5 @@
89
89
  }
90
90
  },
91
91
  "sideEffects": false,
92
- "gitHead": "eb7a658ca58d8cc5863efb9289ae1b42e818bdd0"
92
+ "gitHead": "f2c4983dd390c6244fb4668a8e87c9e786e4326f"
93
93
  }