@banyan_cloud/roots 1.0.69 → 1.0.71

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/cjs/index.js CHANGED
@@ -41226,6 +41226,25 @@ function compareAsc(dirtyDateLeft, dirtyDateRight) {
41226
41226
  }
41227
41227
  }
41228
41228
 
41229
+ /**
41230
+ * Days in 1 week.
41231
+ *
41232
+ * @name daysInWeek
41233
+ * @constant
41234
+ * @type {number}
41235
+ * @default
41236
+ */
41237
+ /**
41238
+ * Milliseconds in 1 hour
41239
+ *
41240
+ * @name millisecondsInHour
41241
+ * @constant
41242
+ * @type {number}
41243
+ * @default
41244
+ */
41245
+
41246
+ var millisecondsInHour = 3600000;
41247
+
41229
41248
  /**
41230
41249
  * @name isSameDay
41231
41250
  * @category Day Helpers
@@ -41374,6 +41393,78 @@ function differenceInDays(dirtyDateLeft, dirtyDateRight) {
41374
41393
  return result === 0 ? 0 : result;
41375
41394
  }
41376
41395
 
41396
+ /**
41397
+ * @name differenceInMilliseconds
41398
+ * @category Millisecond Helpers
41399
+ * @summary Get the number of milliseconds between the given dates.
41400
+ *
41401
+ * @description
41402
+ * Get the number of milliseconds between the given dates.
41403
+ *
41404
+ * @param {Date|Number} dateLeft - the later date
41405
+ * @param {Date|Number} dateRight - the earlier date
41406
+ * @returns {Number} the number of milliseconds
41407
+ * @throws {TypeError} 2 arguments required
41408
+ *
41409
+ * @example
41410
+ * // How many milliseconds are between
41411
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
41412
+ * const result = differenceInMilliseconds(
41413
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
41414
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
41415
+ * )
41416
+ * //=> 1100
41417
+ */
41418
+
41419
+ function differenceInMilliseconds(dateLeft, dateRight) {
41420
+ requiredArgs(2, arguments);
41421
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
41422
+ }
41423
+
41424
+ var roundingMap = {
41425
+ ceil: Math.ceil,
41426
+ round: Math.round,
41427
+ floor: Math.floor,
41428
+ trunc: function trunc(value) {
41429
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
41430
+ } // Math.trunc is not supported by IE
41431
+
41432
+ };
41433
+ var defaultRoundingMethod = 'trunc';
41434
+ function getRoundingMethod(method) {
41435
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
41436
+ }
41437
+
41438
+ /**
41439
+ * @name differenceInHours
41440
+ * @category Hour Helpers
41441
+ * @summary Get the number of hours between the given dates.
41442
+ *
41443
+ * @description
41444
+ * Get the number of hours between the given dates.
41445
+ *
41446
+ * @param {Date|Number} dateLeft - the later date
41447
+ * @param {Date|Number} dateRight - the earlier date
41448
+ * @param {Object} [options] - an object with options.
41449
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
41450
+ * @returns {Number} the number of hours
41451
+ * @throws {TypeError} 2 arguments required
41452
+ *
41453
+ * @example
41454
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
41455
+ * const result = differenceInHours(
41456
+ * new Date(2014, 6, 2, 19, 0),
41457
+ * new Date(2014, 6, 2, 6, 50)
41458
+ * )
41459
+ * //=> 12
41460
+ */
41461
+
41462
+ function differenceInHours(dateLeft, dateRight, options) {
41463
+ requiredArgs(2, arguments);
41464
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
41465
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
41466
+ }
41467
+
41377
41468
  /**
41378
41469
  * @name endOfDay
41379
41470
  * @category Day Helpers
@@ -43428,31 +43519,28 @@ var Calender = function Calender(props) {
43428
43519
  });
43429
43520
  }
43430
43521
  };
43522
+ var commonCalenderProps = {
43523
+ selectedDate: selectedDate,
43524
+ setSelectedDate: setSelectedDate,
43525
+ selectedRange: selectedRange,
43526
+ setSelectedRange: setSelectedRange,
43527
+ range: range
43528
+ };
43431
43529
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
43432
43530
  className: modules_3722b5cd.root,
43433
43531
  children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
43434
43532
  selectedMonth: selectedMonth,
43435
43533
  onMonthChange: onMonthChange
43436
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
43534
+ }), /*#__PURE__*/jsxRuntime.jsx(Body, _objectSpread2(_objectSpread2({}, commonCalenderProps), {}, {
43437
43535
  selectedMonth: selectedMonth,
43438
- range: range,
43439
- selectedDate: selectedDate,
43440
- setSelectedDate: setSelectedDate,
43441
- selectedRange: selectedRange,
43442
- setSelectedRange: setSelectedRange,
43443
43536
  disabledDates: disabledDates,
43444
43537
  disableDatesBefore: disableDatesBefore
43445
- }), /*#__PURE__*/jsxRuntime.jsx(Footer, {
43446
- range: range,
43447
- selectedDate: selectedDate,
43448
- setSelectedDate: setSelectedDate,
43449
- selectedRange: selectedRange,
43450
- setSelectedRange: setSelectedRange,
43538
+ })), /*#__PURE__*/jsxRuntime.jsx(Footer, _objectSpread2(_objectSpread2({}, commonCalenderProps), {}, {
43451
43539
  onApply: onApply,
43452
43540
  goToDate: goToDate,
43453
43541
  customRanges: customRanges,
43454
43542
  setFixedRange: setFixedRange
43455
- })]
43543
+ }))]
43456
43544
  });
43457
43545
  };
43458
43546
 
@@ -43482,6 +43570,21 @@ var isMaxRangeExceeded = function isMaxRangeExceeded(_ref) {
43482
43570
  }
43483
43571
  return false;
43484
43572
  };
43573
+ var getDateRangeTag = function getDateRangeTag() {
43574
+ var dates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
43575
+ var _dates = _slicedToArray(dates, 2),
43576
+ startUnix = _dates[0],
43577
+ endUnix = _dates[1];
43578
+ var dayDifference = differenceInDays(fromUnixTime(endUnix), fromUnixTime(startUnix));
43579
+ var hourDifference = differenceInHours(fromUnixTime(endUnix), fromUnixTime(startUnix));
43580
+ if (hourDifference <= 24) {
43581
+ return 'hours';
43582
+ }
43583
+ if (dayDifference >= 30) {
43584
+ return 'month';
43585
+ }
43586
+ return 'day';
43587
+ };
43485
43588
 
43486
43589
  var DatePicker = function DatePicker(props) {
43487
43590
  var _value$filter;
@@ -43589,7 +43692,8 @@ var DatePicker = function DatePicker(props) {
43589
43692
  getReferenceProps = _useInteractions.getReferenceProps,
43590
43693
  getFloatingProps = _useInteractions.getFloatingProps;
43591
43694
  var apply = function apply() {
43592
- if (selectedRange.dates.length === 2) {
43695
+ var _selectedRange$dates;
43696
+ if (((_selectedRange$dates = selectedRange.dates) === null || _selectedRange$dates === void 0 ? void 0 : _selectedRange$dates.length) === 2) {
43593
43697
  if (maxRange !== null && !isMaxRangeExceeded({
43594
43698
  maxRange: maxRange,
43595
43699
  selectedRange: selectedRange
@@ -43599,7 +43703,7 @@ var DatePicker = function DatePicker(props) {
43599
43703
  return;
43600
43704
  }
43601
43705
  setError('');
43602
- onApply(selectedRange.unix, fixedRange);
43706
+ onApply(selectedRange.unix, fixedRange, getDateRangeTag(selectedRange.unix));
43603
43707
  setOpen(false);
43604
43708
  } else {
43605
43709
  onApply(selectedDate.unix);
@@ -109254,6 +109358,10 @@ var BaseMap = function BaseMap(props) {
109254
109358
  _useState2 = _slicedToArray(_useState, 2),
109255
109359
  map = _useState2[0],
109256
109360
  setMap = _useState2[1];
109361
+ var _useState3 = React.useState(null),
109362
+ _useState4 = _slicedToArray(_useState3, 2),
109363
+ activeInfoWindow = _useState4[0],
109364
+ setActiveInfoWindow = _useState4[1];
109257
109365
  React.useEffect(function () {
109258
109366
  if (ref.current && !map) {
109259
109367
  setMap(new window.google.maps.Map(ref.current, {
@@ -109324,7 +109432,9 @@ var BaseMap = function BaseMap(props) {
109324
109432
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
109325
109433
  ref: ref,
109326
109434
  style: style
109327
- }), React.Children.map(children, function (child, index) {
109435
+ }), React.Children.toArray(children).filter(function (child) {
109436
+ return /*#__PURE__*/React.isValidElement(child);
109437
+ }).map(function (child, index) {
109328
109438
  if (index === 0) {
109329
109439
  markersRef.current = [];
109330
109440
  }
@@ -109335,7 +109445,10 @@ var BaseMap = function BaseMap(props) {
109335
109445
  // set the map prop on the child component
109336
109446
  return /*#__PURE__*/React.cloneElement(child, {
109337
109447
  map: map,
109338
- ref: childRef
109448
+ ref: childRef,
109449
+ index: index,
109450
+ activeInfoWindow: activeInfoWindow,
109451
+ setActiveInfoWindow: setActiveInfoWindow
109339
109452
  });
109340
109453
  }
109341
109454
  return null;
@@ -109373,11 +109486,14 @@ Map$1.defaultProps = {
109373
109486
  libraries: undefined
109374
109487
  };
109375
109488
 
109376
- var _excluded = ["children"];
109489
+ var _excluded = ["children", "activeInfoWindow", "setActiveInfoWindow", "index"];
109377
109490
 
109378
109491
  // eslint-disable-next-line prefer-arrow-callback
109379
109492
  var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109380
109493
  var children = _ref.children,
109494
+ activeInfoWindow = _ref.activeInfoWindow,
109495
+ setActiveInfoWindow = _ref.setActiveInfoWindow,
109496
+ index = _ref.index,
109381
109497
  options = _objectWithoutProperties$1(_ref, _excluded);
109382
109498
  var _useState = React.useState(),
109383
109499
  _useState2 = _slicedToArray(_useState, 2),
@@ -109406,6 +109522,7 @@ var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109406
109522
  if (marker && React.Children.count(children) === 1 && infoWindowRef !== null && infoWindowRef !== void 0 && infoWindowRef.current) {
109407
109523
  var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109408
109524
  marker.addListener('click', function () {
109525
+ setActiveInfoWindow(index);
109409
109526
  infoWindow.open({
109410
109527
  anchor: marker,
109411
109528
  map: options.map
@@ -109418,6 +109535,12 @@ var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109418
109535
  marker.setOptions(options);
109419
109536
  }
109420
109537
  }, [marker, options]);
109538
+ React.useEffect(function () {
109539
+ if (activeInfoWindow == null || activeInfoWindow !== index) {
109540
+ var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109541
+ infoWindow.close();
109542
+ }
109543
+ }, [activeInfoWindow]);
109421
109544
  if (React.Children.count(children) === 1) {
109422
109545
  var _Children$toArray;
109423
109546
  var child = (_Children$toArray = React.Children.toArray(children)) === null || _Children$toArray === void 0 ? void 0 : _Children$toArray[0];