@octostar/map-component 0.1.32 → 0.1.34

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/README.md CHANGED
@@ -4,6 +4,19 @@ A powerful MapLibre-based map editor component for React applications. Provides
4
4
 
5
5
  > **⚠️ Proprietary Software**: This package is proprietary to Octostar Limited. Unauthorized use is prohibited.
6
6
 
7
+ ## Versioning & Releases
8
+
9
+ Versioning is driven by [GitVersion 6](https://gitversion.net/) (`GitVersion.yml`, `GitHubFlow/v1`). Every push to `main` (outside `*.md`/`docs/**`) computes the next semantic version, pushes the matching `v<version>` git tag, publishes the package to npm, and creates a GitHub release with generated notes.
10
+
11
+ The default increment is **patch** — each merge to `main` bumps the patch version (e.g. `0.1.32` → `0.1.33`). Override the bump from a commit/PR message:
12
+
13
+ | Directive | Effect |
14
+ |--------------------|---------------------------------|
15
+ | `+semver: major` | Bump the major version |
16
+ | `+semver: minor` | Bump the minor version |
17
+ | `+semver: patch` | Bump the patch version (default)|
18
+ | `+semver: none` | No version bump |
19
+
7
20
  ## Prerequisites
8
21
 
9
22
  - Node.js 20+ (see `.nvmrc`)
package/dist/index.cjs CHANGED
@@ -494,7 +494,9 @@ function DrawingToolbar({
494
494
  expandSelectionTools = false,
495
495
  showFilterTool = false,
496
496
  getAllFeatures,
497
- onFlyToFeature
497
+ onFlyToFeature,
498
+ canDeleteSelected = true,
499
+ showUndoRedo = false
498
500
  }) {
499
501
  const { toast } = useToast();
500
502
  const [goToLat, setGoToLat] = react.useState("");
@@ -795,30 +797,32 @@ function DrawingToolbar({
795
797
  });
796
798
  }
797
799
  items.push({ type: "divider" });
798
- items.push({
799
- key: "undo",
800
- label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
801
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
802
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "w-4 h-4" }),
803
- "Undo"
800
+ if (showUndoRedo) {
801
+ items.push({
802
+ key: "undo",
803
+ label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
804
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
805
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "w-4 h-4" }),
806
+ "Undo"
807
+ ] }),
808
+ showShortcutHints && /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Z" })
804
809
  ] }),
805
- showShortcutHints && /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Z" })
806
- ] }),
807
- disabled: disabled || !canUndo,
808
- onClick: onUndo
809
- });
810
- items.push({
811
- key: "redo",
812
- label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
813
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
814
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "w-4 h-4" }),
815
- "Redo"
810
+ disabled: disabled || !canUndo,
811
+ onClick: onUndo
812
+ });
813
+ items.push({
814
+ key: "redo",
815
+ label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
816
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
817
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "w-4 h-4" }),
818
+ "Redo"
819
+ ] }),
820
+ showShortcutHints && /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Y" })
816
821
  ] }),
817
- showShortcutHints && /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Y" })
818
- ] }),
819
- disabled: disabled || !canRedo,
820
- onClick: onRedo
821
- });
822
+ disabled: disabled || !canRedo,
823
+ onClick: onRedo
824
+ });
825
+ }
822
826
  items.push({ type: "divider" });
823
827
  items.push({
824
828
  key: "delete",
@@ -1247,55 +1251,57 @@ function DrawingToolbar({
1247
1251
  showShortcutHint: showShortcutHints
1248
1252
  }
1249
1253
  ),
1250
- /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-0 !min-w-0" }),
1251
- /* @__PURE__ */ jsxRuntime.jsx(
1252
- antd.Tooltip,
1253
- {
1254
- title: showShortcutHints ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1255
- "Undo",
1256
- /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Z" })
1257
- ] }) : "Undo",
1258
- placement: "right",
1259
- children: /* @__PURE__ */ jsxRuntime.jsx(
1260
- antd.Button,
1261
- {
1262
- type: "text",
1263
- onClick: onUndo,
1264
- disabled: disabled || !canUndo,
1265
- "aria-label": "Undo",
1266
- "data-testid": "button-undo",
1267
- className: "flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
1268
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "w-5 h-5" })
1269
- }
1270
- )
1271
- }
1272
- ),
1273
- /* @__PURE__ */ jsxRuntime.jsx(
1274
- antd.Tooltip,
1275
- {
1276
- title: showShortcutHints ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1277
- "Redo",
1278
- /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Y" })
1279
- ] }) : "Redo",
1280
- placement: "right",
1281
- children: /* @__PURE__ */ jsxRuntime.jsx(
1282
- antd.Button,
1283
- {
1284
- type: "text",
1285
- onClick: onRedo,
1286
- disabled: disabled || !canRedo,
1287
- "aria-label": "Redo",
1288
- "data-testid": "button-redo",
1289
- className: "flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
1290
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "w-5 h-5" })
1291
- }
1292
- )
1293
- }
1294
- )
1254
+ showUndoRedo && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1255
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-0 !min-w-0" }),
1256
+ /* @__PURE__ */ jsxRuntime.jsx(
1257
+ antd.Tooltip,
1258
+ {
1259
+ title: showShortcutHints ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1260
+ "Undo",
1261
+ /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Z" })
1262
+ ] }) : "Undo",
1263
+ placement: "right",
1264
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1265
+ antd.Button,
1266
+ {
1267
+ type: "text",
1268
+ onClick: onUndo,
1269
+ disabled: disabled || !canUndo,
1270
+ "aria-label": "Undo",
1271
+ "data-testid": "button-undo",
1272
+ className: "flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
1273
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "w-5 h-5" })
1274
+ }
1275
+ )
1276
+ }
1277
+ ),
1278
+ /* @__PURE__ */ jsxRuntime.jsx(
1279
+ antd.Tooltip,
1280
+ {
1281
+ title: showShortcutHints ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1282
+ "Redo",
1283
+ /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Y" })
1284
+ ] }) : "Redo",
1285
+ placement: "right",
1286
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1287
+ antd.Button,
1288
+ {
1289
+ type: "text",
1290
+ onClick: onRedo,
1291
+ disabled: disabled || !canRedo,
1292
+ "aria-label": "Redo",
1293
+ "data-testid": "button-redo",
1294
+ className: "flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
1295
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "w-5 h-5" })
1296
+ }
1297
+ )
1298
+ }
1299
+ )
1300
+ ] })
1295
1301
  ] }),
1296
1302
  compactOverflowItems
1297
1303
  ] }),
1298
- selectedCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1304
+ selectedCount > 0 && canDeleteSelected && /* @__PURE__ */ jsxRuntime.jsx(
1299
1305
  antd.Tooltip,
1300
1306
  {
1301
1307
  title: showShortcutHints ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
@@ -5789,6 +5795,19 @@ const EXTERNAL_STYLE_URLS = {
5789
5795
  streets: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
5790
5796
  dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
5791
5797
  };
5798
+ function computeUndoRedoEvent(fromState, toState) {
5799
+ const fromIds = new Set(fromState.features.map((f) => f.id));
5800
+ const toIds = new Set(toState.features.map((f) => f.id));
5801
+ const restoredFeatures = toState.features.filter((f) => !fromIds.has(f.id)).map((f) => {
5802
+ var _a;
5803
+ return {
5804
+ feature: f,
5805
+ layerId: ((_a = toState.layers.find((l) => l.featureIds.includes(f.id))) == null ? void 0 : _a.id) ?? null
5806
+ };
5807
+ });
5808
+ const removedFeatureIds = fromState.features.filter((f) => !toIds.has(f.id)).map((f) => f.id);
5809
+ return { restoredFeatures, removedFeatureIds };
5810
+ }
5792
5811
  const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5793
5812
  className,
5794
5813
  enableDrawing = true,
@@ -5816,10 +5835,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5816
5835
  onFeatureCreate,
5817
5836
  onFeatureUpdate,
5818
5837
  onFeatureDelete,
5838
+ onUndo,
5839
+ onRedo,
5819
5840
  onLayerChange,
5820
5841
  onActiveEditingLayerChange,
5821
5842
  onTimelineChange,
5822
5843
  onMapReady,
5844
+ onMapLoad,
5823
5845
  onViewportChange,
5824
5846
  showClearFilter = false,
5825
5847
  onClearFilter,
@@ -5930,6 +5952,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5930
5952
  const [rectangleDrawCorner, setRectangleDrawCorner] = react.useState(null);
5931
5953
  const [rectangleDrawPreview, setRectangleDrawPreview] = react.useState(null);
5932
5954
  const isDrawingRectangle = react.useRef(false);
5955
+ const rectangleCornerPointRef = react.useRef(null);
5956
+ const justCreatedRectangleRef = react.useRef(false);
5933
5957
  const [autoLabelConfig, setAutoLabelConfig] = react.useState({ enabled: true, threshold: 220 });
5934
5958
  const [visibleFeatureCount, setVisibleFeatureCount] = react.useState(Infinity);
5935
5959
  const lastLabelVisibility = react.useRef(false);
@@ -6051,6 +6075,27 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6051
6075
  }
6052
6076
  return null;
6053
6077
  }, []);
6078
+ const canDeleteSelected = react.useMemo(() => {
6079
+ if (selectedFeatureIds.length === 0) return false;
6080
+ return selectedFeatureIds.some((id) => {
6081
+ var _a;
6082
+ const feature = getFeatureById(id);
6083
+ if (!feature) return false;
6084
+ const geom = feature.geometry.type;
6085
+ const kind = (_a = feature.properties) == null ? void 0 : _a.kind;
6086
+ const isArrow = kind === "arrow" || arrowFeatureIdsRef.current.has(id);
6087
+ if (geom === "Point") {
6088
+ return kind === "text" ? !hiddenDrawingTools.includes("text") : !hiddenDrawingTools.includes("point");
6089
+ }
6090
+ if (geom === "LineString" || geom === "MultiLineString") {
6091
+ return isArrow ? !hiddenDrawingTools.includes("arrow") : !hiddenDrawingTools.includes("line");
6092
+ }
6093
+ if (geom === "Polygon" || geom === "MultiPolygon") {
6094
+ return kind === "circle" ? !hiddenDrawingTools.includes("circle") : !hiddenDrawingTools.includes("polygon");
6095
+ }
6096
+ return true;
6097
+ });
6098
+ }, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
6054
6099
  const applySelectionState = react.useCallback((nextIds, options) => {
6055
6100
  if (!isMapLoaded || !draw.current) {
6056
6101
  setSelectedFeatureIds(nextIds);
@@ -6095,12 +6140,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6095
6140
  if (!draw.current) return;
6096
6141
  const currentState = {
6097
6142
  features: draw.current.getAll().features,
6098
- layers: JSON.parse(JSON.stringify(layers)),
6143
+ layers: JSON.parse(JSON.stringify(layersRef.current)),
6099
6144
  selectedIds: [...selectedFeatureIds]
6100
6145
  };
6101
6146
  setUndoStack((prev) => [...prev.slice(-49), currentState]);
6102
6147
  setRedoStack([]);
6103
- }, [layers, selectedFeatureIds]);
6148
+ }, [selectedFeatureIds]);
6104
6149
  const updateFeatureCount = react.useCallback(() => {
6105
6150
  const drawFeatureCount = draw.current ? draw.current.getAll().features.length : 0;
6106
6151
  let hiddenCount = 0;
@@ -7623,6 +7668,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7623
7668
  setActiveMode(initialDrawingMode);
7624
7669
  }
7625
7670
  onMapReady == null ? void 0 : onMapReady();
7671
+ onMapLoad == null ? void 0 : onMapLoad(mapInstance);
7626
7672
  if (baseMapStyle !== "satellite") {
7627
7673
  const customDef = customBasemaps == null ? void 0 : customBasemaps[baseMapStyle];
7628
7674
  const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : EXTERNAL_STYLE_URLS[baseMapStyle];
@@ -7803,25 +7849,20 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7803
7849
  }
7804
7850
  if (!isApiAddingRef.current) {
7805
7851
  const currentActiveEditingLayerId = activeEditingLayerIdRef.current;
7806
- setLayers((prev) => {
7807
- let targetLayer = prev.find((l) => l.id === currentActiveEditingLayerId && l.visible && !l.readOnly);
7808
- if (!targetLayer) {
7809
- targetLayer = prev.find((l) => l.visible && !l.readOnly);
7810
- }
7811
- if (!targetLayer) {
7812
- targetLayer = prev.find((l) => !l.readOnly);
7813
- }
7814
- if (!targetLayer) return prev;
7815
- return prev.map((layer) => {
7816
- if (layer.id === targetLayer.id) {
7817
- return {
7818
- ...layer,
7819
- featureIds: [...layer.featureIds, ...newFeatures.map((f) => f.id)]
7820
- };
7821
- }
7822
- return layer;
7823
- });
7824
- });
7852
+ const currentLayers = layersRef.current;
7853
+ const newIds = newFeatures.map((f) => f.id);
7854
+ let targetLayer = currentLayers.find((l) => l.id === currentActiveEditingLayerId && l.visible && !l.readOnly);
7855
+ if (!targetLayer) targetLayer = currentLayers.find((l) => l.visible && !l.readOnly);
7856
+ if (!targetLayer) targetLayer = currentLayers.find((l) => !l.readOnly);
7857
+ if (targetLayer) {
7858
+ const targetId = targetLayer.id;
7859
+ setLayers((prev) => prev.map(
7860
+ (layer) => layer.id === targetId ? { ...layer, featureIds: [...layer.featureIds, ...newIds] } : layer
7861
+ ));
7862
+ layersRef.current = currentLayers.map(
7863
+ (layer) => layer.id === targetId ? { ...layer, featureIds: [...layer.featureIds, ...newIds] } : layer
7864
+ );
7865
+ }
7825
7866
  }
7826
7867
  updateFeatureCount();
7827
7868
  scheduleTimelineUpdate();
@@ -7903,6 +7944,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7903
7944
  return;
7904
7945
  }
7905
7946
  const ids = e.features.map((f) => f.id);
7947
+ if (justCreatedRectangleRef.current && ids.length === 0) {
7948
+ justCreatedRectangleRef.current = false;
7949
+ return;
7950
+ }
7906
7951
  e.features.forEach((feature) => {
7907
7952
  const fid = feature.id;
7908
7953
  if (!originalGeometriesRef.current.has(fid)) {
@@ -8502,9 +8547,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8502
8547
  onTimelineChange == null ? void 0 : onTimelineChange(start, end);
8503
8548
  },
8504
8549
  exportGeoJSON: (layerIds) => {
8505
- const targetLayerIds = layerIds ?? layers.map((l) => l.id);
8550
+ const targetLayerIds = layerIds ?? layersRef.current.map((l) => l.id);
8506
8551
  const allFeatures = [];
8507
- layers.filter((l) => targetLayerIds.includes(l.id)).forEach((layer) => {
8552
+ layersRef.current.filter((l) => targetLayerIds.includes(l.id)).forEach((layer) => {
8508
8553
  const readOnly = readOnlyFeatures.current.get(layer.id);
8509
8554
  if (readOnly) {
8510
8555
  allFeatures.push(...readOnly);
@@ -8906,7 +8951,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8906
8951
  layerTemporalCacheRef.current.clear();
8907
8952
  scheduleTimelineUpdate();
8908
8953
  syncFeaturesToCustomLayers();
8909
- }, [undoStack, layers, selectedFeatureIds, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, applySelectionState]);
8954
+ layersRef.current = prevState.layers;
8955
+ onUndo == null ? void 0 : onUndo(computeUndoRedoEvent(currentState, prevState));
8956
+ }, [undoStack, layers, selectedFeatureIds, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, applySelectionState, onUndo]);
8910
8957
  const handleRedo = react.useCallback(() => {
8911
8958
  if (redoStack.length === 0 || !draw.current) return;
8912
8959
  const currentState = {
@@ -8931,7 +8978,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8931
8978
  layerTemporalCacheRef.current.clear();
8932
8979
  scheduleTimelineUpdate();
8933
8980
  syncFeaturesToCustomLayers();
8934
- }, [redoStack, layers, selectedFeatureIds, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, applySelectionState]);
8981
+ layersRef.current = nextState.layers;
8982
+ onRedo == null ? void 0 : onRedo(computeUndoRedoEvent(currentState, nextState));
8983
+ }, [redoStack, layers, selectedFeatureIds, updateFeatureCount, scheduleTimelineUpdate, syncFeaturesToCustomLayers, applySelectionState, onRedo]);
8935
8984
  const handleClear = react.useCallback(() => {
8936
8985
  if (!draw.current) return;
8937
8986
  const activeLayer = layersRef.current.find((l) => l.id === activeEditingLayerId);
@@ -9087,7 +9136,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9087
9136
  handleToggleEditMode();
9088
9137
  return;
9089
9138
  }
9090
- if ((key === "delete" || key === "backspace") && !isCtrlOrCmd && selectedFeatureIds.length > 0) {
9139
+ if ((key === "delete" || key === "backspace") && !isCtrlOrCmd && selectedFeatureIds.length > 0 && canDeleteSelected) {
9091
9140
  e.preventDefault();
9092
9141
  handleDeleteSelected();
9093
9142
  return;
@@ -9130,7 +9179,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9130
9179
  };
9131
9180
  container.addEventListener("keydown", handleKeyDown);
9132
9181
  return () => container.removeEventListener("keydown", handleKeyDown);
9133
- }, [isMapLoaded, enableKeyboardShortcuts, isEditMode, activeMode, handleToggleEditMode, handleUndo, handleRedo, handleModeChange, selectedFeatureIds, handleDeleteSelected]);
9182
+ }, [isMapLoaded, enableKeyboardShortcuts, isEditMode, activeMode, handleToggleEditMode, handleUndo, handleRedo, handleModeChange, selectedFeatureIds, handleDeleteSelected, canDeleteSelected]);
9134
9183
  const createPointAtCoords = react.useCallback((lng, lat) => {
9135
9184
  if (!draw.current || !isMapLoaded) return;
9136
9185
  if (!isEditModeRef.current) {
@@ -9257,7 +9306,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9257
9306
  return;
9258
9307
  }
9259
9308
  }
9260
- if (features.length === 0) {
9309
+ if (features.length === 0 && !hiddenDrawingTools.includes("point")) {
9261
9310
  e.preventDefault();
9262
9311
  const canCreate = hasEditableLayer;
9263
9312
  const items = [
@@ -9272,7 +9321,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9272
9321
  ];
9273
9322
  setContextMenu({ x: e.clientX, y: e.clientY, items });
9274
9323
  }
9275
- }, [contextMenuProvider, isEditMode, hasEditableLayer, onEntityContextMenu, createPointAtCoords]);
9324
+ }, [contextMenuProvider, isEditMode, hasEditableLayer, onEntityContextMenu, createPointAtCoords, hiddenDrawingTools]);
9276
9325
  react.useEffect(() => {
9277
9326
  if (!isMapLoaded || !map.current) return;
9278
9327
  const canvas = map.current.getCanvas();
@@ -10874,6 +10923,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10874
10923
  react.useEffect(() => {
10875
10924
  if (!map.current || !isMapLoaded || !draw.current) return;
10876
10925
  if (activeMode !== "draw_rectangle") {
10926
+ rectangleCornerPointRef.current = null;
10877
10927
  setRectangleDrawCorner(null);
10878
10928
  setRectangleDrawPreview(null);
10879
10929
  isDrawingRectangle.current = false;
@@ -10884,18 +10934,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10884
10934
  const canvas = mapInstance.getCanvas();
10885
10935
  mapInstance.dragPan.disable();
10886
10936
  canvas.style.cursor = "crosshair";
10887
- let cornerPoint = null;
10888
10937
  const handleMouseDown = (e) => {
10889
10938
  if (e.button !== 0) return;
10890
10939
  const lngLat = mapInstance.unproject([e.offsetX, e.offsetY]);
10891
- cornerPoint = { lngLat: [lngLat.lng, lngLat.lat] };
10940
+ rectangleCornerPointRef.current = { lngLat: [lngLat.lng, lngLat.lat] };
10892
10941
  isDrawingRectangle.current = true;
10893
10942
  setRectangleDrawCorner([lngLat.lng, lngLat.lat]);
10894
10943
  };
10895
10944
  const handleMouseMove = (e) => {
10896
- if (!isDrawingRectangle.current || !cornerPoint) return;
10897
- const oppositeCorner = mapInstance.unproject([e.offsetX, e.offsetY]);
10898
- const [x1, y1] = cornerPoint.lngLat;
10945
+ if (!isDrawingRectangle.current || !rectangleCornerPointRef.current) return;
10946
+ const rect = canvas.getBoundingClientRect();
10947
+ const oppositeCorner = mapInstance.unproject([e.clientX - rect.left, e.clientY - rect.top]);
10948
+ const [x1, y1] = rectangleCornerPointRef.current.lngLat;
10899
10949
  const [x2, y2] = [oppositeCorner.lng, oppositeCorner.lat];
10900
10950
  const rectCoords = [
10901
10951
  [x1, y1],
@@ -10912,9 +10962,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10912
10962
  setRectangleDrawPreview(rectCoords);
10913
10963
  };
10914
10964
  const handleMouseUp = (e) => {
10915
- if (!isDrawingRectangle.current || !cornerPoint) return;
10916
- const oppositeCorner = mapInstance.unproject([e.offsetX, e.offsetY]);
10917
- const [x1, y1] = cornerPoint.lngLat;
10965
+ if (!isDrawingRectangle.current || !rectangleCornerPointRef.current) return;
10966
+ const rect = canvas.getBoundingClientRect();
10967
+ const oppositeCorner = mapInstance.unproject([e.clientX - rect.left, e.clientY - rect.top]);
10968
+ const [x1, y1] = rectangleCornerPointRef.current.lngLat;
10918
10969
  const [x2, y2] = [oppositeCorner.lng, oppositeCorner.lat];
10919
10970
  const width = Math.abs(x2 - x1);
10920
10971
  const height = Math.abs(y2 - y1);
@@ -10959,22 +11010,23 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10959
11010
  layers: layersRef.current
10960
11011
  }]);
10961
11012
  setRedoStack([]);
11013
+ justCreatedRectangleRef.current = true;
10962
11014
  drawInstance.changeMode("simple_select", { featureIds: [featureId] });
10963
11015
  setActiveMode("simple_select");
10964
11016
  setSelectedFeatureIds([featureId]);
10965
- if (enableProperties) setShowProperties(true);
11017
+ setShowProperties(true);
10966
11018
  if (onFeatureCreate) {
10967
11019
  onFeatureCreate(rectFeature);
10968
11020
  }
10969
11021
  }
10970
- cornerPoint = null;
11022
+ rectangleCornerPointRef.current = null;
10971
11023
  isDrawingRectangle.current = false;
10972
11024
  setRectangleDrawCorner(null);
10973
11025
  setRectangleDrawPreview(null);
10974
11026
  };
10975
11027
  const handleKeyDown = (e) => {
10976
11028
  if (e.key === "Escape") {
10977
- cornerPoint = null;
11029
+ rectangleCornerPointRef.current = null;
10978
11030
  isDrawingRectangle.current = false;
10979
11031
  setRectangleDrawCorner(null);
10980
11032
  setRectangleDrawPreview(null);
@@ -10982,13 +11034,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10982
11034
  }
10983
11035
  };
10984
11036
  canvas.addEventListener("mousedown", handleMouseDown);
10985
- canvas.addEventListener("mousemove", handleMouseMove);
10986
- canvas.addEventListener("mouseup", handleMouseUp);
11037
+ window.addEventListener("mousemove", handleMouseMove);
11038
+ window.addEventListener("mouseup", handleMouseUp);
10987
11039
  window.addEventListener("keydown", handleKeyDown);
10988
11040
  return () => {
10989
11041
  canvas.removeEventListener("mousedown", handleMouseDown);
10990
- canvas.removeEventListener("mousemove", handleMouseMove);
10991
- canvas.removeEventListener("mouseup", handleMouseUp);
11042
+ window.removeEventListener("mousemove", handleMouseMove);
11043
+ window.removeEventListener("mouseup", handleMouseUp);
10992
11044
  window.removeEventListener("keydown", handleKeyDown);
10993
11045
  if (map.current) {
10994
11046
  map.current.dragPan.enable();
@@ -12174,7 +12226,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12174
12226
  ] }) });
12175
12227
  }
12176
12228
  const toastContextValue = toastProvider ?? null;
12177
- return /* @__PURE__ */ jsxRuntime.jsx(ToastContext.Provider, { value: toastContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(MapDropZone, { onDrop: handleDropGeoJSON, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `map-container w-full h-full min-w-0 relative ${className || ""}`, "data-testid": "map-editor-canvas", children: [
12229
+ return /* @__PURE__ */ jsxRuntime.jsx(ToastContext.Provider, { value: toastContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(MapDropZone, { onDrop: handleDropGeoJSON, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `map-container w-full h-full min-w-0 relative overflow-hidden isolate ${className || ""}`, "data-testid": "map-editor-canvas", children: [
12178
12230
  /* @__PURE__ */ jsxRuntime.jsx(
12179
12231
  "div",
12180
12232
  {
@@ -12398,6 +12450,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12398
12450
  onRedo: handleRedo,
12399
12451
  featureCount,
12400
12452
  selectedCount: selectedFeatureIds.length,
12453
+ canDeleteSelected,
12401
12454
  canUndo: undoStack.length > 0,
12402
12455
  canRedo: redoStack.length > 0,
12403
12456
  disabled: !isMapLoaded,
@@ -13402,7 +13455,7 @@ function DraggableDroneFlight({ item }) {
13402
13455
  }
13403
13456
  );
13404
13457
  }
13405
- function DebugSidebar({ onAddRandomPoints, onImportKML, canAddFeatures = true, className, onCloseMap }) {
13458
+ function DebugSidebar({ onAddRandomPoints, onImportKML, onAddDomMarkers, onRemoveDomMarkers, canAddFeatures = true, className, onCloseMap }) {
13406
13459
  const [isGenerating, setIsGenerating] = react.useState(false);
13407
13460
  const [isDragOver, setIsDragOver] = react.useState(false);
13408
13461
  const [wizardOpen, setWizardOpen] = react.useState(false);
@@ -13570,6 +13623,32 @@ function DebugSidebar({ onAddRandomPoints, onImportKML, canAddFeatures = true, c
13570
13623
  "Add 100k NYC Points"
13571
13624
  ]
13572
13625
  }
13626
+ ),
13627
+ onAddDomMarkers && /* @__PURE__ */ jsxRuntime.jsxs(
13628
+ antd.Button,
13629
+ {
13630
+ type: "default",
13631
+ size: "small",
13632
+ onClick: onAddDomMarkers,
13633
+ className: "w-full flex items-center justify-center",
13634
+ "data-testid": "button-add-dom-markers",
13635
+ children: [
13636
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-4 h-4 mr-2" }),
13637
+ "Add DOM Markers (test)"
13638
+ ]
13639
+ }
13640
+ ),
13641
+ onRemoveDomMarkers && /* @__PURE__ */ jsxRuntime.jsx(
13642
+ antd.Button,
13643
+ {
13644
+ type: "default",
13645
+ size: "small",
13646
+ danger: true,
13647
+ onClick: onRemoveDomMarkers,
13648
+ className: "w-full flex items-center justify-center",
13649
+ "data-testid": "button-remove-dom-markers",
13650
+ children: "Remove DOM Markers"
13651
+ }
13573
13652
  )
13574
13653
  ] }),
13575
13654
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-2", children: "Sequential: 10 points going east, 1 day apart. NYC: points clustered around Manhattan. People: 5 people moving for 6 hours. 100k: Performance test." })