@inquirer/select 1.2.4 → 1.2.6

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/dist/cjs/index.js CHANGED
@@ -14,7 +14,6 @@ function isSelectableChoice(choice) {
14
14
  }
15
15
  exports.default = (0, core_1.createPrompt)((config, done) => {
16
16
  const { choices } = config;
17
- const paginator = (0, core_1.useRef)(new core_1.Paginator()).current;
18
17
  const firstRender = (0, core_1.useRef)(true);
19
18
  const prefix = (0, core_1.usePrefix)();
20
19
  const [status, setStatus] = (0, core_1.useState)('pending');
@@ -58,9 +57,6 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
58
57
  message += chalk_1.default.dim(' (Use arrow keys)');
59
58
  firstRender.current = false;
60
59
  }
61
- if (status === 'done') {
62
- return `${prefix} ${message} ${chalk_1.default.cyan(choice.name || choice.value)}`;
63
- }
64
60
  const allChoices = choices
65
61
  .map((choice, index) => {
66
62
  if (core_1.Separator.isSeparator(choice)) {
@@ -77,7 +73,13 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
77
73
  return ` ${line}`;
78
74
  })
79
75
  .join('\n');
80
- const windowedChoices = paginator.paginate(allChoices, cursorPosition, config.pageSize);
76
+ const windowedChoices = (0, core_1.usePagination)(allChoices, {
77
+ active: cursorPosition,
78
+ pageSize: config.pageSize,
79
+ });
80
+ if (status === 'done') {
81
+ return `${prefix} ${message} ${chalk_1.default.cyan(choice.name || choice.value)}`;
82
+ }
81
83
  const choiceDescription = choice.description ? `\n${choice.description}` : ``;
82
84
  return `${prefix} ${message}\n${windowedChoices}${choiceDescription}${ansi_escapes_1.default.cursorHide}`;
83
85
  });
@@ -1,4 +1,4 @@
1
- import { createPrompt, useState, useKeypress, useRef, usePrefix, isEnterKey, isUpKey, isDownKey, isNumberKey, Paginator, Separator, } from '@inquirer/core';
1
+ import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, isEnterKey, isUpKey, isDownKey, isNumberKey, Separator, } from '@inquirer/core';
2
2
  import chalk from 'chalk';
3
3
  import figures from 'figures';
4
4
  import ansiEscapes from 'ansi-escapes';
@@ -7,7 +7,6 @@ function isSelectableChoice(choice) {
7
7
  }
8
8
  export default createPrompt((config, done) => {
9
9
  const { choices } = config;
10
- const paginator = useRef(new Paginator()).current;
11
10
  const firstRender = useRef(true);
12
11
  const prefix = usePrefix();
13
12
  const [status, setStatus] = useState('pending');
@@ -51,9 +50,6 @@ export default createPrompt((config, done) => {
51
50
  message += chalk.dim(' (Use arrow keys)');
52
51
  firstRender.current = false;
53
52
  }
54
- if (status === 'done') {
55
- return `${prefix} ${message} ${chalk.cyan(choice.name || choice.value)}`;
56
- }
57
53
  const allChoices = choices
58
54
  .map((choice, index) => {
59
55
  if (Separator.isSeparator(choice)) {
@@ -70,7 +66,13 @@ export default createPrompt((config, done) => {
70
66
  return ` ${line}`;
71
67
  })
72
68
  .join('\n');
73
- const windowedChoices = paginator.paginate(allChoices, cursorPosition, config.pageSize);
69
+ const windowedChoices = usePagination(allChoices, {
70
+ active: cursorPosition,
71
+ pageSize: config.pageSize,
72
+ });
73
+ if (status === 'done') {
74
+ return `${prefix} ${message} ${chalk.cyan(choice.name || choice.value)}`;
75
+ }
74
76
  const choiceDescription = choice.description ? `\n${choice.description}` : ``;
75
77
  return `${prefix} ${message}\n${windowedChoices}${choiceDescription}${ansiEscapes.cursorHide}`;
76
78
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/select",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Inquirer select/list prompt",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "typings": "./dist/cjs/types/index.d.ts",
@@ -54,7 +54,7 @@
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": "^2.3.1",
57
+ "@inquirer/core": "^3.1.0",
58
58
  "@inquirer/type": "^1.1.1",
59
59
  "ansi-escapes": "^4.3.2",
60
60
  "chalk": "^4.1.2",
@@ -88,5 +88,5 @@
88
88
  }
89
89
  }
90
90
  },
91
- "gitHead": "b1b29c0b6da9420d739cd46704c205515de2db04"
91
+ "gitHead": "ab9dd2f301e02d2cc0fec699ce100b174f2b798e"
92
92
  }