@inquirer/core
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -13,2 +13,14 @@ "use strict"; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
@@ -22,3 +34,3 @@ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
exports.createPrompt = exports.usePagination = exports.useRef = exports.useKeypress = exports.useEffect = exports.useState = exports.usePrefix = void 0; | ||
const node_readline_1 = __importDefault(require("node:readline")); | ||
const readline = __importStar(require("node:readline")); | ||
const type_1 = require("@inquirer/type"); | ||
@@ -180,3 +192,3 @@ const chalk_1 = __importDefault(require("chalk")); | ||
output.pipe((_b = context === null || context === void 0 ? void 0 : context.output) !== null && _b !== void 0 ? _b : process.stdout); | ||
sessionRl = node_readline_1.default.createInterface({ | ||
sessionRl = readline.createInterface({ | ||
terminal: true, | ||
@@ -183,0 +195,0 @@ input, |
@@ -13,2 +13,14 @@ "use strict"; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
@@ -22,3 +34,3 @@ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
exports.createPrompt = exports.usePagination = exports.useRef = exports.useKeypress = exports.useEffect = exports.useState = exports.usePrefix = void 0; | ||
const node_readline_1 = __importDefault(require("node:readline")); | ||
const readline = __importStar(require("node:readline")); | ||
const type_1 = require("@inquirer/type"); | ||
@@ -180,3 +192,3 @@ const chalk_1 = __importDefault(require("chalk")); | ||
output.pipe((_b = context === null || context === void 0 ? void 0 : context.output) !== null && _b !== void 0 ? _b : process.stdout); | ||
sessionRl = node_readline_1.default.createInterface({ | ||
sessionRl = readline.createInterface({ | ||
terminal: true, | ||
@@ -183,0 +195,0 @@ input, |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import readline from 'node:readline'; | ||
import * as readline from 'node:readline'; | ||
import { type Prompt } from '@inquirer/type'; | ||
@@ -5,0 +5,0 @@ import MuteStream from 'mute-stream'; |
{ | ||
"name": "@inquirer/core", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"engines": { | ||
@@ -62,8 +62,8 @@ "node": ">=14.18.0" | ||
"@types/mute-stream": "^0.0.1", | ||
"@types/node": "^20.4.2", | ||
"@types/node": "^20.4.8", | ||
"@types/wrap-ansi": "^3.0.0", | ||
"ansi-escapes": "^4.3.2", | ||
"chalk": "^4.1.2", | ||
"cli-spinners": "^2.8.0", | ||
"cli-width": "^4.0.0", | ||
"cli-spinners": "^2.9.0", | ||
"cli-width": "^4.1.0", | ||
"figures": "^3.2.0", | ||
@@ -73,6 +73,6 @@ "mute-stream": "^1.0.0", | ||
"strip-ansi": "^6.0.1", | ||
"wrap-ansi": "^6.0.1" | ||
"wrap-ansi": "^6.2.0" | ||
}, | ||
"devDependencies": { | ||
"@inquirer/testing": "^2.1.1" | ||
"@inquirer/testing": "^2.1.2" | ||
}, | ||
@@ -101,3 +101,3 @@ "scripts": { | ||
}, | ||
"gitHead": "ab9dd2f301e02d2cc0fec699ce100b174f2b798e" | ||
"gitHead": "dd31d57ed3b1d0771e24cc34bc72e5bedb63a1d7" | ||
} |
@@ -111,2 +111,3 @@ # `@inquirer/core` | ||
- `useKeypress` | ||
- `usePagination` | ||
- `usePrefix` | ||
@@ -125,13 +126,18 @@ | ||
### `Paginator` | ||
### `usePagination` | ||
When looping through a long list of options (like in the `select` prompt), paginating the results appearing on the screen at once can be necessary. The `Paginator` utility is there to help this use case. | ||
When looping through a long list of options (like in the `select` prompt), paginating the results appearing on the screen at once can be necessary. The `usePagination` hook is the utility used within the `select` and `checkbox` prompt to cycle through the list of options. | ||
```js | ||
export default createPrompt((config, done) => { | ||
const paginator = useRef(new Paginator()).current; | ||
const [cursorPosition, setCursorPosition] = useState(0); | ||
const windowedChoices = paginator.paginate(allChoices, cursorPosition, config.pageSize); | ||
const allChoices = config.choices.map((choice) => choice.name); | ||
return '...'; | ||
const windowedChoices = usePagination(allChoices, { | ||
active: cursorPosition, | ||
pageSize: config.pageSize, | ||
}); | ||
return `... ${windowedChoices}`; | ||
}); | ||
@@ -138,0 +144,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62729
1319
148
Updated@types/node@^20.4.8
Updatedcli-spinners@^2.9.0
Updatedcli-width@^4.1.0
Updatedwrap-ansi@^6.2.0