intelicoreact 0.0.53 → 0.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/dist/Atomic/FormElements/Input/Input.js +5 -5
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +4 -4
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +265 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +569 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +243 -0
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +486 -0
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +154 -0
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +46 -0
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +249 -0
- package/dist/Atomic/FormElements/Modal/Modal.stories.js +64 -18
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +162 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +81 -0
- package/dist/Atomic/UI/Arrow/Arrow.js +80 -0
- package/dist/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/dist/Atomic/UI/Arrow/Arrow.stories.js +46 -0
- package/dist/Atomic/UI/Button/Button.js +4 -2
- package/dist/Atomic/UI/Button/Button.scss +26 -0
- package/dist/Atomic/UI/Button/Button.stories.js +2 -2
- package/dist/Atomic/{FormElements → UI}/Calendar/Calendar.js +0 -0
- package/dist/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/dist/Atomic/{FormElements → UI}/Calendar/Calendar.stories.js +5 -1
- package/dist/Functions/utils.js +10 -2
- package/package.json +7 -5
- package/src/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/src/Atomic/FormElements/Input/Input.js +5 -5
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +6 -6
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +247 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +569 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +148 -0
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +406 -0
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +112 -0
- package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +24 -0
- package/src/Atomic/FormElements/InputDateRange/dependencies.js +161 -0
- package/src/Atomic/FormElements/Modal/Modal.stories.js +60 -15
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +143 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +54 -0
- package/src/Atomic/UI/Arrow/Arrow.js +41 -0
- package/src/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/src/Atomic/UI/Arrow/Arrow.stories.js +32 -0
- package/src/Atomic/UI/Button/Button.js +3 -3
- package/src/Atomic/UI/Button/Button.scss +26 -0
- package/src/Atomic/UI/Button/Button.stories.js +4 -3
- package/src/Atomic/{FormElements → UI}/Calendar/Calendar.js +0 -0
- package/src/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/src/Atomic/{FormElements → UI}/Calendar/Calendar.stories.js +5 -1
- package/src/Functions/utils.js +6 -0
- package/dist/Atomic/FormElements/Calendar/Calendar.scss +0 -543
- package/src/Atomic/FormElements/Calendar/Calendar.scss +0 -543
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.getActualDateRange = exports.CUSTOM_INTERVAL_KEY_TEXT = exports.CUSTOM_INTERVAL_KEY = exports.ALL_TIME_KEY = exports.INTERVALS = exports.useToggle = exports.useClickOutside = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
17
|
+
|
|
18
|
+
var _InputDateRange = _interopRequireDefault(require("./InputDateRange"));
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
var useClickOutside = function useClickOutside(hideComponent, additionalComponent) {
|
|
25
|
+
var ref = (0, _react.useRef)(null);
|
|
26
|
+
|
|
27
|
+
var checkCondition = function checkCondition(target) {
|
|
28
|
+
var _ref$current, _ref$current2;
|
|
29
|
+
|
|
30
|
+
return additionalComponent ? !((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(target)) && !(additionalComponent !== null && additionalComponent !== void 0 && additionalComponent.contains(target)) : !((_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && _ref$current2.contains(target));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var handleClickOutside = (0, _react.useCallback)(function (_ref) {
|
|
34
|
+
var target = _ref.target;
|
|
35
|
+
if (checkCondition(target)) hideComponent();
|
|
36
|
+
}, [hideComponent]);
|
|
37
|
+
(0, _react.useEffect)(function () {
|
|
38
|
+
document.addEventListener('mousedown', handleClickOutside, true);
|
|
39
|
+
return function () {
|
|
40
|
+
document.removeEventListener('mousedown', handleClickOutside, true);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
return ref;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.useClickOutside = useClickOutside;
|
|
47
|
+
|
|
48
|
+
var useToggle = function useToggle(initialState) {
|
|
49
|
+
var _useState = (0, _react.useState)(!!initialState),
|
|
50
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
|
+
isToggled = _useState2[0],
|
|
52
|
+
setToggle = _useState2[1];
|
|
53
|
+
|
|
54
|
+
var toggle = (0, _react.useCallback)(function () {
|
|
55
|
+
return setToggle(function (isOn) {
|
|
56
|
+
return !isOn;
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
var toggleOn = (0, _react.useCallback)(function () {
|
|
60
|
+
return setToggle(true);
|
|
61
|
+
}, []);
|
|
62
|
+
var toggleOff = (0, _react.useCallback)(function () {
|
|
63
|
+
return setToggle(false);
|
|
64
|
+
}, []);
|
|
65
|
+
return {
|
|
66
|
+
isToggled: isToggled,
|
|
67
|
+
toggle: toggle,
|
|
68
|
+
toggleOn: toggleOn,
|
|
69
|
+
toggleOff: toggleOff
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.useToggle = useToggle;
|
|
74
|
+
var INTERVALS = {
|
|
75
|
+
today: {
|
|
76
|
+
label: 'today',
|
|
77
|
+
start: function start() {
|
|
78
|
+
return (0, _momentTimezone.default)().startOf('day');
|
|
79
|
+
},
|
|
80
|
+
end: function end() {
|
|
81
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
yesterday: {
|
|
85
|
+
label: 'yesterday',
|
|
86
|
+
start: function start() {
|
|
87
|
+
return (0, _momentTimezone.default)().subtract(1, 'day').startOf('day');
|
|
88
|
+
},
|
|
89
|
+
end: function end() {
|
|
90
|
+
return (0, _momentTimezone.default)().startOf('day');
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
thisWeek: {
|
|
94
|
+
label: 'This Week',
|
|
95
|
+
start: function start() {
|
|
96
|
+
return (0, _momentTimezone.default)().startOf('week');
|
|
97
|
+
},
|
|
98
|
+
end: function end() {
|
|
99
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
lastWeek: {
|
|
103
|
+
label: 'Last Week',
|
|
104
|
+
start: function start() {
|
|
105
|
+
return (0, _momentTimezone.default)().subtract(1, 'week').startOf('week');
|
|
106
|
+
},
|
|
107
|
+
end: function end() {
|
|
108
|
+
return (0, _momentTimezone.default)().startOf('week');
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
last3Days: {
|
|
112
|
+
label: 'Last 3 Days',
|
|
113
|
+
start: function start() {
|
|
114
|
+
return (0, _momentTimezone.default)().subtract(2, 'day').startOf('day');
|
|
115
|
+
},
|
|
116
|
+
end: function end() {
|
|
117
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
last7Days: {
|
|
121
|
+
label: 'Last 7 Days',
|
|
122
|
+
start: function start() {
|
|
123
|
+
return (0, _momentTimezone.default)().subtract(6, 'day').startOf('day');
|
|
124
|
+
},
|
|
125
|
+
end: function end() {
|
|
126
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
last14Days: {
|
|
130
|
+
label: 'Last 14 Days',
|
|
131
|
+
start: function start() {
|
|
132
|
+
return (0, _momentTimezone.default)().subtract(13, 'day').startOf('day');
|
|
133
|
+
},
|
|
134
|
+
end: function end() {
|
|
135
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
thisMonth: {
|
|
139
|
+
label: 'This Month',
|
|
140
|
+
start: function start() {
|
|
141
|
+
return (0, _momentTimezone.default)().startOf('month');
|
|
142
|
+
},
|
|
143
|
+
end: function end() {
|
|
144
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
lastMonth: {
|
|
148
|
+
label: 'Last Month',
|
|
149
|
+
start: function start() {
|
|
150
|
+
return (0, _momentTimezone.default)().subtract(1, 'month').startOf('month');
|
|
151
|
+
},
|
|
152
|
+
end: function end() {
|
|
153
|
+
return (0, _momentTimezone.default)().startOf('month');
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
last6Months: {
|
|
157
|
+
label: 'Last 6 Months',
|
|
158
|
+
start: function start() {
|
|
159
|
+
return (0, _momentTimezone.default)().subtract(6, 'month').startOf('month');
|
|
160
|
+
},
|
|
161
|
+
end: function end() {
|
|
162
|
+
return (0, _momentTimezone.default)().startOf('month');
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
thisYear: {
|
|
166
|
+
label: 'This Year',
|
|
167
|
+
start: function start() {
|
|
168
|
+
return (0, _momentTimezone.default)().startOf('year');
|
|
169
|
+
},
|
|
170
|
+
end: function end() {
|
|
171
|
+
return (0, _momentTimezone.default)().add(1, 'day').startOf('day');
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
lastYear: {
|
|
175
|
+
label: 'Last Year',
|
|
176
|
+
start: function start() {
|
|
177
|
+
return (0, _momentTimezone.default)().subtract(1, 'year').startOf('year');
|
|
178
|
+
},
|
|
179
|
+
end: function end() {
|
|
180
|
+
return (0, _momentTimezone.default)().startOf('year');
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
allTime: {
|
|
184
|
+
label: 'All Time',
|
|
185
|
+
start: function start() {
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
188
|
+
end: function end() {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
exports.INTERVALS = INTERVALS;
|
|
194
|
+
var ALL_TIME_KEY = 'allTime';
|
|
195
|
+
exports.ALL_TIME_KEY = ALL_TIME_KEY;
|
|
196
|
+
var CUSTOM_INTERVAL_KEY = 'customDate';
|
|
197
|
+
exports.CUSTOM_INTERVAL_KEY = CUSTOM_INTERVAL_KEY;
|
|
198
|
+
var CUSTOM_INTERVAL_KEY_TEXT = 'Custom Date';
|
|
199
|
+
exports.CUSTOM_INTERVAL_KEY_TEXT = CUSTOM_INTERVAL_KEY_TEXT;
|
|
200
|
+
|
|
201
|
+
var getActualDateRange = function getActualDateRange(inputDateRange) {
|
|
202
|
+
var _INTERVALS$inputDateR, _INTERVALS$inputDateR2, _INTERVALS$inputDateR3, _INTERVALS$inputDateR4;
|
|
203
|
+
|
|
204
|
+
var actualIntervalKey = function () {
|
|
205
|
+
if (inputDateRange.intervalKey && inputDateRange.intervalKey !== CUSTOM_INTERVAL_KEY) {
|
|
206
|
+
return inputDateRange.intervalKey;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (inputDateRange.start && inputDateRange.end) {
|
|
210
|
+
for (var _i = 0, _Object$entries = Object.entries(INTERVALS); _i < _Object$entries.length; _i++) {
|
|
211
|
+
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
212
|
+
key = _Object$entries$_i[0],
|
|
213
|
+
interval = _Object$entries$_i[1];
|
|
214
|
+
|
|
215
|
+
if ((0, _momentTimezone.default)(inputDateRange.start).isSame(interval.start()) && (0, _momentTimezone.default)(inputDateRange.end).isSame(interval.end())) {
|
|
216
|
+
return key;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return null;
|
|
222
|
+
}();
|
|
223
|
+
|
|
224
|
+
if (actualIntervalKey === ALL_TIME_KEY) return {
|
|
225
|
+
intervalKey: ALL_TIME_KEY,
|
|
226
|
+
start: null,
|
|
227
|
+
end: null,
|
|
228
|
+
compare: inputDateRange.compare,
|
|
229
|
+
startPrevDate: null,
|
|
230
|
+
endPrevDate: null
|
|
231
|
+
};
|
|
232
|
+
var actualValues = {
|
|
233
|
+
// intervalKey: inputDateRange.intervalKey || customIntervalKey,
|
|
234
|
+
intervalKey: actualIntervalKey || CUSTOM_INTERVAL_KEY,
|
|
235
|
+
start: inputDateRange.intervalKey === CUSTOM_INTERVAL_KEY ? inputDateRange === null || inputDateRange === void 0 ? void 0 : inputDateRange.start : (_INTERVALS$inputDateR = INTERVALS[inputDateRange.intervalKey]) === null || _INTERVALS$inputDateR === void 0 ? void 0 : (_INTERVALS$inputDateR2 = _INTERVALS$inputDateR.start()) === null || _INTERVALS$inputDateR2 === void 0 ? void 0 : _INTERVALS$inputDateR2.toDate(),
|
|
236
|
+
end: inputDateRange.intervalKey === CUSTOM_INTERVAL_KEY ? inputDateRange === null || inputDateRange === void 0 ? void 0 : inputDateRange.end : (_INTERVALS$inputDateR3 = INTERVALS[inputDateRange.intervalKey]) === null || _INTERVALS$inputDateR3 === void 0 ? void 0 : (_INTERVALS$inputDateR4 = _INTERVALS$inputDateR3.end()) === null || _INTERVALS$inputDateR4 === void 0 ? void 0 : _INTERVALS$inputDateR4.toDate(),
|
|
237
|
+
compare: inputDateRange.compare
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
if (actualValues.compare) {
|
|
241
|
+
var intervalHoursCount = (0, _momentTimezone.default)(actualValues.end).diff(actualValues.start, 'hours');
|
|
242
|
+
actualValues.startPrevDate = (0, _momentTimezone.default)(actualValues.start).subtract(intervalHoursCount, 'hours').toDate();
|
|
243
|
+
actualValues.endPrevDate = actualValues.start;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return actualValues;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
exports.getActualDateRange = getActualDateRange;
|
|
@@ -7,7 +7,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.ModalTemplate = exports.default = void 0;
|
|
10
|
+
exports.ModalWithConfirmation = exports.ModalTemplate = exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
13
|
|
|
12
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
15
|
|
|
@@ -25,7 +27,32 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
25
27
|
|
|
26
28
|
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
29
|
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
33
|
+
|
|
28
34
|
global.lng = 'en';
|
|
35
|
+
var examples = [JSON.stringify({
|
|
36
|
+
withConfirmation: {
|
|
37
|
+
cancel: true
|
|
38
|
+
}
|
|
39
|
+
}), JSON.stringify({
|
|
40
|
+
withConfirmation: {
|
|
41
|
+
confirm: true
|
|
42
|
+
}
|
|
43
|
+
}), JSON.stringify({
|
|
44
|
+
withConfirmation: {
|
|
45
|
+
confirm: true,
|
|
46
|
+
cancel: true
|
|
47
|
+
}
|
|
48
|
+
}), JSON.stringify({
|
|
49
|
+
withConfirmation: {
|
|
50
|
+
title: 'some value',
|
|
51
|
+
children: 'some value',
|
|
52
|
+
confirmBtnLabel: 'some value'
|
|
53
|
+
}
|
|
54
|
+
})];
|
|
55
|
+
var confirmationDescrip = 'If you pass the "withConfirmation" property, you will be able to request confirmation of the user\'s action.\n\n' + "For example, if you want to request confirmation to close a modal window, pass the property like this: ".concat(examples[0], "\n\n") + "To confirm submit, pass the property like this: with Confirmation: ".concat(examples[1], "\n\n") + "If you want confirmation for each action, pass the property like this: with Confirmation: ".concat(examples[2], "\n\n") + "If you want to control the contents of the confirmation window, pass an object with values instead of boolean values, like this:\n\n".concat(examples[3], "\n\n");
|
|
29
56
|
var _default = {
|
|
30
57
|
title: 'Modal',
|
|
31
58
|
component: _Modal.default,
|
|
@@ -47,18 +74,15 @@ var _default = {
|
|
|
47
74
|
type: 'select',
|
|
48
75
|
options: ['default', '290', '420', '870', '770', '950']
|
|
49
76
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
control: {
|
|
60
|
-
type: 'select',
|
|
61
|
-
options: ['default', '290', '420', '770', '870', '950']
|
|
77
|
+
},
|
|
78
|
+
type: {
|
|
79
|
+
control: {
|
|
80
|
+
type: 'select',
|
|
81
|
+
options: ['default', 'primary']
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
withConfirmation: {
|
|
85
|
+
description: confirmationDescrip
|
|
62
86
|
}
|
|
63
87
|
}
|
|
64
88
|
};
|
|
@@ -78,11 +102,15 @@ var Template = function Template(args) {
|
|
|
78
102
|
onClick: function onClick() {
|
|
79
103
|
return setIsOpen(true);
|
|
80
104
|
},
|
|
81
|
-
|
|
82
|
-
}), /*#__PURE__*/_react.default.createElement(_Modal.default, (0, _extends2.default)({
|
|
105
|
+
text: "Show modal"
|
|
106
|
+
}), /*#__PURE__*/_react.default.createElement(_Modal.default, (0, _extends2.default)({}, args, {
|
|
83
107
|
closeModal: closeModal,
|
|
108
|
+
submitHandler: function submitHandler() {
|
|
109
|
+
args.submitHandler();
|
|
110
|
+
closeModal();
|
|
111
|
+
},
|
|
84
112
|
isOpen: isOpen
|
|
85
|
-
}
|
|
113
|
+
}), /*#__PURE__*/_react.default.createElement(_Alert.default, {
|
|
86
114
|
message: "Alert message",
|
|
87
115
|
variant: "error",
|
|
88
116
|
className: "mb5"
|
|
@@ -102,10 +130,28 @@ var Template = function Template(args) {
|
|
|
102
130
|
|
|
103
131
|
var ModalTemplate = Template.bind({});
|
|
104
132
|
exports.ModalTemplate = ModalTemplate;
|
|
105
|
-
|
|
133
|
+
var ModalWithConfirmation = Template.bind({});
|
|
134
|
+
exports.ModalWithConfirmation = ModalWithConfirmation;
|
|
135
|
+
var mainProps = {
|
|
106
136
|
title: 'Modal',
|
|
107
137
|
variant: 'primary',
|
|
108
138
|
mode: 'edit',
|
|
109
139
|
size: '',
|
|
140
|
+
confirmBtnLabel: '',
|
|
141
|
+
submitHandler: function submitHandler() {
|
|
142
|
+
console.log('Hi');
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var confirmationProps = {
|
|
146
|
+
title: '',
|
|
147
|
+
children: '',
|
|
110
148
|
confirmBtnLabel: ''
|
|
111
|
-
};
|
|
149
|
+
};
|
|
150
|
+
var confirmationVariants = {
|
|
151
|
+
// confirm: { ...confirmationProps },
|
|
152
|
+
cancel: _objectSpread({}, confirmationProps)
|
|
153
|
+
};
|
|
154
|
+
ModalTemplate.args = _objectSpread({}, mainProps);
|
|
155
|
+
ModalWithConfirmation.args = _objectSpread(_objectSpread({}, mainProps), {}, {
|
|
156
|
+
withConfirmation: _objectSpread({}, confirmationVariants)
|
|
157
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
+
|
|
20
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
21
|
+
|
|
22
|
+
var _Arrow = _interopRequireDefault(require("../../UI/Arrow/Arrow"));
|
|
23
|
+
|
|
24
|
+
require("./RangeCalendar.scss");
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
var RangeCalendar = function RangeCalendar(props) {
|
|
31
|
+
var className = props.className,
|
|
32
|
+
date = props.date,
|
|
33
|
+
setDate = props.setDate,
|
|
34
|
+
startDate = props.startDate,
|
|
35
|
+
endDate = props.endDate,
|
|
36
|
+
_props$allowPrev = props.allowPrev,
|
|
37
|
+
allowPrev = _props$allowPrev === void 0 ? true : _props$allowPrev,
|
|
38
|
+
_props$allowNext = props.allowNext,
|
|
39
|
+
allowNext = _props$allowNext === void 0 ? true : _props$allowNext,
|
|
40
|
+
_props$onClick = props.onClick,
|
|
41
|
+
onClick = _props$onClick === void 0 ? function () {} : _props$onClick,
|
|
42
|
+
_props$onHover = props.onHover,
|
|
43
|
+
onHover = _props$onHover === void 0 ? function () {} : _props$onHover,
|
|
44
|
+
startPrevDate = props.startPrevDate,
|
|
45
|
+
endPrevDate = props.endPrevDate,
|
|
46
|
+
limitRange = props.limitRange;
|
|
47
|
+
|
|
48
|
+
var _useState = (0, _react.useState)({}),
|
|
49
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
|
+
days = _useState2[0],
|
|
51
|
+
setDays = _useState2[1];
|
|
52
|
+
|
|
53
|
+
var title = (0, _react.useMemo)(function () {
|
|
54
|
+
return "".concat((0, _momentTimezone.default)(date).format('MMM'), " ").concat((0, _momentTimezone.default)(date).format('YYYY'));
|
|
55
|
+
}, [date]);
|
|
56
|
+
(0, _react.useEffect)(function () {
|
|
57
|
+
var result = {};
|
|
58
|
+
var day = (0, _momentTimezone.default)(date).startOf('month');
|
|
59
|
+
var daysInMonth = day.daysInMonth();
|
|
60
|
+
|
|
61
|
+
for (var d = 0; d < daysInMonth; d += 1) {
|
|
62
|
+
var week = day.week();
|
|
63
|
+
if (day.month() === 11 && week === 1) week = 53;
|
|
64
|
+
if (day.month() === 0 && week === 53) week = 0;
|
|
65
|
+
|
|
66
|
+
if (!Object.prototype.hasOwnProperty.call(result, week)) {
|
|
67
|
+
result[week] = {};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
result[week][day.weekday()] = {
|
|
71
|
+
date: day.toDate()
|
|
72
|
+
};
|
|
73
|
+
day.add(1, 'd');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setDays(result);
|
|
77
|
+
}, [date]);
|
|
78
|
+
|
|
79
|
+
var renderDay = function renderDay(week, dayOfWeek) {
|
|
80
|
+
var day = days[week][dayOfWeek];
|
|
81
|
+
var isFutureDay = day && (0, _momentTimezone.default)(day.date).isAfter((0, _momentTimezone.default)(), 'day');
|
|
82
|
+
var isPastDay = limitRange ? day && (0, _momentTimezone.default)(day.date).isBefore((0, _momentTimezone.default)().subtract(limitRange, 'days'), 'day') : null;
|
|
83
|
+
var isRangeStart = day && (0, _momentTimezone.default)(day.date).isSame(startDate, 'day');
|
|
84
|
+
var isRangeEnd = day && (0, _momentTimezone.default)(day.date).isSame((0, _momentTimezone.default)(endDate).subtract(1, 'hour'), 'day');
|
|
85
|
+
var isRangeInside = day && startDate && endDate && (0, _momentTimezone.default)(day.date).isAfter(startDate, 'day') && (0, _momentTimezone.default)(day.date).isBefore((0, _momentTimezone.default)(endDate).subtract(1, 'hour'), 'day');
|
|
86
|
+
var isPrevRangeEnd = day && ((0, _momentTimezone.default)(day.date).isSame(startPrevDate, 'day') || (0, _momentTimezone.default)(day.date).isSame((0, _momentTimezone.default)(endPrevDate).subtract(1, 'day'), 'day'));
|
|
87
|
+
var isPrevRangeInside = day && startPrevDate && endPrevDate && (0, _momentTimezone.default)(day.date).isAfter(startPrevDate, 'day') && (0, _momentTimezone.default)(day.date).isBefore((0, _momentTimezone.default)(endPrevDate).subtract(1, 'day'), 'day');
|
|
88
|
+
var classNames = (0, _classnames.default)('range-calendar__day', {
|
|
89
|
+
'range-calendar__day--clickable': day
|
|
90
|
+
}, {
|
|
91
|
+
'range-calendar__day--disabled': isFutureDay
|
|
92
|
+
}, {
|
|
93
|
+
'range-calendar__day--disabled': isPastDay
|
|
94
|
+
}, {
|
|
95
|
+
'range-calendar__day--range-start': isRangeStart
|
|
96
|
+
}, {
|
|
97
|
+
'range-calendar__day--range-end': isRangeEnd
|
|
98
|
+
}, {
|
|
99
|
+
'range-calendar__day--range-inside': isRangeInside
|
|
100
|
+
}, {
|
|
101
|
+
'range-calendar__day--prev-range-end': isPrevRangeEnd
|
|
102
|
+
}, {
|
|
103
|
+
'range-calendar__day--prev-range-inside': isPrevRangeInside
|
|
104
|
+
});
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
106
|
+
key: "".concat(week, "_").concat(dayOfWeek),
|
|
107
|
+
className: classNames,
|
|
108
|
+
onClick: day && !isFutureDay ? function (e) {
|
|
109
|
+
return onClick(day.date, e);
|
|
110
|
+
} : null,
|
|
111
|
+
onMouseOver: day && !isFutureDay ? function () {
|
|
112
|
+
return onHover(day.date);
|
|
113
|
+
} : null,
|
|
114
|
+
onMouseLeave: function onMouseLeave() {
|
|
115
|
+
return onHover(null);
|
|
116
|
+
}
|
|
117
|
+
}, day && day.date.getDate());
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var handlePrev = function handlePrev() {
|
|
121
|
+
setDate((0, _momentTimezone.default)(date).subtract(1, 'month').toDate());
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var handleNext = function handleNext() {
|
|
125
|
+
setDate((0, _momentTimezone.default)(date).add(1, 'month').toDate());
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
129
|
+
className: (0, _classnames.default)('range-calendar', className)
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
131
|
+
className: "range-calendar-header"
|
|
132
|
+
}, /*#__PURE__*/_react.default.createElement(_Arrow.default, {
|
|
133
|
+
type: "left",
|
|
134
|
+
disabled: !allowPrev,
|
|
135
|
+
onClick: handlePrev,
|
|
136
|
+
className: "range-calendar-header__prev"
|
|
137
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
138
|
+
className: "range-calendar-header__title"
|
|
139
|
+
}, title), /*#__PURE__*/_react.default.createElement(_Arrow.default, {
|
|
140
|
+
type: "right",
|
|
141
|
+
disabled: !allowNext,
|
|
142
|
+
onClick: handleNext,
|
|
143
|
+
className: "range-calendar-header__next"
|
|
144
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
145
|
+
className: "range-calendar__week range-calendar__week-title"
|
|
146
|
+
}, (0, _toConsumableArray2.default)(Array(7).keys()).map(function (dayOfWeek) {
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
148
|
+
key: "day-of-week_".concat(dayOfWeek),
|
|
149
|
+
className: "range-calendar__day range-calendar__day--title"
|
|
150
|
+
}, (0, _momentTimezone.default)().weekday(dayOfWeek).format('dd').charAt(0));
|
|
151
|
+
})), Object.keys(days).map(function (week, index) {
|
|
152
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
153
|
+
key: "week_".concat(index),
|
|
154
|
+
className: "range-calendar__week"
|
|
155
|
+
}, (0, _toConsumableArray2.default)(Array(7).keys()).map(function (dayOfWeek) {
|
|
156
|
+
return renderDay(week, dayOfWeek);
|
|
157
|
+
}));
|
|
158
|
+
}));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var _default = RangeCalendar;
|
|
162
|
+
exports.default = _default;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
.range-calendar {
|
|
2
|
+
width: 195px;
|
|
3
|
+
min-height: 195px;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
user-select: none;
|
|
7
|
+
|
|
8
|
+
&-header {
|
|
9
|
+
height: 24px;
|
|
10
|
+
margin-bottom: 12px;
|
|
11
|
+
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
|
|
16
|
+
&__title {
|
|
17
|
+
line-height: 20px;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
text-align: center;
|
|
20
|
+
flex-grow: 1;
|
|
21
|
+
color: #000000;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__next, &__prev {
|
|
28
|
+
width: 16px;
|
|
29
|
+
height: 16px;
|
|
30
|
+
background-color: #E2E6F8;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
color: #171D33;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__week {
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__day {
|
|
41
|
+
font-size: 13px;
|
|
42
|
+
line-height: 20px;
|
|
43
|
+
margin: 1px 0;
|
|
44
|
+
flex-grow: 1;
|
|
45
|
+
flex-basis: 0;
|
|
46
|
+
text-align: center;
|
|
47
|
+
padding: 1px 6px;
|
|
48
|
+
user-select: none;
|
|
49
|
+
|
|
50
|
+
&--clickable {
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
background: #E2E6F8;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--disabled {
|
|
59
|
+
cursor: default;
|
|
60
|
+
color: #9aa0b9;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
background: inherit;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--range-start, &--range-end {
|
|
69
|
+
background: #6B81DD;
|
|
70
|
+
color: white;
|
|
71
|
+
border-radius: 4px;
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background: #6B81DD;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--range-inside {
|
|
79
|
+
background: #E2E6F8;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&--prev-range-end {
|
|
83
|
+
background: #E2E5EC;
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--prev-range-inside {
|
|
88
|
+
background: #F7F8FA;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&--title {
|
|
92
|
+
font-size: 10px;
|
|
93
|
+
color: #9AA0B9;
|
|
94
|
+
font-weight: normal;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
background: inherit;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|