react-day-picker 8.0.2 → 8.0.5
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/dist/components/Head/utils/getWeekdays.d.ts +1 -1
- package/dist/components/Table/utils/daysToMonthWeeks.d.ts +1 -1
- package/dist/components/Table/utils/getMonthWeeks.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatCaption.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatDay.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatMonthCaption.d.ts +1 -1
- package/dist/contexts/DayPicker/formatters/formatWeekdayName.d.ts +1 -1
- package/dist/hooks/useDayRender/useDayRender.d.ts +1 -1
- package/dist/index.esm.js +30 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +154 -107
- package/dist/index.js.map +1 -1
- package/dist/react-day-picker.min.js +1 -1
- package/dist/style.css +11 -10
- package/dist/style.module.css +11 -10
- package/dist/types/DayPickerBase.d.ts +1 -1
- package/dist/types/Labels.d.ts +1 -1
- package/package.json +15 -14
- package/src/DayPicker.tsx +113 -0
- package/src/components/Button/Button.test.tsx +47 -0
- package/src/components/Button/Button.tsx +36 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Caption/Caption.test.tsx +86 -0
- package/src/components/Caption/Caption.tsx +54 -0
- package/src/components/Caption/index.ts +1 -0
- package/src/components/CaptionDropdowns/CaptionDropdowns.test.tsx +123 -0
- package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +43 -0
- package/src/components/CaptionDropdowns/index.ts +1 -0
- package/src/components/CaptionLabel/CaptionLabel.test.tsx +29 -0
- package/src/components/CaptionLabel/CaptionLabel.tsx +32 -0
- package/src/components/CaptionLabel/index.ts +1 -0
- package/src/components/CaptionNavigation/CaptionNavigation.test.tsx +172 -0
- package/src/components/CaptionNavigation/CaptionNavigation.tsx +63 -0
- package/src/components/CaptionNavigation/index.ts +1 -0
- package/src/components/Day/Day.test.tsx +84 -0
- package/src/components/Day/Day.tsx +30 -0
- package/src/components/Day/index.ts +1 -0
- package/src/components/DayContent/DayContent.test.tsx +51 -0
- package/src/components/DayContent/DayContent.tsx +36 -0
- package/src/components/DayContent/index.ts +1 -0
- package/src/components/Dropdown/Dropdown.test.tsx +73 -0
- package/src/components/Dropdown/Dropdown.tsx +56 -0
- package/src/components/Dropdown/index.ts +1 -0
- package/src/components/Footer/Footer.test.tsx +29 -0
- package/src/components/Footer/Footer.tsx +20 -0
- package/src/components/Footer/index.ts +1 -0
- package/src/components/Head/Head.test.tsx +117 -0
- package/src/components/Head/Head.tsx +51 -0
- package/src/components/Head/index.ts +1 -0
- package/src/components/Head/utils/getWeekdays.test.ts +36 -0
- package/src/components/Head/utils/getWeekdays.ts +22 -0
- package/src/components/Head/utils/index.ts +1 -0
- package/src/components/IconDropdown/IconDropdown.test.tsx +20 -0
- package/src/components/IconDropdown/IconDropdown.tsx +24 -0
- package/src/components/IconDropdown/index.ts +1 -0
- package/src/components/IconLeft/IconLeft.test.tsx +20 -0
- package/src/components/IconLeft/IconLeft.tsx +18 -0
- package/src/components/IconLeft/index.ts +1 -0
- package/src/components/IconRight/IconRight.test.tsx +20 -0
- package/src/components/IconRight/IconRight.tsx +17 -0
- package/src/components/IconRight/index.ts +1 -0
- package/src/components/Month/Month.test.tsx +216 -0
- package/src/components/Month/Month.tsx +53 -0
- package/src/components/Month/index.ts +1 -0
- package/src/components/MonthsDropdown/MonthsDropdown.test.tsx +99 -0
- package/src/components/MonthsDropdown/MonthsDropdown.tsx +75 -0
- package/src/components/MonthsDropdown/index.ts +1 -0
- package/src/components/Navigation/Navigation.test.tsx +129 -0
- package/src/components/Navigation/Navigation.tsx +102 -0
- package/src/components/Navigation/index.ts +1 -0
- package/src/components/Root/Root.test.tsx +123 -0
- package/src/components/Root/Root.tsx +58 -0
- package/src/components/Root/index.ts +1 -0
- package/src/components/Row/Row.test.tsx +69 -0
- package/src/components/Row/Row.tsx +51 -0
- package/src/components/Row/index.ts +1 -0
- package/src/components/Table/Table.test.tsx +42 -0
- package/src/components/Table/Table.tsx +60 -0
- package/src/components/Table/__snapshots__/Table.test.tsx.snap +1453 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/utils/daysToMonthWeeks.ts +47 -0
- package/src/components/Table/utils/getMonthWeeks.test.ts +68 -0
- package/src/components/Table/utils/getMonthWeeks.ts +55 -0
- package/src/components/WeekNumber/WeekNumber.test.tsx +46 -0
- package/src/components/WeekNumber/WeekNumber.tsx +58 -0
- package/src/components/WeekNumber/__snapshots__/WeekNumber.test.tsx.snap +11 -0
- package/src/components/WeekNumber/index.ts +1 -0
- package/src/components/YearsDropdown/YearsDropdown.test.tsx +98 -0
- package/src/components/YearsDropdown/YearsDropdown.tsx +76 -0
- package/src/components/YearsDropdown/index.ts +1 -0
- package/src/contexts/DayPicker/DayPickerContext.tsx +156 -0
- package/src/contexts/DayPicker/defaultClassNames.ts +58 -0
- package/src/contexts/DayPicker/defaultContextValue.ts +37 -0
- package/src/contexts/DayPicker/formatters/formatCaption.test.ts +15 -0
- package/src/contexts/DayPicker/formatters/formatCaption.ts +12 -0
- package/src/contexts/DayPicker/formatters/formatDay.test.ts +7 -0
- package/src/contexts/DayPicker/formatters/formatDay.ts +9 -0
- package/src/contexts/DayPicker/formatters/formatMonthCaption.test.ts +15 -0
- package/src/contexts/DayPicker/formatters/formatMonthCaption.ts +12 -0
- package/src/contexts/DayPicker/formatters/formatWeekNumber.test.ts +5 -0
- package/src/contexts/DayPicker/formatters/formatWeekNumber.ts +6 -0
- package/src/contexts/DayPicker/formatters/formatWeekdayName.test.ts +15 -0
- package/src/contexts/DayPicker/formatters/formatWeekdayName.ts +12 -0
- package/src/contexts/DayPicker/formatters/formatYearCaption.test.ts +7 -0
- package/src/contexts/DayPicker/formatters/formatYearCaption.ts +11 -0
- package/src/contexts/DayPicker/formatters/index.ts +6 -0
- package/src/contexts/DayPicker/index.ts +2 -0
- package/src/contexts/DayPicker/labels/index.ts +7 -0
- package/src/contexts/DayPicker/labels/labelDay.test.ts +7 -0
- package/src/contexts/DayPicker/labels/labelDay.ts +10 -0
- package/src/contexts/DayPicker/labels/labelMonthDropdown.test.ts +5 -0
- package/src/contexts/DayPicker/labels/labelMonthDropdown.ts +6 -0
- package/src/contexts/DayPicker/labels/labelNext.test.ts +5 -0
- package/src/contexts/DayPicker/labels/labelNext.ts +8 -0
- package/src/contexts/DayPicker/labels/labelPrevious.test.ts +5 -0
- package/src/contexts/DayPicker/labels/labelPrevious.ts +8 -0
- package/src/contexts/DayPicker/labels/labelWeekNumber.test.ts +5 -0
- package/src/contexts/DayPicker/labels/labelWeekNumber.ts +8 -0
- package/src/contexts/DayPicker/labels/labelWeekday.test.ts +15 -0
- package/src/contexts/DayPicker/labels/labelWeekday.ts +10 -0
- package/src/contexts/DayPicker/labels/labelYearDropdown.test.ts +5 -0
- package/src/contexts/DayPicker/labels/labelYearDropdown.ts +6 -0
- package/src/contexts/DayPicker/useDayPicker.test.ts +297 -0
- package/src/contexts/DayPicker/useDayPicker.ts +17 -0
- package/src/contexts/DayPicker/utils/index.ts +1 -0
- package/src/contexts/DayPicker/utils/parseFromToProps.test.ts +47 -0
- package/src/contexts/DayPicker/utils/parseFromToProps.ts +32 -0
- package/src/contexts/Focus/FocusContext.tsx +174 -0
- package/src/contexts/Focus/index.ts +2 -0
- package/src/contexts/Focus/useFocusContext.test.ts +183 -0
- package/src/contexts/Focus/useFocusContext.ts +12 -0
- package/src/contexts/Focus/utils/getInitialFocusTarget.test.tsx +12 -0
- package/src/contexts/Focus/utils/getInitialFocusTarget.tsx +44 -0
- package/src/contexts/Modifiers/ModifiersContext.tsx +44 -0
- package/src/contexts/Modifiers/index.ts +2 -0
- package/src/contexts/Modifiers/useModifiers.test.ts +46 -0
- package/src/contexts/Modifiers/useModifiers.ts +17 -0
- package/src/contexts/Modifiers/utils/getActiveModifiers.test.ts +53 -0
- package/src/contexts/Modifiers/utils/getActiveModifiers.ts +33 -0
- package/src/contexts/Modifiers/utils/getCustomModifiers.test.ts +14 -0
- package/src/contexts/Modifiers/utils/getCustomModifiers.ts +14 -0
- package/src/contexts/Modifiers/utils/getInternalModifiers.test.ts +146 -0
- package/src/contexts/Modifiers/utils/getInternalModifiers.ts +58 -0
- package/src/contexts/Modifiers/utils/isDateInRange.test.ts +28 -0
- package/src/contexts/Modifiers/utils/isDateInRange.ts +27 -0
- package/src/contexts/Modifiers/utils/isMatch.test.ts +92 -0
- package/src/contexts/Modifiers/utils/isMatch.ts +76 -0
- package/src/contexts/Modifiers/utils/matcherToArray.test.ts +22 -0
- package/src/contexts/Modifiers/utils/matcherToArray.ts +14 -0
- package/src/contexts/Navigation/NavigationContext.tsx +84 -0
- package/src/contexts/Navigation/index.ts +2 -0
- package/src/contexts/Navigation/useNavigation.test.ts +126 -0
- package/src/contexts/Navigation/useNavigation.ts +12 -0
- package/src/contexts/Navigation/useNavigationState.test.ts +36 -0
- package/src/contexts/Navigation/useNavigationState.ts +25 -0
- package/src/contexts/Navigation/utils/getDisplayMonths.ts +31 -0
- package/src/contexts/Navigation/utils/getInitialMonth.test.ts +56 -0
- package/src/contexts/Navigation/utils/getInitialMonth.ts +24 -0
- package/src/contexts/Navigation/utils/getNextMonth.test.ts +75 -0
- package/src/contexts/Navigation/utils/getNextMonth.ts +45 -0
- package/src/contexts/Navigation/utils/getPreviousMonth.test.ts +55 -0
- package/src/contexts/Navigation/utils/getPreviousMonth.ts +44 -0
- package/src/contexts/RootProvider.tsx +37 -0
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +135 -0
- package/src/contexts/SelectMultiple/index.ts +2 -0
- package/src/contexts/SelectMultiple/useSelectMultiple.test.ts +191 -0
- package/src/contexts/SelectMultiple/useSelectMultiple.ts +17 -0
- package/src/contexts/SelectRange/SelectRangeContext.tsx +158 -0
- package/src/contexts/SelectRange/index.ts +2 -0
- package/src/contexts/SelectRange/useSelectRange.test.ts +282 -0
- package/src/contexts/SelectRange/useSelectRange.ts +15 -0
- package/src/contexts/SelectRange/utils/addToRange.test.ts +119 -0
- package/src/contexts/SelectRange/utils/addToRange.ts +43 -0
- package/src/contexts/SelectSingle/SelectSingleContext.tsx +80 -0
- package/src/contexts/SelectSingle/index.ts +2 -0
- package/src/contexts/SelectSingle/useSelectSingle.test.ts +81 -0
- package/src/contexts/SelectSingle/useSelectSingle.ts +17 -0
- package/src/hooks/useActiveModifiers/index.ts +1 -0
- package/src/hooks/useActiveModifiers/useActiveModifiers.test.tsx +36 -0
- package/src/hooks/useActiveModifiers/useActiveModifiers.tsx +18 -0
- package/src/hooks/useControlledValue/index.ts +1 -0
- package/src/hooks/useControlledValue/useControlledValue.test.ts +68 -0
- package/src/hooks/useControlledValue/useControlledValue.ts +24 -0
- package/src/hooks/useDayEventHandlers/index.ts +1 -0
- package/src/hooks/useDayEventHandlers/useDayEventHandlers.test.tsx +213 -0
- package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +195 -0
- package/src/hooks/useDayRender/index.ts +1 -0
- package/src/hooks/useDayRender/useDayRender.test.tsx +304 -0
- package/src/hooks/useDayRender/useDayRender.tsx +123 -0
- package/src/hooks/useDayRender/utils/getDayClassNames.test.ts +63 -0
- package/src/hooks/useDayRender/utils/getDayClassNames.ts +32 -0
- package/src/hooks/useDayRender/utils/getDayStyle.ts +19 -0
- package/src/hooks/useInput/index.ts +1 -0
- package/src/hooks/useInput/useInput.ts +175 -0
- package/src/hooks/useInput/utils/isValidDate.tsx +4 -0
- package/src/hooks/useSelectedDays/index.ts +1 -0
- package/src/hooks/useSelectedDays/useSelectedDays.test.ts +72 -0
- package/src/hooks/useSelectedDays/useSelectedDays.ts +32 -0
- package/src/index.ts +43 -0
- package/src/style.css +311 -0
- package/src/style.css.d.ts +38 -0
- package/src/types/DayPickerBase.ts +267 -0
- package/src/types/DayPickerDefault.ts +15 -0
- package/src/types/DayPickerMultiple.ts +26 -0
- package/src/types/DayPickerRange.ts +27 -0
- package/src/types/DayPickerSingle.ts +24 -0
- package/src/types/EventHandlers.ts +87 -0
- package/src/types/Formatters.ts +29 -0
- package/src/types/Labels.ts +36 -0
- package/src/types/Matchers.ts +106 -0
- package/src/types/Modifiers.ts +62 -0
- package/src/types/Styles.ts +108 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { Locale } from 'date-fns';
|
|
2
|
+
|
|
3
|
+
import { CaptionLayout, CaptionProps } from 'components/Caption';
|
|
4
|
+
import { CaptionLabelProps } from 'components/CaptionLabel';
|
|
5
|
+
import { DayProps } from 'components/Day';
|
|
6
|
+
import { DayContentProps } from 'components/DayContent';
|
|
7
|
+
import { DropdownProps } from 'components/Dropdown';
|
|
8
|
+
import { RowProps } from 'components/Row';
|
|
9
|
+
import { WeekNumberProps } from 'components/WeekNumber';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
DayClickEventHandler,
|
|
13
|
+
DayFocusEventHandler,
|
|
14
|
+
DayKeyboardEventHandler,
|
|
15
|
+
DayMouseEventHandler,
|
|
16
|
+
DayTouchEventHandler,
|
|
17
|
+
MonthChangeEventHandler,
|
|
18
|
+
WeekNumberClickEventHandler
|
|
19
|
+
} from './EventHandlers';
|
|
20
|
+
import { Formatters } from './Formatters';
|
|
21
|
+
import { Labels } from './Labels';
|
|
22
|
+
import { Matcher } from './Matchers';
|
|
23
|
+
import {
|
|
24
|
+
DayModifiers,
|
|
25
|
+
ModifiersClassNames,
|
|
26
|
+
ModifiersStyles
|
|
27
|
+
} from './Modifiers';
|
|
28
|
+
import { ClassNames, StyledComponent, Styles } from './Styles';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Selection modes supported by DayPicker.
|
|
32
|
+
*
|
|
33
|
+
* - `single`: use DayPicker to select single days.
|
|
34
|
+
* - `multiple`: allow selecting multiple days.
|
|
35
|
+
* - `range`: use DayPicker to select a range of days
|
|
36
|
+
* - `default`: disable the built-in selection behavior. Customize what is selected by using [[onDayClick]].
|
|
37
|
+
*/
|
|
38
|
+
export type DaySelectionMode = 'single' | 'multiple' | 'range' | 'default';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The base props for the [[DayPicker]] component.
|
|
42
|
+
*/
|
|
43
|
+
export interface DayPickerBase {
|
|
44
|
+
/** The CSS class to add to the container element. */
|
|
45
|
+
className?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Change the class names of the HTML elements.
|
|
48
|
+
*
|
|
49
|
+
* Use this prop when you need to change the default class names — for example
|
|
50
|
+
* when using CSS modules.
|
|
51
|
+
*/
|
|
52
|
+
classNames?: ClassNames;
|
|
53
|
+
/**
|
|
54
|
+
* Change the class name for the day matching the [[modifiers]].
|
|
55
|
+
*/
|
|
56
|
+
modifiersClassNames?: ModifiersClassNames;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Style to apply to the container element.
|
|
60
|
+
*/
|
|
61
|
+
style?: React.CSSProperties;
|
|
62
|
+
/**
|
|
63
|
+
* Change the inline styles for each UIElement.
|
|
64
|
+
*/
|
|
65
|
+
styles?: Styles;
|
|
66
|
+
/**
|
|
67
|
+
* Change the inline style for the day matching the [[modifiers]].
|
|
68
|
+
*/
|
|
69
|
+
modifiersStyles?: ModifiersStyles;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The initial month to show in the calendar. Default is the current month.
|
|
73
|
+
*
|
|
74
|
+
* Use this prop to let DayPicker control the current month. If you need to set the month programmatically, use [[month]] and [[onMonthChange]].
|
|
75
|
+
*/
|
|
76
|
+
defaultMonth?: Date;
|
|
77
|
+
/**
|
|
78
|
+
* The month to display in the calendar.
|
|
79
|
+
*
|
|
80
|
+
* As opposed to [[defaultMonth]], use this prop with [[onMonthChange]] to
|
|
81
|
+
* change the month programmatically.
|
|
82
|
+
*/
|
|
83
|
+
month?: Date;
|
|
84
|
+
/**
|
|
85
|
+
* Event fired when the user navigates between months.
|
|
86
|
+
*/
|
|
87
|
+
onMonthChange?: MonthChangeEventHandler;
|
|
88
|
+
/**
|
|
89
|
+
* The number of displayed months. Defaults to `1`.
|
|
90
|
+
*/
|
|
91
|
+
numberOfMonths?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The earliest day to start the month navigation.
|
|
94
|
+
*/
|
|
95
|
+
fromDate?: Date;
|
|
96
|
+
/**
|
|
97
|
+
* The latest day to end the month navigation.
|
|
98
|
+
*/
|
|
99
|
+
toDate?: Date;
|
|
100
|
+
/**
|
|
101
|
+
* The earliest month to start the month navigation.
|
|
102
|
+
*/
|
|
103
|
+
fromMonth?: Date;
|
|
104
|
+
/**
|
|
105
|
+
* The latest month to end the month navigation.
|
|
106
|
+
*/
|
|
107
|
+
toMonth?: Date;
|
|
108
|
+
/**
|
|
109
|
+
* The earliest year to start the month navigation.
|
|
110
|
+
*/
|
|
111
|
+
fromYear?: number;
|
|
112
|
+
/**
|
|
113
|
+
* The latest year to end the month navigation.
|
|
114
|
+
*/
|
|
115
|
+
toYear?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Disable the navigation between months.
|
|
118
|
+
*/
|
|
119
|
+
disableNavigation?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Paginate the month navigation displaying the [[numberOfMonths]] at time.
|
|
122
|
+
*/
|
|
123
|
+
pagedNavigation?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Render the months in reversed order (when [[numberOfMonths]] is greater
|
|
126
|
+
* than `1`) to display the most recent month first.
|
|
127
|
+
*/
|
|
128
|
+
reverseMonths?: boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Change the layout of the caption:
|
|
132
|
+
*
|
|
133
|
+
* - `buttons` (default): display prev/right buttons
|
|
134
|
+
* - `dropdown`: display drop-downs to change the month and the year
|
|
135
|
+
*
|
|
136
|
+
* **Note:** the `dropdown` layout is available only when `fromDate`,
|
|
137
|
+
* `fromMonth` or`fromYear` and `toDate`, `toMonth` or `toYear` are set.
|
|
138
|
+
*/
|
|
139
|
+
captionLayout?: CaptionLayout;
|
|
140
|
+
/**
|
|
141
|
+
* Display six weeks per months, regardless the month’s number of weeks.
|
|
142
|
+
* To use this prop, [[showOutsideDays]] must be set. Default to `false`.
|
|
143
|
+
*/
|
|
144
|
+
fixedWeeks?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Hide the month’s head displaying the weekday names.
|
|
147
|
+
*/
|
|
148
|
+
hideHead?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Show the outside days. An outside day is a day falling in the next or the
|
|
151
|
+
* previous month. Default is `false`.
|
|
152
|
+
*/
|
|
153
|
+
showOutsideDays?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Show the week numbers column. Default to `false`.
|
|
156
|
+
*/
|
|
157
|
+
showWeekNumber?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* A map of components used to create the layout.
|
|
160
|
+
*/
|
|
161
|
+
components?: CustomComponents;
|
|
162
|
+
|
|
163
|
+
/** Content to add to the `tfoot` element. */
|
|
164
|
+
footer?: React.ReactNode;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* When a selection mode is set, DayPicker will focus the first selected day
|
|
168
|
+
* (if set) or the today's date (if not disabled).
|
|
169
|
+
*
|
|
170
|
+
* Use this prop when you need to focus DayPicker after a user actions, for
|
|
171
|
+
* improved accessibility.
|
|
172
|
+
*/
|
|
173
|
+
initialFocus?: boolean;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Apply the `disabled` modifier to the matching days.
|
|
177
|
+
*/
|
|
178
|
+
disabled?: Matcher | Matcher[];
|
|
179
|
+
/**
|
|
180
|
+
* Apply the `hidden` modifier to the matching days. Will hide them from the
|
|
181
|
+
* calendar.
|
|
182
|
+
*/
|
|
183
|
+
hidden?: Matcher | Matcher[];
|
|
184
|
+
|
|
185
|
+
/** Apply the `selected` modifier to the matching days. */
|
|
186
|
+
selected?: Matcher | Matcher[];
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The today’s date. Default is the current date. This Date will get the
|
|
190
|
+
* `today` modifier to style the day.
|
|
191
|
+
*/
|
|
192
|
+
today?: Date;
|
|
193
|
+
/**
|
|
194
|
+
* Add modifiers to the matching days.
|
|
195
|
+
*/
|
|
196
|
+
modifiers?: DayModifiers;
|
|
197
|
+
|
|
198
|
+
/** The date-fns locale object used to localize dates. Defaults to* `en-US`. */
|
|
199
|
+
locale?: Locale;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Labels creators to override the defaults. Use this prop to customize the
|
|
203
|
+
* ARIA labels attributes.
|
|
204
|
+
*/
|
|
205
|
+
labels?: Partial<Labels>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The text direction of the calendar. Use `ltr` for left-to-right (default)
|
|
209
|
+
* or `rtl` for right-to-left.
|
|
210
|
+
*/
|
|
211
|
+
dir?: string;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A map of formatters. Use the formatters to override the default formatting
|
|
215
|
+
* functions.
|
|
216
|
+
*/
|
|
217
|
+
formatters?: Partial<Formatters>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The index of the first day of the week (0 - Sunday). Overrides the locale's one.
|
|
221
|
+
*/
|
|
222
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
223
|
+
|
|
224
|
+
onDayClick?: DayClickEventHandler;
|
|
225
|
+
onDayFocus?: DayFocusEventHandler;
|
|
226
|
+
onDayBlur?: DayFocusEventHandler;
|
|
227
|
+
onDayMouseEnter?: DayMouseEventHandler;
|
|
228
|
+
onDayMouseLeave?: DayMouseEventHandler;
|
|
229
|
+
onDayKeyDown?: DayKeyboardEventHandler;
|
|
230
|
+
onDayKeyUp?: DayKeyboardEventHandler;
|
|
231
|
+
onDayKeyPress?: DayKeyboardEventHandler;
|
|
232
|
+
onDayTouchCancel?: DayTouchEventHandler;
|
|
233
|
+
onDayTouchEnd?: DayTouchEventHandler;
|
|
234
|
+
onDayTouchMove?: DayTouchEventHandler;
|
|
235
|
+
onDayTouchStart?: DayTouchEventHandler;
|
|
236
|
+
onNextClick?: MonthChangeEventHandler;
|
|
237
|
+
onPrevClick?: MonthChangeEventHandler;
|
|
238
|
+
onWeekNumberClick?: WeekNumberClickEventHandler;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** A map of the component that can be changed via the `components` prop. */
|
|
242
|
+
export interface CustomComponents {
|
|
243
|
+
/** The component for the caption element. */
|
|
244
|
+
Caption?: (props: CaptionProps) => JSX.Element | null;
|
|
245
|
+
/** The component for the caption element. */
|
|
246
|
+
CaptionLabel?: (props: CaptionLabelProps) => JSX.Element | null;
|
|
247
|
+
/** The component for the day element. This is a button or a span. */
|
|
248
|
+
Day?: (props: DayProps) => JSX.Element | null;
|
|
249
|
+
/** The component for the content of the day element. */
|
|
250
|
+
DayContent?: (props: DayContentProps) => JSX.Element | null;
|
|
251
|
+
/** The component for the drop-down elements. */
|
|
252
|
+
Dropdown?: (props: DropdownProps) => JSX.Element | null;
|
|
253
|
+
/** The component for the table footer. */
|
|
254
|
+
Footer?: () => JSX.Element | null;
|
|
255
|
+
/** The component for the table’s head. */
|
|
256
|
+
Head?: () => JSX.Element | null;
|
|
257
|
+
/** The component for the small icon in the drop-downs. */
|
|
258
|
+
IconDropdown?: (props: StyledComponent) => JSX.Element | null;
|
|
259
|
+
/** The arrow right icon (used for the Navigation buttons). */
|
|
260
|
+
IconRight?: (props: StyledComponent) => JSX.Element | null;
|
|
261
|
+
/** The arrow left icon (used for the Navigation buttons). */
|
|
262
|
+
IconLeft?: (props: StyledComponent) => JSX.Element | null;
|
|
263
|
+
/** The component for the table rows. */
|
|
264
|
+
Row?: (props: RowProps) => JSX.Element | null;
|
|
265
|
+
/** The component for the week number in the table rows. */
|
|
266
|
+
WeekNumber?: (props: WeekNumberProps) => JSX.Element | null;
|
|
267
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DayPickerProps } from 'DayPicker';
|
|
2
|
+
|
|
3
|
+
import { DayPickerBase } from './DayPickerBase';
|
|
4
|
+
|
|
5
|
+
/** The props for the [[DayPicker]] component when using `mode="default"` or `undefined`. */
|
|
6
|
+
export interface DayPickerDefaultProps extends DayPickerBase {
|
|
7
|
+
mode?: 'default';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Returns true when the props are of type [[DayPickerDefault]]. */
|
|
11
|
+
export function isDayPickerDefault(
|
|
12
|
+
props: DayPickerProps
|
|
13
|
+
): props is DayPickerDefaultProps {
|
|
14
|
+
return props.mode === undefined || props.mode === 'default';
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DayPickerProps } from 'DayPicker';
|
|
2
|
+
|
|
3
|
+
import { DayPickerContextValue } from 'contexts/DayPicker';
|
|
4
|
+
|
|
5
|
+
import { DayPickerBase } from './DayPickerBase';
|
|
6
|
+
import { SelectMultipleEventHandler } from './EventHandlers';
|
|
7
|
+
|
|
8
|
+
/** The props for the [[DayPicker]] component when using `mode="multiple"`. */
|
|
9
|
+
export interface DayPickerMultipleProps extends DayPickerBase {
|
|
10
|
+
mode: 'multiple';
|
|
11
|
+
/** The selected days. */
|
|
12
|
+
selected?: Date[];
|
|
13
|
+
/** Event fired when a days added or removed to the selection. */
|
|
14
|
+
onSelect?: SelectMultipleEventHandler;
|
|
15
|
+
/** The minimum amount of days that can be selected. */
|
|
16
|
+
min?: number;
|
|
17
|
+
/** The maximum amount of days that can be selected. */
|
|
18
|
+
max?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Returns true when the props are of type [[DayPickerMultiple]]. */
|
|
22
|
+
export function isDayPickerMultiple(
|
|
23
|
+
props: DayPickerProps | DayPickerContextValue
|
|
24
|
+
): props is DayPickerMultipleProps {
|
|
25
|
+
return props.mode === 'multiple';
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DayPickerProps } from 'DayPicker';
|
|
2
|
+
|
|
3
|
+
import { DayPickerContextValue } from 'contexts/DayPicker';
|
|
4
|
+
|
|
5
|
+
import { DayPickerBase } from './DayPickerBase';
|
|
6
|
+
import { SelectRangeEventHandler } from './EventHandlers';
|
|
7
|
+
import { DateRange } from './Matchers';
|
|
8
|
+
|
|
9
|
+
/** The props for the [[DayPicker]] component when using `mode="range"`. */
|
|
10
|
+
export interface DayPickerRangeProps extends DayPickerBase {
|
|
11
|
+
mode: 'range';
|
|
12
|
+
/** The selected range of days. */
|
|
13
|
+
selected?: DateRange;
|
|
14
|
+
/** Event fired when a range (or a part of the range) is selected. */
|
|
15
|
+
onSelect?: SelectRangeEventHandler;
|
|
16
|
+
/** The minimum amount of days that can be selected. */
|
|
17
|
+
min?: number;
|
|
18
|
+
/** The maximum amount of days that can be selected. */
|
|
19
|
+
max?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Returns true when the props are of type [[DayPickerRange]]. */
|
|
23
|
+
export function isDayPickerRange(
|
|
24
|
+
props: DayPickerProps | DayPickerContextValue
|
|
25
|
+
): props is DayPickerRangeProps {
|
|
26
|
+
return props.mode === 'range';
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DayPickerProps } from 'DayPicker';
|
|
2
|
+
|
|
3
|
+
import { DayPickerContextValue } from 'contexts/DayPicker';
|
|
4
|
+
|
|
5
|
+
import { DayPickerBase } from './DayPickerBase';
|
|
6
|
+
import { SelectSingleEventHandler } from './EventHandlers';
|
|
7
|
+
|
|
8
|
+
/** The props for the [[DayPicker]] component when using `mode="single"`. */
|
|
9
|
+
export interface DayPickerSingleProps extends DayPickerBase {
|
|
10
|
+
mode: 'single';
|
|
11
|
+
/** The selected day. */
|
|
12
|
+
selected?: Date | undefined;
|
|
13
|
+
/** Event fired when a day is selected. */
|
|
14
|
+
onSelect?: SelectSingleEventHandler;
|
|
15
|
+
/** Make the selection required. */
|
|
16
|
+
required?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Returns true when the props are of type [[DayPickerSingle]]. */
|
|
20
|
+
export function isDayPickerSingle(
|
|
21
|
+
props: DayPickerProps | DayPickerContextValue
|
|
22
|
+
): props is DayPickerSingleProps {
|
|
23
|
+
return props.mode === 'single';
|
|
24
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DateRange } from 'types/Matchers';
|
|
2
|
+
|
|
3
|
+
import { ActiveModifiers } from './Modifiers';
|
|
4
|
+
|
|
5
|
+
/** The event handler when a day is clicked. */
|
|
6
|
+
export type DayClickEventHandler = (
|
|
7
|
+
day: Date,
|
|
8
|
+
activeModifiers: ActiveModifiers,
|
|
9
|
+
e: React.MouseEvent
|
|
10
|
+
) => void;
|
|
11
|
+
|
|
12
|
+
/** The event handler when a day is focused. */
|
|
13
|
+
export type DayFocusEventHandler = (
|
|
14
|
+
day: Date,
|
|
15
|
+
activeModifiers: ActiveModifiers,
|
|
16
|
+
e: React.FocusEvent | React.KeyboardEvent
|
|
17
|
+
) => void;
|
|
18
|
+
|
|
19
|
+
/** The event handler when a day gets a keyboard event. */
|
|
20
|
+
export type DayKeyboardEventHandler = (
|
|
21
|
+
day: Date,
|
|
22
|
+
activeModifiers: ActiveModifiers,
|
|
23
|
+
e: React.KeyboardEvent
|
|
24
|
+
) => void;
|
|
25
|
+
|
|
26
|
+
/** The event handler when a day gets a mouse event. */
|
|
27
|
+
export type DayMouseEventHandler = (
|
|
28
|
+
day: Date,
|
|
29
|
+
activeModifiers: ActiveModifiers,
|
|
30
|
+
e: React.MouseEvent
|
|
31
|
+
) => void;
|
|
32
|
+
|
|
33
|
+
/** The event handler when a month is changed in the calendar. */
|
|
34
|
+
export type MonthChangeEventHandler = (month: Date) => void;
|
|
35
|
+
|
|
36
|
+
/** The event handler when selecting multiple days. */
|
|
37
|
+
export type SelectMultipleEventHandler = (
|
|
38
|
+
/** The selected days */
|
|
39
|
+
days: Date[] | undefined,
|
|
40
|
+
/** The day that was clicked triggering the event. */
|
|
41
|
+
selectedDay: Date,
|
|
42
|
+
/** The day that was clicked */
|
|
43
|
+
activeModifiers: ActiveModifiers,
|
|
44
|
+
/** The mouse event that triggered this event. */
|
|
45
|
+
e: React.MouseEvent
|
|
46
|
+
) => void;
|
|
47
|
+
|
|
48
|
+
/** The event handler when selecting a range of days. */
|
|
49
|
+
export type SelectRangeEventHandler = (
|
|
50
|
+
/** The current range of the selected days. */
|
|
51
|
+
range: DateRange | undefined,
|
|
52
|
+
/** The day that was selected (or clicked) triggering the event. */
|
|
53
|
+
selectedDay: Date,
|
|
54
|
+
/** The modifiers of the selected day. */
|
|
55
|
+
activeModifiers: ActiveModifiers,
|
|
56
|
+
e: React.MouseEvent
|
|
57
|
+
) => void;
|
|
58
|
+
|
|
59
|
+
/** The event handler when selecting a single day. */
|
|
60
|
+
export interface SelectSingleEventHandler {
|
|
61
|
+
(
|
|
62
|
+
/** The selected day, `undefined` when `required={false}` (default) and the day is clicked again. */
|
|
63
|
+
day: Date | undefined,
|
|
64
|
+
/** The day that was selected (or clicked) triggering the event. */
|
|
65
|
+
selectedDay: Date,
|
|
66
|
+
/** The modifiers of the selected day. */
|
|
67
|
+
activeModifiers: ActiveModifiers,
|
|
68
|
+
e: React.MouseEvent
|
|
69
|
+
): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**The event handler when the week number is clicked. */
|
|
73
|
+
export type WeekNumberClickEventHandler = (
|
|
74
|
+
/** The week number that has been clicked. */
|
|
75
|
+
weekNumber: number,
|
|
76
|
+
/** The dates in the clicked week. */
|
|
77
|
+
dates: Date[],
|
|
78
|
+
/** The mouse event that triggered this event. */
|
|
79
|
+
e: React.MouseEvent
|
|
80
|
+
) => void;
|
|
81
|
+
|
|
82
|
+
/** The event handler when a day gets a touch event. */
|
|
83
|
+
export type DayTouchEventHandler = (
|
|
84
|
+
day: Date,
|
|
85
|
+
activeModifiers: ActiveModifiers,
|
|
86
|
+
e: React.TouchEvent
|
|
87
|
+
) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/** Represents a function to format a date. */
|
|
4
|
+
export type DateFormatter = (
|
|
5
|
+
date: Date,
|
|
6
|
+
options?: { locale?: Locale }
|
|
7
|
+
) => React.ReactNode;
|
|
8
|
+
|
|
9
|
+
/** Represent a map of formatters used to render localized content. */
|
|
10
|
+
export type Formatters = {
|
|
11
|
+
/** Format the month in the caption when `captionLayout` is `buttons`. */
|
|
12
|
+
formatCaption: DateFormatter;
|
|
13
|
+
/** Format the month in the navigation dropdown. */
|
|
14
|
+
formatMonthCaption: DateFormatter;
|
|
15
|
+
/** Format the year in the navigation dropdown. */
|
|
16
|
+
formatYearCaption: DateFormatter;
|
|
17
|
+
/** Format the day in the day cell. */
|
|
18
|
+
formatDay: DateFormatter;
|
|
19
|
+
/** Format the week number. */
|
|
20
|
+
formatWeekNumber: WeekNumberFormatter;
|
|
21
|
+
/** Format the week day name in the header */
|
|
22
|
+
formatWeekdayName: DateFormatter;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Represent a function to format the week number. */
|
|
26
|
+
export type WeekNumberFormatter = (
|
|
27
|
+
weekNumber: number,
|
|
28
|
+
options?: { locale?: Locale }
|
|
29
|
+
) => React.ReactNode;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Locale } from 'date-fns';
|
|
2
|
+
|
|
3
|
+
import { ActiveModifiers } from 'types/Modifiers';
|
|
4
|
+
|
|
5
|
+
/** Map of functions to translate ARIA labels for the relative elements. */
|
|
6
|
+
export type Labels = {
|
|
7
|
+
labelMonthDropdown: () => string;
|
|
8
|
+
labelYearDropdown: () => string;
|
|
9
|
+
labelNext: NavButtonLabel;
|
|
10
|
+
labelPrevious: NavButtonLabel;
|
|
11
|
+
labelDay: DayLabel;
|
|
12
|
+
labelWeekday: WeekdayLabel;
|
|
13
|
+
labelWeekNumber: WeekNumberLabel;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Return the ARIA label for the [[Day]] component. */
|
|
17
|
+
export type DayLabel = (
|
|
18
|
+
day: Date,
|
|
19
|
+
activeModifiers: ActiveModifiers,
|
|
20
|
+
options?: { locale?: Locale }
|
|
21
|
+
) => string;
|
|
22
|
+
|
|
23
|
+
/** Return the ARIA label for the "next month" / "prev month" buttons in the navigation.*/
|
|
24
|
+
export type NavButtonLabel = (
|
|
25
|
+
month?: Date,
|
|
26
|
+
options?: { locale?: Locale }
|
|
27
|
+
) => string;
|
|
28
|
+
|
|
29
|
+
/** Return the ARIA label for the Head component.*/
|
|
30
|
+
export type WeekdayLabel = (day: Date, options?: { locale?: Locale }) => string;
|
|
31
|
+
|
|
32
|
+
/** Return the ARIA label of the week number.*/
|
|
33
|
+
export type WeekNumberLabel = (
|
|
34
|
+
n: number,
|
|
35
|
+
options?: { locale?: Locale }
|
|
36
|
+
) => string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value or a function that matches a specific day.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* Matchers are passed to DayPicker via [[DayPickerProps.disabled]],
|
|
6
|
+
* [[DayPickerProps.hidden]] or [[DayPickerProps.selected]] and are used to
|
|
7
|
+
* determine if a day should get a [[Modifier]].
|
|
8
|
+
*
|
|
9
|
+
* Matchers can be of different types:
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* // will always match the day
|
|
13
|
+
* const booleanMatcher: Matcher = true;
|
|
14
|
+
*
|
|
15
|
+
* // will match the today's date
|
|
16
|
+
* const dateMatcher: Matcher = new Date();
|
|
17
|
+
*
|
|
18
|
+
* // will match the days in the array
|
|
19
|
+
* const arrayMatcher: Matcher = [new Date(2019, 1, 2);, new Date(2019, 1, 4)];
|
|
20
|
+
*
|
|
21
|
+
* // will match days after the 2nd of February 2019
|
|
22
|
+
* const afterMatcher: DateAfter = { after: new Date(2019, 1, 2); };
|
|
23
|
+
* // will match days before the 2nd of February 2019 }
|
|
24
|
+
* const beforeMatcher: DateBefore = { before: : new Date(2019, 1, 2); };
|
|
25
|
+
*
|
|
26
|
+
* // will match Sundays
|
|
27
|
+
* const dayOfWeekMatcher: DayOfWeek = {
|
|
28
|
+
* dayOfWeek: 0
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* // will match the included days, except the two dates
|
|
32
|
+
* const intervalMatcher: DateInterval = {
|
|
33
|
+
* after: new Date(2019, 1, 2);,
|
|
34
|
+
* before: new Date(2019, 1, 5)
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* // will match the included days, including the two dates
|
|
38
|
+
* const rangeMatcher: DateRange = {
|
|
39
|
+
* from: new Date(2019, 1, 2);,
|
|
40
|
+
* to: new Date(2019, 1, 5)
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // will match when the function return true
|
|
44
|
+
* const functionMatcher: Matcher = (day: Date) => {
|
|
45
|
+
* return (new Date()).getMonth() === 2 // match when month is March
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @see [[isMatch]]
|
|
50
|
+
*
|
|
51
|
+
* */
|
|
52
|
+
export type Matcher =
|
|
53
|
+
| boolean
|
|
54
|
+
| ((date: Date) => boolean)
|
|
55
|
+
| Date
|
|
56
|
+
| Date[]
|
|
57
|
+
| DateRange
|
|
58
|
+
| DateBefore
|
|
59
|
+
| DateAfter
|
|
60
|
+
| DateInterval
|
|
61
|
+
| DayOfWeek;
|
|
62
|
+
|
|
63
|
+
/** A matcher to match a day falling after the specified date, with the date not included. */
|
|
64
|
+
export type DateAfter = { after: Date };
|
|
65
|
+
|
|
66
|
+
/** A matcher to match a day falling before the specified date, with the date not included. */
|
|
67
|
+
export type DateBefore = { before: Date };
|
|
68
|
+
|
|
69
|
+
/** A matcher to match a day falling before and after two dates, where the dates are not included. */
|
|
70
|
+
export type DateInterval = { before: Date; after: Date };
|
|
71
|
+
|
|
72
|
+
/** A matcher to match a range of dates. The range can be open. Differently from [[DateInterval]], the dates here are included. */
|
|
73
|
+
export type DateRange = { from: Date | undefined; to?: Date | undefined };
|
|
74
|
+
|
|
75
|
+
/** A matcher to match a date being one of the specified days of the week (`0-7`, where `0` is Sunday). */
|
|
76
|
+
export type DayOfWeek = { dayOfWeek: number[] };
|
|
77
|
+
|
|
78
|
+
/** Returns true if `matcher` is of type [[DateInterval]]. */
|
|
79
|
+
export function isDateInterval(matcher: unknown): matcher is DateInterval {
|
|
80
|
+
return Boolean(
|
|
81
|
+
matcher &&
|
|
82
|
+
typeof matcher === 'object' &&
|
|
83
|
+
'before' in matcher &&
|
|
84
|
+
'after' in matcher
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Returns true if `value` is a [[DateRange]] type. */
|
|
89
|
+
export function isDateRange(value: unknown): value is DateRange {
|
|
90
|
+
return Boolean(value && typeof value === 'object' && 'from' in value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Returns true if `value` is of type [[DateAfter]]. */
|
|
94
|
+
export function isDateAfterType(value: unknown): value is DateAfter {
|
|
95
|
+
return Boolean(value && typeof value === 'object' && 'after' in value);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Returns true if `value` is of type [[DateBefore]]. */
|
|
99
|
+
export function isDateBeforeType(value: unknown): value is DateBefore {
|
|
100
|
+
return Boolean(value && typeof value === 'object' && 'before' in value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Returns true if `value` is a [[DayOfWeek]] type. */
|
|
104
|
+
export function isDayOfWeekType(value: unknown): value is DayOfWeek {
|
|
105
|
+
return Boolean(value && typeof value === 'object' && 'dayOfWeek' in value);
|
|
106
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Matcher } from './Matchers';
|
|
2
|
+
|
|
3
|
+
/** A _modifier_ represents different styles or states of a day displayed in the calendar. */
|
|
4
|
+
export type Modifier = string;
|
|
5
|
+
|
|
6
|
+
/** The modifiers used by DayPicker. */
|
|
7
|
+
export type Modifiers = CustomModifiers & InternalModifiers;
|
|
8
|
+
|
|
9
|
+
/** The name of the modifiers that are used internally by DayPicker. */
|
|
10
|
+
export enum InternalModifier {
|
|
11
|
+
Outside = 'outside',
|
|
12
|
+
/** Name of the modifier applied to the disabled days, using the `disabled` prop. */
|
|
13
|
+
Disabled = 'disabled',
|
|
14
|
+
/** Name of the modifier applied to the selected days using the `selected` prop). */
|
|
15
|
+
Selected = 'selected',
|
|
16
|
+
/** Name of the modifier applied to the hidden days using the `hidden` prop). */
|
|
17
|
+
Hidden = 'hidden',
|
|
18
|
+
/** Name of the modifier applied to the day specified using the `today` prop). */
|
|
19
|
+
Today = 'today',
|
|
20
|
+
/** The modifier applied to the day starting a selected range, when in range selection mode. */
|
|
21
|
+
RangeStart = 'range_start',
|
|
22
|
+
/** The modifier applied to the day ending a selected range, when in range selection mode. */
|
|
23
|
+
RangeEnd = 'range_end',
|
|
24
|
+
/** The modifier applied to the days between the start and the end of a selected range, when in range selection mode. */
|
|
25
|
+
RangeMiddle = 'range_middle'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Map of matchers used for the internal modifiers. */
|
|
29
|
+
export type InternalModifiers = Record<InternalModifier, Matcher[]>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Active modifiers are those Modifiers matching a specific day.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* ```
|
|
37
|
+
* const activeModifiers: ActiveModifiers = {
|
|
38
|
+
* selected: true,
|
|
39
|
+
* customModifier: true
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* */
|
|
44
|
+
export type ActiveModifiers = Record<Modifier, true> &
|
|
45
|
+
Partial<Record<InternalModifier, true>>;
|
|
46
|
+
|
|
47
|
+
/** The style to apply to each day element matching a modifier. */
|
|
48
|
+
export type ModifiersStyles = Record<Modifier, React.CSSProperties> &
|
|
49
|
+
Partial<Record<InternalModifier, React.CSSProperties>>;
|
|
50
|
+
|
|
51
|
+
/** The classnames to assign to each day element matching a modifier. */
|
|
52
|
+
export type ModifiersClassNames = Record<Modifier, string> &
|
|
53
|
+
Partial<Record<InternalModifier, string>>;
|
|
54
|
+
|
|
55
|
+
/** The custom modifiers passed to the [[DayPickerProps.modifiers]]. */
|
|
56
|
+
export type DayModifiers = Record<Modifier, Matcher | Matcher[]>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A map of matchers used as custom modifiers by DayPicker component. This is
|
|
60
|
+
* the same as [[DayModifiers]], but it accepts only array of [[Matcher]]s.
|
|
61
|
+
*/
|
|
62
|
+
export type CustomModifiers = Record<Modifier, Matcher[]>;
|