@zendeskgarden/react-datepickers 8.57.1 → 8.59.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/index.cjs.js +648 -770
- package/dist/index.esm.js +649 -771
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -13,161 +13,8 @@ import { Manager, Reference, Popper } from 'react-popper';
|
|
|
13
13
|
import { composeEventHandlers, KEY_CODES } from '@zendeskgarden/container-utilities';
|
|
14
14
|
import { retrieveComponentStyles, DEFAULT_THEME, menuStyles, getColor } from '@zendeskgarden/react-theming';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (Object.getOwnPropertySymbols) {
|
|
20
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
22
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
23
|
-
})), keys.push.apply(keys, symbols);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return keys;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _objectSpread2(target) {
|
|
30
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
32
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
33
|
-
_defineProperty(target, key, source[key]);
|
|
34
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
35
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return target;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _defineProperty(obj, key, value) {
|
|
43
|
-
if (key in obj) {
|
|
44
|
-
Object.defineProperty(obj, key, {
|
|
45
|
-
value: value,
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
obj[key] = value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return obj;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function _extends$2() {
|
|
58
|
-
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
59
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
60
|
-
var source = arguments[i];
|
|
61
|
-
|
|
62
|
-
for (var key in source) {
|
|
63
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
64
|
-
target[key] = source[key];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return target;
|
|
70
|
-
};
|
|
71
|
-
return _extends$2.apply(this, arguments);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
75
|
-
if (source == null) return {};
|
|
76
|
-
var target = {};
|
|
77
|
-
var sourceKeys = Object.keys(source);
|
|
78
|
-
var key, i;
|
|
79
|
-
|
|
80
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
81
|
-
key = sourceKeys[i];
|
|
82
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
83
|
-
target[key] = source[key];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return target;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _objectWithoutProperties(source, excluded) {
|
|
90
|
-
if (source == null) return {};
|
|
91
|
-
|
|
92
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
93
|
-
|
|
94
|
-
var key, i;
|
|
95
|
-
|
|
96
|
-
if (Object.getOwnPropertySymbols) {
|
|
97
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
98
|
-
|
|
99
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
100
|
-
key = sourceSymbolKeys[i];
|
|
101
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
102
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
103
|
-
target[key] = source[key];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return target;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function _slicedToArray(arr, i) {
|
|
111
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function _arrayWithHoles(arr) {
|
|
115
|
-
if (Array.isArray(arr)) return arr;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function _iterableToArrayLimit(arr, i) {
|
|
119
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
120
|
-
|
|
121
|
-
if (_i == null) return;
|
|
122
|
-
var _arr = [];
|
|
123
|
-
var _n = true;
|
|
124
|
-
var _d = false;
|
|
125
|
-
|
|
126
|
-
var _s, _e;
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
130
|
-
_arr.push(_s.value);
|
|
131
|
-
|
|
132
|
-
if (i && _arr.length === i) break;
|
|
133
|
-
}
|
|
134
|
-
} catch (err) {
|
|
135
|
-
_d = true;
|
|
136
|
-
_e = err;
|
|
137
|
-
} finally {
|
|
138
|
-
try {
|
|
139
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
140
|
-
} finally {
|
|
141
|
-
if (_d) throw _e;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return _arr;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
149
|
-
if (!o) return;
|
|
150
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
151
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
152
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
153
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
154
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function _arrayLikeToArray(arr, len) {
|
|
158
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
159
|
-
|
|
160
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
161
|
-
|
|
162
|
-
return arr2;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function _nonIterableRest() {
|
|
166
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
|
|
170
|
-
var PLACEMENT = [].concat(SHARED_PLACEMENT, ['end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom']);
|
|
16
|
+
const SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
|
|
17
|
+
const PLACEMENT = [...SHARED_PLACEMENT, 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
171
18
|
|
|
172
19
|
function getPopperPlacement(gardenPlacement) {
|
|
173
20
|
switch (gardenPlacement) {
|
|
@@ -188,7 +35,7 @@ function getPopperPlacement(gardenPlacement) {
|
|
|
188
35
|
}
|
|
189
36
|
}
|
|
190
37
|
function getRtlPopperPlacement(gardenPlacement) {
|
|
191
|
-
|
|
38
|
+
const popperPlacement = getPopperPlacement(gardenPlacement);
|
|
192
39
|
switch (popperPlacement) {
|
|
193
40
|
case 'left':
|
|
194
41
|
return 'right';
|
|
@@ -387,216 +234,173 @@ function getDate(dirtyDate) {
|
|
|
387
234
|
return dayOfMonth;
|
|
388
235
|
}
|
|
389
236
|
|
|
390
|
-
|
|
391
|
-
|
|
237
|
+
const COMPONENT_ID$b = 'datepickers.menu';
|
|
238
|
+
const StyledMenu = styled.div.attrs({
|
|
392
239
|
'data-garden-id': COMPONENT_ID$b,
|
|
393
|
-
'data-garden-version': '8.
|
|
240
|
+
'data-garden-version': '8.59.0'
|
|
394
241
|
}).withConfig({
|
|
395
242
|
displayName: "StyledMenu",
|
|
396
243
|
componentId: "sc-1npbkk0-0"
|
|
397
|
-
})(["", ";"],
|
|
398
|
-
return retrieveComponentStyles(COMPONENT_ID$b, props);
|
|
399
|
-
});
|
|
244
|
+
})(["", ";"], props => retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
400
245
|
StyledMenu.defaultProps = {
|
|
401
246
|
theme: DEFAULT_THEME
|
|
402
247
|
};
|
|
403
248
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
};
|
|
409
|
-
}).withConfig({
|
|
249
|
+
const COMPONENT_ID$a = 'datepickers.menu_wrapper';
|
|
250
|
+
const StyledMenuWrapper = styled.div.attrs(props => ({
|
|
251
|
+
className: props.isAnimated && 'is-animated'
|
|
252
|
+
})).withConfig({
|
|
410
253
|
displayName: "StyledMenuWrapper",
|
|
411
254
|
componentId: "sc-6fowoz-0"
|
|
412
|
-
})(["", ";", ";"],
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
});
|
|
420
|
-
}, function (props) {
|
|
421
|
-
return retrieveComponentStyles(COMPONENT_ID$a, props);
|
|
422
|
-
});
|
|
255
|
+
})(["", ";", ";"], props => menuStyles(getMenuPosition(props.placement), {
|
|
256
|
+
theme: props.theme,
|
|
257
|
+
hidden: props.isHidden,
|
|
258
|
+
margin: `${props.theme.space.base}px`,
|
|
259
|
+
zIndex: props.zIndex,
|
|
260
|
+
animationModifier: props.isAnimated ? '.is-animated' : undefined
|
|
261
|
+
}), props => retrieveComponentStyles(COMPONENT_ID$a, props));
|
|
423
262
|
StyledMenuWrapper.defaultProps = {
|
|
424
263
|
theme: DEFAULT_THEME
|
|
425
264
|
};
|
|
426
265
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
266
|
+
const COMPONENT_ID$9 = 'datepickers.datepicker';
|
|
267
|
+
const retrievePadding = _ref => {
|
|
268
|
+
let {
|
|
269
|
+
isCompact,
|
|
270
|
+
theme
|
|
271
|
+
} = _ref;
|
|
272
|
+
let value = theme.space.base * 5;
|
|
432
273
|
if (isCompact) {
|
|
433
274
|
value = theme.space.base * 4;
|
|
434
275
|
}
|
|
435
|
-
return
|
|
276
|
+
return `margin: ${value}px;`;
|
|
436
277
|
};
|
|
437
|
-
|
|
278
|
+
const StyledDatepicker = styled.div.attrs({
|
|
438
279
|
'data-garden-id': COMPONENT_ID$9
|
|
439
280
|
}).withConfig({
|
|
440
281
|
displayName: "StyledDatepicker",
|
|
441
282
|
componentId: "sc-w3zqsp-0"
|
|
442
|
-
})(["direction:", ";", " background-color:", ";color:", ";", ";"],
|
|
443
|
-
return props.theme.rtl && 'rtl';
|
|
444
|
-
}, retrievePadding, function (props) {
|
|
445
|
-
return props.theme.colors.background;
|
|
446
|
-
}, function (props) {
|
|
447
|
-
return props.theme.colors.foreground;
|
|
448
|
-
}, function (props) {
|
|
449
|
-
return retrieveComponentStyles(COMPONENT_ID$9, props);
|
|
450
|
-
});
|
|
283
|
+
})(["direction:", ";", " background-color:", ";color:", ";", ";"], props => props.theme.rtl && 'rtl', retrievePadding, props => props.theme.colors.background, props => props.theme.colors.foreground, props => retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
451
284
|
StyledDatepicker.defaultProps = {
|
|
452
285
|
theme: DEFAULT_THEME
|
|
453
286
|
};
|
|
454
287
|
|
|
455
|
-
|
|
456
|
-
|
|
288
|
+
const COMPONENT_ID$8 = 'datepickers.range_calendar';
|
|
289
|
+
const StyledRangeCalendar = styled.div.attrs({
|
|
457
290
|
'data-garden-id': COMPONENT_ID$8
|
|
458
291
|
}).withConfig({
|
|
459
292
|
displayName: "StyledRangeCalendar",
|
|
460
293
|
componentId: "sc-1og46sy-0"
|
|
461
|
-
})(["display:flex;overflow:auto;", "{margin:0;", "}", ";"], StyledDatepicker,
|
|
462
|
-
return props.theme.rtl ? "&:last-of-type {margin-right: ".concat(props.theme.space.base * 5, "px}") : "&:first-of-type {margin-right: ".concat(props.theme.space.base * 5, "px}");
|
|
463
|
-
}, function (props) {
|
|
464
|
-
return retrieveComponentStyles(COMPONENT_ID$8, props);
|
|
465
|
-
});
|
|
294
|
+
})(["display:flex;overflow:auto;", "{margin:0;", "}", ";"], StyledDatepicker, props => props.theme.rtl ? `&:last-of-type {margin-right: ${props.theme.space.base * 5}px}` : `&:first-of-type {margin-right: ${props.theme.space.base * 5}px}`, props => retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
466
295
|
StyledRangeCalendar.defaultProps = {
|
|
467
296
|
theme: DEFAULT_THEME
|
|
468
297
|
};
|
|
469
298
|
|
|
470
|
-
|
|
471
|
-
|
|
299
|
+
const COMPONENT_ID$7 = 'datepickers.header';
|
|
300
|
+
const StyledHeader = styled.div.attrs({
|
|
472
301
|
'data-garden-id': COMPONENT_ID$7
|
|
473
302
|
}).withConfig({
|
|
474
303
|
displayName: "StyledHeader",
|
|
475
304
|
componentId: "sc-upq318-0"
|
|
476
|
-
})(["display:flex;width:", "px;", ";"],
|
|
477
|
-
return props.isCompact ? props.theme.space.base * 56 : props.theme.space.base * 70;
|
|
478
|
-
}, function (props) {
|
|
479
|
-
return retrieveComponentStyles(COMPONENT_ID$7, props);
|
|
480
|
-
});
|
|
305
|
+
})(["display:flex;width:", "px;", ";"], props => props.isCompact ? props.theme.space.base * 56 : props.theme.space.base * 70, props => retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
481
306
|
StyledHeader.defaultProps = {
|
|
482
307
|
theme: DEFAULT_THEME
|
|
483
308
|
};
|
|
484
309
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
310
|
+
const retrieveSizing = _ref => {
|
|
311
|
+
let {
|
|
312
|
+
isCompact,
|
|
313
|
+
theme
|
|
314
|
+
} = _ref;
|
|
315
|
+
let size = theme.space.base * 10;
|
|
489
316
|
if (isCompact) {
|
|
490
317
|
size = theme.space.base * 8;
|
|
491
318
|
}
|
|
492
319
|
return css(["width:", "px;height:", "px;"], size, size);
|
|
493
320
|
};
|
|
494
|
-
|
|
495
|
-
|
|
321
|
+
const retrieveColor$1 = _ref2 => {
|
|
322
|
+
let {
|
|
323
|
+
theme
|
|
324
|
+
} = _ref2;
|
|
496
325
|
return css([":hover{background-color:", ";color:", ";}:active{background-color:", ";color:", ";}color:", ";"], getColor('primaryHue', 600, theme, 0.08), theme.colors.foreground, getColor('primaryHue', 600, theme, 0.2), theme.colors.foreground, getColor('neutralHue', 600, theme));
|
|
497
326
|
};
|
|
498
|
-
|
|
499
|
-
|
|
327
|
+
const COMPONENT_ID$6 = 'datepickers.header_paddle';
|
|
328
|
+
const StyledHeaderPaddle = styled.div.attrs({
|
|
500
329
|
'data-garden-id': COMPONENT_ID$6
|
|
501
330
|
}).withConfig({
|
|
502
331
|
displayName: "StyledHeaderPaddle",
|
|
503
332
|
componentId: "sc-2oqh0g-0"
|
|
504
|
-
})(["display:flex;align-items:center;justify-content:center;transform:", ";visibility:", ";border-radius:50%;cursor:pointer;", " ", " svg{width:", ";height:", ";}", ";"],
|
|
505
|
-
return props.theme.rtl && 'rotate(180deg)';
|
|
506
|
-
}, function (props) {
|
|
507
|
-
return props.isHidden && 'hidden';
|
|
508
|
-
},
|
|
509
|
-
retrieveSizing, retrieveColor$1, function (props) {
|
|
510
|
-
return "".concat(props.theme.iconSizes.md);
|
|
511
|
-
}, function (props) {
|
|
512
|
-
return "".concat(props.theme.iconSizes.md);
|
|
513
|
-
}, function (props) {
|
|
514
|
-
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
515
|
-
});
|
|
333
|
+
})(["display:flex;align-items:center;justify-content:center;transform:", ";visibility:", ";border-radius:50%;cursor:pointer;", " ", " svg{width:", ";height:", ";}", ";"], props => props.theme.rtl && 'rotate(180deg)', props => props.isHidden && 'hidden', retrieveSizing, retrieveColor$1, props => `${props.theme.iconSizes.md}`, props => `${props.theme.iconSizes.md}`, props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
516
334
|
StyledHeaderPaddle.defaultProps = {
|
|
517
335
|
theme: DEFAULT_THEME
|
|
518
336
|
};
|
|
519
337
|
|
|
520
|
-
|
|
521
|
-
|
|
338
|
+
const COMPONENT_ID$5 = 'datepickers.header_label';
|
|
339
|
+
const StyledHeaderLabel = styled.div.attrs({
|
|
522
340
|
'data-garden-id': COMPONENT_ID$5
|
|
523
341
|
}).withConfig({
|
|
524
342
|
displayName: "StyledHeaderLabel",
|
|
525
343
|
componentId: "sc-1ryf5ub-0"
|
|
526
|
-
})(["display:flex;flex-grow:1;align-items:center;justify-content:center;font-size:", ";font-weight:", ";", ";"],
|
|
527
|
-
return props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md;
|
|
528
|
-
}, function (props) {
|
|
529
|
-
return props.theme.fontWeights.semibold;
|
|
530
|
-
}, function (props) {
|
|
531
|
-
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
532
|
-
});
|
|
344
|
+
})(["display:flex;flex-grow:1;align-items:center;justify-content:center;font-size:", ";font-weight:", ";", ";"], props => props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md, props => props.theme.fontWeights.semibold, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
533
345
|
StyledHeaderLabel.defaultProps = {
|
|
534
346
|
theme: DEFAULT_THEME
|
|
535
347
|
};
|
|
536
348
|
|
|
537
|
-
|
|
538
|
-
|
|
349
|
+
const COMPONENT_ID$4 = 'datepickers.calendar';
|
|
350
|
+
const StyledCalendar = styled.div.attrs({
|
|
539
351
|
'data-garden-id': COMPONENT_ID$4
|
|
540
352
|
}).withConfig({
|
|
541
353
|
displayName: "StyledCalendar",
|
|
542
354
|
componentId: "sc-g5hoe8-0"
|
|
543
|
-
})(["width:", "px;", ";"],
|
|
544
|
-
return props.isCompact ? props.theme.space.base * 56 : props.theme.space.base * 70;
|
|
545
|
-
}, function (props) {
|
|
546
|
-
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
547
|
-
});
|
|
355
|
+
})(["width:", "px;", ";"], props => props.isCompact ? props.theme.space.base * 56 : props.theme.space.base * 70, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
548
356
|
StyledCalendar.defaultProps = {
|
|
549
357
|
theme: DEFAULT_THEME
|
|
550
358
|
};
|
|
551
359
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
360
|
+
const COMPONENT_ID$3 = 'datepickers.calendar_item';
|
|
361
|
+
const retrieveSize = _ref => {
|
|
362
|
+
let {
|
|
363
|
+
isCompact,
|
|
364
|
+
theme
|
|
365
|
+
} = _ref;
|
|
366
|
+
let size;
|
|
557
367
|
if (isCompact) {
|
|
558
|
-
size =
|
|
368
|
+
size = `${theme.space.base * 8}px`;
|
|
559
369
|
} else {
|
|
560
|
-
size =
|
|
370
|
+
size = `${theme.space.base * 10}px`;
|
|
561
371
|
}
|
|
562
372
|
return css(["width:", ";height:", ";"], size, size);
|
|
563
373
|
};
|
|
564
|
-
|
|
374
|
+
const StyledCalendarItem = styled.div.attrs({
|
|
565
375
|
'data-garden-id': COMPONENT_ID$3
|
|
566
376
|
}).withConfig({
|
|
567
377
|
displayName: "StyledCalendarItem",
|
|
568
378
|
componentId: "sc-143w8wb-0"
|
|
569
|
-
})(["display:inline-block;position:relative;vertical-align:top;", " ", ";"], retrieveSize,
|
|
570
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
571
|
-
});
|
|
379
|
+
})(["display:inline-block;position:relative;vertical-align:top;", " ", ";"], retrieveSize, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
572
380
|
StyledCalendarItem.defaultProps = {
|
|
573
381
|
theme: DEFAULT_THEME
|
|
574
382
|
};
|
|
575
383
|
|
|
576
|
-
|
|
577
|
-
|
|
384
|
+
const COMPONENT_ID$2 = 'datepickers.day_label';
|
|
385
|
+
const StyledDayLabel = styled.div.attrs({
|
|
578
386
|
'data-garden-id': COMPONENT_ID$2
|
|
579
387
|
}).withConfig({
|
|
580
388
|
displayName: "StyledDayLabel",
|
|
581
389
|
componentId: "sc-9bh1p7-0"
|
|
582
|
-
})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:", ";font-weight:", ";", ";"],
|
|
583
|
-
return props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md;
|
|
584
|
-
}, function (props) {
|
|
585
|
-
return props.theme.fontWeights.semibold;
|
|
586
|
-
}, function (props) {
|
|
587
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
588
|
-
});
|
|
390
|
+
})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:", ";font-weight:", ";", ";"], props => props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md, props => props.theme.fontWeights.semibold, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
589
391
|
StyledDayLabel.defaultProps = {
|
|
590
392
|
theme: DEFAULT_THEME
|
|
591
393
|
};
|
|
592
394
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
395
|
+
const COMPONENT_ID$1 = 'datepickers.highlight';
|
|
396
|
+
const retrieveBorderRadius = _ref => {
|
|
397
|
+
let {
|
|
398
|
+
theme,
|
|
399
|
+
isEnd,
|
|
400
|
+
isStart
|
|
401
|
+
} = _ref;
|
|
402
|
+
const startValue = 'border-radius: 0 50% 50% 0;';
|
|
403
|
+
const endValue = 'border-radius: 50% 0 0 50%;';
|
|
600
404
|
if (theme.rtl) {
|
|
601
405
|
if (isStart) {
|
|
602
406
|
return startValue;
|
|
@@ -611,34 +415,36 @@ var retrieveBorderRadius = function retrieveBorderRadius(_ref) {
|
|
|
611
415
|
}
|
|
612
416
|
return '';
|
|
613
417
|
};
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
418
|
+
const retrieveColor = _ref2 => {
|
|
419
|
+
let {
|
|
420
|
+
isHighlighted,
|
|
421
|
+
theme
|
|
422
|
+
} = _ref2;
|
|
617
423
|
if (isHighlighted) {
|
|
618
424
|
return css(["background-color:", ";"], getColor('primaryHue', 600, theme, 0.08));
|
|
619
425
|
}
|
|
620
426
|
return css([""]);
|
|
621
427
|
};
|
|
622
|
-
|
|
428
|
+
const StyledHighlight = styled.div.attrs({
|
|
623
429
|
'data-garden-id': COMPONENT_ID$1
|
|
624
430
|
}).withConfig({
|
|
625
431
|
displayName: "StyledHighlight",
|
|
626
432
|
componentId: "sc-16vr32x-0"
|
|
627
|
-
})(["position:absolute;top:0;left:0;width:100%;height:100%;", " ", " ", ";"], retrieveBorderRadius, retrieveColor,
|
|
628
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
629
|
-
});
|
|
433
|
+
})(["position:absolute;top:0;left:0;width:100%;height:100%;", " ", " ", ";"], retrieveBorderRadius, retrieveColor, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
630
434
|
StyledHighlight.defaultProps = {
|
|
631
435
|
theme: DEFAULT_THEME
|
|
632
436
|
};
|
|
633
437
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
438
|
+
const retrieveStyledDayColors = _ref => {
|
|
439
|
+
let {
|
|
440
|
+
isSelected,
|
|
441
|
+
isDisabled,
|
|
442
|
+
isToday,
|
|
443
|
+
isPreviousMonth,
|
|
444
|
+
theme
|
|
445
|
+
} = _ref;
|
|
446
|
+
let backgroundColor = 'inherit';
|
|
447
|
+
let color = getColor('primaryHue', 600, theme);
|
|
642
448
|
if (isSelected && !isDisabled) {
|
|
643
449
|
backgroundColor = getColor('primaryHue', 600, theme);
|
|
644
450
|
color = theme.colors.background;
|
|
@@ -649,36 +455,36 @@ var retrieveStyledDayColors = function retrieveStyledDayColors(_ref) {
|
|
|
649
455
|
} else if (isPreviousMonth) {
|
|
650
456
|
color = getColor('neutralHue', 600, theme);
|
|
651
457
|
}
|
|
652
|
-
return css(["background-color:", ";color:", ";", ""], backgroundColor, color, !isSelected && !isDisabled &&
|
|
458
|
+
return css(["background-color:", ";color:", ";", ""], backgroundColor, color, !isSelected && !isDisabled && `
|
|
459
|
+
:hover {
|
|
460
|
+
background-color: ${getColor('primaryHue', 600, theme, 0.08)};
|
|
461
|
+
color: ${getColor('primaryHue', 800, theme)};
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
:active {
|
|
465
|
+
background-color: ${getColor('primaryHue', 600, theme, 0.2)};
|
|
466
|
+
color: ${getColor('primaryHue', 800, theme)};
|
|
467
|
+
}
|
|
468
|
+
`);
|
|
653
469
|
};
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
};
|
|
660
|
-
}).withConfig({
|
|
470
|
+
const COMPONENT_ID = 'datepickers.day';
|
|
471
|
+
const StyledDay = styled.div.attrs(props => ({
|
|
472
|
+
'data-garden-id': COMPONENT_ID,
|
|
473
|
+
'aria-disabled': props.isDisabled ? 'true' : 'false'
|
|
474
|
+
})).withConfig({
|
|
661
475
|
displayName: "StyledDay",
|
|
662
476
|
componentId: "sc-v42uk5-0"
|
|
663
|
-
})(["display:flex;position:absolute;align-items:center;justify-content:center;border-radius:50%;cursor:", ";width:100%;height:100%;font-size:", ";font-weight:", ";", " ", ";"],
|
|
664
|
-
return props.isDisabled ? 'inherit' : 'pointer';
|
|
665
|
-
}, function (props) {
|
|
666
|
-
return props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md;
|
|
667
|
-
}, function (props) {
|
|
668
|
-
return props.isToday && !props.isDisabled ? props.theme.fontWeights.semibold : 'inherit';
|
|
669
|
-
}, retrieveStyledDayColors, function (props) {
|
|
670
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
671
|
-
});
|
|
477
|
+
})(["display:flex;position:absolute;align-items:center;justify-content:center;border-radius:50%;cursor:", ";width:100%;height:100%;font-size:", ";font-weight:", ";", " ", ";"], props => props.isDisabled ? 'inherit' : 'pointer', props => props.isCompact ? props.theme.fontSizes.sm : props.theme.fontSizes.md, props => props.isToday && !props.isDisabled ? props.theme.fontWeights.semibold : 'inherit', retrieveStyledDayColors, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
672
478
|
StyledDay.defaultProps = {
|
|
673
479
|
theme: DEFAULT_THEME
|
|
674
480
|
};
|
|
675
481
|
|
|
676
|
-
|
|
677
|
-
|
|
482
|
+
const DatepickerContext = createContext(undefined);
|
|
483
|
+
const useDatepickerContext$1 = () => {
|
|
678
484
|
return useContext(DatepickerContext);
|
|
679
485
|
};
|
|
680
486
|
|
|
681
|
-
|
|
487
|
+
const REGION_MAPPINGS = {
|
|
682
488
|
'ar-DZ': 0,
|
|
683
489
|
'ar-SA': 0,
|
|
684
490
|
'en-CA': 0,
|
|
@@ -691,7 +497,7 @@ var REGION_MAPPINGS = {
|
|
|
691
497
|
'zh-CN': 1,
|
|
692
498
|
'zh-TW': 1
|
|
693
499
|
};
|
|
694
|
-
|
|
500
|
+
const LANGUAGE_MAPPINGS = {
|
|
695
501
|
af: 0,
|
|
696
502
|
ar: 6,
|
|
697
503
|
be: 1,
|
|
@@ -746,12 +552,12 @@ function getStartOfWeek(locale) {
|
|
|
746
552
|
if (!locale) {
|
|
747
553
|
return 0;
|
|
748
554
|
}
|
|
749
|
-
for (
|
|
555
|
+
for (const region in REGION_MAPPINGS) {
|
|
750
556
|
if (locale.startsWith(region)) {
|
|
751
557
|
return REGION_MAPPINGS[region];
|
|
752
558
|
}
|
|
753
559
|
}
|
|
754
|
-
for (
|
|
560
|
+
for (const language in LANGUAGE_MAPPINGS) {
|
|
755
561
|
if (locale.startsWith(language)) {
|
|
756
562
|
return LANGUAGE_MAPPINGS[language];
|
|
757
563
|
}
|
|
@@ -761,16 +567,17 @@ function getStartOfWeek(locale) {
|
|
|
761
567
|
|
|
762
568
|
var _path$1;
|
|
763
569
|
|
|
764
|
-
function _extends$
|
|
570
|
+
function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
765
571
|
|
|
766
572
|
var SvgChevronLeftStroke = function SvgChevronLeftStroke(props) {
|
|
767
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
573
|
+
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
768
574
|
xmlns: "http://www.w3.org/2000/svg",
|
|
769
575
|
width: 16,
|
|
770
576
|
height: 16,
|
|
771
577
|
focusable: "false",
|
|
772
578
|
viewBox: "0 0 16 16",
|
|
773
|
-
"aria-hidden": "true"
|
|
579
|
+
"aria-hidden": "true",
|
|
580
|
+
role: "img"
|
|
774
581
|
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
775
582
|
fill: "currentColor",
|
|
776
583
|
d: "M10.39 12.688a.5.5 0 01-.718.69l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L6.641 8l3.75 4.688z"
|
|
@@ -779,30 +586,34 @@ var SvgChevronLeftStroke = function SvgChevronLeftStroke(props) {
|
|
|
779
586
|
|
|
780
587
|
var _path;
|
|
781
588
|
|
|
782
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
589
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
783
590
|
|
|
784
591
|
var SvgChevronRightStroke = function SvgChevronRightStroke(props) {
|
|
785
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
592
|
+
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
786
593
|
xmlns: "http://www.w3.org/2000/svg",
|
|
787
594
|
width: 16,
|
|
788
595
|
height: 16,
|
|
789
596
|
focusable: "false",
|
|
790
597
|
viewBox: "0 0 16 16",
|
|
791
|
-
"aria-hidden": "true"
|
|
598
|
+
"aria-hidden": "true",
|
|
599
|
+
role: "img"
|
|
792
600
|
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
793
601
|
fill: "currentColor",
|
|
794
602
|
d: "M5.61 3.312a.5.5 0 01.718-.69l.062.066 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L9.359 8l-3.75-4.688z"
|
|
795
603
|
})));
|
|
796
604
|
};
|
|
797
605
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
606
|
+
const MonthSelector = _ref => {
|
|
607
|
+
let {
|
|
608
|
+
locale,
|
|
609
|
+
isCompact
|
|
610
|
+
} = _ref;
|
|
611
|
+
const {
|
|
612
|
+
state,
|
|
613
|
+
dispatch
|
|
614
|
+
} = useDatepickerContext$1();
|
|
615
|
+
const headerLabelFormatter = useCallback(date => {
|
|
616
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
806
617
|
month: 'long',
|
|
807
618
|
year: 'numeric'
|
|
808
619
|
});
|
|
@@ -812,7 +623,7 @@ var MonthSelector = function MonthSelector(_ref) {
|
|
|
812
623
|
isCompact: isCompact
|
|
813
624
|
}, React__default.createElement(StyledHeaderPaddle, {
|
|
814
625
|
isCompact: isCompact,
|
|
815
|
-
onClick:
|
|
626
|
+
onClick: () => {
|
|
816
627
|
dispatch({
|
|
817
628
|
type: 'PREVIEW_PREVIOUS_MONTH'
|
|
818
629
|
});
|
|
@@ -821,7 +632,7 @@ var MonthSelector = function MonthSelector(_ref) {
|
|
|
821
632
|
isCompact: isCompact
|
|
822
633
|
}, headerLabelFormatter(state.previewDate)), React__default.createElement(StyledHeaderPaddle, {
|
|
823
634
|
isCompact: isCompact,
|
|
824
|
-
onClick:
|
|
635
|
+
onClick: () => {
|
|
825
636
|
dispatch({
|
|
826
637
|
type: 'PREVIEW_NEXT_MONTH'
|
|
827
638
|
});
|
|
@@ -829,52 +640,55 @@ var MonthSelector = function MonthSelector(_ref) {
|
|
|
829
640
|
}, React__default.createElement(SvgChevronRightStroke, null)));
|
|
830
641
|
};
|
|
831
642
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
643
|
+
const Calendar$1 = forwardRef((_ref, ref) => {
|
|
644
|
+
let {
|
|
645
|
+
value,
|
|
646
|
+
minValue,
|
|
647
|
+
maxValue,
|
|
648
|
+
isCompact,
|
|
649
|
+
locale,
|
|
650
|
+
weekStartsOn
|
|
651
|
+
} = _ref;
|
|
652
|
+
const {
|
|
653
|
+
state,
|
|
654
|
+
dispatch
|
|
655
|
+
} = useDatepickerContext$1();
|
|
656
|
+
const preferredWeekStartsOn = weekStartsOn || getStartOfWeek(locale);
|
|
657
|
+
const monthStartDate = startOfMonth(state.previewDate);
|
|
658
|
+
const monthEndDate = endOfMonth(monthStartDate);
|
|
659
|
+
const startDate = startOfWeek(monthStartDate, {
|
|
846
660
|
weekStartsOn: preferredWeekStartsOn
|
|
847
661
|
});
|
|
848
|
-
|
|
662
|
+
const endDate = endOfWeek(monthEndDate, {
|
|
849
663
|
weekStartsOn: preferredWeekStartsOn
|
|
850
664
|
});
|
|
851
|
-
|
|
852
|
-
|
|
665
|
+
const dayLabelFormatter = useCallback(date => {
|
|
666
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
853
667
|
weekday: 'short'
|
|
854
668
|
});
|
|
855
669
|
return formatter.format(date);
|
|
856
670
|
}, [locale]);
|
|
857
|
-
|
|
671
|
+
const dayLabels = eachDayOfInterval({
|
|
858
672
|
start: startDate,
|
|
859
673
|
end: addDays(startDate, 6)
|
|
860
|
-
}).map(
|
|
861
|
-
|
|
674
|
+
}).map(date => {
|
|
675
|
+
const formattedDayLabel = dayLabelFormatter(date);
|
|
862
676
|
return React__default.createElement(StyledCalendarItem, {
|
|
863
|
-
key:
|
|
677
|
+
key: `day-label-${formattedDayLabel}`,
|
|
864
678
|
isCompact: isCompact
|
|
865
679
|
}, React__default.createElement(StyledDayLabel, {
|
|
866
680
|
isCompact: isCompact
|
|
867
681
|
}, formattedDayLabel));
|
|
868
682
|
});
|
|
869
|
-
|
|
683
|
+
const items = eachDayOfInterval({
|
|
870
684
|
start: startDate,
|
|
871
685
|
end: endDate
|
|
872
|
-
}).map(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
686
|
+
}).map((date, itemsIndex) => {
|
|
687
|
+
const formattedDayLabel = getDate(date);
|
|
688
|
+
const isCurrentDate = isToday(date);
|
|
689
|
+
const isPreviousMonth = !isSameMonth(date, state.previewDate);
|
|
690
|
+
const isSelected = value && isSameDay(date, value);
|
|
691
|
+
let isDisabled = false;
|
|
878
692
|
if (minValue !== undefined) {
|
|
879
693
|
isDisabled = isBefore(date, minValue) && !isSameDay(date, minValue);
|
|
880
694
|
}
|
|
@@ -882,7 +696,7 @@ var Calendar$1 = forwardRef(function (_ref, ref) {
|
|
|
882
696
|
isDisabled = isDisabled || isAfter(date, maxValue) && !isSameDay(date, maxValue);
|
|
883
697
|
}
|
|
884
698
|
return React__default.createElement(StyledCalendarItem, {
|
|
885
|
-
key:
|
|
699
|
+
key: `day-${itemsIndex}`,
|
|
886
700
|
isCompact: isCompact
|
|
887
701
|
}, React__default.createElement(StyledDay, {
|
|
888
702
|
isToday: isCurrentDate,
|
|
@@ -890,7 +704,7 @@ var Calendar$1 = forwardRef(function (_ref, ref) {
|
|
|
890
704
|
isSelected: isSelected,
|
|
891
705
|
isDisabled: isDisabled,
|
|
892
706
|
isCompact: isCompact,
|
|
893
|
-
onClick:
|
|
707
|
+
onClick: () => {
|
|
894
708
|
if (!isDisabled) {
|
|
895
709
|
dispatch({
|
|
896
710
|
type: 'SELECT_DATE',
|
|
@@ -903,7 +717,7 @@ var Calendar$1 = forwardRef(function (_ref, ref) {
|
|
|
903
717
|
return React__default.createElement(StyledDatepicker, {
|
|
904
718
|
ref: ref,
|
|
905
719
|
isCompact: isCompact,
|
|
906
|
-
onMouseDown:
|
|
720
|
+
onMouseDown: e => {
|
|
907
721
|
e.preventDefault();
|
|
908
722
|
}
|
|
909
723
|
}, React__default.createElement(MonthSelector, {
|
|
@@ -1073,6 +887,7 @@ var formatLong = {
|
|
|
1073
887
|
defaultWidth: 'full'
|
|
1074
888
|
})
|
|
1075
889
|
};
|
|
890
|
+
var formatLong$1 = formatLong;
|
|
1076
891
|
|
|
1077
892
|
var formatRelativeLocale = {
|
|
1078
893
|
lastWeek: "'last' eeee 'at' p",
|
|
@@ -1233,6 +1048,7 @@ var localize = {
|
|
|
1233
1048
|
defaultFormattingWidth: 'wide'
|
|
1234
1049
|
})
|
|
1235
1050
|
};
|
|
1051
|
+
var localize$1 = localize;
|
|
1236
1052
|
|
|
1237
1053
|
function buildMatchPatternFn(args) {
|
|
1238
1054
|
return function (string) {
|
|
@@ -1390,20 +1206,22 @@ var match = {
|
|
|
1390
1206
|
defaultParseWidth: 'any'
|
|
1391
1207
|
})
|
|
1392
1208
|
};
|
|
1209
|
+
var match$1 = match;
|
|
1393
1210
|
|
|
1394
1211
|
var locale = {
|
|
1395
1212
|
code: 'en-US',
|
|
1396
1213
|
formatDistance: formatDistance,
|
|
1397
|
-
formatLong: formatLong,
|
|
1214
|
+
formatLong: formatLong$1,
|
|
1398
1215
|
formatRelative: formatRelative,
|
|
1399
|
-
localize: localize,
|
|
1400
|
-
match: match,
|
|
1216
|
+
localize: localize$1,
|
|
1217
|
+
match: match$1,
|
|
1401
1218
|
options: {
|
|
1402
1219
|
weekStartsOn: 0
|
|
1403
1220
|
,
|
|
1404
1221
|
firstWeekContainsDate: 1
|
|
1405
1222
|
}
|
|
1406
1223
|
};
|
|
1224
|
+
var defaultLocale = locale;
|
|
1407
1225
|
|
|
1408
1226
|
function addMilliseconds(dirtyDate, dirtyAmount) {
|
|
1409
1227
|
requiredArgs(2, arguments);
|
|
@@ -1510,6 +1328,7 @@ var longFormatters = {
|
|
|
1510
1328
|
p: timeLongFormatter,
|
|
1511
1329
|
P: dateTimeLongFormatter
|
|
1512
1330
|
};
|
|
1331
|
+
var longFormatters$1 = longFormatters;
|
|
1513
1332
|
|
|
1514
1333
|
function getTimezoneOffsetInMilliseconds(date) {
|
|
1515
1334
|
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
@@ -2921,6 +2740,7 @@ var parsers = {
|
|
|
2921
2740
|
incompatibleTokens: '*'
|
|
2922
2741
|
}
|
|
2923
2742
|
};
|
|
2743
|
+
var parsers$1 = parsers;
|
|
2924
2744
|
|
|
2925
2745
|
var TIMEZONE_UNIT_PRIORITY = 10;
|
|
2926
2746
|
var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
|
|
@@ -2934,17 +2754,17 @@ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, dirtyOpti
|
|
|
2934
2754
|
var dateString = String(dirtyDateString);
|
|
2935
2755
|
var formatString = String(dirtyFormatString);
|
|
2936
2756
|
var options = dirtyOptions || {};
|
|
2937
|
-
var locale
|
|
2938
|
-
if (!locale
|
|
2757
|
+
var locale = options.locale || defaultLocale;
|
|
2758
|
+
if (!locale.match) {
|
|
2939
2759
|
throw new RangeError('locale must contain match property');
|
|
2940
2760
|
}
|
|
2941
|
-
var localeFirstWeekContainsDate = locale
|
|
2761
|
+
var localeFirstWeekContainsDate = locale.options && locale.options.firstWeekContainsDate;
|
|
2942
2762
|
var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
|
|
2943
2763
|
var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
|
|
2944
2764
|
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
|
|
2945
2765
|
throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
|
|
2946
2766
|
}
|
|
2947
|
-
var localeWeekStartsOn = locale
|
|
2767
|
+
var localeWeekStartsOn = locale.options && locale.options.weekStartsOn;
|
|
2948
2768
|
var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
|
|
2949
2769
|
var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn);
|
|
2950
2770
|
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
@@ -2960,7 +2780,7 @@ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, dirtyOpti
|
|
|
2960
2780
|
var subFnOptions = {
|
|
2961
2781
|
firstWeekContainsDate: firstWeekContainsDate,
|
|
2962
2782
|
weekStartsOn: weekStartsOn,
|
|
2963
|
-
locale: locale
|
|
2783
|
+
locale: locale
|
|
2964
2784
|
};
|
|
2965
2785
|
var setters = [{
|
|
2966
2786
|
priority: TIMEZONE_UNIT_PRIORITY,
|
|
@@ -2972,8 +2792,8 @@ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, dirtyOpti
|
|
|
2972
2792
|
var tokens = formatString.match(longFormattingTokensRegExp).map(function (substring) {
|
|
2973
2793
|
var firstCharacter = substring[0];
|
|
2974
2794
|
if (firstCharacter === 'p' || firstCharacter === 'P') {
|
|
2975
|
-
var longFormatter = longFormatters[firstCharacter];
|
|
2976
|
-
return longFormatter(substring, locale
|
|
2795
|
+
var longFormatter = longFormatters$1[firstCharacter];
|
|
2796
|
+
return longFormatter(substring, locale.formatLong, subFnOptions);
|
|
2977
2797
|
}
|
|
2978
2798
|
return substring;
|
|
2979
2799
|
}).join('').match(formattingTokensRegExp);
|
|
@@ -2987,7 +2807,7 @@ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, dirtyOpti
|
|
|
2987
2807
|
throwProtectedError(token, formatString, dirtyDateString);
|
|
2988
2808
|
}
|
|
2989
2809
|
var firstCharacter = token[0];
|
|
2990
|
-
var parser = parsers[firstCharacter];
|
|
2810
|
+
var parser = parsers$1[firstCharacter];
|
|
2991
2811
|
if (parser) {
|
|
2992
2812
|
var incompatibleTokens = parser.incompatibleTokens;
|
|
2993
2813
|
if (Array.isArray(incompatibleTokens)) {
|
|
@@ -3009,7 +2829,7 @@ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, dirtyOpti
|
|
|
3009
2829
|
token: firstCharacter,
|
|
3010
2830
|
fullToken: token
|
|
3011
2831
|
});
|
|
3012
|
-
var parseResult = parser.parse(dateString, token, locale
|
|
2832
|
+
var parseResult = parser.parse(dateString, token, locale.match, subFnOptions);
|
|
3013
2833
|
if (!parseResult) {
|
|
3014
2834
|
return new Date(NaN);
|
|
3015
2835
|
}
|
|
@@ -3091,13 +2911,15 @@ function cleanEscapedString(input) {
|
|
|
3091
2911
|
}
|
|
3092
2912
|
|
|
3093
2913
|
function parseInputValue$1(_ref) {
|
|
3094
|
-
|
|
3095
|
-
|
|
2914
|
+
let {
|
|
2915
|
+
inputValue,
|
|
2916
|
+
customParseDate
|
|
2917
|
+
} = _ref;
|
|
3096
2918
|
if (customParseDate) {
|
|
3097
2919
|
return customParseDate(inputValue);
|
|
3098
2920
|
}
|
|
3099
|
-
|
|
3100
|
-
|
|
2921
|
+
const MINIMUM_DATE = new Date(1001, 0, 0);
|
|
2922
|
+
let tryParseDate = parse(inputValue, 'P', new Date());
|
|
3101
2923
|
if (isValid(tryParseDate) && !isBefore(tryParseDate, MINIMUM_DATE)) {
|
|
3102
2924
|
return tryParseDate;
|
|
3103
2925
|
}
|
|
@@ -3112,9 +2934,11 @@ function parseInputValue$1(_ref) {
|
|
|
3112
2934
|
return new Date(NaN);
|
|
3113
2935
|
}
|
|
3114
2936
|
function formatInputValue(_ref2) {
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
2937
|
+
let {
|
|
2938
|
+
date,
|
|
2939
|
+
locale,
|
|
2940
|
+
formatDate
|
|
2941
|
+
} = _ref2;
|
|
3118
2942
|
if (!date) {
|
|
3119
2943
|
return '';
|
|
3120
2944
|
}
|
|
@@ -3127,98 +2951,108 @@ function formatInputValue(_ref2) {
|
|
|
3127
2951
|
year: 'numeric'
|
|
3128
2952
|
}).format(date);
|
|
3129
2953
|
}
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
2954
|
+
const datepickerReducer = _ref3 => {
|
|
2955
|
+
let {
|
|
2956
|
+
value,
|
|
2957
|
+
formatDate,
|
|
2958
|
+
locale,
|
|
2959
|
+
customParseDate,
|
|
2960
|
+
onChange
|
|
2961
|
+
} = _ref3;
|
|
2962
|
+
return (state, action) => {
|
|
3137
2963
|
switch (action.type) {
|
|
3138
2964
|
case 'OPEN':
|
|
3139
|
-
return
|
|
2965
|
+
return {
|
|
2966
|
+
...state,
|
|
3140
2967
|
isOpen: true,
|
|
3141
2968
|
previewDate: value || new Date()
|
|
3142
|
-
}
|
|
2969
|
+
};
|
|
3143
2970
|
case 'CLOSE':
|
|
3144
2971
|
{
|
|
3145
|
-
|
|
2972
|
+
const inputValue = formatInputValue({
|
|
3146
2973
|
date: value,
|
|
3147
|
-
locale
|
|
3148
|
-
formatDate
|
|
2974
|
+
locale,
|
|
2975
|
+
formatDate
|
|
3149
2976
|
});
|
|
3150
|
-
return
|
|
2977
|
+
return {
|
|
2978
|
+
...state,
|
|
3151
2979
|
isOpen: false,
|
|
3152
|
-
inputValue
|
|
3153
|
-
}
|
|
2980
|
+
inputValue
|
|
2981
|
+
};
|
|
3154
2982
|
}
|
|
3155
2983
|
case 'PREVIEW_NEXT_MONTH':
|
|
3156
2984
|
{
|
|
3157
|
-
|
|
3158
|
-
return
|
|
3159
|
-
|
|
3160
|
-
|
|
2985
|
+
const previewDate = addMonths(state.previewDate, 1);
|
|
2986
|
+
return {
|
|
2987
|
+
...state,
|
|
2988
|
+
previewDate
|
|
2989
|
+
};
|
|
3161
2990
|
}
|
|
3162
2991
|
case 'PREVIEW_PREVIOUS_MONTH':
|
|
3163
2992
|
{
|
|
3164
|
-
|
|
3165
|
-
return
|
|
3166
|
-
|
|
3167
|
-
|
|
2993
|
+
const previewDate = subMonths(state.previewDate, 1);
|
|
2994
|
+
return {
|
|
2995
|
+
...state,
|
|
2996
|
+
previewDate
|
|
2997
|
+
};
|
|
3168
2998
|
}
|
|
3169
2999
|
case 'MANUALLY_UPDATE_INPUT':
|
|
3170
3000
|
{
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
inputValue
|
|
3174
|
-
customParseDate
|
|
3001
|
+
const inputValue = action.value;
|
|
3002
|
+
const currentDate = parseInputValue$1({
|
|
3003
|
+
inputValue,
|
|
3004
|
+
customParseDate
|
|
3175
3005
|
});
|
|
3176
3006
|
if (onChange && currentDate && isValid(currentDate) && !isSameDay(value, currentDate)) {
|
|
3177
3007
|
onChange(currentDate);
|
|
3178
3008
|
}
|
|
3179
|
-
return
|
|
3009
|
+
return {
|
|
3010
|
+
...state,
|
|
3180
3011
|
isOpen: true,
|
|
3181
|
-
inputValue
|
|
3182
|
-
}
|
|
3012
|
+
inputValue
|
|
3013
|
+
};
|
|
3183
3014
|
}
|
|
3184
3015
|
case 'CONTROLLED_VALUE_CHANGE':
|
|
3185
3016
|
{
|
|
3186
|
-
|
|
3187
|
-
|
|
3017
|
+
const previewDate = action.value || new Date();
|
|
3018
|
+
const inputValue = formatInputValue({
|
|
3188
3019
|
date: action.value,
|
|
3189
|
-
locale
|
|
3190
|
-
formatDate
|
|
3191
|
-
});
|
|
3192
|
-
return
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3020
|
+
locale,
|
|
3021
|
+
formatDate
|
|
3022
|
+
});
|
|
3023
|
+
return {
|
|
3024
|
+
...state,
|
|
3025
|
+
previewDate,
|
|
3026
|
+
inputValue
|
|
3027
|
+
};
|
|
3196
3028
|
}
|
|
3197
3029
|
case 'CONTROLLED_LOCALE_CHANGE':
|
|
3198
3030
|
{
|
|
3199
|
-
|
|
3031
|
+
const inputValue = formatInputValue({
|
|
3200
3032
|
date: value,
|
|
3201
|
-
locale
|
|
3202
|
-
formatDate
|
|
3203
|
-
});
|
|
3204
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
3205
|
-
inputValue: _inputValue3
|
|
3033
|
+
locale,
|
|
3034
|
+
formatDate
|
|
3206
3035
|
});
|
|
3036
|
+
return {
|
|
3037
|
+
...state,
|
|
3038
|
+
inputValue
|
|
3039
|
+
};
|
|
3207
3040
|
}
|
|
3208
3041
|
case 'SELECT_DATE':
|
|
3209
3042
|
{
|
|
3210
|
-
|
|
3043
|
+
const inputValue = formatInputValue({
|
|
3211
3044
|
date: action.value,
|
|
3212
|
-
locale
|
|
3213
|
-
formatDate
|
|
3045
|
+
locale,
|
|
3046
|
+
formatDate
|
|
3214
3047
|
});
|
|
3215
3048
|
if (onChange && action.value && isValid(action.value) && !isSameDay(value, action.value)) {
|
|
3216
3049
|
onChange(action.value);
|
|
3217
3050
|
}
|
|
3218
|
-
return
|
|
3051
|
+
return {
|
|
3052
|
+
...state,
|
|
3219
3053
|
isOpen: false,
|
|
3220
|
-
inputValue
|
|
3221
|
-
}
|
|
3054
|
+
inputValue
|
|
3055
|
+
};
|
|
3222
3056
|
}
|
|
3223
3057
|
default:
|
|
3224
3058
|
throw new Error();
|
|
@@ -3226,11 +3060,11 @@ var datepickerReducer = function datepickerReducer(_ref3) {
|
|
|
3226
3060
|
};
|
|
3227
3061
|
};
|
|
3228
3062
|
function retrieveInitialState$1(initialProps) {
|
|
3229
|
-
|
|
3063
|
+
let previewDate = initialProps.value;
|
|
3230
3064
|
if (previewDate === undefined || !isValid(previewDate)) {
|
|
3231
3065
|
previewDate = new Date();
|
|
3232
3066
|
}
|
|
3233
|
-
|
|
3067
|
+
let inputValue = '';
|
|
3234
3068
|
if (initialProps.value !== undefined) {
|
|
3235
3069
|
if (initialProps.formatDate) {
|
|
3236
3070
|
inputValue = initialProps.formatDate(initialProps.value);
|
|
@@ -3244,144 +3078,146 @@ function retrieveInitialState$1(initialProps) {
|
|
|
3244
3078
|
}
|
|
3245
3079
|
return {
|
|
3246
3080
|
isOpen: false,
|
|
3247
|
-
previewDate
|
|
3248
|
-
inputValue
|
|
3081
|
+
previewDate,
|
|
3082
|
+
inputValue
|
|
3249
3083
|
};
|
|
3250
3084
|
}
|
|
3251
3085
|
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3086
|
+
const Datepicker = forwardRef((props, calendarRef) => {
|
|
3087
|
+
const {
|
|
3088
|
+
children,
|
|
3089
|
+
placement,
|
|
3090
|
+
popperModifiers,
|
|
3091
|
+
eventsEnabled,
|
|
3092
|
+
zIndex,
|
|
3093
|
+
isAnimated,
|
|
3094
|
+
refKey,
|
|
3095
|
+
value,
|
|
3096
|
+
isCompact,
|
|
3097
|
+
onChange,
|
|
3098
|
+
formatDate,
|
|
3099
|
+
minValue,
|
|
3100
|
+
maxValue,
|
|
3101
|
+
locale,
|
|
3102
|
+
weekStartsOn,
|
|
3103
|
+
customParseDate,
|
|
3104
|
+
...menuProps
|
|
3105
|
+
} = props;
|
|
3106
|
+
const theme = useContext(ThemeContext);
|
|
3107
|
+
const memoizedReducer = useCallback(datepickerReducer({
|
|
3108
|
+
value,
|
|
3109
|
+
formatDate,
|
|
3110
|
+
locale,
|
|
3111
|
+
customParseDate,
|
|
3112
|
+
onChange
|
|
3278
3113
|
}), [value, formatDate, locale, onChange, customParseDate]);
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
var inputRef = useRef(null);
|
|
3285
|
-
var isInputMouseDownRef = useRef(false);
|
|
3286
|
-
useEffect(function () {
|
|
3114
|
+
const [state, dispatch] = useReducer(memoizedReducer, retrieveInitialState$1(props));
|
|
3115
|
+
const scheduleUpdateRef = useRef(undefined);
|
|
3116
|
+
const inputRef = useRef(null);
|
|
3117
|
+
const isInputMouseDownRef = useRef(false);
|
|
3118
|
+
useEffect(() => {
|
|
3287
3119
|
if (state.isOpen && scheduleUpdateRef.current) {
|
|
3288
3120
|
scheduleUpdateRef.current();
|
|
3289
3121
|
}
|
|
3290
3122
|
});
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
setIsVisible = _useState2[1];
|
|
3295
|
-
useEffect(function () {
|
|
3296
|
-
var timeout;
|
|
3123
|
+
const [isVisible, setIsVisible] = useState(state.isOpen);
|
|
3124
|
+
useEffect(() => {
|
|
3125
|
+
let timeout;
|
|
3297
3126
|
if (state.isOpen) {
|
|
3298
3127
|
setIsVisible(true);
|
|
3299
3128
|
} else if (isAnimated) {
|
|
3300
|
-
timeout = setTimeout(
|
|
3301
|
-
return setIsVisible(false);
|
|
3302
|
-
}, 200);
|
|
3129
|
+
timeout = setTimeout(() => setIsVisible(false), 200);
|
|
3303
3130
|
} else {
|
|
3304
3131
|
setIsVisible(false);
|
|
3305
3132
|
}
|
|
3306
|
-
return
|
|
3307
|
-
return clearTimeout(timeout);
|
|
3308
|
-
};
|
|
3133
|
+
return () => clearTimeout(timeout);
|
|
3309
3134
|
}, [state.isOpen, isAnimated]);
|
|
3310
|
-
useEffect(
|
|
3135
|
+
useEffect(() => {
|
|
3311
3136
|
dispatch({
|
|
3312
3137
|
type: 'CONTROLLED_VALUE_CHANGE',
|
|
3313
|
-
value
|
|
3138
|
+
value
|
|
3314
3139
|
});
|
|
3315
3140
|
}, [value]);
|
|
3316
|
-
useEffect(
|
|
3141
|
+
useEffect(() => {
|
|
3317
3142
|
dispatch({
|
|
3318
3143
|
type: 'CONTROLLED_LOCALE_CHANGE'
|
|
3319
3144
|
});
|
|
3320
3145
|
}, [locale]);
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
};
|
|
3327
|
-
}, [state, dispatch]);
|
|
3146
|
+
const popperPlacement = theme.rtl ? getRtlPopperPlacement(placement) : getPopperPlacement(placement);
|
|
3147
|
+
const contextValue = useMemo(() => ({
|
|
3148
|
+
state,
|
|
3149
|
+
dispatch
|
|
3150
|
+
}), [state, dispatch]);
|
|
3328
3151
|
return React__default.createElement(DatepickerContext.Provider, {
|
|
3329
3152
|
value: contextValue
|
|
3330
|
-
}, React__default.createElement(Manager, null, React__default.createElement(Reference, null,
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
isInputMouseDownRef.current =
|
|
3342
|
-
},
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
dispatch({
|
|
3351
|
-
type: 'CLOSE'
|
|
3352
|
-
});
|
|
3353
|
-
})), _defineProperty(_React$cloneElement, "onChange", composeEventHandlers(childElement.props.onChange, function (e) {
|
|
3354
|
-
dispatch({
|
|
3355
|
-
type: 'MANUALLY_UPDATE_INPUT',
|
|
3356
|
-
value: e.target.value
|
|
3357
|
-
});
|
|
3358
|
-
})), _defineProperty(_React$cloneElement, "onKeyDown", composeEventHandlers(childElement.props.onKeyDown, function (e) {
|
|
3359
|
-
switch (e.keyCode) {
|
|
3360
|
-
case KEY_CODES.ESCAPE:
|
|
3361
|
-
case KEY_CODES.ENTER:
|
|
3362
|
-
dispatch({
|
|
3363
|
-
type: 'CLOSE'
|
|
3364
|
-
});
|
|
3365
|
-
break;
|
|
3366
|
-
case KEY_CODES.UP:
|
|
3367
|
-
case KEY_CODES.DOWN:
|
|
3368
|
-
case KEY_CODES.SPACE:
|
|
3153
|
+
}, React__default.createElement(Manager, null, React__default.createElement(Reference, null, _ref => {
|
|
3154
|
+
let {
|
|
3155
|
+
ref
|
|
3156
|
+
} = _ref;
|
|
3157
|
+
const childElement = React__default.Children.only(children);
|
|
3158
|
+
return React__default.cloneElement(childElement, {
|
|
3159
|
+
[refKey]: refValue => {
|
|
3160
|
+
ref(refValue);
|
|
3161
|
+
inputRef.current = refValue;
|
|
3162
|
+
},
|
|
3163
|
+
onMouseDown: composeEventHandlers(childElement.props.onMouseDown, () => {
|
|
3164
|
+
isInputMouseDownRef.current = true;
|
|
3165
|
+
}),
|
|
3166
|
+
onMouseUp: composeEventHandlers(childElement.props.onMouseUp, () => {
|
|
3167
|
+
setTimeout(() => {
|
|
3168
|
+
isInputMouseDownRef.current = false;
|
|
3169
|
+
}, 0);
|
|
3170
|
+
}),
|
|
3171
|
+
onClick: composeEventHandlers(childElement.props.onClick, () => {
|
|
3172
|
+
if (isInputMouseDownRef.current && !state.isOpen) {
|
|
3369
3173
|
dispatch({
|
|
3370
3174
|
type: 'OPEN'
|
|
3371
3175
|
});
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3374
|
-
|
|
3176
|
+
}
|
|
3177
|
+
}),
|
|
3178
|
+
onBlur: composeEventHandlers(childElement.props.onBlur, () => {
|
|
3179
|
+
dispatch({
|
|
3180
|
+
type: 'CLOSE'
|
|
3181
|
+
});
|
|
3182
|
+
}),
|
|
3183
|
+
onChange: composeEventHandlers(childElement.props.onChange, e => {
|
|
3184
|
+
dispatch({
|
|
3185
|
+
type: 'MANUALLY_UPDATE_INPUT',
|
|
3186
|
+
value: e.target.value
|
|
3187
|
+
});
|
|
3188
|
+
}),
|
|
3189
|
+
onKeyDown: composeEventHandlers(childElement.props.onKeyDown, e => {
|
|
3190
|
+
switch (e.keyCode) {
|
|
3191
|
+
case KEY_CODES.ESCAPE:
|
|
3192
|
+
case KEY_CODES.ENTER:
|
|
3193
|
+
dispatch({
|
|
3194
|
+
type: 'CLOSE'
|
|
3195
|
+
});
|
|
3196
|
+
break;
|
|
3197
|
+
case KEY_CODES.UP:
|
|
3198
|
+
case KEY_CODES.DOWN:
|
|
3199
|
+
case KEY_CODES.SPACE:
|
|
3200
|
+
dispatch({
|
|
3201
|
+
type: 'OPEN'
|
|
3202
|
+
});
|
|
3203
|
+
break;
|
|
3204
|
+
}
|
|
3205
|
+
}),
|
|
3206
|
+
autoComplete: 'off',
|
|
3207
|
+
value: state.inputValue
|
|
3208
|
+
});
|
|
3375
3209
|
}), React__default.createElement(Popper, {
|
|
3376
3210
|
placement: popperPlacement,
|
|
3377
3211
|
modifiers: popperModifiers
|
|
3378
3212
|
,
|
|
3379
3213
|
eventsEnabled: state.isOpen && eventsEnabled
|
|
3380
|
-
},
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3214
|
+
}, _ref2 => {
|
|
3215
|
+
let {
|
|
3216
|
+
ref,
|
|
3217
|
+
style,
|
|
3218
|
+
scheduleUpdate,
|
|
3219
|
+
placement: currentPlacement
|
|
3220
|
+
} = _ref2;
|
|
3385
3221
|
scheduleUpdateRef.current = scheduleUpdate;
|
|
3386
3222
|
return React__default.createElement(StyledMenuWrapper, {
|
|
3387
3223
|
ref: ref,
|
|
@@ -3443,10 +3279,12 @@ function compareAsc(dirtyDateLeft, dirtyDateRight) {
|
|
|
3443
3279
|
}
|
|
3444
3280
|
|
|
3445
3281
|
function formatValue(_ref) {
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3282
|
+
let {
|
|
3283
|
+
value,
|
|
3284
|
+
locale,
|
|
3285
|
+
formatDate
|
|
3286
|
+
} = _ref;
|
|
3287
|
+
let stringValue = '';
|
|
3450
3288
|
if (value !== undefined && isValid(value)) {
|
|
3451
3289
|
if (formatDate) {
|
|
3452
3290
|
stringValue = formatDate(value);
|
|
@@ -3461,9 +3299,11 @@ function formatValue(_ref) {
|
|
|
3461
3299
|
return stringValue;
|
|
3462
3300
|
}
|
|
3463
3301
|
function parseInputValue(_ref2) {
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3302
|
+
let {
|
|
3303
|
+
inputValue
|
|
3304
|
+
} = _ref2;
|
|
3305
|
+
const MINIMUM_DATE = new Date(1001, 0, 0);
|
|
3306
|
+
let tryParseDate = parse(inputValue || '', 'P', new Date());
|
|
3467
3307
|
if (isValid(tryParseDate) && !isBefore(tryParseDate, MINIMUM_DATE)) {
|
|
3468
3308
|
return tryParseDate;
|
|
3469
3309
|
}
|
|
@@ -3477,17 +3317,19 @@ function parseInputValue(_ref2) {
|
|
|
3477
3317
|
}
|
|
3478
3318
|
return new Date(NaN);
|
|
3479
3319
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3320
|
+
const datepickerRangeReducer = _ref3 => {
|
|
3321
|
+
let {
|
|
3322
|
+
startValue,
|
|
3323
|
+
endValue,
|
|
3324
|
+
locale,
|
|
3325
|
+
formatDate,
|
|
3326
|
+
customParseDate
|
|
3327
|
+
} = _ref3;
|
|
3328
|
+
return (state, action) => {
|
|
3487
3329
|
switch (action.type) {
|
|
3488
3330
|
case 'START_FOCUS':
|
|
3489
3331
|
{
|
|
3490
|
-
|
|
3332
|
+
let previewDate = state.previewDate;
|
|
3491
3333
|
if (startValue) {
|
|
3492
3334
|
if (compareAsc(startValue, startOfMonth(state.previewDate)) === 1 && compareAsc(startValue, addMonths(endOfMonth(state.previewDate), 1)) === -1) {
|
|
3493
3335
|
previewDate = state.previewDate;
|
|
@@ -3495,31 +3337,33 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
|
|
|
3495
3337
|
previewDate = startOfMonth(startValue);
|
|
3496
3338
|
}
|
|
3497
3339
|
}
|
|
3498
|
-
return
|
|
3499
|
-
|
|
3340
|
+
return {
|
|
3341
|
+
...state,
|
|
3342
|
+
previewDate,
|
|
3500
3343
|
isStartFocused: true,
|
|
3501
3344
|
isEndFocused: false
|
|
3502
|
-
}
|
|
3345
|
+
};
|
|
3503
3346
|
}
|
|
3504
3347
|
case 'END_FOCUS':
|
|
3505
3348
|
{
|
|
3506
|
-
|
|
3349
|
+
let previewDate = state.previewDate;
|
|
3507
3350
|
if (endValue) {
|
|
3508
3351
|
if (compareAsc(endValue, startOfMonth(state.previewDate)) === 1 && compareAsc(endValue, addMonths(endOfMonth(state.previewDate), 1)) === -1) {
|
|
3509
|
-
|
|
3352
|
+
previewDate = state.previewDate;
|
|
3510
3353
|
} else {
|
|
3511
|
-
|
|
3354
|
+
previewDate = startOfMonth(endValue);
|
|
3512
3355
|
}
|
|
3513
3356
|
}
|
|
3514
|
-
return
|
|
3515
|
-
|
|
3357
|
+
return {
|
|
3358
|
+
...state,
|
|
3359
|
+
previewDate,
|
|
3516
3360
|
isEndFocused: true,
|
|
3517
3361
|
isStartFocused: false
|
|
3518
|
-
}
|
|
3362
|
+
};
|
|
3519
3363
|
}
|
|
3520
3364
|
case 'START_BLUR':
|
|
3521
3365
|
{
|
|
3522
|
-
|
|
3366
|
+
let parsedDate;
|
|
3523
3367
|
if (customParseDate) {
|
|
3524
3368
|
parsedDate = customParseDate(state.startInputValue);
|
|
3525
3369
|
} else {
|
|
@@ -3527,168 +3371,184 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
|
|
|
3527
3371
|
inputValue: state.startInputValue
|
|
3528
3372
|
});
|
|
3529
3373
|
}
|
|
3530
|
-
|
|
3374
|
+
const startInputValue = formatValue({
|
|
3531
3375
|
value: parsedDate,
|
|
3532
|
-
locale
|
|
3533
|
-
formatDate
|
|
3376
|
+
locale,
|
|
3377
|
+
formatDate
|
|
3534
3378
|
});
|
|
3535
|
-
return
|
|
3379
|
+
return {
|
|
3380
|
+
...state,
|
|
3536
3381
|
startInputValue: startInputValue || formatValue({
|
|
3537
3382
|
value: startValue,
|
|
3538
|
-
locale
|
|
3539
|
-
formatDate
|
|
3383
|
+
locale,
|
|
3384
|
+
formatDate
|
|
3540
3385
|
}),
|
|
3541
3386
|
isStartFocused: false
|
|
3542
|
-
}
|
|
3387
|
+
};
|
|
3543
3388
|
}
|
|
3544
3389
|
case 'END_BLUR':
|
|
3545
3390
|
{
|
|
3546
|
-
|
|
3391
|
+
let parsedDate;
|
|
3547
3392
|
if (customParseDate) {
|
|
3548
|
-
|
|
3393
|
+
parsedDate = customParseDate(state.endInputValue);
|
|
3549
3394
|
} else {
|
|
3550
|
-
|
|
3395
|
+
parsedDate = parseInputValue({
|
|
3551
3396
|
inputValue: state.endInputValue
|
|
3552
3397
|
});
|
|
3553
3398
|
}
|
|
3554
|
-
|
|
3555
|
-
value:
|
|
3556
|
-
locale
|
|
3557
|
-
formatDate
|
|
3399
|
+
const endInputValue = formatValue({
|
|
3400
|
+
value: parsedDate,
|
|
3401
|
+
locale,
|
|
3402
|
+
formatDate
|
|
3558
3403
|
}) || formatValue({
|
|
3559
3404
|
value: endValue,
|
|
3560
|
-
locale
|
|
3561
|
-
formatDate
|
|
3405
|
+
locale,
|
|
3406
|
+
formatDate
|
|
3562
3407
|
});
|
|
3563
|
-
return
|
|
3564
|
-
|
|
3408
|
+
return {
|
|
3409
|
+
...state,
|
|
3410
|
+
endInputValue,
|
|
3565
3411
|
isEndFocused: false
|
|
3566
|
-
}
|
|
3412
|
+
};
|
|
3567
3413
|
}
|
|
3568
3414
|
case 'CONTROLLED_START_VALUE_CHANGE':
|
|
3569
3415
|
{
|
|
3570
|
-
|
|
3416
|
+
const startInputValue = formatValue({
|
|
3571
3417
|
value: action.value,
|
|
3572
|
-
locale
|
|
3573
|
-
formatDate
|
|
3418
|
+
locale,
|
|
3419
|
+
formatDate
|
|
3574
3420
|
});
|
|
3575
|
-
|
|
3421
|
+
let previewDate = state.previewDate;
|
|
3576
3422
|
if (action.value) {
|
|
3577
3423
|
if (compareAsc(action.value, startOfMonth(state.previewDate)) === 1 && compareAsc(action.value, addMonths(endOfMonth(state.previewDate), 1)) === -1) {
|
|
3578
|
-
|
|
3424
|
+
previewDate = state.previewDate;
|
|
3579
3425
|
} else {
|
|
3580
|
-
|
|
3426
|
+
previewDate = startOfMonth(action.value);
|
|
3581
3427
|
}
|
|
3582
3428
|
}
|
|
3583
|
-
return
|
|
3584
|
-
|
|
3429
|
+
return {
|
|
3430
|
+
...state,
|
|
3431
|
+
startInputValue,
|
|
3585
3432
|
hoverDate: undefined,
|
|
3586
|
-
previewDate
|
|
3587
|
-
}
|
|
3433
|
+
previewDate
|
|
3434
|
+
};
|
|
3588
3435
|
}
|
|
3589
3436
|
case 'CONTROLLED_END_VALUE_CHANGE':
|
|
3590
3437
|
{
|
|
3591
|
-
|
|
3438
|
+
const endInputValue = formatValue({
|
|
3592
3439
|
value: action.value,
|
|
3593
|
-
locale
|
|
3594
|
-
formatDate
|
|
3440
|
+
locale,
|
|
3441
|
+
formatDate
|
|
3595
3442
|
});
|
|
3596
|
-
|
|
3443
|
+
let previewDate = state.previewDate;
|
|
3597
3444
|
if (action.value) {
|
|
3598
3445
|
if (compareAsc(action.value, startOfMonth(state.previewDate)) === 1 && compareAsc(action.value, addMonths(endOfMonth(state.previewDate), 1)) === -1) {
|
|
3599
|
-
|
|
3446
|
+
previewDate = state.previewDate;
|
|
3600
3447
|
} else {
|
|
3601
|
-
|
|
3448
|
+
previewDate = startOfMonth(action.value);
|
|
3602
3449
|
}
|
|
3603
3450
|
}
|
|
3604
|
-
return
|
|
3605
|
-
|
|
3451
|
+
return {
|
|
3452
|
+
...state,
|
|
3453
|
+
endInputValue,
|
|
3606
3454
|
hoverDate: undefined,
|
|
3607
|
-
previewDate
|
|
3608
|
-
}
|
|
3455
|
+
previewDate
|
|
3456
|
+
};
|
|
3609
3457
|
}
|
|
3610
3458
|
case 'CLICK_DATE':
|
|
3611
3459
|
if (state.isStartFocused) {
|
|
3612
3460
|
if (endValue !== undefined && (isBefore(action.value, endValue) || isSameDay(action.value, endValue))) {
|
|
3613
|
-
return
|
|
3461
|
+
return {
|
|
3462
|
+
...state,
|
|
3614
3463
|
startInputValue: formatValue({
|
|
3615
3464
|
value: action.value
|
|
3616
3465
|
})
|
|
3617
|
-
}
|
|
3466
|
+
};
|
|
3618
3467
|
}
|
|
3619
|
-
return
|
|
3468
|
+
return {
|
|
3469
|
+
...state,
|
|
3620
3470
|
startInputValue: formatValue({
|
|
3621
3471
|
value: action.value
|
|
3622
3472
|
}),
|
|
3623
3473
|
endInputValue: undefined
|
|
3624
|
-
}
|
|
3474
|
+
};
|
|
3625
3475
|
} else if (state.isEndFocused) {
|
|
3626
3476
|
if (startValue !== undefined && (isAfter(action.value, startValue) || isSameDay(action.value, startValue))) {
|
|
3627
|
-
return
|
|
3477
|
+
return {
|
|
3478
|
+
...state,
|
|
3628
3479
|
endInputValue: formatValue({
|
|
3629
3480
|
value: action.value
|
|
3630
3481
|
})
|
|
3631
|
-
}
|
|
3482
|
+
};
|
|
3632
3483
|
}
|
|
3633
|
-
return
|
|
3484
|
+
return {
|
|
3485
|
+
...state,
|
|
3634
3486
|
startInputValue: formatValue({
|
|
3635
3487
|
value: action.value
|
|
3636
3488
|
})
|
|
3637
|
-
}
|
|
3489
|
+
};
|
|
3638
3490
|
} else if (startValue === undefined) {
|
|
3639
|
-
return
|
|
3491
|
+
return {
|
|
3492
|
+
...state,
|
|
3640
3493
|
startInputValue: formatValue({
|
|
3641
3494
|
value: action.value
|
|
3642
3495
|
}),
|
|
3643
3496
|
endInputValue: undefined
|
|
3644
|
-
}
|
|
3497
|
+
};
|
|
3645
3498
|
} else if (endValue === undefined) {
|
|
3646
3499
|
if (isBefore(action.value, startValue)) {
|
|
3647
|
-
return
|
|
3500
|
+
return {
|
|
3501
|
+
...state,
|
|
3648
3502
|
startInputValue: formatValue({
|
|
3649
3503
|
value: action.value
|
|
3650
3504
|
}),
|
|
3651
3505
|
endInputValue: undefined
|
|
3652
|
-
}
|
|
3506
|
+
};
|
|
3653
3507
|
}
|
|
3654
|
-
return
|
|
3508
|
+
return {
|
|
3509
|
+
...state,
|
|
3655
3510
|
endInputValue: formatValue({
|
|
3656
3511
|
value: action.value
|
|
3657
3512
|
})
|
|
3658
|
-
}
|
|
3513
|
+
};
|
|
3659
3514
|
}
|
|
3660
3515
|
return state;
|
|
3661
3516
|
case 'START_INPUT_ONCHANGE':
|
|
3662
3517
|
{
|
|
3663
|
-
return
|
|
3518
|
+
return {
|
|
3519
|
+
...state,
|
|
3664
3520
|
startInputValue: action.value
|
|
3665
|
-
}
|
|
3521
|
+
};
|
|
3666
3522
|
}
|
|
3667
3523
|
case 'END_INPUT_ONCHANGE':
|
|
3668
3524
|
{
|
|
3669
|
-
return
|
|
3525
|
+
return {
|
|
3526
|
+
...state,
|
|
3670
3527
|
endInputValue: action.value
|
|
3671
|
-
}
|
|
3528
|
+
};
|
|
3672
3529
|
}
|
|
3673
3530
|
case 'HOVER_DATE':
|
|
3674
|
-
return
|
|
3531
|
+
return {
|
|
3532
|
+
...state,
|
|
3675
3533
|
hoverDate: action.value
|
|
3676
|
-
}
|
|
3534
|
+
};
|
|
3677
3535
|
case 'PREVIEW_NEXT_MONTH':
|
|
3678
3536
|
{
|
|
3679
|
-
|
|
3680
|
-
return
|
|
3681
|
-
|
|
3537
|
+
const previewDate = addMonths(state.previewDate, 1);
|
|
3538
|
+
return {
|
|
3539
|
+
...state,
|
|
3540
|
+
previewDate,
|
|
3682
3541
|
hoverDate: undefined
|
|
3683
|
-
}
|
|
3542
|
+
};
|
|
3684
3543
|
}
|
|
3685
3544
|
case 'PREVIEW_PREVIOUS_MONTH':
|
|
3686
3545
|
{
|
|
3687
|
-
|
|
3688
|
-
return
|
|
3689
|
-
|
|
3546
|
+
const previewDate = subMonths(state.previewDate, 1);
|
|
3547
|
+
return {
|
|
3548
|
+
...state,
|
|
3549
|
+
previewDate,
|
|
3690
3550
|
hoverDate: undefined
|
|
3691
|
-
}
|
|
3551
|
+
};
|
|
3692
3552
|
}
|
|
3693
3553
|
default:
|
|
3694
3554
|
throw new Error();
|
|
@@ -3696,58 +3556,59 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
|
|
|
3696
3556
|
};
|
|
3697
3557
|
};
|
|
3698
3558
|
function retrieveInitialState(initialProps) {
|
|
3699
|
-
|
|
3559
|
+
let previewDate = initialProps.startValue;
|
|
3700
3560
|
if (previewDate === undefined || !isValid(previewDate)) {
|
|
3701
3561
|
previewDate = new Date();
|
|
3702
3562
|
}
|
|
3703
|
-
|
|
3563
|
+
const startInputValue = formatValue({
|
|
3704
3564
|
value: initialProps.startValue,
|
|
3705
3565
|
locale: initialProps.locale,
|
|
3706
3566
|
formatDate: initialProps.formatDate
|
|
3707
3567
|
});
|
|
3708
|
-
|
|
3568
|
+
const endInputValue = formatValue({
|
|
3709
3569
|
value: initialProps.endValue,
|
|
3710
3570
|
locale: initialProps.locale,
|
|
3711
3571
|
formatDate: initialProps.formatDate
|
|
3712
3572
|
});
|
|
3713
3573
|
return {
|
|
3714
|
-
previewDate
|
|
3715
|
-
startInputValue
|
|
3716
|
-
endInputValue
|
|
3574
|
+
previewDate,
|
|
3575
|
+
startInputValue,
|
|
3576
|
+
endInputValue,
|
|
3717
3577
|
isStartFocused: false,
|
|
3718
3578
|
isEndFocused: false
|
|
3719
3579
|
};
|
|
3720
3580
|
}
|
|
3721
3581
|
|
|
3722
|
-
|
|
3723
|
-
|
|
3582
|
+
const DatepickerRangeContext = createContext(undefined);
|
|
3583
|
+
const useDatepickerContext = () => {
|
|
3724
3584
|
return useContext(DatepickerRangeContext);
|
|
3725
3585
|
};
|
|
3726
3586
|
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3587
|
+
const Start = props => {
|
|
3588
|
+
const {
|
|
3589
|
+
state,
|
|
3590
|
+
dispatch,
|
|
3591
|
+
onChange,
|
|
3592
|
+
startValue,
|
|
3593
|
+
endValue,
|
|
3594
|
+
startInputRef,
|
|
3595
|
+
customParseDate
|
|
3596
|
+
} = useDatepickerContext();
|
|
3597
|
+
const onChangeCallback = useCallback(e => {
|
|
3737
3598
|
dispatch({
|
|
3738
3599
|
type: 'START_INPUT_ONCHANGE',
|
|
3739
3600
|
value: e.target.value
|
|
3740
3601
|
});
|
|
3741
3602
|
props.children.props.onChange && props.children.props.onChange(e);
|
|
3742
3603
|
}, [dispatch, props.children]);
|
|
3743
|
-
|
|
3604
|
+
const onFocusCallback = useCallback(e => {
|
|
3744
3605
|
dispatch({
|
|
3745
3606
|
type: 'START_FOCUS'
|
|
3746
3607
|
});
|
|
3747
3608
|
props.children.props.onFocus && props.children.props.onFocus(e);
|
|
3748
3609
|
}, [dispatch, props.children]);
|
|
3749
|
-
|
|
3750
|
-
|
|
3610
|
+
const handleBlur = useCallback(() => {
|
|
3611
|
+
let parsedDate;
|
|
3751
3612
|
if (customParseDate) {
|
|
3752
3613
|
parsedDate = customParseDate(state.startInputValue);
|
|
3753
3614
|
} else {
|
|
@@ -3761,22 +3622,22 @@ var Start = function Start(props) {
|
|
|
3761
3622
|
if (parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, startValue)) {
|
|
3762
3623
|
onChange && onChange({
|
|
3763
3624
|
startValue: parsedDate,
|
|
3764
|
-
endValue
|
|
3625
|
+
endValue
|
|
3765
3626
|
});
|
|
3766
3627
|
}
|
|
3767
3628
|
}, [dispatch, onChange, startValue, endValue, customParseDate, state.startInputValue]);
|
|
3768
|
-
|
|
3629
|
+
const onKeyDownCallback = useCallback(e => {
|
|
3769
3630
|
if (e.keyCode === KEY_CODES.ENTER) {
|
|
3770
3631
|
e.preventDefault();
|
|
3771
3632
|
handleBlur();
|
|
3772
3633
|
}
|
|
3773
3634
|
props.children.props.onKeyDown && props.children.props.onKeyDown(e);
|
|
3774
3635
|
}, [handleBlur, props.children]);
|
|
3775
|
-
|
|
3636
|
+
const onBlurCallback = useCallback(e => {
|
|
3776
3637
|
handleBlur();
|
|
3777
3638
|
props.children.props.onBlur && props.children.props.onBlur(e);
|
|
3778
3639
|
}, [handleBlur, props.children]);
|
|
3779
|
-
|
|
3640
|
+
const childElement = React__default.Children.only(props.children);
|
|
3780
3641
|
return React__default.cloneElement(childElement, {
|
|
3781
3642
|
value: state.startInputValue || '',
|
|
3782
3643
|
ref: startInputRef,
|
|
@@ -3788,33 +3649,34 @@ var Start = function Start(props) {
|
|
|
3788
3649
|
};
|
|
3789
3650
|
Start.displayName = 'DatepickerRange.Start';
|
|
3790
3651
|
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3652
|
+
const End = props => {
|
|
3653
|
+
const {
|
|
3654
|
+
state,
|
|
3655
|
+
dispatch,
|
|
3656
|
+
onChange,
|
|
3657
|
+
startValue,
|
|
3658
|
+
endValue,
|
|
3659
|
+
endInputRef,
|
|
3660
|
+
customParseDate
|
|
3661
|
+
} = useDatepickerContext();
|
|
3662
|
+
const onChangeCallback = useCallback(e => {
|
|
3801
3663
|
dispatch({
|
|
3802
3664
|
type: 'END_INPUT_ONCHANGE',
|
|
3803
3665
|
value: e.target.value
|
|
3804
3666
|
});
|
|
3805
3667
|
props.children.props.onChange && props.children.props.onChange(e);
|
|
3806
3668
|
}, [dispatch, props.children]);
|
|
3807
|
-
|
|
3669
|
+
const onFocusCallback = useCallback(e => {
|
|
3808
3670
|
dispatch({
|
|
3809
3671
|
type: 'END_FOCUS'
|
|
3810
3672
|
});
|
|
3811
3673
|
props.children.props.onFocus && props.children.props.onFocus(e);
|
|
3812
3674
|
}, [dispatch, props.children]);
|
|
3813
|
-
|
|
3675
|
+
const handleBlur = useCallback(() => {
|
|
3814
3676
|
dispatch({
|
|
3815
3677
|
type: 'END_BLUR'
|
|
3816
3678
|
});
|
|
3817
|
-
|
|
3679
|
+
let parsedDate;
|
|
3818
3680
|
if (customParseDate) {
|
|
3819
3681
|
parsedDate = customParseDate(state.endInputValue);
|
|
3820
3682
|
} else {
|
|
@@ -3824,23 +3686,23 @@ var End = function End(props) {
|
|
|
3824
3686
|
}
|
|
3825
3687
|
if (onChange && parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, endValue)) {
|
|
3826
3688
|
onChange && onChange({
|
|
3827
|
-
startValue
|
|
3689
|
+
startValue,
|
|
3828
3690
|
endValue: parsedDate
|
|
3829
3691
|
});
|
|
3830
3692
|
}
|
|
3831
3693
|
}, [dispatch, onChange, startValue, endValue, customParseDate, state.endInputValue]);
|
|
3832
|
-
|
|
3694
|
+
const onKeydownCallback = useCallback(e => {
|
|
3833
3695
|
if (e.keyCode === KEY_CODES.ENTER) {
|
|
3834
3696
|
handleBlur();
|
|
3835
3697
|
e.preventDefault();
|
|
3836
3698
|
}
|
|
3837
3699
|
props.children.props.onKeyDown && props.children.props.onKeyDown(e);
|
|
3838
3700
|
}, [handleBlur, props.children]);
|
|
3839
|
-
|
|
3701
|
+
const onBlurCallback = useCallback(e => {
|
|
3840
3702
|
handleBlur();
|
|
3841
3703
|
props.children.props.onBlur && props.children.props.onBlur(e);
|
|
3842
3704
|
}, [handleBlur, props.children]);
|
|
3843
|
-
|
|
3705
|
+
const childElement = React__default.Children.only(props.children);
|
|
3844
3706
|
return React__default.cloneElement(childElement, {
|
|
3845
3707
|
value: state.endInputValue || '',
|
|
3846
3708
|
ref: endInputRef,
|
|
@@ -3852,77 +3714,95 @@ var End = function End(props) {
|
|
|
3852
3714
|
};
|
|
3853
3715
|
End.displayName = 'DatepickerRange.End';
|
|
3854
3716
|
|
|
3717
|
+
function _extends() {
|
|
3718
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3719
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3720
|
+
var source = arguments[i];
|
|
3721
|
+
for (var key in source) {
|
|
3722
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3723
|
+
target[key] = source[key];
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
return target;
|
|
3728
|
+
};
|
|
3729
|
+
return _extends.apply(this, arguments);
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3855
3732
|
function subDays(dirtyDate, dirtyAmount) {
|
|
3856
3733
|
requiredArgs(2, arguments);
|
|
3857
3734
|
var amount = toInteger(dirtyAmount);
|
|
3858
3735
|
return addDays(dirtyDate, -amount);
|
|
3859
3736
|
}
|
|
3860
3737
|
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3738
|
+
const Month = forwardRef((_ref, ref) => {
|
|
3739
|
+
let {
|
|
3740
|
+
displayDate,
|
|
3741
|
+
isPreviousHidden,
|
|
3742
|
+
isNextHidden
|
|
3743
|
+
} = _ref;
|
|
3744
|
+
const {
|
|
3745
|
+
state,
|
|
3746
|
+
dispatch,
|
|
3747
|
+
locale,
|
|
3748
|
+
weekStartsOn,
|
|
3749
|
+
isCompact,
|
|
3750
|
+
minValue,
|
|
3751
|
+
maxValue,
|
|
3752
|
+
startValue,
|
|
3753
|
+
endValue,
|
|
3754
|
+
onChange
|
|
3755
|
+
} = useDatepickerContext();
|
|
3756
|
+
const headerLabelFormatter = useCallback(date => {
|
|
3757
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
3878
3758
|
month: 'long',
|
|
3879
3759
|
year: 'numeric'
|
|
3880
3760
|
});
|
|
3881
3761
|
return formatter.format(date);
|
|
3882
3762
|
}, [locale]);
|
|
3883
|
-
|
|
3884
|
-
|
|
3763
|
+
const dayLabelFormatter = useCallback(date => {
|
|
3764
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
3885
3765
|
weekday: 'short'
|
|
3886
3766
|
});
|
|
3887
3767
|
return formatter.format(date);
|
|
3888
3768
|
}, [locale]);
|
|
3889
|
-
|
|
3890
|
-
|
|
3769
|
+
const dayFormatter = useCallback(date => {
|
|
3770
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
3891
3771
|
day: 'numeric'
|
|
3892
3772
|
});
|
|
3893
3773
|
return formatter.format(date);
|
|
3894
3774
|
}, [locale]);
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3775
|
+
const preferredWeekStartsOn = weekStartsOn || getStartOfWeek(locale);
|
|
3776
|
+
const monthStartDate = startOfMonth(displayDate);
|
|
3777
|
+
const monthEndDate = endOfMonth(monthStartDate);
|
|
3778
|
+
const startDate = startOfWeek(monthStartDate, {
|
|
3899
3779
|
weekStartsOn: preferredWeekStartsOn
|
|
3900
3780
|
});
|
|
3901
|
-
|
|
3781
|
+
const endDate = endOfWeek(monthEndDate, {
|
|
3902
3782
|
weekStartsOn: preferredWeekStartsOn
|
|
3903
3783
|
});
|
|
3904
|
-
|
|
3784
|
+
const dayLabels = eachDayOfInterval({
|
|
3905
3785
|
start: startDate,
|
|
3906
3786
|
end: addDays(startDate, 6)
|
|
3907
|
-
}).map(
|
|
3908
|
-
|
|
3787
|
+
}).map(date => {
|
|
3788
|
+
const formattedDayLabel = dayLabelFormatter(date);
|
|
3909
3789
|
return React__default.createElement(StyledCalendarItem, {
|
|
3910
|
-
key:
|
|
3790
|
+
key: `day-label-${formattedDayLabel}`,
|
|
3911
3791
|
isCompact: isCompact
|
|
3912
3792
|
}, React__default.createElement(StyledDayLabel, {
|
|
3913
3793
|
isCompact: isCompact
|
|
3914
3794
|
}, formattedDayLabel));
|
|
3915
3795
|
});
|
|
3916
|
-
|
|
3796
|
+
const items = eachDayOfInterval({
|
|
3917
3797
|
start: startDate,
|
|
3918
3798
|
end: endDate
|
|
3919
|
-
}).map(
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3799
|
+
}).map((date, itemsIndex) => {
|
|
3800
|
+
const formattedDayLabel = dayFormatter(date);
|
|
3801
|
+
const isCurrentDate = isToday(date);
|
|
3802
|
+
const isPreviousMonth = !isSameMonth(date, displayDate);
|
|
3923
3803
|
if (isPreviousMonth) {
|
|
3924
3804
|
return React__default.createElement(StyledCalendarItem, {
|
|
3925
|
-
key:
|
|
3805
|
+
key: `day-${itemsIndex}`,
|
|
3926
3806
|
isCompact: isCompact
|
|
3927
3807
|
}, React__default.createElement(StyledDay, {
|
|
3928
3808
|
isCompact: isCompact,
|
|
@@ -3930,29 +3810,29 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
3930
3810
|
isDisabled: true
|
|
3931
3811
|
}, "\xA0"));
|
|
3932
3812
|
}
|
|
3933
|
-
|
|
3813
|
+
let isSelected = false;
|
|
3934
3814
|
if (startValue !== undefined) {
|
|
3935
3815
|
isSelected = isSameDay(date, startValue);
|
|
3936
3816
|
}
|
|
3937
3817
|
if (endValue !== undefined) {
|
|
3938
3818
|
isSelected = isSelected || isSameDay(date, endValue);
|
|
3939
3819
|
}
|
|
3940
|
-
|
|
3820
|
+
let isDisabled = false;
|
|
3941
3821
|
if (minValue !== undefined) {
|
|
3942
3822
|
isDisabled = isBefore(date, minValue) && !isSameDay(date, minValue);
|
|
3943
3823
|
}
|
|
3944
3824
|
if (maxValue !== undefined) {
|
|
3945
3825
|
isDisabled = isDisabled || isAfter(date, maxValue) && !isSameDay(date, maxValue);
|
|
3946
3826
|
}
|
|
3947
|
-
|
|
3827
|
+
let isHighlighted = false;
|
|
3948
3828
|
if (startValue !== undefined && endValue !== undefined) {
|
|
3949
3829
|
isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, endValue) || isSameDay(date, endValue)) && !isSameDay(startValue, endValue);
|
|
3950
3830
|
} else if (startValue !== undefined && state.hoverDate !== undefined) {
|
|
3951
3831
|
isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, state.hoverDate) || isSameDay(date, state.hoverDate));
|
|
3952
3832
|
}
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3833
|
+
const isHighlightStart = isHighlighted && startValue && isSameDay(date, startValue) || false;
|
|
3834
|
+
const isHighlightEnd = isHighlighted && endValue && isSameDay(date, endValue) || state.hoverDate && isSameDay(date, state.hoverDate) && !isBefore(date, endValue) || false;
|
|
3835
|
+
let isInvalidDateRange = endValue && startValue && compareAsc(endValue, startValue) === -1 || false;
|
|
3956
3836
|
if (minValue) {
|
|
3957
3837
|
if (startValue) {
|
|
3958
3838
|
isInvalidDateRange = isInvalidDateRange || compareAsc(startValue, subDays(minValue, 1)) === -1;
|
|
@@ -3970,7 +3850,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
3970
3850
|
}
|
|
3971
3851
|
}
|
|
3972
3852
|
return React__default.createElement(StyledCalendarItem, {
|
|
3973
|
-
key:
|
|
3853
|
+
key: `day-${itemsIndex}`,
|
|
3974
3854
|
isCompact: isCompact
|
|
3975
3855
|
}, React__default.createElement(StyledHighlight, {
|
|
3976
3856
|
isHighlighted: !isInvalidDateRange && isHighlighted && !isDisabled,
|
|
@@ -3982,7 +3862,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
3982
3862
|
isSelected: !isInvalidDateRange && isSelected,
|
|
3983
3863
|
isDisabled: isDisabled,
|
|
3984
3864
|
isCompact: isCompact,
|
|
3985
|
-
onClick:
|
|
3865
|
+
onClick: () => {
|
|
3986
3866
|
if (!isDisabled) {
|
|
3987
3867
|
dispatch({
|
|
3988
3868
|
type: 'CLICK_DATE',
|
|
@@ -3993,7 +3873,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
3993
3873
|
if (endValue !== undefined && (isBefore(date, endValue) || isSameDay(date, endValue))) {
|
|
3994
3874
|
onChange({
|
|
3995
3875
|
startValue: date,
|
|
3996
|
-
endValue
|
|
3876
|
+
endValue
|
|
3997
3877
|
});
|
|
3998
3878
|
} else {
|
|
3999
3879
|
onChange({
|
|
@@ -4004,7 +3884,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4004
3884
|
} else if (state.isEndFocused) {
|
|
4005
3885
|
if (startValue !== undefined && (isAfter(date, startValue) || isSameDay(date, startValue))) {
|
|
4006
3886
|
onChange({
|
|
4007
|
-
startValue
|
|
3887
|
+
startValue,
|
|
4008
3888
|
endValue: date
|
|
4009
3889
|
});
|
|
4010
3890
|
} else {
|
|
@@ -4026,7 +3906,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4026
3906
|
});
|
|
4027
3907
|
} else {
|
|
4028
3908
|
onChange({
|
|
4029
|
-
startValue
|
|
3909
|
+
startValue,
|
|
4030
3910
|
endValue: date
|
|
4031
3911
|
});
|
|
4032
3912
|
}
|
|
@@ -4039,7 +3919,7 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4039
3919
|
}
|
|
4040
3920
|
}
|
|
4041
3921
|
},
|
|
4042
|
-
onMouseEnter:
|
|
3922
|
+
onMouseEnter: () => {
|
|
4043
3923
|
if (!isSelected) {
|
|
4044
3924
|
dispatch({
|
|
4045
3925
|
type: 'HOVER_DATE',
|
|
@@ -4052,14 +3932,14 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4052
3932
|
return React__default.createElement(StyledDatepicker, {
|
|
4053
3933
|
ref: ref,
|
|
4054
3934
|
isCompact: isCompact,
|
|
4055
|
-
onMouseDown:
|
|
3935
|
+
onMouseDown: e => {
|
|
4056
3936
|
e.preventDefault();
|
|
4057
3937
|
}
|
|
4058
3938
|
}, React__default.createElement(StyledHeader, {
|
|
4059
3939
|
isCompact: isCompact
|
|
4060
3940
|
}, React__default.createElement(StyledHeaderPaddle, {
|
|
4061
3941
|
isCompact: isCompact,
|
|
4062
|
-
onClick:
|
|
3942
|
+
onClick: () => {
|
|
4063
3943
|
dispatch({
|
|
4064
3944
|
type: 'PREVIEW_PREVIOUS_MONTH'
|
|
4065
3945
|
});
|
|
@@ -4070,14 +3950,14 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4070
3950
|
}, headerLabelFormatter(displayDate)), React__default.createElement(StyledHeaderPaddle, {
|
|
4071
3951
|
isCompact: isCompact,
|
|
4072
3952
|
isHidden: isNextHidden,
|
|
4073
|
-
onClick:
|
|
3953
|
+
onClick: () => {
|
|
4074
3954
|
dispatch({
|
|
4075
3955
|
type: 'PREVIEW_NEXT_MONTH'
|
|
4076
3956
|
});
|
|
4077
3957
|
}
|
|
4078
3958
|
}, React__default.createElement(SvgChevronRightStroke, null))), React__default.createElement(StyledCalendar, {
|
|
4079
3959
|
isCompact: isCompact,
|
|
4080
|
-
onMouseLeave:
|
|
3960
|
+
onMouseLeave: () => {
|
|
4081
3961
|
dispatch({
|
|
4082
3962
|
type: 'HOVER_DATE',
|
|
4083
3963
|
value: undefined
|
|
@@ -4087,13 +3967,14 @@ var Month = forwardRef(function (_ref, ref) {
|
|
|
4087
3967
|
});
|
|
4088
3968
|
Month.displayName = 'Month';
|
|
4089
3969
|
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
3970
|
+
const Calendar = forwardRef((props, ref) => {
|
|
3971
|
+
const {
|
|
3972
|
+
state
|
|
3973
|
+
} = useDatepickerContext();
|
|
3974
|
+
return React__default.createElement(StyledRangeCalendar, _extends({
|
|
4094
3975
|
ref: ref,
|
|
4095
3976
|
"data-garden-id": "datepickers.range",
|
|
4096
|
-
"data-garden-version": '8.
|
|
3977
|
+
"data-garden-version": '8.59.0'
|
|
4097
3978
|
}, props), React__default.createElement(Month, {
|
|
4098
3979
|
displayDate: state.previewDate,
|
|
4099
3980
|
isNextHidden: true
|
|
@@ -4104,34 +3985,33 @@ var Calendar = forwardRef(function (props, ref) {
|
|
|
4104
3985
|
});
|
|
4105
3986
|
Calendar.displayName = 'DatepickerRange.Calendar';
|
|
4106
3987
|
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
3988
|
+
const DatepickerRangeComponent = props => {
|
|
3989
|
+
const {
|
|
3990
|
+
startValue,
|
|
3991
|
+
locale,
|
|
3992
|
+
weekStartsOn,
|
|
3993
|
+
formatDate,
|
|
3994
|
+
endValue,
|
|
3995
|
+
onChange,
|
|
3996
|
+
customParseDate,
|
|
3997
|
+
isCompact,
|
|
3998
|
+
minValue,
|
|
3999
|
+
maxValue,
|
|
4000
|
+
children
|
|
4001
|
+
} = props;
|
|
4002
|
+
const reducer = useCallback(datepickerRangeReducer({
|
|
4003
|
+
startValue,
|
|
4004
|
+
locale,
|
|
4005
|
+
formatDate,
|
|
4006
|
+
endValue,
|
|
4007
|
+
customParseDate
|
|
4125
4008
|
}), [startValue, endValue, locale, formatDate, onChange, customParseDate]);
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
var startInputRef = useRef();
|
|
4133
|
-
var endInputRef = useRef();
|
|
4134
|
-
useEffect(function () {
|
|
4009
|
+
const [state, dispatch] = useReducer(reducer, retrieveInitialState(props));
|
|
4010
|
+
const previousStartValue = useRef(startValue);
|
|
4011
|
+
const previousEndValue = useRef(endValue);
|
|
4012
|
+
const startInputRef = useRef();
|
|
4013
|
+
const endInputRef = useRef();
|
|
4014
|
+
useEffect(() => {
|
|
4135
4015
|
dispatch({
|
|
4136
4016
|
type: 'CONTROLLED_START_VALUE_CHANGE',
|
|
4137
4017
|
value: startValue
|
|
@@ -4141,7 +4021,7 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
|
|
|
4141
4021
|
}
|
|
4142
4022
|
previousStartValue.current = startValue;
|
|
4143
4023
|
}, [props, startValue]);
|
|
4144
|
-
useEffect(
|
|
4024
|
+
useEffect(() => {
|
|
4145
4025
|
dispatch({
|
|
4146
4026
|
type: 'CONTROLLED_END_VALUE_CHANGE',
|
|
4147
4027
|
value: endValue
|
|
@@ -4151,23 +4031,21 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
|
|
|
4151
4031
|
}
|
|
4152
4032
|
previousEndValue.current = endValue;
|
|
4153
4033
|
}, [props, endValue]);
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
};
|
|
4170
|
-
}, [state, dispatch, isCompact, locale, weekStartsOn, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
|
|
4034
|
+
const value = useMemo(() => ({
|
|
4035
|
+
state,
|
|
4036
|
+
dispatch,
|
|
4037
|
+
isCompact,
|
|
4038
|
+
locale,
|
|
4039
|
+
weekStartsOn,
|
|
4040
|
+
minValue,
|
|
4041
|
+
maxValue,
|
|
4042
|
+
startValue,
|
|
4043
|
+
endValue,
|
|
4044
|
+
onChange,
|
|
4045
|
+
startInputRef,
|
|
4046
|
+
endInputRef,
|
|
4047
|
+
customParseDate
|
|
4048
|
+
}), [state, dispatch, isCompact, locale, weekStartsOn, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
|
|
4171
4049
|
return React__default.createElement(DatepickerRangeContext.Provider, {
|
|
4172
4050
|
value: value
|
|
4173
4051
|
}, children);
|
|
@@ -4188,7 +4066,7 @@ DatepickerRangeComponent.defaultProps = {
|
|
|
4188
4066
|
locale: 'en-US',
|
|
4189
4067
|
isCompact: false
|
|
4190
4068
|
};
|
|
4191
|
-
|
|
4069
|
+
const DatepickerRange = DatepickerRangeComponent;
|
|
4192
4070
|
DatepickerRange.Calendar = Calendar;
|
|
4193
4071
|
DatepickerRange.End = End;
|
|
4194
4072
|
DatepickerRange.Start = Start;
|