react-day-picker 8.2.0 → 8.3.0

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 (204) hide show
  1. package/README.md +57 -19
  2. package/dist/index.d.ts +1176 -40
  3. package/dist/index.esm.d.ts +1176 -0
  4. package/dist/index.esm.js +1473 -1496
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.js +1195 -1214
  7. package/dist/index.js.map +1 -1
  8. package/dist/react-day-picker.min.js +1 -1
  9. package/dist/style.css +9 -11
  10. package/dist/style.module.css +14 -16
  11. package/dist/style.module.css.d.ts +34 -34
  12. package/package.json +2 -2
  13. package/src/components/Caption/Caption.tsx +8 -8
  14. package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +6 -4
  15. package/src/components/CaptionNavigation/CaptionNavigation.tsx +6 -8
  16. package/src/components/Dropdown/Dropdown.tsx +5 -5
  17. package/src/components/Head/Head.tsx +6 -4
  18. package/src/components/HeadRow/HeadRow.tsx +2 -1
  19. package/src/components/HeadRow/utils/getWeekdays.test.ts +10 -0
  20. package/src/components/HeadRow/utils/getWeekdays.ts +9 -3
  21. package/src/components/Month/Month.test.tsx +11 -0
  22. package/src/components/Month/Month.tsx +12 -6
  23. package/src/components/MonthsDropdown/MonthsDropdown.tsx +3 -6
  24. package/src/components/Navigation/Navigation.tsx +5 -15
  25. package/src/components/Row/Row.tsx +8 -8
  26. package/src/components/Table/Table.tsx +10 -12
  27. package/src/components/Table/utils/daysToMonthWeeks.ts +15 -3
  28. package/src/components/Table/utils/getMonthWeeks.test.ts +33 -1
  29. package/src/components/Table/utils/getMonthWeeks.ts +2 -3
  30. package/src/components/YearsDropdown/YearsDropdown.tsx +3 -6
  31. package/src/contexts/DayPicker/{useDayPicker.test.ts → DayPickerContext.test.ts} +13 -29
  32. package/src/contexts/DayPicker/DayPickerContext.tsx +41 -53
  33. package/src/contexts/DayPicker/defaultContextValues.ts +85 -0
  34. package/src/contexts/DayPicker/index.ts +0 -1
  35. package/src/contexts/Focus/{useFocusContext.test.ts → FocusContext.test.ts} +0 -0
  36. package/src/contexts/Focus/FocusContext.tsx +19 -6
  37. package/src/contexts/Focus/index.ts +0 -1
  38. package/src/contexts/Focus/utils/getInitialFocusTarget.test.tsx +37 -8
  39. package/src/contexts/Focus/utils/getInitialFocusTarget.tsx +0 -1
  40. package/src/contexts/Focus/utils/getNextFocus.test.tsx +75 -50
  41. package/src/contexts/Focus/utils/getNextFocus.tsx +54 -19
  42. package/src/contexts/Modifiers/{useModifiers.test.ts → ModifiersContext.test.ts} +0 -0
  43. package/src/contexts/Modifiers/ModifiersContext.tsx +16 -1
  44. package/src/contexts/Modifiers/index.ts +1 -1
  45. package/src/contexts/Modifiers/utils/getInternalModifiers.test.ts +3 -2
  46. package/src/contexts/Navigation/{useNavigation.test.ts → NavigationContext.test.ts} +1 -2
  47. package/src/contexts/Navigation/NavigationContext.tsx +15 -1
  48. package/src/contexts/Navigation/index.ts +0 -1
  49. package/src/contexts/SelectMultiple/{useSelectMultiple.test.ts → SelectMultipleContext.test.ts} +4 -2
  50. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +16 -1
  51. package/src/contexts/SelectMultiple/index.ts +0 -1
  52. package/src/contexts/SelectRange/{useSelectRange.test.ts → SelectRangeContext.test.ts} +4 -21
  53. package/src/contexts/SelectRange/SelectRangeContext.tsx +51 -36
  54. package/src/contexts/SelectRange/index.ts +0 -1
  55. package/src/contexts/SelectSingle/{useSelectSingle.test.ts → SelectSingleContext.test.ts} +1 -1
  56. package/src/contexts/SelectSingle/SelectSingleContext.tsx +16 -1
  57. package/src/contexts/SelectSingle/index.ts +0 -1
  58. package/src/hooks/useDayRender/useDayRender.tsx +5 -4
  59. package/src/style.css +9 -11
  60. package/src/types/DayPickerBase.ts +33 -6
  61. package/src/types/EventHandlers.ts +9 -11
  62. package/src/types/Matchers.ts +1 -1
  63. package/dist/DayPicker.d.ts +0 -93
  64. package/dist/components/Button/Button.d.ts +0 -7
  65. package/dist/components/Button/index.d.ts +0 -1
  66. package/dist/components/Caption/Caption.d.ts +0 -19
  67. package/dist/components/Caption/index.d.ts +0 -1
  68. package/dist/components/CaptionDropdowns/CaptionDropdowns.d.ts +0 -5
  69. package/dist/components/CaptionDropdowns/index.d.ts +0 -1
  70. package/dist/components/CaptionLabel/CaptionLabel.d.ts +0 -9
  71. package/dist/components/CaptionLabel/index.d.ts +0 -1
  72. package/dist/components/CaptionNavigation/CaptionNavigation.d.ts +0 -5
  73. package/dist/components/CaptionNavigation/index.d.ts +0 -1
  74. package/dist/components/Day/Day.d.ts +0 -12
  75. package/dist/components/Day/index.d.ts +0 -1
  76. package/dist/components/DayContent/DayContent.d.ts +0 -12
  77. package/dist/components/DayContent/index.d.ts +0 -1
  78. package/dist/components/Dropdown/Dropdown.d.ts +0 -20
  79. package/dist/components/Dropdown/index.d.ts +0 -1
  80. package/dist/components/Footer/Footer.d.ts +0 -2
  81. package/dist/components/Footer/index.d.ts +0 -1
  82. package/dist/components/Head/Head.d.ts +0 -2
  83. package/dist/components/Head/index.d.ts +0 -1
  84. package/dist/components/Head/utils/getWeekdays.d.ts +0 -8
  85. package/dist/components/Head/utils/index.d.ts +0 -1
  86. package/dist/components/HeadRow/HeadRow.d.ts +0 -4
  87. package/dist/components/HeadRow/index.d.ts +0 -1
  88. package/dist/components/HeadRow/utils/getWeekdays.d.ts +0 -8
  89. package/dist/components/HeadRow/utils/index.d.ts +0 -1
  90. package/dist/components/IconDropdown/IconDropdown.d.ts +0 -5
  91. package/dist/components/IconDropdown/index.d.ts +0 -1
  92. package/dist/components/IconLeft/IconLeft.d.ts +0 -5
  93. package/dist/components/IconLeft/index.d.ts +0 -1
  94. package/dist/components/IconRight/IconRight.d.ts +0 -5
  95. package/dist/components/IconRight/index.d.ts +0 -1
  96. package/dist/components/Month/Month.d.ts +0 -7
  97. package/dist/components/Month/index.d.ts +0 -1
  98. package/dist/components/MonthsDropdown/MonthsDropdown.d.ts +0 -9
  99. package/dist/components/MonthsDropdown/index.d.ts +0 -1
  100. package/dist/components/Navigation/Navigation.d.ts +0 -20
  101. package/dist/components/Navigation/index.d.ts +0 -1
  102. package/dist/components/Root/Root.d.ts +0 -2
  103. package/dist/components/Root/index.d.ts +0 -1
  104. package/dist/components/Row/Row.d.ts +0 -13
  105. package/dist/components/Row/index.d.ts +0 -1
  106. package/dist/components/Table/Table.d.ts +0 -9
  107. package/dist/components/Table/index.d.ts +0 -1
  108. package/dist/components/Table/utils/daysToMonthWeeks.d.ts +0 -8
  109. package/dist/components/Table/utils/getMonthWeeks.d.ts +0 -21
  110. package/dist/components/WeekNumber/WeekNumber.d.ts +0 -14
  111. package/dist/components/WeekNumber/index.d.ts +0 -1
  112. package/dist/components/YearsDropdown/YearsDropdown.d.ts +0 -15
  113. package/dist/components/YearsDropdown/index.d.ts +0 -1
  114. package/dist/contexts/DayPicker/DayPickerContext.d.ts +0 -50
  115. package/dist/contexts/DayPicker/defaultClassNames.d.ts +0 -5
  116. package/dist/contexts/DayPicker/defaultContextValue.d.ts +0 -6
  117. package/dist/contexts/DayPicker/formatters/formatCaption.d.ts +0 -7
  118. package/dist/contexts/DayPicker/formatters/formatDay.d.ts +0 -7
  119. package/dist/contexts/DayPicker/formatters/formatMonthCaption.d.ts +0 -7
  120. package/dist/contexts/DayPicker/formatters/formatWeekNumber.d.ts +0 -4
  121. package/dist/contexts/DayPicker/formatters/formatWeekdayName.d.ts +0 -7
  122. package/dist/contexts/DayPicker/formatters/formatYearCaption.d.ts +0 -6
  123. package/dist/contexts/DayPicker/formatters/index.d.ts +0 -6
  124. package/dist/contexts/DayPicker/index.d.ts +0 -2
  125. package/dist/contexts/DayPicker/labels/index.d.ts +0 -7
  126. package/dist/contexts/DayPicker/labels/labelDay.d.ts +0 -5
  127. package/dist/contexts/DayPicker/labels/labelMonthDropdown.d.ts +0 -4
  128. package/dist/contexts/DayPicker/labels/labelNext.d.ts +0 -5
  129. package/dist/contexts/DayPicker/labels/labelPrevious.d.ts +0 -5
  130. package/dist/contexts/DayPicker/labels/labelWeekNumber.d.ts +0 -5
  131. package/dist/contexts/DayPicker/labels/labelWeekday.d.ts +0 -5
  132. package/dist/contexts/DayPicker/labels/labelYearDropdown.d.ts +0 -4
  133. package/dist/contexts/DayPicker/useDayPicker.d.ts +0 -8
  134. package/dist/contexts/DayPicker/utils/index.d.ts +0 -1
  135. package/dist/contexts/DayPicker/utils/parseFromToProps.d.ts +0 -6
  136. package/dist/contexts/Focus/FocusContext.d.ts +0 -36
  137. package/dist/contexts/Focus/index.d.ts +0 -2
  138. package/dist/contexts/Focus/useFocusContext.d.ts +0 -8
  139. package/dist/contexts/Focus/utils/getInitialFocusTarget.d.ts +0 -3
  140. package/dist/contexts/Focus/utils/getNextFocus.d.ts +0 -9
  141. package/dist/contexts/Modifiers/ModifiersContext.d.ts +0 -9
  142. package/dist/contexts/Modifiers/index.d.ts +0 -2
  143. package/dist/contexts/Modifiers/useModifiers.d.ts +0 -9
  144. package/dist/contexts/Modifiers/utils/getActiveModifiers.d.ts +0 -7
  145. package/dist/contexts/Modifiers/utils/getCustomModifiers.d.ts +0 -3
  146. package/dist/contexts/Modifiers/utils/getInternalModifiers.d.ts +0 -6
  147. package/dist/contexts/Modifiers/utils/isDateInRange.d.ts +0 -3
  148. package/dist/contexts/Modifiers/utils/isMatch.d.ts +0 -19
  149. package/dist/contexts/Modifiers/utils/matcherToArray.d.ts +0 -3
  150. package/dist/contexts/Navigation/NavigationContext.d.ts +0 -27
  151. package/dist/contexts/Navigation/index.d.ts +0 -2
  152. package/dist/contexts/Navigation/useNavigation.d.ts +0 -8
  153. package/dist/contexts/Navigation/useNavigationState.d.ts +0 -7
  154. package/dist/contexts/Navigation/utils/getDisplayMonths.d.ts +0 -8
  155. package/dist/contexts/Navigation/utils/getInitialMonth.d.ts +0 -3
  156. package/dist/contexts/Navigation/utils/getNextMonth.d.ts +0 -18
  157. package/dist/contexts/Navigation/utils/getPreviousMonth.d.ts +0 -19
  158. package/dist/contexts/RootProvider.d.ts +0 -8
  159. package/dist/contexts/SelectMultiple/SelectMultipleContext.d.ts +0 -35
  160. package/dist/contexts/SelectMultiple/index.d.ts +0 -2
  161. package/dist/contexts/SelectMultiple/useSelectMultiple.d.ts +0 -7
  162. package/dist/contexts/SelectRange/SelectRangeContext.d.ts +0 -36
  163. package/dist/contexts/SelectRange/index.d.ts +0 -2
  164. package/dist/contexts/SelectRange/useSelectRange.d.ts +0 -7
  165. package/dist/contexts/SelectRange/utils/addToRange.d.ts +0 -8
  166. package/dist/contexts/SelectSingle/SelectSingleContext.d.ts +0 -30
  167. package/dist/contexts/SelectSingle/index.d.ts +0 -2
  168. package/dist/contexts/SelectSingle/useSelectSingle.d.ts +0 -7
  169. package/dist/hooks/useActiveModifiers/index.d.ts +0 -1
  170. package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +0 -15
  171. package/dist/hooks/useControlledValue/index.d.ts +0 -1
  172. package/dist/hooks/useControlledValue/useControlledValue.d.ts +0 -12
  173. package/dist/hooks/useDayEventHandlers/index.d.ts +0 -1
  174. package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +0 -26
  175. package/dist/hooks/useDayRender/index.d.ts +0 -1
  176. package/dist/hooks/useDayRender/useDayRender.d.ts +0 -32
  177. package/dist/hooks/useDayRender/utils/getDayClassNames.d.ts +0 -10
  178. package/dist/hooks/useDayRender/utils/getDayStyle.d.ts +0 -5
  179. package/dist/hooks/useId/index.d.ts +0 -1
  180. package/dist/hooks/useId/useId.d.ts +0 -19
  181. package/dist/hooks/useInput/index.d.ts +0 -1
  182. package/dist/hooks/useInput/useInput.d.ts +0 -28
  183. package/dist/hooks/useInput/utils/isValidDate.d.ts +0 -2
  184. package/dist/hooks/useSelectedDays/index.d.ts +0 -1
  185. package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +0 -10
  186. package/dist/types/DayPickerBase.d.ts +0 -255
  187. package/dist/types/DayPickerDefault.d.ts +0 -8
  188. package/dist/types/DayPickerMultiple.d.ts +0 -18
  189. package/dist/types/DayPickerRange.d.ts +0 -19
  190. package/dist/types/DayPickerSingle.d.ts +0 -16
  191. package/dist/types/EventHandlers.d.ts +0 -51
  192. package/dist/types/Formatters.d.ts +0 -24
  193. package/dist/types/Labels.d.ts +0 -28
  194. package/dist/types/Matchers.d.ts +0 -84
  195. package/dist/types/Modifiers.d.ts +0 -49
  196. package/dist/types/Styles.d.ts +0 -102
  197. package/src/contexts/DayPicker/defaultContextValue.ts +0 -37
  198. package/src/contexts/DayPicker/useDayPicker.ts +0 -17
  199. package/src/contexts/Focus/useFocusContext.ts +0 -17
  200. package/src/contexts/Modifiers/useModifiers.ts +0 -20
  201. package/src/contexts/Navigation/useNavigation.ts +0 -17
  202. package/src/contexts/SelectMultiple/useSelectMultiple.ts +0 -21
  203. package/src/contexts/SelectRange/useSelectRange.ts +0 -19
  204. package/src/contexts/SelectSingle/useSelectSingle.ts +0 -21
@@ -1,19 +0,0 @@
1
- import { Matcher } from '../../../types/Matchers';
2
- /**
3
- * Returns whether a day matches against at least one of the given Matchers.
4
- *
5
- * ```
6
- * const day = new Date(2022, 5, 19);
7
- * const matcher1: DateRange = {
8
- * from: new Date(2021, 12, 21),
9
- * to: new Date(2021, 12, 30)
10
- * }
11
- * const matcher2: DateRange = {
12
- * from: new Date(2022, 5, 1),
13
- * to: new Date(2022, 5, 23)
14
- * }
15
- *
16
- * const isMatch(day, [matcher1, matcher2]); // true, since day is in the matcher1 range.
17
- * ```
18
- * */
19
- export declare function isMatch(day: Date, matchers: Matcher[]): boolean;
@@ -1,3 +0,0 @@
1
- import { Matcher } from '../../../types/Matchers';
2
- /** Normalize to array a matcher input. */
3
- export declare function matcherToArray(matcher: Matcher | Matcher[] | undefined): Matcher[];
@@ -1,27 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- /** Represents the value of the {@link NavigationContext}. */
3
- export interface NavigationContextValue {
4
- /** The month to display in the calendar. When `numberOfMonths` is greater than one, is the first of the displayed months. */
5
- currentMonth: Date;
6
- /** The months rendered by DayPicker. DayPicker can render multiple months via `numberOfMonths`. */
7
- displayMonths: Date[];
8
- /** Navigate to the specified month. */
9
- goToMonth: (month: Date) => void;
10
- /** Navigate to the specified date. */
11
- goToDate: (date: Date, refDate?: Date) => void;
12
- /** The next month to display. */
13
- nextMonth?: Date;
14
- /** The previous month to display. */
15
- previousMonth?: Date;
16
- /** Whether the given day is included in the displayed months. */
17
- isDateDisplayed: (day: Date) => boolean;
18
- }
19
- /**
20
- * The Navigation context shares details and methods to navigate the months in DayPicker.
21
- * Access this context from the {@link useNavigation} hook.
22
- */
23
- export declare const NavigationContext: React.Context<NavigationContextValue | undefined>;
24
- /** Provides the values for the {@link NavigationContext}. */
25
- export declare function NavigationProvider(props: {
26
- children?: ReactNode;
27
- }): JSX.Element;
@@ -1,2 +0,0 @@
1
- export * from './NavigationContext';
2
- export * from './useNavigation';
@@ -1,8 +0,0 @@
1
- import { NavigationContextValue } from './NavigationContext';
2
- /**
3
- * Hook to access the {@link NavigationContextValue}. Use this hook to navigate
4
- * between months or years in DayPicker.
5
- *
6
- * This hook is meant to be used inside internal or custom components.
7
- */
8
- export declare function useNavigation(): NavigationContextValue;
@@ -1,7 +0,0 @@
1
- /** Controls the navigation state. */
2
- export declare function useNavigationState(): [
3
- /** The month DayPicker is navigating at */
4
- month: Date,
5
- /** Go to the specified month. */
6
- goToMonth: (month: Date) => void
7
- ];
@@ -1,8 +0,0 @@
1
- /**
2
- * Return the months to display in the component according to the number of
3
- * months and the from/to date.
4
- */
5
- export declare function getDisplayMonths(month: Date, { reverseMonths, numberOfMonths }: {
6
- reverseMonths?: boolean;
7
- numberOfMonths: number;
8
- }): Date[];
@@ -1,3 +0,0 @@
1
- import { DayPickerContextValue } from '../../../contexts/DayPicker';
2
- /** Return the initial month according to the given options. */
3
- export declare function getInitialMonth(context: Partial<DayPickerContextValue>): Date;
@@ -1,18 +0,0 @@
1
- /**
2
- * Returns the next month the user can navigate to according to the given
3
- * options.
4
- *
5
- * Please note that the next month is not always the next calendar month:
6
- *
7
- * - if after the `toDate` range, is undefined;
8
- * - if the navigation is paged, is the number of months displayed ahead.
9
- *
10
- */
11
- export declare function getNextMonth(startingMonth: Date, options: {
12
- numberOfMonths?: number;
13
- fromDate?: Date;
14
- toDate?: Date;
15
- pagedNavigation?: boolean;
16
- today?: Date;
17
- disableNavigation?: boolean;
18
- }): Date | undefined;
@@ -1,19 +0,0 @@
1
- /**
2
- * Returns the next previous the user can navigate to, according to the given
3
- * options.
4
- *
5
- * Please note that the previous month is not always the previous calendar
6
- * month:
7
- *
8
- * - if before the `fromDate` date, is `undefined`;
9
- * - if the navigation is paged, is the number of months displayed before.
10
- *
11
- */
12
- export declare function getPreviousMonth(startingMonth: Date, options: {
13
- numberOfMonths?: number;
14
- fromDate?: Date;
15
- toDate?: Date;
16
- pagedNavigation?: boolean;
17
- today?: Date;
18
- disableNavigation?: boolean;
19
- }): Date | undefined;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { DayPickerBase } from '../types/DayPickerBase';
3
- /** The props of {@link RootProvider}. */
4
- export declare type RootContext = DayPickerBase & {
5
- children: React.ReactNode;
6
- };
7
- /** Provide the value for all the context providers. */
8
- export declare function RootProvider(props: RootContext): JSX.Element;
@@ -1,35 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { DayPickerBase } from '../../types/DayPickerBase';
3
- import { DayPickerMultipleProps } from '../../types/DayPickerMultiple';
4
- import { DayClickEventHandler } from '../../types/EventHandlers';
5
- import { InternalModifier, Modifiers } from '../../types/Modifiers';
6
- /** Represent the modifiers that are changed by the multiple selection. */
7
- export declare type SelectMultipleModifiers = Pick<Modifiers, InternalModifier.Disabled>;
8
- /** Represents the value of a {@link SelectMultipleContext}. */
9
- export interface SelectMultipleContextValue {
10
- /** The days that have been selected. */
11
- selected: Date[] | undefined;
12
- /** The modifiers for the corresponding selection. */
13
- modifiers: SelectMultipleModifiers;
14
- /** Event handler to attach to the day button to enable the multiple select. */
15
- onDayClick?: DayClickEventHandler;
16
- }
17
- /**
18
- * The SelectMultiple context shares details about the selected days when in
19
- * multiple selection mode.
20
- *
21
- * Access this context from the {@link useSelectMultiple} hook.
22
- */
23
- export declare const SelectMultipleContext: React.Context<SelectMultipleContextValue | undefined>;
24
- export declare type SelectMultipleProviderProps = {
25
- initialProps: DayPickerBase;
26
- children: ReactNode;
27
- };
28
- /** Provides the values for the {@link SelectMultipleContext}. */
29
- export declare function SelectMultipleProvider(props: SelectMultipleProviderProps): JSX.Element;
30
- declare type SelectMultipleProviderInternalProps = {
31
- initialProps: DayPickerMultipleProps;
32
- children: ReactNode;
33
- };
34
- export declare function SelectMultipleProviderInternal({ initialProps, children }: SelectMultipleProviderInternalProps): JSX.Element;
35
- export {};
@@ -1,2 +0,0 @@
1
- export * from './SelectMultipleContext';
2
- export * from './useSelectMultiple';
@@ -1,7 +0,0 @@
1
- import { SelectMultipleContextValue } from './SelectMultipleContext';
2
- /**
3
- * Hook to access the {@link SelectMultipleContextValue}.
4
- *
5
- * This hook is meant to be used inside internal or custom components.
6
- */
7
- export declare function useSelectMultiple(): SelectMultipleContextValue;
@@ -1,36 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { DayPickerBase } from '../../types/DayPickerBase';
3
- import { DayPickerRangeProps } from '../../types/DayPickerRange';
4
- import { DayClickEventHandler } from '../../types/EventHandlers';
5
- import { DateRange } from '../../types/Matchers';
6
- import { InternalModifier, Modifiers } from '../../types/Modifiers';
7
- /** Represent the modifiers that are changed by the range selection. */
8
- export declare type SelectRangeModifiers = Pick<Modifiers, InternalModifier.Disabled | InternalModifier.RangeEnd | InternalModifier.RangeMiddle | InternalModifier.RangeStart>;
9
- /** Represents the value of a {@link SelectRangeContext}. */
10
- export interface SelectRangeContextValue {
11
- /** The range of days that has been selected. */
12
- selected: DateRange | undefined;
13
- /** The modifiers for the corresponding selection. */
14
- modifiers: SelectRangeModifiers;
15
- /** Event handler to attach to the day button to enable the range select. */
16
- onDayClick?: DayClickEventHandler;
17
- }
18
- /**
19
- * The SelectRange context shares details about the selected days when in
20
- * range selection mode.
21
- *
22
- * Access this context from the {@link useSelectRange} hook.
23
- */
24
- export declare const SelectRangeContext: React.Context<SelectRangeContextValue | undefined>;
25
- declare type SelectRangeProviderProps = {
26
- initialProps: DayPickerBase;
27
- children: ReactNode;
28
- };
29
- /** Provides the values for the {@link SelectRangeProvider}. */
30
- export declare function SelectRangeProvider(props: SelectRangeProviderProps): JSX.Element;
31
- declare type SelectRangeProviderInternalProps = {
32
- initialProps: DayPickerRangeProps;
33
- children: ReactNode;
34
- };
35
- export declare function SelectRangeProviderInternal({ initialProps, children }: SelectRangeProviderInternalProps): JSX.Element;
36
- export {};
@@ -1,2 +0,0 @@
1
- export * from './SelectRangeContext';
2
- export * from './useSelectRange';
@@ -1,7 +0,0 @@
1
- import { SelectRangeContextValue } from './SelectRangeContext';
2
- /**
3
- * Hook to access the {@link SelectRangeContextValue}.
4
- *
5
- * This hook is meant to be used inside internal or custom components.
6
- */
7
- export declare function useSelectRange(): SelectRangeContextValue;
@@ -1,8 +0,0 @@
1
- import { DateRange } from '../../../types/Matchers';
2
- /**
3
- * Add a day to an existing range.
4
- *
5
- * The returned range takes in account the `undefined` values and if the added
6
- * day is already present in the range.
7
- */
8
- export declare function addToRange(day: Date, range?: DateRange): DateRange | undefined;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { DayPickerBase } from '../../types/DayPickerBase';
3
- import { DayPickerSingleProps } from '../../types/DayPickerSingle';
4
- import { DayClickEventHandler } from '../../types/EventHandlers';
5
- /** Represents the value of a {@link SelectSingleContext}. */
6
- export interface SelectSingleContextValue {
7
- /** The day that has been selected. */
8
- selected: Date | undefined;
9
- /** Event handler to attach to the day button to enable the single select. */
10
- onDayClick?: DayClickEventHandler;
11
- }
12
- /**
13
- * The SelectSingle context shares details about the selected days when in
14
- * single selection mode.
15
- *
16
- * Access this context from the {@link useSelectSingle} hook.
17
- */
18
- export declare const SelectSingleContext: React.Context<SelectSingleContextValue | undefined>;
19
- declare type SelectSingleProviderProps = {
20
- initialProps: DayPickerBase;
21
- children: React.ReactNode;
22
- };
23
- /** Provides the values for the {@link SelectSingleProvider}. */
24
- export declare function SelectSingleProvider(props: SelectSingleProviderProps): JSX.Element;
25
- declare type SelectSingleProviderInternal = {
26
- initialProps: DayPickerSingleProps;
27
- children: React.ReactNode;
28
- };
29
- export declare function SelectSingleProviderInternal({ initialProps, children }: SelectSingleProviderInternal): JSX.Element;
30
- export {};
@@ -1,2 +0,0 @@
1
- export * from './SelectSingleContext';
2
- export * from './useSelectSingle';
@@ -1,7 +0,0 @@
1
- import { SelectSingleContextValue } from './SelectSingleContext';
2
- /**
3
- * Hook to access the {@link SelectSingleContextValue}.
4
- *
5
- * This hook is meant to be used inside internal or custom components.
6
- */
7
- export declare function useSelectSingle(): SelectSingleContextValue;
@@ -1 +0,0 @@
1
- export * from './useActiveModifiers';
@@ -1,15 +0,0 @@
1
- import { ActiveModifiers } from '../../types/Modifiers';
2
- /**
3
- * Return the active modifiers for the specified day.
4
- *
5
- * This hook is meant to be used inside internal or custom components.
6
- *
7
- * @param day
8
- * @param displayMonth
9
- */
10
- export declare function useActiveModifiers(day: Date,
11
- /**
12
- * The month where the date is displayed. If not the same as `date`, the day
13
- * is an "outside day".
14
- */
15
- displayMonth?: Date): ActiveModifiers;
@@ -1 +0,0 @@
1
- export * from './useControlledValue';
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- export declare type DispatchStateAction<T> = React.Dispatch<React.SetStateAction<T>>;
3
- /**
4
- * Helper hook for using controlled/uncontrolled values from a component props.
5
- *
6
- * When the value is not controlled, pass `undefined` as `controlledValue` and
7
- * use the returned setter to update it.
8
- *
9
- * When the value is controlled, pass the controlled value as second
10
- * argument, which will be always returned as `value`.
11
- */
12
- export declare function useControlledValue<T>(defaultValue: T, controlledValue: T | undefined): [T, DispatchStateAction<T>];
@@ -1 +0,0 @@
1
- export * from './useDayEventHandlers';
@@ -1,26 +0,0 @@
1
- import { HTMLProps } from 'react';
2
- import { ActiveModifiers } from '../../types/Modifiers';
3
- export declare type EventName = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp' | 'onMouseEnter' | 'onMouseLeave' | 'onTouchCancel' | 'onTouchEnd' | 'onTouchMove' | 'onTouchStart';
4
- export declare type DayEventName = 'onDayClick' | 'onDayFocus' | 'onDayBlur' | 'onDayKeyDown' | 'onDayKeyUp' | 'onDayMouseEnter' | 'onDayMouseLeave' | 'onDayTouchCancel' | 'onDayTouchEnd' | 'onDayTouchMove' | 'onDayTouchStart';
5
- export declare type DayEventHandlers = Pick<HTMLProps<HTMLButtonElement>, EventName>;
6
- /**
7
- * This hook returns details about the content to render in the day cell.
8
- *
9
- *
10
- * When a day cell is rendered in the table, DayPicker can either:
11
- *
12
- * - render nothing: when the day is outside the month or has matched the
13
- * "hidden" modifier.
14
- * - render a button when `onDayClick` or a selection mode is set.
15
- * - render a non-interactive element: when no selection mode is set, the day
16
- * cell shouldn’t respond to any interaction. DayPicker should render a `div`
17
- * or a `span`.
18
- *
19
- * ### Usage
20
- *
21
- * Use this hook to customize the behavior of the {@link Day} component. Create a
22
- * new `Day` component using this hook and pass it to the `components` prop.
23
- * The source of {@link Day} can be a good starting point.
24
- *
25
- */
26
- export declare function useDayEventHandlers(date: Date, activeModifiers: ActiveModifiers): DayEventHandlers;
@@ -1 +0,0 @@
1
- export * from './useDayRender';
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { ButtonProps } from '../../components/Button';
3
- import { DayEventHandlers } from '../../hooks/useDayEventHandlers';
4
- import { SelectedDays } from '../../hooks/useSelectedDays';
5
- import { ActiveModifiers } from '../../types/Modifiers';
6
- import { StyledComponent } from '../../types/Styles';
7
- export declare type DayRender = {
8
- /** Whether the day should be rendered a `button` instead of a `div` */
9
- isButton: boolean;
10
- /** Whether the day should be hidden. */
11
- isHidden: boolean;
12
- /** The modifiers active for the given day. */
13
- activeModifiers: ActiveModifiers;
14
- /** The props to apply to the button element (when `isButton` is true). */
15
- buttonProps: StyledComponent & Pick<ButtonProps, 'disabled' | 'aria-pressed' | 'tabIndex'> & DayEventHandlers;
16
- /** The props to apply to the div element (when `isButton` is false). */
17
- divProps: StyledComponent;
18
- selectedDays: SelectedDays;
19
- };
20
- /**
21
- * Return props and data used to render the {@link Day} component.
22
- *
23
- * Use this hook when creating a component to replace the built-in `Day`
24
- * component.
25
- */
26
- export declare function useDayRender(
27
- /** The date to render. */
28
- day: Date,
29
- /** The month where the date is displayed (if not the same as `date`, it means it is an "outside" day). */
30
- displayMonth: Date,
31
- /** A ref to the button element that will be target of focus when rendered (if required). */
32
- buttonRef: React.RefObject<HTMLButtonElement>): DayRender;
@@ -1,10 +0,0 @@
1
- import { DayPickerContextValue } from '../../../contexts/DayPicker';
2
- import { ActiveModifiers } from '../../../types/Modifiers';
3
- /**
4
- * Return the class names for the Day element, according to the given active
5
- * modifiers.
6
- *
7
- * Custom class names are set via `modifiersClassNames` or `classNames`,
8
- * where the first have the precedence.
9
- */
10
- export declare function getDayClassNames(dayPicker: Pick<DayPickerContextValue, 'modifiersClassNames' | 'classNames'>, activeModifiers: ActiveModifiers): string[];
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { DayPickerContextValue } from '../../../contexts/DayPicker';
3
- import { ActiveModifiers } from '../../../types/Modifiers';
4
- /** Return the style for the Day element, according to the given active modifiers. */
5
- export declare function getDayStyle(dayPicker: Pick<DayPickerContextValue, 'modifiersStyles' | 'styles'>, activeModifiers: ActiveModifiers): React.CSSProperties;
@@ -1 +0,0 @@
1
- export * from './useId';
@@ -1,19 +0,0 @@
1
- /**
2
- * useId
3
- *
4
- * Autogenerate IDs to facilitate WAI-ARIA and server rendering.
5
- *
6
- * Note: The returned ID will initially be `null` and will update after a
7
- * component mounts. Users may need to supply their own ID if they need
8
- * consistent values for SSR.
9
- *
10
- * @see Docs https://reach.tech/auto-id
11
- */
12
- declare function useId(idFromProps: string): string;
13
- declare function useId(idFromProps: number): number;
14
- declare function useId(idFromProps: string | number): string | number;
15
- declare function useId(idFromProps: string | undefined | null): string | undefined;
16
- declare function useId(idFromProps: number | undefined | null): number | undefined;
17
- declare function useId(idFromProps: string | number | undefined | null): string | number | undefined;
18
- declare function useId(): string | undefined;
19
- export { useId };
@@ -1 +0,0 @@
1
- export * from './useInput';
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { DayPickerBase } from '../../types/DayPickerBase';
3
- import { DayPickerSingleProps } from '../../types/DayPickerSingle';
4
- /** The props to attach to the input field when using {@link useInput}. */
5
- export declare type InputHTMLAttributes = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'placeholder'>;
6
- /** The props to attach to the DayPicker component when using {@link useInput}. */
7
- export declare type InputDayPickerProps = Pick<DayPickerSingleProps, 'fromDate' | 'toDate' | 'locale' | 'month' | 'onDayClick' | 'onMonthChange' | 'selected' | 'today'>;
8
- export interface UseInputOptions extends Pick<DayPickerBase, 'locale' | 'fromDate' | 'toDate' | 'fromMonth' | 'toMonth' | 'fromYear' | 'toYear' | 'today'> {
9
- /** The initially selected date */
10
- defaultSelected?: Date;
11
- /** The format string for formatting the input field. See https://date-fns.org/docs/format for a list of format strings. Default to `PP`. */
12
- format?: string;
13
- /** Make the selection required. */
14
- required?: boolean;
15
- }
16
- /** Represent the value returned by {@link useInput}. */
17
- export interface UseInputValue {
18
- /** The props to pass to a DayPicker component. */
19
- dayPickerProps: InputDayPickerProps;
20
- /** The props to pass to an input field. */
21
- inputProps: InputHTMLAttributes;
22
- /** A function to reset to the initial state. */
23
- reset: () => void;
24
- /** A function to set the selected day. */
25
- setSelected: (day: Date | undefined) => void;
26
- }
27
- /** Return props and setters for binding an input field to DayPicker. */
28
- export declare function useInput(options?: UseInputOptions): UseInputValue;
@@ -1,2 +0,0 @@
1
- /** @private */
2
- export declare function isValidDate(day: Date): boolean;
@@ -1 +0,0 @@
1
- export * from './useSelectedDays';
@@ -1,10 +0,0 @@
1
- import { DateRange } from '../../types/Matchers';
2
- export declare type SelectedDays = Date | Date[] | DateRange | undefined;
3
- /**
4
- * Return the current selected days when DayPicker is in selection mode. Days
5
- * selected by the custom selection mode are not returned.
6
- *
7
- * This hook is meant to be used inside internal or custom components.
8
- *
9
- */
10
- export declare function useSelectedDays(): SelectedDays;