import React from "react"; import type { Locale } from "react-day-picker"; import { DateLib } from "react-day-picker"; import { amET, getDateLib as getDateLibEthiopic, } from "react-day-picker/ethiopic"; import * as locales from "react-day-picker/locale"; import { faIR, getDateLib as getDateLibPersian, } from "react-day-picker/persian"; import styles from "./styles.module.css"; import type { DayPickerPropsWithCalendar } from "./useQueryStringSync"; interface CustomizationFieldsetProps { props: DayPickerPropsWithCalendar; setProps: React.Dispatch>; accentColor: string; setAccentColor: React.Dispatch>; } function resolveDateLib(props: DayPickerPropsWithCalendar) { if (props.calendar === "persian") { return getDateLibPersian({ locale: (props.locale as Locale) ?? faIR, timeZone: props.timeZone, numerals: props.numerals, }); } if (props.calendar === "ethiopic") { return getDateLibEthiopic({ locale: (props.locale as Locale) ?? (amET as Locale), timeZone: props.timeZone, numerals: props.numerals, }); } return new DateLib({ locale: (props.locale as Locale) ?? locales.enUS, timeZone: props.timeZone, }); } function resolveReferenceDate( props: DayPickerPropsWithCalendar, dateLib: DateLib, ) { const candidates = [props.month, props.startMonth, props.defaultMonth]; for (const candidate of candidates) { if (candidate instanceof Date) return candidate; } return dateLib.today(); } export function CustomizationFieldset({ props, setProps, accentColor, setAccentColor, }: CustomizationFieldsetProps) { return (
Customization{" "}
{(props.captionLayout === "dropdown" || props.captionLayout === "dropdown-years") && ( )}
); }