react-day-picker 8.0.7 → 8.1.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.
- package/dist/DayPicker.d.ts +2 -5
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Caption/Caption.d.ts +2 -2
- package/dist/components/CaptionLabel/CaptionLabel.d.ts +1 -1
- package/dist/components/Day/Day.d.ts +1 -1
- package/dist/components/DayContent/DayContent.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Month/Month.d.ts +1 -1
- package/dist/components/MonthsDropdown/MonthsDropdown.d.ts +1 -1
- package/dist/components/Navigation/Navigation.d.ts +1 -1
- package/dist/components/Row/Row.d.ts +1 -1
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/WeekNumber/WeekNumber.d.ts +1 -1
- package/dist/components/YearsDropdown/YearsDropdown.d.ts +1 -1
- package/dist/contexts/DayPicker/DayPickerContext.d.ts +5 -6
- package/dist/contexts/DayPicker/useDayPicker.d.ts +3 -3
- package/dist/contexts/Focus/FocusContext.d.ts +3 -3
- package/dist/contexts/Focus/useFocusContext.d.ts +6 -1
- package/dist/contexts/Modifiers/ModifiersContext.d.ts +2 -2
- package/dist/contexts/Modifiers/useModifiers.d.ts +4 -1
- package/dist/contexts/Modifiers/utils/getInternalModifiers.d.ts +1 -1
- package/dist/contexts/Navigation/NavigationContext.d.ts +9 -10
- package/dist/contexts/Navigation/useNavigation.d.ts +6 -1
- package/dist/contexts/RootProvider.d.ts +1 -1
- package/dist/contexts/SelectMultiple/SelectMultipleContext.d.ts +3 -3
- package/dist/contexts/SelectMultiple/useSelectMultiple.d.ts +5 -1
- package/dist/contexts/SelectRange/SelectRangeContext.d.ts +3 -3
- package/dist/contexts/SelectRange/useSelectRange.d.ts +5 -1
- package/dist/contexts/SelectSingle/SelectSingleContext.d.ts +3 -3
- package/dist/contexts/SelectSingle/useSelectSingle.d.ts +5 -1
- package/dist/hooks/useActiveModifiers/useActiveModifiers.d.ts +9 -3
- package/dist/hooks/useDayEventHandlers/useDayEventHandlers.d.ts +2 -2
- package/dist/hooks/useDayRender/useDayRender.d.ts +9 -16
- package/dist/hooks/useId/index.d.ts +1 -0
- package/dist/hooks/useId/useId.d.ts +19 -0
- package/dist/hooks/useInput/useInput.d.ts +5 -5
- package/dist/hooks/useSelectedDays/useSelectedDays.d.ts +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +346 -297
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +275 -207
- package/dist/index.js.map +1 -1
- package/dist/react-day-picker.min.js +1 -1
- package/dist/style.css +13 -19
- package/dist/style.module.css +13 -19
- package/dist/types/DayPickerBase.d.ts +29 -13
- package/dist/types/DayPickerDefault.d.ts +4 -4
- package/dist/types/DayPickerMultiple.d.ts +2 -2
- package/dist/types/DayPickerRange.d.ts +2 -2
- package/dist/types/DayPickerSingle.d.ts +2 -2
- package/dist/types/Labels.d.ts +1 -1
- package/dist/types/Matchers.d.ts +10 -10
- package/dist/types/Modifiers.d.ts +3 -5
- package/package.json +20 -24
- package/src/DayPicker.tsx +13 -10
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/Caption/Caption.tsx +2 -2
- package/src/components/CaptionLabel/CaptionLabel.tsx +1 -1
- package/src/components/Day/Day.tsx +1 -1
- package/src/components/DayContent/DayContent.tsx +1 -1
- package/src/components/Dropdown/Dropdown.tsx +1 -1
- package/src/components/Month/Month.tsx +2 -3
- package/src/components/MonthsDropdown/MonthsDropdown.tsx +1 -1
- package/src/components/Navigation/Navigation.test.tsx +6 -6
- package/src/components/Navigation/Navigation.tsx +3 -3
- package/src/components/Row/Row.tsx +1 -1
- package/src/components/Table/Table.tsx +1 -1
- package/src/components/WeekNumber/WeekNumber.test.tsx +2 -4
- package/src/components/WeekNumber/WeekNumber.tsx +1 -1
- package/src/components/YearsDropdown/YearsDropdown.tsx +1 -1
- package/src/contexts/DayPicker/DayPickerContext.tsx +5 -6
- package/src/contexts/DayPicker/useDayPicker.ts +3 -3
- package/src/contexts/Focus/FocusContext.tsx +9 -5
- package/src/contexts/Focus/useFocusContext.ts +6 -1
- package/src/contexts/Modifiers/ModifiersContext.tsx +2 -2
- package/src/contexts/Modifiers/useModifiers.ts +4 -1
- package/src/contexts/Modifiers/utils/getInternalModifiers.ts +1 -1
- package/src/contexts/Navigation/NavigationContext.tsx +9 -10
- package/src/contexts/Navigation/useNavigation.ts +6 -1
- package/src/contexts/RootProvider.tsx +1 -1
- package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +3 -3
- package/src/contexts/SelectMultiple/useSelectMultiple.ts +5 -1
- package/src/contexts/SelectRange/SelectRangeContext.tsx +3 -3
- package/src/contexts/SelectRange/useSelectRange.ts +5 -1
- package/src/contexts/SelectSingle/SelectSingleContext.tsx +3 -3
- package/src/contexts/SelectSingle/useSelectSingle.ts +5 -1
- package/src/hooks/useActiveModifiers/useActiveModifiers.tsx +7 -2
- package/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx +2 -2
- package/src/hooks/useDayRender/useDayRender.test.tsx +1 -1
- package/src/hooks/useDayRender/useDayRender.tsx +6 -16
- package/src/hooks/useId/index.ts +1 -0
- package/src/hooks/useId/useId.ts +168 -0
- package/src/hooks/useInput/useInput.ts +5 -5
- package/src/hooks/useSelectedDays/useSelectedDays.ts +4 -2
- package/src/index.ts +1 -0
- package/src/style.css +13 -19
- package/src/types/DayPickerBase.ts +29 -13
- package/src/types/DayPickerDefault.ts +4 -4
- package/src/types/DayPickerMultiple.ts +2 -2
- package/src/types/DayPickerRange.ts +2 -2
- package/src/types/DayPickerSingle.ts +2 -2
- package/src/types/Labels.ts +1 -1
- package/src/types/Matchers.ts +10 -10
- package/src/types/Modifiers.ts +3 -5
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { createContext, useContext, useState, forwardRef, useEffect, useRef } from 'react';
|
|
2
3
|
import enUS from 'date-fns/locale/en-US';
|
|
3
4
|
import format from 'date-fns/format';
|
|
4
5
|
import endOfMonth from 'date-fns/endOfMonth';
|
|
@@ -26,7 +27,7 @@ import getWeeksInMonth from 'date-fns/getWeeksInMonth';
|
|
|
26
27
|
import getWeek from 'date-fns/getWeek';
|
|
27
28
|
import parse from 'date-fns/parse';
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
/******************************************************************************
|
|
30
31
|
Copyright (c) Microsoft Corporation.
|
|
31
32
|
|
|
32
33
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -74,147 +75,6 @@ function __spreadArray(to, from, pack) {
|
|
|
74
75
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function canUseDOM() {
|
|
78
|
-
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* React currently throws a warning when using useLayoutEffect on the server. To
|
|
83
|
-
* get around it, we can conditionally useEffect on the server (no-op) and
|
|
84
|
-
* useLayoutEffect in the browser. We occasionally need useLayoutEffect to
|
|
85
|
-
* ensure we don't get a render flash for certain operations, but we may also
|
|
86
|
-
* need affected components to render on the server. One example is when setting
|
|
87
|
-
* a component's descendants to retrieve their index values.
|
|
88
|
-
*
|
|
89
|
-
* Important to note that using this hook as an escape hatch will break the
|
|
90
|
-
* eslint dependency warnings unless you rename the import to `useLayoutEffect`.
|
|
91
|
-
* Use sparingly only when the effect won't effect the rendered HTML to avoid
|
|
92
|
-
* any server/client mismatch.
|
|
93
|
-
*
|
|
94
|
-
* If a useLayoutEffect is needed and the result would create a mismatch, it's
|
|
95
|
-
* likely that the component in question shouldn't be rendered on the server at
|
|
96
|
-
* all, so a better approach would be to lazily render those in a parent
|
|
97
|
-
* component after client-side hydration.
|
|
98
|
-
*
|
|
99
|
-
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
|
100
|
-
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
|
|
101
|
-
*
|
|
102
|
-
* @param effect
|
|
103
|
-
* @param deps
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
var useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? useLayoutEffect : useEffect;
|
|
107
|
-
|
|
108
|
-
/*
|
|
109
|
-
* Welcome to @reach/auto-id!
|
|
110
|
-
|
|
111
|
-
* Let's see if we can make sense of why this hook exists and its
|
|
112
|
-
* implementation.
|
|
113
|
-
*
|
|
114
|
-
* Some background:
|
|
115
|
-
* 1. Accessibility APIs rely heavily on element IDs
|
|
116
|
-
* 2. Requiring developers to put IDs on every element in Reach UI is both
|
|
117
|
-
* cumbersome and error-prone
|
|
118
|
-
* 3. With a component model, we can generate IDs for them!
|
|
119
|
-
*
|
|
120
|
-
* Solution 1: Generate random IDs.
|
|
121
|
-
*
|
|
122
|
-
* This works great as long as you don't server render your app. When React (in
|
|
123
|
-
* the client) tries to reuse the markup from the server, the IDs won't match
|
|
124
|
-
* and React will then recreate the entire DOM tree.
|
|
125
|
-
*
|
|
126
|
-
* Solution 2: Increment an integer
|
|
127
|
-
*
|
|
128
|
-
* This sounds great. Since we're rendering the exact same tree on the server
|
|
129
|
-
* and client, we can increment a counter and get a deterministic result between
|
|
130
|
-
* client and server. Also, JS integers can go up to nine-quadrillion. I'm
|
|
131
|
-
* pretty sure the tab will be closed before an app never needs
|
|
132
|
-
* 10 quadrillion IDs!
|
|
133
|
-
*
|
|
134
|
-
* Problem solved, right?
|
|
135
|
-
*
|
|
136
|
-
* Ah, but there's a catch! React's concurrent rendering makes this approach
|
|
137
|
-
* non-deterministic. While the client and server will end up with the same
|
|
138
|
-
* elements in the end, depending on suspense boundaries (and possibly some user
|
|
139
|
-
* input during the initial render) the incrementing integers won't always match
|
|
140
|
-
* up.
|
|
141
|
-
*
|
|
142
|
-
* Solution 3: Don't use IDs at all on the server; patch after first render.
|
|
143
|
-
*
|
|
144
|
-
* What we've done here is solution 2 with some tricks. With this approach, the
|
|
145
|
-
* ID returned is an empty string on the first render. This way the server and
|
|
146
|
-
* client have the same markup no matter how wild the concurrent rendering may
|
|
147
|
-
* have gotten.
|
|
148
|
-
*
|
|
149
|
-
* After the render, we patch up the components with an incremented ID. This
|
|
150
|
-
* causes a double render on any components with `useId`. Shouldn't be a problem
|
|
151
|
-
* since the components using this hook should be small, and we're only updating
|
|
152
|
-
* the ID attribute on the DOM, nothing big is happening.
|
|
153
|
-
*
|
|
154
|
-
* It doesn't have to be an incremented number, though--we could do generate
|
|
155
|
-
* random strings instead, but incrementing a number is probably the cheapest
|
|
156
|
-
* thing we can do.
|
|
157
|
-
*
|
|
158
|
-
* Additionally, we only do this patchup on the very first client render ever.
|
|
159
|
-
* Any calls to `useId` that happen dynamically in the client will be
|
|
160
|
-
* populated immediately with a value. So, we only get the double render after
|
|
161
|
-
* server hydration and never again, SO BACK OFF ALRIGHT?
|
|
162
|
-
*/
|
|
163
|
-
var serverHandoffComplete = false;
|
|
164
|
-
var id = 0;
|
|
165
|
-
|
|
166
|
-
var genId = function genId() {
|
|
167
|
-
return ++id;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* useId
|
|
171
|
-
*
|
|
172
|
-
* Autogenerate IDs to facilitate WAI-ARIA and server rendering.
|
|
173
|
-
*
|
|
174
|
-
* Note: The returned ID will initially be `null` and will update after a
|
|
175
|
-
* component mounts. Users may need to supply their own ID if they need
|
|
176
|
-
* consistent values for SSR.
|
|
177
|
-
*
|
|
178
|
-
* @see Docs https://reach.tech/auto-id
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
function useId(idFromProps) {
|
|
183
|
-
/*
|
|
184
|
-
* If this instance isn't part of the initial render, we don't have to do the
|
|
185
|
-
* double render/patch-up dance. We can just generate the ID and return it.
|
|
186
|
-
*/
|
|
187
|
-
var initialId = idFromProps || (serverHandoffComplete ? genId() : null);
|
|
188
|
-
|
|
189
|
-
var _React$useState = useState(initialId),
|
|
190
|
-
id = _React$useState[0],
|
|
191
|
-
setId = _React$useState[1];
|
|
192
|
-
|
|
193
|
-
useIsomorphicLayoutEffect(function () {
|
|
194
|
-
if (id === null) {
|
|
195
|
-
/*
|
|
196
|
-
* Patch the ID after render. We do this in `useLayoutEffect` to avoid any
|
|
197
|
-
* rendering flicker, though it'll make the first render slower (unlikely
|
|
198
|
-
* to matter, but you're welcome to measure your app and let us know if
|
|
199
|
-
* it's a problem).
|
|
200
|
-
*/
|
|
201
|
-
setId(genId());
|
|
202
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
203
|
-
|
|
204
|
-
}, []);
|
|
205
|
-
useEffect(function () {
|
|
206
|
-
if (serverHandoffComplete === false) {
|
|
207
|
-
/*
|
|
208
|
-
* Flag all future uses of `useId` to skip the update dance. This is in
|
|
209
|
-
* `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
|
|
210
|
-
* accidentally bail out of the patch-up dance prematurely.
|
|
211
|
-
*/
|
|
212
|
-
serverHandoffComplete = true;
|
|
213
|
-
}
|
|
214
|
-
}, []);
|
|
215
|
-
return id != null ? String(id) : undefined;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
78
|
/**
|
|
219
79
|
* The name of the default CSS classes.
|
|
220
80
|
*/
|
|
@@ -425,16 +285,15 @@ function parseFromToProps(props) {
|
|
|
425
285
|
}
|
|
426
286
|
|
|
427
287
|
/**
|
|
428
|
-
* The DayPicker
|
|
288
|
+
* The DayPicker context shares the props passed to DayPicker within internal
|
|
429
289
|
* and custom components. It is used to set the default values and perform
|
|
430
290
|
* one-time calculations required to render the days.
|
|
431
291
|
*
|
|
432
|
-
*
|
|
433
|
-
* using custom components.
|
|
292
|
+
* Access to this context from the {@link useDayPicker} hook.
|
|
434
293
|
*/
|
|
435
294
|
var DayPickerContext = createContext(undefined);
|
|
436
295
|
/**
|
|
437
|
-
* The provider for the
|
|
296
|
+
* The provider for the {@link DayPickerContext}, assigning the defaults from the
|
|
438
297
|
* initial DayPicker props.
|
|
439
298
|
*/
|
|
440
299
|
function DayPickerProvider(props) {
|
|
@@ -497,14 +356,14 @@ function DayPickerProvider(props) {
|
|
|
497
356
|
today: (_d = initialProps.today) !== null && _d !== void 0 ? _d : defaults.today,
|
|
498
357
|
weekStartsOn: initialProps.weekStartsOn
|
|
499
358
|
};
|
|
500
|
-
return (
|
|
359
|
+
return (React__default.createElement(DayPickerContext.Provider, { value: value }, props.children));
|
|
501
360
|
}
|
|
502
361
|
|
|
503
362
|
/**
|
|
504
|
-
* Hook to access the
|
|
363
|
+
* Hook to access the {@link DayPickerContextValue}.
|
|
505
364
|
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
365
|
+
* Use the DayPicker context to access to the props passed to DayPicker inside
|
|
366
|
+
* internal or custom components.
|
|
508
367
|
*/
|
|
509
368
|
function useDayPicker() {
|
|
510
369
|
var context = useContext(DayPickerContext);
|
|
@@ -517,15 +376,15 @@ function useDayPicker() {
|
|
|
517
376
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
518
377
|
function CaptionLabel(props) {
|
|
519
378
|
var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, formatCaption = _a.formatters.formatCaption;
|
|
520
|
-
return (
|
|
379
|
+
return (React__default.createElement("h2", { className: classNames.caption_label, style: styles.caption_label, "aria-live": "polite", "aria-atomic": "true", id: props.id }, formatCaption(props.displayMonth, { locale: locale })));
|
|
521
380
|
}
|
|
522
381
|
|
|
523
382
|
/**
|
|
524
383
|
* Render the icon in the styled drop-down.
|
|
525
384
|
*/
|
|
526
385
|
function IconDropdown(props) {
|
|
527
|
-
return (
|
|
528
|
-
|
|
386
|
+
return (React__default.createElement("svg", __assign({ width: "8px", height: "8px", viewBox: "0 0 120 120", "data-testid": "iconDropdown" }, props),
|
|
387
|
+
React__default.createElement("path", { d: "M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
529
388
|
}
|
|
530
389
|
|
|
531
390
|
/**
|
|
@@ -537,12 +396,12 @@ function Dropdown(props) {
|
|
|
537
396
|
var onChange = props.onChange, value = props.value, children = props.children, caption = props.caption, className = props.className, style = props.style;
|
|
538
397
|
var dayPicker = useDayPicker();
|
|
539
398
|
var IconDropdownComponent = (_b = (_a = dayPicker.components) === null || _a === void 0 ? void 0 : _a.IconDropdown) !== null && _b !== void 0 ? _b : IconDropdown;
|
|
540
|
-
return (
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
399
|
+
return (React__default.createElement("div", { className: className, style: style },
|
|
400
|
+
React__default.createElement("span", { className: dayPicker.classNames.vhidden }, props['aria-label']),
|
|
401
|
+
React__default.createElement("select", { "aria-label": props['aria-label'], className: dayPicker.classNames.dropdown, style: dayPicker.styles.dropdown, value: value, onChange: onChange }, children),
|
|
402
|
+
React__default.createElement("div", { className: dayPicker.classNames.caption_label, style: dayPicker.styles.caption_label, "aria-hidden": "true" },
|
|
544
403
|
caption,
|
|
545
|
-
|
|
404
|
+
React__default.createElement(IconDropdownComponent, { className: dayPicker.classNames.dropdown_icon, style: dayPicker.styles.dropdown_icon }))));
|
|
546
405
|
}
|
|
547
406
|
|
|
548
407
|
/** Render the dropdown to navigate between months. */
|
|
@@ -551,9 +410,9 @@ function MonthsDropdown(props) {
|
|
|
551
410
|
var _b = useDayPicker(), fromDate = _b.fromDate, toDate = _b.toDate, styles = _b.styles, locale = _b.locale, formatMonthCaption = _b.formatters.formatMonthCaption, classNames = _b.classNames, components = _b.components, labelMonthDropdown = _b.labels.labelMonthDropdown;
|
|
552
411
|
// Dropdown should appear only when both from/toDate is set
|
|
553
412
|
if (!fromDate)
|
|
554
|
-
return
|
|
413
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
555
414
|
if (!toDate)
|
|
556
|
-
return
|
|
415
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
557
416
|
var dropdownMonths = [];
|
|
558
417
|
if (isSameYear(fromDate, toDate)) {
|
|
559
418
|
// only display the months included in the range
|
|
@@ -575,7 +434,7 @@ function MonthsDropdown(props) {
|
|
|
575
434
|
props.onChange(newMonth);
|
|
576
435
|
};
|
|
577
436
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
578
|
-
return (
|
|
437
|
+
return (React__default.createElement(DropdownComponent, { "aria-label": labelMonthDropdown(), className: classNames.dropdown_month, style: styles.dropdown_month, onChange: handleChange, value: props.displayMonth.getMonth(), caption: formatMonthCaption(props.displayMonth, { locale: locale }) }, dropdownMonths.map(function (m) { return (React__default.createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale: locale }))); })));
|
|
579
438
|
}
|
|
580
439
|
|
|
581
440
|
/**
|
|
@@ -589,9 +448,9 @@ function YearsDropdown(props) {
|
|
|
589
448
|
var years = [];
|
|
590
449
|
// Dropdown should appear only when both from/toDate is set
|
|
591
450
|
if (!fromDate)
|
|
592
|
-
return
|
|
451
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
593
452
|
if (!toDate)
|
|
594
|
-
return
|
|
453
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
595
454
|
var fromYear = fromDate.getFullYear();
|
|
596
455
|
var toYear = toDate.getFullYear();
|
|
597
456
|
for (var year = fromYear; year <= toYear; year++) {
|
|
@@ -602,7 +461,7 @@ function YearsDropdown(props) {
|
|
|
602
461
|
props.onChange(newMonth);
|
|
603
462
|
};
|
|
604
463
|
var DropdownComponent = (_a = components === null || components === void 0 ? void 0 : components.Dropdown) !== null && _a !== void 0 ? _a : Dropdown;
|
|
605
|
-
return (
|
|
464
|
+
return (React__default.createElement(DropdownComponent, { "aria-label": labelYearDropdown(), className: classNames.dropdown_year, style: styles.dropdown_year, onChange: handleChange, value: displayMonth.getFullYear(), caption: formatYearCaption(displayMonth, { locale: locale }) }, years.map(function (year) { return (React__default.createElement("option", { key: year.getFullYear(), value: year.getFullYear() }, formatYearCaption(year, { locale: locale }))); })));
|
|
606
465
|
}
|
|
607
466
|
|
|
608
467
|
/**
|
|
@@ -727,12 +586,11 @@ function getPreviousMonth(startingMonth, options) {
|
|
|
727
586
|
}
|
|
728
587
|
|
|
729
588
|
/**
|
|
730
|
-
* The Navigation context shares details
|
|
731
|
-
*
|
|
732
|
-
* Access this context from the [[useNavigation]] hook.
|
|
589
|
+
* The Navigation context shares details and methods to navigate the months in DayPicker.
|
|
590
|
+
* Access this context from the {@link useNavigation} hook.
|
|
733
591
|
*/
|
|
734
592
|
var NavigationContext = createContext(undefined);
|
|
735
|
-
/** Provides the values for the
|
|
593
|
+
/** Provides the values for the {@link NavigationContext}. */
|
|
736
594
|
function NavigationProvider(props) {
|
|
737
595
|
var dayPicker = useDayPicker();
|
|
738
596
|
var _a = useNavigationState(), currentMonth = _a[0], goToMonth = _a[1];
|
|
@@ -764,10 +622,15 @@ function NavigationProvider(props) {
|
|
|
764
622
|
nextMonth: nextMonth,
|
|
765
623
|
isDateDisplayed: isDateDisplayed
|
|
766
624
|
};
|
|
767
|
-
return (
|
|
625
|
+
return (React__default.createElement(NavigationContext.Provider, { value: value }, props.children));
|
|
768
626
|
}
|
|
769
627
|
|
|
770
|
-
/**
|
|
628
|
+
/**
|
|
629
|
+
* Hook to access the {@link NavigationContextValue}. Use this hook to navigate
|
|
630
|
+
* between months or years in DayPicker.
|
|
631
|
+
*
|
|
632
|
+
* This hook is meant to be used inside internal or custom components.
|
|
633
|
+
*/
|
|
771
634
|
function useNavigation() {
|
|
772
635
|
var context = useContext(NavigationContext);
|
|
773
636
|
if (!context) {
|
|
@@ -788,27 +651,27 @@ function CaptionDropdowns(props) {
|
|
|
788
651
|
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(newMonth);
|
|
789
652
|
};
|
|
790
653
|
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
791
|
-
var captionLabel = (
|
|
792
|
-
return (
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
654
|
+
var captionLabel = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
655
|
+
return (React__default.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
|
|
656
|
+
React__default.createElement("div", { className: classNames.vhidden }, captionLabel),
|
|
657
|
+
React__default.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth }),
|
|
658
|
+
React__default.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: props.displayMonth })));
|
|
796
659
|
}
|
|
797
660
|
|
|
798
661
|
/**
|
|
799
662
|
* Render the "previous month" button in the navigation.
|
|
800
663
|
*/
|
|
801
664
|
function IconLeft(props) {
|
|
802
|
-
return (
|
|
803
|
-
|
|
665
|
+
return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
666
|
+
React__default.createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
|
|
804
667
|
}
|
|
805
668
|
|
|
806
669
|
/**
|
|
807
670
|
* Render the "next month" button in the navigation.
|
|
808
671
|
*/
|
|
809
672
|
function IconRight(props) {
|
|
810
|
-
return (
|
|
811
|
-
|
|
673
|
+
return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props),
|
|
674
|
+
React__default.createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
|
|
812
675
|
}
|
|
813
676
|
|
|
814
677
|
/**
|
|
@@ -825,7 +688,7 @@ var Button = forwardRef(function (props, ref) {
|
|
|
825
688
|
if (props.style) {
|
|
826
689
|
Object.assign(style, props.style);
|
|
827
690
|
}
|
|
828
|
-
return (
|
|
691
|
+
return (React__default.createElement("button", __assign({}, props, { ref: ref, type: "button", className: className, style: style })));
|
|
829
692
|
});
|
|
830
693
|
|
|
831
694
|
/** A component rendering the navigation buttons or the drop-downs. */
|
|
@@ -833,7 +696,7 @@ function Navigation(props) {
|
|
|
833
696
|
var _a, _b;
|
|
834
697
|
var _c = useDayPicker(), dir = _c.dir, locale = _c.locale, classNames = _c.classNames, styles = _c.styles, _d = _c.labels, labelPrevious = _d.labelPrevious, labelNext = _d.labelNext, components = _c.components;
|
|
835
698
|
if (!props.nextMonth && !props.previousMonth) {
|
|
836
|
-
return
|
|
699
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
837
700
|
}
|
|
838
701
|
var previousLabel = labelPrevious(props.previousMonth, { locale: locale });
|
|
839
702
|
var previousClassName = [
|
|
@@ -847,9 +710,9 @@ function Navigation(props) {
|
|
|
847
710
|
].join(' ');
|
|
848
711
|
var IconRightComponent = (_a = components === null || components === void 0 ? void 0 : components.IconRight) !== null && _a !== void 0 ? _a : IconRight;
|
|
849
712
|
var IconLeftComponent = (_b = components === null || components === void 0 ? void 0 : components.IconLeft) !== null && _b !== void 0 ? _b : IconLeft;
|
|
850
|
-
return (
|
|
851
|
-
!props.hidePrevious && (
|
|
852
|
-
!props.hideNext && (
|
|
713
|
+
return (React__default.createElement("div", { className: classNames.nav, style: styles.nav },
|
|
714
|
+
!props.hidePrevious && (React__default.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !props.previousMonth, onClick: props.onPreviousClick }, dir === 'rtl' ? (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })))),
|
|
715
|
+
!props.hideNext && (React__default.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !props.nextMonth, onClick: props.onNextClick }, dir === 'rtl' ? (React__default.createElement(IconLeftComponent, { className: classNames.nav_icon, style: styles.nav_icon })) : (React__default.createElement(IconRightComponent, { className: classNames.nav_icon, style: styles.nav_icon }))))));
|
|
853
716
|
}
|
|
854
717
|
|
|
855
718
|
/**
|
|
@@ -883,15 +746,15 @@ function CaptionNavigation(props) {
|
|
|
883
746
|
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
|
|
884
747
|
};
|
|
885
748
|
var CaptionLabelComponent = (_b = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _b !== void 0 ? _b : CaptionLabel;
|
|
886
|
-
var captionLabel = (
|
|
887
|
-
return (
|
|
749
|
+
var captionLabel = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
750
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
888
751
|
captionLabel,
|
|
889
|
-
|
|
752
|
+
React__default.createElement(Navigation, { displayMonth: props.displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })));
|
|
890
753
|
}
|
|
891
754
|
|
|
892
755
|
/**
|
|
893
756
|
* Render the caption of a month. The caption has a different layout when
|
|
894
|
-
* setting the
|
|
757
|
+
* setting the {@link DayPickerBase.captionLayout} prop.
|
|
895
758
|
*/
|
|
896
759
|
function Caption(props) {
|
|
897
760
|
var _a;
|
|
@@ -899,25 +762,25 @@ function Caption(props) {
|
|
|
899
762
|
var CaptionLabelComponent = (_a = components === null || components === void 0 ? void 0 : components.CaptionLabel) !== null && _a !== void 0 ? _a : CaptionLabel;
|
|
900
763
|
var caption;
|
|
901
764
|
if (disableNavigation) {
|
|
902
|
-
caption = (
|
|
765
|
+
caption = (React__default.createElement(CaptionLabelComponent, { id: props.id, displayMonth: props.displayMonth }));
|
|
903
766
|
}
|
|
904
767
|
else if (captionLayout === 'dropdown') {
|
|
905
|
-
caption = (
|
|
768
|
+
caption = (React__default.createElement(CaptionDropdowns, { displayMonth: props.displayMonth, id: props.id }));
|
|
906
769
|
}
|
|
907
770
|
else {
|
|
908
|
-
caption = (
|
|
771
|
+
caption = (React__default.createElement(CaptionNavigation, { displayMonth: props.displayMonth, id: props.id }));
|
|
909
772
|
}
|
|
910
|
-
return (
|
|
773
|
+
return (React__default.createElement("div", { className: classNames.caption, style: styles.caption }, caption));
|
|
911
774
|
}
|
|
912
775
|
|
|
913
776
|
/** Render the Footer component (empty as default).*/
|
|
914
777
|
function Footer() {
|
|
915
778
|
var _a = useDayPicker(), footer = _a.footer, styles = _a.styles, tfoot = _a.classNames.tfoot;
|
|
916
779
|
if (!footer)
|
|
917
|
-
return
|
|
918
|
-
return (
|
|
919
|
-
|
|
920
|
-
|
|
780
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
781
|
+
return (React__default.createElement("tfoot", { className: tfoot, style: styles.tfoot },
|
|
782
|
+
React__default.createElement("tr", null,
|
|
783
|
+
React__default.createElement("td", { colSpan: 8 }, footer))));
|
|
921
784
|
}
|
|
922
785
|
|
|
923
786
|
/**
|
|
@@ -942,12 +805,12 @@ weekStartsOn) {
|
|
|
942
805
|
function Head() {
|
|
943
806
|
var _a = useDayPicker(), classNames = _a.classNames, styles = _a.styles, showWeekNumber = _a.showWeekNumber, locale = _a.locale, weekStartsOn = _a.weekStartsOn, formatWeekdayName = _a.formatters.formatWeekdayName, labelWeekday = _a.labels.labelWeekday;
|
|
944
807
|
var weekdays = getWeekdays(locale, weekStartsOn);
|
|
945
|
-
return (
|
|
946
|
-
|
|
947
|
-
showWeekNumber && (
|
|
948
|
-
weekdays.map(function (weekday, i) { return (
|
|
949
|
-
|
|
950
|
-
|
|
808
|
+
return (React__default.createElement("thead", { style: styles.head, className: classNames.head },
|
|
809
|
+
React__default.createElement("tr", { style: styles.head_row, className: classNames.head_row },
|
|
810
|
+
showWeekNumber && (React__default.createElement("th", { scope: "col", style: styles.head_cell, className: classNames.head_cell })),
|
|
811
|
+
weekdays.map(function (weekday, i) { return (React__default.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell },
|
|
812
|
+
React__default.createElement("span", { "aria-hidden": true }, formatWeekdayName(weekday, { locale: locale })),
|
|
813
|
+
React__default.createElement("span", { className: classNames.vhidden }, labelWeekday(weekday, { locale: locale })))); }))));
|
|
951
814
|
}
|
|
952
815
|
|
|
953
816
|
/**
|
|
@@ -955,12 +818,12 @@ function Head() {
|
|
|
955
818
|
*/
|
|
956
819
|
function DayContent(props) {
|
|
957
820
|
var _a = useDayPicker(), locale = _a.locale, classNames = _a.classNames, styles = _a.styles, labelDay = _a.labels.labelDay, formatDay = _a.formatters.formatDay;
|
|
958
|
-
return (
|
|
959
|
-
|
|
960
|
-
|
|
821
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
822
|
+
React__default.createElement("span", { "aria-hidden": "true" }, formatDay(props.date, { locale: locale })),
|
|
823
|
+
React__default.createElement("span", { className: classNames.vhidden, style: styles.vhidden }, labelDay(props.date, props.activeModifiers, { locale: locale }))));
|
|
961
824
|
}
|
|
962
825
|
|
|
963
|
-
/** Returns true when the props are of type
|
|
826
|
+
/** Returns true when the props are of type {@link DayPickerMultipleProps}. */
|
|
964
827
|
function isDayPickerMultiple(props) {
|
|
965
828
|
return props.mode === 'multiple';
|
|
966
829
|
}
|
|
@@ -969,10 +832,10 @@ function isDayPickerMultiple(props) {
|
|
|
969
832
|
* The SelectMultiple context shares details about the selected days when in
|
|
970
833
|
* multiple selection mode.
|
|
971
834
|
*
|
|
972
|
-
* Access this context from the
|
|
835
|
+
* Access this context from the {@link useSelectMultiple} hook.
|
|
973
836
|
*/
|
|
974
837
|
var SelectMultipleContext = createContext(undefined);
|
|
975
|
-
/** Provides the values for the
|
|
838
|
+
/** Provides the values for the {@link SelectMultipleContext}. */
|
|
976
839
|
function SelectMultipleProvider(props) {
|
|
977
840
|
if (!isDayPickerMultiple(props.initialProps)) {
|
|
978
841
|
var emptyContextValue = {
|
|
@@ -981,9 +844,9 @@ function SelectMultipleProvider(props) {
|
|
|
981
844
|
disabled: []
|
|
982
845
|
}
|
|
983
846
|
};
|
|
984
|
-
return (
|
|
847
|
+
return (React__default.createElement(SelectMultipleContext.Provider, { value: emptyContextValue }, props.children));
|
|
985
848
|
}
|
|
986
|
-
return (
|
|
849
|
+
return (React__default.createElement(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
987
850
|
}
|
|
988
851
|
function SelectMultipleProviderInternal(_a) {
|
|
989
852
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -1028,10 +891,14 @@ function SelectMultipleProviderInternal(_a) {
|
|
|
1028
891
|
onDayClick: onDayClick,
|
|
1029
892
|
modifiers: modifiers
|
|
1030
893
|
};
|
|
1031
|
-
return (
|
|
894
|
+
return (React__default.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
|
|
1032
895
|
}
|
|
1033
896
|
|
|
1034
|
-
/**
|
|
897
|
+
/**
|
|
898
|
+
* Hook to access the {@link SelectMultipleContextValue}.
|
|
899
|
+
*
|
|
900
|
+
* This hook is meant to be used inside internal or custom components.
|
|
901
|
+
*/
|
|
1035
902
|
function useSelectMultiple() {
|
|
1036
903
|
var context = useContext(SelectMultipleContext);
|
|
1037
904
|
if (!context) {
|
|
@@ -1040,7 +907,7 @@ function useSelectMultiple() {
|
|
|
1040
907
|
return context;
|
|
1041
908
|
}
|
|
1042
909
|
|
|
1043
|
-
/** Returns true when the props are of type
|
|
910
|
+
/** Returns true when the props are of type {@link DayPickerRangeProps}. */
|
|
1044
911
|
function isDayPickerRange(props) {
|
|
1045
912
|
return props.mode === 'range';
|
|
1046
913
|
}
|
|
@@ -1084,10 +951,10 @@ function addToRange(day, range) {
|
|
|
1084
951
|
* The SelectRange context shares details about the selected days when in
|
|
1085
952
|
* range selection mode.
|
|
1086
953
|
*
|
|
1087
|
-
* Access this context from the
|
|
954
|
+
* Access this context from the {@link useSelectRange} hook.
|
|
1088
955
|
*/
|
|
1089
956
|
var SelectRangeContext = createContext(undefined);
|
|
1090
|
-
/** Provides the values for the
|
|
957
|
+
/** Provides the values for the {@link SelectRangeProvider}. */
|
|
1091
958
|
function SelectRangeProvider(props) {
|
|
1092
959
|
if (!isDayPickerRange(props.initialProps)) {
|
|
1093
960
|
var emptyContextValue = {
|
|
@@ -1099,9 +966,9 @@ function SelectRangeProvider(props) {
|
|
|
1099
966
|
disabled: []
|
|
1100
967
|
}
|
|
1101
968
|
};
|
|
1102
|
-
return (
|
|
969
|
+
return (React__default.createElement(SelectRangeContext.Provider, { value: emptyContextValue }, props.children));
|
|
1103
970
|
}
|
|
1104
|
-
return (
|
|
971
|
+
return (React__default.createElement(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
1105
972
|
}
|
|
1106
973
|
function SelectRangeProviderInternal(_a) {
|
|
1107
974
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -1162,10 +1029,14 @@ function SelectRangeProviderInternal(_a) {
|
|
|
1162
1029
|
differenceInCalendarDays(date, selectedFrom) >= max));
|
|
1163
1030
|
});
|
|
1164
1031
|
}
|
|
1165
|
-
return (
|
|
1032
|
+
return (React__default.createElement(SelectRangeContext.Provider, { value: { selected: selected, onDayClick: onDayClick, modifiers: modifiers } }, children));
|
|
1166
1033
|
}
|
|
1167
1034
|
|
|
1168
|
-
/**
|
|
1035
|
+
/**
|
|
1036
|
+
* Hook to access the {@link SelectRangeContextValue}.
|
|
1037
|
+
*
|
|
1038
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1039
|
+
*/
|
|
1169
1040
|
function useSelectRange() {
|
|
1170
1041
|
var context = useContext(SelectRangeContext);
|
|
1171
1042
|
if (!context) {
|
|
@@ -1218,7 +1089,7 @@ var InternalModifier;
|
|
|
1218
1089
|
})(InternalModifier || (InternalModifier = {}));
|
|
1219
1090
|
|
|
1220
1091
|
var Selected = InternalModifier.Selected, Disabled = InternalModifier.Disabled, Hidden = InternalModifier.Hidden, Today = InternalModifier.Today, RangeEnd = InternalModifier.RangeEnd, RangeMiddle = InternalModifier.RangeMiddle, RangeStart = InternalModifier.RangeStart, Outside = InternalModifier.Outside;
|
|
1221
|
-
/** Return the
|
|
1092
|
+
/** Return the {@link InternalModifiers} from the DayPicker and select contexts. */
|
|
1222
1093
|
function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
|
|
1223
1094
|
var _a;
|
|
1224
1095
|
var internalModifiers = (_a = {},
|
|
@@ -1249,9 +1120,9 @@ function getInternalModifiers(dayPicker, selectMultiple, selectRange) {
|
|
|
1249
1120
|
return internalModifiers;
|
|
1250
1121
|
}
|
|
1251
1122
|
|
|
1252
|
-
/** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use
|
|
1123
|
+
/** The Modifiers context store the modifiers used in DayPicker. To access the value of this context, use {@link useModifiers}. */
|
|
1253
1124
|
var ModifiersContext = createContext(undefined);
|
|
1254
|
-
/** Provide the value for the
|
|
1125
|
+
/** Provide the value for the {@link ModifiersContext}. */
|
|
1255
1126
|
function ModifiersProvider(props) {
|
|
1256
1127
|
var dayPicker = useDayPicker();
|
|
1257
1128
|
var selectMultiple = useSelectMultiple();
|
|
@@ -1259,13 +1130,16 @@ function ModifiersProvider(props) {
|
|
|
1259
1130
|
var internalModifiers = getInternalModifiers(dayPicker, selectMultiple, selectRange);
|
|
1260
1131
|
var customModifiers = getCustomModifiers(dayPicker.modifiers);
|
|
1261
1132
|
var modifiers = __assign(__assign({}, internalModifiers), customModifiers);
|
|
1262
|
-
return (
|
|
1133
|
+
return (React__default.createElement(ModifiersContext.Provider, { value: modifiers }, props.children));
|
|
1263
1134
|
}
|
|
1264
1135
|
|
|
1265
1136
|
/**
|
|
1266
1137
|
* Return the modifiers used by DayPicker.
|
|
1267
1138
|
*
|
|
1268
|
-
*
|
|
1139
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1140
|
+
* Requires to be wrapped into {@link ModifiersProvider}.
|
|
1141
|
+
*
|
|
1142
|
+
*/
|
|
1269
1143
|
function useModifiers() {
|
|
1270
1144
|
var context = useContext(ModifiersContext);
|
|
1271
1145
|
if (!context) {
|
|
@@ -1274,26 +1148,26 @@ function useModifiers() {
|
|
|
1274
1148
|
return context;
|
|
1275
1149
|
}
|
|
1276
1150
|
|
|
1277
|
-
/** Returns true if `matcher` is of type
|
|
1151
|
+
/** Returns true if `matcher` is of type {@link DateInterval}. */
|
|
1278
1152
|
function isDateInterval(matcher) {
|
|
1279
1153
|
return Boolean(matcher &&
|
|
1280
1154
|
typeof matcher === 'object' &&
|
|
1281
1155
|
'before' in matcher &&
|
|
1282
1156
|
'after' in matcher);
|
|
1283
1157
|
}
|
|
1284
|
-
/** Returns true if `value` is a
|
|
1158
|
+
/** Returns true if `value` is a {@link DateRange} type. */
|
|
1285
1159
|
function isDateRange(value) {
|
|
1286
1160
|
return Boolean(value && typeof value === 'object' && 'from' in value);
|
|
1287
1161
|
}
|
|
1288
|
-
/** Returns true if `value` is of type
|
|
1162
|
+
/** Returns true if `value` is of type {@link DateAfter}. */
|
|
1289
1163
|
function isDateAfterType(value) {
|
|
1290
1164
|
return Boolean(value && typeof value === 'object' && 'after' in value);
|
|
1291
1165
|
}
|
|
1292
|
-
/** Returns true if `value` is of type
|
|
1166
|
+
/** Returns true if `value` is of type {@link DateBefore}. */
|
|
1293
1167
|
function isDateBeforeType(value) {
|
|
1294
1168
|
return Boolean(value && typeof value === 'object' && 'before' in value);
|
|
1295
1169
|
}
|
|
1296
|
-
/** Returns true if `value` is a
|
|
1170
|
+
/** Returns true if `value` is a {@link DayOfWeek} type. */
|
|
1297
1171
|
function isDayOfWeekType(value) {
|
|
1298
1172
|
return Boolean(value && typeof value === 'object' && 'dayOfWeek' in value);
|
|
1299
1173
|
}
|
|
@@ -1437,16 +1311,17 @@ function getInitialFocusTarget(displayMonths, modifiers) {
|
|
|
1437
1311
|
/**
|
|
1438
1312
|
* The Focus context shares details about the focused day for the keyboard
|
|
1439
1313
|
*
|
|
1440
|
-
* Access this context from the
|
|
1314
|
+
* Access this context from the {@link useFocusContext} hook.
|
|
1441
1315
|
*/
|
|
1442
1316
|
var FocusContext = createContext(undefined);
|
|
1443
|
-
/** The provider for the
|
|
1317
|
+
/** The provider for the {@link FocusContext}. */
|
|
1444
1318
|
function FocusProvider(props) {
|
|
1445
1319
|
var navigation = useNavigation();
|
|
1446
1320
|
var modifiers = useModifiers();
|
|
1447
1321
|
var _a = useState(), focusedDay = _a[0], setFocusedDay = _a[1];
|
|
1448
1322
|
var _b = useState(), lastFocused = _b[0], setLastFocused = _b[1];
|
|
1449
1323
|
var initialFocusTarget = getInitialFocusTarget(navigation.displayMonths, modifiers);
|
|
1324
|
+
var weekStartsOn = useDayPicker().weekStartsOn;
|
|
1450
1325
|
// TODO: cleanup and test obscure code below
|
|
1451
1326
|
var focusTarget = (focusedDay !== null && focusedDay !== void 0 ? focusedDay : (lastFocused && navigation.isDateDisplayed(lastFocused)))
|
|
1452
1327
|
? lastFocused
|
|
@@ -1489,14 +1364,14 @@ function FocusProvider(props) {
|
|
|
1489
1364
|
var focusStartOfWeek = function () {
|
|
1490
1365
|
if (!focusedDay)
|
|
1491
1366
|
return;
|
|
1492
|
-
var dayToFocus = startOfWeek(focusedDay);
|
|
1367
|
+
var dayToFocus = startOfWeek(focusedDay, { weekStartsOn: weekStartsOn });
|
|
1493
1368
|
navigation.goToDate(dayToFocus, focusedDay);
|
|
1494
1369
|
focus(dayToFocus);
|
|
1495
1370
|
};
|
|
1496
1371
|
var focusEndOfWeek = function () {
|
|
1497
1372
|
if (!focusedDay)
|
|
1498
1373
|
return;
|
|
1499
|
-
var dayToFocus = endOfWeek(focusedDay);
|
|
1374
|
+
var dayToFocus = endOfWeek(focusedDay, { weekStartsOn: weekStartsOn });
|
|
1500
1375
|
navigation.goToDate(dayToFocus, focusedDay);
|
|
1501
1376
|
focus(dayToFocus);
|
|
1502
1377
|
};
|
|
@@ -1544,10 +1419,15 @@ function FocusProvider(props) {
|
|
|
1544
1419
|
focusStartOfWeek: focusStartOfWeek,
|
|
1545
1420
|
focusEndOfWeek: focusEndOfWeek
|
|
1546
1421
|
};
|
|
1547
|
-
return (
|
|
1422
|
+
return (React__default.createElement(FocusContext.Provider, { value: value }, props.children));
|
|
1548
1423
|
}
|
|
1549
1424
|
|
|
1550
|
-
/**
|
|
1425
|
+
/**
|
|
1426
|
+
* Hook to access the {@link FocusContextValue}. Use this hook to handle the
|
|
1427
|
+
* focus state of the elements.
|
|
1428
|
+
*
|
|
1429
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1430
|
+
*/
|
|
1551
1431
|
function useFocusContext() {
|
|
1552
1432
|
var context = useContext(FocusContext);
|
|
1553
1433
|
if (!context) {
|
|
@@ -1559,17 +1439,23 @@ function useFocusContext() {
|
|
|
1559
1439
|
/**
|
|
1560
1440
|
* Return the active modifiers for the specified day.
|
|
1561
1441
|
*
|
|
1442
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1443
|
+
*
|
|
1562
1444
|
* @param day
|
|
1563
|
-
* @param displayMonth
|
|
1564
|
-
* `date`, the day is an "outside day".
|
|
1445
|
+
* @param displayMonth
|
|
1565
1446
|
*/
|
|
1566
|
-
function useActiveModifiers(day,
|
|
1447
|
+
function useActiveModifiers(day,
|
|
1448
|
+
/**
|
|
1449
|
+
* The month where the date is displayed. If not the same as `date`, the day
|
|
1450
|
+
* is an "outside day".
|
|
1451
|
+
*/
|
|
1452
|
+
displayMonth) {
|
|
1567
1453
|
var modifiers = useModifiers();
|
|
1568
1454
|
var activeModifiers = getActiveModifiers(day, modifiers, displayMonth);
|
|
1569
1455
|
return activeModifiers;
|
|
1570
1456
|
}
|
|
1571
1457
|
|
|
1572
|
-
/** Returns true when the props are of type
|
|
1458
|
+
/** Returns true when the props are of type {@link DayPickerSingleProps}. */
|
|
1573
1459
|
function isDayPickerSingle(props) {
|
|
1574
1460
|
return props.mode === 'single';
|
|
1575
1461
|
}
|
|
@@ -1578,18 +1464,18 @@ function isDayPickerSingle(props) {
|
|
|
1578
1464
|
* The SelectSingle context shares details about the selected days when in
|
|
1579
1465
|
* single selection mode.
|
|
1580
1466
|
*
|
|
1581
|
-
* Access this context from the
|
|
1467
|
+
* Access this context from the {@link useSelectSingle} hook.
|
|
1582
1468
|
*/
|
|
1583
1469
|
var SelectSingleContext = createContext(undefined);
|
|
1584
|
-
/** Provides the values for the
|
|
1470
|
+
/** Provides the values for the {@link SelectSingleProvider}. */
|
|
1585
1471
|
function SelectSingleProvider(props) {
|
|
1586
1472
|
if (!isDayPickerSingle(props.initialProps)) {
|
|
1587
1473
|
var emptyContextValue = {
|
|
1588
1474
|
selected: undefined
|
|
1589
1475
|
};
|
|
1590
|
-
return (
|
|
1476
|
+
return (React__default.createElement(SelectSingleContext.Provider, { value: emptyContextValue }, props.children));
|
|
1591
1477
|
}
|
|
1592
|
-
return (
|
|
1478
|
+
return (React__default.createElement(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
1593
1479
|
}
|
|
1594
1480
|
function SelectSingleProviderInternal(_a) {
|
|
1595
1481
|
var initialProps = _a.initialProps, children = _a.children;
|
|
@@ -1606,10 +1492,14 @@ function SelectSingleProviderInternal(_a) {
|
|
|
1606
1492
|
selected: initialProps.selected,
|
|
1607
1493
|
onDayClick: onDayClick
|
|
1608
1494
|
};
|
|
1609
|
-
return (
|
|
1495
|
+
return (React__default.createElement(SelectSingleContext.Provider, { value: contextValue }, children));
|
|
1610
1496
|
}
|
|
1611
1497
|
|
|
1612
|
-
/**
|
|
1498
|
+
/**
|
|
1499
|
+
* Hook to access the {@link SelectSingleContextValue}.
|
|
1500
|
+
*
|
|
1501
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1502
|
+
*/
|
|
1613
1503
|
function useSelectSingle() {
|
|
1614
1504
|
var context = useContext(SelectSingleContext);
|
|
1615
1505
|
if (!context) {
|
|
@@ -1633,9 +1523,9 @@ function useSelectSingle() {
|
|
|
1633
1523
|
*
|
|
1634
1524
|
* ### Usage
|
|
1635
1525
|
*
|
|
1636
|
-
* Use this hook to customize the behavior of the
|
|
1526
|
+
* Use this hook to customize the behavior of the {@link Day} component. Create a
|
|
1637
1527
|
* new `Day` component using this hook and pass it to the `components` prop.
|
|
1638
|
-
* The source of
|
|
1528
|
+
* The source of {@link Day} can be a good starting point.
|
|
1639
1529
|
*
|
|
1640
1530
|
*/
|
|
1641
1531
|
function useDayEventHandlers(date, activeModifiers) {
|
|
@@ -1758,9 +1648,11 @@ function useDayEventHandlers(date, activeModifiers) {
|
|
|
1758
1648
|
}
|
|
1759
1649
|
|
|
1760
1650
|
/**
|
|
1761
|
-
* Return the current selected days when DayPicker is in selection mode.
|
|
1651
|
+
* Return the current selected days when DayPicker is in selection mode. Days
|
|
1652
|
+
* selected by the custom selection mode are not returned.
|
|
1653
|
+
*
|
|
1654
|
+
* This hook is meant to be used inside internal or custom components.
|
|
1762
1655
|
*
|
|
1763
|
-
* Days selected by the custom selection mode are not returned.
|
|
1764
1656
|
*/
|
|
1765
1657
|
function useSelectedDays() {
|
|
1766
1658
|
var dayPicker = useDayPicker();
|
|
@@ -1815,25 +1707,18 @@ function getDayStyle(dayPicker, activeModifiers) {
|
|
|
1815
1707
|
}
|
|
1816
1708
|
|
|
1817
1709
|
/**
|
|
1818
|
-
* Return props and data used to render the
|
|
1710
|
+
* Return props and data used to render the {@link Day} component.
|
|
1819
1711
|
*
|
|
1820
1712
|
* Use this hook when creating a component to replace the built-in `Day`
|
|
1821
1713
|
* component.
|
|
1822
|
-
*
|
|
1823
|
-
* Each Day in DayPicker should render one of the following, according to the return
|
|
1824
|
-
* value:
|
|
1825
|
-
*
|
|
1826
|
-
* - an empty `React.Fragment`, to render if `isHidden` is true
|
|
1827
|
-
* - a `button` element, when the day is interactive, e.g. is selectable
|
|
1828
|
-
* - a `div` element, whe the day is not interactive
|
|
1829
|
-
*
|
|
1830
|
-
* @param day The date to render
|
|
1831
|
-
* @param displayMonth The month where the date is displayed (if not the same as
|
|
1832
|
-
* `date`, it means it is an "outside" day)
|
|
1833
|
-
* @param buttonRef A ref to the button element that will be target of focus
|
|
1834
|
-
* when rendered (if required).
|
|
1835
1714
|
*/
|
|
1836
|
-
function useDayRender(
|
|
1715
|
+
function useDayRender(
|
|
1716
|
+
/** The date to render. */
|
|
1717
|
+
day,
|
|
1718
|
+
/** The month where the date is displayed (if not the same as `date`, it means it is an "outside" day). */
|
|
1719
|
+
displayMonth,
|
|
1720
|
+
/** A ref to the button element that will be target of focus when rendered (if required). */
|
|
1721
|
+
buttonRef) {
|
|
1837
1722
|
var _a;
|
|
1838
1723
|
var _b, _c;
|
|
1839
1724
|
var dayPicker = useDayPicker();
|
|
@@ -1866,14 +1751,14 @@ function useDayRender(day, displayMonth, buttonRef) {
|
|
|
1866
1751
|
var isHidden = Boolean((activeModifiers.outside && !dayPicker.showOutsideDays) ||
|
|
1867
1752
|
activeModifiers.hidden);
|
|
1868
1753
|
var DayContentComponent = (_c = (_b = dayPicker.components) === null || _b === void 0 ? void 0 : _b.DayContent) !== null && _c !== void 0 ? _c : DayContent;
|
|
1869
|
-
var children = (
|
|
1754
|
+
var children = (React__default.createElement(DayContentComponent, { date: day, displayMonth: displayMonth, activeModifiers: activeModifiers }));
|
|
1870
1755
|
var divProps = {
|
|
1871
1756
|
style: style,
|
|
1872
1757
|
className: className,
|
|
1873
1758
|
children: children
|
|
1874
1759
|
};
|
|
1875
1760
|
var isFocusTarget = Boolean(focusContext.focusTarget && isSameDay(focusContext.focusTarget, day));
|
|
1876
|
-
var buttonProps = __assign(__assign(__assign({}, divProps), (_a = {
|
|
1761
|
+
var buttonProps = __assign(__assign(__assign({}, divProps), (_a = { disabled: activeModifiers.disabled }, _a['aria-pressed'] = activeModifiers.selected, _a.tabIndex = isFocusTarget ? 0 : -1, _a)), eventHandlers);
|
|
1877
1762
|
var dayRender = {
|
|
1878
1763
|
isButton: isButton,
|
|
1879
1764
|
isHidden: isHidden,
|
|
@@ -1893,12 +1778,12 @@ function Day(props) {
|
|
|
1893
1778
|
var buttonRef = useRef(null);
|
|
1894
1779
|
var dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
|
|
1895
1780
|
if (dayRender.isHidden) {
|
|
1896
|
-
return
|
|
1781
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
1897
1782
|
}
|
|
1898
1783
|
if (!dayRender.isButton) {
|
|
1899
|
-
return
|
|
1784
|
+
return React__default.createElement("div", __assign({}, dayRender.divProps));
|
|
1900
1785
|
}
|
|
1901
|
-
return
|
|
1786
|
+
return React__default.createElement(Button, __assign({ ref: buttonRef }, dayRender.buttonProps));
|
|
1902
1787
|
}
|
|
1903
1788
|
|
|
1904
1789
|
/**
|
|
@@ -1910,13 +1795,13 @@ function WeekNumber(props) {
|
|
|
1910
1795
|
var _a = useDayPicker(), onWeekNumberClick = _a.onWeekNumberClick, styles = _a.styles, classNames = _a.classNames, locale = _a.locale, labelWeekNumber = _a.labels.labelWeekNumber, formatWeekNumber = _a.formatters.formatWeekNumber;
|
|
1911
1796
|
var content = formatWeekNumber(Number(weekNumber), { locale: locale });
|
|
1912
1797
|
if (!onWeekNumberClick) {
|
|
1913
|
-
return (
|
|
1798
|
+
return (React__default.createElement("span", { className: classNames.weeknumber, style: styles.weeknumber }, content));
|
|
1914
1799
|
}
|
|
1915
1800
|
var label = labelWeekNumber(Number(weekNumber), { locale: locale });
|
|
1916
1801
|
var handleClick = function (e) {
|
|
1917
1802
|
onWeekNumberClick(weekNumber, dates, e);
|
|
1918
1803
|
};
|
|
1919
|
-
return (
|
|
1804
|
+
return (React__default.createElement(Button, { "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, content));
|
|
1920
1805
|
}
|
|
1921
1806
|
|
|
1922
1807
|
/** Render a row in the calendar, with the days and the week number. */
|
|
@@ -1927,13 +1812,13 @@ function Row(props) {
|
|
|
1927
1812
|
var WeeknumberComponent = (_b = components === null || components === void 0 ? void 0 : components.WeekNumber) !== null && _b !== void 0 ? _b : WeekNumber;
|
|
1928
1813
|
var weekNumberCell;
|
|
1929
1814
|
if (showWeekNumber) {
|
|
1930
|
-
weekNumberCell = (
|
|
1931
|
-
|
|
1815
|
+
weekNumberCell = (React__default.createElement("td", { className: classNames.cell, style: styles.cell },
|
|
1816
|
+
React__default.createElement(WeeknumberComponent, { number: props.weekNumber, dates: props.dates })));
|
|
1932
1817
|
}
|
|
1933
|
-
return (
|
|
1818
|
+
return (React__default.createElement("tr", { className: classNames.row, style: styles.row },
|
|
1934
1819
|
weekNumberCell,
|
|
1935
|
-
props.dates.map(function (date) { return (
|
|
1936
|
-
|
|
1820
|
+
props.dates.map(function (date) { return (React__default.createElement("td", { className: classNames.cell, style: styles.cell, key: getUnixTime(date) },
|
|
1821
|
+
React__default.createElement(DayComponent, { displayMonth: props.displayMonth, date: date }))); })));
|
|
1937
1822
|
}
|
|
1938
1823
|
|
|
1939
1824
|
/** Return the weeks between two dates. */
|
|
@@ -1995,10 +1880,87 @@ function Table(props) {
|
|
|
1995
1880
|
var HeadComponent = (_a = components === null || components === void 0 ? void 0 : components.Head) !== null && _a !== void 0 ? _a : Head;
|
|
1996
1881
|
var RowComponent = (_b = components === null || components === void 0 ? void 0 : components.Row) !== null && _b !== void 0 ? _b : Row;
|
|
1997
1882
|
var FooterComponent = (_c = components === null || components === void 0 ? void 0 : components.Footer) !== null && _c !== void 0 ? _c : Footer;
|
|
1998
|
-
return (
|
|
1999
|
-
!hideHead &&
|
|
2000
|
-
|
|
2001
|
-
|
|
1883
|
+
return (React__default.createElement("table", { className: classNames.table, style: styles.table, role: "grid", "aria-labelledby": props['aria-labelledby'] },
|
|
1884
|
+
!hideHead && React__default.createElement(HeadComponent, null),
|
|
1885
|
+
React__default.createElement("tbody", { className: classNames.tbody, style: styles.tbody }, weeks.map(function (week) { return (React__default.createElement(RowComponent, { displayMonth: props.displayMonth, key: week.weekNumber, dates: week.dates, weekNumber: week.weekNumber })); })),
|
|
1886
|
+
React__default.createElement(FooterComponent, null)));
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
/*
|
|
1890
|
+
The MIT License (MIT)
|
|
1891
|
+
|
|
1892
|
+
Copyright (c) 2018-present, React Training LLC
|
|
1893
|
+
|
|
1894
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
1895
|
+
|
|
1896
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
1897
|
+
|
|
1898
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1899
|
+
*/
|
|
1900
|
+
function canUseDOM() {
|
|
1901
|
+
return !!(typeof window !== 'undefined' &&
|
|
1902
|
+
window.document &&
|
|
1903
|
+
window.document.createElement);
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* React currently throws a warning when using useLayoutEffect on the server. To
|
|
1907
|
+
* get around it, we can conditionally useEffect on the server (no-op) and
|
|
1908
|
+
* useLayoutEffect in the browser. We occasionally need useLayoutEffect to
|
|
1909
|
+
* ensure we don't get a render flash for certain operations, but we may also
|
|
1910
|
+
* need affected components to render on the server. One example is when setting
|
|
1911
|
+
* a component's descendants to retrieve their index values.
|
|
1912
|
+
*
|
|
1913
|
+
* Important to note that using this hook as an escape hatch will break the
|
|
1914
|
+
* eslint dependency warnings unless you rename the import to `useLayoutEffect`.
|
|
1915
|
+
* Use sparingly only when the effect won't effect the rendered HTML to avoid
|
|
1916
|
+
* any server/client mismatch.
|
|
1917
|
+
*
|
|
1918
|
+
* If a useLayoutEffect is needed and the result would create a mismatch, it's
|
|
1919
|
+
* likely that the component in question shouldn't be rendered on the server at
|
|
1920
|
+
* all, so a better approach would be to lazily render those in a parent
|
|
1921
|
+
* component after client-side hydration.
|
|
1922
|
+
*
|
|
1923
|
+
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
|
|
1924
|
+
* https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
|
|
1925
|
+
*
|
|
1926
|
+
* @param effect
|
|
1927
|
+
* @param deps
|
|
1928
|
+
*/
|
|
1929
|
+
var useIsomorphicLayoutEffect = canUseDOM()
|
|
1930
|
+
? React.useLayoutEffect
|
|
1931
|
+
: React.useEffect;
|
|
1932
|
+
var serverHandoffComplete = false;
|
|
1933
|
+
var id = 0;
|
|
1934
|
+
function genId() {
|
|
1935
|
+
return "react-day-picker-".concat(++id);
|
|
1936
|
+
}
|
|
1937
|
+
function useId(providedId) {
|
|
1938
|
+
// TODO: Remove error flag when updating internal deps to React 18. None of
|
|
1939
|
+
// our tricks will play well with concurrent rendering anyway.
|
|
1940
|
+
var _a;
|
|
1941
|
+
// If this instance isn't part of the initial render, we don't have to do the
|
|
1942
|
+
// double render/patch-up dance. We can just generate the ID and return it.
|
|
1943
|
+
var initialId = providedId !== null && providedId !== void 0 ? providedId : (serverHandoffComplete ? genId() : null);
|
|
1944
|
+
var _b = React.useState(initialId), id = _b[0], setId = _b[1];
|
|
1945
|
+
useIsomorphicLayoutEffect(function () {
|
|
1946
|
+
if (id === null) {
|
|
1947
|
+
// Patch the ID after render. We do this in `useLayoutEffect` to avoid any
|
|
1948
|
+
// rendering flicker, though it'll make the first render slower (unlikely
|
|
1949
|
+
// to matter, but you're welcome to measure your app and let us know if
|
|
1950
|
+
// it's a problem).
|
|
1951
|
+
setId(genId());
|
|
1952
|
+
}
|
|
1953
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1954
|
+
}, []);
|
|
1955
|
+
React.useEffect(function () {
|
|
1956
|
+
if (serverHandoffComplete === false) {
|
|
1957
|
+
// Flag all future uses of `useId` to skip the update dance. This is in
|
|
1958
|
+
// `useEffect` because it goes after `useLayoutEffect`, ensuring we don't
|
|
1959
|
+
// accidentally bail out of the patch-up dance prematurely.
|
|
1960
|
+
serverHandoffComplete = true;
|
|
1961
|
+
}
|
|
1962
|
+
}, []);
|
|
1963
|
+
return (_a = providedId !== null && providedId !== void 0 ? providedId : id) !== null && _a !== void 0 ? _a : undefined;
|
|
2002
1964
|
}
|
|
2003
1965
|
|
|
2004
1966
|
/** Render a month. */
|
|
@@ -2030,9 +1992,9 @@ function Month(props) {
|
|
|
2030
1992
|
style = __assign(__assign({}, style), styles.caption_between);
|
|
2031
1993
|
}
|
|
2032
1994
|
var CaptionComponent = (_b = components === null || components === void 0 ? void 0 : components.Caption) !== null && _b !== void 0 ? _b : Caption;
|
|
2033
|
-
return (
|
|
2034
|
-
|
|
2035
|
-
|
|
1995
|
+
return (React__default.createElement("div", { key: props.displayIndex, className: className.join(' '), style: style },
|
|
1996
|
+
React__default.createElement(CaptionComponent, { id: captionId, displayMonth: props.displayMonth }),
|
|
1997
|
+
React__default.createElement(Table, { "aria-labelledby": captionId, displayMonth: props.displayMonth })));
|
|
2036
1998
|
}
|
|
2037
1999
|
|
|
2038
2000
|
/** Render the container with the months according to the number of months to display. */
|
|
@@ -2068,25 +2030,112 @@ function Root() {
|
|
|
2068
2030
|
classNames.push(dayPicker.classNames.with_weeknumber);
|
|
2069
2031
|
}
|
|
2070
2032
|
var style = __assign(__assign({}, dayPicker.styles.root), dayPicker.style);
|
|
2071
|
-
return (
|
|
2072
|
-
|
|
2033
|
+
return (React__default.createElement("div", { className: classNames.join(' '), style: style, dir: dayPicker.dir },
|
|
2034
|
+
React__default.createElement("div", { className: dayPicker.classNames.months, style: dayPicker.styles.months }, navigation.displayMonths.map(function (month, i) { return (React__default.createElement(Month, { key: i, displayIndex: i, displayMonth: month })); }))));
|
|
2073
2035
|
}
|
|
2074
2036
|
|
|
2075
2037
|
/** Provide the value for all the context providers. */
|
|
2076
2038
|
function RootProvider(props) {
|
|
2077
2039
|
var children = props.children, initialProps = __rest(props, ["children"]);
|
|
2078
|
-
return (
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2040
|
+
return (React__default.createElement(DayPickerProvider, { initialProps: initialProps },
|
|
2041
|
+
React__default.createElement(NavigationProvider, null,
|
|
2042
|
+
React__default.createElement(SelectSingleProvider, { initialProps: initialProps },
|
|
2043
|
+
React__default.createElement(SelectMultipleProvider, { initialProps: initialProps },
|
|
2044
|
+
React__default.createElement(SelectRangeProvider, { initialProps: initialProps },
|
|
2045
|
+
React__default.createElement(ModifiersProvider, null,
|
|
2046
|
+
React__default.createElement(FocusProvider, null, children))))))));
|
|
2085
2047
|
}
|
|
2086
2048
|
|
|
2049
|
+
/**
|
|
2050
|
+
* DayPicker render a date picker component to let users pick dates from a
|
|
2051
|
+
* calendar. See http://react-day-picker.js.org for updated documentation and
|
|
2052
|
+
* examples.
|
|
2053
|
+
*
|
|
2054
|
+
* ### Customization
|
|
2055
|
+
*
|
|
2056
|
+
* DayPicker offers different customization props. For example,
|
|
2057
|
+
*
|
|
2058
|
+
* - show multiple months using `numberOfMonths`
|
|
2059
|
+
* - display a dropdown to navigate the months via `captionLayout`
|
|
2060
|
+
* - display the week numbers with `showWeekNumbers`
|
|
2061
|
+
* - disable or hide days with `disabled` or `hidden`
|
|
2062
|
+
*
|
|
2063
|
+
* ### Controlling the months
|
|
2064
|
+
*
|
|
2065
|
+
* Change the initially displayed month using the `defaultMonth` prop. The
|
|
2066
|
+
* displayed months are controlled by DayPicker and stored in its internal
|
|
2067
|
+
* state. To control the months yourself, use `month` instead of `defaultMonth`
|
|
2068
|
+
* and use the `onMonthChange` event to set it.
|
|
2069
|
+
*
|
|
2070
|
+
* To limit the months the user can navigate to, use
|
|
2071
|
+
* `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.
|
|
2072
|
+
*
|
|
2073
|
+
* ### Selection modes
|
|
2074
|
+
*
|
|
2075
|
+
* DayPicker supports different selection mode that can be toggled using the
|
|
2076
|
+
* `mode` prop:
|
|
2077
|
+
*
|
|
2078
|
+
* - `mode="single"`: only one day can be selected. Use `required` to make the
|
|
2079
|
+
* selection required. Use the `onSelect` event handler to get the selected
|
|
2080
|
+
* days.
|
|
2081
|
+
* - `mode="multiple"`: users can select one or more days. Limit the amount of
|
|
2082
|
+
* days that can be selected with the `min` or the `max` props.
|
|
2083
|
+
* - `mode="range"`: users can select a range of days. Limit the amount of days
|
|
2084
|
+
* in the range with the `min` or the `max` props.
|
|
2085
|
+
* - `mode="default"` (default): the built-in selections are disabled. Implement
|
|
2086
|
+
* your own selection mode with `onDayClick`.
|
|
2087
|
+
*
|
|
2088
|
+
* The selection modes should cover the most common use cases. In case you
|
|
2089
|
+
* need a more refined way of selecting days, use `mode="default"`. Use the
|
|
2090
|
+
* `selected` props and add the day event handlers to add/remove days from the
|
|
2091
|
+
* selection.
|
|
2092
|
+
*
|
|
2093
|
+
* ### Modifiers
|
|
2094
|
+
*
|
|
2095
|
+
* A _modifier_ represents different styles or states for the days displayed in
|
|
2096
|
+
* the calendar (like "selected" or "disabled"). Define custom modifiers using
|
|
2097
|
+
* the `modifiers` prop.
|
|
2098
|
+
*
|
|
2099
|
+
* ### Formatters and custom component
|
|
2100
|
+
*
|
|
2101
|
+
* You can customize how the content is displayed in the date picker by using
|
|
2102
|
+
* either the formatters or replacing the internal components.
|
|
2103
|
+
*
|
|
2104
|
+
* For the most common cases you want to use the `formatters` prop to change how
|
|
2105
|
+
* the content is formatted in the calendar. Use the `components` prop to
|
|
2106
|
+
* replace the internal components, like the navigation icons.
|
|
2107
|
+
*
|
|
2108
|
+
* ### Styling
|
|
2109
|
+
*
|
|
2110
|
+
* DayPicker comes with a default, basic style in `react-day-picker/style` – use
|
|
2111
|
+
* it as template for your own style.
|
|
2112
|
+
*
|
|
2113
|
+
* If you are using CSS modules, pass the imported styles object the
|
|
2114
|
+
* `classNames` props.
|
|
2115
|
+
*
|
|
2116
|
+
* You can also style the elements via inline-styles using the `styles` prop.
|
|
2117
|
+
*
|
|
2118
|
+
* ### Form fields
|
|
2119
|
+
*
|
|
2120
|
+
* If you need to bind the date picker to a form field, you can use the
|
|
2121
|
+
* `useInput` hooks for a basic behavior. See the `useInput` source as an
|
|
2122
|
+
* example to bind the date picker with form fields.
|
|
2123
|
+
*
|
|
2124
|
+
* ### Localization
|
|
2125
|
+
*
|
|
2126
|
+
* To localize DayPicker, import the locale from `date-fns` package and use the
|
|
2127
|
+
* `locale` prop.
|
|
2128
|
+
*
|
|
2129
|
+
* For example, to use Spanish locale:
|
|
2130
|
+
*
|
|
2131
|
+
* ```
|
|
2132
|
+
* import es from 'date-fns/locale/es';
|
|
2133
|
+
* <DayPicker locale={es} />
|
|
2134
|
+
* ```
|
|
2135
|
+
*/
|
|
2087
2136
|
function DayPicker(props) {
|
|
2088
|
-
return (
|
|
2089
|
-
|
|
2137
|
+
return (React__default.createElement(RootProvider, __assign({}, props),
|
|
2138
|
+
React__default.createElement(Root, null)));
|
|
2090
2139
|
}
|
|
2091
2140
|
|
|
2092
2141
|
/** @private */
|
|
@@ -2186,10 +2235,10 @@ function useInput(options) {
|
|
|
2186
2235
|
return { dayPickerProps: dayPickerProps, inputProps: inputProps, reset: reset, setSelected: setSelected };
|
|
2187
2236
|
}
|
|
2188
2237
|
|
|
2189
|
-
/** Returns true when the props are of type
|
|
2238
|
+
/** Returns true when the props are of type {@link DayPickerDefaultProps}. */
|
|
2190
2239
|
function isDayPickerDefault(props) {
|
|
2191
2240
|
return props.mode === undefined || props.mode === 'default';
|
|
2192
2241
|
}
|
|
2193
2242
|
|
|
2194
|
-
export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
2243
|
+
export { Button, Caption, CaptionDropdowns, CaptionLabel, CaptionNavigation, Day, DayContent, DayPicker, DayPickerContext, DayPickerProvider, Dropdown, FocusContext, FocusProvider, Footer, Head, IconDropdown, IconLeft, IconRight, InternalModifier, NavigationContext, NavigationProvider, RootProvider, Row, SelectMultipleContext, SelectMultipleProvider, SelectMultipleProviderInternal, SelectRangeContext, SelectRangeProvider, SelectRangeProviderInternal, SelectSingleContext, SelectSingleProvider, SelectSingleProviderInternal, WeekNumber, addToRange, isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, isDayPickerDefault, isDayPickerMultiple, isDayPickerRange, isDayPickerSingle, isMatch, useActiveModifiers, useDayPicker, useDayRender, useFocusContext, useInput, useNavigation, useSelectMultiple, useSelectRange, useSelectSingle };
|
|
2195
2244
|
//# sourceMappingURL=index.esm.js.map
|