@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.cjs CHANGED
@@ -4941,7 +4941,6 @@ var ProjectsMap = ({
4941
4941
  const map = (0, import_react34.useRef)(null);
4942
4942
  const animationIntervalRef = (0, import_react34.useRef)(null);
4943
4943
  const [featureCollection, setFeatureCollection] = (0, import_react34.useState)(null);
4944
- const [isLoading, setIsLoading] = (0, import_react34.useState)(false);
4945
4944
  const initialBboxRef = (0, import_react34.useRef)(null);
4946
4945
  const [isMapReady, setIsMapReady] = (0, import_react34.useState)(false);
4947
4946
  const [strapiProjects, setStrapiProjects] = (0, import_react34.useState)(null);
@@ -4964,15 +4963,12 @@ var ProjectsMap = ({
4964
4963
  }, [locale, strapiProjects]);
4965
4964
  const fetchProjectsData = (0, import_react34.useCallback)(
4966
4965
  async (bbox) => {
4967
- setIsLoading(true);
4968
4966
  try {
4969
4967
  const fpmData = await getFpmProjectsByBbox_default(bbox);
4970
4968
  const mergedData = strapiProjects ? mergeProjectData_default(fpmData, strapiProjects) : fpmData;
4971
4969
  setFeatureCollection(mergedData);
4972
4970
  } catch (error) {
4973
4971
  console.error("Error fetching projects:", error);
4974
- } finally {
4975
- setIsLoading(false);
4976
4972
  }
4977
4973
  },
4978
4974
  [strapiProjects]
@@ -4990,7 +4986,11 @@ var ProjectsMap = ({
4990
4986
  [fetchProjectsData, isBboxContained]
4991
4987
  );
4992
4988
  const addProjectsLayer = (0, import_react34.useCallback)(() => {
4993
- if (!map.current || !featureCollection || !map.current.isStyleLoaded()) {
4989
+ if (!map.current || !featureCollection) {
4990
+ return;
4991
+ }
4992
+ if (!map.current.isStyleLoaded()) {
4993
+ setTimeout(() => addProjectsLayer(), 100);
4994
4994
  return;
4995
4995
  }
4996
4996
  const filteredFeatureCollection = {
@@ -5229,7 +5229,7 @@ var ProjectsMap = ({
5229
5229
  } else {
5230
5230
  source.setData(filteredFeatureCollection);
5231
5231
  }
5232
- }, [featureCollection, locale, formatMessage]);
5232
+ }, [featureCollection, formatMessage]);
5233
5233
  (0, import_react34.useEffect)(() => {
5234
5234
  if (map.current || !mapContainer.current) return;
5235
5235
  let initialCenter;
@@ -5254,19 +5254,17 @@ var ProjectsMap = ({
5254
5254
  center: initialCenter,
5255
5255
  zoom: initialZoom,
5256
5256
  maxZoom: MAPBOX_MAX_ZOOM,
5257
- minZoom: slice.minZoomLevel
5257
+ minZoom: slice.minZoomLevel,
5258
+ cooperativeGestures: true
5258
5259
  });
5259
5260
  map.current.addControl(new import_mapbox_gl.default.NavigationControl(), "top-right");
5260
5261
  map.current.on("load", () => {
5261
- setIsMapReady(true);
5262
- });
5263
- map.current.on("moveend", () => {
5264
- if (initialBboxRef.current) {
5265
- debouncedUpdateBbox();
5262
+ if (map.current?.getLayer("road-number-shield")) {
5263
+ map.current?.setLayoutProperty("road-number-shield", "visibility", "none");
5266
5264
  }
5265
+ setIsMapReady(true);
5267
5266
  });
5268
5267
  return () => {
5269
- debouncedUpdateBbox.cancel();
5270
5268
  if (animationIntervalRef.current) {
5271
5269
  clearInterval(animationIntervalRef.current);
5272
5270
  }
@@ -5276,9 +5274,17 @@ var ProjectsMap = ({
5276
5274
  }, [
5277
5275
  slice.defaultCenterCoordinates,
5278
5276
  slice.defaultZoomLevel,
5279
- slice.minZoomLevel,
5280
- debouncedUpdateBbox
5277
+ slice.minZoomLevel
5281
5278
  ]);
5279
+ (0, import_react34.useEffect)(() => {
5280
+ if (!map.current || !isMapReady) return;
5281
+ const currentMap = map.current;
5282
+ currentMap.on("moveend", debouncedUpdateBbox);
5283
+ return () => {
5284
+ debouncedUpdateBbox.cancel();
5285
+ currentMap.off("moveend", debouncedUpdateBbox);
5286
+ };
5287
+ }, [isMapReady, debouncedUpdateBbox]);
5282
5288
  (0, import_react34.useEffect)(() => {
5283
5289
  fetchStrapiData();
5284
5290
  }, [fetchStrapiData]);
@@ -5312,6 +5318,7 @@ var ProjectsMap = ({
5312
5318
  });
5313
5319
  const buffer = 1;
5314
5320
  const bbox = `${userLoc.lon - buffer},${userLoc.lat - buffer},${userLoc.lon + buffer},${userLoc.lat + buffer}`;
5321
+ initialBboxRef.current = bbox;
5315
5322
  fetchProjectsData(bbox);
5316
5323
  }
5317
5324
  },
@@ -5329,7 +5336,7 @@ var ProjectsMap = ({
5329
5336
  fetchProjectsData
5330
5337
  ]);
5331
5338
  (0, import_react34.useEffect)(() => {
5332
- if (isMapReady && featureCollection && map.current?.isStyleLoaded()) {
5339
+ if (isMapReady && featureCollection) {
5333
5340
  addProjectsLayer();
5334
5341
  }
5335
5342
  }, [isMapReady, featureCollection, addProjectsLayer]);
@@ -5381,8 +5388,7 @@ var ProjectsMap = ({
5381
5388
  overflow: "hidden",
5382
5389
  boxShadow: ["md", null, null, "none"]
5383
5390
  }
5384
- ),
5385
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_boemly34.Box, { children: "Loading projects..." })
5391
+ )
5386
5392
  ] })
5387
5393
  ] });
5388
5394
  };
@@ -8947,7 +8953,7 @@ var Redirect = ({ slice }) => {
8947
8953
  router.asPath,
8948
8954
  router.query
8949
8955
  );
8950
- router.replace(redirectUrl);
8956
+ window.location.replace(redirectUrl);
8951
8957
  }, [slice.url, router]);
8952
8958
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_jsx_runtime61.Fragment, {});
8953
8959
  };