react-picky-date-time 1.9.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,937 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _reactTransitionGroup = require("react-transition-group");
11
-
12
- var _react = _interopRequireWildcard(require("react"));
13
-
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
- var _utils = require("../utils.js");
17
-
18
- var _locale = require("../locale.js");
19
-
20
- var _constValue = require("../constValue");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
-
32
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
-
34
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
35
-
36
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
37
-
38
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
39
-
40
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
41
-
42
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
43
-
44
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
45
-
46
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
47
-
48
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
49
-
50
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
-
52
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
53
-
54
- var isValidDate = function isValidDate(value, userFormat) {
55
- userFormat = userFormat || 'mm/dd/yyyy';
56
- var delimiter = /[^mdy]/.exec(userFormat)[0];
57
- var theFormat = userFormat.split(delimiter);
58
- var theDate = value.split(delimiter);
59
-
60
- function isDate(date, format) {
61
- var m,
62
- d,
63
- y,
64
- i = 0,
65
- len = format.length,
66
- f;
67
-
68
- for (i; i < len; i++) {
69
- f = format[i];
70
- if (/m/.test(f)) m = date[i];
71
- if (/d/.test(f)) d = date[i];
72
- if (/y/.test(f)) y = date[i];
73
- }
74
-
75
- return m > 0 && m < 13 && y && y.length === 4 && d > 0 && // Is it a valid day of the month?
76
- d <= new Date(y, m, 0).getDate();
77
- }
78
-
79
- return isDate(theDate, theFormat);
80
- };
81
-
82
- var Calendar = /*#__PURE__*/function (_Component) {
83
- _inherits(Calendar, _Component);
84
-
85
- var _super = _createSuper(Calendar);
86
-
87
- function Calendar(props) {
88
- var _this;
89
-
90
- _classCallCheck(this, Calendar);
91
-
92
- _this = _super.call(this, props);
93
- var today = new Date();
94
- var year = today.getFullYear();
95
- var month = today.getMonth() + 1;
96
- var date = today.getDate();
97
- var dates = (0, _constValue.getDaysArray)(year, month);
98
- var defaultDateDate = date;
99
- var defaultDateMonth = month;
100
- var defaultDateYear = year;
101
- var isDefaultDateValid = false;
102
-
103
- if (isValidDate(props.defaultDate)) {
104
- var dateStr = props.defaultDate.split('/');
105
- defaultDateMonth = Number(dateStr[0]);
106
- defaultDateDate = Number(dateStr[1]);
107
- defaultDateYear = Number(dateStr[2]);
108
- isDefaultDateValid = true;
109
- dates = (0, _constValue.getDaysArray)(defaultDateYear, defaultDateMonth);
110
- } else {
111
- if (props.defaultDate != '') {
112
- console.error('The date you provide: ' + props.defaultDate + ' is not a valid date');
113
- }
114
- }
115
-
116
- _this.state = {
117
- isDefaultDateValid: isDefaultDateValid,
118
- dates: dates,
119
- pickedYearMonth: {
120
- year: defaultDateYear,
121
- month: defaultDateMonth,
122
- string: "".concat((0, _constValue.formatDateString)(defaultDateYear), "-").concat((0, _constValue.formatDateString)(defaultDateMonth))
123
- },
124
- defaultDate: {
125
- date: defaultDateDate,
126
- year: defaultDateYear,
127
- month: defaultDateMonth
128
- },
129
- pickedDateInfo: {
130
- date: defaultDateDate,
131
- year: defaultDateYear,
132
- month: defaultDateMonth
133
- },
134
- currentYearMonthDate: {
135
- date: date,
136
- year: year,
137
- month: month
138
- },
139
- direction: _constValue.NEXT_TRANSITION,
140
- yearSelectorPanelList: (0, _constValue.getYearSet)(defaultDateYear),
141
- yearSelectorPanel: defaultDateYear,
142
- showMask: false,
143
- showSelectorPanel: false
144
- };
145
- _this.pageClick = _this.pageClick.bind(_assertThisInitialized(_this));
146
- _this.pickDate = _this.pickDate.bind(_assertThisInitialized(_this));
147
- _this.onMouseUp = _this.onMouseUp.bind(_assertThisInitialized(_this));
148
- _this.onMouseDown = _this.onMouseDown.bind(_assertThisInitialized(_this));
149
- _this.showSelectorPanel = _this.showSelectorPanel.bind(_assertThisInitialized(_this));
150
- return _this;
151
- }
152
-
153
- _createClass(Calendar, [{
154
- key: "componentDidMount",
155
- value: function componentDidMount() {
156
- if (document.addEventListener) {
157
- window.addEventListener('mousedown', this.pageClick, false);
158
- window.addEventListener('touchend', this.pageClick, false);
159
- } else {
160
- document.attachEvent('onmousedown', this.pageClick);
161
- document.attachEvent('touchend', this.pageClick);
162
- }
163
- }
164
- }, {
165
- key: "componentWillUnmount",
166
- value: function componentWillUnmount() {
167
- if (document.removeEventListener) {
168
- window.removeEventListener('mousedown', this.pageClick, false);
169
- window.removeEventListener('touchend', this.pageClick, false);
170
- } else {
171
- document.detachEvent('onmousedown', this.pageClick);
172
- document.detachEvent('touchend', this.pageClick);
173
- }
174
- }
175
- }, {
176
- key: "componentDidUpdate",
177
- value: function componentDidUpdate(prevProps, prevState) {
178
- if (prevState.pickedYearMonth != this.state.pickedYearMonth) {
179
- var dates = (0, _constValue.getDaysArray)(Number(this.state.pickedYearMonth.year), Number(this.state.pickedYearMonth.month));
180
- this.setState({
181
- dates: dates
182
- });
183
- }
184
- }
185
- }, {
186
- key: "pageClick",
187
- value: function pageClick() {
188
- if (this.mouseIsDownOnSelectorPanelClicker) {
189
- return;
190
- }
191
-
192
- this.setState({
193
- showSelectorPanel: false,
194
- showMask: false
195
- });
196
- }
197
- }, {
198
- key: "pickYear",
199
- value: function pickYear(year, direction) {
200
- if (direction == _constValue.PREV_TRANSITION) {
201
- year = Number(year) - 1;
202
- } else {
203
- year = Number(year) + 1;
204
- }
205
-
206
- var pickedYearMonth = this.state.pickedYearMonth;
207
- var _pickedYearMonth = pickedYearMonth,
208
- month = _pickedYearMonth.month;
209
- pickedYearMonth = _objectSpread(_objectSpread({}, pickedYearMonth), {}, {
210
- year: year,
211
- string: "".concat(year, "-").concat(month)
212
- });
213
- this.setState({
214
- pickedYearMonth: pickedYearMonth,
215
- direction: direction
216
- });
217
- this.props.onYearPicked({
218
- year: year
219
- });
220
- }
221
- }, {
222
- key: "pickMonth",
223
- value: function pickMonth(month, direction) {
224
- month = Number(month);
225
- var pickedYearMonth = this.state.pickedYearMonth;
226
- var _pickedYearMonth2 = pickedYearMonth,
227
- year = _pickedYearMonth2.year;
228
-
229
- if (direction == _constValue.PREV_TRANSITION) {
230
- if (month == 1) {
231
- month = 12;
232
- year = Number(year) - 1;
233
- } else {
234
- month = month - 1;
235
- }
236
- } else {
237
- if (month == 12) {
238
- month = 1;
239
- year = Number(year) + 1;
240
- } else {
241
- month = month + 1;
242
- }
243
- }
244
-
245
- month = (0, _constValue.formatDateString)(month);
246
- year = String(year);
247
- pickedYearMonth = _objectSpread(_objectSpread({}, pickedYearMonth), {}, {
248
- year: year,
249
- month: month,
250
- string: "".concat(year, "-").concat(month)
251
- });
252
- this.setState({
253
- pickedYearMonth: pickedYearMonth,
254
- direction: direction
255
- });
256
- this.props.onMonthPicked({
257
- year: year,
258
- month: month
259
- });
260
- }
261
- }, {
262
- key: "pickDate",
263
- value: function pickDate(pickedDate) {
264
- var _this$state = this.state,
265
- pickedDateInfo = _this$state.pickedDateInfo,
266
- pickedYearMonth = _this$state.pickedYearMonth;
267
- pickedDateInfo = _objectSpread(_objectSpread({}, pickedDateInfo), {}, {
268
- year: pickedYearMonth.year,
269
- month: (0, _constValue.formatDateString)(pickedYearMonth.month),
270
- date: (0, _constValue.formatDateString)(pickedDate)
271
- });
272
- this.setState({
273
- pickedDateInfo: pickedDateInfo
274
- });
275
- this.props.onDatePicked(pickedDateInfo);
276
- }
277
- }, {
278
- key: "changeSelectorPanelYearSet",
279
- value: function changeSelectorPanelYearSet(yearSelectorPanel, direction) {
280
- var yearSelectorPanelList = (0, _constValue.getYearSet)(yearSelectorPanel);
281
- this.setState({
282
- yearSelectorPanel: yearSelectorPanel,
283
- yearSelectorPanelList: yearSelectorPanelList,
284
- direction: direction
285
- });
286
- }
287
- }, {
288
- key: "showSelectorPanel",
289
- value: function showSelectorPanel() {
290
- var _this$state2 = this.state,
291
- showSelectorPanel = _this$state2.showSelectorPanel,
292
- showMask = _this$state2.showMask;
293
- this.setState({
294
- showSelectorPanel: !showSelectorPanel,
295
- showMask: !showMask
296
- });
297
- }
298
- }, {
299
- key: "onMouseDown",
300
- value: function onMouseDown() {
301
- this.mouseIsDownOnSelectorPanelClicker = true;
302
- }
303
- }, {
304
- key: "onMouseUp",
305
- value: function onMouseUp() {
306
- this.mouseIsDownOnSelectorPanelClicker = false;
307
- }
308
- }, {
309
- key: "reset",
310
- value: function reset() {
311
- var today = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
312
- var _this$state3 = this.state,
313
- currentYearMonthDate = _this$state3.currentYearMonthDate,
314
- pickedDateInfo = _this$state3.pickedDateInfo,
315
- pickedYearMonth = _this$state3.pickedYearMonth,
316
- defaultDate = _this$state3.defaultDate;
317
- var year, month, date;
318
-
319
- if (!today) {
320
- year = defaultDate.year;
321
- month = defaultDate.month;
322
- date = defaultDate.date;
323
- } else {
324
- year = currentYearMonthDate.year;
325
- month = currentYearMonthDate.month;
326
- date = currentYearMonthDate.date;
327
- }
328
-
329
- var direction = _constValue.NEXT_TRANSITION;
330
-
331
- if (year < pickedYearMonth.year) {
332
- direction = _constValue.PREV_TRANSITION;
333
- } else if (year == pickedYearMonth.year) {
334
- if (month < pickedYearMonth.month) {
335
- direction = _constValue.PREV_TRANSITION;
336
- }
337
- }
338
-
339
- month = (0, _constValue.formatDateString)(month);
340
- date = (0, _constValue.formatDateString)(date);
341
- pickedDateInfo = _objectSpread(_objectSpread({}, pickedDateInfo), {}, {
342
- year: year,
343
- month: month,
344
- date: date
345
- });
346
- pickedYearMonth = _objectSpread(_objectSpread({}, pickedYearMonth), {}, {
347
- year: year,
348
- month: month,
349
- string: "".concat(year, "-").concat(month)
350
- });
351
- this.setState({
352
- pickedYearMonth: pickedYearMonth,
353
- pickedDateInfo: pickedDateInfo,
354
- yearSelectorPanel: year,
355
- direction: direction
356
- });
357
-
358
- if (!today) {
359
- this.props.onResetDefaultDate(pickedDateInfo);
360
- } else {
361
- this.props.onResetDate(pickedDateInfo);
362
- }
363
-
364
- this.changeSelectorPanelYearSet(year, direction);
365
- }
366
- }, {
367
- key: "render",
368
- value: function render() {
369
- var _this2 = this;
370
-
371
- var _this$props = this.props,
372
- size = _this$props.size,
373
- locale = _this$props.locale,
374
- markedDates = _this$props.markedDates,
375
- supportDateRange = _this$props.supportDateRange;
376
- var markedDatesHash = {};
377
-
378
- if (markedDates && (0, _utils.isValidDates)(markedDates)) {
379
- markedDates.forEach(function (d) {
380
- markedDatesHash[d] = true;
381
- });
382
- }
383
-
384
- var minSupportDate = supportDateRange.length > 0 && isValidDate(supportDateRange[0]) ? supportDateRange[0] : '';
385
- var maxSupportDate = supportDateRange.length > 1 && isValidDate(supportDateRange[1]) ? supportDateRange[1] : '';
386
- var _this$state4 = this.state,
387
- isDefaultDateValid = _this$state4.isDefaultDateValid,
388
- dates = _this$state4.dates,
389
- direction = _this$state4.direction,
390
- showSelectorPanel = _this$state4.showSelectorPanel,
391
- yearSelectorPanelList = _this$state4.yearSelectorPanelList,
392
- yearSelectorPanel = _this$state4.yearSelectorPanel,
393
- currentYearMonthDate = _this$state4.currentYearMonthDate,
394
- pickedDateInfo = _this$state4.pickedDateInfo,
395
- pickedYearMonth = _this$state4.pickedYearMonth;
396
- var transitionContainerStyle;
397
- var content;
398
-
399
- if (dates.length) {
400
- var row = dates.length / _constValue.WEEK_NUMBER;
401
- var rowIndex = 1;
402
- var rowObj = {};
403
- dates.map(function (item, key) {
404
- if (key < rowIndex * _constValue.WEEK_NUMBER) {
405
- if (!rowObj[rowIndex]) {
406
- rowObj[rowIndex] = [];
407
- }
408
-
409
- rowObj[rowIndex].push(item);
410
- } else {
411
- rowIndex = rowIndex + 1;
412
-
413
- if (!rowObj[rowIndex]) {
414
- rowObj[rowIndex] = [];
415
- }
416
-
417
- rowObj[rowIndex].push(item);
418
- }
419
- });
420
- content = /*#__PURE__*/_react["default"].createElement(CalendarBody, {
421
- size: size,
422
- data: rowObj,
423
- currentYearMonthDate: currentYearMonthDate,
424
- pickedYearMonth: pickedYearMonth,
425
- pickedDateInfo: pickedDateInfo,
426
- onClick: this.pickDate,
427
- key: pickedYearMonth.string,
428
- markedDatesHash: markedDatesHash,
429
- minSupportDate: minSupportDate,
430
- maxSupportDate: maxSupportDate
431
- });
432
-
433
- if (row == 6) {
434
- var height = 385;
435
-
436
- if (size == 'l') {
437
- height = 500;
438
- }
439
-
440
- if (size == 's') {
441
- height = 285;
442
- }
443
-
444
- if (size == 'xs') {
445
- height = 235;
446
- }
447
-
448
- transitionContainerStyle = {
449
- height: "".concat(height, "px")
450
- };
451
- }
452
- }
453
-
454
- var captionHtml;
455
- captionHtml = _locale.LOCALE[locale].weeks.map(function (item, key) {
456
- return /*#__PURE__*/_react["default"].createElement("div", {
457
- className: "picky-date-time-calendar__table-caption picky-date-time-calendar__table-cel no-border ".concat(size),
458
- key: key
459
- }, item);
460
- });
461
- var selectorPanelClass = (0, _utils.cx)('picky-date-time-dropdown', 'picky-date-time-calendar__selector-panel', showSelectorPanel && 'visible');
462
-
463
- var selectorPanelMonthHtml = _locale.LOCALE[locale].months.map(function (item, key) {
464
- var itemMonth = key + 1;
465
- var monthItemClass = (0, _utils.cx)('picky-date-time-dropdown-calendar__month-item', itemMonth == pickedYearMonth.month && 'active');
466
- var month = itemMonth - 1;
467
- var direction = _constValue.NEXT_TRANSITION;
468
-
469
- if (itemMonth < pickedYearMonth.month) {
470
- direction = _constValue.PREV_TRANSITION;
471
- month = itemMonth + 1;
472
- }
473
-
474
- return /*#__PURE__*/_react["default"].createElement("div", {
475
- className: monthItemClass,
476
- onClick: itemMonth !== pickedYearMonth.month ? function () {
477
- return _this2.pickMonth(month, direction);
478
- } : function () {
479
- return;
480
- },
481
- key: key
482
- }, /*#__PURE__*/_react["default"].createElement("div", {
483
- className: size
484
- }, item));
485
- });
486
-
487
- var selectorPanelYearHtml;
488
-
489
- if (yearSelectorPanelList.length) {
490
- selectorPanelYearHtml = yearSelectorPanelList.map(function (item, key) {
491
- var yearItemClass = (0, _utils.cx)('picky-date-time-dropdown-calendar__year-item', item == pickedYearMonth.year && 'active');
492
- var year = item - 1;
493
- var direction = _constValue.NEXT_TRANSITION;
494
-
495
- if (item < pickedYearMonth.year) {
496
- direction = _constValue.PREV_TRANSITION;
497
- year = item + 1;
498
- }
499
-
500
- return /*#__PURE__*/_react["default"].createElement("div", {
501
- className: yearItemClass,
502
- onClick: item !== pickedYearMonth.year ? function () {
503
- return _this2.pickYear(year, direction);
504
- } : function () {
505
- return;
506
- },
507
- key: key
508
- }, /*#__PURE__*/_react["default"].createElement("div", {
509
- className: size
510
- }, item));
511
- });
512
- }
513
-
514
- var classNames = direction == _constValue.NEXT_TRANSITION ? 'forward' : 'backward';
515
- return /*#__PURE__*/_react["default"].createElement("div", {
516
- className: "picky-date-time-calendar"
517
- }, /*#__PURE__*/_react["default"].createElement("div", {
518
- className: "picky-date-time-calendar__header"
519
- }, /*#__PURE__*/_react["default"].createElement("div", {
520
- className: "".concat(selectorPanelClass),
521
- ref: function ref(_ref) {
522
- return _this2.monthSelectorPanel = _ref;
523
- },
524
- onMouseDown: this.onMouseDown,
525
- onMouseUp: this.onMouseUp,
526
- onTouchEnd: this.onMouseDown,
527
- onTouchCancel: this.onMouseUp
528
- }, /*#__PURE__*/_react["default"].createElement("div", {
529
- className: "picky-date-time-dropdown-calendar__menu ".concat([size])
530
- }, /*#__PURE__*/_react["default"].createElement("div", {
531
- className: "picky-date-time-dropdown-calendar__month"
532
- }, selectorPanelMonthHtml), /*#__PURE__*/_react["default"].createElement("div", {
533
- style: {
534
- height: '10px'
535
- }
536
- }), /*#__PURE__*/_react["default"].createElement("div", {
537
- className: "picky-date-time__col picky-date-time__col-0-5"
538
- }, /*#__PURE__*/_react["default"].createElement("svg", {
539
- width: "20",
540
- height: "20",
541
- viewBox: "0 0 24 24",
542
- style: {
543
- verticalAlign: 'middle'
544
- },
545
- onClick: function onClick() {
546
- return _this2.changeSelectorPanelYearSet(yearSelectorPanel - _constValue.SELECTOR_YEAR_SET_NUMBER, _constValue.PREV_TRANSITION);
547
- }
548
- }, /*#__PURE__*/_react["default"].createElement("path", {
549
- d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"
550
- }), /*#__PURE__*/_react["default"].createElement("path", {
551
- d: "M0 0h24v24H0z",
552
- fill: "none"
553
- }))), /*#__PURE__*/_react["default"].createElement("div", {
554
- className: "picky-date-time__col picky-date-time__col-9"
555
- }, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.TransitionGroup, {
556
- className: "picky-date-time-calendar__selector-panel-year-set-container",
557
- childFactory: function childFactory(child) {
558
- return /*#__PURE__*/_react["default"].cloneElement(child, {
559
- classNames: classNames
560
- });
561
- }
562
- }, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
563
- key: yearSelectorPanelList,
564
- timeout: {
565
- enter: 300,
566
- exit: 300
567
- },
568
- className: "picky-date-time-dropdown-calendar__year",
569
- classNames: classNames
570
- }, /*#__PURE__*/_react["default"].createElement("div", null, selectorPanelYearHtml)))), /*#__PURE__*/_react["default"].createElement("div", {
571
- className: "picky-date-time__col picky-date-time__col-0-5"
572
- }, /*#__PURE__*/_react["default"].createElement("svg", {
573
- width: "20",
574
- height: "20",
575
- viewBox: "0 0 24 24",
576
- style: {
577
- verticalAlign: 'middle'
578
- },
579
- onClick: function onClick() {
580
- return _this2.changeSelectorPanelYearSet(yearSelectorPanel + _constValue.SELECTOR_YEAR_SET_NUMBER, _constValue.NEXT_TRANSITION);
581
- }
582
- }, /*#__PURE__*/_react["default"].createElement("path", {
583
- d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
584
- }), /*#__PURE__*/_react["default"].createElement("path", {
585
- d: "M0 0h24v24H0z",
586
- fill: "none"
587
- }))))), /*#__PURE__*/_react["default"].createElement("div", {
588
- className: "picky-date-time__col picky-date-time__col-3"
589
- }, /*#__PURE__*/_react["default"].createElement("div", {
590
- className: "picky-date-time__col picky-date-time-calendar__previous",
591
- onClick: function onClick() {
592
- return _this2.pickYear(pickedYearMonth.year, _constValue.PREV_TRANSITION);
593
- }
594
- }, /*#__PURE__*/_react["default"].createElement("svg", {
595
- width: "20",
596
- height: "20",
597
- viewBox: "0 0 24 24",
598
- style: {
599
- verticalAlign: 'middle'
600
- }
601
- }, /*#__PURE__*/_react["default"].createElement("path", {
602
- d: "M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"
603
- }), /*#__PURE__*/_react["default"].createElement("path", {
604
- fill: "none",
605
- d: "M24 24H0V0h24v24z"
606
- }))), /*#__PURE__*/_react["default"].createElement("div", {
607
- className: "picky-date-time__col picky-date-time-calendar__sub-previous",
608
- onClick: function onClick() {
609
- return _this2.pickMonth(pickedYearMonth.month, _constValue.PREV_TRANSITION);
610
- }
611
- }, /*#__PURE__*/_react["default"].createElement("svg", {
612
- width: "20",
613
- height: "20",
614
- viewBox: "0 0 24 24",
615
- style: {
616
- verticalAlign: 'middle'
617
- }
618
- }, /*#__PURE__*/_react["default"].createElement("path", {
619
- d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"
620
- }), /*#__PURE__*/_react["default"].createElement("path", {
621
- d: "M0 0h24v24H0z",
622
- fill: "none"
623
- })))), /*#__PURE__*/_react["default"].createElement("div", {
624
- className: "picky-date-time__col picky-date-time__col-6"
625
- }, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.TransitionGroup, {
626
- className: "picky-date-time-calendar__title-container",
627
- childFactory: function childFactory(child) {
628
- return /*#__PURE__*/_react["default"].cloneElement(child, {
629
- classNames: classNames
630
- });
631
- }
632
- }, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
633
- key: pickedYearMonth.string,
634
- timeout: {
635
- enter: 300,
636
- exit: 300
637
- },
638
- className: "picky-date-time-calendar__title",
639
- style: {
640
- left: '0'
641
- },
642
- classNames: classNames
643
- }, /*#__PURE__*/_react["default"].createElement("span", {
644
- className: "picky-date-time-calendar__clicker",
645
- onClick: this.showSelectorPanel,
646
- onMouseDown: this.onMouseDown,
647
- onMouseUp: this.onMouseUp
648
- }, /*#__PURE__*/_react["default"].createElement("span", {
649
- className: "picky-date-time-calendar__clicker"
650
- }, /*#__PURE__*/_react["default"].createElement("span", null, "".concat(_locale.LOCALE[locale].months[pickedYearMonth.month - 1]))), /*#__PURE__*/_react["default"].createElement("span", null, "\xA0"), /*#__PURE__*/_react["default"].createElement("span", {
651
- className: "picky-date-time-calendar__clicker"
652
- }, /*#__PURE__*/_react["default"].createElement("span", null, "".concat(pickedYearMonth.year))))))), /*#__PURE__*/_react["default"].createElement("div", {
653
- className: "picky-date-time__col picky-date-time__col-3"
654
- }, /*#__PURE__*/_react["default"].createElement("div", {
655
- className: "picky-date-time__col picky-date-time-calendar__next",
656
- onClick: function onClick() {
657
- return _this2.pickMonth(pickedYearMonth.month, _constValue.NEXT_TRANSITION);
658
- }
659
- }, /*#__PURE__*/_react["default"].createElement("svg", {
660
- width: "20",
661
- height: "20",
662
- viewBox: "0 0 24 24",
663
- style: {
664
- verticalAlign: 'middle'
665
- }
666
- }, /*#__PURE__*/_react["default"].createElement("path", {
667
- d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
668
- }), /*#__PURE__*/_react["default"].createElement("path", {
669
- d: "M0 0h24v24H0z",
670
- fill: "none"
671
- }))), /*#__PURE__*/_react["default"].createElement("div", {
672
- className: "picky-date-time__col picky-date-time-calendar__sub-next",
673
- onClick: function onClick() {
674
- return _this2.pickYear(pickedYearMonth.year, _constValue.NEXT_TRANSITION);
675
- }
676
- }, /*#__PURE__*/_react["default"].createElement("svg", {
677
- width: "20",
678
- height: "20",
679
- viewBox: "0 0 24 24",
680
- style: {
681
- verticalAlign: 'middle'
682
- }
683
- }, /*#__PURE__*/_react["default"].createElement("path", {
684
- d: "M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"
685
- }), /*#__PURE__*/_react["default"].createElement("path", {
686
- fill: "none",
687
- d: "M0 0h24v24H0V0z"
688
- }))))), /*#__PURE__*/_react["default"].createElement("div", {
689
- className: "picky-date-time-calendar__content"
690
- }, /*#__PURE__*/_react["default"].createElement("div", {
691
- className: "picky-date-time-calendar__table"
692
- }, /*#__PURE__*/_react["default"].createElement("div", {
693
- className: "picky-date-time-calendar__table-row"
694
- }, captionHtml)), /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.TransitionGroup, {
695
- className: "picky-date-time-calendar__body-container ".concat(size),
696
- style: transitionContainerStyle,
697
- childFactory: function childFactory(child) {
698
- return /*#__PURE__*/_react["default"].cloneElement(child, {
699
- classNames: classNames
700
- });
701
- }
702
- }, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
703
- key: pickedYearMonth.string,
704
- timeout: {
705
- enter: 300,
706
- exit: 300
707
- },
708
- classNames: classNames
709
- }, content))), /*#__PURE__*/_react["default"].createElement("div", {
710
- className: "picky-date-time-calendar__button picky-date-time-calendar__today",
711
- onClick: function onClick() {
712
- return _this2.reset(true);
713
- }
714
- }, /*#__PURE__*/_react["default"].createElement("span", {
715
- className: "picky-date-time-calendar__inline-span"
716
- }, _locale.LOCALE[locale]['today']), /*#__PURE__*/_react["default"].createElement("svg", {
717
- xmlns: "http://www.w3.org/2000/svg",
718
- height: "15",
719
- viewBox: "0 0 24 24",
720
- width: "15",
721
- style: {
722
- verticalAlign: 'middle'
723
- }
724
- }, /*#__PURE__*/_react["default"].createElement("path", {
725
- fill: "#868e96",
726
- d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
727
- }), /*#__PURE__*/_react["default"].createElement("path", {
728
- d: "M0 0h24v24H0z",
729
- fill: "none"
730
- }))), isDefaultDateValid ? /*#__PURE__*/_react["default"].createElement("div", {
731
- className: "picky-date-time-calendar__button picky-date-time-calendar__default-day",
732
- onClick: function onClick() {
733
- return _this2.reset(false);
734
- }
735
- }, /*#__PURE__*/_react["default"].createElement("span", {
736
- className: "picky-date-time-calendar__inline-span"
737
- }, _locale.LOCALE[locale]['reset-date']), /*#__PURE__*/_react["default"].createElement("svg", {
738
- xmlns: "http://www.w3.org/2000/svg",
739
- height: "15",
740
- viewBox: "0 0 24 24",
741
- width: "15",
742
- style: {
743
- verticalAlign: 'middle'
744
- }
745
- }, /*#__PURE__*/_react["default"].createElement("path", {
746
- fill: "#868e96",
747
- d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
748
- }), /*#__PURE__*/_react["default"].createElement("path", {
749
- d: "M0 0h24v24H0z",
750
- fill: "none"
751
- }))) : "");
752
- }
753
- }]);
754
-
755
- return Calendar;
756
- }(_react.Component);
757
-
758
- var CalendarBody = /*#__PURE__*/function (_Component2) {
759
- _inherits(CalendarBody, _Component2);
760
-
761
- var _super2 = _createSuper(CalendarBody);
762
-
763
- function CalendarBody() {
764
- _classCallCheck(this, CalendarBody);
765
-
766
- return _super2.apply(this, arguments);
767
- }
768
-
769
- _createClass(CalendarBody, [{
770
- key: "render",
771
- value: function render() {
772
- var _this$props2 = this.props,
773
- size = _this$props2.size,
774
- data = _this$props2.data,
775
- currentYearMonthDate = _this$props2.currentYearMonthDate,
776
- pickedDateInfo = _this$props2.pickedDateInfo,
777
- pickedYearMonth = _this$props2.pickedYearMonth,
778
- onClick = _this$props2.onClick,
779
- markedDatesHash = _this$props2.markedDatesHash,
780
- minSupportDate = _this$props2.minSupportDate,
781
- maxSupportDate = _this$props2.maxSupportDate;
782
- var year = currentYearMonthDate.year,
783
- month = currentYearMonthDate.month,
784
- date = currentYearMonthDate.date;
785
- var pickedDateYear = pickedDateInfo.year;
786
- var pickedDateMonth = pickedDateInfo.month;
787
- var pickedDate = pickedDateInfo.date;
788
- var pickedMonth = pickedYearMonth.month;
789
- var content = Object.keys(data).map(function (key) {
790
- var colHtml;
791
-
792
- if (data[key].length) {
793
- colHtml = data[key].map(function (item, key) {
794
- var itemDate = "".concat(item.month, "/").concat(item.name, "/").concat(item.year);
795
- var isPicked = pickedDate == item.name && pickedDateMonth == item.month && pickedDateYear == item.year;
796
- var isDisabled = pickedMonth != item.month;
797
-
798
- if (minSupportDate) {
799
- if (new Date(itemDate) < new Date(minSupportDate)) {
800
- isDisabled = true;
801
- }
802
- }
803
-
804
- if (maxSupportDate) {
805
- if (new Date(itemDate) > new Date(maxSupportDate)) {
806
- isDisabled = true;
807
- }
808
- }
809
-
810
- var datePickerItemClass = (0, _utils.cx)('picky-date-time-calendar__table-cel', 'picky-date-time-calendar__date-item', size, isDisabled && 'disabled', date == item.name && month == item.month && year == item.year && 'today', markedDatesHash[itemDate] && 'marked', isPicked && 'active');
811
- return /*#__PURE__*/_react["default"].createElement(CalendarItem, {
812
- key: key,
813
- item: item,
814
- onClick: onClick,
815
- isPicked: isPicked,
816
- isDisabled: isDisabled,
817
- datePickerItemClass: datePickerItemClass
818
- });
819
- });
820
- }
821
-
822
- return /*#__PURE__*/_react["default"].createElement("div", {
823
- className: "picky-date-time-calendar__table-row",
824
- key: key
825
- }, colHtml);
826
- });
827
- return /*#__PURE__*/_react["default"].createElement("div", {
828
- className: "picky-date-time-calendar__table slide"
829
- }, content);
830
- }
831
- }]);
832
-
833
- return CalendarBody;
834
- }(_react.Component);
835
-
836
- var CalendarItem = /*#__PURE__*/function (_Component3) {
837
- _inherits(CalendarItem, _Component3);
838
-
839
- var _super3 = _createSuper(CalendarItem);
840
-
841
- function CalendarItem(props) {
842
- var _this3;
843
-
844
- _classCallCheck(this, CalendarItem);
845
-
846
- _this3 = _super3.call(this, props);
847
- _this3.onClick = _this3.onClick.bind(_assertThisInitialized(_this3));
848
- return _this3;
849
- }
850
-
851
- _createClass(CalendarItem, [{
852
- key: "onClick",
853
- value: function onClick() {
854
- this.props.onClick(this.props.item.name);
855
- }
856
- }, {
857
- key: "render",
858
- value: function render() {
859
- var _this$props3 = this.props,
860
- item = _this$props3.item,
861
- isPicked = _this$props3.isPicked,
862
- isDisabled = _this$props3.isDisabled,
863
- datePickerItemClass = _this$props3.datePickerItemClass;
864
- return /*#__PURE__*/_react["default"].createElement("div", {
865
- className: "".concat(datePickerItemClass),
866
- onClick: !isDisabled ? this.onClick : function () {
867
- return;
868
- }
869
- }, item.name, isPicked ? /*#__PURE__*/_react["default"].createElement("svg", {
870
- xmlns: "http://www.w3.org/2000/svg",
871
- height: "15",
872
- viewBox: "0 0 24 24",
873
- width: "15"
874
- }, /*#__PURE__*/_react["default"].createElement("path", {
875
- d: "M0 0h24v24H0z",
876
- fill: "none"
877
- }), /*#__PURE__*/_react["default"].createElement("path", {
878
- d: "M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
879
- })) : '');
880
- }
881
- }]);
882
-
883
- return CalendarItem;
884
- }(_react.Component);
885
-
886
- CalendarItem.propTypes = {
887
- item: _propTypes["default"].object,
888
- isPicked: _propTypes["default"].bool,
889
- isDisabled: _propTypes["default"].bool,
890
- datePickerItemClass: _propTypes["default"].string,
891
- onClick: _propTypes["default"].func
892
- };
893
- CalendarItem.defaultProps = {
894
- item: {},
895
- isPicked: false,
896
- isDisabled: false,
897
- datePickerItemClass: '',
898
- onClick: function onClick() {}
899
- };
900
- CalendarBody.propTypes = {
901
- size: _propTypes["default"].string,
902
- data: _propTypes["default"].object,
903
- currentYearMonthDate: _propTypes["default"].object,
904
- pickedDateInfo: _propTypes["default"].object,
905
- pickedYearMonth: _propTypes["default"].object,
906
- onClick: _propTypes["default"].func
907
- };
908
- CalendarBody.defaultProps = {
909
- size: 'm',
910
- data: {},
911
- currentYearMonthDate: {},
912
- pickedDateInfo: {},
913
- pickedYearMonth: {},
914
- onClick: function onClick() {}
915
- };
916
- Calendar.propTypes = {
917
- size: _propTypes["default"].string,
918
- locale: _propTypes["default"].string,
919
- defaultDate: _propTypes["default"].string,
920
- onYearPicked: _propTypes["default"].func,
921
- onMonthPicked: _propTypes["default"].func,
922
- onDatePicked: _propTypes["default"].func,
923
- onResetDate: _propTypes["default"].func,
924
- onResetDefaultDate: _propTypes["default"].func
925
- };
926
- Calendar.defaultProps = {
927
- size: 'm',
928
- locale: 'en-US',
929
- defaultDate: '',
930
- onYearPicked: function onYearPicked() {},
931
- onMonthPicked: function onMonthPicked() {},
932
- onDatePicked: function onDatePicked() {},
933
- onResetDate: function onResetDate() {},
934
- onResetDefaultDate: function onResetDefaultDate() {}
935
- };
936
- var _default = Calendar;
937
- exports["default"] = _default;