react-day-picker 8.10.1 → 8.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +46 -44
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/package.json +3 -3
  7. package/src/DayPicker.tsx +3 -1
  8. package/src/components/Button/Button.tsx +2 -1
  9. package/src/components/Caption/Caption.tsx +4 -2
  10. package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +3 -1
  11. package/src/components/CaptionLabel/CaptionLabel.tsx +3 -1
  12. package/src/components/CaptionNavigation/CaptionNavigation.tsx +2 -2
  13. package/src/components/Day/Day.tsx +2 -1
  14. package/src/components/DayContent/DayContent.tsx +3 -1
  15. package/src/components/Dropdown/Dropdown.tsx +3 -2
  16. package/src/components/Footer/Footer.tsx +3 -1
  17. package/src/components/Head/Head.tsx +3 -1
  18. package/src/components/HeadRow/HeadRow.tsx +3 -1
  19. package/src/components/IconDropdown/IconDropdown.tsx +3 -1
  20. package/src/components/IconLeft/IconLeft.tsx +3 -1
  21. package/src/components/IconRight/IconRight.tsx +3 -1
  22. package/src/components/Months/Months.tsx +2 -2
  23. package/src/components/MonthsDropdown/MonthsDropdown.tsx +2 -2
  24. package/src/components/Navigation/Navigation.tsx +2 -2
  25. package/src/components/Root/Root.tsx +2 -1
  26. package/src/components/Row/Row.tsx +3 -1
  27. package/src/components/Table/Table.tsx +3 -1
  28. package/src/components/WeekNumber/WeekNumber.tsx +2 -2
  29. package/src/components/YearsDropdown/YearsDropdown.tsx +2 -2
  30. package/src/contexts/DayPicker/DayPickerContext.tsx +3 -2
  31. package/src/contexts/Focus/FocusContext.tsx +3 -2
  32. package/src/contexts/Modifiers/ModifiersContext.tsx +3 -2
  33. package/src/contexts/Navigation/NavigationContext.tsx +3 -2
  34. package/src/contexts/RootProvider.tsx +2 -2
  35. package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +1 -1
  36. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +4 -3
  37. package/src/contexts/SelectRange/SelectRangeContext.test.ts +1 -1
  38. package/src/contexts/SelectRange/SelectRangeContext.tsx +4 -3
  39. package/src/contexts/SelectSingle/SelectSingleContext.test.ts +1 -1
  40. package/src/contexts/SelectSingle/SelectSingleContext.tsx +4 -3
  41. package/src/hooks/useControlledValue/useControlledValue.test.ts +1 -1
  42. package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +1 -1
  43. package/src/hooks/useDayRender/useDayRender.tsx +2 -1
  44. package/src/hooks/useDayRender/utils/getDayStyle.ts +1 -1
  45. package/src/hooks/useInput/useInput.ts +3 -3
  46. package/src/types/DayPickerBase.ts +15 -15
  47. package/src/types/EventHandlers.ts +1 -1
  48. package/src/types/Formatters.ts +1 -1
  49. package/src/types/Modifiers.ts +1 -1
  50. package/src/types/Styles.ts +1 -1
@@ -1,9 +1,11 @@
1
+ import type { ReactElement } from 'react';
2
+
1
3
  import { StyledComponent } from 'types/Styles';
2
4
 
3
5
  /**
4
6
  * Render the "next month" button in the navigation.
5
7
  */
6
- export function IconRight(props: StyledComponent): JSX.Element {
8
+ export function IconRight(props: StyledComponent): ReactElement {
7
9
  return (
8
10
  <svg width="16px" height="16px" viewBox="0 0 120 120" {...props}>
9
11
  <path
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { useDayPicker } from 'contexts/DayPicker';
4
4
 
@@ -8,7 +8,7 @@ export type MonthsProps = { children: ReactNode };
8
8
  /**
9
9
  * Render the wrapper for the month grids.
10
10
  */
11
- export function Months(props: MonthsProps): JSX.Element {
11
+ export function Months(props: MonthsProps): ReactElement {
12
12
  const { classNames, styles } = useDayPicker();
13
13
 
14
14
  return (
@@ -1,4 +1,4 @@
1
- import { ChangeEventHandler } from 'react';
1
+ import type { ChangeEventHandler, ReactElement } from 'react';
2
2
 
3
3
  import { isSameYear, setMonth, startOfMonth } from 'date-fns';
4
4
 
@@ -14,7 +14,7 @@ export interface MonthsDropdownProps {
14
14
  }
15
15
 
16
16
  /** Render the dropdown to navigate between months. */
17
- export function MonthsDropdown(props: MonthsDropdownProps): JSX.Element {
17
+ export function MonthsDropdown(props: MonthsDropdownProps): ReactElement {
18
18
  const {
19
19
  fromDate,
20
20
  toDate,
@@ -1,4 +1,4 @@
1
- import { MouseEventHandler } from 'react';
1
+ import type { MouseEventHandler, ReactElement } from 'react';
2
2
 
3
3
  import { IconLeft } from 'components/IconLeft';
4
4
  import { IconRight } from 'components/IconRight';
@@ -25,7 +25,7 @@ export interface NavigationProps {
25
25
  }
26
26
 
27
27
  /** A component rendering the navigation buttons or the drop-downs. */
28
- export function Navigation(props: NavigationProps): JSX.Element {
28
+ export function Navigation(props: NavigationProps): ReactElement {
29
29
  const {
30
30
  dir,
31
31
  locale,
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
+ import type { ReactElement } from 'react';
2
3
 
3
4
  import { DayPickerProps } from 'DayPicker';
4
5
 
@@ -19,7 +20,7 @@ export interface RootProps {
19
20
  }
20
21
 
21
22
  /** Render the container with the months according to the number of months to display. */
22
- export function Root({ initialProps }: RootProps): JSX.Element {
23
+ export function Root({ initialProps }: RootProps): ReactElement {
23
24
  const dayPicker = useDayPicker();
24
25
  const focusContext = useFocusContext();
25
26
  const navigation = useNavigation();
@@ -1,3 +1,5 @@
1
+ import type { ReactElement } from 'react';
2
+
1
3
  import { getUnixTime } from 'date-fns';
2
4
 
3
5
  import { Day } from 'components/Day';
@@ -17,7 +19,7 @@ export interface RowProps {
17
19
  }
18
20
 
19
21
  /** Render a row in the calendar, with the days and the week number. */
20
- export function Row(props: RowProps): JSX.Element {
22
+ export function Row(props: RowProps): ReactElement {
21
23
  const { styles, classNames, showWeekNumber, components } = useDayPicker();
22
24
 
23
25
  const DayComponent = components?.Day ?? Day;
@@ -1,3 +1,5 @@
1
+ import type { ReactElement } from 'react';
2
+
1
3
  import { Footer } from 'components/Footer';
2
4
  import { Head } from 'components/Head';
3
5
  import { Row } from 'components/Row';
@@ -16,7 +18,7 @@ export interface TableProps {
16
18
  }
17
19
 
18
20
  /** Render the table with the calendar. */
19
- export function Table(props: TableProps): JSX.Element {
21
+ export function Table(props: TableProps): ReactElement {
20
22
  const {
21
23
  locale,
22
24
  classNames,
@@ -1,4 +1,4 @@
1
- import { MouseEventHandler } from 'react';
1
+ import type { MouseEventHandler, ReactElement } from 'react';
2
2
 
3
3
  import { useDayPicker } from 'contexts/DayPicker';
4
4
 
@@ -18,7 +18,7 @@ export interface WeekNumberProps {
18
18
  * Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it
19
19
  * renders a button, otherwise a span element.
20
20
  */
21
- export function WeekNumber(props: WeekNumberProps): JSX.Element {
21
+ export function WeekNumber(props: WeekNumberProps): ReactElement {
22
22
  const { number: weekNumber, dates } = props;
23
23
  const {
24
24
  onWeekNumberClick,
@@ -1,4 +1,4 @@
1
- import { ChangeEventHandler } from 'react';
1
+ import type { ChangeEventHandler, ReactElement } from 'react';
2
2
 
3
3
  import { setYear, startOfMonth, startOfYear } from 'date-fns';
4
4
 
@@ -20,7 +20,7 @@ export interface YearsDropdownProps {
20
20
  * Render a dropdown to change the year. Take in account the `nav.fromDate` and
21
21
  * `toDate` from context.
22
22
  */
23
- export function YearsDropdown(props: YearsDropdownProps): JSX.Element {
23
+ export function YearsDropdown(props: YearsDropdownProps): ReactElement {
24
24
  const { displayMonth } = props;
25
25
  const {
26
26
  fromDate,
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { Locale } from 'date-fns';
4
5
  import { DayPickerProps } from 'DayPicker';
@@ -68,7 +69,7 @@ export interface DayPickerProviderProps {
68
69
  * The provider for the {@link DayPickerContext}, assigning the defaults from the
69
70
  * initial DayPicker props.
70
71
  */
71
- export function DayPickerProvider(props: DayPickerProviderProps): JSX.Element {
72
+ export function DayPickerProvider(props: DayPickerProviderProps): ReactElement {
72
73
  const { initialProps } = props;
73
74
 
74
75
  const defaultContextValues = getDefaultContextValues();
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext, useState } from 'react';
1
+ import { createContext, useContext, useState } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { isSameDay } from 'date-fns';
4
5
 
@@ -57,7 +58,7 @@ export const FocusContext = createContext<FocusContextValue | undefined>(
57
58
  export type FocusProviderProps = { children: ReactNode };
58
59
 
59
60
  /** The provider for the {@link FocusContext}. */
60
- export function FocusProvider(props: FocusProviderProps): JSX.Element {
61
+ export function FocusProvider(props: FocusProviderProps): ReactElement {
61
62
  const navigation = useNavigation();
62
63
  const modifiers = useModifiers();
63
64
 
@@ -1,4 +1,5 @@
1
- import { createContext, useContext, ReactNode } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { useDayPicker } from 'contexts/DayPicker';
4
5
  import { useSelectMultiple } from 'contexts/SelectMultiple';
@@ -14,7 +15,7 @@ export const ModifiersContext = createContext<Modifiers | undefined>(undefined);
14
15
  export type ModifiersProviderProps = { children: ReactNode };
15
16
 
16
17
  /** Provide the value for the {@link ModifiersContext}. */
17
- export function ModifiersProvider(props: ModifiersProviderProps): JSX.Element {
18
+ export function ModifiersProvider(props: ModifiersProviderProps): ReactElement {
18
19
  const dayPicker = useDayPicker();
19
20
  const selectMultiple = useSelectMultiple();
20
21
  const selectRange = useSelectRange();
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { addMonths, isBefore, isSameMonth } from 'date-fns';
4
5
 
@@ -37,7 +38,7 @@ export const NavigationContext = createContext<
37
38
  /** Provides the values for the {@link NavigationContext}. */
38
39
  export function NavigationProvider(props: {
39
40
  children?: ReactNode;
40
- }): JSX.Element {
41
+ }): ReactElement {
41
42
  const dayPicker = useDayPicker();
42
43
  const [currentMonth, goToMonth] = useNavigationState();
43
44
 
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { ModifiersProvider } from 'contexts/Modifiers/ModifiersContext';
4
4
 
@@ -25,7 +25,7 @@ export type RootContext = RootContextProps & {
25
25
  };
26
26
 
27
27
  /** Provide the value for all the context providers. */
28
- export function RootProvider(props: RootContext): JSX.Element {
28
+ export function RootProvider(props: RootContext): ReactElement {
29
29
  const { children, ...initialProps } = props;
30
30
 
31
31
  return (
@@ -1,4 +1,4 @@
1
- import { MouseEvent } from 'react';
1
+ import type { MouseEvent } from 'react';
2
2
 
3
3
  import { addDays, addMonths } from 'date-fns';
4
4
  import { DayPickerProps } from 'DayPicker';
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { isSameDay } from 'date-fns';
4
5
 
@@ -44,7 +45,7 @@ export type SelectMultipleProviderProps = {
44
45
  /** Provides the values for the {@link SelectMultipleContext}. */
45
46
  export function SelectMultipleProvider(
46
47
  props: SelectMultipleProviderProps
47
- ): JSX.Element {
48
+ ): ReactElement {
48
49
  if (!isDayPickerMultiple(props.initialProps)) {
49
50
  const emptyContextValue: SelectMultipleContextValue = {
50
51
  selected: undefined,
@@ -75,7 +76,7 @@ export interface SelectMultipleProviderInternalProps {
75
76
  export function SelectMultipleProviderInternal({
76
77
  initialProps,
77
78
  children
78
- }: SelectMultipleProviderInternalProps): JSX.Element {
79
+ }: SelectMultipleProviderInternalProps): ReactElement {
79
80
  const { selected, min, max } = initialProps;
80
81
 
81
82
  const onDayClick: DayClickEventHandler = (day, activeModifiers, e) => {
@@ -1,4 +1,4 @@
1
- import { MouseEvent } from 'react';
1
+ import type { MouseEvent } from 'react';
2
2
 
3
3
  import {
4
4
  addDays,
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import {
4
5
  addDays,
@@ -52,7 +53,7 @@ export interface SelectRangeProviderProps {
52
53
  /** Provides the values for the {@link SelectRangeProvider}. */
53
54
  export function SelectRangeProvider(
54
55
  props: SelectRangeProviderProps
55
- ): JSX.Element {
56
+ ): ReactElement {
56
57
  if (!isDayPickerRange(props.initialProps)) {
57
58
  const emptyContextValue: SelectRangeContextValue = {
58
59
  selected: undefined,
@@ -86,7 +87,7 @@ export interface SelectRangeProviderInternalProps {
86
87
  export function SelectRangeProviderInternal({
87
88
  initialProps,
88
89
  children
89
- }: SelectRangeProviderInternalProps): JSX.Element {
90
+ }: SelectRangeProviderInternalProps): ReactElement {
90
91
  const { selected } = initialProps;
91
92
  const { from: selectedFrom, to: selectedTo } = selected || {};
92
93
  const min = initialProps.min;
@@ -1,4 +1,4 @@
1
- import { MouseEvent } from 'react';
1
+ import type { MouseEvent } from 'react';
2
2
 
3
3
  import { DayPickerProps } from 'DayPicker';
4
4
 
@@ -1,4 +1,5 @@
1
- import { createContext, ReactNode, useContext } from 'react';
1
+ import { createContext, useContext } from 'react';
2
+ import type { ReactElement, ReactNode } from 'react';
2
3
 
3
4
  import { DayPickerBase } from 'types/DayPickerBase';
4
5
  import { DayPickerSingleProps, isDayPickerSingle } from 'types/DayPickerSingle';
@@ -30,7 +31,7 @@ export interface SelectSingleProviderProps {
30
31
  /** Provides the values for the {@link SelectSingleProvider}. */
31
32
  export function SelectSingleProvider(
32
33
  props: SelectSingleProviderProps
33
- ): JSX.Element {
34
+ ): ReactElement {
34
35
  if (!isDayPickerSingle(props.initialProps)) {
35
36
  const emptyContextValue: SelectSingleContextValue = {
36
37
  selected: undefined
@@ -58,7 +59,7 @@ export interface SelectSingleProviderInternal {
58
59
  export function SelectSingleProviderInternal({
59
60
  initialProps,
60
61
  children
61
- }: SelectSingleProviderInternal): JSX.Element {
62
+ }: SelectSingleProviderInternal): ReactElement {
62
63
  const onDayClick: DayClickEventHandler = (day, activeModifiers, e) => {
63
64
  initialProps.onDayClick?.(day, activeModifiers, e);
64
65
 
@@ -1,4 +1,4 @@
1
- import { act } from 'react-dom/test-utils';
1
+ import { act } from '@testing-library/react';
2
2
 
3
3
  import { renderDayPickerHook } from 'test/render';
4
4
 
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  FocusEventHandler,
3
3
  HTMLProps,
4
4
  KeyboardEventHandler,
@@ -1,4 +1,5 @@
1
- import { RefObject, useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
+ import type { RefObject } from 'react';
2
3
 
3
4
  import { isSameDay } from 'date-fns';
4
5
 
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from 'react';
1
+ import type { CSSProperties } from 'react';
2
2
 
3
3
  import { DayPickerContextValue } from 'contexts/DayPicker';
4
4
  import { ActiveModifiers } from 'types/Modifiers';
@@ -1,8 +1,8 @@
1
- import {
1
+ import { useState } from 'react';
2
+ import type {
2
3
  ChangeEventHandler,
3
4
  FocusEventHandler,
4
- InputHTMLAttributes,
5
- useState
5
+ InputHTMLAttributes
6
6
  } from 'react';
7
7
 
8
8
  import { differenceInCalendarDays, format as _format, parse } from 'date-fns';
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import type { CSSProperties, ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { Locale } from 'date-fns';
4
4
 
@@ -386,9 +386,9 @@ export interface DayPickerBase {
386
386
  */
387
387
  export interface CustomComponents {
388
388
  /** The component for the caption element. */
389
- Caption?: (props: CaptionProps) => JSX.Element | null;
389
+ Caption?: (props: CaptionProps) => ReactElement | null;
390
390
  /** The component for the caption element. */
391
- CaptionLabel?: (props: CaptionLabelProps) => JSX.Element | null;
391
+ CaptionLabel?: (props: CaptionLabelProps) => ReactElement | null;
392
392
  /**
393
393
  * The component for the day element.
394
394
  *
@@ -400,27 +400,27 @@ export interface CustomComponents {
400
400
  * - a `div` or a `span` element, when the day is not interactive
401
401
  *
402
402
  */
403
- Day?: (props: DayProps) => JSX.Element | null;
403
+ Day?: (props: DayProps) => ReactElement | null;
404
404
  /** The component for the content of the day element. */
405
- DayContent?: (props: DayContentProps) => JSX.Element | null;
405
+ DayContent?: (props: DayContentProps) => ReactElement | null;
406
406
  /** The component for the drop-down elements. */
407
- Dropdown?: (props: DropdownProps) => JSX.Element | null;
407
+ Dropdown?: (props: DropdownProps) => ReactElement | null;
408
408
  /** The component for the table footer. */
409
- Footer?: (props: FooterProps) => JSX.Element | null;
409
+ Footer?: (props: FooterProps) => ReactElement | null;
410
410
  /** The component for the table’s head. */
411
- Head?: () => JSX.Element | null;
411
+ Head?: () => ReactElement | null;
412
412
  /** The component for the table’s head row. */
413
- HeadRow?: () => JSX.Element | null;
413
+ HeadRow?: () => ReactElement | null;
414
414
  /** The component for the small icon in the drop-downs. */
415
- IconDropdown?: (props: StyledComponent) => JSX.Element | null;
415
+ IconDropdown?: (props: StyledComponent) => ReactElement | null;
416
416
  /** The arrow right icon (used for the Navigation buttons). */
417
- IconRight?: (props: StyledComponent) => JSX.Element | null;
417
+ IconRight?: (props: StyledComponent) => ReactElement | null;
418
418
  /** The arrow left icon (used for the Navigation buttons). */
419
- IconLeft?: (props: StyledComponent) => JSX.Element | null;
419
+ IconLeft?: (props: StyledComponent) => ReactElement | null;
420
420
  /** The component wrapping the month grids. */
421
- Months?: (props: MonthsProps) => JSX.Element | null;
421
+ Months?: (props: MonthsProps) => ReactElement | null;
422
422
  /** The component for the table rows. */
423
- Row?: (props: RowProps) => JSX.Element | null;
423
+ Row?: (props: RowProps) => ReactElement | null;
424
424
  /** The component for the week number in the table rows. */
425
- WeekNumber?: (props: WeekNumberProps) => JSX.Element | null;
425
+ WeekNumber?: (props: WeekNumberProps) => ReactElement | null;
426
426
  }
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  FocusEvent,
3
3
  KeyboardEvent,
4
4
  MouseEvent,
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
2
 
3
3
  import { Locale } from 'date-fns';
4
4
 
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from 'react';
1
+ import type { CSSProperties } from 'react';
2
2
 
3
3
  import { Matcher } from './Matchers';
4
4
 
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import type { CSSProperties, ReactNode } from 'react';
2
2
 
3
3
  /** The style (either via class names or via in-line styles) of an element. */
4
4
  export type StyledElement<T = string | CSSProperties> = {