@treely/strapi-slices 8.2.5 → 8.2.7

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/index.js CHANGED
@@ -5066,7 +5066,6 @@ var ProjectsMap = ({
5066
5066
  const map = useRef4(null);
5067
5067
  const animationIntervalRef = useRef4(null);
5068
5068
  const [featureCollection, setFeatureCollection] = useState5(null);
5069
- const [isLoading, setIsLoading] = useState5(false);
5070
5069
  const initialBboxRef = useRef4(null);
5071
5070
  const [isMapReady, setIsMapReady] = useState5(false);
5072
5071
  const [strapiProjects, setStrapiProjects] = useState5(null);
@@ -5089,15 +5088,12 @@ var ProjectsMap = ({
5089
5088
  }, [locale, strapiProjects]);
5090
5089
  const fetchProjectsData = useCallback2(
5091
5090
  async (bbox) => {
5092
- setIsLoading(true);
5093
5091
  try {
5094
5092
  const fpmData = await getFpmProjectsByBbox_default(bbox);
5095
5093
  const mergedData = strapiProjects ? mergeProjectData_default(fpmData, strapiProjects) : fpmData;
5096
5094
  setFeatureCollection(mergedData);
5097
5095
  } catch (error) {
5098
5096
  console.error("Error fetching projects:", error);
5099
- } finally {
5100
- setIsLoading(false);
5101
5097
  }
5102
5098
  },
5103
5099
  [strapiProjects]
@@ -5115,7 +5111,11 @@ var ProjectsMap = ({
5115
5111
  [fetchProjectsData, isBboxContained]
5116
5112
  );
5117
5113
  const addProjectsLayer = useCallback2(() => {
5118
- if (!map.current || !featureCollection || !map.current.isStyleLoaded()) {
5114
+ if (!map.current || !featureCollection) {
5115
+ return;
5116
+ }
5117
+ if (!map.current.isStyleLoaded()) {
5118
+ setTimeout(() => addProjectsLayer(), 100);
5119
5119
  return;
5120
5120
  }
5121
5121
  const filteredFeatureCollection = {
@@ -5354,7 +5354,7 @@ var ProjectsMap = ({
5354
5354
  } else {
5355
5355
  source.setData(filteredFeatureCollection);
5356
5356
  }
5357
- }, [featureCollection, locale, formatMessage]);
5357
+ }, [featureCollection, formatMessage]);
5358
5358
  useEffect4(() => {
5359
5359
  if (map.current || !mapContainer.current) return;
5360
5360
  let initialCenter;
@@ -5379,19 +5379,17 @@ var ProjectsMap = ({
5379
5379
  center: initialCenter,
5380
5380
  zoom: initialZoom,
5381
5381
  maxZoom: MAPBOX_MAX_ZOOM,
5382
- minZoom: slice.minZoomLevel
5382
+ minZoom: slice.minZoomLevel,
5383
+ cooperativeGestures: true
5383
5384
  });
5384
5385
  map.current.addControl(new mapboxgl.NavigationControl(), "top-right");
5385
5386
  map.current.on("load", () => {
5386
- setIsMapReady(true);
5387
- });
5388
- map.current.on("moveend", () => {
5389
- if (initialBboxRef.current) {
5390
- debouncedUpdateBbox();
5387
+ if (map.current?.getLayer("road-number-shield")) {
5388
+ map.current?.setLayoutProperty("road-number-shield", "visibility", "none");
5391
5389
  }
5390
+ setIsMapReady(true);
5392
5391
  });
5393
5392
  return () => {
5394
- debouncedUpdateBbox.cancel();
5395
5393
  if (animationIntervalRef.current) {
5396
5394
  clearInterval(animationIntervalRef.current);
5397
5395
  }
@@ -5401,9 +5399,17 @@ var ProjectsMap = ({
5401
5399
  }, [
5402
5400
  slice.defaultCenterCoordinates,
5403
5401
  slice.defaultZoomLevel,
5404
- slice.minZoomLevel,
5405
- debouncedUpdateBbox
5402
+ slice.minZoomLevel
5406
5403
  ]);
5404
+ useEffect4(() => {
5405
+ if (!map.current || !isMapReady) return;
5406
+ const currentMap = map.current;
5407
+ currentMap.on("moveend", debouncedUpdateBbox);
5408
+ return () => {
5409
+ debouncedUpdateBbox.cancel();
5410
+ currentMap.off("moveend", debouncedUpdateBbox);
5411
+ };
5412
+ }, [isMapReady, debouncedUpdateBbox]);
5407
5413
  useEffect4(() => {
5408
5414
  fetchStrapiData();
5409
5415
  }, [fetchStrapiData]);
@@ -5437,6 +5443,7 @@ var ProjectsMap = ({
5437
5443
  });
5438
5444
  const buffer = 1;
5439
5445
  const bbox = `${userLoc.lon - buffer},${userLoc.lat - buffer},${userLoc.lon + buffer},${userLoc.lat + buffer}`;
5446
+ initialBboxRef.current = bbox;
5440
5447
  fetchProjectsData(bbox);
5441
5448
  }
5442
5449
  },
@@ -5454,7 +5461,7 @@ var ProjectsMap = ({
5454
5461
  fetchProjectsData
5455
5462
  ]);
5456
5463
  useEffect4(() => {
5457
- if (isMapReady && featureCollection && map.current?.isStyleLoaded()) {
5464
+ if (isMapReady && featureCollection) {
5458
5465
  addProjectsLayer();
5459
5466
  }
5460
5467
  }, [isMapReady, featureCollection, addProjectsLayer]);
@@ -5506,8 +5513,7 @@ var ProjectsMap = ({
5506
5513
  overflow: "hidden",
5507
5514
  boxShadow: ["md", null, null, "none"]
5508
5515
  }
5509
- ),
5510
- isLoading && /* @__PURE__ */ jsx34(Box25, { children: "Loading projects..." })
5516
+ )
5511
5517
  ] })
5512
5518
  ] });
5513
5519
  };
@@ -9263,7 +9269,7 @@ var Redirect = ({ slice }) => {
9263
9269
  router.asPath,
9264
9270
  router.query
9265
9271
  );
9266
- router.replace(redirectUrl);
9272
+ window.location.replace(redirectUrl);
9267
9273
  }, [slice.url, router]);
9268
9274
  return /* @__PURE__ */ jsx61(Fragment32, {});
9269
9275
  };