@inquirer/i18n 1.2.0 → 1.3.0

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
@@ -89,7 +89,7 @@ import { createLocalizedPrompts, registerLocale } from '@inquirer/i18n';
89
89
  import type { Locale } from '@inquirer/i18n';
90
90
 
91
91
  const deLocale: Locale = {
92
- confirm: { yesLabel: 'Ja', noLabel: 'Nein', hintYes: 'J/n', hintNo: 'j/N' },
92
+ confirm: { yesLabel: 'Ja', noLabel: 'Nein' },
93
93
  select: { helpNavigate: 'Navigieren', helpSelect: 'Auswählen' },
94
94
  checkbox: {
95
95
  helpNavigate: 'Navigieren',
package/dist/create.js CHANGED
@@ -10,23 +10,16 @@ import { styleText } from 'node:util';
10
10
  export function createLocalizedPrompts(locale) {
11
11
  return {
12
12
  confirm(config, context) {
13
- const theme = makeTheme(config.theme, {
14
- style: {
15
- defaultAnswer: (text) => {
16
- if (text === 'Y/n')
17
- return styleText('dim', `(${locale.confirm.hintYes})`);
18
- if (text === 'y/N')
19
- return styleText('dim', `(${locale.confirm.hintNo})`);
20
- return styleText('dim', `(${text})`);
21
- },
13
+ // The labels are the keywords: confirm shows their first character in
14
+ // the hint, matches them prefix-based, and displays the label once done.
15
+ const theme = {
16
+ ...config.theme,
17
+ keywords: {
18
+ yes: locale.confirm.yesLabel,
19
+ no: locale.confirm.noLabel,
22
20
  },
23
- });
24
- return confirmPrompt({
25
- ...config,
26
- theme,
27
- transformer: config.transformer ??
28
- ((answer) => answer ? locale.confirm.yesLabel : locale.confirm.noLabel),
29
- }, context);
21
+ };
22
+ return confirmPrompt({ ...config, theme }, context);
30
23
  },
31
24
  select(config, context) {
32
25
  const theme = makeTheme(config.theme, {
@@ -116,6 +109,16 @@ export function createLocalizedPrompts(locale) {
116
109
  const theme = makeTheme(config.theme, {
117
110
  style: {
118
111
  maskedText: locale.password.maskedText,
112
+ keysHelpTip: (keys) => {
113
+ const localizedKeys = keys.map(([key, label]) => {
114
+ if (label === 'toggle visibility')
115
+ return [key, locale.password.helpToggle];
116
+ return [key, label];
117
+ });
118
+ return localizedKeys
119
+ .map(([k, l]) => `${styleText('bold', k)} ${styleText('dim', l)}`)
120
+ .join(styleText('dim', ' • '));
121
+ },
119
122
  },
120
123
  });
121
124
  return passwordPrompt({ ...config, theme }, context);
@@ -1,8 +1,31 @@
1
+ import type { Locale } from '../types.ts';
2
+ export declare const locale: Locale;
1
3
  export declare const confirm: (this: void, config: {
4
+ message: string;
5
+ default?: boolean | undefined | undefined;
6
+ transformer?: ((value: boolean) => string) | undefined;
7
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
8
+ keywords: {
9
+ yes: string;
10
+ no: string;
11
+ };
12
+ style: {
13
+ confirmDefault: (text: string) => string;
14
+ };
15
+ }>> | undefined;
16
+ } & {
2
17
  message: string;
3
18
  default?: boolean | undefined;
4
19
  transformer?: (value: boolean) => string;
5
- theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme>;
20
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
21
+ keywords: {
22
+ yes: string;
23
+ no: string;
24
+ };
25
+ style: {
26
+ confirmDefault: (text: string) => string;
27
+ };
28
+ }>>;
6
29
  }, context?: import("@inquirer/type").Context | undefined) => Promise<boolean>, select: <Value>(this: void, config: {
7
30
  message: string;
8
31
  choices: readonly (import("@inquirer/prompts").Separator | Value | {
@@ -30,6 +53,33 @@ export declare const confirm: (this: void, config: {
30
53
  };
31
54
  indexMode: "hidden" | "number";
32
55
  }>> | undefined;
56
+ } & {
57
+ message: string;
58
+ choices: readonly (import("@inquirer/prompts").Separator | Value | {
59
+ value: Value;
60
+ name?: string;
61
+ description?: string;
62
+ short?: string;
63
+ disabled?: boolean | string;
64
+ type?: never;
65
+ })[];
66
+ pageSize?: number;
67
+ loop?: boolean;
68
+ default?: NoInfer<Value> | undefined;
69
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
70
+ icon: {
71
+ cursor: string;
72
+ };
73
+ style: {
74
+ disabled: (text: string) => string;
75
+ description: (text: string) => string;
76
+ keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
77
+ };
78
+ i18n: {
79
+ disabledError: string;
80
+ };
81
+ indexMode: "hidden" | "number";
82
+ }>>;
33
83
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, checkbox: <Value>(this: void, config: {
34
84
  message: string;
35
85
  prefix?: string | undefined;
@@ -93,6 +143,69 @@ export declare const confirm: (this: void, config: {
93
143
  all?: string | null;
94
144
  invert?: string | null;
95
145
  } | undefined;
146
+ } & {
147
+ message: string;
148
+ prefix?: string;
149
+ pageSize?: number;
150
+ choices: readonly (import("@inquirer/prompts").Separator | Value | {
151
+ value: Value;
152
+ name?: string;
153
+ checkedName?: string;
154
+ description?: string;
155
+ short?: string;
156
+ disabled?: boolean | string;
157
+ checked?: boolean;
158
+ type?: never;
159
+ })[];
160
+ loop?: boolean;
161
+ required?: boolean;
162
+ validate?: ((choices: readonly {
163
+ value: Value;
164
+ name: string;
165
+ checkedName: string;
166
+ description?: string;
167
+ short: string;
168
+ disabled: boolean | string;
169
+ checked: boolean;
170
+ }[]) => boolean | string | Promise<string | boolean>) | undefined;
171
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
172
+ icon: {
173
+ checked: string;
174
+ unchecked: string;
175
+ cursor: string;
176
+ disabledChecked: string;
177
+ disabledUnchecked: string;
178
+ };
179
+ style: {
180
+ disabled: (text: string) => string;
181
+ renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<{
182
+ value: T;
183
+ name: string;
184
+ checkedName: string;
185
+ description?: string;
186
+ short: string;
187
+ disabled: boolean | string;
188
+ checked: boolean;
189
+ }>, allChoices: ReadonlyArray<{
190
+ value: T;
191
+ name: string;
192
+ checkedName: string;
193
+ description?: string;
194
+ short: string;
195
+ disabled: boolean | string;
196
+ checked: boolean;
197
+ } | import("@inquirer/prompts").Separator>) => string;
198
+ description: (text: string) => string;
199
+ keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
200
+ };
201
+ i18n: {
202
+ disabledError: string;
203
+ };
204
+ }>>;
205
+ shortcuts?: {
206
+ all?: string | null;
207
+ invert?: string | null;
208
+ };
96
209
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Value[]>, search: <Value>(this: void, config: {
97
210
  message: string;
98
211
  source: (term: string | undefined, opt: {
@@ -127,23 +240,74 @@ export declare const confirm: (this: void, config: {
127
240
  keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
128
241
  };
129
242
  }>> | undefined;
243
+ } & {
244
+ message: string;
245
+ source: (term: string | undefined, opt: {
246
+ signal: AbortSignal;
247
+ }) => readonly (import("@inquirer/prompts").Separator | Value | {
248
+ value: Value;
249
+ name?: string;
250
+ description?: string;
251
+ short?: string;
252
+ disabled?: boolean | string;
253
+ type?: never;
254
+ })[] | Promise<readonly (import("@inquirer/prompts").Separator | Value | {
255
+ value: Value;
256
+ name?: string;
257
+ description?: string;
258
+ short?: string;
259
+ disabled?: boolean | string;
260
+ type?: never;
261
+ })[]>;
262
+ validate?: ((value: Value) => boolean | string | Promise<string | boolean>) | undefined;
263
+ pageSize?: number;
264
+ default?: NoInfer<Value> | undefined;
265
+ initialValue?: string;
266
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
267
+ icon: {
268
+ cursor: string;
269
+ };
270
+ style: {
271
+ disabled: (text: string) => string;
272
+ searchTerm: (text: string) => string;
273
+ description: (text: string) => string;
274
+ keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
275
+ };
276
+ }>>;
130
277
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, expand: <Value>(this: void, config: {
131
278
  message: string;
132
279
  choices: readonly (import("@inquirer/prompts").Separator | {
133
- key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "f" | "s" | "a" | "b" | "c" | "d" | "e" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
280
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
134
281
  name: Value & string;
135
282
  value?: never;
136
283
  } | ({
137
- key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "f" | "s" | "a" | "b" | "c" | "d" | "e" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
284
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
138
285
  value: Value;
139
286
  } | {
140
- key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "f" | "s" | "a" | "b" | "c" | "d" | "e" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
287
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
141
288
  name: string;
142
289
  value: Value;
143
290
  }))[];
144
- default?: (("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "f" | "s" | "a" | "b" | "c" | "d" | "e" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "t" | "u" | "v" | "w" | "x" | "y" | "z") | "h") | undefined;
291
+ default?: (("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z") | "h") | undefined;
145
292
  expanded?: boolean | undefined;
146
293
  theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme> | undefined;
294
+ } & {
295
+ message: string;
296
+ choices: readonly (import("@inquirer/prompts").Separator | ({
297
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
298
+ value: Value;
299
+ } | {
300
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
301
+ name: string;
302
+ value: Value;
303
+ }) | {
304
+ key: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
305
+ name: Value & string;
306
+ value?: never;
307
+ })[];
308
+ default?: ("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z") | "h";
309
+ expanded?: boolean;
310
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme>;
147
311
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, rawlist: <Value>(this: void, config: {
148
312
  message: string;
149
313
  choices: readonly (import("@inquirer/prompts").Separator | Value | {
@@ -160,7 +324,37 @@ export declare const confirm: (this: void, config: {
160
324
  };
161
325
  }>> | undefined;
162
326
  default?: NoInfer<Value> | undefined;
327
+ } & {
328
+ message: string;
329
+ choices: readonly (import("@inquirer/prompts").Separator | Value | {
330
+ value: Value;
331
+ name?: string;
332
+ short?: string;
333
+ key?: string;
334
+ description?: string;
335
+ })[];
336
+ loop?: boolean;
337
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
338
+ style: {
339
+ description: (text: string) => string;
340
+ };
341
+ }>>;
342
+ default?: NoInfer<Value> | undefined;
163
343
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Value>, editor: (this: void, config: {
344
+ message: string;
345
+ default?: string | undefined | undefined;
346
+ postfix?: string | undefined;
347
+ waitForUserInput?: boolean | undefined;
348
+ validate?: ((value: string) => boolean | string | Promise<string | boolean>) | undefined;
349
+ file?: import("@inquirer/external-editor").FileOptions | undefined;
350
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
351
+ validationFailureMode: "keep" | "clear";
352
+ style: {
353
+ loadingMessage: () => string;
354
+ waitingMessage: (enterKey: string) => string;
355
+ };
356
+ }>> | undefined;
357
+ } & {
164
358
  message: string;
165
359
  default?: string | undefined;
166
360
  postfix?: string;
@@ -175,6 +369,20 @@ export declare const confirm: (this: void, config: {
175
369
  };
176
370
  }>>;
177
371
  }, context?: import("@inquirer/type").Context | undefined) => Promise<string>, input: (this: void, config: {
372
+ message: string;
373
+ default?: string | undefined | undefined;
374
+ prefill?: "tab" | "editable" | undefined;
375
+ required?: boolean | undefined;
376
+ transformer?: ((value: string, { isFinal }: {
377
+ isFinal: boolean;
378
+ }) => string) | undefined;
379
+ validate?: ((value: string) => boolean | string | Promise<string | boolean>) | undefined;
380
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
381
+ validationFailureMode: "keep" | "clear";
382
+ }>> | undefined;
383
+ pattern?: RegExp | undefined;
384
+ patternError?: string | undefined;
385
+ } & {
178
386
  message: string;
179
387
  default?: string | undefined;
180
388
  prefill?: "tab" | "editable";
@@ -197,13 +405,35 @@ export declare const confirm: (this: void, config: {
197
405
  required?: Required | undefined;
198
406
  validate?: ((value: Required extends true ? number : number | undefined) => boolean | string | Promise<string | boolean>) | undefined;
199
407
  theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme> | undefined;
408
+ } & {
409
+ message: string;
410
+ default?: number | undefined;
411
+ min?: number;
412
+ max?: number;
413
+ step?: number | "any";
414
+ required?: Required | undefined;
415
+ validate?: ((value: Required extends true ? number : number | undefined) => boolean | string | Promise<string | boolean>) | undefined;
416
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme>;
200
417
  }, context?: import("@inquirer/type").Context | undefined) => Promise<Required extends true ? number : number | undefined>, password: (this: void, config: {
418
+ message: string;
419
+ mask?: boolean | string | undefined;
420
+ toggleMask?: boolean | undefined;
421
+ validate?: ((value: string) => boolean | string | Promise<string | boolean>) | undefined;
422
+ theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
423
+ style: {
424
+ maskedText: string;
425
+ keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
426
+ };
427
+ }>> | undefined;
428
+ } & {
201
429
  message: string;
202
430
  mask?: boolean | string;
431
+ toggleMask?: boolean;
203
432
  validate?: (value: string) => boolean | string | Promise<string | boolean>;
204
433
  theme?: import("@inquirer/type").PartialDeep<import("@inquirer/core").Theme<{
205
434
  style: {
206
435
  maskedText: string;
436
+ keysHelpTip: (keys: [key: string, action: string][]) => string | undefined;
207
437
  };
208
438
  }>>;
209
439
  }, context?: import("@inquirer/type").Context | undefined) => Promise<string>;
@@ -1,10 +1,8 @@
1
1
  import { createLocalizedPrompts } from "../create.js";
2
- const esLocale = {
2
+ export const locale = {
3
3
  confirm: {
4
4
  yesLabel: 'Sí',
5
5
  noLabel: 'No',
6
- hintYes: 'S/n',
7
- hintNo: 's/N',
8
6
  },
9
7
  select: {
10
8
  helpNavigate: 'navegar',
@@ -27,7 +25,8 @@ const esLocale = {
27
25
  },
28
26
  password: {
29
27
  maskedText: '[entrada oculta]',
28
+ helpToggle: 'alternar visibilidad',
30
29
  },
31
30
  };
32
- export const { confirm, select, checkbox, search, expand, rawlist, editor, input, number, password, } = createLocalizedPrompts(esLocale);
31
+ export const { confirm, select, checkbox, search, expand, rawlist, editor, input, number, password, } = createLocalizedPrompts(locale);
33
32
  export { Separator } from '@inquirer/prompts';