@classic-homes/maps-react 0.2.12 → 0.2.14

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
@@ -1181,6 +1181,11 @@ var Marker = React26__namespace.forwardRef(
1181
1181
  markerRef.current.setRotation(rotation);
1182
1182
  }
1183
1183
  }, [rotation]);
1184
+ React26__namespace.useEffect(() => {
1185
+ if (markerRef.current && offset) {
1186
+ markerRef.current.setOffset(offset);
1187
+ }
1188
+ }, [offset]);
1184
1189
  if (children && elementRef.current) {
1185
1190
  return ReactDOM__namespace.createPortal(children, elementRef.current);
1186
1191
  }
@@ -1470,12 +1475,22 @@ function useLayer({
1470
1475
  if (!map.getLayer(id)) return;
1471
1476
  map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
1472
1477
  }, [map, id, visible, layerAdded]);
1478
+ const lastAppliedPaintRef = React26__namespace.useRef(void 0);
1473
1479
  React26__namespace.useEffect(() => {
1474
1480
  if (!map || !layerAdded) return;
1475
1481
  if (!map.getLayer(id)) return;
1476
- Object.entries(paint).forEach(([key, value]) => {
1477
- map.setPaintProperty(id, key, value);
1478
- });
1482
+ const diff = mapsCore.getChangedPaintProps(lastAppliedPaintRef.current, paint);
1483
+ if (!diff.hasChanges) return;
1484
+ try {
1485
+ for (const [key, value] of Object.entries(diff.changed)) {
1486
+ map.setPaintProperty(id, key, value);
1487
+ }
1488
+ for (const key of diff.removed) {
1489
+ map.setPaintProperty(id, key, void 0);
1490
+ }
1491
+ lastAppliedPaintRef.current = paint ? { ...paint } : void 0;
1492
+ } catch {
1493
+ }
1479
1494
  }, [map, id, paint, layerAdded]);
1480
1495
  React26__namespace.useEffect(() => {
1481
1496
  if (!map || !layerAdded || !filter) return;
@@ -3366,6 +3381,8 @@ var DeckOverlay = ({
3366
3381
  const { map, loaded } = useMap();
3367
3382
  const overlayRef = React26__namespace.useRef(null);
3368
3383
  const MapboxOverlayRef = React26__namespace.useRef(null);
3384
+ const layersRef = React26__namespace.useRef(layers);
3385
+ layersRef.current = layers;
3369
3386
  React26__namespace.useEffect(() => {
3370
3387
  if (!map || !loaded) return;
3371
3388
  let cancelled = false;
@@ -3377,7 +3394,7 @@ var DeckOverlay = ({
3377
3394
  MapboxOverlayRef.current = MapboxOverlay;
3378
3395
  const overlay = new MapboxOverlay({
3379
3396
  interleaved,
3380
- layers,
3397
+ layers: layersRef.current,
3381
3398
  onHover,
3382
3399
  onClick,
3383
3400
  ...getCursor ? { getCursor } : {},
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
2
+ import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, FeatureClickEventParams, FeatureHoverEventParams, BaseLayerProps, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
3
3
  export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
4
4
  import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
2
+ import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, FeatureClickEventParams, FeatureHoverEventParams, BaseLayerProps, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
3
3
  export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
4
4
  import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import maplibregl from 'maplibre-gl';
7
7
  import 'maplibre-gl/dist/maplibre-gl.css';
8
8
  import '@classic-homes/maps-core/styles/controls.css';
9
9
  import '@classic-homes/maps-core/styles/marker.css';
10
- import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
10
+ import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, getChangedPaintProps, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
11
11
  export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, DEFAULT_BASEMAP, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, PRIMARY_BASEMAPS, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
12
12
  import * as ReactDOM from 'react-dom';
13
13
  import { panToFitPopup, normalizePadding } from '@classic-homes/maps-core/utils';
@@ -1157,6 +1157,11 @@ var Marker = React26.forwardRef(
1157
1157
  markerRef.current.setRotation(rotation);
1158
1158
  }
1159
1159
  }, [rotation]);
1160
+ React26.useEffect(() => {
1161
+ if (markerRef.current && offset) {
1162
+ markerRef.current.setOffset(offset);
1163
+ }
1164
+ }, [offset]);
1160
1165
  if (children && elementRef.current) {
1161
1166
  return ReactDOM.createPortal(children, elementRef.current);
1162
1167
  }
@@ -1446,12 +1451,22 @@ function useLayer({
1446
1451
  if (!map.getLayer(id)) return;
1447
1452
  map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
1448
1453
  }, [map, id, visible, layerAdded]);
1454
+ const lastAppliedPaintRef = React26.useRef(void 0);
1449
1455
  React26.useEffect(() => {
1450
1456
  if (!map || !layerAdded) return;
1451
1457
  if (!map.getLayer(id)) return;
1452
- Object.entries(paint).forEach(([key, value]) => {
1453
- map.setPaintProperty(id, key, value);
1454
- });
1458
+ const diff = getChangedPaintProps(lastAppliedPaintRef.current, paint);
1459
+ if (!diff.hasChanges) return;
1460
+ try {
1461
+ for (const [key, value] of Object.entries(diff.changed)) {
1462
+ map.setPaintProperty(id, key, value);
1463
+ }
1464
+ for (const key of diff.removed) {
1465
+ map.setPaintProperty(id, key, void 0);
1466
+ }
1467
+ lastAppliedPaintRef.current = paint ? { ...paint } : void 0;
1468
+ } catch {
1469
+ }
1455
1470
  }, [map, id, paint, layerAdded]);
1456
1471
  React26.useEffect(() => {
1457
1472
  if (!map || !layerAdded || !filter) return;
@@ -3342,6 +3357,8 @@ var DeckOverlay = ({
3342
3357
  const { map, loaded } = useMap();
3343
3358
  const overlayRef = React26.useRef(null);
3344
3359
  const MapboxOverlayRef = React26.useRef(null);
3360
+ const layersRef = React26.useRef(layers);
3361
+ layersRef.current = layers;
3345
3362
  React26.useEffect(() => {
3346
3363
  if (!map || !loaded) return;
3347
3364
  let cancelled = false;
@@ -3353,7 +3370,7 @@ var DeckOverlay = ({
3353
3370
  MapboxOverlayRef.current = MapboxOverlay;
3354
3371
  const overlay = new MapboxOverlay({
3355
3372
  interleaved,
3356
- layers,
3373
+ layers: layersRef.current,
3357
3374
  onHover,
3358
3375
  onClick,
3359
3376
  ...getCursor ? { getCursor } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-react",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "React MapLibre components for Classic Theme",
5
5
  "keywords": [
6
6
  "maps",
@@ -33,8 +33,9 @@
33
33
  "scripts": {
34
34
  "build": "tsup",
35
35
  "dev": "tsup --watch",
36
- "clean": "rm -rf dist",
37
- "typecheck": "tsc --noEmit"
36
+ "clean": "node ../../scripts/rm.mjs dist",
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "vitest run"
38
39
  },
39
40
  "dependencies": {
40
41
  "@classic-homes/maps-core": "*",