@classic-homes/maps-react 0.2.14 → 0.3.1

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
@@ -347,6 +347,7 @@ var Map2 = React26__namespace.forwardRef(
347
347
  doubleClickZoom = true,
348
348
  touchZoomRotate = true,
349
349
  keyboard = true,
350
+ cooperativeGestures,
350
351
  attributionControl = true,
351
352
  customAttribution,
352
353
  navigationControl = true,
@@ -374,6 +375,11 @@ var Map2 = React26__namespace.forwardRef(
374
375
  const [mapLoaded, setMapLoaded] = React26__namespace.useState(false);
375
376
  const [mapError, setMapError] = React26__namespace.useState(null);
376
377
  const [styleVersion, setStyleVersion] = React26__namespace.useState(0);
378
+ const styleVersionRef = React26__namespace.useRef(0);
379
+ const bumpStyleVersion = React26__namespace.useCallback(() => {
380
+ styleVersionRef.current += 1;
381
+ setStyleVersion(styleVersionRef.current);
382
+ }, []);
377
383
  const activeStyleOverrideRef = React26__namespace.useRef(
378
384
  null
379
385
  );
@@ -382,16 +388,19 @@ var Map2 = React26__namespace.forwardRef(
382
388
  positioningCoordinatorRef.current = mapsCore.createPositioningCoordinator();
383
389
  }
384
390
  const positioningCoordinator = positioningCoordinatorRef.current;
385
- const setMapStyle = React26__namespace.useCallback((style) => {
386
- activeStyleOverrideRef.current = style;
387
- const map = mapRef.current;
388
- if (map) {
391
+ const setMapStyle = React26__namespace.useCallback(
392
+ (style) => {
393
+ activeStyleOverrideRef.current = style;
394
+ const map = mapRef.current;
395
+ if (!map) return;
396
+ const versionBefore = styleVersionRef.current;
389
397
  map.setStyle(style);
390
398
  map.once("idle", () => {
391
- setStyleVersion((v) => v + 1);
399
+ if (styleVersionRef.current === versionBefore) bumpStyleVersion();
392
400
  });
393
- }
394
- }, []);
401
+ },
402
+ [bumpStyleVersion]
403
+ );
395
404
  const prefersReducedMotion = useReducedMotion();
396
405
  const { style: themeStyle } = useMapTheme(themePref);
397
406
  const onLoadRef = React26__namespace.useRef(onLoad);
@@ -444,6 +453,7 @@ var Map2 = React26__namespace.forwardRef(
444
453
  doubleClickZoom,
445
454
  touchZoomRotate,
446
455
  keyboard,
456
+ cooperativeGestures,
447
457
  attributionControl: attributionControl ? { customAttribution } : false
448
458
  });
449
459
  mapRef.current = map;
@@ -562,14 +572,11 @@ var Map2 = React26__namespace.forwardRef(
562
572
  React26__namespace.useEffect(() => {
563
573
  const map = mapRef.current;
564
574
  if (!map || !mapLoaded) return;
565
- const handleStyleLoad = () => {
566
- setStyleVersion((v) => v + 1);
567
- };
568
- map.on("style.load", handleStyleLoad);
575
+ map.on("style.load", bumpStyleVersion);
569
576
  return () => {
570
- map.off("style.load", handleStyleLoad);
577
+ map.off("style.load", bumpStyleVersion);
571
578
  };
572
- }, [mapLoaded]);
579
+ }, [mapLoaded, bumpStyleVersion]);
573
580
  const styleInitialized = React26__namespace.useRef(false);
574
581
  React26__namespace.useEffect(() => {
575
582
  if (!mapRef.current || !mapLoaded) return;
package/dist/index.js CHANGED
@@ -323,6 +323,7 @@ var Map2 = React26.forwardRef(
323
323
  doubleClickZoom = true,
324
324
  touchZoomRotate = true,
325
325
  keyboard = true,
326
+ cooperativeGestures,
326
327
  attributionControl = true,
327
328
  customAttribution,
328
329
  navigationControl = true,
@@ -350,6 +351,11 @@ var Map2 = React26.forwardRef(
350
351
  const [mapLoaded, setMapLoaded] = React26.useState(false);
351
352
  const [mapError, setMapError] = React26.useState(null);
352
353
  const [styleVersion, setStyleVersion] = React26.useState(0);
354
+ const styleVersionRef = React26.useRef(0);
355
+ const bumpStyleVersion = React26.useCallback(() => {
356
+ styleVersionRef.current += 1;
357
+ setStyleVersion(styleVersionRef.current);
358
+ }, []);
353
359
  const activeStyleOverrideRef = React26.useRef(
354
360
  null
355
361
  );
@@ -358,16 +364,19 @@ var Map2 = React26.forwardRef(
358
364
  positioningCoordinatorRef.current = createPositioningCoordinator();
359
365
  }
360
366
  const positioningCoordinator = positioningCoordinatorRef.current;
361
- const setMapStyle = React26.useCallback((style) => {
362
- activeStyleOverrideRef.current = style;
363
- const map = mapRef.current;
364
- if (map) {
367
+ const setMapStyle = React26.useCallback(
368
+ (style) => {
369
+ activeStyleOverrideRef.current = style;
370
+ const map = mapRef.current;
371
+ if (!map) return;
372
+ const versionBefore = styleVersionRef.current;
365
373
  map.setStyle(style);
366
374
  map.once("idle", () => {
367
- setStyleVersion((v) => v + 1);
375
+ if (styleVersionRef.current === versionBefore) bumpStyleVersion();
368
376
  });
369
- }
370
- }, []);
377
+ },
378
+ [bumpStyleVersion]
379
+ );
371
380
  const prefersReducedMotion = useReducedMotion();
372
381
  const { style: themeStyle } = useMapTheme(themePref);
373
382
  const onLoadRef = React26.useRef(onLoad);
@@ -420,6 +429,7 @@ var Map2 = React26.forwardRef(
420
429
  doubleClickZoom,
421
430
  touchZoomRotate,
422
431
  keyboard,
432
+ cooperativeGestures,
423
433
  attributionControl: attributionControl ? { customAttribution } : false
424
434
  });
425
435
  mapRef.current = map;
@@ -538,14 +548,11 @@ var Map2 = React26.forwardRef(
538
548
  React26.useEffect(() => {
539
549
  const map = mapRef.current;
540
550
  if (!map || !mapLoaded) return;
541
- const handleStyleLoad = () => {
542
- setStyleVersion((v) => v + 1);
543
- };
544
- map.on("style.load", handleStyleLoad);
551
+ map.on("style.load", bumpStyleVersion);
545
552
  return () => {
546
- map.off("style.load", handleStyleLoad);
553
+ map.off("style.load", bumpStyleVersion);
547
554
  };
548
- }, [mapLoaded]);
555
+ }, [mapLoaded, bumpStyleVersion]);
549
556
  const styleInitialized = React26.useRef(false);
550
557
  React26.useEffect(() => {
551
558
  if (!mapRef.current || !mapLoaded) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-react",
3
- "version": "0.2.14",
3
+ "version": "0.3.1",
4
4
  "description": "React MapLibre components for Classic Theme",
5
5
  "keywords": [
6
6
  "maps",