@optique/inquirer 1.4.0-dev.2726 → 1.4.0-dev.2729

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
@@ -60,8 +60,7 @@ Features
60
60
  --------
61
61
 
62
62
  - *Ten prompt types*: `input`, `password`, `number`, `confirm`, `select`,
63
- `rawlist`, `expand`, `checkbox`, `editor`, and a custom `prompter` for
64
- testing
63
+ `search`, `rawlist`, `expand`, `checkbox`, and `editor`
65
64
  - *Transparent composition* with `bindEnv()` and `bindConfig()` — the
66
65
  prompt fires only when no higher-priority source supplies a value
67
66
  - *Dependency-derived configurations* with `derivePromptConfig()` — later
package/dist/index.cjs CHANGED
@@ -35,6 +35,7 @@ const defaultPromptFunctions = {
35
35
  password: __inquirer_prompts.password,
36
36
  editor: __inquirer_prompts.editor,
37
37
  select: __inquirer_prompts.select,
38
+ search: __inquirer_prompts.search,
38
39
  rawlist: __inquirer_prompts.rawlist,
39
40
  expand: __inquirer_prompts.expand,
40
41
  checkbox: __inquirer_prompts.checkbox
@@ -77,6 +78,7 @@ const validPromptTypes = new Set([
77
78
  "password",
78
79
  "editor",
79
80
  "select",
81
+ "search",
80
82
  "rawlist",
81
83
  "expand",
82
84
  "checkbox"
@@ -188,6 +190,16 @@ async function executePromptRaw(config, context) {
188
190
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
189
191
  }, inquirerContext)
190
192
  };
193
+ case "search": return {
194
+ success: true,
195
+ value: await prompts.search({
196
+ message: cfg.message,
197
+ source: async (term, sourceContext) => normalizeChoices(await cfg.source(term, sourceContext)),
198
+ ...cfg.default === void 0 ? {} : { default: cfg.default },
199
+ ...cfg.pageSize === void 0 ? {} : { pageSize: cfg.pageSize },
200
+ ...cfg.validate === void 0 ? {} : { validate: cfg.validate }
201
+ }, inquirerContext)
202
+ };
191
203
  case "rawlist": return {
192
204
  success: true,
193
205
  value: await prompts.rawlist({
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ import { DerivePromptConfigContext, DerivePromptConfigNoDepsContext, DerivePromp
7
7
 
8
8
  /**
9
9
  * A choice item for selection-type prompts (`select`, `rawlist`, `expand`,
10
- * `checkbox`).
10
+ * `checkbox`, `search`).
11
11
  *
12
12
  * @since 1.0.0
13
13
  */
@@ -180,6 +180,32 @@ interface SelectConfig {
180
180
  */
181
181
  readonly prompter?: (context: PromptExecutionContext$1) => Promise<string>;
182
182
  }
183
+ /**
184
+ * Configuration for a `search` prompt that loads choices for each search term.
185
+ *
186
+ * @since 1.4.0
187
+ */
188
+ interface SearchConfig {
189
+ readonly type: "search";
190
+ /** The question to display to the user. */
191
+ readonly message: string;
192
+ /**
193
+ * Returns choices for the current input; undefined means empty input.
194
+ * Forward the signal to cancel requests when the input changes or the
195
+ * prompt closes. Inquirer displays Error rejections without ending the prompt.
196
+ */
197
+ readonly source: (term: string | undefined, context: {
198
+ readonly signal: AbortSignal;
199
+ }) => readonly (string | Choice | Separator)[] | Promise<readonly (string | Choice | Separator)[]>;
200
+ /** Initially highlighted choice value. */
201
+ readonly default?: string;
202
+ /** Number of choices displayed before pagination. */
203
+ readonly pageSize?: number;
204
+ /** Native validation called when the user submits a selection. */
205
+ readonly validate?: (value: string) => boolean | string | Promise<boolean | string>;
206
+ /** Overrides prompt execution. Useful for testing. */
207
+ readonly prompter?: (context: PromptExecutionContext$1) => Promise<string>;
208
+ }
183
209
  /**
184
210
  * Configuration for a `rawlist` prompt (numbered list).
185
211
  *
@@ -240,7 +266,7 @@ interface CheckboxConfig {
240
266
  *
241
267
  * @since 1.0.0
242
268
  */
243
- type StringPromptConfig = InputConfig | PasswordConfig | EditorConfig | SelectConfig | RawlistConfig | ExpandConfig;
269
+ type StringPromptConfig = InputConfig | PasswordConfig | EditorConfig | SelectConfig | SearchConfig | RawlistConfig | ExpandConfig;
244
270
  /**
245
271
  * Type-safe prompt configuration for a given parser value type `T`.
246
272
  *
@@ -284,4 +310,4 @@ type RuntimePromptConfig = ConfirmConfig | NumberPromptConfig | StringPromptConf
284
310
  */
285
311
  declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue> | DerivedPromptConfig$1<RuntimePromptConfig, NoInfer<TValue>>, options?: PromptOptions$1<NoInfer<TValue>>): FluentParser<"async", TValue, TState>;
286
312
  //#endregion
287
- export { CheckboxChoice, CheckboxConfig, Choice, ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigNoDepsContext, type DerivePromptConfigNoDepsOptions, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, EditorConfig, ExpandChoice, ExpandConfig, InputConfig, NumberPromptConfig, PasswordConfig, PromptConfig, type PromptExecutionContext, type PromptOptions, type PromptValidator, RawlistConfig, RuntimePromptConfig, SelectConfig, Separator, StringPromptConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
313
+ export { CheckboxChoice, CheckboxConfig, Choice, ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigNoDepsContext, type DerivePromptConfigNoDepsOptions, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, EditorConfig, ExpandChoice, ExpandConfig, InputConfig, NumberPromptConfig, PasswordConfig, PromptConfig, type PromptExecutionContext, type PromptOptions, type PromptValidator, RawlistConfig, RuntimePromptConfig, SearchConfig, SelectConfig, Separator, StringPromptConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { Mode, Parser } from "@optique/core/parser";
7
7
 
8
8
  /**
9
9
  * A choice item for selection-type prompts (`select`, `rawlist`, `expand`,
10
- * `checkbox`).
10
+ * `checkbox`, `search`).
11
11
  *
12
12
  * @since 1.0.0
13
13
  */
@@ -180,6 +180,32 @@ interface SelectConfig {
180
180
  */
181
181
  readonly prompter?: (context: PromptExecutionContext$1) => Promise<string>;
182
182
  }
183
+ /**
184
+ * Configuration for a `search` prompt that loads choices for each search term.
185
+ *
186
+ * @since 1.4.0
187
+ */
188
+ interface SearchConfig {
189
+ readonly type: "search";
190
+ /** The question to display to the user. */
191
+ readonly message: string;
192
+ /**
193
+ * Returns choices for the current input; undefined means empty input.
194
+ * Forward the signal to cancel requests when the input changes or the
195
+ * prompt closes. Inquirer displays Error rejections without ending the prompt.
196
+ */
197
+ readonly source: (term: string | undefined, context: {
198
+ readonly signal: AbortSignal;
199
+ }) => readonly (string | Choice | Separator)[] | Promise<readonly (string | Choice | Separator)[]>;
200
+ /** Initially highlighted choice value. */
201
+ readonly default?: string;
202
+ /** Number of choices displayed before pagination. */
203
+ readonly pageSize?: number;
204
+ /** Native validation called when the user submits a selection. */
205
+ readonly validate?: (value: string) => boolean | string | Promise<boolean | string>;
206
+ /** Overrides prompt execution. Useful for testing. */
207
+ readonly prompter?: (context: PromptExecutionContext$1) => Promise<string>;
208
+ }
183
209
  /**
184
210
  * Configuration for a `rawlist` prompt (numbered list).
185
211
  *
@@ -240,7 +266,7 @@ interface CheckboxConfig {
240
266
  *
241
267
  * @since 1.0.0
242
268
  */
243
- type StringPromptConfig = InputConfig | PasswordConfig | EditorConfig | SelectConfig | RawlistConfig | ExpandConfig;
269
+ type StringPromptConfig = InputConfig | PasswordConfig | EditorConfig | SelectConfig | SearchConfig | RawlistConfig | ExpandConfig;
244
270
  /**
245
271
  * Type-safe prompt configuration for a given parser value type `T`.
246
272
  *
@@ -284,4 +310,4 @@ type RuntimePromptConfig = ConfirmConfig | NumberPromptConfig | StringPromptConf
284
310
  */
285
311
  declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue> | DerivedPromptConfig$1<RuntimePromptConfig, NoInfer<TValue>>, options?: PromptOptions$1<NoInfer<TValue>>): FluentParser<"async", TValue, TState>;
286
312
  //#endregion
287
- export { CheckboxChoice, CheckboxConfig, Choice, ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigNoDepsContext, type DerivePromptConfigNoDepsOptions, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, EditorConfig, ExpandChoice, ExpandConfig, InputConfig, NumberPromptConfig, PasswordConfig, PromptConfig, type PromptExecutionContext, type PromptOptions, type PromptValidator, RawlistConfig, RuntimePromptConfig, SelectConfig, Separator, StringPromptConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
313
+ export { CheckboxChoice, CheckboxConfig, Choice, ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigNoDepsContext, type DerivePromptConfigNoDepsOptions, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, EditorConfig, ExpandChoice, ExpandConfig, InputConfig, NumberPromptConfig, PasswordConfig, PromptConfig, type PromptExecutionContext, type PromptOptions, type PromptValidator, RawlistConfig, RuntimePromptConfig, SearchConfig, SelectConfig, Separator, StringPromptConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import process from "node:process";
2
- import { Separator, checkbox, confirm, editor, expand, input, number, password, rawlist, select } from "@inquirer/prompts";
2
+ import { Separator, checkbox, confirm, editor, expand, input, number, password, rawlist, search, select } from "@inquirer/prompts";
3
3
  import { formatMessage, message } from "@optique/core/message";
4
4
  import { createPromptAdapter, derivePromptConfig, isDerivedPromptConfig } from "@optique/prompt";
5
5
 
@@ -12,6 +12,7 @@ const defaultPromptFunctions = {
12
12
  password,
13
13
  editor,
14
14
  select,
15
+ search,
15
16
  rawlist,
16
17
  expand,
17
18
  checkbox
@@ -54,6 +55,7 @@ const validPromptTypes = new Set([
54
55
  "password",
55
56
  "editor",
56
57
  "select",
58
+ "search",
57
59
  "rawlist",
58
60
  "expand",
59
61
  "checkbox"
@@ -165,6 +167,16 @@ async function executePromptRaw(config, context) {
165
167
  ...cfg.default !== void 0 ? { default: cfg.default } : {}
166
168
  }, inquirerContext)
167
169
  };
170
+ case "search": return {
171
+ success: true,
172
+ value: await prompts.search({
173
+ message: cfg.message,
174
+ source: async (term, sourceContext) => normalizeChoices(await cfg.source(term, sourceContext)),
175
+ ...cfg.default === void 0 ? {} : { default: cfg.default },
176
+ ...cfg.pageSize === void 0 ? {} : { pageSize: cfg.pageSize },
177
+ ...cfg.validate === void 0 ? {} : { validate: cfg.validate }
178
+ }, inquirerContext)
179
+ };
168
180
  case "rawlist": return {
169
181
  success: true,
170
182
  value: await prompts.rawlist({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/inquirer",
3
- "version": "1.4.0-dev.2726",
3
+ "version": "1.4.0-dev.2729",
4
4
  "description": "Inquirer.js prompt support for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -62,13 +62,13 @@
62
62
  "sideEffects": false,
63
63
  "dependencies": {
64
64
  "@inquirer/prompts": "^8.3.0",
65
- "@optique/core": "1.4.0-dev.2726+dfa3c577",
66
- "@optique/prompt": "1.4.0-dev.2726+dfa3c577"
65
+ "@optique/core": "1.4.0-dev.2729+72048695",
66
+ "@optique/prompt": "1.4.0-dev.2729+72048695"
67
67
  },
68
68
  "devDependencies": {
69
- "@optique/config": "1.4.0-dev.2726+dfa3c577",
70
- "@optique/env": "1.4.0-dev.2726+dfa3c577",
71
- "@optique/run": "1.4.0-dev.2726+dfa3c577",
69
+ "@optique/config": "1.4.0-dev.2729+72048695",
70
+ "@optique/env": "1.4.0-dev.2729+72048695",
71
+ "@optique/run": "1.4.0-dev.2729+72048695",
72
72
  "@types/node": "^24.0.0",
73
73
  "fast-check": "^4.7.0",
74
74
  "tsdown": "^0.13.0",