@banyan_cloud/roots 2.0.50 → 2.0.52

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 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'];
@@ -12694,7 +12594,8 @@ var getDatePickerDisplayValue = function getDatePickerDisplayValue(_ref3) {
12694
12594
  if (timeRange) {
12695
12595
  var _sDate$getMonth$toStr2;
12696
12596
  var _sDate = fromUnixTime(value - 3600 * limitHours);
12697
- var _timeValue = "".concat(doubleDigitted((_sDate.getHours() + 11) % 12 + 1), ":").concat(doubleDigitted(_sDate.getMinutes()), " ").concat(_sDate.getHours() >= 12 ? 'PM' : 'AM');
12597
+ var eDate = fromUnixTime(value);
12598
+ var _timeValue = "".concat(doubleDigitted((_sDate.getHours() + 11) % 12 + 1), ":").concat(doubleDigitted(_sDate.getMinutes()), " ").concat(_sDate.getHours() >= 12 ? 'PM' : 'AM', " - ").concat(doubleDigitted((eDate.getHours() + 11) % 12 + 1), ":").concat(doubleDigitted(eDate.getMinutes()), " ").concat(eDate.getHours() >= 12 ? 'PM' : 'AM');
12698
12599
  return "".concat(_sDate.getDate(), " ").concat(MONTHS[(_sDate$getMonth$toStr2 = _sDate.getMonth().toString()) === null || _sDate$getMonth$toStr2 === void 0 ? void 0 : _sDate$getMonth$toStr2.substring(0, 3)], " ").concat(_sDate.getFullYear(), ", ").concat(_timeValue);
12699
12600
  }
12700
12601
  return '';
@@ -13291,6 +13192,7 @@ var ClockView = function ClockView() {
13291
13192
  setTimeRangeSelection({
13292
13193
  next: _objectSpread2(_objectSpread2({}, timeRangeSelection.next), {}, {
13293
13194
  HOURS: item === 0 ? 1 : item + limitHours,
13195
+ MINS: timeRangeSelection.previous.MINS,
13294
13196
  MER: item + limitHours >= 12 ? calculateMeridian(timeRangeSelection.previous.MER, timeRangeSelection.next.MER) : timeRangeSelection.previous.MER
13295
13197
  }),
13296
13198
  previous: _objectSpread2(_objectSpread2({}, timeRangeSelection[rangeType]), {}, {
@@ -13950,10 +13852,13 @@ var DateAndTimeSelection = function DateAndTimeSelection(_ref) {
13950
13852
  _useState4 = _slicedToArray(_useState3, 2),
13951
13853
  timeValue = _useState4[0],
13952
13854
  setTimeValue = _useState4[1];
13855
+ console.log({
13856
+ H: defaultTime
13857
+ });
13953
13858
  useEffect(function () {
13954
13859
  setDateValue(defaultDate);
13955
13860
  setTimeValue(defaultTime);
13956
- }, [selectedDate, timeRangeSelection]);
13861
+ }, [defaultDate, defaultTime]);
13957
13862
  var onDateSelectorClick = function onDateSelectorClick() {
13958
13863
  showTimeSelectionView(false);
13959
13864
  showDateSelectionView(function (prev) {
@@ -14040,30 +13945,8 @@ var Header$2 = function Header(props) {
14040
13945
  var _ref2 = props !== null && props !== void 0 ? props : {},
14041
13946
  range = _ref2.range,
14042
13947
  dateSelectionView = _ref2.dateSelectionView,
14043
- defaultHourDiff = _ref2.defaultHourDiff,
14044
- timeSelectionView = _ref2.timeSelectionView,
14045
- setTimeRangeSelection = _ref2.setTimeRangeSelection,
14046
- selectedDate = _ref2.selectedDate;
13948
+ timeSelectionView = _ref2.timeSelectionView;
14047
13949
  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
13950
  return /*#__PURE__*/jsxs("div", {
14068
13951
  className: modules_cf337dc1.root,
14069
13952
  children: [!range && /*#__PURE__*/jsx(DateAndTimeSelection, _objectSpread2({}, props)), showCarouselSwitcher && /*#__PURE__*/jsx(CarouselSwitch, _objectSpread2({}, props)), /*#__PURE__*/jsxs("div", {
@@ -14434,6 +14317,24 @@ var CustomRanges = function CustomRanges(_ref) {
14434
14317
  });
14435
14318
  };
14436
14319
 
14320
+ var getDefaultTimeRangeSelection = function getDefaultTimeRangeSelection(value, limitHours) {
14321
+ var sDate = fromUnixTime(value - 3600 * limitHours);
14322
+ var eDate = fromUnixTime(value);
14323
+ var startDateInfo = getDayInfo(sDate);
14324
+ var endDateInfo = getDayInfo(eDate);
14325
+ return {
14326
+ previous: {
14327
+ HOURS: startDateInfo.hours,
14328
+ MINS: startDateInfo.minutes,
14329
+ MER: 'AM'
14330
+ },
14331
+ next: {
14332
+ HOURS: endDateInfo.hours,
14333
+ MINS: endDateInfo.minutes,
14334
+ MER: endDateInfo.meridian
14335
+ }
14336
+ };
14337
+ };
14437
14338
  var DatePicker = function DatePicker(props) {
14438
14339
  var _value$filter, _datePickerFloatingRe, _datePickerFloatingRe2, _customRangeFloatingR, _customRangeFloatingR2;
14439
14340
  var placeholder = props.placeholder,
@@ -14506,6 +14407,11 @@ var DatePicker = function DatePicker(props) {
14506
14407
  _useState14 = _slicedToArray(_useState13, 2),
14507
14408
  timeRangeSelection = _useState14[0],
14508
14409
  setTimeRangeSelection = _useState14[1];
14410
+ useEffect(function () {
14411
+ setTimeRangeSelection(function () {
14412
+ return getDefaultTimeRangeSelection(value, limitHours);
14413
+ });
14414
+ }, [selectedDate]);
14509
14415
  var datePickerRef = useRef();
14510
14416
  var displayValue = getDatePickerDisplayValue({
14511
14417
  value: value,
@@ -14574,6 +14480,7 @@ var DatePicker = function DatePicker(props) {
14574
14480
  },
14575
14481
  onClear: function onClear() {
14576
14482
  _onClear();
14483
+ setTimeRangeSelection({});
14577
14484
  setOpenDatePicker(false);
14578
14485
  },
14579
14486
  disabledDates: disabledDates,