UNPKG

685 BPlain TextView Raw
1import * as defaultFormatters from "../formatters/index.js";
2import type { DayPickerProps } from "../types/index.js";
3
4/** Return the formatters from the props merged with the default formatters. */
5export function getFormatters(customFormatters: DayPickerProps["formatters"]) {
6 if (customFormatters?.formatMonthCaption && !customFormatters.formatCaption) {
7 customFormatters.formatCaption = customFormatters.formatMonthCaption;
8 }
9 if (
10 customFormatters?.formatYearCaption &&
11 !customFormatters.formatYearDropdown
12 ) {
13 customFormatters.formatYearDropdown = customFormatters.formatYearCaption;
14 }
15 return {
16 ...defaultFormatters,
17 ...customFormatters
18 };
19}