From 02ded33fa6344dcd40f43c7a815e0635e9493056 Mon Sep 17 00:00:00 2001 From: Giampaolo Bellavite Date: Fri, 6 Sep 2024 17:33:12 -0500 Subject: [PATCH] feat: add more properties to useDayPicker Fix #2420. --- src/DayPicker.tsx | 7 ++++++- src/useDayPicker.ts | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/DayPicker.tsx b/src/DayPicker.tsx index 71226c7f1..0c3e2ed41 100644 --- a/src/DayPicker.tsx +++ b/src/DayPicker.tsx @@ -248,7 +248,12 @@ export function DayPicker(props: DayPickerProps) { nextMonth, previousMonth, goToMonth, - getModifiers + getModifiers, + components, + classNames, + styles, + labels, + formatters }; return ( diff --git a/src/useDayPicker.ts b/src/useDayPicker.ts index 2cce86743..cb39abca5 100644 --- a/src/useDayPicker.ts +++ b/src/useDayPicker.ts @@ -4,7 +4,14 @@ import { CalendarDay } from "./classes/CalendarDay.js"; import { CalendarMonth } from "./classes/CalendarMonth.js"; import type { DayPickerProps } from "./types/props.js"; import type { SelectedValue, SelectHandler } from "./types/selection.js"; -import { Modifiers } from "./types/shared.js"; +import { + ClassNames, + CustomComponents, + Formatters, + Labels, + Modifiers, + Styles +} from "./types/shared.js"; /** @private */ export const dayPickerContext = createContext< @@ -28,6 +35,16 @@ export type DayPickerContext = { select: SelectHandler | undefined; /** Whether the given date is selected. */ isSelected: ((date: Date) => boolean) | undefined; + /** The components used internally by DayP. */ + components: CustomComponents; + /** The class names for the UI elements. */ + classNames: ClassNames; + /** The styles for the UI elements. */ + styles: Partial | undefined; + /** The labels used in the UI. */ + labels: Labels; + /** The formatters used to format the UI elements. */ + formatters: Formatters; }; /**