@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.mjs CHANGED
@@ -5896,6 +5896,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5896
5896
  externalPersistence = false,
5897
5897
  enableKeyboardShortcuts = true,
5898
5898
  enableProperties = true,
5899
+ autoOpenProperties = true,
5899
5900
  toastProvider,
5900
5901
  customGlobalMenuItems,
5901
5902
  extraLayerToolbarButtons,
@@ -5977,6 +5978,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5977
5978
  const isDrawingRectangle = useRef(false);
5978
5979
  const rectangleCornerPointRef = useRef(null);
5979
5980
  const justCreatedRectangleRef = useRef(false);
5981
+ const justCreatedFeatureRef = useRef(false);
5980
5982
  const [autoLabelConfig, setAutoLabelConfig] = useState({ enabled: true, threshold: 220 });
5981
5983
  const [visibleFeatureCount, setVisibleFeatureCount] = useState(Infinity);
5982
5984
  const lastLabelVisibility = useRef(false);
@@ -7805,6 +7807,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7805
7807
  });
7806
7808
  const processedFeatureIds = /* @__PURE__ */ new Set();
7807
7809
  mapInstance.on("draw.create", (e) => {
7810
+ justCreatedFeatureRef.current = true;
7811
+ setTimeout(() => {
7812
+ justCreatedFeatureRef.current = false;
7813
+ }, 0);
7808
7814
  const newFeatures = e.features.filter((f) => {
7809
7815
  const id = f.id;
7810
7816
  if (processedFeatureIds.has(id)) return false;
@@ -7989,7 +7995,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7989
7995
  });
7990
7996
  setSelectedFeatureIds(ids);
7991
7997
  selectedFeatureIdsRef.current = ids;
7992
- if (enableProperties) setShowProperties(ids.length > 0);
7998
+ const wasJustCreated = justCreatedFeatureRef.current;
7999
+ justCreatedFeatureRef.current = false;
8000
+ if (enableProperties && (autoOpenProperties || !wasJustCreated)) {
8001
+ setShowProperties(ids.length > 0);
8002
+ }
7993
8003
  syncRef.current();
7994
8004
  onFeatureSelect == null ? void 0 : onFeatureSelect(e.features);
7995
8005
  });
@@ -9239,13 +9249,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9239
9249
  });
9240
9250
  draw.current.changeMode("simple_select", { featureIds: [id] });
9241
9251
  setSelectedFeatureIds([id]);
9242
- if (enableProperties) setShowProperties(true);
9252
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
9243
9253
  updateFeatureCount();
9244
9254
  scheduleTimelineUpdate();
9245
9255
  saveStateForUndo();
9246
9256
  syncFeaturesToCustomLayers();
9247
9257
  onFeatureCreate == null ? void 0 : onFeatureCreate(feature);
9248
- }, [isMapLoaded, externalPersistence, enableProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, onFeatureCreate]);
9258
+ }, [isMapLoaded, externalPersistence, enableProperties, autoOpenProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, onFeatureCreate]);
9249
9259
  const handleFeatureContextMenu = useCallback((e) => {
9250
9260
  var _a, _b;
9251
9261
  contextMenuFiredRef.current = true;
@@ -10921,7 +10931,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10921
10931
  drawInstance.changeMode("simple_select", { featureIds: [featureId] });
10922
10932
  setActiveMode("simple_select");
10923
10933
  setSelectedFeatureIds([featureId]);
10924
- if (enableProperties) setShowProperties(true);
10934
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
10925
10935
  if (onFeatureCreate) {
10926
10936
  onFeatureCreate(circleFeature);
10927
10937
  }
@@ -10954,7 +10964,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10954
10964
  map.current.getCanvas().style.cursor = "";
10955
10965
  }
10956
10966
  };
10957
- }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties]);
10967
+ }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties, autoOpenProperties]);
10958
10968
  useEffect(() => {
10959
10969
  if (!map.current || !isMapLoaded || !draw.current) return;
10960
10970
  if (activeMode !== "draw_rectangle") {
@@ -11049,7 +11059,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11049
11059
  drawInstance.changeMode("simple_select", { featureIds: [featureId] });
11050
11060
  setActiveMode("simple_select");
11051
11061
  setSelectedFeatureIds([featureId]);
11052
- if (enableProperties) setShowProperties(true);
11062
+ if (enableProperties && autoOpenProperties) setShowProperties(true);
11053
11063
  if (onFeatureCreate) {
11054
11064
  onFeatureCreate(rectFeature);
11055
11065
  }
@@ -11082,7 +11092,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11082
11092
  map.current.getCanvas().style.cursor = "";
11083
11093
  }
11084
11094
  };
11085
- }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties]);
11095
+ }, [activeMode, isMapLoaded, onFeatureCreate, enableProperties, autoOpenProperties]);
11086
11096
  const measurePointsRef = useRef([]);
11087
11097
  useEffect(() => {
11088
11098
  measurePointsRef.current = measurePoints;