Skip to content

Commit c263cbd

Browse files
committed
update version
1 parent 7dcad8f commit c263cbd

File tree

14 files changed

+51
-39
lines changed

14 files changed

+51
-39
lines changed

.changeset/four-bobcats-turn.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/gorgeous-peaches-give.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/tender-dingos-guess.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/tidy-kids-teach.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/basic/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.json"
3+
}

packages/core/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @clack/core
22

3+
## 0.1.2
4+
5+
### Patch Changes
6+
7+
- Allow isCancel to type guard any unknown value
8+
- 7dcad8f: Allow placeholder to be passed to TextPrompt
9+
- 2242f13: Fix multiselect returning undefined
10+
- b1341d6: Improved placeholder handling
11+
312
## 0.1.1
413

514
### Patch Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@clack/core",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"type": "module",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",

packages/core/src/prompts/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function diffLines(a: string, b: string) {
2121
}
2222

2323
const cancel = Symbol('clack:cancel');
24-
export function isCancel(value: string|symbol): value is symbol {
24+
export function isCancel(value: unknown): value is symbol {
2525
return value === cancel;
2626
}
2727

packages/core/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.json"
3+
}

packages/prompts/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# @clack/prompts
22

3+
## 0.2.0
4+
5+
### Minor Changes
6+
7+
- Improved type safety
8+
- b1341d6: Updated styles, new note component
9+
10+
### Patch Changes
11+
12+
- Updated dependencies [7dcad8f]
13+
- Updated dependencies [2242f13]
14+
- Updated dependencies [b1341d6]
15+
- @clack/core@0.1.2
16+
317
## 0.1.1
418

519
### Patch Changes

packages/prompts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@clack/prompts",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"type": "module",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",
@@ -52,7 +52,7 @@
5252
"prepack": "unbuild"
5353
},
5454
"dependencies": {
55-
"@clack/core": "workspace:^0.1.1",
55+
"@clack/core": "workspace:^0.1.3",
5656
"ansi-regex": "^6.0.1",
5757
"picocolors": "^1.0.0",
5858
"sisteransi": "^1.0.5"

packages/prompts/src/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const text = (opts: TextOptions) => {
6060
)}\n`;
6161
}
6262
},
63-
}).prompt();
63+
}).prompt() as Promise<string | symbol>;
6464
};
6565

6666
export interface ConfirmOptions {
@@ -102,21 +102,21 @@ export const confirm = (opts: ConfirmOptions) => {
102102
}
103103
}
104104
},
105-
}).prompt();
105+
}).prompt() as Promise<boolean | symbol>;
106106
};
107107

108-
interface Option {
109-
value: any;
108+
interface Option<Value extends Readonly<string>> {
109+
value: Value;
110110
label?: string;
111111
hint?: string;
112112
}
113-
export interface SelectOptions<Options extends Option[]> {
113+
export interface SelectOptions<Options extends Option<Value>[], Value extends Readonly<string>> {
114114
message: string;
115115
options: Options;
116116
initialValue?: Options[number]["value"];
117117
}
118-
export const select = <Options extends Option[]>(
119-
opts: SelectOptions<Options>
118+
export const select = <Options extends Option<Value>[], Value extends Readonly<string>>(
119+
opts: SelectOptions<Options, Value>
120120
) => {
121121
const opt = (
122122
option: Options[number],
@@ -163,10 +163,10 @@ export const select = <Options extends Option[]>(
163163
}
164164
}
165165
},
166-
}).prompt();
166+
}).prompt() as Promise<Options[number]['value'] | symbol>;
167167
};
168168

169-
export const multiselect = <Options extends Option[]>(opts: SelectOptions<Options>) => {
169+
export const multiselect = <Options extends Option<Value>[], Value extends Readonly<string>>(opts: SelectOptions<Options, Value>) => {
170170
const opt = (option: Options[number], state: 'inactive' | 'active' | 'selected' | 'active-selected' | 'submitted' | 'cancelled') => {
171171
const label = option.label ?? option.value;
172172
if (state === 'active') {
@@ -191,18 +191,18 @@ export const multiselect = <Options extends Option[]>(opts: SelectOptions<Option
191191

192192
switch (this.state) {
193193
case 'submit': {
194-
const selectedOptions = this.options.filter(option => this.selectedValues.some(selectedValue => selectedValue === option.value));
194+
const selectedOptions = this.options.filter(option => this.selectedValues.some(selectedValue => selectedValue === option.value as any));
195195
return `${title}${color.gray(bar)} ${selectedOptions.map((option, i) => opt(option, 'submitted')).join(color.dim(", "))}`;
196196
};
197197
case 'cancel': {
198-
const selectedOptions = this.options.filter(option => this.selectedValues.some(selectedValue => selectedValue === option.value));
198+
const selectedOptions = this.options.filter(option => this.selectedValues.some(selectedValue => selectedValue === option.value as any));
199199
const label = selectedOptions.map((option, i) => opt(option, 'cancelled')).join(color.dim(", "));
200200
return `${title}${color.gray(bar)} ${label.trim() ? `${label}\n${color.gray(bar)}` : ''}`
201201
};
202202
case 'error': {
203203
const footer = this.error.split('\n').map((ln, i) => i === 0 ? `${color.yellow(barEnd)} ${color.yellow(ln)}` : ` ${ln}`).join('\n');
204204
return `${title}${color.yellow(bar)} ${this.options.map((option, i) => {
205-
const isOptionSelected = this.selectedValues.includes(option.value);
205+
const isOptionSelected = this.selectedValues.includes(option.value as any);
206206
const isOptionHovered = i === this.cursor;
207207
if(isOptionHovered && isOptionSelected) {
208208
return opt(option, 'active-selected');
@@ -215,7 +215,7 @@ export const multiselect = <Options extends Option[]>(opts: SelectOptions<Option
215215
}
216216
default: {
217217
return `${title}${color.cyan(bar)} ${this.options.map((option, i) => {
218-
const isOptionSelected = this.selectedValues.includes(option.value);
218+
const isOptionSelected = this.selectedValues.includes(option.value as any);
219219
const isOptionHovered = i === this.cursor;
220220
if(isOptionHovered && isOptionSelected) {
221221
return opt(option, 'active-selected');
@@ -228,7 +228,7 @@ export const multiselect = <Options extends Option[]>(opts: SelectOptions<Option
228228
}
229229
}
230230
}
231-
}).prompt();
231+
}).prompt() as Promise<Options[number]['value'][] | symbol>;
232232
}
233233

234234
const strip = (str: string) => str.replace(ansiRegex(), '')

packages/prompts/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.json"
3+
}

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)