@synerise/ds-date-picker 0.6.2 → 0.6.3

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,36 +1,8 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
-
9
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
-
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
-
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
-
15
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
-
17
- 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); } }
18
-
19
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20
-
21
- 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
-
23
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
-
25
- 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); }; }
26
-
27
- 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); }
28
-
29
1
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
2
 
31
- 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; } }
3
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
32
4
 
33
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
5
+ 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; }
34
6
 
35
7
  import * as React from 'react';
36
8
  import { legacyParse } from '@date-fns/upgrade/v2';
@@ -60,39 +32,36 @@ function getCells(cursor) {
60
32
  }
61
33
 
62
34
  var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
63
- _inherits(YearPicker, _React$PureComponent);
64
-
65
- var _super = _createSuper(YearPicker);
35
+ _inheritsLoose(YearPicker, _React$PureComponent);
66
36
 
67
37
  function YearPicker() {
68
38
  var _this;
69
39
 
70
- _classCallCheck(this, YearPicker);
71
-
72
40
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
41
  args[_key] = arguments[_key];
74
42
  }
75
43
 
76
- _this = _super.call.apply(_super, [this].concat(args));
77
- _this.state = getInitialState(_this.props);
44
+ _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
45
+
46
+ _defineProperty(_assertThisInitialized(_this), "state", getInitialState(_this.props));
78
47
 
79
- _this.handleLongPrev = function () {
48
+ _defineProperty(_assertThisInitialized(_this), "handleLongPrev", function () {
80
49
  var cursor = _this.state.cursor;
81
50
 
82
51
  _this.setState({
83
52
  cursor: fnsAddYears(cursor, -10)
84
53
  });
85
- };
54
+ });
86
55
 
87
- _this.handleLongNext = function () {
56
+ _defineProperty(_assertThisInitialized(_this), "handleLongNext", function () {
88
57
  var cursor = _this.state.cursor;
89
58
 
90
59
  _this.setState({
91
60
  cursor: fnsAddYears(cursor, 10)
92
61
  });
93
- };
62
+ });
94
63
 
95
- _this.handleCellClick = function (isoDate) {
64
+ _defineProperty(_assertThisInitialized(_this), "handleCellClick", function (isoDate) {
96
65
  var onChange = _this.props.onChange;
97
66
 
98
67
  if (isoDate === -1) {
@@ -108,77 +77,75 @@ var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
108
77
  }
109
78
 
110
79
  onChange && onChange(new Date(isoDate));
111
- };
80
+ });
112
81
 
113
82
  return _this;
114
83
  }
115
84
 
116
- _createClass(YearPicker, [{
117
- key: "getSnapshotBeforeUpdate",
118
- value: function getSnapshotBeforeUpdate(prevProps) {
119
- var value = this.props.value;
85
+ var _proto = YearPicker.prototype;
120
86
 
121
- if (value && (prevProps === null || prevProps === void 0 ? void 0 : prevProps.value) !== value) {
122
- this.setState(getInitialState(this.props));
123
- }
87
+ _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
88
+ var value = this.props.value;
124
89
 
125
- return null;
90
+ if (value && (prevProps == null ? void 0 : prevProps.value) !== value) {
91
+ this.setState(getInitialState(this.props));
126
92
  }
127
- }, {
128
- key: "render",
129
- value: function render() {
130
- var _this2 = this;
131
-
132
- var _this$state = this.state,
133
- cursor = _this$state.cursor,
134
- decadeMode = _this$state.decadeMode;
135
- var value = this.props.value;
136
- var decadeRange = getDecadeRange(cursor);
137
- var cells = getCells(cursor);
138
- var valueCell = value ? cells.find(function (cell) {
139
- return fnsIsSameYear(value, legacyParse(cell.key));
140
- }) : null;
141
- var selectedKey = valueCell ? valueCell.key : null;
142
- cells = [{
143
- key: -1,
144
- text: decadeRange[0] - 1,
145
- outside: true
146
- }].concat(_toConsumableArray(cells), [{
147
- key: 1,
148
- text: decadeRange[1] + 1,
149
- outside: true
150
- }]);
151
-
152
- if (decadeMode) {
153
- return /*#__PURE__*/React.createElement(DecadePicker, {
154
- value: cursor,
155
- onChange: function onChange(selectedDecade) {
156
- return _this2.setState({
157
- cursor: selectedDecade,
158
- decadeMode: false
159
- });
160
- }
161
- });
162
- }
163
93
 
164
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Navbar, {
165
- onTitleClick: function onTitleClick() {
94
+ return null;
95
+ };
96
+
97
+ _proto.render = function render() {
98
+ var _this2 = this;
99
+
100
+ var _this$state = this.state,
101
+ cursor = _this$state.cursor,
102
+ decadeMode = _this$state.decadeMode;
103
+ var value = this.props.value;
104
+ var decadeRange = getDecadeRange(cursor);
105
+ var cells = getCells(cursor);
106
+ var valueCell = value ? cells.find(function (cell) {
107
+ return fnsIsSameYear(value, legacyParse(cell.key));
108
+ }) : null;
109
+ var selectedKey = valueCell ? valueCell.key : null;
110
+ cells = [{
111
+ key: -1,
112
+ text: decadeRange[0] - 1,
113
+ outside: true
114
+ }].concat(cells, [{
115
+ key: 1,
116
+ text: decadeRange[1] + 1,
117
+ outside: true
118
+ }]);
119
+
120
+ if (decadeMode) {
121
+ return /*#__PURE__*/React.createElement(DecadePicker, {
122
+ value: cursor,
123
+ onChange: function onChange(selectedDecade) {
166
124
  return _this2.setState({
167
- decadeMode: true
125
+ cursor: selectedDecade,
126
+ decadeMode: false
168
127
  });
169
- },
170
- title: decadeRange.join('-'),
171
- onLongPrev: this.handleLongPrev,
172
- onLongNext: this.handleLongNext,
173
- key: "head"
174
- }), /*#__PURE__*/React.createElement(GridPicker, {
175
- selectedKey: selectedKey,
176
- cells: cells,
177
- onCellClick: this.handleCellClick,
178
- key: "body"
179
- }), ",");
128
+ }
129
+ });
180
130
  }
181
- }]);
131
+
132
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Navbar, {
133
+ onTitleClick: function onTitleClick() {
134
+ return _this2.setState({
135
+ decadeMode: true
136
+ });
137
+ },
138
+ title: decadeRange.join('-'),
139
+ onLongPrev: this.handleLongPrev,
140
+ onLongNext: this.handleLongNext,
141
+ key: "head"
142
+ }), /*#__PURE__*/React.createElement(GridPicker, {
143
+ selectedKey: selectedKey,
144
+ cells: cells,
145
+ onCellClick: this.handleCellClick,
146
+ key: "body"
147
+ }), ",");
148
+ };
182
149
 
183
150
  return YearPicker;
184
151
  }(React.PureComponent);
@@ -1,24 +1,8 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- 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); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
-
9
- 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
-
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- 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); }; }
14
-
15
- 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); }
16
-
17
1
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
2
 
19
- 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; } }
3
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
20
4
 
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
5
+ 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; }
22
6
 
23
7
  import * as React from 'react';
24
8
  import { FormattedMessage } from 'react-intl';
@@ -35,18 +19,14 @@ import { fnsStartOfMonth, fnsSetYear, fnsSetMonth, fnsSetDate, fnsStartOfDay, fn
35
19
  import { changeDayWithHoursPreserved } from '../utils';
36
20
 
37
21
  var RawDatePicker = /*#__PURE__*/function (_React$Component) {
38
- _inherits(RawDatePicker, _React$Component);
39
-
40
- var _super = _createSuper(RawDatePicker);
22
+ _inheritsLoose(RawDatePicker, _React$Component);
41
23
 
42
24
  function RawDatePicker(props) {
43
25
  var _this;
44
26
 
45
- _classCallCheck(this, RawDatePicker);
27
+ _this = _React$Component.call(this, props) || this; // eslint-disable-next-line react/state-in-constructor
46
28
 
47
- _this = _super.call(this, props); // eslint-disable-next-line react/state-in-constructor
48
-
49
- _this.handleChange = function (value) {
29
+ _defineProperty(_assertThisInitialized(_this), "handleChange", function (value) {
50
30
  var onValueChange = _this.props.onValueChange;
51
31
  var _this$state = _this.state,
52
32
  mode = _this$state.mode,
@@ -69,21 +49,21 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
69
49
 
70
50
  onValueChange && onValueChange(value);
71
51
  }
72
- };
52
+ });
73
53
 
74
- _this.handleDayMouseEnter = function (day) {
54
+ _defineProperty(_assertThisInitialized(_this), "handleDayMouseEnter", function (day) {
75
55
  return _this.setState({
76
56
  enteredTo: day
77
57
  });
78
- };
58
+ });
79
59
 
80
- _this.handleDayMouseLeave = function () {
60
+ _defineProperty(_assertThisInitialized(_this), "handleDayMouseLeave", function () {
81
61
  return _this.setState({
82
62
  enteredTo: undefined
83
63
  });
84
- };
64
+ });
85
65
 
86
- _this.handleDayClick = function (day, modifiers) {
66
+ _defineProperty(_assertThisInitialized(_this), "handleDayClick", function (day, modifiers) {
87
67
  var _this$state2 = _this.state,
88
68
  isChanged = _this$state2.changed,
89
69
  value = _this$state2.value;
@@ -106,15 +86,15 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
106
86
  }
107
87
 
108
88
  !!showTime && _this.handleModeSwitch('time');
109
- };
89
+ });
110
90
 
111
- _this.handleModeSwitch = function (mode) {
91
+ _defineProperty(_assertThisInitialized(_this), "handleModeSwitch", function (mode) {
112
92
  return _this.setState({
113
93
  mode: mode
114
94
  });
115
- };
95
+ });
116
96
 
117
- _this.handleApply = function (date) {
97
+ _defineProperty(_assertThisInitialized(_this), "handleApply", function (date) {
118
98
  var onApply = _this.props.onApply;
119
99
  if (!onApply) return;
120
100
  var value = _this.state.value;
@@ -130,23 +110,23 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
130
110
  }
131
111
 
132
112
  _this.handleModeSwitch('date');
133
- };
113
+ });
134
114
 
135
- _this.handleMonthChange = function (month, mode) {
115
+ _defineProperty(_assertThisInitialized(_this), "handleMonthChange", function (month, mode) {
136
116
  return _this.setState({
137
117
  month: month,
138
118
  mode: mode
139
119
  });
140
- };
120
+ });
141
121
 
142
- _this.renderDay = function (day) {
122
+ _defineProperty(_assertThisInitialized(_this), "renderDay", function (day) {
143
123
  var text = day.getDate();
144
124
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DayBackground, null), /*#__PURE__*/React.createElement(DayText, {
145
125
  "data-attr": text
146
126
  }, text), /*#__PURE__*/React.createElement(DayForeground, null));
147
- };
127
+ });
148
128
 
149
- _this.renderYearPicker = function () {
129
+ _defineProperty(_assertThisInitialized(_this), "renderYearPicker", function () {
150
130
  var month = _this.state.month;
151
131
  return /*#__PURE__*/React.createElement(YearPicker, {
152
132
  value: month,
@@ -154,9 +134,9 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
154
134
  return changedMonth && _this.handleMonthChange(changedMonth, 'date');
155
135
  }
156
136
  });
157
- };
137
+ });
158
138
 
159
- _this.renderMonthPicker = function () {
139
+ _defineProperty(_assertThisInitialized(_this), "renderMonthPicker", function () {
160
140
  var month = _this.state.month;
161
141
  return /*#__PURE__*/React.createElement(MonthPicker, {
162
142
  value: month,
@@ -164,9 +144,9 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
164
144
  return changedMonth && _this.handleMonthChange(changedMonth, 'date');
165
145
  }
166
146
  });
167
- };
147
+ });
168
148
 
169
- _this.renderDayPicker = function () {
149
+ _defineProperty(_assertThisInitialized(_this), "renderDayPicker", function () {
170
150
  var _this$state3 = _this.state,
171
151
  value = _this$state3.value,
172
152
  enteredTo = _this$state3.enteredTo;
@@ -203,18 +183,18 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
203
183
  },
204
184
  modifiers: modifiers
205
185
  });
206
- };
186
+ });
207
187
 
208
- _this.handleDaySwitch = function (day) {
188
+ _defineProperty(_assertThisInitialized(_this), "handleDaySwitch", function (day) {
209
189
  var disabledDates = _this.props.disabledDates; // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
210
190
  // @ts-ignore
211
191
 
212
192
  _this.handleDayClick(day, {
213
193
  disabled: disabledDates ? disabledDates(day) : false
214
194
  });
215
- };
195
+ });
216
196
 
217
- _this.renderTimePicker = function () {
197
+ _defineProperty(_assertThisInitialized(_this), "renderTimePicker", function () {
218
198
  var value = _this.state.value;
219
199
  var _this$props2 = _this.props,
220
200
  disabledHours = _this$props2.disabledHours,
@@ -233,7 +213,7 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
233
213
  return _this.handleDaySwitch(fnsAddDays(legacyParse(value), -1));
234
214
  }
235
215
  });
236
- };
216
+ });
237
217
 
238
218
  _this.state = {
239
219
  mode: 'date',
@@ -246,102 +226,100 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
246
226
  return _this;
247
227
  }
248
228
 
249
- _createClass(RawDatePicker, [{
250
- key: "getTexts",
251
- value: function getTexts() {
252
- var _this$props3 = this.props,
253
- texts = _this$props3.texts,
254
- intl = _this$props3.intl;
255
- var updatedTexts = {
256
- apply: (texts === null || texts === void 0 ? void 0 : texts.apply) || /*#__PURE__*/React.createElement(FormattedMessage, {
257
- id: "DS.DATE-PICKER.APPLY"
258
- }),
259
- now: (texts === null || texts === void 0 ? void 0 : texts.now) || /*#__PURE__*/React.createElement(FormattedMessage, {
260
- id: "DS.DATE-PICKER.NOW"
261
- }),
262
- inputPlaceholder: (texts === null || texts === void 0 ? void 0 : texts.inputPlaceholder) || (intl === null || intl === void 0 ? void 0 : intl.formatMessage({
263
- id: 'DS.DATE-PICKER.SELECT-DATE'
264
- })) || ''
265
- };
266
- return updatedTexts;
267
- }
268
- }, {
269
- key: "getSnapshotBeforeUpdate",
270
- value: function getSnapshotBeforeUpdate(prevProps) {
271
- var value = this.props.value;
272
- var mode = this.state.mode;
273
-
274
- if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.value) !== value) {
275
- this.setState({
276
- value: value,
277
- month: fnsStartOfMonth(value || new Date()),
278
- changed: true,
279
- mode: value === undefined ? 'date' : mode
280
- });
281
- }
229
+ var _proto = RawDatePicker.prototype;
230
+
231
+ _proto.getTexts = function getTexts() {
232
+ var _this$props3 = this.props,
233
+ texts = _this$props3.texts,
234
+ intl = _this$props3.intl;
235
+ var updatedTexts = {
236
+ apply: (texts == null ? void 0 : texts.apply) || /*#__PURE__*/React.createElement(FormattedMessage, {
237
+ id: "DS.DATE-PICKER.APPLY"
238
+ }),
239
+ now: (texts == null ? void 0 : texts.now) || /*#__PURE__*/React.createElement(FormattedMessage, {
240
+ id: "DS.DATE-PICKER.NOW"
241
+ }),
242
+ inputPlaceholder: (texts == null ? void 0 : texts.inputPlaceholder) || (intl == null ? void 0 : intl.formatMessage({
243
+ id: 'DS.DATE-PICKER.SELECT-DATE'
244
+ })) || ''
245
+ };
246
+ return updatedTexts;
247
+ };
248
+
249
+ _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
250
+ var value = this.props.value;
251
+ var mode = this.state.mode;
282
252
 
283
- return null;
253
+ if ((prevProps == null ? void 0 : prevProps.value) !== value) {
254
+ this.setState({
255
+ value: value,
256
+ month: fnsStartOfMonth(value || new Date()),
257
+ changed: true,
258
+ mode: value === undefined ? 'date' : mode
259
+ });
284
260
  }
285
- }, {
286
- key: "render",
287
- value: function render() {
288
- var _this2 = this;
289
-
290
- var _this$state4 = this.state,
291
- mode = _this$state4.mode,
292
- changed = _this$state4.changed,
293
- value = _this$state4.value,
294
- texts = _this$state4.texts;
295
- var _this$props4 = this.props,
296
- showTime = _this$props4.showTime,
297
- hideNow = _this$props4.hideNow;
298
- var isValid = !!value;
299
- var picker;
300
-
301
- switch (mode) {
302
- case 'time':
303
- picker = this.renderTimePicker();
304
- break;
305
-
306
- case 'date':
307
- picker = this.renderDayPicker();
308
- break;
309
-
310
- case 'month':
311
- picker = this.renderMonthPicker();
312
- break;
313
-
314
- case 'year':
315
- picker = this.renderYearPicker();
316
- break;
317
-
318
- default:
319
- picker = null;
320
- break;
321
- }
322
261
 
323
- return /*#__PURE__*/React.createElement(S.Container, null, picker, /*#__PURE__*/React.createElement(Footer, {
324
- canApply: isValid && changed,
325
- onApply: this.handleApply,
326
- dateOnly: !showTime,
327
- mode: mode,
328
- canSwitchMode: isValid,
329
- onSwitchMode: function onSwitchMode() {
330
- return _this2.handleModeSwitch(mode === 'time' ? 'date' : 'time');
331
- },
332
- texts: texts,
333
- hideNow: hideNow
334
- }));
262
+ return null;
263
+ };
264
+
265
+ _proto.render = function render() {
266
+ var _this2 = this;
267
+
268
+ var _this$state4 = this.state,
269
+ mode = _this$state4.mode,
270
+ changed = _this$state4.changed,
271
+ value = _this$state4.value,
272
+ texts = _this$state4.texts;
273
+ var _this$props4 = this.props,
274
+ showTime = _this$props4.showTime,
275
+ hideNow = _this$props4.hideNow;
276
+ var isValid = !!value;
277
+ var picker;
278
+
279
+ switch (mode) {
280
+ case 'time':
281
+ picker = this.renderTimePicker();
282
+ break;
283
+
284
+ case 'date':
285
+ picker = this.renderDayPicker();
286
+ break;
287
+
288
+ case 'month':
289
+ picker = this.renderMonthPicker();
290
+ break;
291
+
292
+ case 'year':
293
+ picker = this.renderYearPicker();
294
+ break;
295
+
296
+ default:
297
+ picker = null;
298
+ break;
335
299
  }
336
- }]);
300
+
301
+ return /*#__PURE__*/React.createElement(S.Container, null, picker, /*#__PURE__*/React.createElement(Footer, {
302
+ canApply: isValid && changed,
303
+ onApply: this.handleApply,
304
+ dateOnly: !showTime,
305
+ mode: mode,
306
+ canSwitchMode: isValid,
307
+ onSwitchMode: function onSwitchMode() {
308
+ return _this2.handleModeSwitch(mode === 'time' ? 'date' : 'time');
309
+ },
310
+ texts: texts,
311
+ hideNow: hideNow
312
+ }));
313
+ };
337
314
 
338
315
  return RawDatePicker;
339
316
  }(React.Component);
340
317
 
341
- RawDatePicker.defaultProps = {
318
+ _defineProperty(RawDatePicker, "defaultProps", {
342
319
  showTime: false,
343
320
  disabledHours: [],
344
321
  disabledMinutes: [],
345
322
  disabledSeconds: []
346
- };
323
+ });
324
+
347
325
  export default RawDatePicker;
package/dist/format.js CHANGED
@@ -6,8 +6,11 @@ var locales = {
6
6
  es: es
7
7
  };
8
8
  var defaultLocale = 'en';
9
- export default function (date, formatStr) {
10
- var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultLocale;
9
+ export default function (date, formatStr, locale) {
10
+ if (locale === void 0) {
11
+ locale = defaultLocale;
12
+ }
13
+
11
14
  return fnsFormat(date, formatStr, {
12
15
  locale: locales[locale.substring(0, 2)]
13
16
  });
@@ -15,14 +15,20 @@ var FIRST_DAY = {
15
15
  pl: 1
16
16
  };
17
17
 
18
- function formatDay(d) {
19
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
20
- return "".concat(WEEKDAYS_LONG[locale][d.getDay()], ", ").concat(d.getDate(), " ").concat(MONTHS[locale][d.getMonth()], " ").concat(d.getFullYear());
18
+ function formatDay(d, locale) {
19
+ if (locale === void 0) {
20
+ locale = 'en';
21
+ }
22
+
23
+ return WEEKDAYS_LONG[locale][d.getDay()] + ", " + d.getDate() + " " + MONTHS[locale][d.getMonth()] + " " + d.getFullYear();
21
24
  }
22
25
 
23
- function formatMonthTitle(d) {
24
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
25
- return "".concat(MONTHS[locale][d.getMonth()], " ").concat(d.getFullYear());
26
+ function formatMonthTitle(d, locale) {
27
+ if (locale === void 0) {
28
+ locale = 'en';
29
+ }
30
+
31
+ return MONTHS[locale][d.getMonth()] + " " + d.getFullYear();
26
32
  }
27
33
 
28
34
  function formatWeekdayShort(i, locale) {
package/dist/utils.js CHANGED
@@ -1,15 +1,3 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
1
  import { differenceInCalendarDays } from 'date-fns';
14
2
  import { legacyParse } from "@date-fns/upgrade/v2";
15
3
  import { fnsAddSeconds, fnsDifferenceInSeconds, fnsGetYear } from './fns';
@@ -19,7 +7,7 @@ export var range = function range(start, end) {
19
7
  }
20
8
 
21
9
  var size = end - start;
22
- return _toConsumableArray(Array(size).keys()).map(function (i) {
10
+ return [].concat(Array(size).keys()).map(function (i) {
23
11
  return i + start;
24
12
  });
25
13
  };