@synerise/ds-date-range-picker 0.11.2 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/DateRangePicker.js +9 -24
- package/dist/DateRangePicker.styles.js +1 -1
- package/dist/Footer/Footer.js +3 -5
- package/dist/RangeFilter/Filters/MonthlyFilter/MonthlyFilter.js +166 -204
- package/dist/RangeFilter/Filters/WeeklyFilter/WeeklyFilter.js +1 -1
- package/dist/RangeFilter/Filters/new/Daily/Daily.js +5 -17
- package/dist/RangeFilter/Filters/new/Weekly/Weekly.js +17 -38
- package/dist/RangeFilter/Filters/new/Weekly/utils.js +6 -3
- package/dist/RangeFilter/Filters/new/hooks/useShiftAndControlKeys.js +6 -20
- package/dist/RangeFilter/RangeFilter.js +110 -138
- package/dist/RangeFilter/Shared/AddButton/AddButton.js +2 -4
- package/dist/RangeFilter/Shared/FilterDropdown/FilterDropdown.js +3 -3
- package/dist/RangeFilter/Shared/RangeFilterStatus/RangeFilterStatus.js +1 -1
- package/dist/RangeFilter/Shared/SaveFilterForm/SaveFilterForm.js +5 -19
- package/dist/RangeFilter/Shared/SelectionCount/SelectionCount.js +1 -1
- package/dist/RangeFilter/Shared/TimeWindow/Day/Day.js +5 -20
- package/dist/RangeFilter/Shared/TimeWindow/Header/Header.js +1 -1
- package/dist/RangeFilter/Shared/TimeWindow/RangeFormContainer/RangeForm/RangeForm.js +8 -22
- package/dist/RangeFilter/Shared/TimeWindow/RangeFormContainer/RangeFormContainer.js +9 -22
- package/dist/RangeFilter/Shared/TimeWindow/RangeSummary/RangeSummary.js +1 -1
- package/dist/RangeFilter/Shared/TimeWindow/TimeWindow.js +148 -182
- package/dist/RangeFilter/Shared/TimeWindow/utils.js +2 -2
- package/dist/RangeFilter/constants.js +1 -1
- package/dist/RangeFilter/utils.js +43 -61
- package/dist/RangePicker/RangePicker.js +100 -118
- package/dist/RangePicker/utils.js +8 -3
- package/dist/RangePickerInput/RangePickerInput.js +5 -18
- package/dist/RangePickerInput/RangePickerInput.styles.js +1 -1
- package/dist/RawDateRangePicker.js +116 -139
- package/dist/RelativeRangePicker/Elements/CustomRangeForm/DurationField/DurationField.js +1 -1
- package/dist/RelativeRangePicker/Elements/CustomRangeForm/OffsetField/OffsetField.js +1 -1
- package/dist/RelativeRangePicker/Elements/ModeDropdown/ModeDropdown.js +3 -16
- package/dist/RelativeRangePicker/Elements/RangeButtons/RangeButtons.js +1 -1
- package/dist/RelativeRangePicker/Elements/RangeDropdown/RangeDropdown.js +3 -16
- package/dist/RelativeRangePicker/Elements/TimestampRange/TimestampRange.js +14 -30
- package/dist/RelativeRangePicker/RelativeRangePicker.js +80 -115
- package/dist/RelativeRangePicker/RelativeRangePicker.styles.d.ts +1 -1
- package/dist/RelativeRangePicker/RelativeRangePicker.styles.js +3 -5
- package/dist/RelativeRangePicker/utils.js +1 -1
- package/dist/constants.js +1 -13
- package/dist/dateUtils/format.js +5 -2
- package/dist/dateUtils/getRelativePresetForRange.js +1 -1
- package/dist/utils.js +55 -55
- package/package.json +8 -8
|
@@ -1,50 +1,18 @@
|
|
|
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
1
|
var _excluded = ["days", "numberOfDays", "daily", "intl", "texts", "disabled"];
|
|
4
2
|
|
|
5
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
4
|
|
|
7
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
-
|
|
9
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
6
|
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
12
8
|
|
|
13
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
10
|
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
18
|
-
|
|
19
|
-
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."); }
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
23
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
24
|
-
|
|
25
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
26
|
-
|
|
27
|
-
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; }
|
|
28
|
-
|
|
29
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
30
|
-
|
|
31
|
-
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); } }
|
|
32
|
-
|
|
33
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
34
|
-
|
|
35
|
-
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); }
|
|
36
|
-
|
|
37
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
38
|
-
|
|
39
|
-
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); }; }
|
|
40
|
-
|
|
41
|
-
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); }
|
|
42
|
-
|
|
43
11
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
44
12
|
|
|
45
|
-
function
|
|
13
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
46
14
|
|
|
47
|
-
function
|
|
15
|
+
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; }
|
|
48
16
|
|
|
49
17
|
import * as React from 'react';
|
|
50
18
|
import { range } from 'lodash';
|
|
@@ -64,32 +32,30 @@ import SelectionHint from '../SelectionHint/SelectionHint';
|
|
|
64
32
|
export var DEFAULT_LIMIT_MODE = 'Range';
|
|
65
33
|
|
|
66
34
|
var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _super = _createSuper(TimeWindowBase);
|
|
35
|
+
_inheritsLoose(TimeWindowBase, _React$PureComponent);
|
|
70
36
|
|
|
71
37
|
function TimeWindowBase() {
|
|
72
38
|
var _this;
|
|
73
39
|
|
|
74
|
-
_classCallCheck(this, TimeWindowBase);
|
|
75
|
-
|
|
76
40
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
41
|
args[_key] = arguments[_key];
|
|
78
42
|
}
|
|
79
43
|
|
|
80
|
-
_this =
|
|
81
|
-
|
|
44
|
+
_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
|
|
45
|
+
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
82
47
|
activeDays: _this.props.daily ? [0] : [],
|
|
83
48
|
controlKeyPressed: false
|
|
84
|
-
};
|
|
85
|
-
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "wrapperRef", React.createRef());
|
|
86
52
|
|
|
87
|
-
_this
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "isDayRestricted", function (dayKey) {
|
|
88
54
|
var days = _this.props.days;
|
|
89
55
|
return !!days[dayKey] && days[dayKey].restricted;
|
|
90
|
-
};
|
|
56
|
+
});
|
|
91
57
|
|
|
92
|
-
_this
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "checkActiveDay", function (dayKey) {
|
|
93
59
|
var isRangeDefined = _this.state.isRangeDefined;
|
|
94
60
|
if (!_this.isDayRestricted(dayKey) && isRangeDefined && !_this.haveActiveDaysCommonRange()) _this.checkDay(dayKey);
|
|
95
61
|
var _this$state = _this.state,
|
|
@@ -99,7 +65,7 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
99
65
|
var updatedActiveDay = [];
|
|
100
66
|
|
|
101
67
|
if (controlKeyPressed) {
|
|
102
|
-
updatedActiveDay = activeDays.includes(dayKey) ? activeDays : [].concat(
|
|
68
|
+
updatedActiveDay = activeDays.includes(dayKey) ? activeDays : [].concat(activeDays, [dayKey]);
|
|
103
69
|
} else if (activeDays.length > 0 && shiftKeyPressed) {
|
|
104
70
|
updatedActiveDay = activeDays[0] < dayKey ? range(+activeDays[0], +dayKey + 1) : range(+dayKey, +activeDays[0] + 1);
|
|
105
71
|
} else {
|
|
@@ -107,13 +73,13 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
107
73
|
}
|
|
108
74
|
|
|
109
75
|
_this.setState(function (state) {
|
|
110
|
-
return _objectSpread(
|
|
76
|
+
return _objectSpread({}, state, {
|
|
111
77
|
activeDays: updatedActiveDay
|
|
112
78
|
});
|
|
113
79
|
});
|
|
114
|
-
};
|
|
80
|
+
});
|
|
115
81
|
|
|
116
|
-
_this
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "uncheckActiveDay", function (dayKey) {
|
|
117
83
|
var _this$state2 = _this.state,
|
|
118
84
|
activeDays = _this$state2.activeDays,
|
|
119
85
|
controlKeyPressed = _this$state2.controlKeyPressed;
|
|
@@ -126,15 +92,15 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
126
92
|
}
|
|
127
93
|
|
|
128
94
|
_this.setState(function (state) {
|
|
129
|
-
return _objectSpread(
|
|
95
|
+
return _objectSpread({}, state, {
|
|
130
96
|
activeDays: updatedActiveDay
|
|
131
97
|
});
|
|
132
98
|
});
|
|
133
99
|
|
|
134
100
|
_this.removeDaySelection(dayKey);
|
|
135
|
-
};
|
|
101
|
+
});
|
|
136
102
|
|
|
137
|
-
_this
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleToggleDay", function (dayKey, forcedState) {
|
|
138
104
|
var _this$state3 = _this.state,
|
|
139
105
|
activeDays = _this$state3.activeDays,
|
|
140
106
|
controlKeyPressed = _this$state3.controlKeyPressed;
|
|
@@ -149,25 +115,27 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
149
115
|
} else {
|
|
150
116
|
activeDays.includes(dayKey) ? _this.uncheckActiveDay(dayKey) : _this.checkActiveDay(dayKey);
|
|
151
117
|
}
|
|
152
|
-
};
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "handleDayChange", function (dayKey, dayChanges) {
|
|
121
|
+
var _objectSpread2;
|
|
153
122
|
|
|
154
|
-
_this.handleDayChange = function (dayKey, dayChanges) {
|
|
155
123
|
var _this$props = _this.props,
|
|
156
124
|
onChange = _this$props.onChange,
|
|
157
125
|
days = _this$props.days;
|
|
158
|
-
onChange(_objectSpread(
|
|
159
|
-
};
|
|
126
|
+
onChange(_objectSpread({}, days, (_objectSpread2 = {}, _objectSpread2[dayKey] = _objectSpread({}, _this.getDayValue(dayKey), {}, dayChanges), _objectSpread2)));
|
|
127
|
+
});
|
|
160
128
|
|
|
161
|
-
_this
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "removeDaySelection", function (dayKey) {
|
|
162
130
|
var _this$props2 = _this.props,
|
|
163
131
|
onChange = _this$props2.onChange,
|
|
164
132
|
days = _this$props2.days;
|
|
165
133
|
var updatedDays = days;
|
|
166
134
|
delete updatedDays[dayKey];
|
|
167
135
|
onChange(updatedDays);
|
|
168
|
-
};
|
|
136
|
+
});
|
|
169
137
|
|
|
170
|
-
_this
|
|
138
|
+
_defineProperty(_assertThisInitialized(_this), "checkDay", function (dayKey) {
|
|
171
139
|
var onCheckDay = _this.props.onCheckDay;
|
|
172
140
|
|
|
173
141
|
_this.handleDayChange(dayKey, {
|
|
@@ -178,17 +146,17 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
178
146
|
});
|
|
179
147
|
|
|
180
148
|
onCheckDay && onCheckDay(dayKey);
|
|
181
|
-
};
|
|
149
|
+
});
|
|
182
150
|
|
|
183
|
-
_this
|
|
151
|
+
_defineProperty(_assertThisInitialized(_this), "handleDayTimeChange", function (value, dayKey) {
|
|
184
152
|
_this.handleDayChange(dayKey, {
|
|
185
153
|
restricted: true,
|
|
186
154
|
start: dayjs(value[0]).format(TIME_FORMAT),
|
|
187
155
|
stop: dayjs(value[1]).format(TIME_FORMAT)
|
|
188
156
|
});
|
|
189
|
-
};
|
|
157
|
+
});
|
|
190
158
|
|
|
191
|
-
_this
|
|
159
|
+
_defineProperty(_assertThisInitialized(_this), "handleMultipleDayTimeChange", function (value) {
|
|
192
160
|
var _this$props3 = _this.props,
|
|
193
161
|
onChange = _this$props3.onChange,
|
|
194
162
|
days = _this$props3.days;
|
|
@@ -202,10 +170,10 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
202
170
|
restricted: true
|
|
203
171
|
};
|
|
204
172
|
});
|
|
205
|
-
onChange(_objectSpread(
|
|
206
|
-
};
|
|
173
|
+
onChange(_objectSpread({}, days, {}, updatedDays));
|
|
174
|
+
});
|
|
207
175
|
|
|
208
|
-
_this
|
|
176
|
+
_defineProperty(_assertThisInitialized(_this), "handleRangeDelete", function () {
|
|
209
177
|
var _this$props4 = _this.props,
|
|
210
178
|
onChange = _this$props4.onChange,
|
|
211
179
|
days = _this$props4.days;
|
|
@@ -215,15 +183,15 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
215
183
|
delete updatedDays[k];
|
|
216
184
|
});
|
|
217
185
|
onChange(_objectSpread({}, updatedDays));
|
|
218
|
-
};
|
|
186
|
+
});
|
|
219
187
|
|
|
220
|
-
_this
|
|
188
|
+
_defineProperty(_assertThisInitialized(_this), "handleClearSelection", function () {
|
|
221
189
|
_this.setState({
|
|
222
190
|
activeDays: []
|
|
223
191
|
});
|
|
224
|
-
};
|
|
192
|
+
});
|
|
225
193
|
|
|
226
|
-
_this
|
|
194
|
+
_defineProperty(_assertThisInitialized(_this), "handleSelectAll", function () {
|
|
227
195
|
var keys = _this.getAllKeys();
|
|
228
196
|
|
|
229
197
|
var onSelectAll = _this.props.onSelectAll;
|
|
@@ -233,9 +201,9 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
233
201
|
}, function () {
|
|
234
202
|
onSelectAll && onSelectAll();
|
|
235
203
|
});
|
|
236
|
-
};
|
|
204
|
+
});
|
|
237
205
|
|
|
238
|
-
_this
|
|
206
|
+
_defineProperty(_assertThisInitialized(_this), "getDayValue", function (dayKey) {
|
|
239
207
|
var _customDays$dayKey, _customDays$dayKey2;
|
|
240
208
|
|
|
241
209
|
var _this$props5 = _this.props,
|
|
@@ -245,7 +213,7 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
245
213
|
daily = _this$props5.daily,
|
|
246
214
|
valueSelectionModes = _this$props5.valueSelectionModes;
|
|
247
215
|
var dayValue = {};
|
|
248
|
-
if (daily) dayValue = days;else if (days[dayKey]) dayValue = days[dayKey];else if (typeof dayKey === 'number') dayValue = dayTemplate(dayKey);else if (customDays && (_customDays$dayKey = customDays[dayKey])
|
|
216
|
+
if (daily) dayValue = days;else if (days[dayKey]) dayValue = days[dayKey];else if (typeof dayKey === 'number') dayValue = dayTemplate(dayKey);else if (customDays && (_customDays$dayKey = customDays[dayKey]) != null && _customDays$dayKey.template && ((_customDays$dayKey2 = customDays[dayKey]) == null ? void 0 : _customDays$dayKey2.template) !== null) {
|
|
249
217
|
dayValue = customDays[dayKey].template;
|
|
250
218
|
}
|
|
251
219
|
return _objectSpread({
|
|
@@ -256,9 +224,9 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
256
224
|
inverted: false,
|
|
257
225
|
mode: valueSelectionModes[0] || DEFAULT_LIMIT_MODE
|
|
258
226
|
}, dayValue);
|
|
259
|
-
};
|
|
227
|
+
});
|
|
260
228
|
|
|
261
|
-
_this
|
|
229
|
+
_defineProperty(_assertThisInitialized(_this), "getDayLabel", function (dayKey, _long) {
|
|
262
230
|
var _this$props6 = _this.props,
|
|
263
231
|
dayFormatter = _this$props6.dayFormatter,
|
|
264
232
|
customDays = _this$props6.customDays;
|
|
@@ -270,18 +238,18 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
270
238
|
|
|
271
239
|
if (!label) label = dayFormatter(dayKey, _long);
|
|
272
240
|
return label;
|
|
273
|
-
};
|
|
241
|
+
});
|
|
274
242
|
|
|
275
|
-
_this
|
|
243
|
+
_defineProperty(_assertThisInitialized(_this), "handleRangePaste", function (dayKeys) {
|
|
276
244
|
var rangeClipboard = _this.props.rangeClipboard;
|
|
277
245
|
var activeDays = _this.state.activeDays;
|
|
278
246
|
|
|
279
|
-
if (rangeClipboard
|
|
247
|
+
if (rangeClipboard != null && rangeClipboard.stop && rangeClipboard != null && rangeClipboard.start) {
|
|
280
248
|
activeDays.length > 1 ? _this.handleMultipleDayTimeChange([getDateFromDayValue(rangeClipboard.start), getDateFromDayValue(rangeClipboard.stop)]) : _this.handleDayTimeChange([getDateFromDayValue(rangeClipboard.start), getDateFromDayValue(rangeClipboard.stop)], dayKeys);
|
|
281
249
|
}
|
|
282
|
-
};
|
|
250
|
+
});
|
|
283
251
|
|
|
284
|
-
_this
|
|
252
|
+
_defineProperty(_assertThisInitialized(_this), "handleRangeCopy", function () {
|
|
285
253
|
var onRangeCopy = _this.props.onRangeCopy;
|
|
286
254
|
var activeDays = _this.state.activeDays;
|
|
287
255
|
|
|
@@ -291,18 +259,18 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
291
259
|
start: dayValue.start,
|
|
292
260
|
stop: dayValue.stop
|
|
293
261
|
});
|
|
294
|
-
};
|
|
262
|
+
});
|
|
295
263
|
|
|
296
|
-
_this
|
|
264
|
+
_defineProperty(_assertThisInitialized(_this), "getAllKeys", function () {
|
|
297
265
|
var _this$props7 = _this.props,
|
|
298
266
|
numberOfDays = _this$props7.numberOfDays,
|
|
299
267
|
customDays = _this$props7.customDays;
|
|
300
268
|
var keys = range(numberOfDays);
|
|
301
|
-
if (customDays) keys = [].concat(
|
|
269
|
+
if (customDays) keys = [].concat(keys, Object.keys(customDays));
|
|
302
270
|
return keys;
|
|
303
|
-
};
|
|
271
|
+
});
|
|
304
272
|
|
|
305
|
-
_this
|
|
273
|
+
_defineProperty(_assertThisInitialized(_this), "renderDay", function (dayKey) {
|
|
306
274
|
var _this$props8 = _this.props,
|
|
307
275
|
customDays = _this$props8.customDays,
|
|
308
276
|
intl = _this$props8.intl,
|
|
@@ -336,9 +304,9 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
336
304
|
onToggle: _this.handleToggleDay,
|
|
337
305
|
texts: texts
|
|
338
306
|
});
|
|
339
|
-
};
|
|
307
|
+
});
|
|
340
308
|
|
|
341
|
-
_this
|
|
309
|
+
_defineProperty(_assertThisInitialized(_this), "handleRangeAdd", function () {
|
|
342
310
|
var daily = _this.props.daily;
|
|
343
311
|
|
|
344
312
|
if (!daily && !_this.haveActiveDaysCommonRange()) {
|
|
@@ -348,9 +316,9 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
348
316
|
_this.setState({
|
|
349
317
|
isRangeDefined: true
|
|
350
318
|
});
|
|
351
|
-
};
|
|
319
|
+
});
|
|
352
320
|
|
|
353
|
-
_this
|
|
321
|
+
_defineProperty(_assertThisInitialized(_this), "renderRangeForm", function (dayKeys) {
|
|
354
322
|
var activeDays = _this.state.activeDays;
|
|
355
323
|
var _this$props9 = _this.props,
|
|
356
324
|
hideHeader = _this$props9.hideHeader,
|
|
@@ -388,9 +356,9 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
388
356
|
timePickerProps: timePickerProps,
|
|
389
357
|
valueSelectionModes: valueSelectionModes
|
|
390
358
|
});
|
|
391
|
-
};
|
|
359
|
+
});
|
|
392
360
|
|
|
393
|
-
_this
|
|
361
|
+
_defineProperty(_assertThisInitialized(_this), "haveActiveDaysCommonRange", function () {
|
|
394
362
|
var activeDays = _this.state.activeDays;
|
|
395
363
|
var days = _this.props.days;
|
|
396
364
|
var previousDay;
|
|
@@ -408,17 +376,17 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
408
376
|
return false;
|
|
409
377
|
}
|
|
410
378
|
|
|
411
|
-
var areRangeDifferent = (currentDay
|
|
379
|
+
var areRangeDifferent = (currentDay == null ? void 0 : currentDay.start) !== ((_previousDay = previousDay) == null ? void 0 : _previousDay.start) || (currentDay == null ? void 0 : currentDay.stop) !== ((_previousDay2 = previousDay) == null ? void 0 : _previousDay2.stop);
|
|
412
380
|
previousDay = currentDay;
|
|
413
381
|
return areRangeDifferent;
|
|
414
382
|
});
|
|
415
383
|
return !activeDaysHaveDifferentRanges;
|
|
416
|
-
};
|
|
384
|
+
});
|
|
417
385
|
|
|
418
|
-
_this
|
|
386
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (e) {
|
|
419
387
|
if (e.key === 'Shift') {
|
|
420
388
|
_this.setState(function (state) {
|
|
421
|
-
return _objectSpread(
|
|
389
|
+
return _objectSpread({}, state, {
|
|
422
390
|
controlKeyPressed: false,
|
|
423
391
|
shiftKeyPressed: true
|
|
424
392
|
});
|
|
@@ -427,18 +395,18 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
427
395
|
|
|
428
396
|
if (e.key === 'Control' || e.key === 'Meta') {
|
|
429
397
|
_this.setState(function (state) {
|
|
430
|
-
return _objectSpread(
|
|
398
|
+
return _objectSpread({}, state, {
|
|
431
399
|
controlKeyPressed: true,
|
|
432
400
|
shiftKeyPressed: false
|
|
433
401
|
});
|
|
434
402
|
});
|
|
435
403
|
}
|
|
436
|
-
};
|
|
404
|
+
});
|
|
437
405
|
|
|
438
|
-
_this
|
|
406
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyUp", function (e) {
|
|
439
407
|
if (e.key === 'Control' || e.key === 'Meta') {
|
|
440
408
|
_this.setState(function (state) {
|
|
441
|
-
return _objectSpread(
|
|
409
|
+
return _objectSpread({}, state, {
|
|
442
410
|
controlKeyPressed: false
|
|
443
411
|
});
|
|
444
412
|
});
|
|
@@ -446,102 +414,99 @@ var TimeWindowBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
446
414
|
|
|
447
415
|
if (e.key === 'Shift') {
|
|
448
416
|
_this.setState(function (state) {
|
|
449
|
-
return _objectSpread(
|
|
417
|
+
return _objectSpread({}, state, {
|
|
450
418
|
shiftKeyPressed: false
|
|
451
419
|
});
|
|
452
420
|
});
|
|
453
421
|
}
|
|
454
|
-
};
|
|
422
|
+
});
|
|
455
423
|
|
|
456
424
|
return _this;
|
|
457
425
|
}
|
|
458
426
|
|
|
459
|
-
|
|
460
|
-
key: "componentDidMount",
|
|
461
|
-
value: function componentDidMount() {
|
|
462
|
-
var wrapper = this.wrapperRef;
|
|
427
|
+
var _proto = TimeWindowBase.prototype;
|
|
463
428
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
429
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
430
|
+
var wrapper = this.wrapperRef;
|
|
431
|
+
|
|
432
|
+
if (wrapper != null && wrapper.current && wrapper.current !== null) {
|
|
433
|
+
// focus on wrapper to enable listening for keydown without having to click on wrapper
|
|
434
|
+
wrapper.current.focus();
|
|
468
435
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
});
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
439
|
+
var hasCommonRange = this.haveActiveDaysCommonRange();
|
|
440
|
+
|
|
441
|
+
if (prevState.isRangeDefined !== hasCommonRange) {
|
|
442
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
443
|
+
this.setState(function (state) {
|
|
444
|
+
return _objectSpread({}, state, {
|
|
445
|
+
isRangeDefined: hasCommonRange
|
|
480
446
|
});
|
|
481
|
-
}
|
|
447
|
+
});
|
|
482
448
|
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
label: intl.formatMessage({
|
|
523
|
-
id: 'DS.DATE-RANGE-PICKER.SELECTED',
|
|
524
|
-
defaultMessage: 'Selected: '
|
|
525
|
-
})
|
|
526
|
-
})
|
|
527
|
-
})), shouldRenderRangeForm && this.renderRangeForm(rangeFormKey), shouldRenderSelectionHint && /*#__PURE__*/React.createElement(SelectionHint, {
|
|
528
|
-
message: intl.formatMessage({
|
|
529
|
-
id: 'DS.DATE-RANGE-PICKER.SELECT-DAYS-DESCRIPTION'
|
|
530
|
-
})
|
|
531
|
-
}), shouldRenderAddButton && /*#__PURE__*/React.createElement(S.AddButtonWrapper, null, /*#__PURE__*/React.createElement(AddButton, {
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
_proto.render = function render() {
|
|
452
|
+
var _this$props10 = this.props,
|
|
453
|
+
days = _this$props10.days,
|
|
454
|
+
numberOfDays = _this$props10.numberOfDays,
|
|
455
|
+
daily = _this$props10.daily,
|
|
456
|
+
intl = _this$props10.intl,
|
|
457
|
+
texts = _this$props10.texts,
|
|
458
|
+
disabled = _this$props10.disabled,
|
|
459
|
+
rest = _objectWithoutPropertiesLoose(_this$props10, _excluded);
|
|
460
|
+
|
|
461
|
+
var _this$state4 = this.state,
|
|
462
|
+
activeDays = _this$state4.activeDays,
|
|
463
|
+
isRangeDefined = _this$state4.isRangeDefined;
|
|
464
|
+
var keys = this.getAllKeys();
|
|
465
|
+
var singleMode = keys.length === 1;
|
|
466
|
+
var rangeFormKey = singleMode ? keys[0] : activeDays;
|
|
467
|
+
var shouldRenderRangeForm = !!activeDays.length && isRangeDefined || !!daily;
|
|
468
|
+
var shouldRenderSelectionHint = !activeDays.length && !disabled;
|
|
469
|
+
var shouldRenderAddButton = !!activeDays.length && !daily && !isRangeDefined && !disabled;
|
|
470
|
+
return /*#__PURE__*/React.createElement(S.TimeWindowContainer, {
|
|
471
|
+
tabIndex: 0,
|
|
472
|
+
ref: this.wrapperRef,
|
|
473
|
+
onKeyDown: this.handleKeyDown,
|
|
474
|
+
onKeyUp: this.handleKeyUp
|
|
475
|
+
}, !singleMode && /*#__PURE__*/React.createElement(Grid, _extends({
|
|
476
|
+
onUnselectAll: this.handleClearSelection,
|
|
477
|
+
onSelectAll: this.handleSelectAll,
|
|
478
|
+
showUnselectAll: (activeDays == null ? void 0 : activeDays.length) > 0,
|
|
479
|
+
renderDay: this.renderDay,
|
|
480
|
+
keys: keys,
|
|
481
|
+
days: days,
|
|
482
|
+
intl: intl,
|
|
483
|
+
numberOfDays: numberOfDays,
|
|
484
|
+
texts: texts
|
|
485
|
+
}, rest, {
|
|
486
|
+
title: /*#__PURE__*/React.createElement(SelectionCount, {
|
|
487
|
+
selectedDayCount: activeDays.length,
|
|
532
488
|
label: intl.formatMessage({
|
|
533
|
-
id: 'DS.DATE-RANGE-PICKER.
|
|
534
|
-
defaultMessage: '
|
|
535
|
-
})
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
489
|
+
id: 'DS.DATE-RANGE-PICKER.SELECTED',
|
|
490
|
+
defaultMessage: 'Selected: '
|
|
491
|
+
})
|
|
492
|
+
})
|
|
493
|
+
})), shouldRenderRangeForm && this.renderRangeForm(rangeFormKey), shouldRenderSelectionHint && /*#__PURE__*/React.createElement(SelectionHint, {
|
|
494
|
+
message: intl.formatMessage({
|
|
495
|
+
id: 'DS.DATE-RANGE-PICKER.SELECT-DAYS-DESCRIPTION'
|
|
496
|
+
})
|
|
497
|
+
}), shouldRenderAddButton && /*#__PURE__*/React.createElement(S.AddButtonWrapper, null, /*#__PURE__*/React.createElement(AddButton, {
|
|
498
|
+
label: intl.formatMessage({
|
|
499
|
+
id: 'DS.DATE-RANGE-PICKER.ADD-TIME',
|
|
500
|
+
defaultMessage: 'Add time'
|
|
501
|
+
}),
|
|
502
|
+
onClick: this.handleRangeAdd
|
|
503
|
+
})));
|
|
504
|
+
};
|
|
540
505
|
|
|
541
506
|
return TimeWindowBase;
|
|
542
507
|
}(React.PureComponent);
|
|
543
508
|
|
|
544
|
-
TimeWindowBase
|
|
509
|
+
_defineProperty(TimeWindowBase, "defaultProps", {
|
|
545
510
|
days: {},
|
|
546
511
|
numberOfDays: 1,
|
|
547
512
|
showSelectAll: false,
|
|
@@ -553,8 +518,9 @@ TimeWindowBase.defaultProps = {
|
|
|
553
518
|
},
|
|
554
519
|
dayFormatter: function dayFormatter(dayKey) {
|
|
555
520
|
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
556
|
-
id: "DS.DATE-RANGE-PICKER.WEEKDAYS-SHORT-"
|
|
521
|
+
id: "DS.DATE-RANGE-PICKER.WEEKDAYS-SHORT-" + dayKey
|
|
557
522
|
});
|
|
558
523
|
}
|
|
559
|
-
};
|
|
524
|
+
});
|
|
525
|
+
|
|
560
526
|
export default injectIntl(TimeWindowBase);
|
|
@@ -7,9 +7,9 @@ var TODAY = new Date();
|
|
|
7
7
|
export var getDateFromDayValue = function getDateFromDayValue(dayValue, hourTimeFormat) {
|
|
8
8
|
var DAY_FORMAT = "YYYY-MM-DD";
|
|
9
9
|
var todayToString = dayjs(TODAY).format(DAY_FORMAT);
|
|
10
|
-
var input =
|
|
10
|
+
var input = todayToString + "-" + dayValue;
|
|
11
11
|
var hourFormat = hourTimeFormat || DEFAULT_TIME_FORMAT;
|
|
12
|
-
return dayjs(input,
|
|
12
|
+
return dayjs(input, DAY_FORMAT + "-" + hourFormat).toDate();
|
|
13
13
|
};
|
|
14
14
|
export var reverseRange = function reverseRange(inputRange, groupItem) {
|
|
15
15
|
var grouping = function grouping(item) {
|
|
@@ -10,7 +10,7 @@ export var DEFAULT_RANGE_START = '00:00:00.000';
|
|
|
10
10
|
export var DEFAULT_RANGE_END = '23:59:59.999';
|
|
11
11
|
export var MONTH_DAYS = function MONTH_DAYS(locale) {
|
|
12
12
|
return range(0, 31).map(function (i) {
|
|
13
|
-
return locale === 'pl' ?
|
|
13
|
+
return locale === 'pl' ? i + 1 + "." : fnsFormat(fnsAddDays(LONG_MONTH, i), 'Do');
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
export var DAYS_OF_PERIOD_ENUM;
|