@banyan_cloud/roots 1.0.69 → 1.0.70

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
@@ -109254,6 +109254,10 @@ var BaseMap = function BaseMap(props) {
109254
109254
  _useState2 = _slicedToArray(_useState, 2),
109255
109255
  map = _useState2[0],
109256
109256
  setMap = _useState2[1];
109257
+ var _useState3 = React.useState(null),
109258
+ _useState4 = _slicedToArray(_useState3, 2),
109259
+ activeInfoWindow = _useState4[0],
109260
+ setActiveInfoWindow = _useState4[1];
109257
109261
  React.useEffect(function () {
109258
109262
  if (ref.current && !map) {
109259
109263
  setMap(new window.google.maps.Map(ref.current, {
@@ -109324,7 +109328,9 @@ var BaseMap = function BaseMap(props) {
109324
109328
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
109325
109329
  ref: ref,
109326
109330
  style: style
109327
- }), React.Children.map(children, function (child, index) {
109331
+ }), React.Children.toArray(children).filter(function (child) {
109332
+ return /*#__PURE__*/React.isValidElement(child);
109333
+ }).map(function (child, index) {
109328
109334
  if (index === 0) {
109329
109335
  markersRef.current = [];
109330
109336
  }
@@ -109335,7 +109341,10 @@ var BaseMap = function BaseMap(props) {
109335
109341
  // set the map prop on the child component
109336
109342
  return /*#__PURE__*/React.cloneElement(child, {
109337
109343
  map: map,
109338
- ref: childRef
109344
+ ref: childRef,
109345
+ index: index,
109346
+ activeInfoWindow: activeInfoWindow,
109347
+ setActiveInfoWindow: setActiveInfoWindow
109339
109348
  });
109340
109349
  }
109341
109350
  return null;
@@ -109373,11 +109382,14 @@ Map$1.defaultProps = {
109373
109382
  libraries: undefined
109374
109383
  };
109375
109384
 
109376
- var _excluded = ["children"];
109385
+ var _excluded = ["children", "activeInfoWindow", "setActiveInfoWindow", "index"];
109377
109386
 
109378
109387
  // eslint-disable-next-line prefer-arrow-callback
109379
109388
  var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109380
109389
  var children = _ref.children,
109390
+ activeInfoWindow = _ref.activeInfoWindow,
109391
+ setActiveInfoWindow = _ref.setActiveInfoWindow,
109392
+ index = _ref.index,
109381
109393
  options = _objectWithoutProperties$1(_ref, _excluded);
109382
109394
  var _useState = React.useState(),
109383
109395
  _useState2 = _slicedToArray(_useState, 2),
@@ -109406,6 +109418,7 @@ var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109406
109418
  if (marker && React.Children.count(children) === 1 && infoWindowRef !== null && infoWindowRef !== void 0 && infoWindowRef.current) {
109407
109419
  var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109408
109420
  marker.addListener('click', function () {
109421
+ setActiveInfoWindow(index);
109409
109422
  infoWindow.open({
109410
109423
  anchor: marker,
109411
109424
  map: options.map
@@ -109418,6 +109431,12 @@ var Marker = /*#__PURE__*/React.forwardRef(function Marker(_ref, ref) {
109418
109431
  marker.setOptions(options);
109419
109432
  }
109420
109433
  }, [marker, options]);
109434
+ React.useEffect(function () {
109435
+ if (activeInfoWindow == null || activeInfoWindow !== index) {
109436
+ var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109437
+ infoWindow.close();
109438
+ }
109439
+ }, [activeInfoWindow]);
109421
109440
  if (React.Children.count(children) === 1) {
109422
109441
  var _Children$toArray;
109423
109442
  var child = (_Children$toArray = React.Children.toArray(children)) === null || _Children$toArray === void 0 ? void 0 : _Children$toArray[0];