UNPKG

53.7 kBTypeScriptView Raw
1import * as react from 'react';
2import { CSSProperties, ReactNode, SelectHTMLAttributes, ChangeEventHandler, MouseEvent, FocusEvent, KeyboardEvent, PointerEvent, TouchEvent, InputHTMLAttributes, HTMLProps, RefObject } from 'react';
3import { Locale } from 'date-fns';
4
5/** Represent the props of the {@link Caption} component. */
6interface CaptionProps {
7 /** The ID for the heading element. Must be the same as the labelled-by in Table. */
8 id?: string;
9 /** The month where the caption is displayed. */
10 displayMonth: Date;
11 /** The index of the month where the caption is displayed. Older custom components may miss this prop. */
12 displayIndex?: number | undefined;
13}
14/**
15 * The layout of the caption:
16 *
17 * - `dropdown`: display dropdowns for choosing the month and the year.
18 * - `buttons`: display previous month / next month buttons.
19 * - `dropdown-buttons`: display both month / year dropdowns and previous month / next month buttons.
20 */
21type CaptionLayout = 'dropdown' | 'buttons' | 'dropdown-buttons';
22/**
23 * Render the caption of a month. The caption has a different layout when
24 * setting the {@link DayPickerBase.captionLayout} prop.
25 */
26declare function Caption(props: CaptionProps): JSX.Element;
27
28/** The props for the {@link CaptionLabel} component. */
29interface CaptionLabelProps {
30 /** The ID for the heading element. Must be the same as the labelled-by in Table. */
31 id?: string;
32 /** The month where the caption is displayed. */
33 displayMonth: Date;
34 /** The index of the month where the caption is displayed. Older custom components may miss this prop. */
35 displayIndex?: number | undefined;
36}
37/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
38declare function CaptionLabel(props: CaptionLabelProps): JSX.Element;
39
40/** Represent the props used by the {@link Day} component. */
41interface DayProps {
42 /** The month where the date is displayed. */
43 displayMonth: Date;
44 /** The date to render. */
45 date: Date;
46}
47/**
48 * The content of a day cell – as a button or span element according to its
49 * modifiers.
50 */
51declare function Day(props: DayProps): JSX.Element;
52
53/**
54 * A value or a function that matches a specific day.
55 *
56 *
57 * Matchers are passed to DayPicker via {@link DayPickerBase.disabled},
58 * {@link DayPickerBase.hidden]] or [[DayPickerProps.selected} and are used to
59 * determine if a day should get a {@link Modifier}.
60 *
61 * Matchers can be of different types:
62 *
63 * ```
64 * // will always match the day
65 * const booleanMatcher: Matcher = true;
66 *
67 * // will match the today's date
68 * const dateMatcher: Matcher = new Date();
69 *
70 * // will match the days in the array
71 * const arrayMatcher: Matcher = [new Date(2019, 1, 2), new Date(2019, 1, 4)];
72 *
73 * // will match days after the 2nd of February 2019
74 * const afterMatcher: DateAfter = { after: new Date(2019, 1, 2) };
75 * // will match days before the 2nd of February 2019 }
76 * const beforeMatcher: DateBefore = { before: new Date(2019, 1, 2) };
77 *
78 * // will match Sundays
79 * const dayOfWeekMatcher: DayOfWeek = {
80 * dayOfWeek: 0
81 * };
82 *
83 * // will match the included days, except the two dates
84 * const intervalMatcher: DateInterval = {
85 * after: new Date(2019, 1, 2),
86 * before: new Date(2019, 1, 5)
87 * };
88 *
89 * // will match the included days, including the two dates
90 * const rangeMatcher: DateRange = {
91 * from: new Date(2019, 1, 2),
92 * to: new Date(2019, 1, 5)
93 * };
94 *
95 * // will match when the function return true
96 * const functionMatcher: Matcher = (day: Date) => {
97 * return day.getMonth() === 2 // match when month is March
98 * };
99 * ```
100 *
101 * @see {@link isMatch}
102 *
103 * */
104type Matcher = boolean | ((date: Date) => boolean) | Date | Date[] | DateRange | DateBefore | DateAfter | DateInterval | DayOfWeek;
105/** A matcher to match a day falling after the specified date, with the date not included. */
106type DateAfter = {
107 after: Date;
108};
109/** A matcher to match a day falling before the specified date, with the date not included. */
110type DateBefore = {
111 before: Date;
112};
113/** A matcher to match a day falling before and/or after two dates, where the dates are not included. */
114type DateInterval = {
115 before: Date;
116 after: Date;
117};
118/** A matcher to match a range of dates. The range can be open. Differently from {@link DateInterval}, the dates here are included. */
119type DateRange = {
120 from: Date | undefined;
121 to?: Date | undefined;
122};
123/** A matcher to match a date being one of the specified days of the week (`0-6`, where `0` is Sunday). */
124type DayOfWeek = {
125 dayOfWeek: number[];
126};
127/** Returns true if `matcher` is of type {@link DateInterval}. */
128declare function isDateInterval(matcher: unknown): matcher is DateInterval;
129/** Returns true if `value` is a {@link DateRange} type. */
130declare function isDateRange(value: unknown): value is DateRange;
131/** Returns true if `value` is of type {@link DateAfter}. */
132declare function isDateAfterType(value: unknown): value is DateAfter;
133/** Returns true if `value` is of type {@link DateBefore}. */
134declare function isDateBeforeType(value: unknown): value is DateBefore;
135/** Returns true if `value` is a {@link DayOfWeek} type. */
136declare function isDayOfWeekType(value: unknown): value is DayOfWeek;
137
138/** A _modifier_ represents different styles or states of a day displayed in the calendar. */
139type Modifier = string;
140/** The modifiers used by DayPicker. */
141type Modifiers = CustomModifiers & InternalModifiers;
142/** The name of the modifiers that are used internally by DayPicker. */
143declare enum InternalModifier {
144 Outside = "outside",
145 /** Name of the modifier applied to the disabled days, using the `disabled` prop. */
146 Disabled = "disabled",
147 /** Name of the modifier applied to the selected days using the `selected` prop). */
148 Selected = "selected",
149 /** Name of the modifier applied to the hidden days using the `hidden` prop). */
150 Hidden = "hidden",
151 /** Name of the modifier applied to the day specified using the `today` prop). */
152 Today = "today",
153 /** The modifier applied to the day starting a selected range, when in range selection mode. */
154 RangeStart = "range_start",
155 /** The modifier applied to the day ending a selected range, when in range selection mode. */
156 RangeEnd = "range_end",
157 /** The modifier applied to the days between the start and the end of a selected range, when in range selection mode. */
158 RangeMiddle = "range_middle"
159}
160/** Map of matchers used for the internal modifiers. */
161type InternalModifiers = Record<InternalModifier, Matcher[]>;
162/**
163 * The modifiers that are matching a day in the calendar. Use the {@link useActiveModifiers} hook to get the modifiers for a day.
164 *
165 * ```
166 * const activeModifiers: ActiveModifiers = {
167 * selected: true,
168 * customModifier: true
169 * }
170 * ```
171 *
172 * */
173type ActiveModifiers = Record<Modifier, true> & Partial<Record<InternalModifier, true>>;
174/** The style to apply to each day element matching a modifier. */
175type ModifiersStyles = Record<Modifier, CSSProperties> & Partial<Record<InternalModifier, CSSProperties>>;
176/** The classnames to assign to each day element matching a modifier. */
177type ModifiersClassNames = Record<Modifier, string> & Partial<Record<InternalModifier, string>>;
178/** The custom modifiers passed to the {@link DayPickerBase.modifiers}. */
179type DayModifiers = Record<Modifier, Matcher | Matcher[]>;
180/**
181 * A map of matchers used as custom modifiers by DayPicker component. This is
182 * the same as {@link DayModifiers]], but it accepts only array of [[Matcher}s.
183 */
184type CustomModifiers = Record<Modifier, Matcher[]>;
185
186/** Represent the props for the {@link DayContent} component. */
187interface DayContentProps {
188 /** The date representing the day. */
189 date: Date;
190 /** The month where the day is displayed. */
191 displayMonth: Date;
192 /** The active modifiers for the given date. */
193 activeModifiers: ActiveModifiers;
194}
195/** Render the content of the day cell. */
196declare function DayContent(props: DayContentProps): JSX.Element;
197
198/** The props for the {@link Dropdown} component. */
199interface DropdownProps {
200 /** The name attribute of the element. */
201 name?: string;
202 /** The caption displayed to replace the hidden select. */
203 caption?: ReactNode;
204 children?: SelectHTMLAttributes<HTMLSelectElement>['children'];
205 className?: string;
206 ['aria-label']?: string;
207 style?: CSSProperties;
208 /** The selected value. */
209 value?: string | number;
210 onChange?: ChangeEventHandler<HTMLSelectElement>;
211}
212/**
213 * Render a styled select componentdisplaying a caption and a custom
214 * drop-down icon.
215 */
216declare function Dropdown(props: DropdownProps): JSX.Element;
217
218interface FooterProps {
219 /** The month where the footer is displayed. */
220 displayMonth?: Date;
221}
222/** Render the Footer component (empty as default).*/
223declare function Footer(props: FooterProps): JSX.Element;
224
225/** The props for the {@link Months} component. */
226type MonthsProps = {
227 children: ReactNode;
228};
229/**
230 * Render the wrapper for the month grids.
231 */
232declare function Months(props: MonthsProps): JSX.Element;
233
234/**
235 * The props for the {@link Row} component.
236 */
237interface RowProps {
238 /** The month where the row is displayed. */
239 displayMonth: Date;
240 /** The number of the week to render. */
241 weekNumber: number;
242 /** The days contained in the week. */
243 dates: Date[];
244}
245/** Render a row in the calendar, with the days and the week number. */
246declare function Row(props: RowProps): JSX.Element;
247
248/**
249 * The props for the {@link WeekNumber} component.
250 */
251interface WeekNumberProps {
252 /** The number of the week. */
253 number: number;
254 /** The dates in the week. */
255 dates: Date[];
256}
257/**
258 * Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it
259 * renders a button, otherwise a span element.
260 */
261declare function WeekNumber(props: WeekNumberProps): JSX.Element;
262
263/** The event handler when a day is clicked. */
264type DayClickEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: MouseEvent) => void;
265/** The event handler when a day is focused. */
266type DayFocusEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: FocusEvent | KeyboardEvent) => void;
267/** The event handler when a day gets a keyboard event. */
268type DayKeyboardEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: KeyboardEvent) => void;
269/** The event handler when a day gets a mouse event. */
270type DayMouseEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: MouseEvent) => void;
271/** The event handler when a day gets a pointer event. */
272type DayPointerEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: PointerEvent) => void;
273/** The event handler when a month is changed in the calendar. */
274type MonthChangeEventHandler = (month: Date) => void;
275/** The event handler when selecting multiple days. */
276type SelectMultipleEventHandler = (
277/** The selected days */
278days: Date[] | undefined,
279/** The day that was clicked triggering the event. */
280selectedDay: Date,
281/** The day that was clicked */
282activeModifiers: ActiveModifiers,
283/** The mouse event that triggered this event. */
284e: MouseEvent) => void;
285/** The event handler when selecting a range of days. */
286type SelectRangeEventHandler = (
287/** The current range of the selected days. */
288range: DateRange | undefined,
289/** The day that was selected (or clicked) triggering the event. */
290selectedDay: Date,
291/** The modifiers of the selected day. */
292activeModifiers: ActiveModifiers, e: MouseEvent) => void;
293/** The event handler when selecting a single day. */
294type SelectSingleEventHandler = (
295/** The selected day, `undefined` when `required={false}` (default) and the day is clicked again. */
296day: Date | undefined,
297/** The day that was selected (or clicked) triggering the event. */
298selectedDay: Date,
299/** The modifiers of the selected day. */
300activeModifiers: ActiveModifiers, e: MouseEvent) => void;
301/**The event handler when the week number is clicked. */
302type WeekNumberClickEventHandler = (
303/** The week number that has been clicked. */
304weekNumber: number,
305/** The dates in the clicked week. */
306dates: Date[],
307/** The mouse event that triggered this event. */
308e: MouseEvent) => void;
309/** The event handler when a day gets a touch event. */
310type DayTouchEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: TouchEvent) => void;
311
312/** Represents a function to format a date. */
313type DateFormatter = (date: Date, options?: {
314 locale?: Locale;
315}) => ReactNode;
316/** Represent a map of formatters used to render localized content. */
317type Formatters = {
318 /** Format the month in the caption when `captionLayout` is `buttons`. */
319 formatCaption: DateFormatter;
320 /** Format the month in the navigation dropdown. */
321 formatMonthCaption: DateFormatter;
322 /** Format the year in the navigation dropdown. */
323 formatYearCaption: DateFormatter;
324 /** Format the day in the day cell. */
325 formatDay: DateFormatter;
326 /** Format the week number. */
327 formatWeekNumber: WeekNumberFormatter;
328 /** Format the week day name in the header */
329 formatWeekdayName: DateFormatter;
330};
331/** Represent a function to format the week number. */
332type WeekNumberFormatter = (weekNumber: number, options?: {
333 locale?: Locale;
334}) => ReactNode;
335
336/** Map of functions to translate ARIA labels for the relative elements. */
337type Labels = {
338 labelMonthDropdown: () => string;
339 labelYearDropdown: () => string;
340 labelNext: NavButtonLabel;
341 labelPrevious: NavButtonLabel;
342 /** @deprecated This label is not used anymore and this function will be removed in the future. */
343 labelDay: DayLabel;
344 labelWeekday: WeekdayLabel;
345 labelWeekNumber: WeekNumberLabel;
346};
347/** Return the ARIA label for the {@link Day} component. */
348type DayLabel = (day: Date, activeModifiers: ActiveModifiers, options?: {
349 locale?: Locale;
350}) => string;
351/** Return the ARIA label for the "next month" / "prev month" buttons in the navigation.*/
352type NavButtonLabel = (month?: Date, options?: {
353 locale?: Locale;
354}) => string;
355/** Return the ARIA label for the Head component.*/
356type WeekdayLabel = (day: Date, options?: {
357 locale?: Locale;
358}) => string;
359/** Return the ARIA label of the week number.*/
360type WeekNumberLabel = (n: number, options?: {
361 locale?: Locale;
362}) => string;
363
364/** The style (either via class names or via in-line styles) of an element. */
365type StyledElement<T = string | CSSProperties> = {
366 /** The root element. */
367 readonly root: T;
368 /** The root element when `numberOfMonths > 1`. */
369 readonly multiple_months: T;
370 /** The root element when `showWeekNumber={true}`. */
371 readonly with_weeknumber: T;
372 /** The style of an element visually hidden. */
373 readonly vhidden: T;
374 /** The style for resetting the buttons. */
375 readonly button_reset: T;
376 /** The buttons. */
377 readonly button: T;
378 /** The caption (showing the calendar heading and the navigation) */
379 readonly caption: T;
380 /** The caption when at the start of a series of months. */
381 readonly caption_start: T;
382 /** The caption when at the end of a series of months. */
383 readonly caption_end: T;
384 /** The caption when between two months (when `multipleMonths > 2`). */
385 readonly caption_between: T;
386 /** The caption label. */
387 readonly caption_label: T;
388 /** The drop-downs container. */
389 readonly caption_dropdowns: T;
390 /** The drop-down (select) element. */
391 readonly dropdown: T;
392 /** The drop-down to change the month. */
393 readonly dropdown_month: T;
394 /** The drop-down to change the year. */
395 readonly dropdown_year: T;
396 /** The drop-down icon. */
397 readonly dropdown_icon: T;
398 /** The months wrapper. */
399 readonly months: T;
400 /** The table wrapper. */
401 readonly month: T;
402 /** Table containing the monthly calendar. */
403 readonly table: T;
404 /** The table body. */
405 readonly tbody: T;
406 /** The table footer. */
407 readonly tfoot: T;
408 /** The table’s head. */
409 readonly head: T;
410 /** The row in the head. */
411 readonly head_row: T;
412 /** The head cell. */
413 readonly head_cell: T;
414 /** The navigation container. */
415 readonly nav: T;
416 /** The navigation button. */
417 readonly nav_button: T;
418 /** The "previous month" navigation button. */
419 readonly nav_button_previous: T;
420 /** The "next month" navigation button. */
421 readonly nav_button_next: T;
422 /** The icon for the navigation button. */
423 readonly nav_icon: T;
424 /** The table’s row. */
425 readonly row: T;
426 /** The weeknumber displayed in the column. */
427 readonly weeknumber: T;
428 /** The table cell containing the day element. */
429 readonly cell: T;
430 /** The day element: it is a `span` when not interactive, a `button` otherwise. */
431 readonly day: T;
432 /** The day when outside the month. */
433 readonly day_outside: T;
434 /** The day when selected. */
435 readonly day_selected: T;
436 /** The day when disabled. */
437 readonly day_disabled: T;
438 /** The day when hidden. */
439 readonly day_hidden: T;
440 /** The day when at the start of a selected range. */
441 readonly day_range_start: T;
442 /** The day when at the end of a selected range. */
443 readonly day_range_end: T;
444 /** The day in the middle of a selected range: it does not include the "from" and the "to" days. */
445 readonly day_range_middle: T;
446 /** The day when today. */
447 readonly day_today: T;
448};
449/** These elements must not be in the `styles` or `classNames` records as they are styled via the `modifiersStyles` or `modifiersClassNames` pop */
450type InternalModifiersElement = 'day_outside' | 'day_selected' | 'day_disabled' | 'day_hidden' | 'day_range_start' | 'day_range_end' | 'day_range_middle' | 'day_today';
451/** The class names of each element. */
452type ClassNames = Partial<StyledElement<string>>;
453/**
454 * The inline-styles of each styled element, to use with the `styles` prop. Day
455 * modifiers, such as `today` or `hidden`, should be styled using the
456 * `modifiersStyles` prop.
457 */
458type Styles = Partial<Omit<StyledElement<CSSProperties>, InternalModifiersElement>>;
459/** Props of a component that can be styled via classNames or inline-styles. */
460type StyledComponent = {
461 className?: string;
462 style?: CSSProperties;
463 children?: ReactNode;
464};
465
466/**
467 * Selection modes supported by DayPicker.
468 *
469 * - `single`: use DayPicker to select single days.
470 * - `multiple`: allow selecting multiple days.
471 * - `range`: use DayPicker to select a range of days
472 * - `default`: disable the built-in selection behavior. Customize what is
473 * selected by using {@link DayPickerBase.onDayClick}.
474 */
475type DaySelectionMode = 'single' | 'multiple' | 'range' | 'default';
476/**
477 * The base props for the {@link DayPicker} component and the {@link DayPickerContext}.
478 */
479interface DayPickerBase {
480 /**
481 * The CSS class to add to the container element. To change the name of the
482 * class instead, use `classNames.root`.
483 */
484 className?: string;
485 /**
486 * Change the class names of the HTML elements.
487 *
488 * Use this prop when you need to change the default class names — for example
489 * when using CSS modules.
490 */
491 classNames?: ClassNames;
492 /**
493 * Change the class name for the day matching the {@link modifiers}.
494 */
495 modifiersClassNames?: ModifiersClassNames;
496 /**
497 * Style to apply to the container element.
498 */
499 style?: CSSProperties;
500 /**
501 * Change the inline styles of the HTML elements.
502 */
503 styles?: Styles;
504 /**
505 * Change the inline style for the day matching the {@link modifiers}.
506 */
507 modifiersStyles?: ModifiersStyles;
508 /**
509 * A unique id to replace the random generated id – used by DayPicker for
510 * accessibility.
511 */
512 id?: string;
513 /**
514 * The initial month to show in the calendar. Use this prop to let DayPicker
515 * control the current month. If you need to set the month programmatically,
516 * use {@link month]] and [[onMonthChange}.
517 *
518 * @defaultValue The current month
519 */
520 defaultMonth?: Date;
521 /**
522 * The month displayed in the calendar.
523 *
524 * As opposed to {@link DayPickerBase.defaultMonth}, use this prop with
525 * {@link DayPickerBase.onMonthChange} to change the month programmatically.
526 */
527 month?: Date;
528 /**
529 * Event fired when the user navigates between months.
530 */
531 onMonthChange?: MonthChangeEventHandler;
532 /**
533 * The number of displayed months.
534 *
535 * @defaultValue 1
536 */
537 numberOfMonths?: number;
538 /**
539 * The earliest day to start the month navigation.
540 */
541 fromDate?: Date;
542 /**
543 * The latest day to end the month navigation.
544 */
545 toDate?: Date;
546 /**
547 * The earliest month to start the month navigation.
548 */
549 fromMonth?: Date;
550 /**
551 * The latest month to end the month navigation.
552 */
553 toMonth?: Date;
554 /**
555 * The earliest year to start the month navigation.
556 */
557 fromYear?: number;
558 /**
559 * The latest year to end the month navigation.
560 */
561 toYear?: number;
562 /**
563 * Disable the navigation between months.
564 *
565 * @defaultValue false
566 */
567 disableNavigation?: boolean;
568 /**
569 * Paginate the month navigation displaying the {@link numberOfMonths} at
570 * time.
571 *
572 * @defaultValue false
573 */
574 pagedNavigation?: boolean;
575 /**
576 * Render the months in reversed order (when {@link numberOfMonths} is greater
577 * than `1`) to display the most recent month first.
578 *
579 * @defaultValue false
580 */
581 reverseMonths?: boolean;
582 /**
583 * Change the layout of the caption:
584 *
585 * - `buttons`: display prev/right buttons
586 * - `dropdown`: display drop-downs to change the month and the year
587 *
588 * **Note:** the `dropdown` layout is available only when `fromDate`,
589 * `fromMonth` or`fromYear` and `toDate`, `toMonth` or `toYear` are set.
590 *
591 * @defaultValue buttons
592 */
593 captionLayout?: CaptionLayout;
594 /**
595 * Display six weeks per months, regardless the month’s number of weeks.
596 * To use this prop, {@link showOutsideDays} must be set.
597 *
598 * @defaultValue false
599 */
600 fixedWeeks?: boolean;
601 /**
602 * Hide the month’s head displaying the weekday names.
603 *
604 * @defaultValue false
605 */
606 hideHead?: boolean;
607 /**
608 * Show the outside days. An outside day is a day falling in the next or the
609 * previous month.
610 *
611 * @defaultValue false
612 */
613 showOutsideDays?: boolean;
614 /**
615 * Show the week numbers column. Weeks are numbered according to the local
616 * week index.
617 *
618 * - to use ISO week numbering, use the {@link ISOWeek} prop.
619 * - to change how the week numbers are displayed, use the {@link Formatters} prop.
620 *
621 * @see {@link ISOWeek}, {@link weekStartsOn} and {@link firstWeekContainsDate}.
622 *
623 * @defaultValue false
624 */
625 showWeekNumber?: boolean;
626 /**
627 * The index of the first day of the week (0 - Sunday). Overrides the locale's one.
628 *
629 * @see {@link ISOWeek}.
630 */
631 weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
632 /**
633 * The day of January, which is always in the first week of the year. Can be
634 * either Monday (`1`) or Thursday (`4`).
635 *
636 * @see https://date-fns.org/docs/getWeek
637 * @see https://en.wikipedia.org/wiki/Week#Numbering
638 * @see {@link ISOWeek}.
639 */
640 firstWeekContainsDate?: 1 | 4;
641 /**
642 * Use ISO week dates instead of the locale setting. Setting this prop will
643 * ignore {@link weekStartsOn} and {@link firstWeekContainsDate}.
644 *
645 * @see https://en.wikipedia.org/wiki/ISO_week_date
646 */
647 ISOWeek?: boolean;
648 /**
649 * Map of components used to create the layout. Look at the [components
650 * source](https://github.com/gpbl/react-day-picker/tree/main/src/components)
651 * to understand how internal components are built and provide your custom components.
652 */
653 components?: CustomComponents;
654 /**
655 * Content to add to the table footer element.
656 */
657 footer?: ReactNode;
658 /**
659 * When a selection mode is set, DayPicker will focus the first selected day
660 * (if set) or the today's date (if not disabled).
661 *
662 * Use this prop when you need to focus DayPicker after a user actions, for
663 * improved accessibility.
664 */
665 initialFocus?: boolean;
666 /**
667 * Apply the `disabled` modifier to the matching days.
668 */
669 disabled?: Matcher | Matcher[] | undefined;
670 /**
671 * Apply the `hidden` modifier to the matching days. Will hide them from the
672 * calendar.
673 */
674 hidden?: Matcher | Matcher[] | undefined;
675 /**
676 * Apply the `selected` modifier to the matching days.
677 */
678 selected?: Matcher | Matcher[] | undefined;
679 /**
680 * The today’s date. Default is the current date. This Date will get the
681 * `today` modifier to style the day.
682 */
683 today?: Date;
684 /**
685 * Add modifiers to the matching days.
686 */
687 modifiers?: DayModifiers;
688 /**
689 * The date-fns locale object used to localize dates.
690 *
691 * @defaultValue en-US
692 */
693 locale?: Locale;
694 /**
695 * Labels creators to override the defaults. Use this prop to customize the
696 * ARIA labels attributes.
697 */
698 labels?: Partial<Labels>;
699 /**
700 * A map of formatters. Use the formatters to override the default formatting
701 * functions.
702 */
703 formatters?: Partial<Formatters>;
704 /**
705 * The text direction of the calendar. Use `ltr` for left-to-right (default)
706 * or `rtl` for right-to-left.
707 */
708 dir?: HTMLDivElement['dir'];
709 /**
710 * A cryptographic nonce ("number used once") which can be used by Content
711 * Security Policy for the inline `style` attributes.
712 **/
713 nonce?: HTMLDivElement['nonce'];
714 /**
715 * Add a `title` attribute to the container element.
716 **/
717 title?: HTMLDivElement['title'];
718 /**
719 * Add the language tag to the container element.
720 **/
721 lang?: HTMLDivElement['lang'];
722 /**
723 * Event callback fired when the next month button is clicked.
724 */
725 onNextClick?: MonthChangeEventHandler;
726 /**
727 * Event callback fired when the previous month button is clicked.
728 */
729 onPrevClick?: MonthChangeEventHandler;
730 /**
731 * Event callback fired when the week number is clicked. Requires
732 * `showWeekNumbers` set.
733 */
734 onWeekNumberClick?: WeekNumberClickEventHandler;
735 /**
736 * Event callback fired when the user clicks on a day.
737 */
738 onDayClick?: DayClickEventHandler;
739 /**
740 * Event callback fired when the user focuses on a day.
741 */
742 onDayFocus?: DayFocusEventHandler;
743 /**
744 * Event callback fired when the user blurs from a day.
745 */
746 onDayBlur?: DayFocusEventHandler;
747 /**
748 * Event callback fired when the user hovers on a day.
749 */
750 onDayMouseEnter?: DayMouseEventHandler;
751 /**
752 * Event callback fired when the user hovers away from a day.
753 */
754 onDayMouseLeave?: DayMouseEventHandler;
755 /**
756 * Event callback fired when the user presses a key on a day.
757 */
758 onDayKeyDown?: DayKeyboardEventHandler;
759 /**
760 * Event callback fired when the user presses a key on a day.
761 */
762 onDayKeyUp?: DayKeyboardEventHandler;
763 /**
764 * Event callback fired when the user presses a key on a day.
765 */
766 onDayKeyPress?: DayKeyboardEventHandler;
767 /**
768 * Event callback fired when the pointer enters a day.
769 */
770 onDayPointerEnter?: DayPointerEventHandler;
771 /**
772 * Event callback fired when the pointer leaves a day.
773 */
774 onDayPointerLeave?: DayPointerEventHandler;
775 /**
776 * Event callback when a day touch event is canceled.
777 */
778 onDayTouchCancel?: DayTouchEventHandler;
779 /**
780 * Event callback when a day touch event ends.
781 */
782 onDayTouchEnd?: DayTouchEventHandler;
783 /**
784 * Event callback when a day touch event moves.
785 */
786 onDayTouchMove?: DayTouchEventHandler;
787 /**
788 * Event callback when a day touch event starts.
789 */
790 onDayTouchStart?: DayTouchEventHandler;
791}
792/**
793 * Map of the components that can be changed using the `components` prop.
794 *
795 * @see https://github.com/gpbl/react-day-picker/tree/main/src/components
796 */
797interface CustomComponents {
798 /** The component for the caption element. */
799 Caption?: (props: CaptionProps) => JSX.Element | null;
800 /** The component for the caption element. */
801 CaptionLabel?: (props: CaptionLabelProps) => JSX.Element | null;
802 /**
803 * The component for the day element.
804 *
805 * Each `Day` in DayPicker should render one of the following, according to
806 * the return value of {@link useDayRender}.
807 *
808 * - an empty `Fragment`, to render if `isHidden` is true
809 * - a `button` element, when the day is interactive, e.g. is selectable
810 * - a `div` or a `span` element, when the day is not interactive
811 *
812 */
813 Day?: (props: DayProps) => JSX.Element | null;
814 /** The component for the content of the day element. */
815 DayContent?: (props: DayContentProps) => JSX.Element | null;
816 /** The component for the drop-down elements. */
817 Dropdown?: (props: DropdownProps) => JSX.Element | null;
818 /** The component for the table footer. */
819 Footer?: (props: FooterProps) => JSX.Element | null;
820 /** The component for the table’s head. */
821 Head?: () => JSX.Element | null;
822 /** The component for the table’s head row. */
823 HeadRow?: () => JSX.Element | null;
824 /** The component for the small icon in the drop-downs. */
825 IconDropdown?: (props: StyledComponent) => JSX.Element | null;
826 /** The arrow right icon (used for the Navigation buttons). */
827 IconRight?: (props: StyledComponent) => JSX.Element | null;
828 /** The arrow left icon (used for the Navigation buttons). */
829 IconLeft?: (props: StyledComponent) => JSX.Element | null;
830 /** The component wrapping the month grids. */
831 Months?: (props: MonthsProps) => JSX.Element | null;
832 /** The component for the table rows. */
833 Row?: (props: RowProps) => JSX.Element | null;
834 /** The component for the week number in the table rows. */
835 WeekNumber?: (props: WeekNumberProps) => JSX.Element | null;
836}
837
838/** The props for the {@link DayPicker} component when using `mode="default"` or `undefined`. */
839interface DayPickerDefaultProps extends DayPickerBase {
840 mode?: undefined | 'default';
841}
842/** Returns true when the props are of type {@link DayPickerDefaultProps}. */
843declare function isDayPickerDefault(props: DayPickerProps): props is DayPickerDefaultProps;
844
845/** The props for the {@link DayPicker} component when using `mode="range"`. */
846interface DayPickerRangeProps extends DayPickerBase {
847 mode: 'range';
848 /** The selected range of days. */
849 selected?: DateRange | undefined;
850 /** Event fired when a range (or a part of the range) is selected. */
851 onSelect?: SelectRangeEventHandler;
852 /** The minimum amount of days that can be selected. */
853 min?: number;
854 /** The maximum amount of days that can be selected. */
855 max?: number;
856}
857/** Returns true when the props are of type {@link DayPickerRangeProps}. */
858declare function isDayPickerRange(props: DayPickerProps | DayPickerContextValue): props is DayPickerRangeProps;
859
860/** The props for the {@link DayPicker} component when using `mode="single"`. */
861interface DayPickerSingleProps extends DayPickerBase {
862 mode: 'single';
863 /** The selected day. */
864 selected?: Date | undefined;
865 /** Event fired when a day is selected. */
866 onSelect?: SelectSingleEventHandler;
867 /** Make the selection required. */
868 required?: boolean;
869}
870/** Returns true when the props are of type {@link DayPickerSingleProps}. */
871declare function isDayPickerSingle(props: DayPickerProps | DayPickerContextValue): props is DayPickerSingleProps;
872
873/**
874 * The value of the {@link DayPickerContext} extends the props from DayPicker
875 * with default and cleaned up values.
876 */
877interface DayPickerContextValue extends DayPickerBase {
878 mode: DaySelectionMode;
879 onSelect?: DayPickerSingleProps['onSelect'] | DayPickerMultipleProps['onSelect'] | DayPickerRangeProps['onSelect'];
880 required?: boolean;
881 min?: number;
882 max?: number;
883 selected?: Matcher | Matcher[];
884 captionLayout: CaptionLayout;
885 classNames: Required<ClassNames>;
886 formatters: Formatters;
887 labels: Labels;
888 locale: Locale;
889 modifiersClassNames: ModifiersClassNames;
890 modifiers: DayModifiers;
891 numberOfMonths: number;
892 styles: Styles;
893 today: Date;
894}
895/**
896 * The DayPicker context shares the props passed to DayPicker within internal
897 * and custom components. It is used to set the default values and perform
898 * one-time calculations required to render the days.
899 *
900 * Access to this context from the {@link useDayPicker} hook.
901 */
902declare const DayPickerContext: react.Context<DayPickerContextValue | undefined>;
903/** The props for the {@link DayPickerProvider}. */
904interface DayPickerProviderProps {
905 /** The initial props from the DayPicker component. */
906 initialProps: DayPickerProps;
907 children?: ReactNode;
908}
909/**
910 * The provider for the {@link DayPickerContext}, assigning the defaults from the
911 * initial DayPicker props.
912 */
913declare function DayPickerProvider(props: DayPickerProviderProps): JSX.Element;
914/**
915 * Hook to access the {@link DayPickerContextValue}.
916 *
917 * Use the DayPicker context to access to the props passed to DayPicker inside
918 * internal or custom components.
919 */
920declare function useDayPicker(): DayPickerContextValue;
921
922/** The props for the {@link DayPicker} component when using `mode="multiple"`. */
923interface DayPickerMultipleProps extends DayPickerBase {
924 mode: 'multiple';
925 /** The selected days. */
926 selected?: Date[] | undefined;
927 /** Event fired when a days added or removed to the selection. */
928 onSelect?: SelectMultipleEventHandler;
929 /** The minimum amount of days that can be selected. */
930 min?: number;
931 /** The maximum amount of days that can be selected. */
932 max?: number;
933}
934/** Returns true when the props are of type {@link DayPickerMultipleProps}. */
935declare function isDayPickerMultiple(props: DayPickerProps | DayPickerContextValue): props is DayPickerMultipleProps;
936
937type DayPickerProps = DayPickerDefaultProps | DayPickerSingleProps | DayPickerMultipleProps | DayPickerRangeProps;
938/**
939 * DayPicker render a date picker component to let users pick dates from a
940 * calendar. See http://react-day-picker.js.org for updated documentation and
941 * examples.
942 *
943 * ### Customization
944 *
945 * DayPicker offers different customization props. For example,
946 *
947 * - show multiple months using `numberOfMonths`
948 * - display a dropdown to navigate the months via `captionLayout`
949 * - display the week numbers with `showWeekNumbers`
950 * - disable or hide days with `disabled` or `hidden`
951 *
952 * ### Controlling the months
953 *
954 * Change the initially displayed month using the `defaultMonth` prop. The
955 * displayed months are controlled by DayPicker and stored in its internal
956 * state. To control the months yourself, use `month` instead of `defaultMonth`
957 * and use the `onMonthChange` event to set it.
958 *
959 * To limit the months the user can navigate to, use
960 * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.
961 *
962 * ### Selection modes
963 *
964 * DayPicker supports different selection mode that can be toggled using the
965 * `mode` prop:
966 *
967 * - `mode="single"`: only one day can be selected. Use `required` to make the
968 * selection required. Use the `onSelect` event handler to get the selected
969 * days.
970 * - `mode="multiple"`: users can select one or more days. Limit the amount of
971 * days that can be selected with the `min` or the `max` props.
972 * - `mode="range"`: users can select a range of days. Limit the amount of days
973 * in the range with the `min` or the `max` props.
974 * - `mode="default"` (default): the built-in selections are disabled. Implement
975 * your own selection mode with `onDayClick`.
976 *
977 * The selection modes should cover the most common use cases. In case you
978 * need a more refined way of selecting days, use `mode="default"`. Use the
979 * `selected` props and add the day event handlers to add/remove days from the
980 * selection.
981 *
982 * ### Modifiers
983 *
984 * A _modifier_ represents different styles or states for the days displayed in
985 * the calendar (like "selected" or "disabled"). Define custom modifiers using
986 * the `modifiers` prop.
987 *
988 * ### Formatters and custom component
989 *
990 * You can customize how the content is displayed in the date picker by using
991 * either the formatters or replacing the internal components.
992 *
993 * For the most common cases you want to use the `formatters` prop to change how
994 * the content is formatted in the calendar. Use the `components` prop to
995 * replace the internal components, like the navigation icons.
996 *
997 * ### Styling
998 *
999 * DayPicker comes with a default, basic style in `react-day-picker/style` – use
1000 * it as template for your own style.
1001 *
1002 * If you are using CSS modules, pass the imported styles object the
1003 * `classNames` props.
1004 *
1005 * You can also style the elements via inline styles using the `styles` prop.
1006 *
1007 * ### Form fields
1008 *
1009 * If you need to bind the date picker to a form field, you can use the
1010 * `useInput` hooks for a basic behavior. See the `useInput` source as an
1011 * example to bind the date picker with form fields.
1012 *
1013 * ### Localization
1014 *
1015 * To localize DayPicker, import the locale from `date-fns` package and use the
1016 * `locale` prop.
1017 *
1018 * For example, to use Spanish locale:
1019 *
1020 * ```
1021 * import { es } from 'date-fns/locale';
1022 * <DayPicker locale={es} />
1023 * ```
1024 */
1025declare function DayPicker(props: DayPickerDefaultProps | DayPickerSingleProps | DayPickerMultipleProps | DayPickerRangeProps): JSX.Element;
1026
1027/** The props for the {@link Button} component. */
1028type ButtonProps = JSX.IntrinsicElements['button'];
1029/** Render a button HTML element applying the reset class name. */
1030declare const Button: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
1031
1032/**
1033 * Render a caption with the dropdowns to navigate between months and years.
1034 */
1035declare function CaptionDropdowns(props: CaptionProps): JSX.Element;
1036
1037/**
1038 * Render a caption with a button-based navigation.
1039 */
1040declare function CaptionNavigation(props: CaptionProps): JSX.Element;
1041
1042/** Render the table head. */
1043declare function Head(): JSX.Element;
1044
1045/**
1046 * Render the HeadRow component - i.e. the table head row with the weekday names.
1047 */
1048declare function HeadRow(): JSX.Element;
1049
1050/**
1051 * Render the icon in the styled drop-down.
1052 */
1053declare function IconDropdown(props: StyledComponent): JSX.Element;
1054
1055/**
1056 * Render the "next month" button in the navigation.
1057 */
1058declare function IconRight(props: StyledComponent): JSX.Element;
1059
1060/**
1061 * Render the "previous month" button in the navigation.
1062 */
1063declare function IconLeft(props: StyledComponent): JSX.Element;
1064
1065/** The props to attach to the input field when using {@link useInput}. */
1066type InputProps = Pick<InputHTMLAttributes<HTMLInputElement>, 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'placeholder'>;
1067/** The props to attach to the DayPicker component when using {@link useInput}. */
1068type InputDayPickerProps = Pick<DayPickerSingleProps, 'fromDate' | 'toDate' | 'locale' | 'month' | 'onDayClick' | 'onMonthChange' | 'selected' | 'today'>;
1069interface UseInputOptions extends Pick<DayPickerBase, 'locale' | 'fromDate' | 'toDate' | 'fromMonth' | 'toMonth' | 'fromYear' | 'toYear' | 'today'> {
1070 /** The initially selected date */
1071 defaultSelected?: Date;
1072 /**
1073 * The format string for formatting the input field. See
1074 * https://date-fns.org/docs/format for a list of format strings.
1075 *
1076 * @defaultValue PP
1077 */
1078 format?: string;
1079 /** Make the selection required. */
1080 required?: boolean;
1081}
1082/** Represent the value returned by {@link useInput}. */
1083interface UseInputValue {
1084 /** The props to pass to a DayPicker component. */
1085 dayPickerProps: InputDayPickerProps;
1086 /** The props to pass to an input field. */
1087 inputProps: InputProps;
1088 /** A function to reset to the initial state. */
1089 reset: () => void;
1090 /** A function to set the selected day. */
1091 setSelected: (day: Date | undefined) => void;
1092}
1093/** Return props and setters for binding an input field to DayPicker. */
1094declare function useInput(options?: UseInputOptions): UseInputValue;
1095
1096type EventName = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp' | 'onMouseEnter' | 'onMouseLeave' | 'onPointerEnter' | 'onPointerLeave' | 'onTouchCancel' | 'onTouchEnd' | 'onTouchMove' | 'onTouchStart';
1097type DayEventHandlers = Pick<HTMLProps<HTMLButtonElement>, EventName>;
1098
1099type SelectedDays = Date | Date[] | DateRange | undefined;
1100
1101type DayRender = {
1102 /** Whether the day should be rendered a `button` instead of a `div` */
1103 isButton: boolean;
1104 /** Whether the day should be hidden. */
1105 isHidden: boolean;
1106 /** The modifiers active for the given day. */
1107 activeModifiers: ActiveModifiers;
1108 /** The props to apply to the button element (when `isButton` is true). */
1109 buttonProps: StyledComponent & Pick<ButtonProps, 'disabled' | 'aria-selected' | 'tabIndex'> & DayEventHandlers;
1110 /** The props to apply to the div element (when `isButton` is false). */
1111 divProps: StyledComponent;
1112 selectedDays: SelectedDays;
1113};
1114/**
1115 * Return props and data used to render the {@link Day} component.
1116 *
1117 * Use this hook when creating a component to replace the built-in `Day`
1118 * component.
1119 */
1120declare function useDayRender(
1121/** The date to render. */
1122day: Date,
1123/** The month where the date is displayed (if not the same as `date`, it means it is an "outside" day). */
1124displayMonth: Date,
1125/** A ref to the button element that will be target of focus when rendered (if required). */
1126buttonRef: RefObject<HTMLButtonElement>): DayRender;
1127
1128/**
1129 * Return the active modifiers for the specified day.
1130 *
1131 * This hook is meant to be used inside internal or custom components.
1132 *
1133 * @param day
1134 * @param displayMonth
1135 */
1136declare function useActiveModifiers(day: Date,
1137/**
1138 * The month where the date is displayed. If not the same as `date`, the day
1139 * is an "outside day".
1140 */
1141displayMonth?: Date): ActiveModifiers;
1142
1143/** Represents the value of the {@link FocusContext}. */
1144type FocusContextValue = {
1145 /** The day currently focused. */
1146 focusedDay: Date | undefined;
1147 /** Day that will be focused. */
1148 focusTarget: Date | undefined;
1149 /** Focus a day. */
1150 focus: (day: Date) => void;
1151 /** Blur the focused day. */
1152 blur: () => void;
1153 /** Focus the day after the focused day. */
1154 focusDayAfter: () => void;
1155 /** Focus the day before the focused day. */
1156 focusDayBefore: () => void;
1157 /** Focus the day in the week before the focused day. */
1158 focusWeekBefore: () => void;
1159 /** Focus the day in the week after the focused day. */
1160 focusWeekAfter: () => void;
1161 focusMonthBefore: () => void;
1162 focusMonthAfter: () => void;
1163 focusYearBefore: () => void;
1164 focusYearAfter: () => void;
1165 focusStartOfWeek: () => void;
1166 focusEndOfWeek: () => void;
1167};
1168/**
1169 * The Focus context shares details about the focused day for the keyboard
1170 *
1171 * Access this context from the {@link useFocusContext} hook.
1172 */
1173declare const FocusContext: react.Context<FocusContextValue | undefined>;
1174type FocusProviderProps = {
1175 children: ReactNode;
1176};
1177/** The provider for the {@link FocusContext}. */
1178declare function FocusProvider(props: FocusProviderProps): JSX.Element;
1179/**
1180 * Hook to access the {@link FocusContextValue}. Use this hook to handle the
1181 * focus state of the elements.
1182 *
1183 * This hook is meant to be used inside internal or custom components.
1184 */
1185declare function useFocusContext(): FocusContextValue;
1186
1187/** Represents the value of the {@link NavigationContext}. */
1188interface NavigationContextValue {
1189 /** The month to display in the calendar. When `numberOfMonths` is greater than one, is the first of the displayed months. */
1190 currentMonth: Date;
1191 /** The months rendered by DayPicker. DayPicker can render multiple months via `numberOfMonths`. */
1192 displayMonths: Date[];
1193 /** Navigate to the specified month. */
1194 goToMonth: (month: Date) => void;
1195 /** Navigate to the specified date. */
1196 goToDate: (date: Date, refDate?: Date) => void;
1197 /** The next month to display. */
1198 nextMonth?: Date;
1199 /** The previous month to display. */
1200 previousMonth?: Date;
1201 /** Whether the given day is included in the displayed months. */
1202 isDateDisplayed: (day: Date) => boolean;
1203}
1204/**
1205 * The Navigation context shares details and methods to navigate the months in DayPicker.
1206 * Access this context from the {@link useNavigation} hook.
1207 */
1208declare const NavigationContext: react.Context<NavigationContextValue | undefined>;
1209/** Provides the values for the {@link NavigationContext}. */
1210declare function NavigationProvider(props: {
1211 children?: ReactNode;
1212}): JSX.Element;
1213/**
1214 * Hook to access the {@link NavigationContextValue}. Use this hook to navigate
1215 * between months or years in DayPicker.
1216 *
1217 * This hook is meant to be used inside internal or custom components.
1218 */
1219declare function useNavigation(): NavigationContextValue;
1220
1221/** The props of {@link RootProvider}. */
1222interface RootContext {
1223 children?: ReactNode;
1224}
1225/** Provide the value for all the context providers. */
1226declare function RootProvider(props: RootContext): JSX.Element;
1227
1228/** Represent the modifiers that are changed by the multiple selection. */
1229type SelectMultipleModifiers = Pick<Modifiers, InternalModifier.Disabled>;
1230/** Represents the value of a {@link SelectMultipleContext}. */
1231interface SelectMultipleContextValue {
1232 /** The days that have been selected. */
1233 selected: Date[] | undefined;
1234 /** The modifiers for the corresponding selection. */
1235 modifiers: SelectMultipleModifiers;
1236 /** Event handler to attach to the day button to enable the multiple select. */
1237 onDayClick?: DayClickEventHandler;
1238}
1239/**
1240 * The SelectMultiple context shares details about the selected days when in
1241 * multiple selection mode.
1242 *
1243 * Access this context from the {@link useSelectMultiple} hook.
1244 */
1245declare const SelectMultipleContext: react.Context<SelectMultipleContextValue | undefined>;
1246type SelectMultipleProviderProps = {
1247 initialProps: DayPickerBase;
1248 children?: ReactNode;
1249};
1250/** Provides the values for the {@link SelectMultipleContext}. */
1251declare function SelectMultipleProvider(props: SelectMultipleProviderProps): JSX.Element;
1252/** @private */
1253interface SelectMultipleProviderInternalProps {
1254 initialProps: DayPickerMultipleProps;
1255 children?: ReactNode;
1256}
1257declare function SelectMultipleProviderInternal({ initialProps, children }: SelectMultipleProviderInternalProps): JSX.Element;
1258/**
1259 * Hook to access the {@link SelectMultipleContextValue}.
1260 *
1261 * This hook is meant to be used inside internal or custom components.
1262 */
1263declare function useSelectMultiple(): SelectMultipleContextValue;
1264
1265/** Represent the modifiers that are changed by the range selection. */
1266type SelectRangeModifiers = Pick<Modifiers, InternalModifier.Disabled | InternalModifier.RangeEnd | InternalModifier.RangeMiddle | InternalModifier.RangeStart>;
1267/** Represents the value of a {@link SelectRangeContext}. */
1268interface SelectRangeContextValue {
1269 /** The range of days that has been selected. */
1270 selected: DateRange | undefined;
1271 /** The modifiers for the corresponding selection. */
1272 modifiers: SelectRangeModifiers;
1273 /** Event handler to attach to the day button to enable the range select. */
1274 onDayClick?: DayClickEventHandler;
1275}
1276/**
1277 * The SelectRange context shares details about the selected days when in
1278 * range selection mode.
1279 *
1280 * Access this context from the {@link useSelectRange} hook.
1281 */
1282declare const SelectRangeContext: react.Context<SelectRangeContextValue | undefined>;
1283interface SelectRangeProviderProps {
1284 initialProps: DayPickerBase;
1285 children?: ReactNode;
1286}
1287/** Provides the values for the {@link SelectRangeProvider}. */
1288declare function SelectRangeProvider(props: SelectRangeProviderProps): JSX.Element;
1289/** @private */
1290interface SelectRangeProviderInternalProps {
1291 initialProps: DayPickerRangeProps;
1292 children?: ReactNode;
1293}
1294declare function SelectRangeProviderInternal({ initialProps, children }: SelectRangeProviderInternalProps): JSX.Element;
1295/**
1296 * Hook to access the {@link SelectRangeContextValue}.
1297 *
1298 * This hook is meant to be used inside internal or custom components.
1299 */
1300declare function useSelectRange(): SelectRangeContextValue;
1301
1302/** Represents the value of a {@link SelectSingleContext}. */
1303interface SelectSingleContextValue {
1304 /** The day that has been selected. */
1305 selected: Date | undefined;
1306 /** Event handler to attach to the day button to enable the single select. */
1307 onDayClick?: DayClickEventHandler;
1308}
1309/**
1310 * The SelectSingle context shares details about the selected days when in
1311 * single selection mode.
1312 *
1313 * Access this context from the {@link useSelectSingle} hook.
1314 */
1315declare const SelectSingleContext: react.Context<SelectSingleContextValue | undefined>;
1316interface SelectSingleProviderProps {
1317 initialProps: DayPickerBase;
1318 children?: ReactNode;
1319}
1320/** Provides the values for the {@link SelectSingleProvider}. */
1321declare function SelectSingleProvider(props: SelectSingleProviderProps): JSX.Element;
1322/** @private */
1323interface SelectSingleProviderInternal {
1324 initialProps: DayPickerSingleProps;
1325 children?: ReactNode;
1326}
1327declare function SelectSingleProviderInternal({ initialProps, children }: SelectSingleProviderInternal): JSX.Element;
1328/**
1329 * Hook to access the {@link SelectSingleContextValue}.
1330 *
1331 * This hook is meant to be used inside internal or custom components.
1332 */
1333declare function useSelectSingle(): SelectSingleContextValue;
1334
1335/**
1336 * Returns whether a day matches against at least one of the given Matchers.
1337 *
1338 * ```
1339 * const day = new Date(2022, 5, 19);
1340 * const matcher1: DateRange = {
1341 * from: new Date(2021, 12, 21),
1342 * to: new Date(2021, 12, 30)
1343 * }
1344 * const matcher2: DateRange = {
1345 * from: new Date(2022, 5, 1),
1346 * to: new Date(2022, 5, 23)
1347 * }
1348 *
1349 * const isMatch(day, [matcher1, matcher2]); // true, since day is in the matcher1 range.
1350 * ```
1351 * */
1352declare function isMatch(day: Date, matchers: Matcher[]): boolean;
1353
1354/**
1355 * Add a day to an existing range.
1356 *
1357 * The returned range takes in account the `undefined` values and if the added
1358 * day is already present in the range.
1359 */
1360declare function addToRange(day: Date, range?: DateRange): DateRange | undefined;
1361
1362export { type ActiveModifiers, Button, type ButtonProps, Caption, CaptionDropdowns, CaptionLabel, type CaptionLabelProps, type CaptionLayout, CaptionNavigation, type CaptionProps, type ClassNames, type CustomComponents, type CustomModifiers, type DateAfter, type DateBefore, type DateFormatter, type DateInterval, type DateRange, Day, type DayClickEventHandler, DayContent, type DayContentProps, type DayFocusEventHandler, type DayKeyboardEventHandler, type DayLabel, type DayModifiers, type DayMouseEventHandler, type DayOfWeek, DayPicker, type DayPickerBase, DayPickerContext, type DayPickerContextValue, type DayPickerDefaultProps, type DayPickerMultipleProps, type DayPickerProps, DayPickerProvider, type DayPickerProviderProps, type DayPickerRangeProps, type DayPickerSingleProps, type DayPointerEventHandler, type DayProps, type DayRender, type DaySelectionMode, type DayTouchEventHandler, Dropdown, type DropdownProps, FocusContext, type FocusContextValue, FocusProvider, type FocusProviderProps, Footer, type FooterProps, type Formatters, Head, HeadRow, IconDropdown, IconLeft, IconRight, type InputDayPickerProps, type InputProps, InternalModifier, type InternalModifiers, type InternalModifiersElement, type Labels, type Matcher, type Modifier, type Modifiers, type ModifiersClassNames, type ModifiersStyles, type MonthChangeEventHandler, Months, type MonthsProps, type NavButtonLabel, NavigationContext, type NavigationContextValue, NavigationProvider, type RootContext, RootProvider, Row, type RowProps, SelectMultipleContext, type SelectMultipleContextValue, type SelectMultipleEventHandler, type SelectMultipleModifiers, SelectMultipleProvider, SelectMultipleProviderInternal, type SelectMultipleProviderInternalProps, type SelectMultipleProviderProps, SelectRangeContext, type SelectRangeContextValue, type SelectRangeEventHandler, type SelectRangeModifiers, SelectRangeProvider, SelectRangeProviderInternal, type SelectRangeProviderInternalProps, type SelectRangeProviderProps, SelectSingleContext, type SelectSingleContextValue, type SelectSingleEventHandler, SelectSingleProvider, SelectSingleProviderInternal, type SelectSingleProviderProps, type StyledComponent, type StyledElement, type Styles, type UseInputOptions, type UseInputValue, WeekNumber, type WeekNumberClickEventHandler, type WeekNumberFormatter, type WeekNumberLabel, type WeekNumberProps, type WeekdayLabel, addToRange, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };