# @salmonui/calendars/date-picker API reference

> 40 exported symbols of @salmonui/calendars/date-picker: 2 components, 5 functions, 18 interfaces, 14 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/calendars/date-picker

```ts
import { … } from '@salmonui/calendars/date-picker';
```

## Components

### DatePicker

Kind: component

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePicker

```ts
function DatePicker(props: DatePickerProps): import("react").JSX.Element;
```

Props: [`DatePickerProps`](https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerProps) (its members are the props)

## Interfaces

### DatePickerLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerLocaleText

```ts
interface DatePickerLocaleText {
    readonly chooseDate: PickerMessage;
    readonly chooseDateTime: PickerMessage;
    readonly clear: PickerMessage;
    readonly close: PickerMessage;
    readonly time: PickerMessage;
    readonly timeList: PickerMessage;
    readonly rangeUnderflow: PickerMessage;
    readonly rangeOverflow: PickerMessage;
    readonly unavailable: PickerMessage;
}
```

UI strings of `DatePicker` (`localeText`).

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `chooseDate` | `readonly chooseDate: PickerMessage;` |  |  |
| `chooseDateTime` | `readonly chooseDateTime: PickerMessage;` |  |  |
| `clear` | `readonly clear: PickerMessage;` |  |  |
| `close` | `readonly close: PickerMessage;` |  |  |
| `time` | `readonly time: PickerMessage;` |  |  |
| `timeList` | `readonly timeList: PickerMessage;` |  |  |
| `rangeUnderflow` | `readonly rangeUnderflow: PickerMessage;` |  | Validity message for a value before `min` (`{min}`). |
| `rangeOverflow` | `readonly rangeOverflow: PickerMessage;` |  | Validity message for a value after `max` (`{max}`). |
| `unavailable` | `readonly unavailable: PickerMessage;` |  |  |

### DatePickerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerProps

```ts
interface DatePickerProps extends PickerFieldProps, DatePickerCalendarProps {
    readonly value?: DateInput | null | undefined;
    readonly defaultValue?: DateInput | null | undefined;
    readonly onValueChange?: ((value: PlainDate | PlainDateTime | null, details: DatePickerValueChangeDetails) => void) | undefined;
    readonly granularity?: DatePickerGranularity | undefined;
    readonly min?: DateInput | null | undefined;
    readonly max?: DateInput | null | undefined;
    readonly format?: DateFormat | undefined;
    readonly inputFormats?: readonly string[] | undefined;
    readonly parse?: ParseFn | undefined;
    readonly placeholderValue?: DateInput | null | undefined;
    readonly timeStep?: number | undefined;
    readonly minTime?: TimeInput | null | undefined;
    readonly maxTime?: TimeInput | null | undefined;
    readonly localeText?: Partial<DatePickerLocaleText> | undefined;
    readonly ref?: Ref<PickerHandle> | undefined;
}
```

Members (64):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `value` | `readonly value?: DateInput \| null \| undefined;` | optional | A `PlainDate` or `PlainDateTime` (what `onValueChange` passes), fields, an ISO string or a `Date` instant. |
| `defaultValue` | `readonly defaultValue?: DateInput \| null \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: PlainDate \| PlainDateTime \| null, details: DatePickerValueChangeDetails) => void) \| undefined;` | optional | `PlainDate` for `'year' \| 'month' \| 'day'`, `PlainDateTime` for `'hour' \| 'minute' \| 'second'`. |
| `granularity` | `readonly granularity?: DatePickerGranularity \| undefined;` | optional | Deepest segment; also the deepest calendar view and the time part. Default `'day'`. |
| `min` | `readonly min?: DateInput \| null \| undefined;` | optional |  |
| `max` | `readonly max?: DateInput \| null \| undefined;` | optional |  |
| `format` | `readonly format?: DateFormat \| undefined;` | optional | Display format of the field: `Intl` options, a skeleton (`'yMMMd'`) or a pattern (`'dd/MM/yyyy'`); the segments follow it. |
| `inputFormats` | `readonly inputFormats?: readonly string[] \| undefined;` | optional | Extra patterns accepted when typing over or pasting a whole value. |
| `parse` | `readonly parse?: ParseFn \| undefined;` | optional | Custom text parser for paste. |
| `placeholderValue` | `readonly placeholderValue?: DateInput \| null \| undefined;` | optional | Segment seed and popup position without a value. |
| `timeStep` | `readonly timeStep?: number \| undefined;` | optional | Minutes between time list options (default 30). |
| `minTime` | `readonly minTime?: TimeInput \| null \| undefined;` | optional | Daily time window. |
| `maxTime` | `readonly maxTime?: TimeInput \| null \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: Partial<DatePickerLocaleText> \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<PickerHandle> \| undefined;` | optional |  |
| `firstDayOfWeek` | `firstDayOfWeek?: number;` | optional, inherited |  |
| `showWeekNumbers` | `showWeekNumbers?: boolean;` | optional, inherited |  |
| `weekRule` | `weekRule?: WeekRule;` | optional, inherited |  |
| `weekdayFormat` | `weekdayFormat?: WeekdayFormat;` | optional, inherited |  |
| `calendar` | `calendar?: string;` | optional, inherited | `Intl` calendar id (`'gregory'`, `'islamic-umalqura'`, `'japanese'`, ...). |
| `showTodayButton` | `showTodayButton?: boolean;` | optional, inherited |  |
| `showOutsideDays` | `showOutsideDays?: boolean;` | optional, inherited |  |
| `isDateDisabled` | `isDateDisabled?: ((date: PlainDate) => boolean);` | optional, inherited |  |
| `renderDay` | `renderDay?: ((ctx: CalendarDayContext) => ReactNode);` | optional, inherited |  |
| `getDayProps` | `getDayProps?: ((ctx: CalendarDayContext) => CalendarDayProps \| undefined);` | optional, inherited |  |
| `view` | `view?: CalendarView;` | optional, inherited |  |
| `defaultView` | `defaultView?: CalendarView;` | optional, inherited |  |
| `onViewChange` | `onViewChange?: ((view: CalendarView) => void);` | optional, inherited |  |
| `focusedValue` | `focusedValue?: DateInput;` | optional, inherited |  |
| `defaultFocusedValue` | `defaultFocusedValue?: DateInput;` | optional, inherited |  |
| `onFocusedValueChange` | `onFocusedValueChange?: ((date: PlainDate) => void);` | optional, inherited |  |
| `open` | `open?: boolean;` | optional, inherited |  |
| `defaultOpen` | `defaultOpen?: boolean;` | optional, inherited |  |
| `onOpenChange` | `onOpenChange?: ((open: boolean, details: PickerOpenChangeDetails) => void);` | optional, inherited |  |
| `popupMode` | `popupMode?: PopupMode;` | optional, inherited |  |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `openOnFocus` | `openOnFocus?: boolean;` | optional, inherited | Opens the popup when focus enters the field. |
| `editable` | `editable?: boolean;` | optional, inherited | `false` makes the segments read-only; a click on the field opens the popup. |
| `clearable` | `clearable?: boolean;` | optional, inherited | Renders a clear button. |
| `onClear` | `onClear?: (() => void);` | optional, inherited |  |
| `strict` | `strict?: boolean;` | optional, inherited | Out-of-range values move to the nearest bound and disabled or unparsable input reverts on blur. |
| `required` | `required?: boolean;` | optional, inherited |  |
| `invalid` | `invalid?: boolean;` | optional, inherited |  |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ReactNode;` | optional, inherited |  |
| `placeholder` | `placeholder?: string;` | optional, inherited | Watermark shown while empty and not focused. |
| `name` | `name?: string;` | optional, inherited |  |
| `form` | `form?: string;` | optional, inherited |  |
| `autoFocus` | `autoFocus?: boolean;` | optional, inherited |  |
| `onFocus` | `onFocus?: ((event: FocusEvent<Element, Element>) => void);` | optional, inherited | Focus entered the field group (once). |
| `onBlur` | `onBlur?: ((event: FocusEvent<Element, Element>) => void);` | optional, inherited | Focus left the field group and its popup (once). |
| `onInvalid` | `onInvalid?: (() => void);` | optional, inherited | The form value input failed constraint validation. |
| `locale` | `locale?: string;` | optional, inherited | BCP 47 locale; default `'en-US'`. |
| `timeZone` | `timeZone?: string;` | optional, inherited | IANA time zone for instant values (`Date`, ISO with an offset). |
| `hourCycle` | `hourCycle?: "h12" \| "h23";` | optional, inherited |  |
| `size` | `size?: "lg" \| "md" \| "sm";` | optional, inherited | Control size: `'sm'` 24px, `'md'` 32px (default), `'lg'` 40px tall. |
| `id` | `id?: string;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `aria-label` | `aria-label?: string;` | optional, inherited |  |
| `aria-labelledby` | `aria-labelledby?: string;` | optional, inherited |  |
| `aria-describedby` | `aria-describedby?: string;` | optional, inherited |  |

### DatePickerValueChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerValueChangeDetails

```ts
interface DatePickerValueChangeDetails {
    readonly source: ChangeSource;
    readonly reason: 'input' | 'calendar' | 'time' | 'clear' | 'reset' | 'strict';
    readonly iso: string;
    readonly epochMilliseconds?: number | undefined;
}
```

Second argument of `onValueChange`.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ChangeSource;` |  |  |
| `reason` | `readonly reason: 'input' \| 'calendar' \| 'time' \| 'clear' \| 'reset' \| 'strict';` |  |  |
| `iso` | `readonly iso: string;` |  | The form value (`YYYY-MM-DD`, `YYYY-MM`, `YYYY`, `YYYY-MM-DDTHH:mm[:ss]` with an offset when `timeZone` is given; `''` when empty). |
| `epochMilliseconds` | `readonly epochMilliseconds?: number \| undefined;` | optional | The instant of a date-time value in the resolved time zone. |

### PickerHandle

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/PickerHandle

```ts
interface PickerHandle {
    readonly element: HTMLDivElement | null;
    focus(options?: FocusOptions): void;
    blur(): void;
    open(): void;
    close(): void;
}
```

The `ref` handle of every picker.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `readonly element: HTMLDivElement \| null;` |  | The root element of the picker. |
| `focus` | `focus(options?: FocusOptions): void;` |  |  |
| `blur` | `blur(): void;` |  |  |
| `open` | `open(): void;` |  |  |
| `close` | `close(): void;` |  |  |

### PickerOpenChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/PickerOpenChangeDetails

```ts
interface PickerOpenChangeDetails {
    readonly source: ChangeSource;
    readonly reason: 'trigger' | 'keyboard' | 'focus' | 'escape' | 'outside' | 'tab' | 'select' | 'apply' | 'cancel' | 'api' | 'field';
}
```

Second argument of `onOpenChange`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: ChangeSource;` |  |  |
| `reason` | `readonly reason: 'trigger' \| 'keyboard' \| 'focus' \| 'escape' \| 'outside' \| 'tab' \| 'select' \| 'apply' \| 'cancel' \| 'api' \| 'field';` |  |  |

### TimeOptionContext

Kind: interface

Page: https://salmonui.dev/docs/reference/calendars/date-picker/TimeOptionContext

```ts
interface TimeOptionContext {
    readonly time: PlainTime;
    readonly text: string;
    readonly selected: boolean;
    readonly disabled: boolean;
    readonly index: number;
}
```

Context of `renderOption`.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `time` | `readonly time: PlainTime;` |  |  |
| `text` | `readonly text: string;` |  | The formatted option text. |
| `selected` | `readonly selected: boolean;` |  |  |
| `disabled` | `readonly disabled: boolean;` |  |  |
| `index` | `readonly index: number;` |  |  |

## Types

### ChangeSource

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-picker/ChangeSource

```ts
type ChangeSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

### DatePickerCalendarProps

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerCalendarProps

```ts
type DatePickerCalendarProps = PickerCalendarProps;
```

The popup `Calendar` props a `DatePicker` forwards.

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `firstDayOfWeek` | `firstDayOfWeek?: number;` | optional, inherited |  |
| `showWeekNumbers` | `showWeekNumbers?: boolean;` | optional, inherited |  |
| `weekRule` | `weekRule?: WeekRule;` | optional, inherited |  |
| `weekdayFormat` | `weekdayFormat?: WeekdayFormat;` | optional, inherited |  |
| `calendar` | `calendar?: string;` | optional, inherited | `Intl` calendar id (`'gregory'`, `'islamic-umalqura'`, `'japanese'`, ...). |
| `showTodayButton` | `showTodayButton?: boolean;` | optional, inherited |  |
| `showOutsideDays` | `showOutsideDays?: boolean;` | optional, inherited |  |
| `isDateDisabled` | `isDateDisabled?: ((date: PlainDate) => boolean);` | optional, inherited |  |
| `renderDay` | `renderDay?: ((ctx: CalendarDayContext) => ReactNode);` | optional, inherited |  |
| `getDayProps` | `getDayProps?: ((ctx: CalendarDayContext) => CalendarDayProps \| undefined);` | optional, inherited |  |
| `view` | `view?: CalendarView;` | optional, inherited |  |
| `defaultView` | `defaultView?: CalendarView;` | optional, inherited |  |
| `onViewChange` | `onViewChange?: ((view: CalendarView) => void);` | optional, inherited |  |
| `focusedValue` | `focusedValue?: DateInput;` | optional, inherited |  |
| `defaultFocusedValue` | `defaultFocusedValue?: DateInput;` | optional, inherited |  |
| `onFocusedValueChange` | `onFocusedValueChange?: ((date: PlainDate) => void);` | optional, inherited |  |

### DatePickerGranularity

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DatePickerGranularity

```ts
type DatePickerGranularity = PickerGranularity;
```

### PickerMessage

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-picker/PickerMessage

```ts
type PickerMessage = string | {
    readonly zero?: string;
    readonly one?: string;
    readonly two?: string;
    readonly few?: string;
    readonly many?: string;
    readonly other: string;
};
```

A `localeText` message: a `{param}` template or plural forms (the Data Grid `LocaleMessage` shape).

### PopupMode

Kind: type

Page: https://salmonui.dev/docs/reference/calendars/date-picker/PopupMode

```ts
type PopupMode = 'popover' | 'modal' | 'auto';
```

## Constants

### DATE_PICKER_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/calendars/date-picker/DATE_PICKER_DEFAULT_LOCALE_TEXT

```ts
const DATE_PICKER_DEFAULT_LOCALE_TEXT: DatePickerLocaleText;
```

## Re-exported entry points

- [@salmonui/calendars/calendar](https://salmonui.dev/docs/reference/calendars/calendar.md): 20 symbols: 5 functions, 8 interfaces and 7 types
  `CalendarDayContext`, `CalendarDayProps`, `CalendarView`, `DateInput`, `DateRange`, `DateTimeInput`, `PlainDate`, `PlainDateLike`, `PlainDateTime`, `PlainDateTimeLike`, `PlainTime`, `PlainTimeLike`, `TimeInput`, `WeekRule`, `WeekdayFormat`, `getRangeDays`, `toDate`, `toPlainDate`, `toPlainDateTime`, `toPlainTime`
- [@salmonui/calendars/date-field](https://salmonui.dev/docs/reference/calendars/date-field.md): 7 symbols: 1 component, 4 interfaces and 2 types
  `DateField`, `DateFieldDateProps`, `DateFieldDateTimeProps`, `DateFieldProps`, `FieldBaseProps`, `FieldChangeDetails`, `FieldLocaleText`
