···11+---
22+"@clack/prompts": patch
33+---
44+55+docs: add jsdoc for `date`, `limit-options`, and `messages`
+6-6
packages/prompts/README.md
···93939494### Date
95959696-The date component accepts a calendar date and returns a `Date` value.
9696+The `date` prompt provides an interactive date picker, allowing users to navigate between year, month, and day segments and increment/decrement values using keyboard controls.
97979898```js
9999import { date } from '@clack/prompts';
100100101101-const dueDate = await date({
102102- message: 'Pick a due date.',
103103- format: 'YMD',
104104- minDate: new Date(Date.UTC(2026, 0, 1)),
105105- maxDate: new Date(Date.UTC(2026, 11, 31)),
101101+const birthday = await date({
102102+ message: 'Pick your birthday',
103103+ minDate: new Date('1900-01-01'),
104104+ initialValue: new Date(),
105105+ maxDate: new Date(),
106106});
107107```
108108
+53
packages/prompts/src/date.ts
···5566export type { DateFormat };
7788+/**
99+ * Options for the {@link date} prompt.
1010+ */
811export interface DateOptions extends CommonOptions {
1212+ /**
1313+ * The message or question shown to the user above the input.
1414+ */
915 message: string;
1616+1717+ /**
1818+ * The date format for the input segments.
1919+ * @deafult based on locale
2020+ */
1021 format?: DateFormat;
2222+2323+ /**
2424+ * The BCP 47 language tag to use for formatting
2525+ * @see https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag
2626+ * @example "en-GB"
2727+ */
1128 locale?: string;
2929+3030+ /**
3131+ * The default value returned when the user doesn't select a date.
3232+ */
1233 defaultValue?: Date;
3434+3535+ /**
3636+ * The starting date shown when the prompt first renders.
3737+ * Users can edit this value before submitting.
3838+ */
1339 initialValue?: Date;
4040+4141+ /**
4242+ * The minimum allowed date for validation.
4343+ */
1444 minDate?: Date;
4545+4646+ /**
4747+ * The maximum allowed date for validation.
4848+ */
1549 maxDate?: Date;
16501751 /**
···2256 validate?: Validate<Date>;
2357}
24585959+/**
6060+ * The `date` prompt provides an interactive date picker, allowing users
6161+ * to navigate between year, month, and day segments and
6262+ * increment/decrement values using keyboard controls.
6363+ *
6464+ * @see https://bomb.sh/docs/clack/packages/prompts/#date-input
6565+ *
6666+ * @example
6767+ * ```ts
6868+ * import { date } from '@clack/prompts';
6969+ *
7070+ * const birthday = await date({
7171+ * message: 'Pick your birthday',
7272+ * minDate: new Date('1900-01-01'),
7373+ * initialValue: new Date(),
7474+ * maxDate: new Date(),
7575+ * });
7676+ * ```
7777+ */
2578export const date = (opts: DateOptions) => {
2679 const validate = opts.validate;
2780 return new DatePrompt({
+55
packages/prompts/src/limit-options.ts
···33import { wrapAnsi } from 'fast-wrap-ansi';
44import type { CommonOptions } from './common.js';
5566+/**
77+ * Options for the {@link limitOptions} function.
88+ */
69export interface LimitOptionsParams<TOption> extends CommonOptions {
1010+ /**
1111+ * The list of options to display.
1212+ */
713 options: TOption[];
1414+1515+ /**
1616+ * The index of the currently active/selected option.
1717+ */
818 cursor: number;
1919+2020+ /**
2121+ * A function that styles the given option string.
2222+ *
2323+ * @param option - The option string to style.
2424+ * @param active - Whether the option is currently selected.
2525+ */
926 style: (option: TOption, active: boolean) => string;
2727+2828+ /**
2929+ * Maximum number of options to display at once.
3030+ * @default Infinity
3131+ */
1032 maxItems?: number;
3333+3434+ /**
3535+ * Number of columns to reserve for padding.
3636+ * @default 0
3737+ */
1138 columnPadding?: number;
3939+4040+ /**
4141+ * Number of rows to reserve for padding.
4242+ * @default 4
4343+ */
1244 rowPadding?: number;
1345}
1446···3870 return { lineCount, removals };
3971};
40727373+/**
7474+ * Trims an option list to what fits the terminal, while keeping the active
7575+ * option (cursor) visible using a Clack style sliding window.
7676+ *
7777+ * @returns The lines to render.
7878+ *
7979+ * @see https://bomb.sh/docs/clack/packages/prompts/#limitoptions
8080+ *
8181+ * @example
8282+ * ```ts
8383+ * import { limitOptions } from '@clack/prompts';
8484+ * import { styleText } from 'node:util';
8585+ *
8686+ * const options = ['apple', 'banana', 'cherry', 'date'];
8787+ * const lines = limitOptions({
8888+ * options,
8989+ * cursor: 2,
9090+ * maxItems: 8,
9191+ * style: (opt, active) =>
9292+ * active ? styleText('cyan', opt) : styleText('dim', opt),
9393+ * });
9494+ * ```
9595+ */
4196export const limitOptions = <TOption>({
4297 cursor,
4398 options,
+48
packages/prompts/src/messages.ts
···33import { settings } from '@clack/core';
44import { type CommonOptions, S_BAR, S_BAR_END, S_BAR_START } from './common.js';
5566+/**
77+ * The `cancel` function defines an interruption of an interaction
88+ * and therefore its end.
99+ *
1010+ * @param title Optional closing message to be displayed.
1111+ * @param opts Additional configuration options.
1212+ *
1313+ * @see https://bomb.sh/docs/clack/packages/prompts/#cancel
1414+ *
1515+ * @example
1616+ * ```ts
1717+ * import { cancel } from '@clack/prompts';
1818+ * import process from 'node:process';
1919+ *
2020+ * cancel('Installation canceled');
2121+ * process.exit(1);
2222+ * ```
2323+ */
624export const cancel = (message = '', opts?: CommonOptions) => {
725 const output: Writable = opts?.output ?? process.stdout;
826 const hasGuide = opts?.withGuide ?? settings.withGuide;
···1028 output.write(`${prefix}${styleText('red', message)}\n\n`);
1129};
12303131+/**
3232+ * The `intro` function defines the beginning of an interaction.
3333+ *
3434+ * @param title Optional title to be displayed.
3535+ * @param opts Additional configuration options.
3636+ *
3737+ * @see https://bomb.sh/docs/clack/packages/prompts/#intro
3838+ *
3939+ * @example
4040+ * ```ts
4141+ * import { intro } from '@clack/prompts';
4242+ *
4343+ * intro('Welcome to clack');
4444+ * ```
4545+ */
1346export const intro = (title = '', opts?: CommonOptions) => {
1447 const output: Writable = opts?.output ?? process.stdout;
1548 const hasGuide = opts?.withGuide ?? settings.withGuide;
···1750 output.write(`${prefix}${title}\n`);
1851};
19525353+/**
5454+ * The `outro` function defines the end of an interaction.
5555+ *
5656+ * @param title Optional closing message to be displayed.
5757+ * @param opts Additional configuration options.
5858+ *
5959+ * @see https://bomb.sh/docs/clack/packages/prompts/#outro
6060+ *
6161+ * @example
6262+ * ```ts
6363+ * import { outro } from '@clack/prompts';
6464+ *
6565+ * outro('All operations are finished');
6666+ * ```
6767+ */
2068export const outro = (message = '', opts?: CommonOptions) => {
2169 const output: Writable = opts?.output ?? process.stdout;
2270 const hasGuide = opts?.withGuide ?? settings.withGuide;