@docsvision/material-ui-pickers 3.2.0-beta.9 → 3.2.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/DatePicker/DatePicker.d.ts +2 -2
  2. package/DatePicker/DatePicker.js +1 -1
  3. package/DatePicker/DatePickerToolbar.js +1 -1
  4. package/DateTimePicker/DateTimePicker.js +1 -1
  5. package/Picker/Picker.js +1 -1
  6. package/Picker/WrappedKeyboardPicker.js +4 -2
  7. package/Picker/WrappedPurePicker.js +4 -2
  8. package/README.md +1 -0
  9. package/Rifm/Rifm.d.ts +17 -0
  10. package/Rifm/Rifm.js +174 -0
  11. package/TimePicker/TimePicker.js +1 -1
  12. package/TimePicker/TimePickerToolbar.js +1 -1
  13. package/_helpers/text-field-helper.d.ts +2 -2
  14. package/_helpers/text-field-helper.js +62 -6
  15. package/_shared/KeyboardDateInput.js +27 -139
  16. package/_shared/ModalDialog.d.ts +2 -2
  17. package/_shared/ModalDialog.js +5 -3
  18. package/_shared/PickerToolbar.d.ts +1 -1
  19. package/_shared/PickerToolbar.js +7 -5
  20. package/_shared/PureDateInput.js +5 -3
  21. package/_shared/ToolbarButton.d.ts +2 -2
  22. package/_shared/ToolbarButton.js +4 -2
  23. package/_shared/ToolbarText.js +9 -7
  24. package/_shared/hooks/useKeyboardPickerState.js +5 -3
  25. package/_shared/hooks/useOpenState.js +1 -1
  26. package/_shared/hooks/usePickerState.js +9 -9
  27. package/constants/prop-types.js +2 -2
  28. package/dist/material-ui-pickers.esm.js +3626 -0
  29. package/dist/material-ui-pickers.esm.js.map +1 -0
  30. package/dist/material-ui-pickers.js +3651 -0
  31. package/dist/material-ui-pickers.js.map +1 -0
  32. package/dist/material-ui-pickers.umd.js +34161 -0
  33. package/dist/material-ui-pickers.umd.min.js +1 -0
  34. package/package.json +3 -4
  35. package/typings/BasePicker.d.ts +1 -1
  36. package/typings/overrides.d.ts +2 -2
  37. package/views/Calendar/Calendar.js +3 -2
  38. package/views/Calendar/CalendarHeader.d.ts +1 -1
  39. package/views/Calendar/Day.d.ts +1 -1
  40. package/views/Calendar/Day.js +5 -3
  41. package/views/Calendar/DayWrapper.js +4 -2
  42. package/views/Calendar/SlideTransition.d.ts +1 -1
  43. package/views/Clock/Clock.d.ts +1 -1
  44. package/views/Clock/ClockNumber.d.ts +1 -1
  45. package/views/Clock/ClockNumber.js +1 -1
  46. package/views/Clock/ClockPointer.d.ts +1 -1
  47. package/views/Month/Month.d.ts +1 -1
  48. package/views/Month/Month.js +5 -3
  49. package/views/Year/Year.d.ts +1 -1
  50. package/views/Year/Year.js +5 -3
  51. package/wrappers/InlineWrapper.d.ts +2 -0
  52. package/wrappers/InlineWrapper.js +5 -3
  53. package/wrappers/ModalWrapper.js +4 -2
  54. package/wrappers/Wrapper.js +4 -2
@@ -0,0 +1,3651 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var tslib = require('tslib');
8
+ var React = require('react');
9
+ var React__default = _interopDefault(React);
10
+ var PropTypes = require('prop-types');
11
+ var clsx = _interopDefault(require('clsx'));
12
+ var Typography = _interopDefault(require('@material-ui/core/Typography'));
13
+ var styles$5 = require('@material-ui/core/styles');
14
+ var Button = _interopDefault(require('@material-ui/core/Button'));
15
+ var Toolbar = _interopDefault(require('@material-ui/core/Toolbar'));
16
+ var IconButton = _interopDefault(require('@material-ui/core/IconButton'));
17
+ var reactTransitionGroup = require('react-transition-group');
18
+ var SvgIcon = _interopDefault(require('@material-ui/core/SvgIcon'));
19
+ var CircularProgress = _interopDefault(require('@material-ui/core/CircularProgress'));
20
+ var core = require('@material-ui/core');
21
+ var DialogActions = _interopDefault(require('@material-ui/core/DialogActions'));
22
+ var DialogContent = _interopDefault(require('@material-ui/core/DialogContent'));
23
+ var Dialog = _interopDefault(require('@material-ui/core/Dialog'));
24
+ var Popover = _interopDefault(require('@material-ui/core/Popover'));
25
+ var TextField = _interopDefault(require('@material-ui/core/TextField'));
26
+ var InputAdornment = _interopDefault(require('@material-ui/core/InputAdornment'));
27
+ var Tab = _interopDefault(require('@material-ui/core/Tab'));
28
+ var Tabs = _interopDefault(require('@material-ui/core/Tabs'));
29
+ var Paper = _interopDefault(require('@material-ui/core/Paper'));
30
+
31
+ var MuiPickersContext = React.createContext(null);
32
+ var MuiPickersUtilsProvider = function (_a) {
33
+ var Utils = _a.utils,
34
+ children = _a.children,
35
+ locale = _a.locale,
36
+ libInstance = _a.libInstance;
37
+ var utils = React.useMemo(function () {
38
+ return new Utils({
39
+ locale: locale,
40
+ moment: libInstance
41
+ });
42
+ }, [Utils, libInstance, locale]);
43
+ return React.createElement(MuiPickersContext.Provider, {
44
+ value: utils,
45
+ children: children
46
+ });
47
+ };
48
+ process.env.NODE_ENV !== "production" ? MuiPickersUtilsProvider.propTypes = {
49
+ utils: PropTypes.func.isRequired,
50
+ locale: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
51
+ children: PropTypes.oneOfType([PropTypes.element.isRequired, PropTypes.arrayOf(PropTypes.element.isRequired)]).isRequired
52
+ } : void 0;
53
+
54
+ var checkUtils = function (utils) {
55
+ if (!utils) {
56
+ // tslint:disable-next-line
57
+ throw new Error('Can not find utils in context. You either a) forgot to wrap your component tree in MuiPickersUtilsProvider; or b) mixed named and direct file imports. Recommendation: use named imports from the module index.');
58
+ }
59
+ };
60
+ function useUtils() {
61
+ var utils = React.useContext(MuiPickersContext);
62
+ checkUtils(utils);
63
+ return utils;
64
+ }
65
+
66
+ var useStyles = styles$5.makeStyles(function (theme) {
67
+ var textColor = theme.palette.type === 'light' ? theme.palette.primary.contrastText : theme.palette.getContrastText(theme.palette.background.default);
68
+ return {
69
+ toolbarTxt: {
70
+ color: styles$5.fade(textColor, 0.54)
71
+ },
72
+ toolbarBtnSelected: {
73
+ color: textColor
74
+ }
75
+ };
76
+ }, {
77
+ name: 'MuiPickersToolbarText'
78
+ });
79
+
80
+ var ToolbarText = function (_a) {
81
+ var _b;
82
+
83
+ var selected = _a.selected,
84
+ label = _a.label,
85
+ _c = _a.className,
86
+ className = _c === void 0 ? null : _c,
87
+ other = tslib.__rest(_a, ["selected", "label", "className"]);
88
+
89
+ var classes = useStyles();
90
+ return React.createElement(Typography, tslib.__assign({
91
+ children: label,
92
+ className: clsx(classes.toolbarTxt, className, (_b = {}, _b[classes.toolbarBtnSelected] = selected, _b))
93
+ }, other));
94
+ };
95
+
96
+ var ToolbarButton = function (_a) {
97
+ var classes = _a.classes,
98
+ _b = _a.className,
99
+ className = _b === void 0 ? null : _b,
100
+ label = _a.label,
101
+ selected = _a.selected,
102
+ variant = _a.variant,
103
+ align = _a.align,
104
+ typographyClassName = _a.typographyClassName,
105
+ other = tslib.__rest(_a, ["classes", "className", "label", "selected", "variant", "align", "typographyClassName"]);
106
+
107
+ return React.createElement(Button, tslib.__assign({
108
+ variant: "text",
109
+ className: clsx(classes.toolbarBtn, className)
110
+ }, other), React.createElement(ToolbarText, {
111
+ align: align,
112
+ className: typographyClassName,
113
+ variant: variant,
114
+ label: label,
115
+ selected: selected
116
+ }));
117
+ };
118
+
119
+ process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
120
+ selected: PropTypes.bool.isRequired,
121
+ label: PropTypes.string.isRequired,
122
+ classes: PropTypes.any.isRequired,
123
+ className: PropTypes.string,
124
+ innerRef: PropTypes.any
125
+ } : void 0;
126
+ ToolbarButton.defaultProps = {
127
+ className: ''
128
+ };
129
+ var styles = styles$5.createStyles({
130
+ toolbarBtn: {
131
+ padding: 0,
132
+ minWidth: '16px',
133
+ textTransform: 'none'
134
+ }
135
+ });
136
+ var ToolbarButton$1 = styles$5.withStyles(styles, {
137
+ name: 'MuiPickersToolbarButton'
138
+ })(ToolbarButton);
139
+
140
+ var useStyles$1 = styles$5.makeStyles(function (theme) {
141
+ return {
142
+ toolbar: {
143
+ display: 'flex',
144
+ flexDirection: 'row',
145
+ alignItems: 'center',
146
+ justifyContent: 'center',
147
+ height: 100,
148
+ backgroundColor: theme.palette.type === 'light' ? theme.palette.primary.main : theme.palette.background.default
149
+ },
150
+ toolbarLandscape: {
151
+ height: 'auto',
152
+ maxWidth: 150,
153
+ padding: 8,
154
+ justifyContent: 'flex-start'
155
+ }
156
+ };
157
+ }, {
158
+ name: 'MuiPickersToolbar'
159
+ });
160
+
161
+ var PickerToolbar = function (_a) {
162
+ var _b;
163
+
164
+ var children = _a.children,
165
+ isLandscape = _a.isLandscape,
166
+ _c = _a.className,
167
+ className = _c === void 0 ? null : _c,
168
+ other = tslib.__rest(_a, ["children", "isLandscape", "className"]);
169
+
170
+ var classes = useStyles$1();
171
+ return React.createElement(Toolbar, tslib.__assign({
172
+ className: clsx(classes.toolbar, (_b = {}, _b[classes.toolbarLandscape] = isLandscape, _b), className)
173
+ }, other), children);
174
+ };
175
+
176
+ /** Use it instead of .includes method for IE support */
177
+ function arrayIncludes(array, itemOrItems) {
178
+ if (Array.isArray(itemOrItems)) {
179
+ return itemOrItems.every(function (item) {
180
+ return array.indexOf(item) !== -1;
181
+ });
182
+ }
183
+
184
+ return array.indexOf(itemOrItems) !== -1;
185
+ }
186
+
187
+ var findClosestEnabledDate = function (_a) {
188
+ var date = _a.date,
189
+ utils = _a.utils,
190
+ minDate = _a.minDate,
191
+ maxDate = _a.maxDate,
192
+ disableFuture = _a.disableFuture,
193
+ disablePast = _a.disablePast,
194
+ shouldDisableDate = _a.shouldDisableDate;
195
+ var today = utils.startOfDay(utils.date());
196
+
197
+ if (disablePast && utils.isBefore(minDate, today)) {
198
+ minDate = today;
199
+ }
200
+
201
+ if (disableFuture && utils.isAfter(maxDate, today)) {
202
+ maxDate = today;
203
+ }
204
+
205
+ var forward = date;
206
+ var backward = date;
207
+
208
+ if (utils.isBefore(date, minDate)) {
209
+ forward = utils.date(minDate);
210
+ backward = null;
211
+ }
212
+
213
+ if (utils.isAfter(date, maxDate)) {
214
+ if (backward) {
215
+ backward = utils.date(maxDate);
216
+ }
217
+
218
+ forward = null;
219
+ }
220
+
221
+ while (forward || backward) {
222
+ if (forward && utils.isAfter(forward, maxDate)) {
223
+ forward = null;
224
+ }
225
+
226
+ if (backward && utils.isBefore(backward, minDate)) {
227
+ backward = null;
228
+ }
229
+
230
+ if (forward) {
231
+ if (!shouldDisableDate(forward)) {
232
+ return forward;
233
+ }
234
+
235
+ forward = utils.addDays(forward, 1);
236
+ }
237
+
238
+ if (backward) {
239
+ if (!shouldDisableDate(backward)) {
240
+ return backward;
241
+ }
242
+
243
+ backward = utils.addDays(backward, -1);
244
+ }
245
+ }
246
+
247
+ return null;
248
+ };
249
+ var isYearOnlyView = function (views) {
250
+ return views.length === 1 && views[0] === 'year';
251
+ };
252
+ var isYearAndMonthViews = function (views) {
253
+ return views.length === 2 && arrayIncludes(views, 'month') && arrayIncludes(views, 'year');
254
+ };
255
+ var getFormatByViews = function (views, utils) {
256
+ if (isYearOnlyView(views)) {
257
+ return utils.yearFormat;
258
+ }
259
+
260
+ if (isYearAndMonthViews(views)) {
261
+ return utils.yearMonthFormat;
262
+ }
263
+
264
+ return utils.dateFormat;
265
+ };
266
+
267
+ var useStyles$2 = styles$5.makeStyles({
268
+ toolbar: {
269
+ flexDirection: 'column',
270
+ alignItems: 'flex-start'
271
+ },
272
+ toolbarLandscape: {
273
+ padding: 16
274
+ },
275
+ dateLandscape: {
276
+ marginRight: 16
277
+ }
278
+ }, {
279
+ name: 'MuiPickersDatePickerRoot'
280
+ });
281
+ var DatePickerToolbar = function (_a) {
282
+ var _b, _c;
283
+
284
+ var date = _a.date,
285
+ views = _a.views,
286
+ setOpenView = _a.setOpenView,
287
+ isLandscape = _a.isLandscape,
288
+ openView = _a.openView;
289
+ var utils = useUtils();
290
+ var classes = useStyles$2();
291
+ var isYearOnly = React.useMemo(function () {
292
+ return isYearOnlyView(views);
293
+ }, [views]);
294
+ var isYearAndMonth = React.useMemo(function () {
295
+ return isYearAndMonthViews(views);
296
+ }, [views]);
297
+ return React.createElement(PickerToolbar, {
298
+ isLandscape: isLandscape,
299
+ className: clsx((_b = {}, _b[classes.toolbar] = !isYearOnly, _b[classes.toolbarLandscape] = isLandscape, _b))
300
+ }, React.createElement(ToolbarButton$1, {
301
+ variant: isYearOnly ? 'h3' : 'subtitle1',
302
+ onClick: function () {
303
+ return setOpenView('year');
304
+ },
305
+ selected: openView === 'year',
306
+ label: utils.getYearText(date)
307
+ }), !isYearOnly && !isYearAndMonth && React.createElement(ToolbarButton$1, {
308
+ variant: "h4",
309
+ selected: openView === 'date',
310
+ onClick: function () {
311
+ return setOpenView('date');
312
+ },
313
+ align: isLandscape ? 'left' : 'center',
314
+ label: utils.getDatePickerHeaderText(date),
315
+ className: clsx((_c = {}, _c[classes.dateLandscape] = isLandscape, _c))
316
+ }), isYearAndMonth && React.createElement(ToolbarButton$1, {
317
+ variant: "h4",
318
+ onClick: function () {
319
+ return setOpenView('month');
320
+ },
321
+ selected: openView === 'month',
322
+ label: utils.getMonthText(date)
323
+ }));
324
+ };
325
+
326
+ var date = PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]);
327
+ var datePickerView = PropTypes.oneOf(['year', 'month', 'day']);
328
+ /* eslint-disable @typescript-eslint/no-object-literal-type-assertion */
329
+
330
+ var timePickerDefaultProps = {
331
+ ampm: true,
332
+ invalidDateMessage: 'Invalid Time Format'
333
+ };
334
+ var datePickerDefaultProps = {
335
+ minDate: new Date('1900-01-01'),
336
+ maxDate: new Date('2200-01-01'),
337
+ invalidDateMessage: 'Invalid Date Format',
338
+ minDateMessage: 'Date should not be before minimal date',
339
+ maxDateMessage: 'Date should not be after maximal date',
340
+ allowKeyboardControl: true
341
+ };
342
+ var dateTimePickerDefaultProps = tslib.__assign(tslib.__assign(tslib.__assign({}, timePickerDefaultProps), datePickerDefaultProps), {
343
+ showTabs: true
344
+ });
345
+
346
+ var useStyles$3 = styles$5.makeStyles(function (theme) {
347
+ return {
348
+ day: {
349
+ width: 36,
350
+ height: 36,
351
+ fontSize: theme.typography.caption.fontSize,
352
+ margin: '0 2px',
353
+ color: theme.palette.text.primary,
354
+ fontWeight: theme.typography.fontWeightMedium,
355
+ padding: 0
356
+ },
357
+ hidden: {
358
+ opacity: 0,
359
+ pointerEvents: 'none'
360
+ },
361
+ current: {
362
+ color: theme.palette.primary.main,
363
+ fontWeight: 600
364
+ },
365
+ daySelected: {
366
+ color: theme.palette.primary.contrastText,
367
+ backgroundColor: theme.palette.primary.main,
368
+ fontWeight: theme.typography.fontWeightMedium,
369
+ '&:hover': {
370
+ backgroundColor: theme.palette.primary.main
371
+ }
372
+ },
373
+ dayDisabled: {
374
+ pointerEvents: 'none',
375
+ color: theme.palette.text.hint
376
+ }
377
+ };
378
+ }, {
379
+ name: 'MuiPickersDay'
380
+ });
381
+ var Day = function (_a) {
382
+ var _b;
383
+
384
+ var children = _a.children,
385
+ disabled = _a.disabled,
386
+ hidden = _a.hidden,
387
+ current = _a.current,
388
+ selected = _a.selected,
389
+ other = tslib.__rest(_a, ["children", "disabled", "hidden", "current", "selected"]);
390
+
391
+ var classes = useStyles$3();
392
+ var className = clsx(classes.day, (_b = {}, _b[classes.hidden] = hidden, _b[classes.current] = current, _b[classes.daySelected] = selected, _b[classes.dayDisabled] = disabled, _b));
393
+ return React.createElement(IconButton, tslib.__assign({
394
+ className: className,
395
+ tabIndex: hidden || disabled ? -1 : 0
396
+ }, other), React.createElement(Typography, {
397
+ variant: "body2",
398
+ color: "inherit"
399
+ }, children));
400
+ };
401
+ Day.displayName = 'Day';
402
+ process.env.NODE_ENV !== "production" ? Day.propTypes = {
403
+ current: PropTypes.bool,
404
+ disabled: PropTypes.bool,
405
+ hidden: PropTypes.bool,
406
+ selected: PropTypes.bool
407
+ } : void 0;
408
+ Day.defaultProps = {
409
+ disabled: false,
410
+ hidden: false,
411
+ current: false,
412
+ selected: false
413
+ };
414
+
415
+ var DayWrapper = function (_a) {
416
+ var children = _a.children,
417
+ value = _a.value,
418
+ disabled = _a.disabled,
419
+ onSelect = _a.onSelect,
420
+ dayInCurrentMonth = _a.dayInCurrentMonth,
421
+ other = tslib.__rest(_a, ["children", "value", "disabled", "onSelect", "dayInCurrentMonth"]);
422
+
423
+ var handleClick = React.useCallback(function () {
424
+ return onSelect(value);
425
+ }, [onSelect, value]);
426
+ return React.createElement("div", tslib.__assign({
427
+ role: "presentation",
428
+ onClick: dayInCurrentMonth && !disabled ? handleClick : undefined,
429
+ onKeyPress: dayInCurrentMonth && !disabled ? handleClick : undefined
430
+ }, other), children);
431
+ };
432
+
433
+ var animationDuration = 350;
434
+ var useStyles$4 = styles$5.makeStyles(function (theme) {
435
+ var slideTransition = theme.transitions.create('transform', {
436
+ duration: animationDuration,
437
+ easing: 'cubic-bezier(0.35, 0.8, 0.4, 1)'
438
+ });
439
+ return {
440
+ transitionContainer: {
441
+ display: 'block',
442
+ position: 'relative',
443
+ '& > *': {
444
+ position: 'absolute',
445
+ top: 0,
446
+ right: 0,
447
+ left: 0
448
+ }
449
+ },
450
+ 'slideEnter-left': {
451
+ willChange: 'transform',
452
+ transform: 'translate(100%)'
453
+ },
454
+ 'slideEnter-right': {
455
+ willChange: 'transform',
456
+ transform: 'translate(-100%)'
457
+ },
458
+ slideEnterActive: {
459
+ transform: 'translate(0%)',
460
+ transition: slideTransition
461
+ },
462
+ slideExit: {
463
+ transform: 'translate(0%)'
464
+ },
465
+ 'slideExitActiveLeft-left': {
466
+ willChange: 'transform',
467
+ transform: 'translate(-200%)',
468
+ transition: slideTransition
469
+ },
470
+ 'slideExitActiveLeft-right': {
471
+ willChange: 'transform',
472
+ transform: 'translate(200%)',
473
+ transition: slideTransition
474
+ }
475
+ };
476
+ }, {
477
+ name: 'MuiPickersSlideTransition'
478
+ });
479
+
480
+ var SlideTransition = function (_a) {
481
+ var children = _a.children,
482
+ transKey = _a.transKey,
483
+ slideDirection = _a.slideDirection,
484
+ _b = _a.className,
485
+ className = _b === void 0 ? null : _b;
486
+ var classes = useStyles$4();
487
+ var transitionClasses = {
488
+ exit: classes.slideExit,
489
+ enterActive: classes.slideEnterActive,
490
+ // @ts-ignore
491
+ enter: classes['slideEnter-' + slideDirection],
492
+ // @ts-ignore
493
+ exitActive: classes['slideExitActiveLeft-' + slideDirection]
494
+ };
495
+ return React.createElement(reactTransitionGroup.TransitionGroup, {
496
+ className: clsx(classes.transitionContainer, className),
497
+ childFactory: function (element) {
498
+ return React.cloneElement(element, {
499
+ classNames: transitionClasses
500
+ });
501
+ }
502
+ }, React.createElement(reactTransitionGroup.CSSTransition, {
503
+ mountOnEnter: true,
504
+ unmountOnExit: true,
505
+ key: transKey + slideDirection,
506
+ timeout: animationDuration,
507
+ classNames: transitionClasses,
508
+ children: children
509
+ }));
510
+ };
511
+
512
+ var ArrowLeftIcon = function (props) {
513
+ return React__default.createElement(SvgIcon, tslib.__assign({}, props), React__default.createElement("path", {
514
+ d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"
515
+ }), React__default.createElement("path", {
516
+ fill: "none",
517
+ d: "M0 0h24v24H0V0z"
518
+ }));
519
+ };
520
+
521
+ var ArrowRightIcon = function (props) {
522
+ return React__default.createElement(SvgIcon, tslib.__assign({}, props), React__default.createElement("path", {
523
+ d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
524
+ }), React__default.createElement("path", {
525
+ fill: "none",
526
+ d: "M0 0h24v24H0V0z"
527
+ }));
528
+ };
529
+
530
+ var useStyles$5 = styles$5.makeStyles(function (theme) {
531
+ return {
532
+ switchHeader: {
533
+ display: 'flex',
534
+ justifyContent: 'space-between',
535
+ alignItems: 'center',
536
+ marginTop: theme.spacing(0.5),
537
+ marginBottom: theme.spacing(1)
538
+ },
539
+ transitionContainer: {
540
+ width: '100%',
541
+ overflow: 'hidden',
542
+ height: 23
543
+ },
544
+ iconButton: {
545
+ zIndex: 1,
546
+ backgroundColor: theme.palette.background.paper
547
+ },
548
+ daysHeader: {
549
+ display: 'flex',
550
+ justifyContent: 'center',
551
+ alignItems: 'center',
552
+ maxHeight: 16
553
+ },
554
+ dayLabel: {
555
+ width: 36,
556
+ margin: '0 2px',
557
+ textAlign: 'center',
558
+ color: theme.palette.text.hint
559
+ }
560
+ };
561
+ }, {
562
+ name: 'MuiPickersCalendarHeader'
563
+ });
564
+ var CalendarHeader = function (_a) {
565
+ var currentMonth = _a.currentMonth,
566
+ onMonthChange = _a.onMonthChange,
567
+ leftArrowIcon = _a.leftArrowIcon,
568
+ rightArrowIcon = _a.rightArrowIcon,
569
+ leftArrowButtonProps = _a.leftArrowButtonProps,
570
+ rightArrowButtonProps = _a.rightArrowButtonProps,
571
+ disablePrevMonth = _a.disablePrevMonth,
572
+ disableNextMonth = _a.disableNextMonth,
573
+ slideDirection = _a.slideDirection;
574
+ var utils = useUtils();
575
+ var classes = useStyles$5();
576
+ var theme = styles$5.useTheme();
577
+ var rtl = theme.direction === 'rtl';
578
+
579
+ var selectNextMonth = function () {
580
+ return onMonthChange(utils.getNextMonth(currentMonth), 'left');
581
+ };
582
+
583
+ var selectPreviousMonth = function () {
584
+ return onMonthChange(utils.getPreviousMonth(currentMonth), 'right');
585
+ };
586
+
587
+ return React.createElement("div", null, React.createElement("div", {
588
+ className: classes.switchHeader
589
+ }, React.createElement(IconButton, tslib.__assign({}, leftArrowButtonProps, {
590
+ disabled: disablePrevMonth,
591
+ onClick: selectPreviousMonth,
592
+ className: classes.iconButton
593
+ }), rtl ? rightArrowIcon : leftArrowIcon), React.createElement(SlideTransition, {
594
+ slideDirection: slideDirection,
595
+ transKey: currentMonth.toString(),
596
+ className: classes.transitionContainer
597
+ }, React.createElement(Typography, {
598
+ align: "center",
599
+ variant: "body1"
600
+ }, utils.getCalendarHeaderText(currentMonth))), React.createElement(IconButton, tslib.__assign({}, rightArrowButtonProps, {
601
+ disabled: disableNextMonth,
602
+ onClick: selectNextMonth,
603
+ className: classes.iconButton
604
+ }), rtl ? leftArrowIcon : rightArrowIcon)), React.createElement("div", {
605
+ className: classes.daysHeader
606
+ }, utils.getWeekdays().map(function (day, index) {
607
+ return React.createElement(Typography, {
608
+ key: index,
609
+ variant: "caption",
610
+ className: classes.dayLabel
611
+ }, day);
612
+ })));
613
+ };
614
+ CalendarHeader.displayName = 'CalendarHeader';
615
+ process.env.NODE_ENV !== "production" ? CalendarHeader.propTypes = {
616
+ leftArrowIcon: PropTypes.node,
617
+ rightArrowIcon: PropTypes.node,
618
+ disablePrevMonth: PropTypes.bool,
619
+ disableNextMonth: PropTypes.bool
620
+ } : void 0;
621
+ CalendarHeader.defaultProps = {
622
+ leftArrowIcon: React.createElement(ArrowLeftIcon, null),
623
+ rightArrowIcon: React.createElement(ArrowRightIcon, null),
624
+ disablePrevMonth: false,
625
+ disableNextMonth: false
626
+ };
627
+
628
+ var useIsomorphicEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
629
+ function runKeyHandler(e, keyHandlers) {
630
+ var handler = keyHandlers[e.key];
631
+
632
+ if (handler) {
633
+ handler(); // if event was handled prevent other side effects (e.g. page scroll)
634
+
635
+ e.preventDefault();
636
+ }
637
+ }
638
+ function useKeyDown(active, keyHandlers) {
639
+ var keyHandlersRef = React.useRef(keyHandlers);
640
+ useIsomorphicEffect(function () {
641
+ keyHandlersRef.current = keyHandlers;
642
+ });
643
+ React.useEffect(function () {
644
+ if (active) {
645
+ var handleKeyDown_1 = function (event) {
646
+ runKeyHandler(event, keyHandlers);
647
+ };
648
+
649
+ window.addEventListener('keydown', handleKeyDown_1);
650
+ return function () {
651
+ window.removeEventListener('keydown', handleKeyDown_1);
652
+ };
653
+ }
654
+ }, [active, keyHandlers]);
655
+ }
656
+
657
+ var withUtils = function () {
658
+ return function (Component) {
659
+ var WithUtils = function (props) {
660
+ var utils = useUtils();
661
+ return React.createElement(Component, tslib.__assign({
662
+ utils: utils
663
+ }, props));
664
+ };
665
+
666
+ WithUtils.displayName = "WithUtils(" + (Component.displayName || Component.name) + ")";
667
+ return WithUtils;
668
+ };
669
+ };
670
+
671
+ var KeyDownListener = function (_a) {
672
+ var onKeyDown = _a.onKeyDown;
673
+ React.useEffect(function () {
674
+ window.addEventListener('keydown', onKeyDown);
675
+ return function () {
676
+ window.removeEventListener('keydown', onKeyDown);
677
+ };
678
+ }, [onKeyDown]);
679
+ return null;
680
+ };
681
+
682
+ var Calendar =
683
+ /** @class */
684
+ function (_super) {
685
+ tslib.__extends(Calendar, _super);
686
+
687
+ function Calendar() {
688
+ var _this = _super !== null && _super.apply(this, arguments) || this;
689
+
690
+ _this.state = {
691
+ slideDirection: 'left',
692
+ currentMonth: _this.props.utils.startOfMonth(_this.props.date),
693
+ loadingQueue: 0
694
+ };
695
+
696
+ _this.pushToLoadingQueue = function () {
697
+ var loadingQueue = _this.state.loadingQueue + 1;
698
+
699
+ _this.setState({
700
+ loadingQueue: loadingQueue
701
+ });
702
+ };
703
+
704
+ _this.popFromLoadingQueue = function () {
705
+ var loadingQueue = _this.state.loadingQueue;
706
+ loadingQueue = loadingQueue <= 0 ? 0 : loadingQueue - 1;
707
+
708
+ _this.setState({
709
+ loadingQueue: loadingQueue
710
+ });
711
+ };
712
+
713
+ _this.handleChangeMonth = function (newMonth, slideDirection) {
714
+ _this.setState({
715
+ currentMonth: newMonth,
716
+ slideDirection: slideDirection
717
+ });
718
+
719
+ if (_this.props.onMonthChange) {
720
+ var returnVal = _this.props.onMonthChange(newMonth);
721
+
722
+ if (returnVal) {
723
+ _this.pushToLoadingQueue();
724
+
725
+ returnVal.then(function () {
726
+ _this.popFromLoadingQueue();
727
+ });
728
+ }
729
+ }
730
+ };
731
+
732
+ _this.validateMinMaxDate = function (day) {
733
+ var _a = _this.props,
734
+ minDate = _a.minDate,
735
+ maxDate = _a.maxDate,
736
+ utils = _a.utils,
737
+ disableFuture = _a.disableFuture,
738
+ disablePast = _a.disablePast;
739
+ var now = utils.date();
740
+ var moment = utils.moment;
741
+ return Boolean(disableFuture && utils.isAfterDay(day, now) || disablePast && moment(day).isBefore(now, 'second') || minDate && utils.isBeforeDay(day, utils.date(minDate)) || maxDate && utils.isAfterDay(day, utils.date(maxDate)));
742
+ };
743
+
744
+ _this.shouldDisablePrevMonth = function () {
745
+ var _a = _this.props,
746
+ utils = _a.utils,
747
+ disablePast = _a.disablePast,
748
+ minDate = _a.minDate;
749
+ var now = utils.date();
750
+ var firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, utils.date(minDate)) ? now : utils.date(minDate));
751
+ return !utils.isBefore(firstEnabledMonth, _this.state.currentMonth);
752
+ };
753
+
754
+ _this.shouldDisableNextMonth = function () {
755
+ var _a = _this.props,
756
+ utils = _a.utils,
757
+ disableFuture = _a.disableFuture,
758
+ maxDate = _a.maxDate;
759
+ var now = utils.date();
760
+ var lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, utils.date(maxDate)) ? now : utils.date(maxDate));
761
+ return !utils.isAfter(lastEnabledMonth, _this.state.currentMonth);
762
+ };
763
+
764
+ _this.shouldDisableDate = function (day) {
765
+ var shouldDisableDate = _this.props.shouldDisableDate;
766
+ return _this.validateMinMaxDate(day) || Boolean(shouldDisableDate && shouldDisableDate(day));
767
+ };
768
+
769
+ _this.handleDaySelect = function (day, isFinish) {
770
+ if (isFinish === void 0) {
771
+ isFinish = true;
772
+ }
773
+
774
+ var _a = _this.props,
775
+ date = _a.date,
776
+ utils = _a.utils;
777
+
778
+ _this.props.onChange(utils.mergeDateAndTime(day, date), isFinish);
779
+ };
780
+
781
+ _this.moveToDay = function (day) {
782
+ var utils = _this.props.utils;
783
+
784
+ if (day && !_this.shouldDisableDate(day)) {
785
+ if (utils.getMonth(day) !== utils.getMonth(_this.state.currentMonth)) {
786
+ _this.handleChangeMonth(utils.startOfMonth(day), 'left');
787
+ }
788
+
789
+ _this.handleDaySelect(day, false);
790
+ }
791
+ };
792
+
793
+ _this.handleKeyDown = function (event) {
794
+ var _a = _this.props,
795
+ theme = _a.theme,
796
+ date = _a.date,
797
+ utils = _a.utils;
798
+ runKeyHandler(event, {
799
+ ArrowUp: function () {
800
+ return _this.moveToDay(utils.addDays(date, -7));
801
+ },
802
+ ArrowDown: function () {
803
+ return _this.moveToDay(utils.addDays(date, 7));
804
+ },
805
+ ArrowLeft: function () {
806
+ return _this.moveToDay(utils.addDays(date, theme.direction === 'ltr' ? -1 : 1));
807
+ },
808
+ ArrowRight: function () {
809
+ return _this.moveToDay(utils.addDays(date, theme.direction === 'ltr' ? 1 : -1));
810
+ }
811
+ });
812
+ };
813
+
814
+ _this.renderWeeks = function () {
815
+ var _a = _this.props,
816
+ utils = _a.utils,
817
+ classes = _a.classes;
818
+ var weeks = utils.getWeekArray(_this.state.currentMonth);
819
+ return weeks.map(function (week) {
820
+ return React.createElement("div", {
821
+ key: "week-" + week[0].toString(),
822
+ className: classes.week
823
+ }, _this.renderDays(week));
824
+ });
825
+ };
826
+
827
+ _this.renderDays = function (week) {
828
+ var _a = _this.props,
829
+ date = _a.date,
830
+ renderDay = _a.renderDay,
831
+ utils = _a.utils;
832
+ var now = utils.date();
833
+ var selectedDate = utils.startOfDay(date);
834
+ var currentMonthNumber = utils.getMonth(_this.state.currentMonth);
835
+ return week.map(function (day) {
836
+ var disabled = _this.shouldDisableDate(day);
837
+
838
+ var isDayInCurrentMonth = utils.getMonth(day) === currentMonthNumber;
839
+ var dayComponent = React.createElement(Day, {
840
+ disabled: disabled,
841
+ current: utils.isSameDay(day, now),
842
+ hidden: !isDayInCurrentMonth,
843
+ selected: utils.isSameDay(selectedDate, day)
844
+ }, utils.getDayText(day));
845
+
846
+ if (renderDay) {
847
+ dayComponent = renderDay(day, selectedDate, isDayInCurrentMonth, dayComponent);
848
+ }
849
+
850
+ return React.createElement(DayWrapper, {
851
+ value: day,
852
+ key: day.toString(),
853
+ disabled: disabled,
854
+ dayInCurrentMonth: isDayInCurrentMonth,
855
+ onSelect: _this.handleDaySelect
856
+ }, dayComponent);
857
+ });
858
+ };
859
+
860
+ return _this;
861
+ }
862
+
863
+ Calendar.getDerivedStateFromProps = function (nextProps, state) {
864
+ var utils = nextProps.utils,
865
+ nextDate = nextProps.date;
866
+
867
+ if (!utils.isEqual(nextDate, state.lastDate)) {
868
+ var nextMonth = utils.getMonth(nextDate);
869
+ var lastDate = state.lastDate || nextDate;
870
+ var lastMonth = utils.getMonth(lastDate);
871
+ return {
872
+ lastDate: nextDate,
873
+ currentMonth: nextProps.utils.startOfMonth(nextDate),
874
+ // prettier-ignore
875
+ slideDirection: nextMonth === lastMonth ? state.slideDirection : utils.isAfterDay(nextDate, lastDate) ? 'left' : 'right'
876
+ };
877
+ }
878
+
879
+ return null;
880
+ };
881
+
882
+ Calendar.prototype.componentDidMount = function () {
883
+ var _a = this.props,
884
+ date = _a.date,
885
+ minDate = _a.minDate,
886
+ maxDate = _a.maxDate,
887
+ utils = _a.utils,
888
+ disablePast = _a.disablePast,
889
+ disableFuture = _a.disableFuture;
890
+
891
+ if (this.shouldDisableDate(date)) {
892
+ var closestEnabledDate = findClosestEnabledDate({
893
+ date: date,
894
+ utils: utils,
895
+ minDate: utils.date(minDate),
896
+ maxDate: utils.date(maxDate),
897
+ disablePast: Boolean(disablePast),
898
+ disableFuture: Boolean(disableFuture),
899
+ shouldDisableDate: this.shouldDisableDate
900
+ });
901
+ this.handleDaySelect(closestEnabledDate, false);
902
+ }
903
+ };
904
+
905
+ Calendar.prototype.render = function () {
906
+ var _a = this.state,
907
+ currentMonth = _a.currentMonth,
908
+ slideDirection = _a.slideDirection;
909
+ var _b = this.props,
910
+ classes = _b.classes,
911
+ allowKeyboardControl = _b.allowKeyboardControl,
912
+ leftArrowButtonProps = _b.leftArrowButtonProps,
913
+ leftArrowIcon = _b.leftArrowIcon,
914
+ rightArrowButtonProps = _b.rightArrowButtonProps,
915
+ rightArrowIcon = _b.rightArrowIcon,
916
+ loadingIndicator = _b.loadingIndicator;
917
+ var loadingElement = loadingIndicator ? loadingIndicator : React.createElement(CircularProgress, null);
918
+ return React.createElement(React.Fragment, null, allowKeyboardControl && React.createElement(KeyDownListener, {
919
+ onKeyDown: this.handleKeyDown
920
+ }), React.createElement(CalendarHeader, {
921
+ currentMonth: currentMonth,
922
+ slideDirection: slideDirection,
923
+ onMonthChange: this.handleChangeMonth,
924
+ leftArrowIcon: leftArrowIcon,
925
+ leftArrowButtonProps: leftArrowButtonProps,
926
+ rightArrowIcon: rightArrowIcon,
927
+ rightArrowButtonProps: rightArrowButtonProps,
928
+ disablePrevMonth: this.shouldDisablePrevMonth(),
929
+ disableNextMonth: this.shouldDisableNextMonth()
930
+ }), React.createElement(SlideTransition, {
931
+ slideDirection: slideDirection,
932
+ transKey: currentMonth.toString(),
933
+ className: classes.transitionContainer
934
+ }, React.createElement(React.Fragment, null, this.state.loadingQueue > 0 && React.createElement("div", {
935
+ className: classes.progressContainer
936
+ }, loadingElement) || React.createElement("div", null, this.renderWeeks()))));
937
+ };
938
+
939
+ process.env.NODE_ENV !== "production" ? Calendar.propTypes = {
940
+ renderDay: PropTypes.func,
941
+ shouldDisableDate: PropTypes.func,
942
+ allowKeyboardControl: PropTypes.bool
943
+ } : void 0;
944
+ Calendar.defaultProps = {
945
+ minDate: new Date('1900-01-01'),
946
+ maxDate: new Date('2200-01-01'),
947
+ disablePast: false,
948
+ disableFuture: false,
949
+ allowKeyboardControl: true
950
+ };
951
+ return Calendar;
952
+ }(React.Component);
953
+ var styles$1 = function (theme) {
954
+ return {
955
+ transitionContainer: {
956
+ minHeight: 36 * 6,
957
+ marginTop: theme.spacing(1.5)
958
+ },
959
+ progressContainer: {
960
+ width: '100%',
961
+ height: '100%',
962
+ display: 'flex',
963
+ justifyContent: 'center',
964
+ alignItems: 'center'
965
+ },
966
+ week: {
967
+ display: 'flex',
968
+ justifyContent: 'center'
969
+ }
970
+ };
971
+ };
972
+ var Calendar$1 = styles$5.withStyles(styles$1, {
973
+ name: 'MuiPickersCalendar',
974
+ withTheme: true
975
+ })(withUtils()(Calendar));
976
+
977
+ function useViews(views, openTo, onChange) {
978
+ var _a = React.useState(openTo && arrayIncludes(views, openTo) ? openTo : views[0]),
979
+ openView = _a[0],
980
+ setOpenView = _a[1];
981
+
982
+ var handleChangeAndOpenNext = React.useCallback(function (date, isFinish) {
983
+ var nextViewToOpen = views[views.indexOf(openView) + 1];
984
+
985
+ if (isFinish && nextViewToOpen) {
986
+ // do not close picker if needs to show next view
987
+ onChange(date, false);
988
+ setOpenView(nextViewToOpen);
989
+ return;
990
+ }
991
+
992
+ onChange(date, Boolean(isFinish));
993
+ }, [onChange, openView, views]);
994
+ return {
995
+ handleChangeAndOpenNext: handleChangeAndOpenNext,
996
+ openView: openView,
997
+ setOpenView: setOpenView
998
+ };
999
+ }
1000
+
1001
+ var useStyles$6 = styles$5.makeStyles(function (theme) {
1002
+ return {
1003
+ root: {
1004
+ height: 40,
1005
+ display: 'flex',
1006
+ alignItems: 'center',
1007
+ justifyContent: 'center',
1008
+ cursor: 'pointer',
1009
+ outline: 'none',
1010
+ '&:focus': {
1011
+ color: theme.palette.primary.main,
1012
+ fontWeight: theme.typography.fontWeightMedium
1013
+ }
1014
+ },
1015
+ yearSelected: {
1016
+ margin: '10px 0',
1017
+ fontWeight: theme.typography.fontWeightMedium
1018
+ },
1019
+ yearDisabled: {
1020
+ pointerEvents: 'none',
1021
+ color: theme.palette.text.hint
1022
+ }
1023
+ };
1024
+ }, {
1025
+ name: 'MuiPickersYear'
1026
+ });
1027
+ var Year = function (_a) {
1028
+ var _b;
1029
+
1030
+ var onSelect = _a.onSelect,
1031
+ forwardedRef = _a.forwardedRef,
1032
+ value = _a.value,
1033
+ selected = _a.selected,
1034
+ disabled = _a.disabled,
1035
+ children = _a.children,
1036
+ other = tslib.__rest(_a, ["onSelect", "forwardedRef", "value", "selected", "disabled", "children"]);
1037
+
1038
+ var classes = useStyles$6();
1039
+ var handleClick = React.useCallback(function () {
1040
+ return onSelect(value);
1041
+ }, [onSelect, value]);
1042
+ return React.createElement(Typography, tslib.__assign({
1043
+ role: "button",
1044
+ component: "div",
1045
+ tabIndex: disabled ? -1 : 0,
1046
+ onClick: handleClick,
1047
+ onKeyPress: handleClick,
1048
+ color: selected ? 'primary' : undefined,
1049
+ variant: selected ? 'h5' : 'subtitle1',
1050
+ children: children,
1051
+ ref: forwardedRef,
1052
+ className: clsx(classes.root, (_b = {}, _b[classes.yearSelected] = selected, _b[classes.yearDisabled] = disabled, _b))
1053
+ }, other));
1054
+ };
1055
+ Year.displayName = 'Year';
1056
+ var Year$1 = React.forwardRef(function (props, ref) {
1057
+ return React.createElement(Year, tslib.__assign({}, props, {
1058
+ forwardedRef: ref
1059
+ }));
1060
+ });
1061
+
1062
+ var DIALOG_WIDTH = 310;
1063
+ var DIALOG_WIDTH_WIDER = 325;
1064
+ var VIEW_HEIGHT = 305;
1065
+
1066
+ var useStyles$7 = core.makeStyles(function (theme) {
1067
+ return {
1068
+ staticWrapperRoot: {
1069
+ overflow: 'hidden',
1070
+ minWidth: DIALOG_WIDTH,
1071
+ display: 'flex',
1072
+ flexDirection: 'column',
1073
+ backgroundColor: theme.palette.background.paper
1074
+ }
1075
+ };
1076
+ }, {
1077
+ name: 'MuiPickersStaticWrapper'
1078
+ });
1079
+ var StaticWrapper = function (_a) {
1080
+ var children = _a.children;
1081
+ var classes = useStyles$7();
1082
+ return React.createElement("div", {
1083
+ className: classes.staticWrapperRoot,
1084
+ children: children
1085
+ });
1086
+ };
1087
+
1088
+ var ModalDialog = function (_a) {
1089
+ var _b, _c;
1090
+
1091
+ var children = _a.children,
1092
+ classes = _a.classes,
1093
+ onAccept = _a.onAccept,
1094
+ onDismiss = _a.onDismiss,
1095
+ onClear = _a.onClear,
1096
+ onSetToday = _a.onSetToday,
1097
+ okLabel = _a.okLabel,
1098
+ cancelLabel = _a.cancelLabel,
1099
+ clearLabel = _a.clearLabel,
1100
+ todayLabel = _a.todayLabel,
1101
+ clearable = _a.clearable,
1102
+ showTodayButton = _a.showTodayButton,
1103
+ showTabs = _a.showTabs,
1104
+ wider = _a.wider,
1105
+ other = tslib.__rest(_a, ["children", "classes", "onAccept", "onDismiss", "onClear", "onSetToday", "okLabel", "cancelLabel", "clearLabel", "todayLabel", "clearable", "showTodayButton", "showTabs", "wider"]);
1106
+
1107
+ return React.createElement(Dialog, tslib.__assign({
1108
+ role: "dialog",
1109
+ onClose: onDismiss,
1110
+ classes: {
1111
+ paper: clsx(classes.dialogRoot, (_b = {}, _b[classes.dialogRootWider] = wider, _b))
1112
+ }
1113
+ }, other), React.createElement(DialogContent, {
1114
+ children: children,
1115
+ className: classes.dialog
1116
+ }), React.createElement(DialogActions, {
1117
+ classes: {
1118
+ root: clsx((_c = {}, _c[classes.withAdditionalAction] = clearable || showTodayButton, _c))
1119
+ }
1120
+ }, clearable && React.createElement(Button, {
1121
+ color: "primary",
1122
+ onClick: onClear
1123
+ }, clearLabel), !clearable && showTodayButton && React.createElement(Button, {
1124
+ color: "primary",
1125
+ onClick: onSetToday
1126
+ }, todayLabel), cancelLabel && React.createElement(Button, {
1127
+ color: "primary",
1128
+ onClick: onDismiss
1129
+ }, cancelLabel), okLabel && React.createElement(Button, {
1130
+ color: "primary",
1131
+ onClick: onAccept
1132
+ }, okLabel)));
1133
+ };
1134
+ ModalDialog.displayName = 'ModalDialog';
1135
+ var styles$2 = styles$5.createStyles({
1136
+ dialogRoot: {
1137
+ minWidth: DIALOG_WIDTH
1138
+ },
1139
+ dialogRootWider: {// minWidth: DIALOG_WIDTH_WIDER,
1140
+ },
1141
+ dialog: {
1142
+ '&:first-child': {
1143
+ padding: 0
1144
+ }
1145
+ },
1146
+ withAdditionalAction: {
1147
+ // set justifyContent to default value to fix IE11 layout bug
1148
+ // see https://github.com/dmtrKovalenko/material-ui-pickers/pull/267
1149
+ justifyContent: 'flex-start',
1150
+ '& > *:first-child': {
1151
+ marginRight: 'auto'
1152
+ }
1153
+ }
1154
+ });
1155
+ var ModalDialog$1 = styles$5.withStyles(styles$2, {
1156
+ name: 'MuiPickersModal'
1157
+ })(ModalDialog);
1158
+
1159
+ var ModalWrapper = function (_a) {
1160
+ var open = _a.open,
1161
+ children = _a.children,
1162
+ okLabel = _a.okLabel,
1163
+ cancelLabel = _a.cancelLabel,
1164
+ clearLabel = _a.clearLabel,
1165
+ todayLabel = _a.todayLabel,
1166
+ showTodayButton = _a.showTodayButton,
1167
+ clearable = _a.clearable,
1168
+ DialogProps = _a.DialogProps,
1169
+ showTabs = _a.showTabs,
1170
+ wider = _a.wider,
1171
+ InputComponent = _a.InputComponent,
1172
+ DateInputProps = _a.DateInputProps,
1173
+ onClear = _a.onClear,
1174
+ onAccept = _a.onAccept,
1175
+ onDismiss = _a.onDismiss,
1176
+ onSetToday = _a.onSetToday,
1177
+ other = tslib.__rest(_a, ["open", "children", "okLabel", "cancelLabel", "clearLabel", "todayLabel", "showTodayButton", "clearable", "DialogProps", "showTabs", "wider", "InputComponent", "DateInputProps", "onClear", "onAccept", "onDismiss", "onSetToday"]);
1178
+
1179
+ useKeyDown(open, {
1180
+ Enter: onAccept
1181
+ });
1182
+ return React.createElement(React.Fragment, null, React.createElement(InputComponent, tslib.__assign({}, other, DateInputProps)), React.createElement(ModalDialog$1, tslib.__assign({
1183
+ wider: wider,
1184
+ showTabs: showTabs,
1185
+ open: open,
1186
+ onClear: onClear,
1187
+ onAccept: onAccept,
1188
+ onDismiss: onDismiss,
1189
+ onSetToday: onSetToday,
1190
+ clearLabel: clearLabel,
1191
+ todayLabel: todayLabel,
1192
+ okLabel: okLabel,
1193
+ cancelLabel: cancelLabel,
1194
+ clearable: clearable,
1195
+ showTodayButton: showTodayButton,
1196
+ children: children
1197
+ }, DialogProps)));
1198
+ };
1199
+ process.env.NODE_ENV !== "production" ? ModalWrapper.propTypes = {
1200
+ okLabel: PropTypes.node,
1201
+ cancelLabel: PropTypes.node,
1202
+ clearLabel: PropTypes.node,
1203
+ clearable: PropTypes.bool,
1204
+ todayLabel: PropTypes.node,
1205
+ showTodayButton: PropTypes.bool,
1206
+ DialogProps: PropTypes.object
1207
+ } : void 0;
1208
+ ModalWrapper.defaultProps = {
1209
+ okLabel: 'OK',
1210
+ cancelLabel: 'Cancel',
1211
+ clearLabel: 'Clear',
1212
+ todayLabel: 'Today',
1213
+ clearable: false,
1214
+ showTodayButton: false
1215
+ };
1216
+
1217
+ var useStyles$8 = styles$5.makeStyles({
1218
+ popoverPaper: {
1219
+ width: DIALOG_WIDTH,
1220
+ paddingBottom: 8
1221
+ },
1222
+ popoverPaperWider: {
1223
+ width: DIALOG_WIDTH_WIDER
1224
+ }
1225
+ }, {
1226
+ name: 'MuiPickersInlineWrapper'
1227
+ });
1228
+ var InlineWrapper = function (_a) {
1229
+ var _b;
1230
+
1231
+ var open = _a.open,
1232
+ wider = _a.wider,
1233
+ children = _a.children,
1234
+ PopoverProps = _a.PopoverProps,
1235
+ onClear = _a.onClear,
1236
+ onDismiss = _a.onDismiss,
1237
+ onSetToday = _a.onSetToday,
1238
+ onAccept = _a.onAccept,
1239
+ showTabs = _a.showTabs,
1240
+ showTodayButton = _a.showTodayButton,
1241
+ todayLabel = _a.todayLabel,
1242
+ DateInputProps = _a.DateInputProps,
1243
+ InputComponent = _a.InputComponent,
1244
+ other = tslib.__rest(_a, ["open", "wider", "children", "PopoverProps", "onClear", "onDismiss", "onSetToday", "onAccept", "showTabs", "showTodayButton", "todayLabel", "DateInputProps", "InputComponent"]);
1245
+
1246
+ var ref = React.useRef();
1247
+ var classes = useStyles$8();
1248
+ useKeyDown(open, {
1249
+ Enter: onAccept
1250
+ });
1251
+ return React.createElement(React.Fragment, null, React.createElement(InputComponent, tslib.__assign({}, other, DateInputProps, {
1252
+ inputRef: ref
1253
+ })), React.createElement(Popover, tslib.__assign({
1254
+ open: open,
1255
+ onClose: onDismiss,
1256
+ anchorEl: ref.current,
1257
+ classes: {
1258
+ paper: clsx(classes.popoverPaper, (_b = {}, _b[classes.popoverPaperWider] = wider, _b))
1259
+ },
1260
+ anchorOrigin: {
1261
+ vertical: 'bottom',
1262
+ horizontal: 'center'
1263
+ },
1264
+ transformOrigin: {
1265
+ vertical: 'top',
1266
+ horizontal: 'center'
1267
+ },
1268
+ children: children
1269
+ }, PopoverProps)));
1270
+ };
1271
+ process.env.NODE_ENV !== "production" ? InlineWrapper.propTypes = {
1272
+ onOpen: PropTypes.func,
1273
+ onClose: PropTypes.func,
1274
+ PopoverProps: PropTypes.object
1275
+ } : void 0;
1276
+
1277
+ function getWrapperFromVariant(variant) {
1278
+ switch (variant) {
1279
+ case 'inline':
1280
+ return InlineWrapper;
1281
+
1282
+ case 'static':
1283
+ return StaticWrapper;
1284
+
1285
+ default:
1286
+ return ModalWrapper;
1287
+ }
1288
+ }
1289
+ var VariantContext = React.createContext(null);
1290
+ var Wrapper = function (_a) {
1291
+ var variant = _a.variant,
1292
+ props = tslib.__rest(_a, ["variant"]);
1293
+
1294
+ var Component = getWrapperFromVariant(variant);
1295
+ return React.createElement(VariantContext.Provider, {
1296
+ value: variant || 'dialog'
1297
+ }, React.createElement(Component, tslib.__assign({}, props)));
1298
+ };
1299
+
1300
+ var useStyles$9 = styles$5.makeStyles({
1301
+ container: {
1302
+ height: 300,
1303
+ overflowY: 'auto'
1304
+ }
1305
+ }, {
1306
+ name: 'MuiPickersYearSelection'
1307
+ });
1308
+ var YearSelection = function (_a) {
1309
+ var date = _a.date,
1310
+ onChange = _a.onChange,
1311
+ onYearChange = _a.onYearChange,
1312
+ minDate = _a.minDate,
1313
+ maxDate = _a.maxDate,
1314
+ disablePast = _a.disablePast,
1315
+ disableFuture = _a.disableFuture,
1316
+ animateYearScrolling = _a.animateYearScrolling;
1317
+ var utils = useUtils();
1318
+ var classes = useStyles$9();
1319
+ var currentVariant = React.useContext(VariantContext);
1320
+ var selectedYearRef = React.useRef(null);
1321
+ React.useEffect(function () {
1322
+ if (selectedYearRef.current && selectedYearRef.current.scrollIntoView) {
1323
+ selectedYearRef.current.scrollIntoView({
1324
+ block: currentVariant === 'static' ? 'nearest' : 'center',
1325
+ behavior: animateYearScrolling ? 'smooth' : 'auto'
1326
+ });
1327
+ }
1328
+ }, []); // eslint-disable-line
1329
+
1330
+ var currentYear = utils.getYear(date);
1331
+ var onYearSelect = React.useCallback(function (year) {
1332
+ var newDate = utils.setYear(date, year);
1333
+
1334
+ if (onYearChange) {
1335
+ onYearChange(newDate);
1336
+ }
1337
+
1338
+ onChange(newDate, true);
1339
+ }, [date, onChange, onYearChange, utils]);
1340
+ return React.createElement("div", {
1341
+ className: classes.container
1342
+ }, utils.getYearRange(minDate, maxDate).map(function (year) {
1343
+ var yearNumber = utils.getYear(year);
1344
+ var selected = yearNumber === currentYear;
1345
+ return React.createElement(Year$1, {
1346
+ key: utils.getYearText(year),
1347
+ selected: selected,
1348
+ value: yearNumber,
1349
+ onSelect: onYearSelect,
1350
+ ref: selected ? selectedYearRef : undefined,
1351
+ disabled: Boolean(disablePast && utils.isBeforeYear(year, utils.date()) || disableFuture && utils.isAfterYear(year, utils.date()))
1352
+ }, utils.getYearText(year));
1353
+ }));
1354
+ };
1355
+
1356
+ var ClockType;
1357
+
1358
+ (function (ClockType) {
1359
+ ClockType["HOURS"] = "hours";
1360
+ ClockType["MINUTES"] = "minutes";
1361
+ ClockType["SECONDS"] = "seconds";
1362
+ })(ClockType || (ClockType = {}));
1363
+
1364
+ var ClockType$1 = ClockType;
1365
+
1366
+ var ClockPointer =
1367
+ /** @class */
1368
+ function (_super) {
1369
+ tslib.__extends(ClockPointer, _super);
1370
+
1371
+ function ClockPointer() {
1372
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1373
+
1374
+ _this.state = {
1375
+ toAnimateTransform: false,
1376
+ previousType: undefined
1377
+ };
1378
+
1379
+ _this.getAngleStyle = function () {
1380
+ var _a = _this.props,
1381
+ value = _a.value,
1382
+ isInner = _a.isInner,
1383
+ type = _a.type;
1384
+ var max = type === ClockType$1.HOURS ? 12 : 60;
1385
+ var angle = 360 / max * value;
1386
+
1387
+ if (type === ClockType$1.HOURS && value > 12) {
1388
+ angle -= 360; // round up angle to max 360 degrees
1389
+ }
1390
+
1391
+ return {
1392
+ height: isInner ? '26%' : '40%',
1393
+ transform: "rotateZ(" + angle + "deg)"
1394
+ };
1395
+ };
1396
+
1397
+ return _this;
1398
+ }
1399
+
1400
+ ClockPointer.prototype.render = function () {
1401
+ var _a, _b;
1402
+
1403
+ var _c = this.props,
1404
+ classes = _c.classes,
1405
+ hasSelected = _c.hasSelected;
1406
+ return React.createElement("div", {
1407
+ style: this.getAngleStyle(),
1408
+ className: clsx(classes.pointer, (_a = {}, _a[classes.animateTransform] = this.state.toAnimateTransform, _a))
1409
+ }, React.createElement("div", {
1410
+ className: clsx(classes.thumb, (_b = {}, _b[classes.noPoint] = hasSelected, _b))
1411
+ }));
1412
+ };
1413
+
1414
+ ClockPointer.getDerivedStateFromProps = function (nextProps, state) {
1415
+ if (nextProps.type !== state.previousType) {
1416
+ return {
1417
+ toAnimateTransform: true,
1418
+ previousType: nextProps.type
1419
+ };
1420
+ }
1421
+
1422
+ return {
1423
+ toAnimateTransform: false,
1424
+ previousType: nextProps.type
1425
+ };
1426
+ };
1427
+
1428
+ return ClockPointer;
1429
+ }(React.Component);
1430
+ var styles$3 = function (theme) {
1431
+ return styles$5.createStyles({
1432
+ pointer: {
1433
+ width: 2,
1434
+ backgroundColor: theme.palette.primary.main,
1435
+ position: 'absolute',
1436
+ left: 'calc(50% - 1px)',
1437
+ bottom: '50%',
1438
+ transformOrigin: 'center bottom 0px'
1439
+ },
1440
+ animateTransform: {
1441
+ transition: theme.transitions.create(['transform', 'height'])
1442
+ },
1443
+ thumb: {
1444
+ width: 4,
1445
+ height: 4,
1446
+ backgroundColor: theme.palette.primary.contrastText,
1447
+ borderRadius: '100%',
1448
+ position: 'absolute',
1449
+ top: -21,
1450
+ left: -15,
1451
+ border: "14px solid " + theme.palette.primary.main,
1452
+ boxSizing: 'content-box'
1453
+ },
1454
+ noPoint: {
1455
+ backgroundColor: theme.palette.primary.main
1456
+ }
1457
+ });
1458
+ };
1459
+ var ClockPointer$1 = styles$5.withStyles(styles$3, {
1460
+ name: 'MuiPickersClockPointer'
1461
+ })(ClockPointer);
1462
+
1463
+ var center = {
1464
+ x: 260 / 2,
1465
+ y: 260 / 2
1466
+ };
1467
+ var basePoint = {
1468
+ x: center.x,
1469
+ y: 0
1470
+ };
1471
+ var cx = basePoint.x - center.x;
1472
+ var cy = basePoint.y - center.y;
1473
+
1474
+ var rad2deg = function (rad) {
1475
+ return rad * 57.29577951308232;
1476
+ };
1477
+
1478
+ var getAngleValue = function (step, offsetX, offsetY) {
1479
+ var x = offsetX - center.x;
1480
+ var y = offsetY - center.y;
1481
+ var atan = Math.atan2(cx, cy) - Math.atan2(x, y);
1482
+ var deg = rad2deg(atan);
1483
+ deg = Math.round(deg / step) * step;
1484
+ deg %= 360;
1485
+ var value = Math.floor(deg / step) || 0;
1486
+ var delta = Math.pow(x, 2) + Math.pow(y, 2);
1487
+ var distance = Math.sqrt(delta);
1488
+ return {
1489
+ value: value,
1490
+ distance: distance
1491
+ };
1492
+ };
1493
+
1494
+ var getHours = function (offsetX, offsetY, ampm) {
1495
+ var _a = getAngleValue(30, offsetX, offsetY),
1496
+ value = _a.value,
1497
+ distance = _a.distance;
1498
+
1499
+ value = value || 12;
1500
+
1501
+ if (!ampm) {
1502
+ if (distance < 90) {
1503
+ value += 12;
1504
+ value %= 24;
1505
+ }
1506
+ } else {
1507
+ value %= 12;
1508
+ }
1509
+
1510
+ return value;
1511
+ };
1512
+ var getMinutes = function (offsetX, offsetY, step) {
1513
+ if (step === void 0) {
1514
+ step = 1;
1515
+ }
1516
+
1517
+ var angleStep = step * 6;
1518
+ var value = getAngleValue(angleStep, offsetX, offsetY).value;
1519
+ value = value * step % 60;
1520
+ return value;
1521
+ };
1522
+ var getMeridiem = function (date, utils) {
1523
+ return utils.getHours(date) >= 12 ? 'pm' : 'am';
1524
+ };
1525
+ var convertToMeridiem = function (time, meridiem, ampm, utils) {
1526
+ if (ampm) {
1527
+ var currentMeridiem = utils.getHours(time) >= 12 ? 'pm' : 'am';
1528
+
1529
+ if (currentMeridiem !== meridiem) {
1530
+ var hours = meridiem === 'am' ? utils.getHours(time) - 12 : utils.getHours(time) + 12;
1531
+ return utils.setHours(time, hours);
1532
+ }
1533
+ }
1534
+
1535
+ return time;
1536
+ };
1537
+
1538
+ var Clock =
1539
+ /** @class */
1540
+ function (_super) {
1541
+ tslib.__extends(Clock, _super);
1542
+
1543
+ function Clock() {
1544
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1545
+
1546
+ _this.isMoving = false;
1547
+
1548
+ _this.handleTouchMove = function (e) {
1549
+ _this.isMoving = true;
1550
+
1551
+ _this.setTime(e);
1552
+ };
1553
+
1554
+ _this.handleTouchEnd = function (e) {
1555
+ if (_this.isMoving) {
1556
+ _this.setTime(e, true);
1557
+
1558
+ _this.isMoving = false;
1559
+ }
1560
+ };
1561
+
1562
+ _this.handleMove = function (e) {
1563
+ e.preventDefault();
1564
+ e.stopPropagation(); // MouseEvent.which is deprecated, but MouseEvent.buttons is not supported in Safari
1565
+
1566
+ var isButtonPressed = typeof e.buttons === 'undefined' ? e.nativeEvent.which === 1 : e.buttons === 1;
1567
+
1568
+ if (isButtonPressed) {
1569
+ _this.setTime(e.nativeEvent, false);
1570
+ }
1571
+ };
1572
+
1573
+ _this.handleMouseUp = function (e) {
1574
+ if (_this.isMoving) {
1575
+ _this.isMoving = false;
1576
+ }
1577
+
1578
+ _this.setTime(e.nativeEvent, true);
1579
+ };
1580
+
1581
+ _this.hasSelected = function () {
1582
+ var _a = _this.props,
1583
+ type = _a.type,
1584
+ value = _a.value;
1585
+
1586
+ if (type === ClockType$1.HOURS) {
1587
+ return true;
1588
+ }
1589
+
1590
+ return value % 5 === 0;
1591
+ };
1592
+
1593
+ return _this;
1594
+ }
1595
+
1596
+ Clock.prototype.setTime = function (e, isFinish) {
1597
+ if (isFinish === void 0) {
1598
+ isFinish = false;
1599
+ }
1600
+
1601
+ var offsetX = e.offsetX,
1602
+ offsetY = e.offsetY;
1603
+
1604
+ if (typeof offsetX === 'undefined') {
1605
+ var rect = e.target.getBoundingClientRect();
1606
+ offsetX = e.changedTouches[0].clientX - rect.left;
1607
+ offsetY = e.changedTouches[0].clientY - rect.top;
1608
+ }
1609
+
1610
+ var value = this.props.type === ClockType$1.SECONDS || this.props.type === ClockType$1.MINUTES ? getMinutes(offsetX, offsetY, this.props.minutesStep) : getHours(offsetX, offsetY, Boolean(this.props.ampm));
1611
+ this.props.onChange(value, isFinish);
1612
+ };
1613
+
1614
+ Clock.prototype.render = function () {
1615
+ var _a = this.props,
1616
+ classes = _a.classes,
1617
+ value = _a.value,
1618
+ children = _a.children,
1619
+ type = _a.type,
1620
+ ampm = _a.ampm;
1621
+ var isPointerInner = !ampm && type === ClockType$1.HOURS && (value < 1 || value > 12);
1622
+ return React.createElement("div", {
1623
+ className: classes.container
1624
+ }, React.createElement("div", {
1625
+ className: classes.clock
1626
+ }, React.createElement("div", {
1627
+ role: "menu",
1628
+ tabIndex: -1,
1629
+ className: classes.squareMask,
1630
+ onTouchMove: this.handleTouchMove,
1631
+ onTouchEnd: this.handleTouchEnd,
1632
+ onMouseUp: this.handleMouseUp,
1633
+ onMouseMove: this.handleMove
1634
+ }), React.createElement("div", {
1635
+ className: classes.pin
1636
+ }), React.createElement(ClockPointer$1, {
1637
+ type: type,
1638
+ value: value,
1639
+ isInner: isPointerInner,
1640
+ hasSelected: this.hasSelected()
1641
+ }), children));
1642
+ };
1643
+
1644
+ process.env.NODE_ENV !== "production" ? Clock.propTypes = {
1645
+ type: PropTypes.oneOf(Object.keys(ClockType$1).map(function (key) {
1646
+ return ClockType$1[key];
1647
+ })).isRequired,
1648
+ value: PropTypes.number.isRequired,
1649
+ onChange: PropTypes.func.isRequired,
1650
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
1651
+ ampm: PropTypes.bool,
1652
+ minutesStep: PropTypes.number,
1653
+ innerRef: PropTypes.any
1654
+ } : void 0;
1655
+ Clock.defaultProps = {
1656
+ ampm: false,
1657
+ minutesStep: 1
1658
+ };
1659
+ return Clock;
1660
+ }(React.Component);
1661
+ var styles$4 = function (theme) {
1662
+ return styles$5.createStyles({
1663
+ container: {
1664
+ display: 'flex',
1665
+ justifyContent: 'center',
1666
+ alignItems: 'flex-end',
1667
+ margin: theme.spacing(2) + "px 0 " + theme.spacing(1) + "px"
1668
+ },
1669
+ clock: {
1670
+ backgroundColor: 'rgba(0,0,0,.07)',
1671
+ borderRadius: '50%',
1672
+ height: 260,
1673
+ width: 260,
1674
+ position: 'relative',
1675
+ pointerEvents: 'none',
1676
+ zIndex: 1
1677
+ },
1678
+ squareMask: {
1679
+ width: '100%',
1680
+ height: '100%',
1681
+ position: 'absolute',
1682
+ pointerEvents: 'auto',
1683
+ outline: 'none',
1684
+ touchActions: 'none',
1685
+ userSelect: 'none',
1686
+ '&:active': {
1687
+ cursor: 'move'
1688
+ }
1689
+ },
1690
+ pin: {
1691
+ width: 6,
1692
+ height: 6,
1693
+ borderRadius: '50%',
1694
+ backgroundColor: theme.palette.primary.main,
1695
+ position: 'absolute',
1696
+ top: '50%',
1697
+ left: '50%',
1698
+ transform: 'translate(-50%, -50%)'
1699
+ }
1700
+ });
1701
+ };
1702
+ var Clock$1 = styles$5.withStyles(styles$4, {
1703
+ name: 'MuiPickersClock'
1704
+ })(Clock);
1705
+
1706
+ var positions = {
1707
+ 0: [0, 40],
1708
+ 1: [55, 19.6],
1709
+ 2: [94.4, 59.5],
1710
+ 3: [109, 114],
1711
+ 4: [94.4, 168.5],
1712
+ 5: [54.5, 208.4],
1713
+ 6: [0, 223],
1714
+ 7: [-54.5, 208.4],
1715
+ 8: [-94.4, 168.5],
1716
+ 9: [-109, 114],
1717
+ 10: [-94.4, 59.5],
1718
+ 11: [-54.5, 19.6],
1719
+ 12: [0, 5],
1720
+ 13: [36.9, 49.9],
1721
+ 14: [64, 77],
1722
+ 15: [74, 114],
1723
+ 16: [64, 151],
1724
+ 17: [37, 178],
1725
+ 18: [0, 188],
1726
+ 19: [-37, 178],
1727
+ 20: [-64, 151],
1728
+ 21: [-74, 114],
1729
+ 22: [-64, 77],
1730
+ 23: [-37, 50]
1731
+ };
1732
+ var useStyles$a = styles$5.makeStyles(function (theme) {
1733
+ var size = theme.spacing(4);
1734
+ return {
1735
+ clockNumber: {
1736
+ width: size,
1737
+ height: 32,
1738
+ userSelect: 'none',
1739
+ position: 'absolute',
1740
+ left: "calc(50% - " + size / 2 + "px)",
1741
+ display: 'inline-flex',
1742
+ justifyContent: 'center',
1743
+ alignItems: 'center',
1744
+ borderRadius: '50%',
1745
+ color: theme.palette.type === 'light' ? theme.palette.text.primary : theme.palette.text.hint
1746
+ },
1747
+ clockNumberSelected: {
1748
+ color: theme.palette.primary.contrastText
1749
+ }
1750
+ };
1751
+ }, {
1752
+ name: 'MuiPickersClockNumber'
1753
+ });
1754
+ var ClockNumber = function (_a) {
1755
+ var _b;
1756
+
1757
+ var selected = _a.selected,
1758
+ label = _a.label,
1759
+ index = _a.index,
1760
+ isInner = _a.isInner;
1761
+ var classes = useStyles$a();
1762
+ var className = clsx(classes.clockNumber, (_b = {}, _b[classes.clockNumberSelected] = selected, _b));
1763
+ var transformStyle = React.useMemo(function () {
1764
+ var position = positions[index];
1765
+ return {
1766
+ transform: "translate(" + position[0] + "px, " + position[1] + "px"
1767
+ };
1768
+ }, [index]);
1769
+ return React.createElement(Typography, {
1770
+ component: "span",
1771
+ className: className,
1772
+ variant: isInner ? 'body2' : 'body1',
1773
+ style: transformStyle,
1774
+ children: label
1775
+ });
1776
+ };
1777
+
1778
+ var getHourNumbers = function (_a) {
1779
+ var ampm = _a.ampm,
1780
+ utils = _a.utils,
1781
+ date = _a.date;
1782
+ var currentHours = utils.getHours(date);
1783
+ var hourNumbers = [];
1784
+ var startHour = ampm ? 1 : 0;
1785
+ var endHour = ampm ? 12 : 23;
1786
+
1787
+ var isSelected = function (hour) {
1788
+ if (ampm) {
1789
+ if (hour === 12) {
1790
+ return currentHours === 12 || currentHours === 0;
1791
+ }
1792
+
1793
+ return currentHours === hour || currentHours - 12 === hour;
1794
+ }
1795
+
1796
+ return currentHours === hour;
1797
+ };
1798
+
1799
+ for (var hour = startHour; hour <= endHour; hour += 1) {
1800
+ var label = hour.toString();
1801
+
1802
+ if (hour === 0) {
1803
+ label = '00';
1804
+ }
1805
+
1806
+ var props = {
1807
+ index: hour,
1808
+ label: utils.formatNumber(label),
1809
+ selected: isSelected(hour),
1810
+ isInner: !ampm && (hour === 0 || hour > 12)
1811
+ };
1812
+ hourNumbers.push(React.createElement(ClockNumber, tslib.__assign({
1813
+ key: hour
1814
+ }, props)));
1815
+ }
1816
+
1817
+ return hourNumbers;
1818
+ };
1819
+ var getMinutesNumbers = function (_a) {
1820
+ var value = _a.value,
1821
+ utils = _a.utils;
1822
+ var f = utils.formatNumber;
1823
+ return [React.createElement(ClockNumber, {
1824
+ label: f('00'),
1825
+ selected: value === 0,
1826
+ index: 12,
1827
+ key: 12
1828
+ }), React.createElement(ClockNumber, {
1829
+ label: f('05'),
1830
+ selected: value === 5,
1831
+ index: 1,
1832
+ key: 1
1833
+ }), React.createElement(ClockNumber, {
1834
+ label: f('10'),
1835
+ selected: value === 10,
1836
+ index: 2,
1837
+ key: 2
1838
+ }), React.createElement(ClockNumber, {
1839
+ label: f('15'),
1840
+ selected: value === 15,
1841
+ index: 3,
1842
+ key: 3
1843
+ }), React.createElement(ClockNumber, {
1844
+ label: f('20'),
1845
+ selected: value === 20,
1846
+ index: 4,
1847
+ key: 4
1848
+ }), React.createElement(ClockNumber, {
1849
+ label: f('25'),
1850
+ selected: value === 25,
1851
+ index: 5,
1852
+ key: 5
1853
+ }), React.createElement(ClockNumber, {
1854
+ label: f('30'),
1855
+ selected: value === 30,
1856
+ index: 6,
1857
+ key: 6
1858
+ }), React.createElement(ClockNumber, {
1859
+ label: f('35'),
1860
+ selected: value === 35,
1861
+ index: 7,
1862
+ key: 7
1863
+ }), React.createElement(ClockNumber, {
1864
+ label: f('40'),
1865
+ selected: value === 40,
1866
+ index: 8,
1867
+ key: 8
1868
+ }), React.createElement(ClockNumber, {
1869
+ label: f('45'),
1870
+ selected: value === 45,
1871
+ index: 9,
1872
+ key: 9
1873
+ }), React.createElement(ClockNumber, {
1874
+ label: f('50'),
1875
+ selected: value === 50,
1876
+ index: 10,
1877
+ key: 10
1878
+ }), React.createElement(ClockNumber, {
1879
+ label: f('55'),
1880
+ selected: value === 55,
1881
+ index: 11,
1882
+ key: 11
1883
+ })];
1884
+ };
1885
+
1886
+ var TimePickerView = function (_a) {
1887
+ var type = _a.type,
1888
+ onHourChange = _a.onHourChange,
1889
+ onMinutesChange = _a.onMinutesChange,
1890
+ onSecondsChange = _a.onSecondsChange,
1891
+ ampm = _a.ampm,
1892
+ date = _a.date,
1893
+ minutesStep = _a.minutesStep;
1894
+ var utils = useUtils();
1895
+ var viewProps = React.useMemo(function () {
1896
+ switch (type) {
1897
+ case ClockType$1.HOURS:
1898
+ return {
1899
+ value: utils.getHours(date),
1900
+ children: getHourNumbers({
1901
+ date: date,
1902
+ utils: utils,
1903
+ ampm: Boolean(ampm)
1904
+ }),
1905
+ onChange: function (value, isFinish) {
1906
+ var currentMeridiem = getMeridiem(date, utils);
1907
+ var updatedTimeWithMeridiem = convertToMeridiem(utils.setHours(date, value), currentMeridiem, Boolean(ampm), utils);
1908
+ onHourChange(updatedTimeWithMeridiem, isFinish);
1909
+ }
1910
+ };
1911
+
1912
+ case ClockType$1.MINUTES:
1913
+ var minutesValue = utils.getMinutes(date);
1914
+ return {
1915
+ value: minutesValue,
1916
+ children: getMinutesNumbers({
1917
+ value: minutesValue,
1918
+ utils: utils
1919
+ }),
1920
+ onChange: function (value, isFinish) {
1921
+ var updatedTime = utils.setMinutes(date, value);
1922
+ onMinutesChange(updatedTime, isFinish);
1923
+ }
1924
+ };
1925
+
1926
+ case ClockType$1.SECONDS:
1927
+ var secondsValue = utils.getSeconds(date);
1928
+ return {
1929
+ value: secondsValue,
1930
+ children: getMinutesNumbers({
1931
+ value: secondsValue,
1932
+ utils: utils
1933
+ }),
1934
+ onChange: function (value, isFinish) {
1935
+ var updatedTime = utils.setSeconds(date, value);
1936
+ onSecondsChange(updatedTime, isFinish);
1937
+ }
1938
+ };
1939
+
1940
+ default:
1941
+ throw new Error('You must provide the type for TimePickerView');
1942
+ }
1943
+ }, [ampm, date, onHourChange, onMinutesChange, onSecondsChange, type, utils]);
1944
+ return React.createElement(Clock$1, tslib.__assign({
1945
+ type: type,
1946
+ ampm: ampm,
1947
+ minutesStep: minutesStep
1948
+ }, viewProps));
1949
+ };
1950
+ TimePickerView.displayName = 'TimePickerView';
1951
+ process.env.NODE_ENV !== "production" ? TimePickerView.propTypes = {
1952
+ date: PropTypes.object.isRequired,
1953
+ onHourChange: PropTypes.func.isRequired,
1954
+ onMinutesChange: PropTypes.func.isRequired,
1955
+ onSecondsChange: PropTypes.func.isRequired,
1956
+ ampm: PropTypes.bool,
1957
+ minutesStep: PropTypes.number,
1958
+ type: PropTypes.oneOf(Object.keys(ClockType$1).map(function (key) {
1959
+ return ClockType$1[key];
1960
+ })).isRequired
1961
+ } : void 0;
1962
+ TimePickerView.defaultProps = {
1963
+ ampm: true,
1964
+ minutesStep: 1
1965
+ };
1966
+ var ClockView = React.memo(TimePickerView);
1967
+
1968
+ var useStyles$b = styles$5.makeStyles(function (theme) {
1969
+ return {
1970
+ root: {
1971
+ flex: '1 0 33.33%',
1972
+ display: 'flex',
1973
+ alignItems: 'center',
1974
+ justifyContent: 'center',
1975
+ cursor: 'pointer',
1976
+ outline: 'none',
1977
+ height: 75,
1978
+ transition: theme.transitions.create('font-size', {
1979
+ duration: '100ms'
1980
+ }),
1981
+ '&:focus': {
1982
+ color: theme.palette.primary.main,
1983
+ fontWeight: theme.typography.fontWeightMedium
1984
+ }
1985
+ },
1986
+ monthSelected: {
1987
+ color: theme.palette.primary.main,
1988
+ fontWeight: theme.typography.fontWeightMedium
1989
+ },
1990
+ monthDisabled: {
1991
+ pointerEvents: 'none',
1992
+ color: theme.palette.text.hint
1993
+ }
1994
+ };
1995
+ }, {
1996
+ name: 'MuiPickersMonth'
1997
+ });
1998
+ var Month = function (_a) {
1999
+ var _b;
2000
+
2001
+ var selected = _a.selected,
2002
+ onSelect = _a.onSelect,
2003
+ disabled = _a.disabled,
2004
+ value = _a.value,
2005
+ children = _a.children,
2006
+ other = tslib.__rest(_a, ["selected", "onSelect", "disabled", "value", "children"]);
2007
+
2008
+ var classes = useStyles$b();
2009
+ var handleSelection = React.useCallback(function () {
2010
+ onSelect(value);
2011
+ }, [onSelect, value]);
2012
+ return React.createElement(Typography, tslib.__assign({
2013
+ role: "button",
2014
+ component: "div",
2015
+ className: clsx(classes.root, (_b = {}, _b[classes.monthSelected] = selected, _b[classes.monthDisabled] = disabled, _b)),
2016
+ tabIndex: disabled ? -1 : 0,
2017
+ onClick: handleSelection,
2018
+ onKeyPress: handleSelection,
2019
+ color: selected ? 'primary' : undefined,
2020
+ variant: selected ? 'h5' : 'subtitle1',
2021
+ children: children
2022
+ }, other));
2023
+ };
2024
+ Month.displayName = 'Month';
2025
+
2026
+ var useStyles$c = styles$5.makeStyles({
2027
+ container: {
2028
+ width: 310,
2029
+ display: 'flex',
2030
+ flexWrap: 'wrap',
2031
+ alignContent: 'stretch'
2032
+ }
2033
+ }, {
2034
+ name: 'MuiPickersMonthSelection'
2035
+ });
2036
+ var MonthSelection = function (_a) {
2037
+ var disablePast = _a.disablePast,
2038
+ disableFuture = _a.disableFuture,
2039
+ minDate = _a.minDate,
2040
+ maxDate = _a.maxDate,
2041
+ date = _a.date,
2042
+ onMonthChange = _a.onMonthChange,
2043
+ onChange = _a.onChange;
2044
+ var utils = useUtils();
2045
+ var classes = useStyles$c();
2046
+ var currentMonth = utils.getMonth(date);
2047
+
2048
+ var shouldDisableMonth = function (month) {
2049
+ var now = utils.date();
2050
+ var utilMinDate = utils.date(minDate);
2051
+ var utilMaxDate = utils.date(maxDate);
2052
+ var firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, utilMinDate) ? now : utilMinDate);
2053
+ var lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, utilMaxDate) ? now : utilMaxDate);
2054
+ var isBeforeFirstEnabled = utils.isBefore(month, firstEnabledMonth);
2055
+ var isAfterLastEnabled = utils.isAfter(month, lastEnabledMonth);
2056
+ return isBeforeFirstEnabled || isAfterLastEnabled;
2057
+ };
2058
+
2059
+ var onMonthSelect = React.useCallback(function (month) {
2060
+ var newDate = utils.setMonth(date, month);
2061
+ onChange(newDate, true);
2062
+
2063
+ if (onMonthChange) {
2064
+ onMonthChange(newDate);
2065
+ }
2066
+ }, [date, onChange, onMonthChange, utils]);
2067
+ return React.createElement("div", {
2068
+ className: classes.container
2069
+ }, utils.getMonthArray(date).map(function (month) {
2070
+ var monthNumber = utils.getMonth(month);
2071
+ var monthText = utils.format(month, 'MMM');
2072
+ return React.createElement(Month, {
2073
+ key: monthText,
2074
+ value: monthNumber,
2075
+ selected: monthNumber === currentMonth,
2076
+ onSelect: onMonthSelect,
2077
+ disabled: shouldDisableMonth(month)
2078
+ }, monthText);
2079
+ }));
2080
+ };
2081
+
2082
+ var getOrientation = function () {
2083
+ return typeof window !== 'undefined' && window.screen && window.screen.orientation && Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
2084
+ };
2085
+
2086
+ function useIsLandscape(customOrientation) {
2087
+ var _a = React.useState(getOrientation()),
2088
+ orientation = _a[0],
2089
+ setOrientation = _a[1];
2090
+
2091
+ var eventHandler = React.useCallback(function () {
2092
+ return setOrientation(getOrientation());
2093
+ }, []);
2094
+ useIsomorphicEffect(function () {
2095
+ window.addEventListener('orientationchange', eventHandler);
2096
+ return function () {
2097
+ return window.removeEventListener('orientationchange', eventHandler);
2098
+ };
2099
+ }, [eventHandler]);
2100
+ var orientationToUse = customOrientation || orientation;
2101
+ return orientationToUse === 'landscape';
2102
+ }
2103
+
2104
+ var viewsMap = {
2105
+ year: YearSelection,
2106
+ month: MonthSelection,
2107
+ date: Calendar$1,
2108
+ hours: TimePickerView,
2109
+ minutes: TimePickerView,
2110
+ seconds: TimePickerView
2111
+ };
2112
+ var useStyles$d = styles$5.makeStyles({
2113
+ container: {
2114
+ display: 'flex',
2115
+ flexDirection: 'column'
2116
+ },
2117
+ containerLandscape: {
2118
+ flexDirection: 'row'
2119
+ },
2120
+ pickerView: {
2121
+ overflowX: 'hidden',
2122
+ minHeight: VIEW_HEIGHT,
2123
+ minWidth: DIALOG_WIDTH,
2124
+ maxWidth: DIALOG_WIDTH_WIDER,
2125
+ display: 'flex',
2126
+ flexDirection: 'column',
2127
+ justifyContent: 'center'
2128
+ },
2129
+ pickerViewLandscape: {
2130
+ padding: '0 8px'
2131
+ }
2132
+ }, {
2133
+ name: 'MuiPickersBasePicker'
2134
+ });
2135
+ var useButtonsStyles = styles$5.makeStyles({
2136
+ root: {
2137
+ minWidth: 32
2138
+ }
2139
+ }, {
2140
+ name: 'MuiButtonBase'
2141
+ });
2142
+ var useDialogActionsStyles = styles$5.makeStyles({
2143
+ withAdditionalAction: {}
2144
+ });
2145
+ var Picker = function (props) {
2146
+ var _a, _b, _c;
2147
+
2148
+ var date = props.date,
2149
+ ampm = props.ampm,
2150
+ views = props.views,
2151
+ disableToolbar = props.disableToolbar,
2152
+ disablePast = props.disablePast,
2153
+ disableFuture = props.disableFuture,
2154
+ hideTabs = props.hideTabs,
2155
+ onChange = props.onChange,
2156
+ openTo = props.openTo,
2157
+ minutesStep = props.minutesStep,
2158
+ dateRangeIcon = props.dateRangeIcon,
2159
+ timeIcon = props.timeIcon,
2160
+ unparsedMinDate = props.minDate,
2161
+ unparsedMaxDate = props.maxDate,
2162
+ animateYearScrolling = props.animateYearScrolling,
2163
+ leftArrowIcon = props.leftArrowIcon,
2164
+ rightArrowIcon = props.rightArrowIcon,
2165
+ renderDay = props.renderDay,
2166
+ shouldDisableDate = props.shouldDisableDate,
2167
+ allowKeyboardControl = props.allowKeyboardControl,
2168
+ onMonthChange = props.onMonthChange,
2169
+ onYearChange = props.onYearChange,
2170
+ leftArrowButtonProps = props.leftArrowButtonProps,
2171
+ rightArrowButtonProps = props.rightArrowButtonProps,
2172
+ ToolbarComponent = props.ToolbarComponent,
2173
+ loadingIndicator = props.loadingIndicator,
2174
+ orientation = props.orientation,
2175
+ showActionsBar = props.showActionsBar,
2176
+ onSetToday = props.onSetToday,
2177
+ showTodayButton = props.showTodayButton,
2178
+ todayLabel = props.todayLabel,
2179
+ onSetShift = props.onSetShift,
2180
+ showShiftButtons = props.showShiftButtons,
2181
+ setShiftFunction = props.setShiftFunction,
2182
+ shiftButtonValues = props.shiftButtonValues;
2183
+ var utils = useUtils();
2184
+ var classes = useStyles$d();
2185
+ var buttonClasses = useButtonsStyles();
2186
+ var dialogActionsClasses = useDialogActionsStyles();
2187
+ var isLandscape = useIsLandscape(orientation);
2188
+
2189
+ var _d = useViews(views, openTo, onChange),
2190
+ openView = _d.openView,
2191
+ setOpenView = _d.setOpenView,
2192
+ handleChangeAndOpenNext = _d.handleChangeAndOpenNext;
2193
+
2194
+ var minDate = React.useMemo(function () {
2195
+ return utils.date(unparsedMinDate);
2196
+ }, [unparsedMinDate, utils]);
2197
+ var maxDate = React.useMemo(function () {
2198
+ return utils.date(unparsedMaxDate);
2199
+ }, [unparsedMaxDate, utils]);
2200
+ var shiftButtons = new Array();
2201
+
2202
+ if (showShiftButtons && setShiftFunction && onSetShift && shiftButtonValues) {
2203
+ var _loop_1 = function (key) {
2204
+ shiftButtons.push(React.createElement(core.Button, {
2205
+ color: "primary",
2206
+ onClick: function () {
2207
+ return onSetShift(setShiftFunction(parseInt(key)));
2208
+ },
2209
+ key: shiftButtonValues[key]
2210
+ }, parseInt(key) > 0 ? '+' : '', shiftButtonValues[key]));
2211
+ };
2212
+
2213
+ for (var key in shiftButtonValues) {
2214
+ _loop_1(key);
2215
+ }
2216
+ }
2217
+
2218
+ return React.createElement("div", {
2219
+ className: clsx(classes.container, (_a = {}, _a[classes.containerLandscape] = isLandscape, _a))
2220
+ }, !disableToolbar && React.createElement(ToolbarComponent, tslib.__assign({
2221
+ date: date,
2222
+ onChange: onChange,
2223
+ setOpenView: setOpenView,
2224
+ openView: openView,
2225
+ hideTabs: hideTabs,
2226
+ dateRangeIcon: dateRangeIcon,
2227
+ timeIcon: timeIcon,
2228
+ isLandscape: isLandscape
2229
+ }, props)), React.createElement("div", {
2230
+ className: clsx(classes.pickerView, (_b = {}, _b[classes.pickerViewLandscape] = isLandscape, _b))
2231
+ }, openView === 'year' && React.createElement(YearSelection, {
2232
+ date: date,
2233
+ onChange: handleChangeAndOpenNext,
2234
+ minDate: minDate,
2235
+ maxDate: maxDate,
2236
+ disablePast: disablePast,
2237
+ disableFuture: disableFuture,
2238
+ onYearChange: onYearChange,
2239
+ animateYearScrolling: animateYearScrolling
2240
+ }), openView === 'month' && React.createElement(MonthSelection, {
2241
+ date: date,
2242
+ onChange: handleChangeAndOpenNext,
2243
+ minDate: minDate,
2244
+ maxDate: maxDate,
2245
+ disablePast: disablePast,
2246
+ disableFuture: disableFuture,
2247
+ onMonthChange: onMonthChange
2248
+ }), openView === 'date' && React.createElement(Calendar$1, {
2249
+ date: date,
2250
+ onChange: handleChangeAndOpenNext,
2251
+ onMonthChange: onMonthChange,
2252
+ disablePast: disablePast,
2253
+ disableFuture: disableFuture,
2254
+ minDate: minDate,
2255
+ maxDate: maxDate,
2256
+ leftArrowIcon: leftArrowIcon,
2257
+ leftArrowButtonProps: leftArrowButtonProps,
2258
+ rightArrowIcon: rightArrowIcon,
2259
+ rightArrowButtonProps: rightArrowButtonProps,
2260
+ renderDay: renderDay,
2261
+ shouldDisableDate: shouldDisableDate,
2262
+ allowKeyboardControl: allowKeyboardControl,
2263
+ loadingIndicator: loadingIndicator
2264
+ }), (openView === 'hours' || openView === 'minutes' || openView === 'seconds') && React.createElement(TimePickerView, {
2265
+ date: date,
2266
+ ampm: ampm,
2267
+ type: openView,
2268
+ minutesStep: minutesStep,
2269
+ onHourChange: handleChangeAndOpenNext,
2270
+ onMinutesChange: handleChangeAndOpenNext,
2271
+ onSecondsChange: handleChangeAndOpenNext
2272
+ })), showActionsBar && React.createElement(core.DialogActions, {
2273
+ classes: {
2274
+ root: clsx((_c = {}, _c[dialogActionsClasses.withAdditionalAction] = showTodayButton, _c))
2275
+ }
2276
+ }, showTodayButton && React.createElement(core.Button, {
2277
+ color: "primary",
2278
+ onClick: onSetToday,
2279
+ key: "today"
2280
+ }, todayLabel), showShiftButtons && setShiftFunction && shiftButtons));
2281
+ };
2282
+ Picker.defaultProps = tslib.__assign(tslib.__assign({}, datePickerDefaultProps), {
2283
+ views: Object.keys(viewsMap)
2284
+ });
2285
+
2286
+ function useOpenState(_a) {
2287
+ var _b;
2288
+
2289
+ var open = _a.open,
2290
+ onOpen = _a.onOpen,
2291
+ onClose = _a.onClose;
2292
+ var setIsOpenState = null;
2293
+
2294
+ if (open === undefined || open === null) {
2295
+ // The component is uncontrolled, so we need to give it its own state.
2296
+ _b = React.useState(false), open = _b[0], setIsOpenState = _b[1];
2297
+ } // prettier-ignore
2298
+
2299
+
2300
+ var setIsOpen = React.useCallback(function (newIsOpen) {
2301
+ setIsOpenState && setIsOpenState(newIsOpen);
2302
+ return newIsOpen ? onOpen && onOpen() : onClose && onClose();
2303
+ }, [onOpen, onClose, setIsOpenState]);
2304
+ return {
2305
+ isOpen: open,
2306
+ setIsOpen: setIsOpen
2307
+ };
2308
+ }
2309
+
2310
+ var getDisplayDate = function (value, format, utils, isEmpty, _a) {
2311
+ var invalidLabel = _a.invalidLabel,
2312
+ emptyLabel = _a.emptyLabel,
2313
+ labelFunc = _a.labelFunc;
2314
+ var date = utils.date(value);
2315
+
2316
+ if (labelFunc) {
2317
+ return labelFunc(isEmpty ? null : date, invalidLabel);
2318
+ }
2319
+
2320
+ if (isEmpty) {
2321
+ return emptyLabel || '';
2322
+ }
2323
+
2324
+ return utils.isValid(date) ? utils.format(date, format) : invalidLabel;
2325
+ };
2326
+
2327
+ var getComparisonMaxDate = function (utils, strictCompareDates, date) {
2328
+ if (strictCompareDates) {
2329
+ return date;
2330
+ }
2331
+
2332
+ return utils.endOfDay(date);
2333
+ };
2334
+
2335
+ var getComparisonMinDate = function (utils, strictCompareDates, date) {
2336
+ if (strictCompareDates) {
2337
+ return date;
2338
+ }
2339
+
2340
+ return utils.startOfDay(date);
2341
+ };
2342
+
2343
+ var validate = function (value, utils, _a // DateTimePicker doesn't support
2344
+ ) {
2345
+ var maxDate = _a.maxDate,
2346
+ minDate = _a.minDate,
2347
+ disablePast = _a.disablePast,
2348
+ disableFuture = _a.disableFuture,
2349
+ maxDateMessage = _a.maxDateMessage,
2350
+ minDateMessage = _a.minDateMessage,
2351
+ invalidDateMessage = _a.invalidDateMessage,
2352
+ strictCompareDates = _a.strictCompareDates;
2353
+ var parsedValue = utils.date(value); // if null - do not show error
2354
+
2355
+ if (value === null) {
2356
+ return '';
2357
+ }
2358
+
2359
+ if (!utils.isValid(value)) {
2360
+ return invalidDateMessage;
2361
+ }
2362
+
2363
+ if (maxDate && utils.isAfter(parsedValue, getComparisonMaxDate(utils, !!strictCompareDates, utils.date(maxDate)))) {
2364
+ return maxDateMessage;
2365
+ }
2366
+
2367
+ if (disableFuture && utils.isAfter(parsedValue, getComparisonMaxDate(utils, !!strictCompareDates, utils.date()))) {
2368
+ return maxDateMessage;
2369
+ }
2370
+
2371
+ if (minDate && utils.isBefore(parsedValue, getComparisonMinDate(utils, !!strictCompareDates, utils.date(minDate)))) {
2372
+ return minDateMessage;
2373
+ }
2374
+
2375
+ if (disablePast && utils.isBefore(parsedValue, getComparisonMinDate(utils, !!strictCompareDates, utils.date()))) {
2376
+ return minDateMessage;
2377
+ }
2378
+
2379
+ return '';
2380
+ };
2381
+ function pick12hOr24hFormat(userFormat, ampm, formats) {
2382
+ if (ampm === void 0) {
2383
+ ampm = true;
2384
+ }
2385
+
2386
+ if (userFormat) {
2387
+ return userFormat;
2388
+ }
2389
+
2390
+ return ampm ? formats['12h'] : formats['24h'];
2391
+ }
2392
+ function makeMaskFromFormat(format, numberMaskChar) {
2393
+ return format.replace(/[a-z]/gi, numberMaskChar);
2394
+ }
2395
+ var maskedDateFormatter = function (mask, numberMaskChar) {
2396
+ return function (value, oldValue, currentCaretPosition) {
2397
+ var refuse = /[^\d\w_]+/gi;
2398
+
2399
+ if (!value || value === '') {
2400
+ return value;
2401
+ }
2402
+
2403
+ if (!oldValue) {
2404
+ oldValue = '';
2405
+ }
2406
+
2407
+ if (value == oldValue) {
2408
+ return value;
2409
+ }
2410
+
2411
+ if (value.length < oldValue.length && currentCaretPosition != null) {
2412
+ value = value.slice(0, currentCaretPosition) + '_' + value.slice(currentCaretPosition, oldValue.length);
2413
+ }
2414
+
2415
+ var refusedOldValue = oldValue.replace(refuse, '');
2416
+ var refusedNewValue = value.replace(refuse, '');
2417
+ var refusedMaskSymbols = mask.replace(refuse, '');
2418
+ var minLength = refusedOldValue.length > refusedNewValue.length ? refusedNewValue.length : refusedOldValue.length;
2419
+ var startPos = 0;
2420
+ var endPosShift = 0;
2421
+
2422
+ while (startPos < minLength) {
2423
+ if (refusedNewValue[startPos] == refusedOldValue[startPos]) {
2424
+ startPos++;
2425
+ } else {
2426
+ break;
2427
+ }
2428
+ }
2429
+
2430
+ while (endPosShift < minLength && startPos < refusedNewValue.length - endPosShift && startPos < refusedOldValue.length - endPosShift) {
2431
+ if (refusedNewValue[refusedNewValue.length - endPosShift - 1] == refusedOldValue[refusedOldValue.length - endPosShift - 1]) {
2432
+ endPosShift++;
2433
+ } else {
2434
+ break;
2435
+ }
2436
+ }
2437
+
2438
+ var endStartPos = refusedNewValue.length - endPosShift;
2439
+ endStartPos = endStartPos < startPos ? startPos : endStartPos;
2440
+ var firstPart = refusedNewValue.slice(0, startPos);
2441
+ var addedPart = refusedNewValue.slice(startPos, endStartPos);
2442
+ var endPart = refusedNewValue.slice(endStartPos, refusedNewValue.length);
2443
+ var maxSymbolsInEnd = refusedMaskSymbols.length - firstPart.length - addedPart.length;
2444
+
2445
+ while (maxSymbolsInEnd > endPart.length) {
2446
+ addedPart += numberMaskChar;
2447
+ maxSymbolsInEnd--;
2448
+ }
2449
+
2450
+ var entireRefusedString = firstPart + addedPart + endPart.slice(endPart.length - maxSymbolsInEnd, endPart.length); // Do nothing ?...
2451
+
2452
+ entireRefusedString = entireRefusedString.slice(0, refusedMaskSymbols.length);
2453
+ var i = 0;
2454
+ var n = 0;
2455
+ var result = '';
2456
+
2457
+ while (i < mask.length) {
2458
+ var maskChar = mask[i];
2459
+
2460
+ if (maskChar === numberMaskChar && n < entireRefusedString.length) {
2461
+ var parsedChar = entireRefusedString[n];
2462
+ result += parsedChar;
2463
+ n += 1;
2464
+ } else {
2465
+ result += maskChar;
2466
+ }
2467
+
2468
+ i += 1;
2469
+ }
2470
+
2471
+ return result;
2472
+ };
2473
+ };
2474
+
2475
+ var useValueToDate = function (utils, _a) {
2476
+ var value = _a.value,
2477
+ initialFocusedDate = _a.initialFocusedDate;
2478
+ var nowRef = React.useRef(utils.date());
2479
+ var date = utils.date(value || initialFocusedDate || nowRef.current);
2480
+ return date && utils.isValid(date) ? date : nowRef.current;
2481
+ };
2482
+
2483
+ function useDateValues(props, options) {
2484
+ var utils = useUtils();
2485
+ var date = useValueToDate(utils, props);
2486
+ var format = props.format || options.getDefaultFormat();
2487
+ return {
2488
+ date: date,
2489
+ format: format
2490
+ };
2491
+ }
2492
+
2493
+ function usePickerState(props, options) {
2494
+ var autoOk = props.autoOk,
2495
+ disabled = props.disabled,
2496
+ onAccept = props.onAccept,
2497
+ onChange = props.onChange,
2498
+ onError = props.onError,
2499
+ value = props.value,
2500
+ variant = props.variant;
2501
+ var utils = useUtils();
2502
+
2503
+ var _a = useOpenState(props),
2504
+ isOpen = _a.isOpen,
2505
+ setIsOpen = _a.setIsOpen;
2506
+
2507
+ var _b = useDateValues(props, options),
2508
+ date = _b.date,
2509
+ format = _b.format;
2510
+
2511
+ var _c = React.useState(date),
2512
+ pickerDate = _c[0],
2513
+ setPickerDate = _c[1];
2514
+
2515
+ React.useEffect(function () {
2516
+ // if value was changed in closed state - treat it as accepted
2517
+ if (!isOpen && !utils.isEqual(pickerDate, date)) {
2518
+ setPickerDate(date);
2519
+ }
2520
+ }, [date, isOpen, pickerDate, utils]);
2521
+ var acceptDate = React.useCallback(function (acceptedDate) {
2522
+ setIsOpen(false);
2523
+ onChange(acceptedDate);
2524
+
2525
+ if (onAccept) {
2526
+ onAccept(acceptedDate);
2527
+ }
2528
+ }, [onAccept, onChange, setIsOpen]);
2529
+ var wrapperProps = React.useMemo(function () {
2530
+ return {
2531
+ format: format,
2532
+ open: isOpen,
2533
+ onClear: function () {
2534
+ return acceptDate(null);
2535
+ },
2536
+ onAccept: function () {
2537
+ return acceptDate(pickerDate);
2538
+ },
2539
+ onSetToday: function () {
2540
+ return setPickerDate(utils.date());
2541
+ },
2542
+ onDismiss: function () {
2543
+ setIsOpen(false);
2544
+ }
2545
+ };
2546
+ }, [acceptDate, format, isOpen, pickerDate, setIsOpen, utils]);
2547
+ var pickerProps = React.useMemo(function () {
2548
+ return {
2549
+ date: pickerDate,
2550
+ onChange: function (newDate, isFinish) {
2551
+ if (isFinish === void 0) {
2552
+ isFinish = true;
2553
+ }
2554
+
2555
+ setPickerDate(newDate);
2556
+
2557
+ if (isFinish && autoOk) {
2558
+ acceptDate(newDate);
2559
+ } else if (variant === 'inline' || variant === 'static') {
2560
+ onChange(newDate);
2561
+ }
2562
+ },
2563
+ onSetToday: function () {
2564
+ var newDate = utils.date();
2565
+ setPickerDate(newDate);
2566
+
2567
+ if (autoOk) {
2568
+ acceptDate(newDate);
2569
+ } else if (variant === 'inline' || variant === 'static') {
2570
+ onChange(newDate);
2571
+ }
2572
+ },
2573
+ onSetShift: function (shiftDate) {
2574
+ var newDate = utils.date(shiftDate);
2575
+
2576
+ if (autoOk) {
2577
+ acceptDate(newDate);
2578
+ } else if (variant === 'inline' || variant === 'static') {
2579
+ onChange(newDate);
2580
+ }
2581
+ }
2582
+ };
2583
+ }, [acceptDate, autoOk, onChange, pickerDate, variant]);
2584
+ var validationError = validate(value, utils, props);
2585
+ React.useEffect(function () {
2586
+ if (validationError && onError) {
2587
+ onError(validationError, value);
2588
+ }
2589
+ }, [onError, validationError, value]);
2590
+ var inputValue = getDisplayDate(date, format, utils, value === null, props);
2591
+ var inputProps = React.useMemo(function () {
2592
+ return {
2593
+ inputValue: inputValue,
2594
+ validationError: validationError,
2595
+ onClick: function () {
2596
+ return !disabled && setIsOpen(true);
2597
+ }
2598
+ };
2599
+ }, [disabled, inputValue, setIsOpen, validationError]);
2600
+ var pickerState = {
2601
+ pickerProps: pickerProps,
2602
+ inputProps: inputProps,
2603
+ wrapperProps: wrapperProps
2604
+ };
2605
+ React.useDebugValue(pickerState);
2606
+ return pickerState;
2607
+ }
2608
+
2609
+ var PureDateInput = function (_a) {
2610
+ var inputValue = _a.inputValue,
2611
+ inputVariant = _a.inputVariant,
2612
+ validationError = _a.validationError,
2613
+ InputProps = _a.InputProps,
2614
+ _b = _a.TextFieldComponent,
2615
+ TextFieldComponent = _b === void 0 ? TextField : _b,
2616
+ other = tslib.__rest(_a, ["inputValue", "inputVariant", "validationError", "InputProps", "TextFieldComponent"]);
2617
+
2618
+ var PureDateInputProps = React.useMemo(function () {
2619
+ return tslib.__assign(tslib.__assign({}, InputProps), {
2620
+ readOnly: true
2621
+ });
2622
+ }, [InputProps]);
2623
+ return React.createElement(TextFieldComponent, tslib.__assign({
2624
+ error: Boolean(validationError),
2625
+ helperText: validationError
2626
+ }, other, {
2627
+ // do not overridable
2628
+ value: inputValue,
2629
+ variant: inputVariant,
2630
+ InputProps: PureDateInputProps
2631
+ }));
2632
+ };
2633
+ PureDateInput.displayName = 'PureDateInput';
2634
+
2635
+ function makePurePicker(_a) {
2636
+ var useOptions = _a.useOptions,
2637
+ getCustomProps = _a.getCustomProps,
2638
+ DefaultToolbarComponent = _a.DefaultToolbarComponent;
2639
+
2640
+ function WrappedPurePicker(props) {
2641
+ var allowKeyboardControl = props.allowKeyboardControl,
2642
+ ampm = props.ampm,
2643
+ hideTabs = props.hideTabs,
2644
+ animateYearScrolling = props.animateYearScrolling,
2645
+ autoOk = props.autoOk,
2646
+ disableFuture = props.disableFuture,
2647
+ disablePast = props.disablePast,
2648
+ format = props.format,
2649
+ forwardedRef = props.forwardedRef,
2650
+ initialFocusedDate = props.initialFocusedDate,
2651
+ invalidDateMessage = props.invalidDateMessage,
2652
+ labelFunc = props.labelFunc,
2653
+ leftArrowIcon = props.leftArrowIcon,
2654
+ leftArrowButtonProps = props.leftArrowButtonProps,
2655
+ maxDate = props.maxDate,
2656
+ maxDateMessage = props.maxDateMessage,
2657
+ minDate = props.minDate,
2658
+ onOpen = props.onOpen,
2659
+ onClose = props.onClose,
2660
+ minDateMessage = props.minDateMessage,
2661
+ strictCompareDates = props.strictCompareDates,
2662
+ minutesStep = props.minutesStep,
2663
+ onAccept = props.onAccept,
2664
+ onChange = props.onChange,
2665
+ onMonthChange = props.onMonthChange,
2666
+ onYearChange = props.onYearChange,
2667
+ renderDay = props.renderDay,
2668
+ views = props.views,
2669
+ openTo = props.openTo,
2670
+ rightArrowIcon = props.rightArrowIcon,
2671
+ rightArrowButtonProps = props.rightArrowButtonProps,
2672
+ shouldDisableDate = props.shouldDisableDate,
2673
+ dateRangeIcon = props.dateRangeIcon,
2674
+ emptyLabel = props.emptyLabel,
2675
+ invalidLabel = props.invalidLabel,
2676
+ timeIcon = props.timeIcon,
2677
+ value = props.value,
2678
+ variant = props.variant,
2679
+ orientation = props.orientation,
2680
+ disableToolbar = props.disableToolbar,
2681
+ loadingIndicator = props.loadingIndicator,
2682
+ _a = props.ToolbarComponent,
2683
+ ToolbarComponent = _a === void 0 ? DefaultToolbarComponent : _a,
2684
+ showActionsBar = props.showActionsBar,
2685
+ showTodayButton = props.showTodayButton,
2686
+ todayLabel = props.todayLabel,
2687
+ showShiftButtons = props.showShiftButtons,
2688
+ setShiftFunction = props.setShiftFunction,
2689
+ shiftButtonValues = props.shiftButtonValues,
2690
+ other = tslib.__rest(props, ["allowKeyboardControl", "ampm", "hideTabs", "animateYearScrolling", "autoOk", "disableFuture", "disablePast", "format", "forwardedRef", "initialFocusedDate", "invalidDateMessage", "labelFunc", "leftArrowIcon", "leftArrowButtonProps", "maxDate", "maxDateMessage", "minDate", "onOpen", "onClose", "minDateMessage", "strictCompareDates", "minutesStep", "onAccept", "onChange", "onMonthChange", "onYearChange", "renderDay", "views", "openTo", "rightArrowIcon", "rightArrowButtonProps", "shouldDisableDate", "dateRangeIcon", "emptyLabel", "invalidLabel", "timeIcon", "value", "variant", "orientation", "disableToolbar", "loadingIndicator", "ToolbarComponent", "showActionsBar", "showTodayButton", "todayLabel", "showShiftButtons", "setShiftFunction", "shiftButtonValues"]);
2691
+
2692
+ var injectedProps = getCustomProps ? getCustomProps(props) : {};
2693
+ var options = useOptions(props);
2694
+
2695
+ var _b = usePickerState(props, options),
2696
+ pickerProps = _b.pickerProps,
2697
+ inputProps = _b.inputProps,
2698
+ wrapperProps = _b.wrapperProps;
2699
+
2700
+ return React.createElement(Wrapper, tslib.__assign({
2701
+ variant: variant,
2702
+ InputComponent: PureDateInput,
2703
+ DateInputProps: inputProps,
2704
+ showTodayButton: showTodayButton,
2705
+ todayLabel: todayLabel
2706
+ }, wrapperProps, injectedProps, other), React.createElement(Picker, tslib.__assign({}, pickerProps, {
2707
+ orientation: orientation,
2708
+ disableToolbar: disableToolbar,
2709
+ ToolbarComponent: ToolbarComponent,
2710
+ hideTabs: hideTabs,
2711
+ ampm: ampm,
2712
+ views: views,
2713
+ openTo: openTo,
2714
+ allowKeyboardControl: allowKeyboardControl,
2715
+ minutesStep: minutesStep,
2716
+ animateYearScrolling: animateYearScrolling,
2717
+ disableFuture: disableFuture,
2718
+ disablePast: disablePast,
2719
+ leftArrowIcon: leftArrowIcon,
2720
+ leftArrowButtonProps: leftArrowButtonProps,
2721
+ maxDate: maxDate,
2722
+ minDate: minDate,
2723
+ strictCompareDates: strictCompareDates,
2724
+ onMonthChange: onMonthChange,
2725
+ onYearChange: onYearChange,
2726
+ renderDay: renderDay,
2727
+ dateRangeIcon: dateRangeIcon,
2728
+ timeIcon: timeIcon,
2729
+ rightArrowIcon: rightArrowIcon,
2730
+ rightArrowButtonProps: rightArrowButtonProps,
2731
+ shouldDisableDate: shouldDisableDate,
2732
+ loadingIndicator: loadingIndicator,
2733
+ showActionsBar: showActionsBar,
2734
+ showTodayButton: showTodayButton,
2735
+ todayLabel: todayLabel,
2736
+ showShiftButtons: showShiftButtons,
2737
+ setShiftFunction: setShiftFunction,
2738
+ shiftButtonValues: shiftButtonValues
2739
+ })));
2740
+ }
2741
+
2742
+ return WrappedPurePicker;
2743
+ }
2744
+
2745
+ var KeyboardIcon = function (props) {
2746
+ return React__default.createElement(SvgIcon, tslib.__assign({}, props), React__default.createElement("path", {
2747
+ d: "M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"
2748
+ }), React__default.createElement("path", {
2749
+ fill: "none",
2750
+ d: "M0 0h24v24H0z"
2751
+ }));
2752
+ };
2753
+
2754
+ var Rifm = function (props) {
2755
+ var _a = React.useReducer(function (c) {
2756
+ return c + 1;
2757
+ }, 0),
2758
+ refresh = _a[1];
2759
+
2760
+ var valueRef = React.useRef(null);
2761
+ var replace = props.replace,
2762
+ maskChar = props.maskChar;
2763
+
2764
+ var _b = React.useState({
2765
+ value: ''
2766
+ }),
2767
+ previousValue = _b[0],
2768
+ setPreviousValue = _b[1];
2769
+
2770
+ var userValue = replace ? replace(props.format(props.value, previousValue.value)) : props.format(props.value, previousValue.value);
2771
+ var currentPreviousValue = previousValue.value; // state of delete button see comments below about inputType support
2772
+
2773
+ var isDeleleteButtonDownRef = React.useRef(false);
2774
+
2775
+ var onChange = function (evt) {
2776
+ var eventValue = evt.target.value;
2777
+ var selectionStart = evt.target.selectionStart;
2778
+ valueRef.current = [eventValue, evt.target, eventValue.length > userValue.length, isDeleleteButtonDownRef.current, selectionStart, userValue === props.format(eventValue, currentPreviousValue, selectionStart), props.value]; // The main trick is to update underlying input with non formatted value (= eventValue)
2779
+ // that allows us to calculate right cursor position after formatting (see getCursorPosition)
2780
+ // then we format new value and call props.onChange with masked/formatted value
2781
+ // and finally we are able to set cursor position into right place
2782
+
2783
+ refresh(null);
2784
+ }; // React prints warn on server in non production mode about useLayoutEffect usage
2785
+ // in both cases it's noop
2786
+
2787
+
2788
+ if (typeof window !== 'undefined') {
2789
+ React.useLayoutEffect(function () {
2790
+ if (valueRef.current == null) return;
2791
+ var _a = valueRef.current,
2792
+ eventValue = _a[0],
2793
+ input = _a[1],
2794
+ isSizeIncreaseOperation = _a[2],
2795
+ isDeleleteButtonDown = _a[3],
2796
+ selectionStart = _a[4],
2797
+ // No operation means that value itself hasn't been changed, BTW cursor, selection etc can be changed
2798
+ isNoOperation = _a[5],
2799
+ valueAtChange = _a[6];
2800
+ valueRef.current = null; // A calendar selection can replace the controlled value in the same React batch as an
2801
+ // input event from the mask. In that case the event describes an obsolete value and must
2802
+ // not overwrite the date selected in the calendar.
2803
+
2804
+ if (props.value !== valueAtChange) {
2805
+ refresh(null);
2806
+ return;
2807
+ } // this usually occurs on deleting special symbols like ' here 123'123.00
2808
+ // in case of isDeleleteButtonDown cursor should move differently vs backspace
2809
+
2810
+
2811
+ var deleteWasNoOp = isDeleleteButtonDown && isNoOperation; // Create string from only accepted symbols
2812
+
2813
+ var clean = function (str) {
2814
+ return (str.match(props.accept || /\d|\w/g) || []).join('');
2815
+ };
2816
+
2817
+ var valueBeforeSelectionStart = clean(eventValue.substr(0, input.selectionStart)); // trying to find cursor position in formatted value having knowledge about valueBeforeSelectionStart
2818
+ // This works because we assume that format doesn't change the order of accepted symbols.
2819
+ // Imagine we have formatter which adds ' symbol between numbers, and by default we refuse all non numeric symbols
2820
+ // for example we had input = 1'2|'4 (| means cursor position) then user entered '3' symbol
2821
+ // inputValue = 1'23'|4 so valueBeforeSelectionStart = 123 and formatted value = 1'2'3'4
2822
+ // calling getCursorPosition("1'2'3'4") will give us position after 3, 1'2'3|'4
2823
+ // so for formatting just this function to determine cursor position after formatting is enough
2824
+ // with masking we need to do some additional checks see `mask` below
2825
+
2826
+ var getCursorPosition = function (val) {
2827
+ var start = 0;
2828
+ var cleanPos = 0;
2829
+
2830
+ for (var i = 0; i !== valueBeforeSelectionStart.length; ++i) {
2831
+ var newPos = val.indexOf(valueBeforeSelectionStart[i], start) + 1;
2832
+ var newCleanPos = clean(val).indexOf(valueBeforeSelectionStart[i], cleanPos) + 1; // this skips position change if accepted symbols order was broken
2833
+ // For example fixes edge case with fixed point numbers:
2834
+ // You have '0|.00', then press 1, it becomes 01|.00 and after format 1.00, this breaks our assumption
2835
+ // that order of accepted symbols is not changed after format,
2836
+ // so here we don't update start position if other accepted symbols was inbetween current and new position
2837
+
2838
+ if (newCleanPos - cleanPos > 1) {
2839
+ newPos = start;
2840
+ newCleanPos = cleanPos;
2841
+ }
2842
+
2843
+ cleanPos = Math.max(newCleanPos, cleanPos);
2844
+ start = Math.max(start, newPos);
2845
+ }
2846
+
2847
+ return start;
2848
+ }; //let start = getCursorPosition(eventValue);
2849
+ // // Masking part, for masks if size of mask is above some value
2850
+ // // we need to replace symbols instead of do nothing as like in format
2851
+ // if (props.mask === true && isSizeIncreaseOperation && !isNoOperation) {
2852
+ // const c = clean(eventValue.substr(start))[0];
2853
+ // start = eventValue.indexOf(c, start);
2854
+ // eventValue = `${eventValue.substr(0, start)}${eventValue.substr(
2855
+ // start + 1
2856
+ // )}`;
2857
+ // }
2858
+
2859
+
2860
+ var formattedValue = props.format(eventValue, currentPreviousValue, selectionStart);
2861
+ var replacedValue = replace ? replace(formattedValue) : formattedValue;
2862
+ var start = getCursorPosition(formattedValue);
2863
+ var inputCharPosition = start - 1;
2864
+
2865
+ if (inputCharPosition > -1) {
2866
+ if (props.letterPosition && props.letterPosition > -1 && replacedValue[inputCharPosition].match(/[a-zA-Z]/) && (inputCharPosition < props.letterPosition || inputCharPosition > props.letterPosition + 1)) {
2867
+ replacedValue = currentPreviousValue;
2868
+ } else if (props.letterPosition && props.letterPosition > -1 && replacedValue[inputCharPosition].match(/\d/) && inputCharPosition >= props.letterPosition && inputCharPosition <= props.letterPosition + 1) {
2869
+ replacedValue = currentPreviousValue;
2870
+ }
2871
+ }
2872
+
2873
+ if (userValue === replacedValue) {
2874
+ // if nothing changed for formatted value, just refresh so userValue will be used at render
2875
+ refresh(null);
2876
+ } else {
2877
+ props.onChange(replacedValue);
2878
+ }
2879
+
2880
+ return function () {
2881
+ // Visually improves working with masked values,
2882
+ // like cursor jumping over refused symbols
2883
+ // as an example date mask: was "5|1-24-3" then user pressed "6"
2884
+ // it becomes "56-|12-43" with this code, and "56|-12-43" without
2885
+ if (props.mask != null && (isSizeIncreaseOperation || isDeleleteButtonDown && !deleteWasNoOp)) {
2886
+ while (formattedValue[start] && clean(formattedValue[start]) === '' && formattedValue[start] != maskChar) {
2887
+ start += 1;
2888
+ }
2889
+ } //input.selectionStart = input.selectionEnd = start + (deleteWasNoOp ? 1 : 0);
2890
+
2891
+ };
2892
+ });
2893
+ }
2894
+
2895
+ React.useEffect(function () {
2896
+ // until https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/inputType will be supported
2897
+ // by all major browsers (now supported by: +chrome, +safari, ?edge, !firefox)
2898
+ // there is no way I found to distinguish in onChange
2899
+ // backspace or delete was called in some situations
2900
+ // firefox track https://bugzilla.mozilla.org/show_bug.cgi?id=1447239
2901
+ var handleKeyDown = function (evt) {
2902
+ if (evt.code === 'Delete') {
2903
+ isDeleleteButtonDownRef.current = true;
2904
+ }
2905
+ };
2906
+
2907
+ var handleKeyUp = function (evt) {
2908
+ if (evt.code === 'Delete') {
2909
+ isDeleleteButtonDownRef.current = false;
2910
+ }
2911
+ };
2912
+
2913
+ document.addEventListener('keydown', handleKeyDown);
2914
+ document.addEventListener('keyup', handleKeyUp);
2915
+ return function () {
2916
+ document.removeEventListener('keydown', handleKeyDown);
2917
+ document.removeEventListener('keyup', handleKeyUp);
2918
+ };
2919
+ }, []);
2920
+ var value = valueRef.current != null ? valueRef.current[0] : userValue; // value = props.format(value, currentPreviousValue);
2921
+
2922
+ previousValue.value = value;
2923
+ return props.children({
2924
+ value: value,
2925
+ onChange: onChange
2926
+ });
2927
+ };
2928
+
2929
+ var KeyboardDateInput = function (_a) {
2930
+ var inputValue = _a.inputValue,
2931
+ _b = _a.showErrorOnBlur,
2932
+ showErrorOnBlur = _b === void 0 ? false : _b,
2933
+ inputVariant = _a.inputVariant,
2934
+ validationError = _a.validationError,
2935
+ KeyboardButtonProps = _a.KeyboardButtonProps,
2936
+ InputAdornmentProps = _a.InputAdornmentProps,
2937
+ onClick = _a.onClick,
2938
+ onChange = _a.onChange,
2939
+ onBlur = _a.onBlur,
2940
+ onFocus = _a.onFocus,
2941
+ InputProps = _a.InputProps,
2942
+ mask = _a.mask,
2943
+ _c = _a.maskChar,
2944
+ maskChar = _c === void 0 ? '_' : _c,
2945
+ _d = _a.refuse,
2946
+ format = _a.format,
2947
+ keyboardIcon = _a.keyboardIcon,
2948
+ disabled = _a.disabled,
2949
+ rifmFormatter = _a.rifmFormatter,
2950
+ _e = _a.TextFieldComponent,
2951
+ TextFieldComponent = _e === void 0 ? TextField : _e,
2952
+ other = tslib.__rest(_a, ["inputValue", "showErrorOnBlur", "inputVariant", "validationError", "KeyboardButtonProps", "InputAdornmentProps", "onClick", "onChange", "onBlur", "onFocus", "InputProps", "mask", "maskChar", "refuse", "format", "keyboardIcon", "disabled", "rifmFormatter", "TextFieldComponent"]);
2953
+
2954
+ var inputMask = mask || makeMaskFromFormat(format, maskChar);
2955
+ var letterPosition = format.indexOf('a'); // prettier-ignore
2956
+
2957
+ var formatter = React.useCallback(maskedDateFormatter(inputMask, maskChar), [mask, maskChar]);
2958
+ var position = InputAdornmentProps && InputAdornmentProps.position ? InputAdornmentProps.position : 'end';
2959
+
2960
+ var handleChange = function (text) {
2961
+ var finalString = text === '' || text === inputMask ? null : text;
2962
+ onChange(finalString);
2963
+ };
2964
+
2965
+ var replace = function (text) {
2966
+ return text;
2967
+ };
2968
+
2969
+ var _f = React.useState(showErrorOnBlur ? true : false),
2970
+ showErrorFlag = _f[0],
2971
+ handleBlur = _f[1];
2972
+
2973
+ return React.createElement(Rifm, {
2974
+ value: inputValue,
2975
+ onChange: handleChange,
2976
+ format: rifmFormatter || formatter,
2977
+ replace: replace,
2978
+ mask: true,
2979
+ maskChar: maskChar,
2980
+ letterPosition: letterPosition
2981
+ }, function (_a) {
2982
+ var _b;
2983
+
2984
+ var onChange = _a.onChange,
2985
+ value = _a.value;
2986
+ return React.createElement(TextFieldComponent, tslib.__assign({
2987
+ disabled: disabled,
2988
+ error: Boolean(validationError) && !showErrorFlag,
2989
+ helperText: !showErrorFlag && validationError
2990
+ }, other, {
2991
+ value: value,
2992
+ onChange: onChange,
2993
+ // onInput={changeInputStringValue}
2994
+ // onKeyUp={handleKeyUp}
2995
+ // onMouseUp={handleClick}
2996
+ onBlur: function () {
2997
+ if (onBlur) {
2998
+ onBlur();
2999
+ }
3000
+
3001
+ if (showErrorOnBlur) {
3002
+ handleBlur(false);
3003
+ }
3004
+ },
3005
+ onFocus: function (ev) {
3006
+ if (onFocus) {
3007
+ onFocus(ev);
3008
+ }
3009
+
3010
+ if (showErrorOnBlur) {
3011
+ handleBlur(true);
3012
+ }
3013
+ },
3014
+ variant: inputVariant,
3015
+ InputProps: tslib.__assign(tslib.__assign({}, InputProps), (_b = {}, _b[position + "Adornment"] = React.createElement(InputAdornment, tslib.__assign({
3016
+ position: position
3017
+ }, InputAdornmentProps), React.createElement(core.IconButton, tslib.__assign({
3018
+ disabled: disabled
3019
+ }, KeyboardButtonProps, {
3020
+ onClick: onClick
3021
+ }), keyboardIcon)), _b))
3022
+ }));
3023
+ });
3024
+ };
3025
+
3026
+ KeyboardDateInput.defaultProps = {
3027
+ keyboardIcon: React.createElement(KeyboardIcon, null)
3028
+ };
3029
+
3030
+ function parseInputString(value, utils, format) {
3031
+ try {
3032
+ return utils.parse(value, format);
3033
+ } catch (_a) {
3034
+ return null;
3035
+ }
3036
+ }
3037
+
3038
+ function useKeyboardPickerState(props, options) {
3039
+ var _a = props.format,
3040
+ format = _a === void 0 ? options.getDefaultFormat() : _a,
3041
+ inputValue = props.inputValue,
3042
+ onChange = props.onChange,
3043
+ value = props.value;
3044
+ var utils = useUtils();
3045
+ var displayDate = getDisplayDate(value, format, utils, value === null, props);
3046
+
3047
+ var _b = React.useState(displayDate),
3048
+ innerInputValue = _b[0],
3049
+ setInnerInputValue = _b[1];
3050
+
3051
+ var dateValue = inputValue ? parseInputString(inputValue, utils, format) : value;
3052
+ React.useEffect(function () {
3053
+ if (value === null || utils.isValid(value)) {
3054
+ setInnerInputValue(displayDate);
3055
+ }
3056
+ }, [displayDate, setInnerInputValue, utils, value]);
3057
+ var handleKeyboardChange = React.useCallback(function (date) {
3058
+ var formattedValue = date === null ? null : utils.format(date, format);
3059
+ setInnerInputValue(formattedValue || '');
3060
+ onChange(date, formattedValue);
3061
+ }, [format, onChange, utils]);
3062
+
3063
+ var _c = usePickerState(tslib.__assign(tslib.__assign({}, props), {
3064
+ value: dateValue,
3065
+ onChange: handleKeyboardChange
3066
+ }), options),
3067
+ innerInputProps = _c.inputProps,
3068
+ wrapperProps = _c.wrapperProps,
3069
+ pickerProps = _c.pickerProps;
3070
+
3071
+ var inputProps = React.useMemo(function () {
3072
+ return tslib.__assign(tslib.__assign({}, innerInputProps), {
3073
+ format: wrapperProps.format,
3074
+ inputValue: inputValue || innerInputValue,
3075
+ onChange: function (value) {
3076
+ setInnerInputValue(value || '');
3077
+ var date = value === null ? null : utils.parse(value, wrapperProps.format);
3078
+ onChange(date, value);
3079
+ }
3080
+ });
3081
+ }, [innerInputProps, innerInputValue, inputValue, onChange, utils, wrapperProps.format]);
3082
+ return {
3083
+ inputProps: inputProps,
3084
+ wrapperProps: wrapperProps,
3085
+ pickerProps: pickerProps
3086
+ };
3087
+ }
3088
+
3089
+ // TODO investigate how to reduce duplications
3090
+
3091
+ function makeKeyboardPicker(_a) {
3092
+ var useOptions = _a.useOptions,
3093
+ getCustomProps = _a.getCustomProps,
3094
+ DefaultToolbarComponent = _a.DefaultToolbarComponent;
3095
+
3096
+ function WrappedKeyboardPicker(props) {
3097
+ var allowKeyboardControl = props.allowKeyboardControl,
3098
+ ampm = props.ampm,
3099
+ hideTabs = props.hideTabs,
3100
+ animateYearScrolling = props.animateYearScrolling,
3101
+ autoOk = props.autoOk,
3102
+ disableFuture = props.disableFuture,
3103
+ disablePast = props.disablePast,
3104
+ format = props.format,
3105
+ forwardedRef = props.forwardedRef,
3106
+ initialFocusedDate = props.initialFocusedDate,
3107
+ invalidDateMessage = props.invalidDateMessage,
3108
+ labelFunc = props.labelFunc,
3109
+ leftArrowIcon = props.leftArrowIcon,
3110
+ leftArrowButtonProps = props.leftArrowButtonProps,
3111
+ maxDate = props.maxDate,
3112
+ maxDateMessage = props.maxDateMessage,
3113
+ minDate = props.minDate,
3114
+ onOpen = props.onOpen,
3115
+ onClose = props.onClose,
3116
+ minDateMessage = props.minDateMessage,
3117
+ strictCompareDates = props.strictCompareDates,
3118
+ minutesStep = props.minutesStep,
3119
+ onAccept = props.onAccept,
3120
+ onChange = props.onChange,
3121
+ onMonthChange = props.onMonthChange,
3122
+ onYearChange = props.onYearChange,
3123
+ renderDay = props.renderDay,
3124
+ views = props.views,
3125
+ openTo = props.openTo,
3126
+ rightArrowIcon = props.rightArrowIcon,
3127
+ rightArrowButtonProps = props.rightArrowButtonProps,
3128
+ shouldDisableDate = props.shouldDisableDate,
3129
+ value = props.value,
3130
+ dateRangeIcon = props.dateRangeIcon,
3131
+ emptyLabel = props.emptyLabel,
3132
+ invalidLabel = props.invalidLabel,
3133
+ timeIcon = props.timeIcon,
3134
+ orientation = props.orientation,
3135
+ variant = props.variant,
3136
+ disableToolbar = props.disableToolbar,
3137
+ loadingIndicator = props.loadingIndicator,
3138
+ showActionsBar = props.showActionsBar,
3139
+ showTodayButton = props.showTodayButton,
3140
+ todayLabel = props.todayLabel,
3141
+ _a = props.ToolbarComponent,
3142
+ ToolbarComponent = _a === void 0 ? DefaultToolbarComponent : _a,
3143
+ showShiftButtons = props.showShiftButtons,
3144
+ setShiftFunction = props.setShiftFunction,
3145
+ shiftButtonValues = props.shiftButtonValues,
3146
+ other = tslib.__rest(props, ["allowKeyboardControl", "ampm", "hideTabs", "animateYearScrolling", "autoOk", "disableFuture", "disablePast", "format", "forwardedRef", "initialFocusedDate", "invalidDateMessage", "labelFunc", "leftArrowIcon", "leftArrowButtonProps", "maxDate", "maxDateMessage", "minDate", "onOpen", "onClose", "minDateMessage", "strictCompareDates", "minutesStep", "onAccept", "onChange", "onMonthChange", "onYearChange", "renderDay", "views", "openTo", "rightArrowIcon", "rightArrowButtonProps", "shouldDisableDate", "value", "dateRangeIcon", "emptyLabel", "invalidLabel", "timeIcon", "orientation", "variant", "disableToolbar", "loadingIndicator", "showActionsBar", "showTodayButton", "todayLabel", "ToolbarComponent", "showShiftButtons", "setShiftFunction", "shiftButtonValues"]);
3147
+
3148
+ var injectedProps = getCustomProps ? getCustomProps(props) : {};
3149
+ var options = useOptions(props);
3150
+
3151
+ var _b = useKeyboardPickerState(props, options),
3152
+ pickerProps = _b.pickerProps,
3153
+ inputProps = _b.inputProps,
3154
+ wrapperProps = _b.wrapperProps;
3155
+
3156
+ return React.createElement(Wrapper, tslib.__assign({
3157
+ variant: variant,
3158
+ InputComponent: KeyboardDateInput,
3159
+ DateInputProps: inputProps
3160
+ }, injectedProps, wrapperProps, other), React.createElement(Picker, tslib.__assign({}, pickerProps, {
3161
+ ToolbarComponent: ToolbarComponent,
3162
+ disableToolbar: disableToolbar,
3163
+ hideTabs: hideTabs,
3164
+ orientation: orientation,
3165
+ showActionsBar: showActionsBar,
3166
+ showTodayButton: showTodayButton,
3167
+ todayLabel: todayLabel,
3168
+ ampm: ampm,
3169
+ views: views,
3170
+ openTo: openTo,
3171
+ allowKeyboardControl: allowKeyboardControl,
3172
+ minutesStep: minutesStep,
3173
+ animateYearScrolling: animateYearScrolling,
3174
+ disableFuture: disableFuture,
3175
+ disablePast: disablePast,
3176
+ leftArrowIcon: leftArrowIcon,
3177
+ leftArrowButtonProps: leftArrowButtonProps,
3178
+ maxDate: maxDate,
3179
+ minDate: minDate,
3180
+ strictCompareDates: strictCompareDates,
3181
+ onMonthChange: onMonthChange,
3182
+ onYearChange: onYearChange,
3183
+ renderDay: renderDay,
3184
+ dateRangeIcon: dateRangeIcon,
3185
+ timeIcon: timeIcon,
3186
+ rightArrowIcon: rightArrowIcon,
3187
+ rightArrowButtonProps: rightArrowButtonProps,
3188
+ shouldDisableDate: shouldDisableDate,
3189
+ loadingIndicator: loadingIndicator,
3190
+ showShiftButtons: showShiftButtons,
3191
+ setShiftFunction: setShiftFunction,
3192
+ shiftButtonValues: shiftButtonValues
3193
+ })));
3194
+ }
3195
+
3196
+ return WrappedKeyboardPicker;
3197
+ }
3198
+
3199
+ var defaultProps = tslib.__assign(tslib.__assign({}, datePickerDefaultProps), {
3200
+ openTo: 'date',
3201
+ views: ['year', 'date'],
3202
+ showActionsBar: false,
3203
+ todayLabel: 'TODAY'
3204
+ });
3205
+
3206
+ function useOptions(props) {
3207
+ var utils = useUtils();
3208
+ return {
3209
+ getDefaultFormat: function () {
3210
+ return getFormatByViews(props.views, utils);
3211
+ }
3212
+ };
3213
+ }
3214
+
3215
+ var DatePicker = makePurePicker({
3216
+ useOptions: useOptions,
3217
+ DefaultToolbarComponent: DatePickerToolbar
3218
+ });
3219
+ var KeyboardDatePicker = makeKeyboardPicker({
3220
+ useOptions: useOptions,
3221
+ DefaultToolbarComponent: DatePickerToolbar
3222
+ });
3223
+ DatePicker.defaultProps = defaultProps;
3224
+ KeyboardDatePicker.defaultProps = defaultProps;
3225
+
3226
+ var useStyles$e = styles$5.makeStyles({
3227
+ toolbarLandscape: {
3228
+ flexWrap: 'wrap'
3229
+ },
3230
+ toolbarAmpmLeftPadding: {
3231
+ paddingLeft: 50
3232
+ },
3233
+ separator: {
3234
+ margin: '0 4px 0 2px',
3235
+ cursor: 'default'
3236
+ },
3237
+ hourMinuteLabel: {
3238
+ display: 'flex',
3239
+ justifyContent: 'flex-end',
3240
+ alignItems: 'flex-end'
3241
+ },
3242
+ hourMinuteLabelLandscape: {
3243
+ marginTop: 'auto'
3244
+ },
3245
+ hourMinuteLabelReverse: {
3246
+ flexDirection: 'row-reverse'
3247
+ },
3248
+ ampmSelection: {
3249
+ marginLeft: 20,
3250
+ marginRight: -20,
3251
+ display: 'flex',
3252
+ flexDirection: 'column'
3253
+ },
3254
+ ampmLandscape: {
3255
+ margin: '4px 0 auto',
3256
+ flexDirection: 'row',
3257
+ justifyContent: 'space-around',
3258
+ flexBasis: '100%'
3259
+ },
3260
+ ampmSelectionWithSeconds: {
3261
+ marginLeft: 15,
3262
+ marginRight: 10
3263
+ },
3264
+ ampmLabel: {
3265
+ fontSize: 18
3266
+ }
3267
+ }, {
3268
+ name: 'MuiPickersTimePickerToolbar'
3269
+ });
3270
+ function useMeridiemMode(date, ampm, onChange) {
3271
+ var utils = useUtils();
3272
+ var meridiemMode = getMeridiem(date, utils);
3273
+ var handleMeridiemChange = React.useCallback(function (mode) {
3274
+ var timeWithMeridiem = convertToMeridiem(date, mode, Boolean(ampm), utils);
3275
+ onChange(timeWithMeridiem, false);
3276
+ }, [ampm, date, onChange, utils]);
3277
+ return {
3278
+ meridiemMode: meridiemMode,
3279
+ handleMeridiemChange: handleMeridiemChange
3280
+ };
3281
+ }
3282
+
3283
+ var TimePickerToolbar = function (_a) {
3284
+ var _b, _c, _d;
3285
+
3286
+ var date = _a.date,
3287
+ views = _a.views,
3288
+ ampm = _a.ampm,
3289
+ openView = _a.openView,
3290
+ onChange = _a.onChange,
3291
+ isLandscape = _a.isLandscape,
3292
+ setOpenView = _a.setOpenView;
3293
+ var utils = useUtils();
3294
+ var theme = styles$5.useTheme();
3295
+ var classes = useStyles$e();
3296
+
3297
+ var _e = useMeridiemMode(date, ampm, onChange),
3298
+ meridiemMode = _e.meridiemMode,
3299
+ handleMeridiemChange = _e.handleMeridiemChange;
3300
+
3301
+ var clockTypographyVariant = isLandscape ? 'h3' : 'h2';
3302
+ return React.createElement(PickerToolbar, {
3303
+ isLandscape: isLandscape,
3304
+ className: clsx((_b = {}, _b[classes.toolbarLandscape] = isLandscape, _b[classes.toolbarAmpmLeftPadding] = ampm && !isLandscape, _b))
3305
+ }, React.createElement("div", {
3306
+ className: clsx(classes.hourMinuteLabel, (_c = {}, _c[classes.hourMinuteLabelLandscape] = isLandscape, _c[classes.hourMinuteLabelReverse] = theme.direction === 'rtl', _c))
3307
+ }, arrayIncludes(views, 'hours') && React.createElement(ToolbarButton$1, {
3308
+ variant: clockTypographyVariant,
3309
+ onClick: function () {
3310
+ return setOpenView(ClockType$1.HOURS);
3311
+ },
3312
+ selected: openView === ClockType$1.HOURS,
3313
+ label: utils.getHourText(date, Boolean(ampm))
3314
+ }), arrayIncludes(views, ['hours', 'minutes']) && React.createElement(ToolbarText, {
3315
+ label: ":",
3316
+ variant: clockTypographyVariant,
3317
+ selected: false,
3318
+ className: classes.separator
3319
+ }), arrayIncludes(views, 'minutes') && React.createElement(ToolbarButton$1, {
3320
+ variant: clockTypographyVariant,
3321
+ onClick: function () {
3322
+ return setOpenView(ClockType$1.MINUTES);
3323
+ },
3324
+ selected: openView === ClockType$1.MINUTES,
3325
+ label: utils.getMinuteText(date)
3326
+ }), arrayIncludes(views, ['minutes', 'seconds']) && React.createElement(ToolbarText, {
3327
+ variant: "h2",
3328
+ label: ":",
3329
+ selected: false,
3330
+ className: classes.separator
3331
+ }), arrayIncludes(views, 'seconds') && React.createElement(ToolbarButton$1, {
3332
+ variant: "h2",
3333
+ onClick: function () {
3334
+ return setOpenView(ClockType$1.SECONDS);
3335
+ },
3336
+ selected: openView === ClockType$1.SECONDS,
3337
+ label: utils.getSecondText(date)
3338
+ })), ampm && React.createElement("div", {
3339
+ className: clsx(classes.ampmSelection, (_d = {}, _d[classes.ampmLandscape] = isLandscape, _d[classes.ampmSelectionWithSeconds] = arrayIncludes(views, 'seconds'), _d))
3340
+ }, React.createElement(ToolbarButton$1, {
3341
+ disableRipple: true,
3342
+ variant: "subtitle1",
3343
+ selected: meridiemMode === 'am',
3344
+ typographyClassName: classes.ampmLabel,
3345
+ label: utils.getMeridiemText('am'),
3346
+ onClick: function () {
3347
+ return handleMeridiemChange('am');
3348
+ }
3349
+ }), React.createElement(ToolbarButton$1, {
3350
+ disableRipple: true,
3351
+ variant: "subtitle1",
3352
+ selected: meridiemMode === 'pm',
3353
+ typographyClassName: classes.ampmLabel,
3354
+ label: utils.getMeridiemText('pm'),
3355
+ onClick: function () {
3356
+ return handleMeridiemChange('pm');
3357
+ }
3358
+ })));
3359
+ };
3360
+
3361
+ var defaultProps$1 = tslib.__assign(tslib.__assign({}, timePickerDefaultProps), {
3362
+ openTo: 'hours',
3363
+ views: ['hours', 'minutes']
3364
+ });
3365
+
3366
+ function useOptions$1(props) {
3367
+ var utils = useUtils();
3368
+ return {
3369
+ getDefaultFormat: function () {
3370
+ return pick12hOr24hFormat(props.format, props.ampm, {
3371
+ '12h': utils.time12hFormat,
3372
+ '24h': utils.time24hFormat
3373
+ });
3374
+ }
3375
+ };
3376
+ }
3377
+
3378
+ var TimePicker = makePurePicker({
3379
+ useOptions: useOptions$1,
3380
+ DefaultToolbarComponent: TimePickerToolbar
3381
+ });
3382
+ var KeyboardTimePicker = makeKeyboardPicker({
3383
+ useOptions: useOptions$1,
3384
+ DefaultToolbarComponent: TimePickerToolbar,
3385
+ getCustomProps: function (props) {
3386
+ return {
3387
+ refuse: props.ampm ? /[^\dap]+/gi : /[^\d]+/gi
3388
+ };
3389
+ }
3390
+ });
3391
+ TimePicker.defaultProps = defaultProps$1;
3392
+ KeyboardTimePicker.defaultProps = defaultProps$1;
3393
+
3394
+ var TimeIcon = function (props) {
3395
+ return React__default.createElement(SvgIcon, tslib.__assign({}, props), React__default.createElement("path", {
3396
+ d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
3397
+ }), React__default.createElement("path", {
3398
+ fill: "none",
3399
+ d: "M0 0h24v24H0z"
3400
+ }), React__default.createElement("path", {
3401
+ d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
3402
+ }));
3403
+ };
3404
+
3405
+ var DateRangeIcon = function (props) {
3406
+ return React__default.createElement(SvgIcon, tslib.__assign({}, props), React__default.createElement("path", {
3407
+ d: "M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"
3408
+ }), React__default.createElement("path", {
3409
+ fill: "none",
3410
+ d: "M0 0h24v24H0z"
3411
+ }));
3412
+ };
3413
+
3414
+ var viewToTabIndex = function (openView) {
3415
+ if (openView === 'date' || openView === 'year') {
3416
+ return 'date';
3417
+ }
3418
+
3419
+ return 'time';
3420
+ };
3421
+
3422
+ var tabIndexToView = function (tab) {
3423
+ if (tab === 'date') {
3424
+ return 'date';
3425
+ }
3426
+
3427
+ return 'hours';
3428
+ };
3429
+
3430
+ var useStyles$f = styles$5.makeStyles(function (theme) {
3431
+ // prettier-ignore
3432
+ var tabsBackground = theme.palette.type === 'light' ? theme.palette.primary.main : theme.palette.background.default;
3433
+ return {
3434
+ tabs: {
3435
+ color: theme.palette.getContrastText(tabsBackground),
3436
+ backgroundColor: tabsBackground
3437
+ }
3438
+ };
3439
+ }, {
3440
+ name: 'MuiPickerDTTabs'
3441
+ });
3442
+ var DateTimePickerTabs = function (_a) {
3443
+ var view = _a.view,
3444
+ onChange = _a.onChange,
3445
+ dateRangeIcon = _a.dateRangeIcon,
3446
+ timeIcon = _a.timeIcon;
3447
+ var classes = useStyles$f();
3448
+ var theme = styles$5.useTheme();
3449
+ var indicatorColor = theme.palette.type === 'light' ? 'secondary' : 'primary';
3450
+
3451
+ var handleChange = function (e, value) {
3452
+ if (value !== viewToTabIndex(view)) {
3453
+ onChange(tabIndexToView(value));
3454
+ }
3455
+ };
3456
+
3457
+ return React.createElement(Paper, null, React.createElement(Tabs, {
3458
+ variant: "fullWidth",
3459
+ value: viewToTabIndex(view),
3460
+ onChange: handleChange,
3461
+ className: classes.tabs,
3462
+ indicatorColor: indicatorColor
3463
+ }, React.createElement(Tab, {
3464
+ value: "date",
3465
+ icon: React.createElement(React.Fragment, null, dateRangeIcon)
3466
+ }), React.createElement(Tab, {
3467
+ value: "time",
3468
+ icon: React.createElement(React.Fragment, null, timeIcon)
3469
+ })));
3470
+ };
3471
+ DateTimePickerTabs.defaultProps = {
3472
+ dateRangeIcon: React.createElement(DateRangeIcon, null),
3473
+ timeIcon: React.createElement(TimeIcon, null)
3474
+ };
3475
+
3476
+ var useStyles$g = styles$5.makeStyles(function (_) {
3477
+ return {
3478
+ toolbar: {
3479
+ paddingLeft: 16,
3480
+ paddingRight: 16,
3481
+ justifyContent: 'space-around'
3482
+ },
3483
+ separator: {
3484
+ margin: '0 4px 0 2px',
3485
+ cursor: 'default'
3486
+ }
3487
+ };
3488
+ }, {
3489
+ name: 'MuiPickerDTToolbar'
3490
+ });
3491
+ var DateTimePickerToolbar = function (_a) {
3492
+ var date = _a.date,
3493
+ openView = _a.openView,
3494
+ setOpenView = _a.setOpenView,
3495
+ ampm = _a.ampm,
3496
+ hideTabs = _a.hideTabs,
3497
+ dateRangeIcon = _a.dateRangeIcon,
3498
+ timeIcon = _a.timeIcon,
3499
+ onChange = _a.onChange;
3500
+ var utils = useUtils();
3501
+ var classes = useStyles$g();
3502
+ var showTabs = !hideTabs && typeof window !== 'undefined' && window.innerHeight > 667;
3503
+
3504
+ var _b = useMeridiemMode(date, ampm, onChange),
3505
+ meridiemMode = _b.meridiemMode,
3506
+ handleMeridiemChange = _b.handleMeridiemChange;
3507
+
3508
+ var theme = styles$5.useTheme();
3509
+ var rtl = theme.direction === 'rtl';
3510
+ return React.createElement(React.Fragment, null, React.createElement(PickerToolbar, {
3511
+ isLandscape: false,
3512
+ className: classes.toolbar
3513
+ }, React.createElement(core.Grid, {
3514
+ container: true,
3515
+ justify: "center",
3516
+ wrap: "nowrap"
3517
+ }, React.createElement(core.Grid, {
3518
+ item: true,
3519
+ container: true,
3520
+ xs: 5,
3521
+ justify: "flex-start",
3522
+ direction: "column"
3523
+ }, React.createElement("div", null, React.createElement(ToolbarButton$1, {
3524
+ variant: "subtitle1",
3525
+ onClick: function () {
3526
+ return setOpenView('year');
3527
+ },
3528
+ selected: openView === 'year',
3529
+ label: utils.getYearText(date)
3530
+ })), React.createElement("div", null, React.createElement(ToolbarButton$1, {
3531
+ variant: "h4",
3532
+ onClick: function () {
3533
+ return setOpenView('date');
3534
+ },
3535
+ selected: openView === 'date',
3536
+ label: utils.getDateTimePickerHeaderText(date)
3537
+ }))), React.createElement(core.Grid, {
3538
+ item: true,
3539
+ container: true,
3540
+ xs: 6,
3541
+ justify: "center",
3542
+ alignItems: "flex-end",
3543
+ direction: rtl ? 'row-reverse' : 'row'
3544
+ }, React.createElement(ToolbarButton$1, {
3545
+ variant: "h3",
3546
+ onClick: function () {
3547
+ return setOpenView('hours');
3548
+ },
3549
+ selected: openView === 'hours',
3550
+ label: utils.getHourText(date, ampm)
3551
+ }), React.createElement(ToolbarText, {
3552
+ variant: "h3",
3553
+ label: ":",
3554
+ className: classes.separator
3555
+ }), React.createElement(ToolbarButton$1, {
3556
+ variant: "h3",
3557
+ onClick: function () {
3558
+ return setOpenView('minutes');
3559
+ },
3560
+ selected: openView === 'minutes',
3561
+ label: utils.getMinuteText(date)
3562
+ })), ampm && React.createElement(core.Grid, {
3563
+ item: true,
3564
+ container: true,
3565
+ xs: 1,
3566
+ direction: "column",
3567
+ justify: "flex-end"
3568
+ }, React.createElement(ToolbarButton$1, {
3569
+ variant: "subtitle1",
3570
+ selected: meridiemMode === 'am',
3571
+ label: utils.getMeridiemText('am'),
3572
+ onClick: function () {
3573
+ return handleMeridiemChange('am');
3574
+ }
3575
+ }), React.createElement(ToolbarButton$1, {
3576
+ variant: "subtitle1",
3577
+ selected: meridiemMode === 'pm',
3578
+ label: utils.getMeridiemText('pm'),
3579
+ onClick: function () {
3580
+ return handleMeridiemChange('pm');
3581
+ }
3582
+ })))), showTabs && React.createElement(DateTimePickerTabs, {
3583
+ dateRangeIcon: dateRangeIcon,
3584
+ timeIcon: timeIcon,
3585
+ view: openView,
3586
+ onChange: setOpenView
3587
+ }));
3588
+ };
3589
+
3590
+ var defaultProps$2 = tslib.__assign(tslib.__assign({}, dateTimePickerDefaultProps), {
3591
+ showActionsBar: false,
3592
+ todayLabel: 'TODAY',
3593
+ wider: true,
3594
+ orientation: 'portrait',
3595
+ openTo: 'date',
3596
+ views: ['year', 'date', 'hours', 'minutes']
3597
+ });
3598
+
3599
+ function useOptions$2(props) {
3600
+ var utils = useUtils();
3601
+
3602
+ if (props.orientation !== 'portrait') {
3603
+ throw new Error('We are not supporting custom orientation for DateTimePicker yet :(');
3604
+ }
3605
+
3606
+ return {
3607
+ getDefaultFormat: function () {
3608
+ return pick12hOr24hFormat(props.format, props.ampm, {
3609
+ '12h': utils.dateTime12hFormat,
3610
+ '24h': utils.dateTime24hFormat
3611
+ });
3612
+ }
3613
+ };
3614
+ }
3615
+
3616
+ var DateTimePicker = makePurePicker({
3617
+ useOptions: useOptions$2,
3618
+ DefaultToolbarComponent: DateTimePickerToolbar
3619
+ });
3620
+ var KeyboardDateTimePicker = makeKeyboardPicker({
3621
+ useOptions: useOptions$2,
3622
+ DefaultToolbarComponent: DateTimePickerToolbar,
3623
+ getCustomProps: function (props) {
3624
+ return {
3625
+ refuse: props.ampm ? /[^\dap]+/gi : /[^\d]+/gi
3626
+ };
3627
+ }
3628
+ });
3629
+ DateTimePicker.defaultProps = defaultProps$2;
3630
+ KeyboardDateTimePicker.defaultProps = defaultProps$2;
3631
+
3632
+ exports.Calendar = Calendar$1;
3633
+ exports.Clock = Clock$1;
3634
+ exports.DatePicker = DatePicker;
3635
+ exports.DateTimePicker = DateTimePicker;
3636
+ exports.Day = Day;
3637
+ exports.KeyboardDatePicker = KeyboardDatePicker;
3638
+ exports.KeyboardDateTimePicker = KeyboardDateTimePicker;
3639
+ exports.KeyboardTimePicker = KeyboardTimePicker;
3640
+ exports.MuiPickersContext = MuiPickersContext;
3641
+ exports.MuiPickersUtilsProvider = MuiPickersUtilsProvider;
3642
+ exports.Picker = Picker;
3643
+ exports.TimePicker = TimePicker;
3644
+ exports.TimePickerView = ClockView;
3645
+ exports.makeKeyboardPicker = makeKeyboardPicker;
3646
+ exports.makePurePicker = makePurePicker;
3647
+ exports.useKeyboardPickerState = useKeyboardPickerState;
3648
+ exports.usePickerState = usePickerState;
3649
+ exports.useUtils = useUtils;
3650
+ exports.validate = validate;
3651
+ //# sourceMappingURL=material-ui-pickers.js.map