@abcagency/hc-ui-components 1.3.4 → 1.3.6

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.
@@ -51,12 +51,12 @@ var Map = function Map(_ref) {
51
51
  }
52
52
  };
53
53
  useEffect(function () {
54
- if (mapContainerRef.current) {
54
+ var current = mapContainerRef.current;
55
+ if (current) {
55
56
  var handleScroll = function handleScroll() {
56
57
  setMapInteracted(true);
57
58
  };
58
- var mapContainerRefCurrent = mapContainerRef.current;
59
- mapContainerRef.current.addEventListener('wheel', handleScroll);
59
+ current.addEventListener('wheel', handleScroll);
60
60
  return function () {
61
61
  return mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
62
62
  };
@@ -64,12 +64,12 @@ var Map = function Map(_ref) {
64
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
65
65
  }, [mapContainerRef.current]);
66
66
  useEffect(function () {
67
- if (mapRef.current) {
68
- var mapInstance = mapRef.current;
69
- var dragStartListener = mapInstance.addListener('dragstart', function () {
67
+ var current = mapContainerRef.current;
68
+ if (current) {
69
+ var dragStartListener = current.addListener('dragstart', function () {
70
70
  return setMapInteracted(true);
71
71
  });
72
- var mouseDownListener = mapInstance.addListener('mousedown', function () {
72
+ var mouseDownListener = current.addListener('mousedown', function () {
73
73
  return setMapInteracted(true);
74
74
  });
75
75
  return function () {
@@ -78,35 +78,39 @@ var Map = function Map(_ref) {
78
78
  };
79
79
  }
80
80
  // eslint-disable-next-line react-hooks/exhaustive-deps
81
- }, [mapRef.current, mapContainerRef.current]);
81
+ }, [mapContainerRef.current]);
82
82
  useEffect(function () {
83
- if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
84
- fitBounds(mapRef.current);
83
+ var current = mapRef.current;
84
+ if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {
85
+ fitBounds(current);
85
86
  }
86
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
87
88
  }, [mapItems, mapRef.current, location]);
88
89
  useEffect(function () {
89
- if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
90
- fitBounds(mapRef.current, true);
90
+ var current = mapRef.current;
91
+ if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && current && mapInteracted) {
92
+ fitBounds(current, true);
91
93
  }
92
- if (mapRef.current) {
93
- var currZoom = mapRef.current.zoom;
94
+ if (current) {
95
+ var currZoom = current.zoom;
94
96
  var setZoomVal = currZoom < 13 ? currZoom : 12;
95
- mapRef.current.setZoom(setZoomVal);
97
+ current.setZoom(setZoomVal);
96
98
  }
97
99
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
100
  }, [filteredListings]);
99
101
  useEffect(function () {
100
- if (!mapRef.current || !location || mapInteracted) return;
101
- mapRef.current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
102
- if (mapRef.current) {
102
+ var current = mapRef.current;
103
+ if (!current || !location || mapInteracted) return;
104
+ current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
105
+ if (current) {
103
106
  var setZoomVal = zoom < 13 ? zoom : 12;
104
- mapRef.current.setZoom(setZoomVal);
107
+ current.setZoom(setZoomVal);
105
108
  }
106
109
  // eslint-disable-next-line react-hooks/exhaustive-deps
107
110
  }, [location, zoom, mapRef.current]);
108
111
  var fitBounds = function fitBounds(map) {
109
112
  var overload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
113
+ var current = mapRef.current;
110
114
  if ((mapInteracted === false || overload) && mapItems != null) {
111
115
  var bounds = new window.google.maps.LatLngBounds();
112
116
  mapItems.forEach(function (item) {
@@ -115,8 +119,8 @@ var Map = function Map(_ref) {
115
119
  if (!map) return;
116
120
  map.fitBounds(bounds);
117
121
  }
118
- if (mapRef.current.zoom > 17) {
119
- mapRef.current.setZoom(16);
122
+ if (current.zoom > 17) {
123
+ current.setZoom(16);
120
124
  }
121
125
  };
122
126
  var markerClickHandler = function markerClickHandler(mapLocation) {
@@ -124,15 +128,16 @@ var Map = function Map(_ref) {
124
128
  selectLocationEntity(mapLocation);
125
129
  };
126
130
  var onLoad = function onLoad(map) {
131
+ var current = mapRef.current;
127
132
  if (!location || location === null) {
128
- mapRef.current = map;
133
+ current = map;
129
134
  fitBounds(map, true);
130
135
  return;
131
136
  }
132
- mapRef.current = map;
137
+ current = map;
133
138
  if (mapInteracted === false) {
134
- mapRef.current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
135
- mapRef.current.setZoom(zoom);
139
+ current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
140
+ current.setZoom(zoom);
136
141
  }
137
142
  };
138
143
  var pinIconUrl = pinIcon({
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["/* eslint-disable no-undef */\nimport React, { useEffect, useRef } from 'react';\nimport { GoogleMap, MarkerClustererF } from \"@react-google-maps/api\";\n\nimport MapMarker from \"~/components/modules/maps/map-marker\";\nimport PlaceMarker from \"~/components/modules/maps/place-marker\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nimport { usePlaces } from \"~/contexts/placesContext\";\nimport { useMap } from \"~/contexts/mapContext\";\nimport { useMapList } from \"~/contexts/mapListContext\";\n\nimport { markerIconSelected, markerIcon, pinIcon } from \"~/util/mapIconUtil\";\nimport { clusterOptions } from \"~/util/mapUtil\";\n\nconst Map = ({\n\tmarkerConfigs,\n\tinfoWindowClasses,\n\tclusterGridSize = 60\n}) => {\n\tconst {\n\t\tlocation,\n\t\tzoom,\n\t\tcenter,\n\t\tselectLocationEntity,\n\t\tsetLocation,\n\t\tmapInteracted,\n\t\tsetMapInteracted\n\t} = useMap();\n\n\tconst {\n\t\tmapItems, filteredListings, setSelectedFilters,\n\t\tsetQuery\n\t} = useMapList();\n\n\tconst mapRef = useRef();\n\tconst markerRefs = useRef({});\n\tconst mapContainerRef = useRef(null);\n\tconst {\n\t\tpoiMarkers,\n\t\tsetCurrentCenter,\n\t\tcurrentCenter,\n\t\tsetCurrentZoom,\n\t\tcurrentZoom,\n\t\tselectedPlaceMarker,\n\t\tsetSelectedPlaceMarker,\n\t\tplacesWindow,\n\t\tsetPlacesWindow } = usePlaces();\n\n\tconst onIdle = () => {\n\t\tif (!currentCenter || !mapRef.current) return;\n\t\tconst newCenter = mapRef.current.getCenter().toJSON();\n\t\tconst newZoom = mapRef.current.zoom;\n\n\t\tsetCurrentCenter(newCenter);\n\n\t\tif (newZoom != currentZoom) {\n\t\t\tsetCurrentZoom(newZoom);\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tif (mapContainerRef.current) {\n\t\t\tconst handleScroll = () => {\n\t\t\t\tsetMapInteracted(true);\n\t\t\t};\n\t\t\tvar mapContainerRefCurrent = mapContainerRef.current;\n\t\t\tmapContainerRef.current.addEventListener('wheel', handleScroll);\n\t\t\treturn () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tif (mapRef.current) {\n\t\t\tconst mapInstance = mapRef.current;\n\t\t\tconst dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));\n\t\t\tconst mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));\n\t\t\treturn () => {\n\t\t\t\tgoogle.maps.event.removeListener(dragStartListener);\n\t\t\t\tgoogle.maps.event.removeListener(mouseDownListener);\n\t\t\t};\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapRef.current, mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tif ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {\n\t\t\tfitBounds(mapRef.current);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapItems, mapRef.current, location]);\n\n\tuseEffect(() => {\n\t\tif (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {\n\t\t\tfitBounds(mapRef.current, true);\n\t\t}\n\t\tif (mapRef.current) {\n\t\t\tlet currZoom = mapRef.current.zoom;\n\t\t\tlet setZoomVal = currZoom < 13 ? currZoom : 12;\n\t\t\tmapRef.current.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [filteredListings]);\n\n\tuseEffect(() => {\n\t\tif (!mapRef.current || !location || mapInteracted) return;\n\t\tmapRef.current.panTo(\n\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t);\n\t\tif (mapRef.current) {\n\t\t\tlet setZoomVal = zoom < 13 ? zoom : 12;\n\t\t\tmapRef.current.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [location, zoom, mapRef.current]);\n\n\tconst fitBounds = (map, overload = false) => {\n\t\tif ((mapInteracted === false || overload) && mapItems != null) {\n\t\t\tconst bounds = new window.google.maps.LatLngBounds();\n\t\t\tmapItems.forEach(item => {\n\t\t\t\tbounds.extend(new google.maps.LatLng(item.latitude, item.longitude));\n\t\t\t});\n\t\t\tif (!map) return;\n\t\t\tmap.fitBounds(bounds);\n\t\t}\n\t\tif (mapRef.current.zoom > 17) {\n\t\t\tmapRef.current.setZoom(16);\n\t\t}\n\t};\n\n\tconst markerClickHandler = mapLocation => {\n\t\tsetMapInteracted(true);\n\t\tselectLocationEntity(mapLocation);\n\t};\n\n\tconst onLoad = map => {\n\t\tif (!location || location === null) {\n\t\t\tmapRef.current = map;\n\t\t\tfitBounds(map, true);\n\t\t\treturn;\n\t\t}\n\t\tmapRef.current = map;\n\n\t\tif (mapInteracted === false) {\n\t\t\tmapRef.current.panTo(\n\t\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t\t);\n\n\t\t\tmapRef.current.setZoom(zoom);\n\t\t}\n\t};\n\n\tconst pinIconUrl = pinIcon({\n\t\tfillColor: markerConfigs.fillColor,\n\t\tstrokeColor: markerConfigs.strokeColor\n\t});\n\n\treturn (\n\t\t<>{zoom && center && <div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t<GoogleMap\n\t\t\t\tzoom={zoom}\n\t\t\t\tonLoad={onLoad}\n\t\t\t\tonIdle={onIdle}\n\t\t\t\tcenter={center}\n\t\t\t\tmapContainerStyle={{\n\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\theight: \"100%\"\n\t\t\t\t}}\n\t\t\t\toptions={{\n\t\t\t\t\tstyles: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>\n\t\t\t\t\t{clusterer => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{mapItems.map(item => (\n\t\t\t\t\t\t\t\t<MapMarker\n\t\t\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\tselectedLocation={location}\n\t\t\t\t\t\t\t\t\tmarkerRefs={markerRefs}\n\t\t\t\t\t\t\t\t\tinfoWindowClasses={infoWindowClasses}\n\t\t\t\t\t\t\t\t\tsetSelectedLocation={setLocation}\n\t\t\t\t\t\t\t\t\tmarkerClickHandler={markerClickHandler}\n\t\t\t\t\t\t\t\t\tclusterer={clusterer}\n\t\t\t\t\t\t\t\t\tmarkerIcon={markerIcon(markerConfigs)}\n\t\t\t\t\t\t\t\t\tmarkerIconSelected={markerIconSelected(markerConfigs)}\n\t\t\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t{poiMarkers && poiMarkers.markers.map((marker, index) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<PlaceMarker\n\t\t\t\t\t\t\t\t\t\tkey={`marker-${marker.title}-${index}`}\n\t\t\t\t\t\t\t\t\t\tmarker={marker}\n\t\t\t\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\t\t\t\tselectedPlaceMarker={selectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\tplacesWindow={placesWindow}\n\t\t\t\t\t\t\t\t\t\tsetPlacesWindow={setPlacesWindow}\n\t\t\t\t\t\t\t\t\t\tsetSelectedPlaceMarker={setSelectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</MarkerClustererF>\n\t\t\t</GoogleMap>\n\t\t\t{mapInteracted && markerConfigs && (\n\t\t\t\t<ShowAllButton\n\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\tlistingCount={filteredListings.length}\n\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t\t}\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","markerConfigs","infoWindowClasses","_ref$clusterGridSize","clusterGridSize","_useMap","useMap","location","zoom","center","selectLocationEntity","setLocation","mapInteracted","setMapInteracted","_useMapList","useMapList","mapItems","filteredListings","setSelectedFilters","setQuery","mapRef","useRef","markerRefs","mapContainerRef","_usePlaces","usePlaces","poiMarkers","setCurrentCenter","currentCenter","setCurrentZoom","currentZoom","selectedPlaceMarker","setSelectedPlaceMarker","placesWindow","setPlacesWindow","onIdle","current","newCenter","getCenter","toJSON","newZoom","useEffect","handleScroll","mapContainerRefCurrent","addEventListener","removeEventListener","mapInstance","dragStartListener","addListener","mouseDownListener","google","maps","event","removeListener","length","fitBounds","currZoom","setZoomVal","setZoom","panTo","LatLng","latitude","longitude","map","overload","arguments","undefined","bounds","window","LatLngBounds","forEach","item","extend","markerClickHandler","mapLocation","onLoad","pinIconUrl","pinIcon","fillColor","strokeColor","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","MarkerClustererF","clusterOptions","clusterer","MapMarker","key","id","selectedLocation","setSelectedLocation","markerIcon","markerIconSelected","markers","marker","index","PlaceMarker","concat","title","ShowAllButton","listingCount"],"mappings":";;;;;;;;;;;AAAA;AAeA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAIH;AAAA,EAAA,IAHLC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IAAAC,oBAAA,GAAAH,IAAA,CACjBI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,oBAAA,CAAA;AAEpB,EAAA,IAAAE,OAAA,GAQIC,MAAM,EAAE;IAPXC,QAAQ,GAAAF,OAAA,CAARE,QAAQ;IACRC,IAAI,GAAAH,OAAA,CAAJG,IAAI;IACJC,MAAM,GAAAJ,OAAA,CAANI,MAAM;IACNC,oBAAoB,GAAAL,OAAA,CAApBK,oBAAoB;IACpBC,WAAW,GAAAN,OAAA,CAAXM,WAAW;IACXC,aAAa,GAAAP,OAAA,CAAbO,aAAa;IACbC,gBAAgB,GAAAR,OAAA,CAAhBQ,gBAAgB,CAAA;AAGjB,EAAA,IAAAC,WAAA,GAGIC,UAAU,EAAE;IAFfC,QAAQ,GAAAF,WAAA,CAARE,QAAQ;IAAEC,gBAAgB,GAAAH,WAAA,CAAhBG,gBAAgB;IAAEC,kBAAkB,GAAAJ,W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aAAA,CAAC2B,WAAW,EAAA;QACXT,GAAG,EAAA,SAAA,CAAAU,MAAA,CAAYH,MAAM,CAACI,KAAK,EAAAD,GAAAA,CAAAA,CAAAA,MAAA,CAAIF,KAAK,CAAG;AACvCD,QAAAA,MAAM,EAAEA,MAAO;AACfC,QAAAA,KAAK,EAAEA,KAAM;AACb5E,QAAAA,mBAAmB,EAAEA,mBAAoB;AACzCE,QAAAA,YAAY,EAAEA,YAAa;AAC3BC,QAAAA,eAAe,EAAEA,eAAgB;AACjCF,QAAAA,sBAAsB,EAAEA,sBAAAA;AAAuB,OAC/C,CAAC,CAAA;AAEJ,KAAC,CACA,CAAC,CAAA;GAEa,CACR,CAAC,EACXpB,aAAa,IAAIX,aAAa,iBAC9B+E,KAAA,CAAAC,aAAA,CAAC8B,aAAa,EAAA;AACbnG,IAAAA,aAAa,EAAEA,aAAc;AAC7BX,IAAAA,aAAa,EAAEA,aAAc;AAC7BY,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnC0C,IAAAA,SAAS,EAAEA,SAAU;AACrBnC,IAAAA,MAAM,EAAEA,MAAO;AACfwD,IAAAA,UAAU,EAAEA,UAAW;AACvBzD,IAAAA,QAAQ,EAAEA,QAAS;IACnB6F,YAAY,EAAE/F,gBAAgB,CAACqC,MAAO;AACtCpC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CAEH,CAAC,CAAA;AAEL;;;;"}
1
+ {"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["/* eslint-disable no-undef */\nimport React, { useEffect, useRef } from 'react';\nimport { GoogleMap, MarkerClustererF } from \"@react-google-maps/api\";\n\nimport MapMarker from \"~/components/modules/maps/map-marker\";\nimport PlaceMarker from \"~/components/modules/maps/place-marker\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nimport { usePlaces } from \"~/contexts/placesContext\";\nimport { useMap } from \"~/contexts/mapContext\";\nimport { useMapList } from \"~/contexts/mapListContext\";\n\nimport { markerIconSelected, markerIcon, pinIcon } from \"~/util/mapIconUtil\";\nimport { clusterOptions } from \"~/util/mapUtil\";\n\nconst Map = ({\n\tmarkerConfigs,\n\tinfoWindowClasses,\n\tclusterGridSize = 60\n}) => {\n\tconst {\n\t\tlocation,\n\t\tzoom,\n\t\tcenter,\n\t\tselectLocationEntity,\n\t\tsetLocation,\n\t\tmapInteracted,\n\t\tsetMapInteracted\n\t} = useMap();\n\n\tconst {\n\t\tmapItems, filteredListings, setSelectedFilters,\n\t\tsetQuery\n\t} = useMapList();\n\n\tconst mapRef = useRef();\n\tconst markerRefs = useRef({});\n\tconst mapContainerRef = useRef(null);\n\tconst {\n\t\tpoiMarkers,\n\t\tsetCurrentCenter,\n\t\tcurrentCenter,\n\t\tsetCurrentZoom,\n\t\tcurrentZoom,\n\t\tselectedPlaceMarker,\n\t\tsetSelectedPlaceMarker,\n\t\tplacesWindow,\n\t\tsetPlacesWindow } = usePlaces();\n\n\tconst onIdle = () => {\n\t\tif (!currentCenter || !mapRef.current) return;\n\t\tconst newCenter = mapRef.current.getCenter().toJSON();\n\t\tconst newZoom = mapRef.current.zoom;\n\n\t\tsetCurrentCenter(newCenter);\n\n\t\tif (newZoom != currentZoom) {\n\t\t\tsetCurrentZoom(newZoom);\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tconst { current } = mapContainerRef;\n\t\tif (current) {\n\t\t\tconst handleScroll = () => {\n\t\t\t\tsetMapInteracted(true);\n\t\t\t};\n\t\t\tcurrent.addEventListener('wheel', handleScroll);\n\t\t\treturn () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapContainerRef;\n\t\tif (current) {\n\t\t\tconst dragStartListener = current.addListener('dragstart', () => setMapInteracted(true));\n\t\t\tconst mouseDownListener = current.addListener('mousedown', () => setMapInteracted(true));\n\t\t\treturn () => {\n\t\t\t\tgoogle.maps.event.removeListener(dragStartListener);\n\t\t\t\tgoogle.maps.event.removeListener(mouseDownListener);\n\t\t\t};\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {\n\t\t\tfitBounds(current);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapItems, mapRef.current, location]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && current && mapInteracted) {\n\t\t\tfitBounds(current, true);\n\t\t}\n\t\tif (current) {\n\t\t\tlet currZoom = current.zoom;\n\t\t\tlet setZoomVal = currZoom < 13 ? currZoom : 12;\n\t\t\tcurrent.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [filteredListings]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif (!current || !location || mapInteracted) return;\n\t\tcurrent.panTo(\n\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t);\n\t\tif (current) {\n\t\t\tlet setZoomVal = zoom < 13 ? zoom : 12;\n\t\t\tcurrent.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [location, zoom, mapRef.current]);\n\n\tconst fitBounds = (map, overload = false) => {\n\t\tconst { current } = mapRef;\n\t\tif ((mapInteracted === false || overload) && mapItems != null) {\n\t\t\tconst bounds = new window.google.maps.LatLngBounds();\n\t\t\tmapItems.forEach(item => {\n\t\t\t\tbounds.extend(new google.maps.LatLng(item.latitude, item.longitude));\n\t\t\t});\n\t\t\tif (!map) return;\n\t\t\tmap.fitBounds(bounds);\n\t\t}\n\t\tif (current.zoom > 17) {\n\t\t\tcurrent.setZoom(16);\n\t\t}\n\t};\n\n\tconst markerClickHandler = mapLocation => {\n\t\tsetMapInteracted(true);\n\t\tselectLocationEntity(mapLocation);\n\t};\n\n\tconst onLoad = map => {\n\t\tlet { current } = mapRef;\n\t\tif (!location || location === null) {\n\t\t\tcurrent = map;\n\t\t\tfitBounds(map, true);\n\t\t\treturn;\n\t\t}\n\t\tcurrent = map;\n\n\t\tif (mapInteracted === false) {\n\t\t\tcurrent.panTo(\n\t\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t\t);\n\n\t\t\tcurrent.setZoom(zoom);\n\t\t}\n\t};\n\n\tconst pinIconUrl = pinIcon({\n\t\tfillColor: markerConfigs.fillColor,\n\t\tstrokeColor: markerConfigs.strokeColor\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{zoom && center && <div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t\t<GoogleMap\n\t\t\t\t\tzoom={zoom}\n\t\t\t\t\tonLoad={onLoad}\n\t\t\t\t\tonIdle={onIdle}\n\t\t\t\t\tcenter={center}\n\t\t\t\t\tmapContainerStyle={{\n\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\theight: \"100%\"\n\t\t\t\t\t}}\n\t\t\t\t\toptions={{\n\t\t\t\t\t\tstyles: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>\n\t\t\t\t\t\t{clusterer => (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{mapItems.map(item => (\n\t\t\t\t\t\t\t\t\t<MapMarker\n\t\t\t\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\t\tselectedLocation={location}\n\t\t\t\t\t\t\t\t\t\tmarkerRefs={markerRefs}\n\t\t\t\t\t\t\t\t\t\tinfoWindowClasses={infoWindowClasses}\n\t\t\t\t\t\t\t\t\t\tsetSelectedLocation={setLocation}\n\t\t\t\t\t\t\t\t\t\tmarkerClickHandler={markerClickHandler}\n\t\t\t\t\t\t\t\t\t\tclusterer={clusterer}\n\t\t\t\t\t\t\t\t\t\tmarkerIcon={markerIcon(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\tmarkerIconSelected={markerIconSelected(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t{poiMarkers && poiMarkers.markers.map((marker, index) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<PlaceMarker\n\t\t\t\t\t\t\t\t\t\t\tkey={`marker-${marker.title}-${index}`}\n\t\t\t\t\t\t\t\t\t\t\tmarker={marker}\n\t\t\t\t\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\t\t\t\t\tselectedPlaceMarker={selectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\t\tplacesWindow={placesWindow}\n\t\t\t\t\t\t\t\t\t\t\tsetPlacesWindow={setPlacesWindow}\n\t\t\t\t\t\t\t\t\t\t\tsetSelectedPlaceMarker={setSelectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</MarkerClustererF>\n\t\t\t\t</GoogleMap>\n\t\t\t\t{mapInteracted && markerConfigs && (\n\t\t\t\t\t<ShowAllButton\n\t\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\t\tlistingCount={filteredListings.length}\n\t\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t}\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","markerConfigs","infoWindowClasses","_ref$clusterGridSize","clusterGridSize","_useMap","useMap","location","zoom","center","selectLocationEntity","setLocation","mapInteracted","setMapInteracted","_useMapList","useMapList","mapItems","filteredListings","setSelectedFilters","setQuery","mapRef","useRef","markerRefs","mapContainerRef","_usePlaces","usePlaces","poiMarkers","setCurrentCenter","currentCenter","setCurrentZoom","currentZoom","selectedPlaceMarker","setSelectedPlaceMarker","placesWindow","setPlacesWindow","onIdle","current","newCenter","getCenter","toJSON","newZoom","useEffect","handleScroll","addEventListener","mapContainerRefCurrent","removeEventListener","dragStartListener","addListener","mouseDownListener","google","maps","event","removeListener","length","fitBounds","currZoom","setZoomVal","setZoom","panTo","LatLng","latitude","longitude","map","overload","arguments","undefined","bounds","window","LatLngBounds","forEach","item","extend","markerClickHandler","mapLocation","onLoad","pinIconUrl","pinIcon","fillColor","strokeColor","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","MarkerClustererF","clusterOptions","clusterer","MapMarker","key","id","selectedLocation","setSelectedLocation","markerIcon","markerIconSelected","markers","marker","index","PlaceMarker","concat","title","ShowAllButton","listingCount"],"mappings":";;;;;;;;;;;AAAA;AAeA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAIH;AAAA,EAAA,IAHLC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IAAAC,oB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AAA,aAAa,EAAEA,aAAc;AAC7BY,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCyC,IAAAA,SAAS,EAAEA,SAAU;AACrBlC,IAAAA,MAAM,EAAEA,MAAO;AACfuD,IAAAA,UAAU,EAAEA,UAAW;AACvBxD,IAAAA,QAAQ,EAAEA,QAAS;IACnB4F,YAAY,EAAE9F,gBAAgB,CAACoC,MAAO;AACtCnC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CAEJ,CAAC,CAAA;AAEL;;;;"}
@@ -47,19 +47,19 @@ var useListLogic = function useListLogic() {
47
47
  rootMargin: "100px 0px",
48
48
  threshold: 0.5
49
49
  });
50
- if (loader.current) {
51
- observer.current.observe(loader.current);
50
+ var current = loader.current;
51
+ if (current) {
52
+ observer.current.observe(current);
52
53
  }
53
54
  return function () {
54
- if (observer.current && loader.current) {
55
- observer.current.unobserve(loader.current);
55
+ if (observer.current && current) {
56
+ observer.current.unobserve(current);
56
57
  }
57
58
  };
59
+ // eslint-disable-next-line react-hooks/exhaustive-deps
58
60
  }, [filteredListings.length, itemLimit]);
59
61
  useEffect(function () {
60
62
  localStorage.setItem('scrollPosition', scrollPosition.toString());
61
- }, [scrollPosition]);
62
- useEffect(function () {
63
63
  var savedScrollPosition = scrollPosition;
64
64
  if (parseInt(savedScrollPosition) > 3000) {
65
65
  setItemLimit(savedScrollPosition / 10);
@@ -69,15 +69,15 @@ var useListLogic = function useListLogic() {
69
69
  scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
70
70
  }, 300);
71
71
  }
72
- }, []);
72
+ }, [scrollPosition]);
73
73
  useEffect(function () {
74
- var scrollContainer = scrollContainerRef.current;
75
- if (scrollContainer) {
76
- scrollContainer.addEventListener('scroll', handleScroll);
74
+ var current = scrollContainerRef.current;
75
+ if (current) {
76
+ current.addEventListener('scroll', handleScroll);
77
77
  }
78
78
  return function () {
79
- if (scrollContainer) {
80
- scrollContainer.removeEventListener('scroll', handleScroll);
79
+ if (current) {
80
+ current.removeEventListener('scroll', handleScroll);
81
81
  }
82
82
  };
83
83
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"useList.js","sources":["../../src/hooks/useList.js"],"sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport { getStorageObject } from '~/util/localStorageUtil';\nimport { dynamicSort } from '~/util/sortUtil';\n\nimport { useMapList } from '~/contexts/mapListContext';\n\nconst getDefaultItemId = () => {\n\tlet item = getStorageObject(\"selectedListItem\");\n\tif (item?.expanded == true) {\n\t\treturn item.id;\n\t} else {\n\t\treturn null;\n\t}\n};\n\nconst useListLogic = () => {\n\tconst [itemLimit, setItemLimit] = useState(100);\n\tconst [expandedId] = useState(getDefaultItemId());\n\tconst [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));\n\tconst [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));\n\tconst loader = useRef(null);\n\tconst scrollContainerRef = useRef(null);\n\tconst itemRefs = useRef({});\n\tconst observer = useRef(null);\n\tconst { filteredListings, setFilteredListings } = useMapList();\n\n\tuseEffect(() => {\n\t\tif (!sortSetting) return;\n\t\tlocalStorage.setItem('sortSetting', JSON.stringify(sortSetting));\n\t\tlet listingFiltered = dynamicSort(filteredListings, sortSetting.field, sortSetting.type);\n\t\tsetFilteredListings(listingFiltered);\n\t}, [sortSetting, filteredListings, setFilteredListings]);\n\n\tuseEffect(() => {\n\t\tobserver.current = new IntersectionObserver(handleObserver, {\n\t\t\troot: scrollContainerRef.current,\n\t\t\trootMargin: \"100px 0px\",\n\t\t\tthreshold: 0.5\n\t\t});\n\t\tif (loader.current) {\n\t\t\tobserver.current.observe(loader.current);\n\t\t}\n\t\treturn () => {\n\t\t\tif (observer.current && loader.current) {\n\t\t\t\tobserver.current.unobserve(loader.current);\n\t\t\t}\n\t\t};\n\t}, [filteredListings.length, itemLimit]);\n\n\tuseEffect(() => {\n\t\tlocalStorage.setItem('scrollPosition', scrollPosition.toString());\n\t}, [scrollPosition]);\n\n\tuseEffect(() => {\n\t\tconst savedScrollPosition = scrollPosition;\n\t\tif (parseInt(savedScrollPosition) > 3000) {\n\t\t\tsetItemLimit(savedScrollPosition / 10);\n\t\t}\n\t\tif (savedScrollPosition && scrollContainerRef.current) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tscrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);\n\t\t\t}, 300);\n\t\t}\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst scrollContainer = scrollContainerRef.current;\n\t\tif (scrollContainer) {\n\t\t\tscrollContainer.addEventListener('scroll', handleScroll);\n\t\t}\n\t\treturn () => {\n\t\t\tif (scrollContainer) {\n\t\t\t\tscrollContainer.removeEventListener('scroll', handleScroll);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tconst handleObserver = entities => {\n\t\tconst target = entities[0];\n\t\tif (!target.isIntersecting) return;\n\t\tif (filteredListings.length > itemLimit) {\n\t\t\tsetItemLimit(prevLimit => prevLimit + 100);\n\t\t} else if (observer.current) {\n\t\t\tobserver.current.disconnect();\n\t\t}\n\t};\n\n\tconst handleScroll = () => {\n\t\tif (scrollContainerRef.current) {\n\t\t\tsetScrollPosition(scrollContainerRef.current.scrollTop);\n\t\t}\n\t};\n\n\treturn { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, dynamicSort, filteredListings };\n};\n\nexport default useListLogic;\n"],"names":["getDefaultItemId","item","getStorageObject","expanded","id","useListLogic","_useState","useState","_useState2","_slicedToArray","itemLimit","setItemLimit","_useState3","_useState4","expandedId","_useState5","_useState6","sortSetting","setSortSetting","_useState7","_useState8","scrollPosition","setScrollPosition","loader","useRef","scrollContainerRef","itemRefs","observer","_useMapList","useMapList","filteredListings","setFilteredListings","useEffect","localStorage","setItem","JSON","stringify","listingFiltered","dynamicSort","field","type","current","IntersectionObserver","handleObserver","root","rootMargin","threshold","observe","unobserve","length","toString","savedScrollPosition","parseInt","setTimeout","scroll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IAAAA,gBAAgB,EAAhBA,gBAAAA;GAAkB,CAAA;AACtK;;;;"}
1
+ {"version":3,"file":"useList.js","sources":["../../src/hooks/useList.js"],"sourcesContent":["import { useEffect, useState, useRef } from 'react';\n\nimport { getStorageObject } from '~/util/localStorageUtil';\nimport { dynamicSort } from '~/util/sortUtil';\n\nimport { useMapList } from '~/contexts/mapListContext';\n\nconst getDefaultItemId = () => {\n\tlet item = getStorageObject(\"selectedListItem\");\n\tif (item?.expanded == true) {\n\t\treturn item.id;\n\t} else {\n\t\treturn null;\n\t}\n};\n\nconst useListLogic = () => {\n\tconst [itemLimit, setItemLimit] = useState(100);\n\tconst [expandedId] = useState(getDefaultItemId());\n\tconst [sortSetting, setSortSetting] = useState(getStorageObject('sortSetting', null));\n\tconst [scrollPosition, setScrollPosition] = useState(getStorageObject('scrollPosition', 0));\n\tconst loader = useRef(null);\n\tconst scrollContainerRef = useRef(null);\n\tconst itemRefs = useRef({});\n\tconst observer = useRef(null);\n\tconst { filteredListings, setFilteredListings } = useMapList();\n\n\tuseEffect(() => {\n\t\tif (!sortSetting) return;\n\t\tlocalStorage.setItem('sortSetting', JSON.stringify(sortSetting));\n\t\tlet listingFiltered = dynamicSort(filteredListings, sortSetting.field, sortSetting.type);\n\t\tsetFilteredListings(listingFiltered);\n\t}, [sortSetting, filteredListings, setFilteredListings]);\n\n\tuseEffect(() => {\n\t\tobserver.current = new IntersectionObserver(handleObserver, {\n\t\t\troot: scrollContainerRef.current,\n\t\t\trootMargin: \"100px 0px\",\n\t\t\tthreshold: 0.5\n\t\t});\n\t\tconst { current } = loader;\n\t\tif (current) {\n\t\t\tobserver.current.observe(current);\n\t\t}\n\t\treturn () => {\n\t\t\tif (observer.current && current) {\n\t\t\t\tobserver.current.unobserve(current);\n\t\t\t}\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [filteredListings.length, itemLimit]);\n\n\tuseEffect(() => {\n\t\tlocalStorage.setItem('scrollPosition', scrollPosition.toString());\n\t\tconst savedScrollPosition = scrollPosition;\n\t\tif (parseInt(savedScrollPosition) > 3000) {\n\t\t\tsetItemLimit(savedScrollPosition / 10);\n\t\t}\n\t\tif (savedScrollPosition && scrollContainerRef.current) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tscrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);\n\t\t\t}, 300);\n\t\t}\n\t}, [scrollPosition]);\n\n\tuseEffect(() => {\n\t\tconst { current } = scrollContainerRef;\n\t\tif (current) {\n\t\t\tcurrent.addEventListener('scroll', handleScroll);\n\t\t}\n\t\treturn () => {\n\t\t\tif (current) {\n\t\t\t\tcurrent.removeEventListener('scroll', handleScroll);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tconst handleObserver = entities => {\n\t\tconst target = entities[0];\n\t\tif (!target.isIntersecting) return;\n\t\tif (filteredListings.length > itemLimit) {\n\t\t\tsetItemLimit(prevLimit => prevLimit + 100);\n\t\t} else if (observer.current) {\n\t\t\tobserver.current.disconnect();\n\t\t}\n\t};\n\n\tconst handleScroll = () => {\n\t\tif (scrollContainerRef.current) {\n\t\t\tsetScrollPosition(scrollContainerRef.current.scrollTop);\n\t\t}\n\t};\n\n\treturn { itemLimit, expandedId, sortSetting, scrollPosition, loader, scrollContainerRef, itemRefs, setSortSetting, setScrollPosition, dynamicSort, filteredListings };\n};\n\nexport default useListLogic;\n"],"names":["getDefaultItemId","item","getStorageObject","expanded","id","useListLogic","_useState","useState","_useState2","_slicedToArray","itemLimit","setItemLimit","_useState3","_useState4","expandedId","_useState5","_useState6","sortSetting","setSortSetting","_useState7","_useState8","scrollPosition","setScrollPosition","loader","useRef","scrollContainerRef","itemRefs","observer","_useMapList","useMapList","filteredListings","setFilteredListings","useEffect","localStorage","setItem","JSON","stringify","listingFiltered","dynamicSort","field","type","current","IntersectionObserver","handleObserver","root","rootMargin","threshold","observe","unobserve","length","toString","savedScrollPosition","parseInt","setTimeout","scrollTop","addEventListener","handleScroll","removeEventListener","entities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1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hc-ui-components",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "UI Components for HireControl",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -60,62 +60,66 @@ const Map = ({
60
60
  };
61
61
 
62
62
  useEffect(() => {
63
- if (mapContainerRef.current) {
63
+ const { current } = mapContainerRef;
64
+ if (current) {
64
65
  const handleScroll = () => {
65
66
  setMapInteracted(true);
66
67
  };
67
- var mapContainerRefCurrent = mapContainerRef.current;
68
- mapContainerRef.current.addEventListener('wheel', handleScroll);
68
+ current.addEventListener('wheel', handleScroll);
69
69
  return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
70
70
  }
71
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
72
72
  }, [mapContainerRef.current]);
73
73
 
74
74
  useEffect(() => {
75
- if (mapRef.current) {
76
- const mapInstance = mapRef.current;
77
- const dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));
78
- const mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));
75
+ const { current } = mapContainerRef;
76
+ if (current) {
77
+ const dragStartListener = current.addListener('dragstart', () => setMapInteracted(true));
78
+ const mouseDownListener = current.addListener('mousedown', () => setMapInteracted(true));
79
79
  return () => {
80
80
  google.maps.event.removeListener(dragStartListener);
81
81
  google.maps.event.removeListener(mouseDownListener);
82
82
  };
83
83
  }
84
84
  // eslint-disable-next-line react-hooks/exhaustive-deps
85
- }, [mapRef.current, mapContainerRef.current]);
85
+ }, [mapContainerRef.current]);
86
86
 
87
87
  useEffect(() => {
88
- if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
89
- fitBounds(mapRef.current);
88
+ const { current } = mapRef;
89
+ if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {
90
+ fitBounds(current);
90
91
  }
91
92
  // eslint-disable-next-line react-hooks/exhaustive-deps
92
93
  }, [mapItems, mapRef.current, location]);
93
94
 
94
95
  useEffect(() => {
95
- if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
96
- fitBounds(mapRef.current, true);
96
+ const { current } = mapRef;
97
+ if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && current && mapInteracted) {
98
+ fitBounds(current, true);
97
99
  }
98
- if (mapRef.current) {
99
- let currZoom = mapRef.current.zoom;
100
+ if (current) {
101
+ let currZoom = current.zoom;
100
102
  let setZoomVal = currZoom < 13 ? currZoom : 12;
101
- mapRef.current.setZoom(setZoomVal);
103
+ current.setZoom(setZoomVal);
102
104
  }
103
105
  // eslint-disable-next-line react-hooks/exhaustive-deps
104
106
  }, [filteredListings]);
105
107
 
106
108
  useEffect(() => {
107
- if (!mapRef.current || !location || mapInteracted) return;
108
- mapRef.current.panTo(
109
+ const { current } = mapRef;
110
+ if (!current || !location || mapInteracted) return;
111
+ current.panTo(
109
112
  new google.maps.LatLng(location.latitude, location.longitude)
110
113
  );
111
- if (mapRef.current) {
114
+ if (current) {
112
115
  let setZoomVal = zoom < 13 ? zoom : 12;
113
- mapRef.current.setZoom(setZoomVal);
116
+ current.setZoom(setZoomVal);
114
117
  }
115
118
  // eslint-disable-next-line react-hooks/exhaustive-deps
116
119
  }, [location, zoom, mapRef.current]);
117
120
 
118
121
  const fitBounds = (map, overload = false) => {
122
+ const { current } = mapRef;
119
123
  if ((mapInteracted === false || overload) && mapItems != null) {
120
124
  const bounds = new window.google.maps.LatLngBounds();
121
125
  mapItems.forEach(item => {
@@ -124,8 +128,8 @@ const Map = ({
124
128
  if (!map) return;
125
129
  map.fitBounds(bounds);
126
130
  }
127
- if (mapRef.current.zoom > 17) {
128
- mapRef.current.setZoom(16);
131
+ if (current.zoom > 17) {
132
+ current.setZoom(16);
129
133
  }
130
134
  };
131
135
 
@@ -135,19 +139,20 @@ const Map = ({
135
139
  };
136
140
 
137
141
  const onLoad = map => {
142
+ let { current } = mapRef;
138
143
  if (!location || location === null) {
139
- mapRef.current = map;
144
+ current = map;
140
145
  fitBounds(map, true);
141
146
  return;
142
147
  }
143
- mapRef.current = map;
148
+ current = map;
144
149
 
145
150
  if (mapInteracted === false) {
146
- mapRef.current.panTo(
151
+ current.panTo(
147
152
  new google.maps.LatLng(location.latitude, location.longitude)
148
153
  );
149
154
 
150
- mapRef.current.setZoom(zoom);
155
+ current.setZoom(zoom);
151
156
  }
152
157
  };
153
158
 
@@ -157,76 +162,77 @@ const Map = ({
157
162
  });
158
163
 
159
164
  return (
160
- <>{zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
161
- <GoogleMap
162
- zoom={zoom}
163
- onLoad={onLoad}
164
- onIdle={onIdle}
165
- center={center}
166
- mapContainerStyle={{
167
- width: "100%",
168
- height: "100%"
169
- }}
170
- options={{
171
- styles: [
172
- {
173
- featureType: "poi",
174
- elementType: "labels",
175
- stylers: [{ visibility: "off" }]
176
- }
177
- ]
178
- }}
179
- >
180
- <MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
181
- {clusterer => (
182
- <>
183
- {mapItems.map(item => (
184
- <MapMarker
185
- key={item.id}
186
- item={item}
187
- selectedLocation={location}
188
- markerRefs={markerRefs}
189
- infoWindowClasses={infoWindowClasses}
190
- setSelectedLocation={setLocation}
191
- markerClickHandler={markerClickHandler}
192
- clusterer={clusterer}
193
- markerIcon={markerIcon(markerConfigs)}
194
- markerIconSelected={markerIconSelected(markerConfigs)}
195
- setMapInteracted={setMapInteracted}
196
- />
197
- ))}
198
- {poiMarkers && poiMarkers.markers.map((marker, index) => {
199
- return (
200
- <PlaceMarker
201
- key={`marker-${marker.title}-${index}`}
202
- marker={marker}
203
- index={index}
204
- selectedPlaceMarker={selectedPlaceMarker}
205
- placesWindow={placesWindow}
206
- setPlacesWindow={setPlacesWindow}
207
- setSelectedPlaceMarker={setSelectedPlaceMarker}
165
+ <>
166
+ {zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
167
+ <GoogleMap
168
+ zoom={zoom}
169
+ onLoad={onLoad}
170
+ onIdle={onIdle}
171
+ center={center}
172
+ mapContainerStyle={{
173
+ width: "100%",
174
+ height: "100%"
175
+ }}
176
+ options={{
177
+ styles: [
178
+ {
179
+ featureType: "poi",
180
+ elementType: "labels",
181
+ stylers: [{ visibility: "off" }]
182
+ }
183
+ ]
184
+ }}
185
+ >
186
+ <MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
187
+ {clusterer => (
188
+ <>
189
+ {mapItems.map(item => (
190
+ <MapMarker
191
+ key={item.id}
192
+ item={item}
193
+ selectedLocation={location}
194
+ markerRefs={markerRefs}
195
+ infoWindowClasses={infoWindowClasses}
196
+ setSelectedLocation={setLocation}
197
+ markerClickHandler={markerClickHandler}
198
+ clusterer={clusterer}
199
+ markerIcon={markerIcon(markerConfigs)}
200
+ markerIconSelected={markerIconSelected(markerConfigs)}
201
+ setMapInteracted={setMapInteracted}
208
202
  />
209
- );
210
- })}
211
- </>
212
- )}
213
- </MarkerClustererF>
214
- </GoogleMap>
215
- {mapInteracted && markerConfigs && (
216
- <ShowAllButton
217
- mapInteracted={mapInteracted}
218
- markerConfigs={markerConfigs}
219
- setMapInteracted={setMapInteracted}
220
- fitBounds={fitBounds}
221
- mapRef={mapRef}
222
- pinIconUrl={pinIconUrl}
223
- setQuery={setQuery}
224
- listingCount={filteredListings.length}
225
- setSelectedFilters={setSelectedFilters}
226
- />
227
- )}
228
- </div>
229
- }
203
+ ))}
204
+ {poiMarkers && poiMarkers.markers.map((marker, index) => {
205
+ return (
206
+ <PlaceMarker
207
+ key={`marker-${marker.title}-${index}`}
208
+ marker={marker}
209
+ index={index}
210
+ selectedPlaceMarker={selectedPlaceMarker}
211
+ placesWindow={placesWindow}
212
+ setPlacesWindow={setPlacesWindow}
213
+ setSelectedPlaceMarker={setSelectedPlaceMarker}
214
+ />
215
+ );
216
+ })}
217
+ </>
218
+ )}
219
+ </MarkerClustererF>
220
+ </GoogleMap>
221
+ {mapInteracted && markerConfigs && (
222
+ <ShowAllButton
223
+ mapInteracted={mapInteracted}
224
+ markerConfigs={markerConfigs}
225
+ setMapInteracted={setMapInteracted}
226
+ fitBounds={fitBounds}
227
+ mapRef={mapRef}
228
+ pinIconUrl={pinIconUrl}
229
+ setQuery={setQuery}
230
+ listingCount={filteredListings.length}
231
+ setSelectedFilters={setSelectedFilters}
232
+ />
233
+ )}
234
+ </div>
235
+ }
230
236
  </>
231
237
  );
232
238
  };
@@ -38,21 +38,20 @@ const useListLogic = () => {
38
38
  rootMargin: "100px 0px",
39
39
  threshold: 0.5
40
40
  });
41
- if (loader.current) {
42
- observer.current.observe(loader.current);
41
+ const { current } = loader;
42
+ if (current) {
43
+ observer.current.observe(current);
43
44
  }
44
45
  return () => {
45
- if (observer.current && loader.current) {
46
- observer.current.unobserve(loader.current);
46
+ if (observer.current && current) {
47
+ observer.current.unobserve(current);
47
48
  }
48
49
  };
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
51
  }, [filteredListings.length, itemLimit]);
50
52
 
51
53
  useEffect(() => {
52
54
  localStorage.setItem('scrollPosition', scrollPosition.toString());
53
- }, [scrollPosition]);
54
-
55
- useEffect(() => {
56
55
  const savedScrollPosition = scrollPosition;
57
56
  if (parseInt(savedScrollPosition) > 3000) {
58
57
  setItemLimit(savedScrollPosition / 10);
@@ -62,16 +61,16 @@ const useListLogic = () => {
62
61
  scrollContainerRef.current.scrollTop = parseInt(savedScrollPosition, 10);
63
62
  }, 300);
64
63
  }
65
- }, []);
64
+ }, [scrollPosition]);
66
65
 
67
66
  useEffect(() => {
68
- const scrollContainer = scrollContainerRef.current;
69
- if (scrollContainer) {
70
- scrollContainer.addEventListener('scroll', handleScroll);
67
+ const { current } = scrollContainerRef;
68
+ if (current) {
69
+ current.addEventListener('scroll', handleScroll);
71
70
  }
72
71
  return () => {
73
- if (scrollContainer) {
74
- scrollContainer.removeEventListener('scroll', handleScroll);
72
+ if (current) {
73
+ current.removeEventListener('scroll', handleScroll);
75
74
  }
76
75
  };
77
76
  }, []);