UNPKG

909 BPlain TextView Raw
1import type { DateLib, LabelOptions } from "../index.js";
2import { dateLib as defaultDateLib } from "../lib/index.js";
3import type { Modifiers } from "../types/index.js";
4
5/**
6 * The ARIA label for the day button.
7 *
8 * Use the `modifiers` argument to add additional context to the label, e.g.
9 * when a day is selected or is today.
10 *
11 * @defaultValue The formatted date.
12 * @group Labels
13 * @see https://daypicker.dev/docs/translation#aria-labels
14 */
15export function labelDayButton(
16 date: Date,
17 /** The modifiers for the day. */
18 modifiers: Modifiers,
19 options?: LabelOptions,
20 /** @ignore */
21 dateLib: DateLib = defaultDateLib
22) {
23 let label = dateLib.format(date, "PPPP", options);
24 if (modifiers.today) label = `Today, ${label}`;
25 if (modifiers.selected) label = `${label}, selected`;
26 return label;
27}
28
29/** @deprecated Use `labelDayButton` instead. */
30export const labelDay = labelDayButton;