···11+---
22+"@clack/prompts": minor
33+---
44+55+Add theme support for the text prompt. Users can now customize the colors of symbols, guide lines, and error messages by passing a `theme` option.
66+77+Example usage:
88+```typescript
99+import { text } from '@clack/prompts';
1010+import color from 'picocolors';
1111+1212+const result = await text({
1313+ message: 'Enter your name',
1414+ theme: {
1515+ formatSymbolActive: (str) => color.magenta(str),
1616+ formatGuide: (str) => color.blue(str),
1717+ formatErrorMessage: (str) => color.bgRed(color.white(str)),
1818+ }
1919+});
2020+```
2121+2222+Available theme options for text prompt:
2323+- `formatSymbolActive` - Format the prompt symbol in active/initial state
2424+- `formatSymbolSubmit` - Format the prompt symbol on submit
2525+- `formatSymbolCancel` - Format the prompt symbol on cancel
2626+- `formatSymbolError` - Format the prompt symbol on error
2727+- `formatErrorMessage` - Format error messages
2828+- `formatGuide` - Format the left guide line in active state
2929+- `formatGuideSubmit` - Format the guide line on submit
3030+- `formatGuideCancel` - Format the guide line on cancel
3131+- `formatGuideError` - Format the guide line on error
3232+3333+This establishes the foundation for theming support that will be extended to other prompts.
3434+
···7373 signal?: AbortSignal;
7474 withGuide?: boolean;
7575}
7676+7777+export type ColorFormatter = (str: string) => string;
7878+7979+/**
8080+ * Global theme options shared across all prompts.
8181+ * These control the common visual elements like the guide line.
8282+ */
8383+export interface GlobalTheme {
8484+ /** Format the left guide/border line (default: cyan) */
8585+ formatGuide?: ColorFormatter;
8686+ /** Format the guide line on submit (default: gray) */
8787+ formatGuideSubmit?: ColorFormatter;
8888+ /** Format the guide line on cancel (default: gray) */
8989+ formatGuideCancel?: ColorFormatter;
9090+ /** Format the guide line on error (default: yellow) */
9191+ formatGuideError?: ColorFormatter;
9292+}
9393+9494+export interface ThemeOptions<T> {
9595+ theme?: T & GlobalTheme;
9696+}
9797+9898+export const defaultGlobalTheme: Required<GlobalTheme> = {
9999+ formatGuide: color.cyan,
100100+ formatGuideSubmit: color.gray,
101101+ formatGuideCancel: color.gray,
102102+ formatGuideError: color.yellow,
103103+};
104104+105105+export function resolveTheme<T>(
106106+ theme: Partial<T> | undefined,
107107+ defaults: T
108108+): T {
109109+ return { ...defaults, ...theme };
110110+}