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.
- package/README.md +2 -0
- package/dist/index.d.ts +46 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
- 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 +2 -2
- 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/README.md
CHANGED
|
@@ -30,6 +30,8 @@ pnpm install react-day-picker date-fns # using pnpm
|
|
|
30
30
|
yarn add react-day-picker date-fns # using yarn
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
DayPicker v8 supports React 16.8, 17, 18, and 19, with date-fns 2 or 3.
|
|
34
|
+
|
|
33
35
|
<a href="https://www.npmjs.com/package/react-day-picker"><img src="https://img.shields.io/npm/v/react-day-picker.svg?style=flat-square" alt="npm version"/></a> <img src="https://img.shields.io/npm/dm/react-day-picker.svg?style=flat-square" alt="npm downloads"/> <img src="https://img.shields.io/bundlephobia/minzip/react-day-picker" alt="Min gzipped size"/>
|
|
34
36
|
|
|
35
37
|
## Example
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { CSSProperties, ReactNode, SelectHTMLAttributes, ChangeEventHandler, MouseEvent, FocusEvent, KeyboardEvent, PointerEvent, TouchEvent, InputHTMLAttributes, HTMLProps, RefObject } from 'react';
|
|
2
|
+
import { ReactElement, CSSProperties, ReactNode, SelectHTMLAttributes, ChangeEventHandler, MouseEvent, FocusEvent, KeyboardEvent, PointerEvent, TouchEvent, ComponentPropsWithRef, InputHTMLAttributes, HTMLProps, RefObject } from 'react';
|
|
3
3
|
import { Locale } from 'date-fns';
|
|
4
4
|
|
|
5
5
|
/** Represent the props of the {@link Caption} component. */
|
|
@@ -23,7 +23,7 @@ type CaptionLayout = 'dropdown' | 'buttons' | 'dropdown-buttons';
|
|
|
23
23
|
* Render the caption of a month. The caption has a different layout when
|
|
24
24
|
* setting the {@link DayPickerBase.captionLayout} prop.
|
|
25
25
|
*/
|
|
26
|
-
declare function Caption(props: CaptionProps):
|
|
26
|
+
declare function Caption(props: CaptionProps): ReactElement;
|
|
27
27
|
|
|
28
28
|
/** The props for the {@link CaptionLabel} component. */
|
|
29
29
|
interface CaptionLabelProps {
|
|
@@ -35,7 +35,7 @@ interface CaptionLabelProps {
|
|
|
35
35
|
displayIndex?: number | undefined;
|
|
36
36
|
}
|
|
37
37
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
38
|
-
declare function CaptionLabel(props: CaptionLabelProps):
|
|
38
|
+
declare function CaptionLabel(props: CaptionLabelProps): ReactElement;
|
|
39
39
|
|
|
40
40
|
/** Represent the props used by the {@link Day} component. */
|
|
41
41
|
interface DayProps {
|
|
@@ -48,7 +48,7 @@ interface DayProps {
|
|
|
48
48
|
* The content of a day cell – as a button or span element according to its
|
|
49
49
|
* modifiers.
|
|
50
50
|
*/
|
|
51
|
-
declare function Day(props: DayProps):
|
|
51
|
+
declare function Day(props: DayProps): ReactElement;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* A value or a function that matches a specific day.
|
|
@@ -193,7 +193,7 @@ interface DayContentProps {
|
|
|
193
193
|
activeModifiers: ActiveModifiers;
|
|
194
194
|
}
|
|
195
195
|
/** Render the content of the day cell. */
|
|
196
|
-
declare function DayContent(props: DayContentProps):
|
|
196
|
+
declare function DayContent(props: DayContentProps): ReactElement;
|
|
197
197
|
|
|
198
198
|
/** The props for the {@link Dropdown} component. */
|
|
199
199
|
interface DropdownProps {
|
|
@@ -213,14 +213,14 @@ interface DropdownProps {
|
|
|
213
213
|
* Render a styled select component – displaying a caption and a custom
|
|
214
214
|
* drop-down icon.
|
|
215
215
|
*/
|
|
216
|
-
declare function Dropdown(props: DropdownProps):
|
|
216
|
+
declare function Dropdown(props: DropdownProps): ReactElement;
|
|
217
217
|
|
|
218
218
|
interface FooterProps {
|
|
219
219
|
/** The month where the footer is displayed. */
|
|
220
220
|
displayMonth?: Date;
|
|
221
221
|
}
|
|
222
222
|
/** Render the Footer component (empty as default).*/
|
|
223
|
-
declare function Footer(props: FooterProps):
|
|
223
|
+
declare function Footer(props: FooterProps): ReactElement;
|
|
224
224
|
|
|
225
225
|
/** The props for the {@link Months} component. */
|
|
226
226
|
type MonthsProps = {
|
|
@@ -229,7 +229,7 @@ type MonthsProps = {
|
|
|
229
229
|
/**
|
|
230
230
|
* Render the wrapper for the month grids.
|
|
231
231
|
*/
|
|
232
|
-
declare function Months(props: MonthsProps):
|
|
232
|
+
declare function Months(props: MonthsProps): ReactElement;
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* The props for the {@link Row} component.
|
|
@@ -243,7 +243,7 @@ interface RowProps {
|
|
|
243
243
|
dates: Date[];
|
|
244
244
|
}
|
|
245
245
|
/** Render a row in the calendar, with the days and the week number. */
|
|
246
|
-
declare function Row(props: RowProps):
|
|
246
|
+
declare function Row(props: RowProps): ReactElement;
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
249
|
* The props for the {@link WeekNumber} component.
|
|
@@ -258,7 +258,7 @@ interface WeekNumberProps {
|
|
|
258
258
|
* Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it
|
|
259
259
|
* renders a button, otherwise a span element.
|
|
260
260
|
*/
|
|
261
|
-
declare function WeekNumber(props: WeekNumberProps):
|
|
261
|
+
declare function WeekNumber(props: WeekNumberProps): ReactElement;
|
|
262
262
|
|
|
263
263
|
/** The event handler when a day is clicked. */
|
|
264
264
|
type DayClickEventHandler = (day: Date, activeModifiers: ActiveModifiers, e: MouseEvent) => void;
|
|
@@ -796,9 +796,9 @@ interface DayPickerBase {
|
|
|
796
796
|
*/
|
|
797
797
|
interface CustomComponents {
|
|
798
798
|
/** The component for the caption element. */
|
|
799
|
-
Caption?: (props: CaptionProps) =>
|
|
799
|
+
Caption?: (props: CaptionProps) => ReactElement | null;
|
|
800
800
|
/** The component for the caption element. */
|
|
801
|
-
CaptionLabel?: (props: CaptionLabelProps) =>
|
|
801
|
+
CaptionLabel?: (props: CaptionLabelProps) => ReactElement | null;
|
|
802
802
|
/**
|
|
803
803
|
* The component for the day element.
|
|
804
804
|
*
|
|
@@ -810,29 +810,29 @@ interface CustomComponents {
|
|
|
810
810
|
* - a `div` or a `span` element, when the day is not interactive
|
|
811
811
|
*
|
|
812
812
|
*/
|
|
813
|
-
Day?: (props: DayProps) =>
|
|
813
|
+
Day?: (props: DayProps) => ReactElement | null;
|
|
814
814
|
/** The component for the content of the day element. */
|
|
815
|
-
DayContent?: (props: DayContentProps) =>
|
|
815
|
+
DayContent?: (props: DayContentProps) => ReactElement | null;
|
|
816
816
|
/** The component for the drop-down elements. */
|
|
817
|
-
Dropdown?: (props: DropdownProps) =>
|
|
817
|
+
Dropdown?: (props: DropdownProps) => ReactElement | null;
|
|
818
818
|
/** The component for the table footer. */
|
|
819
|
-
Footer?: (props: FooterProps) =>
|
|
819
|
+
Footer?: (props: FooterProps) => ReactElement | null;
|
|
820
820
|
/** The component for the table’s head. */
|
|
821
|
-
Head?: () =>
|
|
821
|
+
Head?: () => ReactElement | null;
|
|
822
822
|
/** The component for the table’s head row. */
|
|
823
|
-
HeadRow?: () =>
|
|
823
|
+
HeadRow?: () => ReactElement | null;
|
|
824
824
|
/** The component for the small icon in the drop-downs. */
|
|
825
|
-
IconDropdown?: (props: StyledComponent) =>
|
|
825
|
+
IconDropdown?: (props: StyledComponent) => ReactElement | null;
|
|
826
826
|
/** The arrow right icon (used for the Navigation buttons). */
|
|
827
|
-
IconRight?: (props: StyledComponent) =>
|
|
827
|
+
IconRight?: (props: StyledComponent) => ReactElement | null;
|
|
828
828
|
/** The arrow left icon (used for the Navigation buttons). */
|
|
829
|
-
IconLeft?: (props: StyledComponent) =>
|
|
829
|
+
IconLeft?: (props: StyledComponent) => ReactElement | null;
|
|
830
830
|
/** The component wrapping the month grids. */
|
|
831
|
-
Months?: (props: MonthsProps) =>
|
|
831
|
+
Months?: (props: MonthsProps) => ReactElement | null;
|
|
832
832
|
/** The component for the table rows. */
|
|
833
|
-
Row?: (props: RowProps) =>
|
|
833
|
+
Row?: (props: RowProps) => ReactElement | null;
|
|
834
834
|
/** The component for the week number in the table rows. */
|
|
835
|
-
WeekNumber?: (props: WeekNumberProps) =>
|
|
835
|
+
WeekNumber?: (props: WeekNumberProps) => ReactElement | null;
|
|
836
836
|
}
|
|
837
837
|
|
|
838
838
|
/** The props for the {@link DayPicker} component when using `mode="default"` or `undefined`. */
|
|
@@ -910,7 +910,7 @@ interface DayPickerProviderProps {
|
|
|
910
910
|
* The provider for the {@link DayPickerContext}, assigning the defaults from the
|
|
911
911
|
* initial DayPicker props.
|
|
912
912
|
*/
|
|
913
|
-
declare function DayPickerProvider(props: DayPickerProviderProps):
|
|
913
|
+
declare function DayPickerProvider(props: DayPickerProviderProps): ReactElement;
|
|
914
914
|
/**
|
|
915
915
|
* Hook to access the {@link DayPickerContextValue}.
|
|
916
916
|
*
|
|
@@ -1022,45 +1022,47 @@ type DayPickerProps = DayPickerDefaultProps | DayPickerSingleProps | DayPickerMu
|
|
|
1022
1022
|
* <DayPicker locale={es} />
|
|
1023
1023
|
* ```
|
|
1024
1024
|
*/
|
|
1025
|
-
declare function DayPicker(props: DayPickerDefaultProps | DayPickerSingleProps | DayPickerMultipleProps | DayPickerRangeProps):
|
|
1025
|
+
declare function DayPicker(props: DayPickerDefaultProps | DayPickerSingleProps | DayPickerMultipleProps | DayPickerRangeProps): ReactElement;
|
|
1026
1026
|
|
|
1027
1027
|
/** The props for the {@link Button} component. */
|
|
1028
|
-
type ButtonProps =
|
|
1028
|
+
type ButtonProps = ComponentPropsWithRef<'button'>;
|
|
1029
1029
|
/** Render a button HTML element applying the reset class name. */
|
|
1030
|
-
declare const Button: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> &
|
|
1030
|
+
declare const Button: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
1031
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | react.RefObject<HTMLButtonElement> | null | undefined;
|
|
1032
|
+
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
1031
1033
|
|
|
1032
1034
|
/**
|
|
1033
1035
|
* Render a caption with the dropdowns to navigate between months and years.
|
|
1034
1036
|
*/
|
|
1035
|
-
declare function CaptionDropdowns(props: CaptionProps):
|
|
1037
|
+
declare function CaptionDropdowns(props: CaptionProps): ReactElement;
|
|
1036
1038
|
|
|
1037
1039
|
/**
|
|
1038
1040
|
* Render a caption with a button-based navigation.
|
|
1039
1041
|
*/
|
|
1040
|
-
declare function CaptionNavigation(props: CaptionProps):
|
|
1042
|
+
declare function CaptionNavigation(props: CaptionProps): ReactElement;
|
|
1041
1043
|
|
|
1042
1044
|
/** Render the table head. */
|
|
1043
|
-
declare function Head():
|
|
1045
|
+
declare function Head(): ReactElement;
|
|
1044
1046
|
|
|
1045
1047
|
/**
|
|
1046
1048
|
* Render the HeadRow component - i.e. the table head row with the weekday names.
|
|
1047
1049
|
*/
|
|
1048
|
-
declare function HeadRow():
|
|
1050
|
+
declare function HeadRow(): ReactElement;
|
|
1049
1051
|
|
|
1050
1052
|
/**
|
|
1051
1053
|
* Render the icon in the styled drop-down.
|
|
1052
1054
|
*/
|
|
1053
|
-
declare function IconDropdown(props: StyledComponent):
|
|
1055
|
+
declare function IconDropdown(props: StyledComponent): ReactElement;
|
|
1054
1056
|
|
|
1055
1057
|
/**
|
|
1056
1058
|
* Render the "next month" button in the navigation.
|
|
1057
1059
|
*/
|
|
1058
|
-
declare function IconRight(props: StyledComponent):
|
|
1060
|
+
declare function IconRight(props: StyledComponent): ReactElement;
|
|
1059
1061
|
|
|
1060
1062
|
/**
|
|
1061
1063
|
* Render the "previous month" button in the navigation.
|
|
1062
1064
|
*/
|
|
1063
|
-
declare function IconLeft(props: StyledComponent):
|
|
1065
|
+
declare function IconLeft(props: StyledComponent): ReactElement;
|
|
1064
1066
|
|
|
1065
1067
|
/** The props to attach to the input field when using {@link useInput}. */
|
|
1066
1068
|
type InputProps = Pick<InputHTMLAttributes<HTMLInputElement>, 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'placeholder'>;
|
|
@@ -1175,7 +1177,7 @@ type FocusProviderProps = {
|
|
|
1175
1177
|
children: ReactNode;
|
|
1176
1178
|
};
|
|
1177
1179
|
/** The provider for the {@link FocusContext}. */
|
|
1178
|
-
declare function FocusProvider(props: FocusProviderProps):
|
|
1180
|
+
declare function FocusProvider(props: FocusProviderProps): ReactElement;
|
|
1179
1181
|
/**
|
|
1180
1182
|
* Hook to access the {@link FocusContextValue}. Use this hook to handle the
|
|
1181
1183
|
* focus state of the elements.
|
|
@@ -1209,7 +1211,7 @@ declare const NavigationContext: react.Context<NavigationContextValue | undefine
|
|
|
1209
1211
|
/** Provides the values for the {@link NavigationContext}. */
|
|
1210
1212
|
declare function NavigationProvider(props: {
|
|
1211
1213
|
children?: ReactNode;
|
|
1212
|
-
}):
|
|
1214
|
+
}): ReactElement;
|
|
1213
1215
|
/**
|
|
1214
1216
|
* Hook to access the {@link NavigationContextValue}. Use this hook to navigate
|
|
1215
1217
|
* between months or years in DayPicker.
|
|
@@ -1224,7 +1226,7 @@ type RootContext = RootContextProps & {
|
|
|
1224
1226
|
children?: ReactNode;
|
|
1225
1227
|
};
|
|
1226
1228
|
/** Provide the value for all the context providers. */
|
|
1227
|
-
declare function RootProvider(props: RootContext):
|
|
1229
|
+
declare function RootProvider(props: RootContext): ReactElement;
|
|
1228
1230
|
|
|
1229
1231
|
/** Represent the modifiers that are changed by the multiple selection. */
|
|
1230
1232
|
type SelectMultipleModifiers = Pick<Modifiers, InternalModifier.Disabled>;
|
|
@@ -1249,13 +1251,13 @@ type SelectMultipleProviderProps = {
|
|
|
1249
1251
|
children?: ReactNode;
|
|
1250
1252
|
};
|
|
1251
1253
|
/** Provides the values for the {@link SelectMultipleContext}. */
|
|
1252
|
-
declare function SelectMultipleProvider(props: SelectMultipleProviderProps):
|
|
1254
|
+
declare function SelectMultipleProvider(props: SelectMultipleProviderProps): ReactElement;
|
|
1253
1255
|
/** @private */
|
|
1254
1256
|
interface SelectMultipleProviderInternalProps {
|
|
1255
1257
|
initialProps: DayPickerMultipleProps;
|
|
1256
1258
|
children?: ReactNode;
|
|
1257
1259
|
}
|
|
1258
|
-
declare function SelectMultipleProviderInternal({ initialProps, children }: SelectMultipleProviderInternalProps):
|
|
1260
|
+
declare function SelectMultipleProviderInternal({ initialProps, children }: SelectMultipleProviderInternalProps): ReactElement;
|
|
1259
1261
|
/**
|
|
1260
1262
|
* Hook to access the {@link SelectMultipleContextValue}.
|
|
1261
1263
|
*
|
|
@@ -1286,13 +1288,13 @@ interface SelectRangeProviderProps {
|
|
|
1286
1288
|
children?: ReactNode;
|
|
1287
1289
|
}
|
|
1288
1290
|
/** Provides the values for the {@link SelectRangeProvider}. */
|
|
1289
|
-
declare function SelectRangeProvider(props: SelectRangeProviderProps):
|
|
1291
|
+
declare function SelectRangeProvider(props: SelectRangeProviderProps): ReactElement;
|
|
1290
1292
|
/** @private */
|
|
1291
1293
|
interface SelectRangeProviderInternalProps {
|
|
1292
1294
|
initialProps: DayPickerRangeProps;
|
|
1293
1295
|
children?: ReactNode;
|
|
1294
1296
|
}
|
|
1295
|
-
declare function SelectRangeProviderInternal({ initialProps, children }: SelectRangeProviderInternalProps):
|
|
1297
|
+
declare function SelectRangeProviderInternal({ initialProps, children }: SelectRangeProviderInternalProps): ReactElement;
|
|
1296
1298
|
/**
|
|
1297
1299
|
* Hook to access the {@link SelectRangeContextValue}.
|
|
1298
1300
|
*
|
|
@@ -1319,13 +1321,13 @@ interface SelectSingleProviderProps {
|
|
|
1319
1321
|
children?: ReactNode;
|
|
1320
1322
|
}
|
|
1321
1323
|
/** Provides the values for the {@link SelectSingleProvider}. */
|
|
1322
|
-
declare function SelectSingleProvider(props: SelectSingleProviderProps):
|
|
1324
|
+
declare function SelectSingleProvider(props: SelectSingleProviderProps): ReactElement;
|
|
1323
1325
|
/** @private */
|
|
1324
1326
|
interface SelectSingleProviderInternal {
|
|
1325
1327
|
initialProps: DayPickerSingleProps;
|
|
1326
1328
|
children?: ReactNode;
|
|
1327
1329
|
}
|
|
1328
|
-
declare function SelectSingleProviderInternal({ initialProps, children }: SelectSingleProviderInternal):
|
|
1330
|
+
declare function SelectSingleProviderInternal({ initialProps, children }: SelectSingleProviderInternal): ReactElement;
|
|
1329
1331
|
/**
|
|
1330
1332
|
* Hook to access the {@link SelectSingleContextValue}.
|
|
1331
1333
|
*
|