AsterUIDocsv1.0.2

Docs / Component reference

Calendar, DatePicker & yield* pickDate()

Let someone choose a day by moving through a month. Calendar, DatePicker and the generator helper offer different ways to use that selection.

Calendar example

Install

sh
npx @fierst/ui@1.0.2 add calendar

Registry dependencies: theme, icon, button, dialog. Package dependencies: @lucide/icons.

Exports from ./ui/calendar: toIsoDate, Calendar, DatePicker, pickDate.

Download the registry source for calendar 1.0.2.

API contracts

ts
export function toIsoDate(d: Date): string

export function* Calendar(
  props: {
    value?: string;
    defaultValue?: string;
    min?: string;
    max?: string;
    /** Earliest selectable year in the year dropdown (default: 1900 or min's year). */
    fromYear?: number;
    /** Latest selectable year in the year dropdown (default: currentYear + 20 or max's year). */
    toYear?: number;
    locale?: string;
    embedded?: boolean;
    onChange?: (isoDate: string) => void;
    class?: string;
  },
  ctx: Ctx,
)

export function* DatePicker(
  props: {
    label?: string;
    value?: string;
    defaultValue?: string;
    min?: string;
    max?: string;
    fromYear?: number;
    toYear?: number;
    placeholder?: string;
    locale?: string;
    onChange?: (isoDate: string) => void;
    class?: string;
  },
  ctx: Ctx,
)

export function* pickDate(
  opts: {
    title?: string;
    description?: string;
    initial?: string;
    min?: string;
    max?: string;
    fromYear?: number;
    toYear?: number;
  } = {},
): Generator<View, string | null, any>