@clack/prompts
Advanced tools
Comparing version 0.6.0 to 0.6.1
# @clack/prompts | ||
## 0.6.1 | ||
### Patch Changes | ||
- ca08fb6: Support complex value types for `select`, `multiselect` and `groupMultiselect`. | ||
## 0.6.0 | ||
@@ -4,0 +10,0 @@ |
@@ -25,30 +25,34 @@ export { isCancel } from '@clack/core'; | ||
type Primitive = Readonly<string | boolean | number>; | ||
interface Option<Value extends Primitive> { | ||
type Option<Value> = Value extends Primitive ? { | ||
value: Value; | ||
label?: string; | ||
hint?: string; | ||
} | ||
interface SelectOptions<Options extends Option<Value>[], Value extends Primitive> { | ||
} : { | ||
value: Value; | ||
label: string; | ||
hint?: string; | ||
}; | ||
interface SelectOptions<Options extends Option<Value>[], Value> { | ||
message: string; | ||
options: Options; | ||
initialValue?: Options[number]['value']; | ||
initialValue?: Value; | ||
} | ||
declare const select: <Options extends Option<Value>[], Value extends Primitive>(opts: SelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"]>; | ||
declare const selectKey: <Options extends Option<Value>[], Value extends string>(opts: SelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"]>; | ||
interface MultiSelectOptions<Options extends Option<Value>[], Value extends Primitive> { | ||
declare const select: <Options extends Option<Value>[], Value>(opts: SelectOptions<Options, Value>) => Promise<symbol | Value>; | ||
declare const selectKey: <Options extends Option<Value>[], Value extends string>(opts: SelectOptions<Options, Value>) => Promise<symbol | Value>; | ||
interface MultiSelectOptions<Options extends Option<Value>[], Value> { | ||
message: string; | ||
options: Options; | ||
initialValues?: Options[number]['value'][]; | ||
initialValues?: Value[]; | ||
required?: boolean; | ||
cursorAt?: Options[number]['value']; | ||
cursorAt?: Value; | ||
} | ||
declare const multiselect: <Options extends Option<Value>[], Value extends Primitive>(opts: MultiSelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"][]>; | ||
interface GroupMultiSelectOptions<Options extends Option<Value>[], Value extends Primitive> { | ||
declare const multiselect: <Options extends Option<Value>[], Value>(opts: MultiSelectOptions<Options, Value>) => Promise<symbol | Value[]>; | ||
interface GroupMultiSelectOptions<Options extends Option<Value>[], Value> { | ||
message: string; | ||
options: Record<string, Options>; | ||
initialValues?: Options[number]['value'][]; | ||
initialValues?: Value[]; | ||
required?: boolean; | ||
cursorAt?: Options[number]['value']; | ||
cursorAt?: Value; | ||
} | ||
declare const groupMultiselect: <Options extends Option<Value>[], Value extends Primitive>(opts: GroupMultiSelectOptions<Options, Value>) => Promise<symbol | Options[number]["value"][]>; | ||
declare const groupMultiselect: <Options extends Option<Value>[], Value>(opts: GroupMultiSelectOptions<Options, Value>) => Promise<symbol | Value[]>; | ||
declare const note: (message?: string, title?: string) => void; | ||
@@ -55,0 +59,0 @@ declare const cancel: (message?: string) => void; |
{ | ||
"name": "@clack/prompts", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs", |
324
43042