Skip to content

Commit b780203

Browse files
committed
chore: rebase branch
1 parent 69b7030 commit b780203

File tree

6 files changed

+257
-324
lines changed

6 files changed

+257
-324
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
"volta": {
2626
"node": "20.18.1"
2727
}
28-
}
28+
}

packages/core/src/index.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
export { default as ConfirmPrompt } from "./prompts/confirm";
2-
export { default as GroupMultiSelectPrompt } from "./prompts/group-multiselect";
3-
export { default as MultiSelectPrompt } from "./prompts/multi-select";
4-
export { default as PasswordPrompt } from "./prompts/password";
5-
export { default as Prompt, State } from "./prompts/prompt";
6-
export { default as SelectPrompt } from "./prompts/select";
7-
export { default as SelectKeyPrompt } from "./prompts/select-key";
8-
export { default as TextPrompt } from "./prompts/text";
9-
export { block, isCancel, strLength, setGlobalAliases } from "./utils";
1+
export { default as ConfirmPrompt } from './prompts/confirm';
2+
export { default as GroupMultiSelectPrompt } from './prompts/group-multiselect';
3+
export { default as MultiSelectPrompt } from './prompts/multi-select';
4+
export { default as PasswordPrompt } from './prompts/password';
5+
export { default as Prompt } from './prompts/prompt';
6+
export { default as SelectPrompt } from './prompts/select';
7+
export { default as SelectKeyPrompt } from './prompts/select-key';
8+
export { default as TextPrompt } from './prompts/text';
9+
export type { ClackState as State } from './types';
10+
export { block, isCancel, strLength, setGlobalAliases } from './utils';

packages/core/src/prompts/prompt.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export interface PromptOptions<Self extends Prompt> {
2020
debug?: boolean;
2121
}
2222

23-
export type State = 'initial' | 'active' | 'cancel' | 'submit' | 'error';
24-
2523
export type LineOption = 'firstLine' | 'newLine' | 'lastLine';
2624

2725
export interface FormatLineOptions {
@@ -313,8 +311,8 @@ export default class Prompt {
313311
): NonNullable<FormatOptions[TLine][TKey]> => {
314312
return (
315313
key === 'style'
316-
? options?.[line]?.[key] ?? options?.default?.[key] ?? ((line) => line)
317-
: options?.[line]?.[key] ?? options?.[line]?.sides ?? options?.default?.[key] ?? ''
314+
? (options?.[line]?.[key] ?? options?.default?.[key] ?? ((line) => line))
315+
: (options?.[line]?.[key] ?? options?.[line]?.sides ?? options?.default?.[key] ?? '')
318316
) as NonNullable<FormatOptions[TLine][TKey]>;
319317
};
320318
const getLineOptions = (line: LineOption): Omit<FormatLineOptions, 'sides'> => {
@@ -376,14 +374,14 @@ export default class Prompt {
376374
): FormatLineOptions[TPosition] => {
377375
return (
378376
i === 0 && ar.length === 1
379-
? options?.firstLine?.[position] ??
380-
options?.lastLine?.[position] ??
381-
firstLine[position]
377+
? (options?.firstLine?.[position] ??
378+
options?.lastLine?.[position] ??
379+
firstLine[position])
382380
: i === 0
383-
? firstLine[position]
384-
: i + 1 === ar.length
385-
? lastLine[position]
386-
: newLine[position]
381+
? firstLine[position]
382+
: i + 1 === ar.length
383+
? lastLine[position]
384+
: newLine[position]
387385
) as FormatLineOptions[TPosition];
388386
};
389387
const startLine = opt('start');
@@ -401,9 +399,10 @@ export default class Prompt {
401399
.join('\n');
402400
}
403401

404-
private _prevFrame = '';
405402
private render() {
406-
const frame = wrap(this._render(this) ?? '', process.stdout.columns, { hard: true });
403+
const frame = wrap(this._render(this) ?? '', process.stdout.columns, {
404+
hard: true,
405+
});
407406
if (frame === this._prevFrame) return;
408407

409408
if (this.state === 'initial') {

packages/core/src/utils/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ export function strLength(str: string): number {
101101
}
102102

103103
// Remove ANSI escape codes from the input string.
104-
str = stripAnsi(str);
104+
const stripedStr = stripAnsi(str);
105105

106106
let length = 0;
107107

108-
for (let i = 0; i < str.length; i++) {
109-
const code = str.codePointAt(i);
108+
for (let i = 0; i < stripedStr.length; i++) {
109+
const code = stripedStr.codePointAt(i);
110110

111111
if (!code || isControlCharacter(code) || isCombiningCharacter(code)) {
112112
continue;

0 commit comments

Comments
 (0)