Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more properties to useDayPicker #2427

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/DayPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ export function DayPicker(props: DayPickerProps) {
nextMonth,
previousMonth,
goToMonth,
getModifiers
getModifiers,
components,
classNames,
styles,
labels,
formatters
};

return (
Expand Down
19 changes: 18 additions & 1 deletion src/useDayPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -28,6 +35,16 @@ export type DayPickerContext<T extends DayPickerProps> = {
select: SelectHandler<T> | 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<Styles> | undefined;
/** The labels used in the UI. */
labels: Labels;
/** The formatters used to format the UI elements. */
formatters: Formatters;
};

/**
Expand Down