react-day-picker 8.10.0 → 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.
- package/README.md +3 -9
- package/dist/index.d.ts +49 -46
- package/dist/index.esm.js +56 -1409
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +84 -1437
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -10
- package/dist/index.min.js.map +1 -1
- package/package.json +4 -4
- package/src/DayPicker.tsx +3 -1
- package/src/components/Button/Button.tsx +2 -1
- package/src/components/Caption/Caption.tsx +4 -2
- package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +3 -1
- package/src/components/CaptionLabel/CaptionLabel.tsx +3 -1
- package/src/components/CaptionNavigation/CaptionNavigation.tsx +2 -2
- package/src/components/Day/Day.tsx +2 -1
- package/src/components/DayContent/DayContent.tsx +3 -1
- package/src/components/Dropdown/Dropdown.tsx +3 -2
- package/src/components/Footer/Footer.tsx +3 -1
- package/src/components/Head/Head.tsx +3 -1
- package/src/components/HeadRow/HeadRow.tsx +3 -1
- package/src/components/IconDropdown/IconDropdown.tsx +3 -1
- package/src/components/IconLeft/IconLeft.tsx +3 -1
- package/src/components/IconRight/IconRight.tsx +3 -1
- package/src/components/Months/Months.tsx +2 -2
- package/src/components/MonthsDropdown/MonthsDropdown.tsx +2 -2
- package/src/components/Navigation/Navigation.tsx +2 -2
- package/src/components/Root/Root.tsx +2 -1
- package/src/components/Row/Row.tsx +3 -1
- package/src/components/Table/Table.tsx +3 -1
- package/src/components/WeekNumber/WeekNumber.tsx +2 -2
- package/src/components/YearsDropdown/YearsDropdown.tsx +2 -2
- package/src/contexts/DayPicker/DayPickerContext.tsx +3 -2
- package/src/contexts/Focus/FocusContext.tsx +3 -2
- package/src/contexts/Modifiers/ModifiersContext.tsx +3 -2
- package/src/contexts/Navigation/NavigationContext.tsx +3 -2
- package/src/contexts/RootProvider.tsx +14 -4
- package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +1 -1
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +4 -3
- package/src/contexts/SelectRange/SelectRangeContext.test.ts +1 -1
- package/src/contexts/SelectRange/SelectRangeContext.tsx +4 -3
- package/src/contexts/SelectSingle/SelectSingleContext.test.ts +1 -1
- package/src/contexts/SelectSingle/SelectSingleContext.tsx +4 -3
- package/src/hooks/useControlledValue/useControlledValue.test.ts +1 -1
- package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +1 -1
- package/src/hooks/useDayRender/useDayRender.tsx +2 -1
- package/src/hooks/useDayRender/utils/getDayStyle.ts +1 -1
- package/src/hooks/useInput/useInput.ts +3 -3
- package/src/types/DayPickerBase.ts +15 -15
- package/src/types/EventHandlers.ts +1 -1
- package/src/types/Formatters.ts +1 -1
- package/src/types/Modifiers.ts +1 -1
- package/src/types/Styles.ts +1 -1
- package/src/hooks/useId/useIsomorphicLayoutEffect.ts +0 -31
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { CaptionDropdowns } from 'components/CaptionDropdowns';
|
|
2
4
|
import { CaptionLabel } from 'components/CaptionLabel';
|
|
3
5
|
import { CaptionNavigation } from 'components/CaptionNavigation';
|
|
@@ -26,13 +28,13 @@ export type CaptionLayout = 'dropdown' | 'buttons' | 'dropdown-buttons';
|
|
|
26
28
|
* Render the caption of a month. The caption has a different layout when
|
|
27
29
|
* setting the {@link DayPickerBase.captionLayout} prop.
|
|
28
30
|
*/
|
|
29
|
-
export function Caption(props: CaptionProps):
|
|
31
|
+
export function Caption(props: CaptionProps): ReactElement {
|
|
30
32
|
const { classNames, disableNavigation, styles, captionLayout, components } =
|
|
31
33
|
useDayPicker();
|
|
32
34
|
|
|
33
35
|
const CaptionLabelComponent = components?.CaptionLabel ?? CaptionLabel;
|
|
34
36
|
|
|
35
|
-
let caption:
|
|
37
|
+
let caption: ReactElement;
|
|
36
38
|
if (disableNavigation) {
|
|
37
39
|
caption = (
|
|
38
40
|
<CaptionLabelComponent id={props.id} displayMonth={props.displayMonth} />
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { addMonths } from 'date-fns';
|
|
2
4
|
|
|
3
5
|
import { CaptionProps } from 'components/Caption/Caption';
|
|
@@ -11,7 +13,7 @@ import { MonthChangeEventHandler } from 'types/EventHandlers';
|
|
|
11
13
|
/**
|
|
12
14
|
* Render a caption with the dropdowns to navigate between months and years.
|
|
13
15
|
*/
|
|
14
|
-
export function CaptionDropdowns(props: CaptionProps):
|
|
16
|
+
export function CaptionDropdowns(props: CaptionProps): ReactElement {
|
|
15
17
|
const { classNames, styles, components } = useDayPicker();
|
|
16
18
|
const { goToMonth } = useNavigation();
|
|
17
19
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { useDayPicker } from 'contexts/DayPicker';
|
|
2
4
|
|
|
3
5
|
/** The props for the {@link CaptionLabel} component. */
|
|
@@ -11,7 +13,7 @@ export interface CaptionLabelProps {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
14
|
-
export function CaptionLabel(props: CaptionLabelProps):
|
|
16
|
+
export function CaptionLabel(props: CaptionLabelProps): ReactElement {
|
|
15
17
|
const {
|
|
16
18
|
locale,
|
|
17
19
|
classNames,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MouseEventHandler } from 'react';
|
|
1
|
+
import type { MouseEventHandler, ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { isSameMonth } from 'date-fns';
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import { useNavigation } from 'contexts/Navigation';
|
|
|
10
10
|
/**
|
|
11
11
|
* Render a caption with a button-based navigation.
|
|
12
12
|
*/
|
|
13
|
-
export function CaptionNavigation(props: CaptionProps):
|
|
13
|
+
export function CaptionNavigation(props: CaptionProps): ReactElement {
|
|
14
14
|
const { numberOfMonths } = useDayPicker();
|
|
15
15
|
const { previousMonth, nextMonth, goToMonth, displayMonths } =
|
|
16
16
|
useNavigation();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
2
3
|
|
|
3
4
|
import { useDayRender } from 'hooks/useDayRender';
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ export interface DayProps {
|
|
|
16
17
|
* The content of a day cell – as a button or span element according to its
|
|
17
18
|
* modifiers.
|
|
18
19
|
*/
|
|
19
|
-
export function Day(props: DayProps):
|
|
20
|
+
export function Day(props: DayProps): ReactElement {
|
|
20
21
|
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
21
22
|
const dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
|
|
22
23
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { useDayPicker } from 'contexts/DayPicker';
|
|
2
4
|
import { ActiveModifiers } from 'types/Modifiers';
|
|
3
5
|
|
|
@@ -12,7 +14,7 @@ export interface DayContentProps {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/** Render the content of the day cell. */
|
|
15
|
-
export function DayContent(props: DayContentProps):
|
|
17
|
+
export function DayContent(props: DayContentProps): ReactElement {
|
|
16
18
|
const {
|
|
17
19
|
locale,
|
|
18
20
|
formatters: { formatDay }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
ChangeEventHandler,
|
|
3
3
|
CSSProperties,
|
|
4
|
+
ReactElement,
|
|
4
5
|
ReactNode,
|
|
5
6
|
SelectHTMLAttributes
|
|
6
7
|
} from 'react';
|
|
@@ -27,7 +28,7 @@ export interface DropdownProps {
|
|
|
27
28
|
* Render a styled select component – displaying a caption and a custom
|
|
28
29
|
* drop-down icon.
|
|
29
30
|
*/
|
|
30
|
-
export function Dropdown(props: DropdownProps):
|
|
31
|
+
export function Dropdown(props: DropdownProps): ReactElement {
|
|
31
32
|
const { onChange, value, children, caption, className, style } = props;
|
|
32
33
|
const dayPicker = useDayPicker();
|
|
33
34
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { useDayPicker } from 'contexts/DayPicker';
|
|
2
4
|
|
|
3
5
|
export interface FooterProps {
|
|
@@ -6,7 +8,7 @@ export interface FooterProps {
|
|
|
6
8
|
}
|
|
7
9
|
/** Render the Footer component (empty as default).*/
|
|
8
10
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
export function Footer(props: FooterProps):
|
|
11
|
+
export function Footer(props: FooterProps): ReactElement {
|
|
10
12
|
const {
|
|
11
13
|
footer,
|
|
12
14
|
styles,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { HeadRow } from 'components/HeadRow';
|
|
2
4
|
import { useDayPicker } from 'contexts/DayPicker';
|
|
3
5
|
|
|
4
6
|
/** Render the table head. */
|
|
5
|
-
export function Head():
|
|
7
|
+
export function Head(): ReactElement {
|
|
6
8
|
const { classNames, styles, components } = useDayPicker();
|
|
7
9
|
const HeadRowComponent = components?.HeadRow ?? HeadRow;
|
|
8
10
|
return (
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { useDayPicker } from 'contexts/DayPicker';
|
|
2
4
|
|
|
3
5
|
import { getWeekdays } from './utils';
|
|
@@ -5,7 +7,7 @@ import { getWeekdays } from './utils';
|
|
|
5
7
|
/**
|
|
6
8
|
* Render the HeadRow component - i.e. the table head row with the weekday names.
|
|
7
9
|
*/
|
|
8
|
-
export function HeadRow():
|
|
10
|
+
export function HeadRow(): ReactElement {
|
|
9
11
|
const {
|
|
10
12
|
classNames,
|
|
11
13
|
styles,
|
|
@@ -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 icon in the styled drop-down.
|
|
5
7
|
*/
|
|
6
|
-
export function IconDropdown(props: StyledComponent):
|
|
8
|
+
export function IconDropdown(props: StyledComponent): ReactElement {
|
|
7
9
|
return (
|
|
8
10
|
<svg
|
|
9
11
|
width="8px"
|
|
@@ -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 "previous month" button in the navigation.
|
|
5
7
|
*/
|
|
6
|
-
export function IconLeft(props: StyledComponent):
|
|
8
|
+
export function IconLeft(props: StyledComponent): ReactElement {
|
|
7
9
|
return (
|
|
8
10
|
<svg width="16px" height="16px" viewBox="0 0 120 120" {...props}>
|
|
9
11
|
<path
|
|
@@ -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):
|
|
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):
|
|
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):
|
|
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):
|
|
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):
|
|
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):
|
|
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):
|
|
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):
|
|
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):
|
|
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,
|
|
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):
|
|
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,
|
|
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):
|
|
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
|
|
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):
|
|
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,
|
|
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
|
-
}):
|
|
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
|
|
|
@@ -8,14 +8,24 @@ import { NavigationProvider } from './Navigation';
|
|
|
8
8
|
import { SelectMultipleProvider } from './SelectMultiple';
|
|
9
9
|
import { SelectRangeProvider } from './SelectRange';
|
|
10
10
|
import { SelectSingleProvider } from './SelectSingle';
|
|
11
|
+
import { DayPickerDefaultProps } from 'types/DayPickerDefault';
|
|
12
|
+
import { DayPickerSingleProps } from 'types/DayPickerSingle';
|
|
13
|
+
import { DayPickerMultipleProps } from 'types/DayPickerMultiple';
|
|
14
|
+
import { DayPickerRangeProps } from 'types/DayPickerRange';
|
|
15
|
+
|
|
16
|
+
type RootContextProps =
|
|
17
|
+
| Partial<DayPickerDefaultProps>
|
|
18
|
+
| Partial<DayPickerSingleProps>
|
|
19
|
+
| Partial<DayPickerMultipleProps>
|
|
20
|
+
| Partial<DayPickerRangeProps>;
|
|
11
21
|
|
|
12
22
|
/** The props of {@link RootProvider}. */
|
|
13
|
-
export
|
|
23
|
+
export type RootContext = RootContextProps & {
|
|
14
24
|
children?: ReactNode;
|
|
15
|
-
}
|
|
25
|
+
};
|
|
16
26
|
|
|
17
27
|
/** Provide the value for all the context providers. */
|
|
18
|
-
export function RootProvider(props: RootContext):
|
|
28
|
+
export function RootProvider(props: RootContext): ReactElement {
|
|
19
29
|
const { children, ...initialProps } = props;
|
|
20
30
|
|
|
21
31
|
return (
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createContext,
|
|
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
|
-
):
|
|
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):
|
|
79
|
+
}: SelectMultipleProviderInternalProps): ReactElement {
|
|
79
80
|
const { selected, min, max } = initialProps;
|
|
80
81
|
|
|
81
82
|
const onDayClick: DayClickEventHandler = (day, activeModifiers, e) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createContext,
|
|
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
|
-
):
|
|
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):
|
|
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,5 @@
|
|
|
1
|
-
import { createContext,
|
|
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
|
-
):
|
|
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):
|
|
62
|
+
}: SelectSingleProviderInternal): ReactElement {
|
|
62
63
|
const onDayClick: DayClickEventHandler = (day, activeModifiers, e) => {
|
|
63
64
|
initialProps.onDayClick?.(day, activeModifiers, e);
|
|
64
65
|
|
|
@@ -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) =>
|
|
389
|
+
Caption?: (props: CaptionProps) => ReactElement | null;
|
|
390
390
|
/** The component for the caption element. */
|
|
391
|
-
CaptionLabel?: (props: CaptionLabelProps) =>
|
|
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) =>
|
|
403
|
+
Day?: (props: DayProps) => ReactElement | null;
|
|
404
404
|
/** The component for the content of the day element. */
|
|
405
|
-
DayContent?: (props: DayContentProps) =>
|
|
405
|
+
DayContent?: (props: DayContentProps) => ReactElement | null;
|
|
406
406
|
/** The component for the drop-down elements. */
|
|
407
|
-
Dropdown?: (props: DropdownProps) =>
|
|
407
|
+
Dropdown?: (props: DropdownProps) => ReactElement | null;
|
|
408
408
|
/** The component for the table footer. */
|
|
409
|
-
Footer?: (props: FooterProps) =>
|
|
409
|
+
Footer?: (props: FooterProps) => ReactElement | null;
|
|
410
410
|
/** The component for the table’s head. */
|
|
411
|
-
Head?: () =>
|
|
411
|
+
Head?: () => ReactElement | null;
|
|
412
412
|
/** The component for the table’s head row. */
|
|
413
|
-
HeadRow?: () =>
|
|
413
|
+
HeadRow?: () => ReactElement | null;
|
|
414
414
|
/** The component for the small icon in the drop-downs. */
|
|
415
|
-
IconDropdown?: (props: StyledComponent) =>
|
|
415
|
+
IconDropdown?: (props: StyledComponent) => ReactElement | null;
|
|
416
416
|
/** The arrow right icon (used for the Navigation buttons). */
|
|
417
|
-
IconRight?: (props: StyledComponent) =>
|
|
417
|
+
IconRight?: (props: StyledComponent) => ReactElement | null;
|
|
418
418
|
/** The arrow left icon (used for the Navigation buttons). */
|
|
419
|
-
IconLeft?: (props: StyledComponent) =>
|
|
419
|
+
IconLeft?: (props: StyledComponent) => ReactElement | null;
|
|
420
420
|
/** The component wrapping the month grids. */
|
|
421
|
-
Months?: (props: MonthsProps) =>
|
|
421
|
+
Months?: (props: MonthsProps) => ReactElement | null;
|
|
422
422
|
/** The component for the table rows. */
|
|
423
|
-
Row?: (props: RowProps) =>
|
|
423
|
+
Row?: (props: RowProps) => ReactElement | null;
|
|
424
424
|
/** The component for the week number in the table rows. */
|
|
425
|
-
WeekNumber?: (props: WeekNumberProps) =>
|
|
425
|
+
WeekNumber?: (props: WeekNumberProps) => ReactElement | null;
|
|
426
426
|
}
|
package/src/types/Formatters.ts
CHANGED