@banyan_cloud/roots 2.0.50 → 2.0.51
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/esm/index.js +37 -124
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -586,32 +586,6 @@ function addMilliseconds(dirtyDate, dirtyAmount) {
|
|
|
586
586
|
return new Date(timestamp + amount);
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
-
var MILLISECONDS_IN_HOUR = 3600000;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* @name addHours
|
|
593
|
-
* @category Hour Helpers
|
|
594
|
-
* @summary Add the specified number of hours to the given date.
|
|
595
|
-
*
|
|
596
|
-
* @description
|
|
597
|
-
* Add the specified number of hours to the given date.
|
|
598
|
-
*
|
|
599
|
-
* @param {Date|Number} date - the date to be changed
|
|
600
|
-
* @param {Number} amount - the amount of hours to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
601
|
-
* @returns {Date} the new date with the hours added
|
|
602
|
-
* @throws {TypeError} 2 arguments required
|
|
603
|
-
*
|
|
604
|
-
* @example
|
|
605
|
-
* // Add 2 hours to 10 July 2014 23:00:00:
|
|
606
|
-
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
|
|
607
|
-
* //=> Fri Jul 11 2014 01:00:00
|
|
608
|
-
*/
|
|
609
|
-
function addHours(dirtyDate, dirtyAmount) {
|
|
610
|
-
requiredArgs(2, arguments);
|
|
611
|
-
var amount = toInteger(dirtyAmount);
|
|
612
|
-
return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_HOUR);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
589
|
var defaultOptions = {};
|
|
616
590
|
function getDefaultOptions() {
|
|
617
591
|
return defaultOptions;
|
|
@@ -704,32 +678,6 @@ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
|
|
|
704
678
|
return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY$1);
|
|
705
679
|
}
|
|
706
680
|
|
|
707
|
-
var MILLISECONDS_IN_MINUTE = 60000;
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* @name addMinutes
|
|
711
|
-
* @category Minute Helpers
|
|
712
|
-
* @summary Add the specified number of minutes to the given date.
|
|
713
|
-
*
|
|
714
|
-
* @description
|
|
715
|
-
* Add the specified number of minutes to the given date.
|
|
716
|
-
*
|
|
717
|
-
* @param {Date|Number} date - the date to be changed
|
|
718
|
-
* @param {Number} amount - the amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
719
|
-
* @returns {Date} the new date with the minutes added
|
|
720
|
-
* @throws {TypeError} 2 arguments required
|
|
721
|
-
*
|
|
722
|
-
* @example
|
|
723
|
-
* // Add 30 minutes to 10 July 2014 12:00:00:
|
|
724
|
-
* const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
|
|
725
|
-
* //=> Thu Jul 10 2014 12:30:00
|
|
726
|
-
*/
|
|
727
|
-
function addMinutes(dirtyDate, dirtyAmount) {
|
|
728
|
-
requiredArgs(2, arguments);
|
|
729
|
-
var amount = toInteger(dirtyAmount);
|
|
730
|
-
return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
681
|
/**
|
|
734
682
|
* @name compareAsc
|
|
735
683
|
* @category Common Helpers
|
|
@@ -3541,54 +3489,6 @@ function sub(date, duration) {
|
|
|
3541
3489
|
return finalDate;
|
|
3542
3490
|
}
|
|
3543
3491
|
|
|
3544
|
-
/**
|
|
3545
|
-
* @name subHours
|
|
3546
|
-
* @category Hour Helpers
|
|
3547
|
-
* @summary Subtract the specified number of hours from the given date.
|
|
3548
|
-
*
|
|
3549
|
-
* @description
|
|
3550
|
-
* Subtract the specified number of hours from the given date.
|
|
3551
|
-
*
|
|
3552
|
-
* @param {Date|Number} date - the date to be changed
|
|
3553
|
-
* @param {Number} amount - the amount of hours to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
3554
|
-
* @returns {Date} the new date with the hours subtracted
|
|
3555
|
-
* @throws {TypeError} 2 arguments required
|
|
3556
|
-
*
|
|
3557
|
-
* @example
|
|
3558
|
-
* // Subtract 2 hours from 11 July 2014 01:00:00:
|
|
3559
|
-
* const result = subHours(new Date(2014, 6, 11, 1, 0), 2)
|
|
3560
|
-
* //=> Thu Jul 10 2014 23:00:00
|
|
3561
|
-
*/
|
|
3562
|
-
function subHours(dirtyDate, dirtyAmount) {
|
|
3563
|
-
requiredArgs(2, arguments);
|
|
3564
|
-
var amount = toInteger(dirtyAmount);
|
|
3565
|
-
return addHours(dirtyDate, -amount);
|
|
3566
|
-
}
|
|
3567
|
-
|
|
3568
|
-
/**
|
|
3569
|
-
* @name subMinutes
|
|
3570
|
-
* @category Minute Helpers
|
|
3571
|
-
* @summary Subtract the specified number of minutes from the given date.
|
|
3572
|
-
*
|
|
3573
|
-
* @description
|
|
3574
|
-
* Subtract the specified number of minutes from the given date.
|
|
3575
|
-
*
|
|
3576
|
-
* @param {Date|Number} date - the date to be changed
|
|
3577
|
-
* @param {Number} amount - the amount of minutes to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
3578
|
-
* @returns {Date} the new date with the minutes subtracted
|
|
3579
|
-
* @throws {TypeError} 2 arguments required
|
|
3580
|
-
*
|
|
3581
|
-
* @example
|
|
3582
|
-
* // Subtract 30 minutes from 10 July 2014 12:00:00:
|
|
3583
|
-
* const result = subMinutes(new Date(2014, 6, 10, 12, 0), 30)
|
|
3584
|
-
* //=> Thu Jul 10 2014 11:30:00
|
|
3585
|
-
*/
|
|
3586
|
-
function subMinutes(dirtyDate, dirtyAmount) {
|
|
3587
|
-
requiredArgs(2, arguments);
|
|
3588
|
-
var amount = toInteger(dirtyAmount);
|
|
3589
|
-
return addMinutes(dirtyDate, -amount);
|
|
3590
|
-
}
|
|
3591
|
-
|
|
3592
3492
|
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
3593
3493
|
var FULL_MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
3594
3494
|
var DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
@@ -13953,7 +13853,7 @@ var DateAndTimeSelection = function DateAndTimeSelection(_ref) {
|
|
|
13953
13853
|
useEffect(function () {
|
|
13954
13854
|
setDateValue(defaultDate);
|
|
13955
13855
|
setTimeValue(defaultTime);
|
|
13956
|
-
}, [
|
|
13856
|
+
}, [defaultDate, defaultTime]);
|
|
13957
13857
|
var onDateSelectorClick = function onDateSelectorClick() {
|
|
13958
13858
|
showTimeSelectionView(false);
|
|
13959
13859
|
showDateSelectionView(function (prev) {
|
|
@@ -14040,30 +13940,8 @@ var Header$2 = function Header(props) {
|
|
|
14040
13940
|
var _ref2 = props !== null && props !== void 0 ? props : {},
|
|
14041
13941
|
range = _ref2.range,
|
|
14042
13942
|
dateSelectionView = _ref2.dateSelectionView,
|
|
14043
|
-
|
|
14044
|
-
timeSelectionView = _ref2.timeSelectionView,
|
|
14045
|
-
setTimeRangeSelection = _ref2.setTimeRangeSelection,
|
|
14046
|
-
selectedDate = _ref2.selectedDate;
|
|
13943
|
+
timeSelectionView = _ref2.timeSelectionView;
|
|
14047
13944
|
var showCarouselSwitcher = !dateSelectionView && !timeSelectionView;
|
|
14048
|
-
var currentTime = getDayInfo(new Date());
|
|
14049
|
-
if (selectedDate.unix !== undefined) {
|
|
14050
|
-
currentTime = getDayInfo(new Date(selectedDate.unix * 1000));
|
|
14051
|
-
}
|
|
14052
|
-
var prevTime = getDayInfo(subMinutes(subHours(new Date(currentTime.year, currentTime.monthAsNumber, currentTime.dateAsNumber, currentTime.hoursIn12, currentTime.minutes), defaultHourDiff !== null && defaultHourDiff !== void 0 ? defaultHourDiff : currentTime.hoursIn12), defaultHourDiff ? 0 : currentTime.minutes));
|
|
14053
|
-
useEffect(function () {
|
|
14054
|
-
setTimeRangeSelection({
|
|
14055
|
-
next: {
|
|
14056
|
-
HOURS: currentTime.hours,
|
|
14057
|
-
MINS: currentTime.minutes,
|
|
14058
|
-
MER: currentTime.meridian
|
|
14059
|
-
},
|
|
14060
|
-
previous: {
|
|
14061
|
-
HOURS: prevTime.hours,
|
|
14062
|
-
MINS: prevTime.minutes,
|
|
14063
|
-
MER: prevTime.meridian
|
|
14064
|
-
}
|
|
14065
|
-
});
|
|
14066
|
-
}, [selectedDate.unix]);
|
|
14067
13945
|
return /*#__PURE__*/jsxs("div", {
|
|
14068
13946
|
className: modules_cf337dc1.root,
|
|
14069
13947
|
children: [!range && /*#__PURE__*/jsx(DateAndTimeSelection, _objectSpread2({}, props)), showCarouselSwitcher && /*#__PURE__*/jsx(CarouselSwitch, _objectSpread2({}, props)), /*#__PURE__*/jsxs("div", {
|
|
@@ -14434,6 +14312,25 @@ var CustomRanges = function CustomRanges(_ref) {
|
|
|
14434
14312
|
});
|
|
14435
14313
|
};
|
|
14436
14314
|
|
|
14315
|
+
var getDefaultTimeRangeSelection = function getDefaultTimeRangeSelection(isToday) {
|
|
14316
|
+
var now = getDayInfo(new Date());
|
|
14317
|
+
return {
|
|
14318
|
+
previous: {
|
|
14319
|
+
HOURS: 12,
|
|
14320
|
+
MINS: 0,
|
|
14321
|
+
MER: 'AM'
|
|
14322
|
+
},
|
|
14323
|
+
next: isToday ? {
|
|
14324
|
+
HOURS: now.hours,
|
|
14325
|
+
MINS: now.minutes,
|
|
14326
|
+
MER: now.meridian
|
|
14327
|
+
} : {
|
|
14328
|
+
HOURS: 11,
|
|
14329
|
+
MINS: 59,
|
|
14330
|
+
MER: 'PM'
|
|
14331
|
+
}
|
|
14332
|
+
};
|
|
14333
|
+
};
|
|
14437
14334
|
var DatePicker = function DatePicker(props) {
|
|
14438
14335
|
var _value$filter, _datePickerFloatingRe, _datePickerFloatingRe2, _customRangeFloatingR, _customRangeFloatingR2;
|
|
14439
14336
|
var placeholder = props.placeholder,
|
|
@@ -14502,10 +14399,25 @@ var DatePicker = function DatePicker(props) {
|
|
|
14502
14399
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
14503
14400
|
error = _useState12[0],
|
|
14504
14401
|
setError = _useState12[1];
|
|
14402
|
+
var isToday = function isToday(selectedDate) {
|
|
14403
|
+
if (!selectedDate) return false;
|
|
14404
|
+
var today = new Date();
|
|
14405
|
+
return selectedDate.date === today.getDate() && selectedDate.year === today.getFullYear() && selectedDate.month === today.toLocaleString('default', {
|
|
14406
|
+
month: 'long'
|
|
14407
|
+
});
|
|
14408
|
+
};
|
|
14505
14409
|
var _useState13 = useState({}),
|
|
14506
14410
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
14507
14411
|
timeRangeSelection = _useState14[0],
|
|
14508
14412
|
setTimeRangeSelection = _useState14[1];
|
|
14413
|
+
useEffect(function () {
|
|
14414
|
+
if (!(selectedDate !== null && selectedDate !== void 0 && selectedDate.date)) return;
|
|
14415
|
+
var today = isToday(selectedDate);
|
|
14416
|
+
setTimeRangeSelection(function (prev) {
|
|
14417
|
+
if (prev !== null && prev !== void 0 && prev.previous && prev !== null && prev !== void 0 && prev.next) return prev;
|
|
14418
|
+
return getDefaultTimeRangeSelection(today);
|
|
14419
|
+
});
|
|
14420
|
+
}, [selectedDate]);
|
|
14509
14421
|
var datePickerRef = useRef();
|
|
14510
14422
|
var displayValue = getDatePickerDisplayValue({
|
|
14511
14423
|
value: value,
|
|
@@ -14574,6 +14486,7 @@ var DatePicker = function DatePicker(props) {
|
|
|
14574
14486
|
},
|
|
14575
14487
|
onClear: function onClear() {
|
|
14576
14488
|
_onClear();
|
|
14489
|
+
setTimeRangeSelection({});
|
|
14577
14490
|
setOpenDatePicker(false);
|
|
14578
14491
|
},
|
|
14579
14492
|
disabledDates: disabledDates,
|