@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/esm/index.js CHANGED
@@ -109234,6 +109234,10 @@ var BaseMap = function BaseMap(props) {
109234
109234
  _useState2 = _slicedToArray(_useState, 2),
109235
109235
  map = _useState2[0],
109236
109236
  setMap = _useState2[1];
109237
+ var _useState3 = useState(null),
109238
+ _useState4 = _slicedToArray(_useState3, 2),
109239
+ activeInfoWindow = _useState4[0],
109240
+ setActiveInfoWindow = _useState4[1];
109237
109241
  useEffect(function () {
109238
109242
  if (ref.current && !map) {
109239
109243
  setMap(new window.google.maps.Map(ref.current, {
@@ -109304,7 +109308,9 @@ var BaseMap = function BaseMap(props) {
109304
109308
  children: [/*#__PURE__*/jsx("div", {
109305
109309
  ref: ref,
109306
109310
  style: style
109307
- }), Children.map(children, function (child, index) {
109311
+ }), Children.toArray(children).filter(function (child) {
109312
+ return /*#__PURE__*/isValidElement(child);
109313
+ }).map(function (child, index) {
109308
109314
  if (index === 0) {
109309
109315
  markersRef.current = [];
109310
109316
  }
@@ -109315,7 +109321,10 @@ var BaseMap = function BaseMap(props) {
109315
109321
  // set the map prop on the child component
109316
109322
  return /*#__PURE__*/cloneElement(child, {
109317
109323
  map: map,
109318
- ref: childRef
109324
+ ref: childRef,
109325
+ index: index,
109326
+ activeInfoWindow: activeInfoWindow,
109327
+ setActiveInfoWindow: setActiveInfoWindow
109319
109328
  });
109320
109329
  }
109321
109330
  return null;
@@ -109353,11 +109362,14 @@ Map$1.defaultProps = {
109353
109362
  libraries: undefined
109354
109363
  };
109355
109364
 
109356
- var _excluded = ["children"];
109365
+ var _excluded = ["children", "activeInfoWindow", "setActiveInfoWindow", "index"];
109357
109366
 
109358
109367
  // eslint-disable-next-line prefer-arrow-callback
109359
109368
  var Marker = /*#__PURE__*/forwardRef(function Marker(_ref, ref) {
109360
109369
  var children = _ref.children,
109370
+ activeInfoWindow = _ref.activeInfoWindow,
109371
+ setActiveInfoWindow = _ref.setActiveInfoWindow,
109372
+ index = _ref.index,
109361
109373
  options = _objectWithoutProperties$1(_ref, _excluded);
109362
109374
  var _useState = useState(),
109363
109375
  _useState2 = _slicedToArray(_useState, 2),
@@ -109386,6 +109398,7 @@ var Marker = /*#__PURE__*/forwardRef(function Marker(_ref, ref) {
109386
109398
  if (marker && Children.count(children) === 1 && infoWindowRef !== null && infoWindowRef !== void 0 && infoWindowRef.current) {
109387
109399
  var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109388
109400
  marker.addListener('click', function () {
109401
+ setActiveInfoWindow(index);
109389
109402
  infoWindow.open({
109390
109403
  anchor: marker,
109391
109404
  map: options.map
@@ -109398,6 +109411,12 @@ var Marker = /*#__PURE__*/forwardRef(function Marker(_ref, ref) {
109398
109411
  marker.setOptions(options);
109399
109412
  }
109400
109413
  }, [marker, options]);
109414
+ useEffect(function () {
109415
+ if (activeInfoWindow == null || activeInfoWindow !== index) {
109416
+ var infoWindow = infoWindowRef === null || infoWindowRef === void 0 ? void 0 : infoWindowRef.current;
109417
+ infoWindow.close();
109418
+ }
109419
+ }, [activeInfoWindow]);
109401
109420
  if (Children.count(children) === 1) {
109402
109421
  var _Children$toArray;
109403
109422
  var child = (_Children$toArray = Children.toArray(children)) === null || _Children$toArray === void 0 ? void 0 : _Children$toArray[0];