@octostar/map-component 0.1.36 → 0.1.37

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
@@ -5917,6 +5917,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5917
5917
  externalPersistence = false,
5918
5918
  enableKeyboardShortcuts = true,
5919
5919
  enableProperties = true,
5920
+ autoOpenProperties = true,
5920
5921
  toastProvider,
5921
5922
  customGlobalMenuItems,
5922
5923
  extraLayerToolbarButtons,
@@ -5998,6 +5999,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5998
5999
  const isDrawingRectangle = react.useRef(false);
5999
6000
  const rectangleCornerPointRef = react.useRef(null);
6000
6001
  const justCreatedRectangleRef = react.useRef(false);
6002
+ const justCreatedFeatureRef = react.useRef(false);
6001
6003
  const [autoLabelConfig, setAutoLabelConfig] = react.useState({ enabled: true, threshold: 220 });
6002
6004
  const [visibleFeatureCount, setVisibleFeatureCount] = react.useState(Infinity);
6003
6005
  const lastLabelVisibility = react.useRef(false);
@@ -7826,6 +7828,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7826
7828
  });
7827
7829
  const processedFeatureIds = /* @__PURE__ */ new Set();
7828
7830
  mapInstance.on("draw.create", (e) => {
7831
+ justCreatedFeatureRef.current = true;
7832
+ setTimeout(() => {
7833
+ justCreatedFeatureRef.current = false;
7834
+ }, 0);
7829
7835
  const newFeatures = e.features.filter((f) => {
7830
7836
  const id = f.id;
7831
7837
  if (processedFeatureIds.has(id)) return false;
@@ -8010,7 +8016,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8010
8016
  });
8011
8017
  setSelectedFeatureIds(ids);
8012
8018
  selectedFeatureIdsRef.current = ids;
8013
- if (enableProperties) setShowProperties(ids.length > 0);
8019
+ const wasJustCreated = justCreatedFeatureRef.current;
8020
+ justCreatedFeatureRef.current = false;
8021
+ if (enableProperties && (autoOpenProperties || !wasJustCreated)) {
8022
+ setShowProperties(ids.length > 0);
8023
+ }
8014
8024
  syncRef.current();
8015
8025
  onFeatureSelect == null ? void 0 : onFeatureSelect(e.features);
8016
8026
  });
@@ -9260,13 +9270,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9260
9270
  });
9261
9271
  draw.current.changeMode("simple_select", { featureIds: [id] });
9262
9272
  setSelectedFeatureIds([id]);
9263
- if (enableProperties) setShowProperties(true);
9273
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
9264
9274
  updateFeatureCount();
9265
9275
  scheduleTimelineUpdate();
9266
9276
  saveStateForUndo();
9267
9277
  syncFeaturesToCustomLayers();
9268
9278
  onFeatureCreate == null ? void 0 : onFeatureCreate(feature);
9269
- }, [isMapLoaded, externalPersistence, enableProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, onFeatureCreate]);
9279
+ }, [isMapLoaded, externalPersistence, enableProperties, autoOpenProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, onFeatureCreate]);
9270
9280
  const handleFeatureContextMenu = react.useCallback((e) => {
9271
9281
  var _a, _b;
9272
9282
  contextMenuFiredRef.current = true;
@@ -10942,7 +10952,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10942
10952
  drawInstance.changeMode("simple_select", { featureIds: [featureId] });
10943
10953
  setActiveMode("simple_select");
10944
10954
  setSelectedFeatureIds([featureId]);
10945
- if (enableProperties) setShowProperties(true);
10955
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
10946
10956
  if (onFeatureCreate) {
10947
10957
  onFeatureCreate(circleFeature);
10948
10958
  }
@@ -10975,7 +10985,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10975
10985
  map.current.getCanvas().style.cursor = "";
10976
10986
  }
10977
10987
  };
10978
- }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties]);
10988
+ }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties, autoOpenProperties]);
10979
10989
  react.useEffect(() => {
10980
10990
  if (!map.current || !isMapLoaded || !draw.current) return;
10981
10991
  if (activeMode !== "draw_rectangle") {
@@ -11070,7 +11080,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11070
11080
  drawInstance.changeMode("simple_select", { featureIds: [featureId] });
11071
11081
  setActiveMode("simple_select");
11072
11082
  setSelectedFeatureIds([featureId]);
11073
- if (enableProperties) setShowProperties(true);
11083
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
11074
11084
  if (onFeatureCreate) {
11075
11085
  onFeatureCreate(rectFeature);
11076
11086
  }
@@ -11103,7 +11113,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11103
11113
  map.current.getCanvas().style.cursor = "";
11104
11114
  }
11105
11115
  };
11106
- }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties]);
11116
+ }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties, autoOpenProperties]);
11107
11117
  const measurePointsRef = react.useRef([]);
11108
11118
  react.useEffect(() => {
11109
11119
  measurePointsRef.current = measurePoints;