@octostar/map-component 0.1.35 → 0.1.36
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 +54 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +54 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/properties-panel.d.ts +3 -1
- package/dist/types/components/properties-panel.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2875,6 +2875,37 @@ function formatEntityTypeName(type) {
|
|
|
2875
2875
|
function formatPropertyKey(key) {
|
|
2876
2876
|
return key.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
2877
2877
|
}
|
|
2878
|
+
const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
2879
|
+
const ISO_DATETIME_ZONED_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:?\d{2})$/;
|
|
2880
|
+
const ISO_DATETIME_NAIVE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?$/;
|
|
2881
|
+
function formatFieldValue(value) {
|
|
2882
|
+
if (ISO_DATE_RE.test(value)) {
|
|
2883
|
+
const d = /* @__PURE__ */ new Date(`${value}T00:00:00Z`);
|
|
2884
|
+
if (Number.isNaN(d.getTime())) return value;
|
|
2885
|
+
return new Intl.DateTimeFormat(void 0, {
|
|
2886
|
+
year: "numeric",
|
|
2887
|
+
month: "short",
|
|
2888
|
+
day: "numeric",
|
|
2889
|
+
timeZone: "UTC"
|
|
2890
|
+
}).format(d);
|
|
2891
|
+
}
|
|
2892
|
+
const zoned = ISO_DATETIME_ZONED_RE.test(value);
|
|
2893
|
+
if (zoned || ISO_DATETIME_NAIVE_RE.test(value)) {
|
|
2894
|
+
const d = new Date(zoned ? value : `${value}Z`);
|
|
2895
|
+
if (Number.isNaN(d.getTime())) return value;
|
|
2896
|
+
const formatted = new Intl.DateTimeFormat(void 0, {
|
|
2897
|
+
year: "numeric",
|
|
2898
|
+
month: "short",
|
|
2899
|
+
day: "numeric",
|
|
2900
|
+
hour: "2-digit",
|
|
2901
|
+
minute: "2-digit",
|
|
2902
|
+
hour12: false,
|
|
2903
|
+
timeZone: "UTC"
|
|
2904
|
+
}).format(d);
|
|
2905
|
+
return zoned ? `${formatted} UTC` : formatted;
|
|
2906
|
+
}
|
|
2907
|
+
return value;
|
|
2908
|
+
}
|
|
2878
2909
|
const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
2879
2910
|
"entity_id",
|
|
2880
2911
|
"entity_type",
|
|
@@ -2932,7 +2963,7 @@ function parseRecordFields(feature) {
|
|
|
2932
2963
|
for (const [k, v] of Object.entries(obj)) {
|
|
2933
2964
|
if (v == null || v === "") continue;
|
|
2934
2965
|
if (RECORD_FIELDS_HIDDEN_PREFIXES.some((p) => k.startsWith(p))) continue;
|
|
2935
|
-
const display = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
2966
|
+
const display = typeof v === "object" ? JSON.stringify(v) : formatFieldValue(String(v));
|
|
2936
2967
|
entries.push({ key: k, value: display });
|
|
2937
2968
|
}
|
|
2938
2969
|
entries.sort((a, b) => a.key.localeCompare(b.key));
|
|
@@ -3325,7 +3356,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3325
3356
|
};
|
|
3326
3357
|
const updated = await featureRefreshProvider(geoFeature);
|
|
3327
3358
|
if (updated) {
|
|
3328
|
-
onUpdateProperties(feature.id, updated);
|
|
3359
|
+
onUpdateProperties(feature.id, updated, { fromRefresh: true });
|
|
3329
3360
|
if (!silent) {
|
|
3330
3361
|
toast({ title: "Refreshed", description: "Properties updated from record" });
|
|
3331
3362
|
}
|
|
@@ -3351,7 +3382,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3351
3382
|
}, [feature == null ? void 0 : feature.id, isRecord, featureRefreshProvider, feature, handleRefresh]);
|
|
3352
3383
|
const recordProperties = feature ? Object.entries(feature.properties).filter(
|
|
3353
3384
|
([key, value]) => !isExcludedRecordKey(key) && value !== void 0 && value !== null && !key.startsWith("_") && !key.startsWith("os_") && !key.startsWith("isHidden")
|
|
3354
|
-
).map(([key, value]) => ({ key, value: String(value) })) : [];
|
|
3385
|
+
).map(([key, value]) => ({ key, value: formatFieldValue(String(value)) })) : [];
|
|
3355
3386
|
const entityCardsContent = /* @__PURE__ */ jsx("div", { className: "p-2 space-y-2", children: entityCardProvider ? selectedFeatures.map((f) => {
|
|
3356
3387
|
const geoFeature = {
|
|
3357
3388
|
type: "Feature",
|
|
@@ -7900,12 +7931,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7900
7931
|
}
|
|
7901
7932
|
}
|
|
7902
7933
|
} else {
|
|
7903
|
-
originalGeometriesRef.current.
|
|
7904
|
-
|
|
7905
|
-
|
|
7934
|
+
const previousGeometry = originalGeometriesRef.current.get(fid);
|
|
7935
|
+
const geometryChanged = !previousGeometry || JSON.stringify(previousGeometry) !== JSON.stringify(feature.geometry);
|
|
7936
|
+
if (geometryChanged) {
|
|
7937
|
+
originalGeometriesRef.current.set(fid, JSON.parse(JSON.stringify(feature.geometry)));
|
|
7938
|
+
if (!externalPersistence) {
|
|
7939
|
+
drawInstance.setFeatureProperty(fid, "_unsaved", true);
|
|
7940
|
+
}
|
|
7941
|
+
onFeatureUpdate == null ? void 0 : onFeatureUpdate(feature);
|
|
7942
|
+
setFeatureUpdateCounter((c) => c + 1);
|
|
7906
7943
|
}
|
|
7907
|
-
onFeatureUpdate == null ? void 0 : onFeatureUpdate(feature);
|
|
7908
|
-
setFeatureUpdateCounter((c) => c + 1);
|
|
7909
7944
|
}
|
|
7910
7945
|
});
|
|
7911
7946
|
syncRef.current();
|
|
@@ -9367,7 +9402,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9367
9402
|
}
|
|
9368
9403
|
setSelectedFeatureIds([]);
|
|
9369
9404
|
}, [isEditMode]);
|
|
9370
|
-
const handleUpdateProperties = useCallback((featureId, properties) => {
|
|
9405
|
+
const handleUpdateProperties = useCallback((featureId, properties, options) => {
|
|
9371
9406
|
var _a, _b, _c;
|
|
9372
9407
|
if (!map.current) return;
|
|
9373
9408
|
saveStateForUndo();
|
|
@@ -9389,7 +9424,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9389
9424
|
draw.current.setFeatureProperty(featureId, key, value);
|
|
9390
9425
|
});
|
|
9391
9426
|
const currentUnsaved = (_b = drawFeature.properties) == null ? void 0 : _b._unsaved;
|
|
9392
|
-
if (!externalPersistence && hasRealChange && currentUnsaved !== false) {
|
|
9427
|
+
if (!externalPersistence && hasRealChange && currentUnsaved !== false && !(options == null ? void 0 : options.fromRefresh)) {
|
|
9393
9428
|
draw.current.setFeatureProperty(featureId, "_unsaved", true);
|
|
9394
9429
|
}
|
|
9395
9430
|
if (properties.kind === "text" || ((_c = drawFeature.properties) == null ? void 0 : _c.kind) === "text") {
|
|
@@ -9414,7 +9449,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9414
9449
|
});
|
|
9415
9450
|
const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
|
|
9416
9451
|
f.properties = { ...f.properties, ...normalizedProperties };
|
|
9417
|
-
if (!externalPersistence && hasRealChange && currentUnsaved !== false) {
|
|
9452
|
+
if (!externalPersistence && hasRealChange && currentUnsaved !== false && !(options == null ? void 0 : options.fromRefresh)) {
|
|
9418
9453
|
f.properties._unsaved = true;
|
|
9419
9454
|
}
|
|
9420
9455
|
if (properties.kind === "text" || ((_b2 = f.properties) == null ? void 0 : _b2.kind) === "text") {
|
|
@@ -9804,8 +9839,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9804
9839
|
const v = (_a = l.layout) == null ? void 0 : _a.visibility;
|
|
9805
9840
|
return v === void 0 || v === "visible";
|
|
9806
9841
|
};
|
|
9842
|
+
const isBasemap = (l) => basemapPrefixes.some((p) => l.id.startsWith(p));
|
|
9843
|
+
let lastBasemapGeometryIdx = -1;
|
|
9844
|
+
allLayers.forEach((l, i) => {
|
|
9845
|
+
if (isBasemap(l) && l.type !== "symbol" && isVisible(l)) {
|
|
9846
|
+
lastBasemapGeometryIdx = i;
|
|
9847
|
+
}
|
|
9848
|
+
});
|
|
9807
9849
|
const firstVisibleBasemapSymbol = allLayers.find(
|
|
9808
|
-
(l) => l.type === "symbol" &&
|
|
9850
|
+
(l, i) => i > lastBasemapGeometryIdx && l.type === "symbol" && isBasemap(l) && isVisible(l)
|
|
9809
9851
|
);
|
|
9810
9852
|
try {
|
|
9811
9853
|
if (firstVisibleBasemapSymbol) {
|