@octostar/map-component 0.1.30 → 0.1.32

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
@@ -10,6 +10,7 @@ import { saveAs } from "file-saver";
10
10
  import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
11
11
  import { clsx } from "clsx";
12
12
  import { twMerge } from "tailwind-merge";
13
+ import { createPortal } from "react-dom";
13
14
  import { format } from "date-fns";
14
15
  import { create } from "zustand";
15
16
  import dayjs from "dayjs";
@@ -2951,7 +2952,7 @@ function RecordFieldsSection({ feature }) {
2951
2952
  );
2952
2953
  }
2953
2954
  let persistedTabPreference = "properties";
2954
- function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures, getFeatureColor }) {
2955
+ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, entityCardPlacement = "tab", inlineEntityCardLabel = "Point Detail", typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures, getFeatureColor, anchorEl }) {
2955
2956
  var _a, _b, _c, _d, _e;
2956
2957
  const feature = selectedFeatures[0];
2957
2958
  const { toast } = useToast();
@@ -2987,6 +2988,28 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
2987
2988
  }
2988
2989
  prevMultiSelection.current = hasMultipleSelection;
2989
2990
  }, [hasMultipleSelection, entityCardProvider]);
2991
+ const [anchorRect, setAnchorRect] = useState(
2992
+ () => anchorEl ? anchorEl.getBoundingClientRect() : null
2993
+ );
2994
+ useEffect(() => {
2995
+ if (!anchorEl) {
2996
+ setAnchorRect(null);
2997
+ return;
2998
+ }
2999
+ const update = () => {
3000
+ setAnchorRect(anchorEl.getBoundingClientRect());
3001
+ };
3002
+ update();
3003
+ window.addEventListener("resize", update, { passive: true });
3004
+ window.addEventListener("scroll", update, { capture: true, passive: true });
3005
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
3006
+ observer == null ? void 0 : observer.observe(anchorEl);
3007
+ return () => {
3008
+ window.removeEventListener("resize", update);
3009
+ window.removeEventListener("scroll", update, { capture: true });
3010
+ observer == null ? void 0 : observer.disconnect();
3011
+ };
3012
+ }, [anchorEl]);
2990
3013
  const featureIds = selectedFeatures.map((f) => f.id);
2991
3014
  const targetLayers = (layers == null ? void 0 : layers.filter((l) => l.id !== layerId && !l.readOnly)) ?? [];
2992
3015
  const hasLayerActions = targetLayers.length > 0 || onCreateLayerAndMoveFeatures || onCreateLayerAndCopyFeatures;
@@ -4061,6 +4084,35 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4061
4084
  ] }, key)) })
4062
4085
  ] })
4063
4086
  ] }),
4087
+ entityCardPlacement === "inline-above" && entityCardProvider && !hasMultipleSelection && (() => {
4088
+ const inlineCard = entityCardProvider({
4089
+ type: "Feature",
4090
+ id: feature.id,
4091
+ geometry: feature.geometry,
4092
+ properties: feature.properties
4093
+ });
4094
+ if (!inlineCard) return null;
4095
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4096
+ /* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
4097
+ /* @__PURE__ */ jsx(
4098
+ Collapse,
4099
+ {
4100
+ size: "small",
4101
+ defaultActiveKey: ["inline-entity-card"],
4102
+ ghost: true,
4103
+ className: "[&_.ant-collapse-header]:!px-0 [&_.ant-collapse-header]:!py-1 [&_.ant-collapse-content-box]:!px-0 [&_.ant-collapse-content-box]:!py-1",
4104
+ items: [{
4105
+ key: "inline-entity-card",
4106
+ label: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
4107
+ /* @__PURE__ */ jsx(MapPin, { className: "w-3 h-3 text-foreground" }),
4108
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: inlineEntityCardLabel })
4109
+ ] }),
4110
+ children: inlineCard
4111
+ }]
4112
+ }
4113
+ )
4114
+ ] });
4115
+ })(),
4064
4116
  /* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
4065
4117
  /* @__PURE__ */ jsx(RecordFieldsSection, { feature }),
4066
4118
  /* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
@@ -4073,12 +4125,43 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4073
4125
  ] })
4074
4126
  ] });
4075
4127
  const panelContent = isRecord ? recordContent : propertiesContent;
4076
- if (entityCardProvider) {
4077
- return /* @__PURE__ */ jsxs(
4128
+ const COMMON_PANEL_CLASSES = "bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden";
4129
+ const EDGE_MARGIN = 16;
4130
+ const BOTTOM_MARGIN = 32;
4131
+ const computePanelPosition = (panelWidthPx, widthClass) => {
4132
+ if (!anchorEl) {
4133
+ return {
4134
+ className: `absolute top-4 right-4 z-10 ${widthClass} ${COMMON_PANEL_CLASSES}`,
4135
+ style: { maxHeight: "calc(100vh - 6rem)" }
4136
+ };
4137
+ }
4138
+ const anchorHidden = !anchorRect || anchorRect.width === 0 || anchorRect.height === 0 || anchorRect.bottom <= 0 || anchorRect.top >= window.innerHeight || anchorRect.right <= 0 || anchorRect.left >= window.innerWidth;
4139
+ if (anchorHidden) {
4140
+ return {
4141
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES} opacity-0 pointer-events-none`,
4142
+ // `display:none` (not just opacity:0) so the panel truly cannot
4143
+ // intercept clicks while hidden, even with `pointer-events: none`
4144
+ // disabled by a stray CSS rule somewhere upstream.
4145
+ style: { top: 0, left: 0, maxHeight: "calc(100vh - 6rem)", zIndex: 1e3, display: "none" }
4146
+ };
4147
+ }
4148
+ const top = Math.max(EDGE_MARGIN, anchorRect.top + EDGE_MARGIN);
4149
+ const desiredRight = window.innerWidth - anchorRect.right + EDGE_MARGIN;
4150
+ const right = Math.max(EDGE_MARGIN, Math.min(desiredRight, window.innerWidth - panelWidthPx - EDGE_MARGIN));
4151
+ const maxHeight = Math.max(160, window.innerHeight - top - BOTTOM_MARGIN);
4152
+ return {
4153
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES}`,
4154
+ style: { top, right, maxHeight, zIndex: 1e3 }
4155
+ };
4156
+ };
4157
+ const portalIfAnchored = (jsx2) => anchorEl ? createPortal(jsx2, document.body) : jsx2;
4158
+ if (entityCardProvider && (entityCardPlacement !== "inline-above" || hasMultipleSelection)) {
4159
+ const cardsPositioned = computePanelPosition(320, "w-80");
4160
+ const cardsPanel = /* @__PURE__ */ jsxs(
4078
4161
  "div",
4079
4162
  {
4080
- className: "absolute top-4 right-4 z-10 w-80 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
4081
- style: { maxHeight: "calc(100vh - 6rem)" },
4163
+ className: cardsPositioned.className,
4164
+ style: cardsPositioned.style,
4082
4165
  "data-testid": "panel-properties",
4083
4166
  children: [
4084
4167
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-background/95", children: [
@@ -4206,12 +4289,14 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4206
4289
  ]
4207
4290
  }
4208
4291
  );
4292
+ return portalIfAnchored(cardsPanel);
4209
4293
  }
4210
- return /* @__PURE__ */ jsxs(
4294
+ const positioned = computePanelPosition(288, "w-72");
4295
+ const panelJsx = /* @__PURE__ */ jsxs(
4211
4296
  "div",
4212
4297
  {
4213
- className: "absolute top-4 right-4 z-10 w-72 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
4214
- style: { maxHeight: "calc(100vh - 6rem)" },
4298
+ className: positioned.className,
4299
+ style: positioned.style,
4215
4300
  "data-testid": "panel-properties",
4216
4301
  children: [
4217
4302
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-background/95", children: [
@@ -4303,6 +4388,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4303
4388
  ]
4304
4389
  }
4305
4390
  );
4391
+ return portalIfAnchored(panelJsx);
4306
4392
  }
4307
4393
  function StatusIndicator({ featureCount, selectedCount = 0 }) {
4308
4394
  const hasSelection = selectedCount > 0;
@@ -5727,6 +5813,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5727
5813
  onMapStateLoaded,
5728
5814
  interceptGeoJSONFileLoad,
5729
5815
  entityCardProvider,
5816
+ entityCardPlacement,
5817
+ inlineEntityCardLabel,
5730
5818
  typePickerProvider,
5731
5819
  contextMenuProvider,
5732
5820
  featureSaveProvider,
@@ -5777,6 +5865,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5777
5865
  const handleMapStyleChangeRef = useRef(null);
5778
5866
  const flightPath3DLayerId = useRef(null);
5779
5867
  const update3DFlightPathsRef = useRef(null);
5868
+ const moveLabelsBeforeBasemapSymbolsRef = useRef(null);
5780
5869
  const tooltipProviderRef = useRef(tooltipProvider);
5781
5870
  tooltipProviderRef.current = tooltipProvider;
5782
5871
  const restoreEnrichedGeoJSONRef = useRef(null);
@@ -5871,6 +5960,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5871
5960
  window.removeEventListener("error", handleGlobalError, true);
5872
5961
  window.removeEventListener("unhandledrejection", handleUnhandledRejection, true);
5873
5962
  if (tooltipElRef.current) {
5963
+ const cleanup = tooltipElRef.current._cleanup;
5964
+ try {
5965
+ cleanup == null ? void 0 : cleanup();
5966
+ } catch {
5967
+ }
5874
5968
  try {
5875
5969
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
5876
5970
  } catch {
@@ -6191,7 +6285,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6191
6285
  const sourceData = {
6192
6286
  type: "FeatureCollection",
6193
6287
  features: allFeatures.map((f) => {
6194
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6288
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6195
6289
  const featureId = String(f.id);
6196
6290
  const layer = featureToLayer.get(featureId);
6197
6291
  const visualConfig = layer == null ? void 0 : layer.visualConfig;
@@ -6284,6 +6378,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6284
6378
  });
6285
6379
  }
6286
6380
  const isFeatureSelected = selectedIds.includes(featureId) ? 1 : 0;
6381
+ let labelPriority = 100;
6382
+ if (isFeatureSelected) {
6383
+ labelPriority = 0;
6384
+ } else if (traceLabel) {
6385
+ labelPriority = 5;
6386
+ } else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
6387
+ labelPriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
6388
+ } else {
6389
+ const idStr = String(featureId);
6390
+ let h = 0;
6391
+ for (let i = 0; i < idStr.length; i++) {
6392
+ h = (h << 5) - h + idStr.charCodeAt(i);
6393
+ h |= 0;
6394
+ }
6395
+ labelPriority = 100 + Math.abs(h) % 1e3;
6396
+ }
6287
6397
  return {
6288
6398
  type: "Feature",
6289
6399
  id: featureId,
@@ -6306,10 +6416,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6306
6416
  "stroke-width": strokeWidth,
6307
6417
  "stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
6308
6418
  fill: strokeColor,
6309
- "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_l = f.properties) == null ? void 0 : _l["fill-opacity"]) ?? 0.2 : 0,
6419
+ "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? 0.2 : 0,
6310
6420
  pointRadius,
6311
6421
  isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
6312
- isTimelineHidden: isTimelineVisible ? 0 : 1
6422
+ isTimelineHidden: isTimelineVisible ? 0 : 1,
6423
+ _labelPriority: labelPriority
6313
6424
  }
6314
6425
  };
6315
6426
  })
@@ -6977,36 +7088,36 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6977
7088
  // Text features: center anchor; others: top anchor
6978
7089
  "text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
6979
7090
  "text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
6980
- // Always allow overlap for every label this layer renders.
6981
- //
6982
- // The earlier `false` branch (for plain entity labels) was an
6983
- // attempt to thin dense clusters via MapLibre's collision
6984
- // detection. In practice it interacts poorly with this layer:
7091
+ // Native collision-based de-overlap.
6985
7092
  //
6986
- // - The `custom-labels` symbol layer has NO `icon-image`, so
6987
- // `text-optional: true` cannot fall back to "show icon, drop
6988
- // text". MapLibre instead drops the entire symbol when the
6989
- // text loses collision.
6990
- // - Vector basemaps (Streets / OSM Bright) place dense
6991
- // city / POI / street labels everywhere, and our entity
6992
- // label loses against ANY of them even at low zoom on an
6993
- // otherwise-empty map. The PR that introduced collision
6994
- // here only anticipated this happening "occasionally at
6995
- // very high zoom", but the empirical behaviour is far more
6996
- // aggressive.
7093
+ // History: a prior PR turned collision off (`text-allow-overlap: true`)
7094
+ // because basemap symbol layers (city / POI / street names from Carto
7095
+ // Voyager etc.) were processed FIRST by MapLibre's collision pipeline
7096
+ // (lower z-order = placed earlier), so our entity labels lost against
7097
+ // every basemap label -- even on near-empty maps. With `false`, freshly
7098
+ // dropped points rendered no label at all.
6997
7099
  //
6998
- // Net effect of the previous setting: a freshly dropped entity
6999
- // point on an editable layer rendered NO label at all on most
7000
- // basemaps, even with a single feature on the map.
7100
+ // The fix has two parts:
7101
+ // 1. (here) Re-enable collision and use `symbol-sort-key` to control
7102
+ // intra-layer priority. Selected/text/trace features win against
7103
+ // ordinary points so they keep their labels when crowded.
7104
+ // 2. (see `moveLabelsBeforeBasemapSymbols` below) After each basemap
7105
+ // load, move `custom-labels` BEFORE basemap symbol layers in the
7106
+ // style stack. MapLibre processes collision in painter order, so
7107
+ // placing our layer earlier makes entity labels claim space
7108
+ // first and basemap labels yield to us.
7001
7109
  //
7002
- // Reverting to unconditional `true` restores the previous
7003
- // (working) behaviour. Stacking in dense clusters should be
7004
- // addressed via a different mechanism (cluster/heatmap modes
7005
- // already exist; per-zoom font-size or a host-supplied
7006
- // collision opt-in are options if revisited).
7007
- "text-allow-overlap": true,
7110
+ // Net effect: dense clusters de-overlap automatically, important
7111
+ // features keep their labels, and basemap labels no longer suppress
7112
+ // entity labels. The auto-label threshold (autoLabelConfig.threshold)
7113
+ // remains as a hard cap for very dense viewports.
7114
+ "text-allow-overlap": false,
7008
7115
  "text-ignore-placement": false,
7009
7116
  "text-optional": true,
7117
+ "text-padding": 2,
7118
+ // Lower value = higher collision priority (placed first).
7119
+ // Computed per-feature in syncFeaturesToCustomLayers.
7120
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100],
7010
7121
  // Bold font for text features with fontWeight=bold, trace labels, others regular
7011
7122
  "text-font": [
7012
7123
  "case",
@@ -7098,12 +7209,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7098
7209
  }
7099
7210
  });
7100
7211
  if (tooltipElRef.current) {
7212
+ const prevCleanup = tooltipElRef.current._cleanup;
7213
+ try {
7214
+ prevCleanup == null ? void 0 : prevCleanup();
7215
+ } catch {
7216
+ }
7101
7217
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
7102
7218
  }
7103
7219
  const tooltipEl2 = document.createElement("div");
7104
7220
  tooltipEl2.className = "feature-tooltip-fixed";
7105
- tooltipEl2.style.cssText = "position:absolute;z-index:50;pointer-events:auto;display:none;max-width:320px;";
7106
- mapInstance.getContainer().appendChild(tooltipEl2);
7221
+ tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;";
7222
+ document.body.appendChild(tooltipEl2);
7107
7223
  tooltipElRef.current = tooltipEl2;
7108
7224
  let tooltipLngLat = null;
7109
7225
  let tooltipHideTimeout = null;
@@ -7118,17 +7234,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7118
7234
  if (!tooltipLngLat || tooltipEl2.style.display === "none") return;
7119
7235
  const point = mapInstance.project(tooltipLngLat);
7120
7236
  const container = mapInstance.getContainer();
7121
- const cw = container.clientWidth;
7122
- const ch = container.clientHeight;
7123
- tooltipEl2.style.maxWidth = Math.min(320, cw - 24) + "px";
7237
+ const rect = container.getBoundingClientRect();
7238
+ const ax = rect.left + point.x;
7239
+ const ay = rect.top + point.y;
7240
+ const vw = window.innerWidth;
7241
+ const vh = window.innerHeight;
7242
+ tooltipEl2.style.maxWidth = Math.min(480, vw - 24) + "px";
7124
7243
  const tw = tooltipEl2.offsetWidth || 200;
7125
7244
  const th = tooltipEl2.offsetHeight || 80;
7126
7245
  const gap = 12;
7127
- let left = point.x < cw / 2 ? point.x + gap : point.x - tw - gap;
7128
- let top = point.y - th - gap;
7129
- if (top < 4) top = point.y + gap;
7130
- if (left + tw > cw - 4) left = cw - tw - 4;
7131
- if (top + th > ch - 4) top = ch - th - 4;
7246
+ let left = ax < vw / 2 ? ax + gap : ax - tw - gap;
7247
+ let top = ay - th - gap;
7248
+ if (top < 4) top = ay + gap;
7249
+ if (left + tw > vw - 4) left = vw - tw - 4;
7250
+ if (top + th > vh - 4) top = vh - th - 4;
7132
7251
  left = Math.max(4, left);
7133
7252
  top = Math.max(4, top);
7134
7253
  tooltipEl2.style.left = left + "px";
@@ -7154,6 +7273,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7154
7273
  tooltipLngLatForPagination = null;
7155
7274
  };
7156
7275
  mapInstance.on("move", positionTooltip);
7276
+ const onWindowReposition = () => positionTooltip();
7277
+ window.addEventListener("scroll", onWindowReposition, { capture: true, passive: true });
7278
+ window.addEventListener("resize", onWindowReposition, { passive: true });
7279
+ tooltipEl2._cleanup = () => {
7280
+ window.removeEventListener("scroll", onWindowReposition, { capture: true });
7281
+ window.removeEventListener("resize", onWindowReposition);
7282
+ };
7157
7283
  const scheduleTooltipHide = () => {
7158
7284
  if (tooltipHideTimeout) clearTimeout(tooltipHideTimeout);
7159
7285
  tooltipHideTimeout = setTimeout(() => {
@@ -7482,6 +7608,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7482
7608
  if (styleUrl) {
7483
7609
  const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
7484
7610
  fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
7611
+ var _a2;
7485
7612
  const addedLayerIds = [];
7486
7613
  const resolveUrl = (url) => {
7487
7614
  if (/^https?:\/\//.test(url)) return url;
@@ -7537,6 +7664,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7537
7664
  }
7538
7665
  basemapLayerIds.current.set(baseMapStyle, addedLayerIds);
7539
7666
  loadedBasemaps.current.add(baseMapStyle);
7667
+ (_a2 = moveLabelsBeforeBasemapSymbolsRef.current) == null ? void 0 : _a2.call(moveLabelsBeforeBasemapSymbolsRef);
7540
7668
  const triggerResize = () => {
7541
7669
  try {
7542
7670
  mapInstance.resize();
@@ -7767,6 +7895,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7767
7895
  }
7768
7896
  });
7769
7897
  setSelectedFeatureIds(ids);
7898
+ selectedFeatureIdsRef.current = ids;
7770
7899
  setShowProperties(ids.length > 0);
7771
7900
  syncRef.current();
7772
7901
  onFeatureSelect == null ? void 0 : onFeatureSelect(e.features);
@@ -9210,13 +9339,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9210
9339
  } else {
9211
9340
  let updatedFeature;
9212
9341
  readOnlyFeatures.current.forEach((features, layerId) => {
9213
- var _a2;
9342
+ var _a2, _b2;
9214
9343
  const idx = features.findIndex((f) => String(f.id) === featureId);
9215
9344
  if (idx !== -1) {
9216
9345
  const f = features[idx];
9346
+ let hasRealChange = false;
9347
+ Object.entries(normalizedProperties).forEach(([key, value]) => {
9348
+ var _a3;
9349
+ const oldVal = (_a3 = f.properties) == null ? void 0 : _a3[key];
9350
+ if (JSON.stringify(oldVal) !== JSON.stringify(value)) hasRealChange = true;
9351
+ });
9352
+ const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
9217
9353
  f.properties = { ...f.properties, ...normalizedProperties };
9218
- if (!externalPersistence) f.properties._unsaved = true;
9219
- if (properties.kind === "text" || ((_a2 = f.properties) == null ? void 0 : _a2.kind) === "text") {
9354
+ if (!externalPersistence && hasRealChange && currentUnsaved !== false) {
9355
+ f.properties._unsaved = true;
9356
+ }
9357
+ if (properties.kind === "text" || ((_b2 = f.properties) == null ? void 0 : _b2.kind) === "text") {
9220
9358
  delete f.properties.text;
9221
9359
  }
9222
9360
  layerTemporalCacheRef.current.delete(layerId);
@@ -9591,6 +9729,38 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9591
9729
  });
9592
9730
  return total;
9593
9731
  }, [layers, getLayerUnsavedCount]);
9732
+ const moveLabelsBeforeBasemapSymbols = useCallback(() => {
9733
+ if (!map.current) return;
9734
+ const m = map.current;
9735
+ if (!m.getLayer("custom-labels")) return;
9736
+ const style = m.getStyle();
9737
+ const allLayers = (style == null ? void 0 : style.layers) || [];
9738
+ const basemapPrefixes = Object.values(BASEMAP_LAYER_PREFIXES);
9739
+ const isVisible = (l) => {
9740
+ var _a;
9741
+ const v = (_a = l.layout) == null ? void 0 : _a.visibility;
9742
+ return v === void 0 || v === "visible";
9743
+ };
9744
+ const firstVisibleBasemapSymbol = allLayers.find(
9745
+ (l) => l.type === "symbol" && basemapPrefixes.some((p) => l.id.startsWith(p)) && isVisible(l)
9746
+ );
9747
+ try {
9748
+ if (firstVisibleBasemapSymbol) {
9749
+ m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
9750
+ if (m.getLayer("custom-arrow-labels")) {
9751
+ m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
9752
+ }
9753
+ } else {
9754
+ m.moveLayer("custom-labels");
9755
+ if (m.getLayer("custom-arrow-labels")) {
9756
+ m.moveLayer("custom-arrow-labels");
9757
+ }
9758
+ }
9759
+ } catch (e) {
9760
+ console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
9761
+ }
9762
+ }, []);
9763
+ moveLabelsBeforeBasemapSymbolsRef.current = moveLabelsBeforeBasemapSymbols;
9594
9764
  const loadBasemapStyle = useCallback(async (styleName) => {
9595
9765
  if (!map.current) return [];
9596
9766
  const mapInstance = map.current;
@@ -9654,12 +9824,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9654
9824
  }
9655
9825
  }
9656
9826
  }
9827
+ moveLabelsBeforeBasemapSymbols();
9657
9828
  return addedLayerIds;
9658
9829
  } catch (e) {
9659
9830
  console.error(`Failed to load basemap style ${styleName}:`, e);
9660
9831
  return [];
9661
9832
  }
9662
- }, []);
9833
+ }, [moveLabelsBeforeBasemapSymbols]);
9663
9834
  const setBasemapVisibility = useCallback((styleName, visible) => {
9664
9835
  if (!map.current) return;
9665
9836
  const mapInstance = map.current;
@@ -9711,7 +9882,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9711
9882
  }
9712
9883
  setBasemapVisibility(style, true);
9713
9884
  setCurrentMapStyle(style);
9714
- }, [loadBasemapStyle, setBasemapVisibility]);
9885
+ moveLabelsBeforeBasemapSymbols();
9886
+ }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
9715
9887
  handleMapStyleChangeRef.current = handleMapStyleChange;
9716
9888
  const handleUpdateTraceConfig = useCallback((layerId, config) => {
9717
9889
  setLayers((prev) => prev.map(
@@ -12372,7 +12544,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12372
12544
  }
12373
12545
  ),
12374
12546
  showProperties && selectedFeatures.length > 0 && (() => {
12375
- var _a;
12547
+ var _a, _b;
12376
12548
  const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
12377
12549
  const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
12378
12550
  const layerName = featureLayer == null ? void 0 : featureLayer.name;
@@ -12396,6 +12568,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12396
12568
  layerId,
12397
12569
  autoFocusLabel,
12398
12570
  entityCardProvider,
12571
+ entityCardPlacement,
12572
+ inlineEntityCardLabel,
12399
12573
  typePickerProvider,
12400
12574
  featureSaveProvider,
12401
12575
  featureRefreshProvider,
@@ -12408,7 +12582,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12408
12582
  onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
12409
12583
  onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
12410
12584
  onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
12411
- getFeatureColor: (featureId) => selectedFeatureColors.get(featureId)
12585
+ getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
12586
+ anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null
12412
12587
  }
12413
12588
  );
12414
12589
  })(),