@inquirer/search
Advanced tools
+1
-0
@@ -29,2 +29,3 @@ import { Separator, type Theme } from '@inquirer/core'; | ||
| pageSize?: number | undefined; | ||
| default?: NoInfer<Value> | undefined; | ||
| theme?: PartialDeep<Theme<SearchTheme>> | undefined; | ||
@@ -31,0 +32,0 @@ }, context?: import("@inquirer/type").Context) => Promise<Value>; |
+11
-4
@@ -1,2 +0,2 @@ | ||
| import { createPrompt, useState, useKeypress, usePrefix, usePagination, useEffect, useMemo, isDownKey, isEnterKey, isTabKey, isUpKey, Separator, makeTheme, } from '@inquirer/core'; | ||
| import { createPrompt, useState, useKeypress, usePrefix, usePagination, useEffect, useMemo, useRef, isDownKey, isEnterKey, isTabKey, isUpKey, Separator, makeTheme, } from '@inquirer/core'; | ||
| import { styleText } from 'node:util'; | ||
@@ -50,2 +50,3 @@ import figures from '@inquirer/figures'; | ||
| const [searchError, setSearchError] = useState(); | ||
| const defaultApplied = useRef(false); | ||
| const prefix = usePrefix({ status, theme }); | ||
@@ -68,6 +69,12 @@ const bounds = useMemo(() => { | ||
| if (!controller.signal.aborted) { | ||
| // Reset the pointer | ||
| setActive(undefined); | ||
| const normalized = normalizeChoices(results); | ||
| let initialActive; | ||
| if (!defaultApplied.current && 'default' in config) { | ||
| const defaultIndex = normalized.findIndex((item) => isSelectable(item) && item.value === config.default); | ||
| initialActive = defaultIndex === -1 ? undefined : defaultIndex; | ||
| defaultApplied.current = true; | ||
| } | ||
| setActive(initialActive); | ||
| setSearchError(undefined); | ||
| setSearchResults(normalizeChoices(results)); | ||
| setSearchResults(normalized); | ||
| setStatus('idle'); | ||
@@ -74,0 +81,0 @@ } |
+20
-21
| { | ||
| "name": "@inquirer/search", | ||
| "version": "4.0.3", | ||
| "version": "4.1.0", | ||
| "description": "Inquirer search prompt", | ||
@@ -45,2 +45,4 @@ "keywords": [ | ||
| "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/search/README.md", | ||
| "license": "MIT", | ||
| "author": "Simon Boudrias <admin@simonboudrias.com>", | ||
| "repository": { | ||
@@ -50,16 +52,17 @@ "type": "git", | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Simon Boudrias <admin@simonboudrias.com>", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "type": "module", | ||
| "sideEffects": false, | ||
| "type": "module", | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
@@ -69,17 +72,10 @@ "tsc": "tsc" | ||
| "dependencies": { | ||
| "@inquirer/core": "^11.1.0", | ||
| "@inquirer/figures": "^2.0.2", | ||
| "@inquirer/type": "^4.0.2" | ||
| "@inquirer/core": "^11.1.1", | ||
| "@inquirer/figures": "^2.0.3", | ||
| "@inquirer/type": "^4.0.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@inquirer/testing": "^3.0.3", | ||
| "@repo/tsconfig": "0.0.0", | ||
| "@inquirer/testing": "^3.0.4", | ||
| "typescript": "^5.9.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "peerDependencies": { | ||
@@ -93,5 +89,8 @@ "@types/node": ">=18" | ||
| }, | ||
| "engines": { | ||
| "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" | ||
| }, | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "gitHead": "7eedd8e1de71764d0d30e762c97992ceb9f68ed3" | ||
| "gitHead": "99d00a9adc53be8b7edf5926b2ec4ba0b792f68f" | ||
| } |
+2
-1
@@ -84,2 +84,3 @@ # `@inquirer/search` | ||
| | 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. | | ||
| | default | `Value` | no | Defines in front of which item the cursor will initially appear. When omitted, the cursor will appear on the first selectable item. | | ||
| | validate | `Value => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the answer. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. | | ||
@@ -140,3 +141,3 @@ | theme | [See Theming](#Theming) | no | Customize look of the prompt. | | ||
| You can see this behavior in action in [our search demo](https://github.com/SBoudrias/Inquirer.js/blob/main/packages/demo/demos/search.mjs). | ||
| You can see this behavior in action in [our search demo](https://github.com/SBoudrias/Inquirer.js/blob/main/packages/demo/src/demos/search.ts). | ||
@@ -143,0 +144,0 @@ ## Theming |
19153
4.19%2
-33.33%226
3.67%214
0.47%Updated
Updated
Updated