@onesy/ui-react 1.0.153 → 1.0.155
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/Calendar/Calendar.js
CHANGED
|
@@ -364,12 +364,12 @@ const Calendar = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
364
364
|
disabled
|
|
365
365
|
}, CalendarMonthProps);
|
|
366
366
|
const main = () => {
|
|
367
|
-
var _value
|
|
367
|
+
var _value$, _value$2;
|
|
368
368
|
switch (version) {
|
|
369
369
|
case 'year':
|
|
370
370
|
return /*#__PURE__*/_react.default.createElement(Carousel, {
|
|
371
371
|
color: "default",
|
|
372
|
-
id: value[0]
|
|
372
|
+
id: ((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.milliseconds) + (((_value$2 = value[1]) === null || _value$2 === void 0 ? void 0 : _value$2.milliseconds) || 0) + year,
|
|
373
373
|
value: carousel,
|
|
374
374
|
arrows: false,
|
|
375
375
|
progress: false,
|
|
@@ -324,14 +324,16 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
324
324
|
// make a reset, ie. make both values that same date
|
|
325
325
|
if (range) {
|
|
326
326
|
if (value.filter(Boolean).some(item => valueUpdated.year === item.year && valueUpdated.month === item.month && valueUpdated.day === item.day)) valueNew = [valueUpdated, valueUpdated];else {
|
|
327
|
+
var _value$, _value$2;
|
|
327
328
|
// Update the value closest to from, to value
|
|
328
329
|
let index;
|
|
329
330
|
|
|
330
331
|
// Update from or to
|
|
331
332
|
// based on if value is closer to the middle from, or middle to
|
|
332
|
-
if (!value[0]) index = 0;else if (!value[1]) index = 1;else if (valueUpdated.milliseconds < value[0]
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
if (!value[0]) index = 0;else if (!value[1]) index = 1;else if (valueUpdated.milliseconds < ((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.milliseconds)) index = 0;else if (valueUpdated.milliseconds > ((_value$2 = value[1]) === null || _value$2 === void 0 ? void 0 : _value$2.milliseconds)) index = 1;else {
|
|
334
|
+
var _value$3, _value$4;
|
|
335
|
+
const middle = Math.abs(value[1].milliseconds - ((_value$3 = value[0]) === null || _value$3 === void 0 ? void 0 : _value$3.milliseconds)) / 2;
|
|
336
|
+
index = valueUpdated.milliseconds <= ((_value$4 = value[0]) === null || _value$4 === void 0 ? void 0 : _value$4.milliseconds) + middle ? 0 : 1;
|
|
335
337
|
}
|
|
336
338
|
valueNew = [...value];
|
|
337
339
|
valueNew[index] = valueUpdated;
|
|
@@ -385,7 +387,7 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
385
387
|
const monthSame = ((_refs$previous$curren = refs.previous.current) === null || _refs$previous$curren === void 0 ? void 0 : _refs$previous$curren.year) === (calendar === null || calendar === void 0 ? void 0 : calendar.year) && ((_refs$previous$curren2 = refs.previous.current) === null || _refs$previous$curren2 === void 0 ? void 0 : _refs$previous$curren2.month) === (calendar === null || calendar === void 0 ? void 0 : calendar.month);
|
|
386
388
|
const getRanges = _react.default.useCallback(ranges => {
|
|
387
389
|
// Convert all ranges to start/end timestamps
|
|
388
|
-
const rangeTimestamps = ranges.map(itemRange => ({
|
|
390
|
+
const rangeTimestamps = ranges.filter(itemRange => itemRange.filter(Boolean).length).map(itemRange => ({
|
|
389
391
|
start: itemRange[0].milliseconds,
|
|
390
392
|
end: (itemRange[1] || itemRange[0]).milliseconds
|
|
391
393
|
}));
|
package/esm/Calendar/Calendar.js
CHANGED
|
@@ -320,7 +320,7 @@ const Calendar = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
320
320
|
case 'year':
|
|
321
321
|
return /*#__PURE__*/React.createElement(Carousel, {
|
|
322
322
|
color: "default",
|
|
323
|
-
id: value[0]
|
|
323
|
+
id: value[0]?.milliseconds + (value[1]?.milliseconds || 0) + year,
|
|
324
324
|
value: carousel,
|
|
325
325
|
arrows: false,
|
|
326
326
|
progress: false,
|
|
@@ -300,9 +300,9 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
300
300
|
|
|
301
301
|
// Update from or to
|
|
302
302
|
// based on if value is closer to the middle from, or middle to
|
|
303
|
-
if (!value[0]) index = 0;else if (!value[1]) index = 1;else if (valueUpdated.milliseconds < value[0]
|
|
304
|
-
const middle = Math.abs(value[1].milliseconds - value[0]
|
|
305
|
-
index = valueUpdated.milliseconds <= value[0]
|
|
303
|
+
if (!value[0]) index = 0;else if (!value[1]) index = 1;else if (valueUpdated.milliseconds < value[0]?.milliseconds) index = 0;else if (valueUpdated.milliseconds > value[1]?.milliseconds) index = 1;else {
|
|
304
|
+
const middle = Math.abs(value[1].milliseconds - value[0]?.milliseconds) / 2;
|
|
305
|
+
index = valueUpdated.milliseconds <= value[0]?.milliseconds + middle ? 0 : 1;
|
|
306
306
|
}
|
|
307
307
|
valueNew = [...value];
|
|
308
308
|
valueNew[index] = valueUpdated;
|
|
@@ -356,7 +356,7 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
356
356
|
const monthSame = refs.previous.current?.year === calendar?.year && refs.previous.current?.month === calendar?.month;
|
|
357
357
|
const getRanges = React.useCallback(ranges => {
|
|
358
358
|
// Convert all ranges to start/end timestamps
|
|
359
|
-
const rangeTimestamps = ranges.map(itemRange => ({
|
|
359
|
+
const rangeTimestamps = ranges.filter(itemRange => itemRange.filter(Boolean).length).map(itemRange => ({
|
|
360
360
|
start: itemRange[0].milliseconds,
|
|
361
361
|
end: (itemRange[1] || itemRange[0]).milliseconds
|
|
362
362
|
}));
|
package/esm/index.js
CHANGED
package/index.js
CHANGED