@octostar/map-component 0.1.28 → 0.1.29
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 +449 -248
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +449 -248
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +13 -3
- package/dist/types/components/layers-panel.d.ts +7 -2
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/properties-panel.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +62 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1724,6 +1724,7 @@ function LayersPanel({
|
|
|
1724
1724
|
hideBasemapSwitcher = false,
|
|
1725
1725
|
externalPersistence = false,
|
|
1726
1726
|
customGlobalMenuItems,
|
|
1727
|
+
extraLayerToolbarButtons,
|
|
1727
1728
|
layerBadgeProvider,
|
|
1728
1729
|
featureCountProvider
|
|
1729
1730
|
}) {
|
|
@@ -2029,12 +2030,11 @@ function LayersPanel({
|
|
|
2029
2030
|
size: "small",
|
|
2030
2031
|
checked: ((_d = layer.heatmapConfig) == null ? void 0 : _d.enabled) ?? false,
|
|
2031
2032
|
onChange: (checked) => {
|
|
2032
|
-
var _a2, _b2
|
|
2033
|
+
var _a2, _b2;
|
|
2033
2034
|
return onUpdateHeatmapConfig(layer.id, {
|
|
2034
2035
|
enabled: checked,
|
|
2035
2036
|
intensity: ((_a2 = layer.heatmapConfig) == null ? void 0 : _a2.intensity) ?? 1,
|
|
2036
|
-
radius: ((_b2 = layer.heatmapConfig) == null ? void 0 : _b2.radius) ?? 20
|
|
2037
|
-
hideFeatures: ((_c2 = layer.heatmapConfig) == null ? void 0 : _c2.hideFeatures) ?? false
|
|
2037
|
+
radius: ((_b2 = layer.heatmapConfig) == null ? void 0 : _b2.radius) ?? 20
|
|
2038
2038
|
});
|
|
2039
2039
|
},
|
|
2040
2040
|
"data-testid": `switch-heatmap-${layer.id}`
|
|
@@ -2076,20 +2076,6 @@ function LayersPanel({
|
|
|
2076
2076
|
})
|
|
2077
2077
|
}
|
|
2078
2078
|
)
|
|
2079
|
-
] }),
|
|
2080
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2081
|
-
/* @__PURE__ */ jsx(
|
|
2082
|
-
Switch,
|
|
2083
|
-
{
|
|
2084
|
-
size: "small",
|
|
2085
|
-
checked: layer.heatmapConfig.hideFeatures ?? false,
|
|
2086
|
-
onChange: (checked) => onUpdateHeatmapConfig(layer.id, {
|
|
2087
|
-
...layer.heatmapConfig,
|
|
2088
|
-
hideFeatures: checked
|
|
2089
|
-
})
|
|
2090
|
-
}
|
|
2091
|
-
),
|
|
2092
|
-
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Hide points" })
|
|
2093
2079
|
] })
|
|
2094
2080
|
] })
|
|
2095
2081
|
] }),
|
|
@@ -2515,6 +2501,7 @@ function LayersPanel({
|
|
|
2515
2501
|
) })
|
|
2516
2502
|
}
|
|
2517
2503
|
),
|
|
2504
|
+
extraLayerToolbarButtons,
|
|
2518
2505
|
/* @__PURE__ */ jsx(
|
|
2519
2506
|
Dropdown,
|
|
2520
2507
|
{
|
|
@@ -2797,6 +2784,56 @@ function getFeatureTypeIcon(geometryType, kind, size = "sm") {
|
|
|
2797
2784
|
return null;
|
|
2798
2785
|
}
|
|
2799
2786
|
}
|
|
2787
|
+
function colorPickerNoHexPanel(_panel, extra) {
|
|
2788
|
+
const { Picker, Presets } = extra.components;
|
|
2789
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 min-w-[220px]", children: [
|
|
2790
|
+
/* @__PURE__ */ jsx(Picker, {}),
|
|
2791
|
+
/* @__PURE__ */ jsx(Presets, {})
|
|
2792
|
+
] });
|
|
2793
|
+
}
|
|
2794
|
+
function LatLngFields(props) {
|
|
2795
|
+
const { latitude, longitude, isEditable, testIdPrefix } = props;
|
|
2796
|
+
if (!isEditable) {
|
|
2797
|
+
return /* @__PURE__ */ jsxs(
|
|
2798
|
+
"div",
|
|
2799
|
+
{
|
|
2800
|
+
className: "flex items-center gap-2 text-[13px] font-mono text-foreground px-1 py-1",
|
|
2801
|
+
"data-testid": `${testIdPrefix}-display`,
|
|
2802
|
+
children: [
|
|
2803
|
+
/* @__PURE__ */ jsx("span", { "data-testid": `${testIdPrefix}-latitude-text`, children: latitude || "—" }),
|
|
2804
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "/" }),
|
|
2805
|
+
/* @__PURE__ */ jsx("span", { "data-testid": `${testIdPrefix}-longitude-text`, children: longitude || "—" })
|
|
2806
|
+
]
|
|
2807
|
+
}
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2810
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
2811
|
+
/* @__PURE__ */ jsx(
|
|
2812
|
+
Input,
|
|
2813
|
+
{
|
|
2814
|
+
value: latitude,
|
|
2815
|
+
onChange: (e) => props.onLatChange(e.target.value),
|
|
2816
|
+
onFocus: props.onLatFocus,
|
|
2817
|
+
onBlur: props.onLatBlur,
|
|
2818
|
+
placeholder: "Latitude",
|
|
2819
|
+
className: "!h-6 text-[13px] flex-1",
|
|
2820
|
+
"data-testid": `${testIdPrefix}-latitude`
|
|
2821
|
+
}
|
|
2822
|
+
),
|
|
2823
|
+
/* @__PURE__ */ jsx(
|
|
2824
|
+
Input,
|
|
2825
|
+
{
|
|
2826
|
+
value: longitude,
|
|
2827
|
+
onChange: (e) => props.onLngChange(e.target.value),
|
|
2828
|
+
onFocus: props.onLngFocus,
|
|
2829
|
+
onBlur: props.onLngBlur,
|
|
2830
|
+
placeholder: "Longitude",
|
|
2831
|
+
className: "!h-6 text-[13px] flex-1",
|
|
2832
|
+
"data-testid": `${testIdPrefix}-longitude`
|
|
2833
|
+
}
|
|
2834
|
+
)
|
|
2835
|
+
] });
|
|
2836
|
+
}
|
|
2800
2837
|
function PointColorDot({ color, size = 20 }) {
|
|
2801
2838
|
return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 20 20", className: "shrink-0", children: /* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "7", fill: color, stroke: color, strokeWidth: "2", opacity: "0.9" }) });
|
|
2802
2839
|
}
|
|
@@ -2850,8 +2887,21 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
2850
2887
|
"entityType",
|
|
2851
2888
|
"startDate",
|
|
2852
2889
|
"endDate",
|
|
2853
|
-
|
|
2890
|
+
// The feature's color is already conveyed by the colored dot in the panel
|
|
2891
|
+
// header; showing it again as a property row (`#0C66E4`) is just noise.
|
|
2892
|
+
"color"
|
|
2893
|
+
// NOTE: 'description' intentionally NOT excluded — we surface it as a regular
|
|
2894
|
+
// property row instead of giving it its own labelled section.
|
|
2854
2895
|
]);
|
|
2896
|
+
function buildKeyExclusionPredicate(set) {
|
|
2897
|
+
const lowered = new Set(Array.from(set, (k) => k.toLowerCase()));
|
|
2898
|
+
return (key) => {
|
|
2899
|
+
if (set.has(key)) return true;
|
|
2900
|
+
const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
|
|
2901
|
+
return lowered.has(normalized);
|
|
2902
|
+
};
|
|
2903
|
+
}
|
|
2904
|
+
const isExcludedRecordKey = buildKeyExclusionPredicate(RECORD_EXCLUDE_KEYS);
|
|
2855
2905
|
const RECORD_FIELDS_HIDDEN_PREFIXES = ["_", "os_"];
|
|
2856
2906
|
function parseRecordFields(feature) {
|
|
2857
2907
|
const raw = feature.properties._recordFields;
|
|
@@ -2878,14 +2928,14 @@ function RecordFieldsSection({ feature }) {
|
|
|
2878
2928
|
Collapse,
|
|
2879
2929
|
{
|
|
2880
2930
|
size: "small",
|
|
2881
|
-
defaultActiveKey: [
|
|
2931
|
+
defaultActiveKey: [],
|
|
2882
2932
|
ghost: true,
|
|
2883
2933
|
className: "[&_.ant-collapse-header]:!px-0 [&_.ant-collapse-header]:!py-1 [&_.ant-collapse-content-box]:!px-0 [&_.ant-collapse-content-box]:!py-1",
|
|
2884
2934
|
items: [{
|
|
2885
2935
|
key: "record-fields",
|
|
2886
2936
|
label: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2887
2937
|
/* @__PURE__ */ jsx(Info, { className: "w-3 h-3 text-foreground" }),
|
|
2888
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
2938
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Record Fields" }),
|
|
2889
2939
|
/* @__PURE__ */ jsxs("span", { className: "text-[10px] text-muted-foreground ml-1", children: [
|
|
2890
2940
|
"(",
|
|
2891
2941
|
fields.length,
|
|
@@ -3035,10 +3085,46 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3035
3085
|
setLatitude("");
|
|
3036
3086
|
}
|
|
3037
3087
|
}
|
|
3038
|
-
const reserved =
|
|
3088
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
3089
|
+
"name",
|
|
3090
|
+
"description",
|
|
3091
|
+
"startDate",
|
|
3092
|
+
"endDate",
|
|
3093
|
+
"stroke",
|
|
3094
|
+
"stroke-width",
|
|
3095
|
+
"stroke-opacity",
|
|
3096
|
+
"fill",
|
|
3097
|
+
"fill-opacity",
|
|
3098
|
+
"kind",
|
|
3099
|
+
"label",
|
|
3100
|
+
"fontSize",
|
|
3101
|
+
"fontColor",
|
|
3102
|
+
"fontWeight",
|
|
3103
|
+
"arrowSize",
|
|
3104
|
+
"circleCenter",
|
|
3105
|
+
"circleRadius",
|
|
3106
|
+
"icon",
|
|
3107
|
+
"iconSize",
|
|
3108
|
+
"pointIcon",
|
|
3109
|
+
"pointIconSize",
|
|
3110
|
+
"entityType",
|
|
3111
|
+
"entity_id",
|
|
3112
|
+
"entity_type",
|
|
3113
|
+
"entity_label",
|
|
3114
|
+
"os_workspace",
|
|
3115
|
+
"workspace",
|
|
3116
|
+
"source_name",
|
|
3117
|
+
"id",
|
|
3118
|
+
"latitude",
|
|
3119
|
+
"longitude",
|
|
3120
|
+
// The marker color is shown via the colored dot in the panel header,
|
|
3121
|
+
// so we don't repeat it as an editable property row.
|
|
3122
|
+
"color"
|
|
3123
|
+
]);
|
|
3124
|
+
const isReservedKey = buildKeyExclusionPredicate(reserved);
|
|
3039
3125
|
const custom = [];
|
|
3040
3126
|
Object.entries(feature.properties).forEach(([key, value]) => {
|
|
3041
|
-
if (!
|
|
3127
|
+
if (!isReservedKey(key) && value !== void 0 && value !== null && !key.startsWith("_") && !key.startsWith("os_") && !key.startsWith("isHidden")) {
|
|
3042
3128
|
custom.push({ key, value: String(value) });
|
|
3043
3129
|
}
|
|
3044
3130
|
});
|
|
@@ -3222,7 +3308,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3222
3308
|
handleRefresh(true);
|
|
3223
3309
|
}, [feature == null ? void 0 : feature.id, isRecord, featureRefreshProvider, feature, handleRefresh]);
|
|
3224
3310
|
const recordProperties = feature ? Object.entries(feature.properties).filter(
|
|
3225
|
-
([key, value]) => !
|
|
3311
|
+
([key, value]) => !isExcludedRecordKey(key) && value !== void 0 && value !== null && !key.startsWith("_") && !key.startsWith("os_") && !key.startsWith("isHidden")
|
|
3226
3312
|
).map(([key, value]) => ({ key, value: String(value) })) : [];
|
|
3227
3313
|
const entityCardsContent = /* @__PURE__ */ jsx("div", { className: "p-2 space-y-2", children: entityCardProvider ? selectedFeatures.map((f) => {
|
|
3228
3314
|
const geoFeature = {
|
|
@@ -3239,7 +3325,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3239
3325
|
return /* @__PURE__ */ jsxs(
|
|
3240
3326
|
"div",
|
|
3241
3327
|
{
|
|
3242
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
3328
|
+
className: "absolute top-4 right-4 z-10 w-80 bg-background/95 floating-panel rounded-lg shadow-lg border border-border",
|
|
3243
3329
|
"data-testid": "panel-properties",
|
|
3244
3330
|
children: [
|
|
3245
3331
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-2.5 py-2 border-b border-border", children: [
|
|
@@ -3275,21 +3361,20 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3275
3361
|
onMoveFeaturesToLayer && /* @__PURE__ */ jsx(Dropdown, { menu: { items: buildLayerMenuItems("move") }, trigger: ["click"], placement: "bottomRight", children: /* @__PURE__ */ jsx(Tooltip, { title: "Move to layer", children: /* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(FolderInput, { className: "w-3.5 h-3.5" }), className: "!w-5 !h-5 !min-w-0 !p-0", "data-testid": "button-move-to-layer-prop" }) }) })
|
|
3276
3362
|
] })
|
|
3277
3363
|
] }),
|
|
3278
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-
|
|
3279
|
-
isRecord ? /* @__PURE__ */ jsx(Tag, { color: "cyan", className: "!text-[
|
|
3280
|
-
isUnsaved && /* @__PURE__ */ jsx(Tag, { color: "orange", className: "!text-[
|
|
3364
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
3365
|
+
isRecord ? /* @__PURE__ */ jsx(Tag, { color: "cyan", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Octostar record" }) : /* @__PURE__ */ jsx(Tag, { color: "blue", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Local map feature" }),
|
|
3366
|
+
isUnsaved && /* @__PURE__ */ jsx(Tag, { color: "orange", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !border-0 !m-0 !font-semibold", children: "Unsaved" }),
|
|
3281
3367
|
!isRecord && featureSaveProvider && /* @__PURE__ */ jsx(
|
|
3282
3368
|
Button,
|
|
3283
3369
|
{
|
|
3284
3370
|
type: "primary",
|
|
3285
|
-
size: "
|
|
3286
|
-
icon: /* @__PURE__ */ jsx(Save, { className: "w-3 h-3" }),
|
|
3371
|
+
size: "middle",
|
|
3372
|
+
icon: /* @__PURE__ */ jsx(Save, { className: "w-3.5 h-3.5" }),
|
|
3287
3373
|
loading: isSaving,
|
|
3288
3374
|
onClick: handleFeatureSave,
|
|
3289
|
-
className: "!h-
|
|
3290
|
-
style: { padding: "1px 6px" },
|
|
3375
|
+
className: "!h-7 !px-3 !text-[12px] !font-medium",
|
|
3291
3376
|
"data-testid": "button-save-feature",
|
|
3292
|
-
children: "Create entity
|
|
3377
|
+
children: "Create entity"
|
|
3293
3378
|
}
|
|
3294
3379
|
)
|
|
3295
3380
|
] })
|
|
@@ -3373,92 +3458,57 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3373
3458
|
/* @__PURE__ */ jsx("label", { className: "text-xs text-muted-foreground", children: "Lat / Lng" }),
|
|
3374
3459
|
feature.geometry.type !== "Point" && /* @__PURE__ */ jsx(Tooltip, { title: "Lat and Lng refer to the centroid of this feature", children: /* @__PURE__ */ jsx("span", { className: "text-[13px] text-muted-foreground cursor-help", children: "*" }) })
|
|
3375
3460
|
] }),
|
|
3376
|
-
/* @__PURE__ */
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3461
|
+
/* @__PURE__ */ jsx(
|
|
3462
|
+
LatLngFields,
|
|
3463
|
+
{
|
|
3464
|
+
latitude,
|
|
3465
|
+
longitude,
|
|
3466
|
+
isEditable: feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer,
|
|
3467
|
+
testIdPrefix: "input-feature",
|
|
3468
|
+
onLatChange: setLatitude,
|
|
3469
|
+
onLngChange: setLongitude,
|
|
3470
|
+
onLatFocus: () => {
|
|
3471
|
+
latInputFocused.current = true;
|
|
3472
|
+
},
|
|
3473
|
+
onLngFocus: () => {
|
|
3474
|
+
lngInputFocused.current = true;
|
|
3475
|
+
},
|
|
3476
|
+
onLatBlur: () => {
|
|
3477
|
+
latInputFocused.current = false;
|
|
3478
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3479
|
+
const lat = parseFloat(latitude);
|
|
3480
|
+
const lng = parseFloat(longitude);
|
|
3481
|
+
const coords = feature.geometry.coordinates;
|
|
3482
|
+
if (isNaN(lat)) {
|
|
3483
|
+
toast({ title: "Invalid latitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3484
|
+
setLatitude(coords[1].toFixed(6));
|
|
3485
|
+
} else if (lat < -90 || lat > 90) {
|
|
3486
|
+
toast({ title: "Invalid latitude", description: "Latitude must be between -90 and 90", variant: "destructive" });
|
|
3487
|
+
setLatitude(coords[1].toFixed(6));
|
|
3488
|
+
} else if (isNaN(lng) || lng < -180 || lng > 180) ;
|
|
3489
|
+
else {
|
|
3490
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3404
3491
|
}
|
|
3405
|
-
}
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
"
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3423
|
-
const lat = parseFloat(latitude);
|
|
3424
|
-
const lng = parseFloat(longitude);
|
|
3425
|
-
const coords = feature.geometry.coordinates;
|
|
3426
|
-
if (isNaN(lng)) {
|
|
3427
|
-
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3428
|
-
setLongitude(coords[0].toFixed(6));
|
|
3429
|
-
} else if (lng < -180 || lng > 180) {
|
|
3430
|
-
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3431
|
-
setLongitude(coords[0].toFixed(6));
|
|
3432
|
-
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3433
|
-
else {
|
|
3434
|
-
onUpdateGeometry(feature.id, {
|
|
3435
|
-
type: "Point",
|
|
3436
|
-
coordinates: [lng, lat]
|
|
3437
|
-
});
|
|
3438
|
-
}
|
|
3492
|
+
}
|
|
3493
|
+
},
|
|
3494
|
+
onLngBlur: () => {
|
|
3495
|
+
lngInputFocused.current = false;
|
|
3496
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3497
|
+
const lat = parseFloat(latitude);
|
|
3498
|
+
const lng = parseFloat(longitude);
|
|
3499
|
+
const coords = feature.geometry.coordinates;
|
|
3500
|
+
if (isNaN(lng)) {
|
|
3501
|
+
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3502
|
+
setLongitude(coords[0].toFixed(6));
|
|
3503
|
+
} else if (lng < -180 || lng > 180) {
|
|
3504
|
+
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3505
|
+
setLongitude(coords[0].toFixed(6));
|
|
3506
|
+
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3507
|
+
else {
|
|
3508
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3439
3509
|
}
|
|
3440
|
-
}
|
|
3441
|
-
placeholder: "Longitude",
|
|
3442
|
-
readOnly: feature.geometry.type !== "Point" || !isEditMode || isReadOnlyLayer,
|
|
3443
|
-
className: "!h-6 text-[13px] flex-1",
|
|
3444
|
-
"data-testid": "input-feature-longitude"
|
|
3510
|
+
}
|
|
3445
3511
|
}
|
|
3446
|
-
)
|
|
3447
|
-
] })
|
|
3448
|
-
] }),
|
|
3449
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3450
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "feature-description", className: "text-xs text-muted-foreground", children: "Description" }),
|
|
3451
|
-
/* @__PURE__ */ jsx(
|
|
3452
|
-
TextArea,
|
|
3453
|
-
{
|
|
3454
|
-
id: "feature-description",
|
|
3455
|
-
value: description,
|
|
3456
|
-
onChange: (e) => setDescription(e.target.value),
|
|
3457
|
-
onBlur: () => handleSave(),
|
|
3458
|
-
placeholder: isEditMode ? "Add description..." : "No description",
|
|
3459
|
-
className: "!min-h-[50px] resize-none text-[13px]",
|
|
3460
|
-
readOnly: !isEditMode,
|
|
3461
|
-
"data-testid": "input-feature-description"
|
|
3462
3512
|
}
|
|
3463
3513
|
)
|
|
3464
3514
|
] }),
|
|
@@ -3474,7 +3524,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3474
3524
|
key: "temporal",
|
|
3475
3525
|
label: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3476
3526
|
/* @__PURE__ */ jsx(Calendar, { className: "w-3 h-3 text-foreground" }),
|
|
3477
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
3527
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Temporal" }),
|
|
3478
3528
|
(startDate || endDate) && /* @__PURE__ */ jsxs("span", { className: "text-[10px] text-muted-foreground ml-1", children: [
|
|
3479
3529
|
"(",
|
|
3480
3530
|
startDate && endDate ? "2 dates" : "1 date",
|
|
@@ -3561,10 +3611,10 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3561
3611
|
}
|
|
3562
3612
|
),
|
|
3563
3613
|
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
|
|
3564
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
3614
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
3565
3615
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3566
3616
|
/* @__PURE__ */ jsx(Palette, { className: "w-3 h-3 text-foreground" }),
|
|
3567
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
3617
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Style" })
|
|
3568
3618
|
] }),
|
|
3569
3619
|
feature.properties.kind === "text" && /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
3570
3620
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -3681,6 +3731,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3681
3731
|
disabled: !isEditMode,
|
|
3682
3732
|
size: "small",
|
|
3683
3733
|
showText: false,
|
|
3734
|
+
disabledAlpha: true,
|
|
3735
|
+
panelRender: colorPickerNoHexPanel,
|
|
3684
3736
|
"data-testid": "color-picker-stroke"
|
|
3685
3737
|
}
|
|
3686
3738
|
) }) }),
|
|
@@ -3755,6 +3807,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3755
3807
|
disabled: !isEditMode,
|
|
3756
3808
|
size: "small",
|
|
3757
3809
|
showText: false,
|
|
3810
|
+
disabledAlpha: true,
|
|
3811
|
+
panelRender: colorPickerNoHexPanel,
|
|
3758
3812
|
"data-testid": "color-picker-fill"
|
|
3759
3813
|
}
|
|
3760
3814
|
) }) }),
|
|
@@ -3811,49 +3865,67 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3811
3865
|
] })
|
|
3812
3866
|
] }),
|
|
3813
3867
|
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
|
|
3814
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
3815
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3868
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
3869
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Properties" }),
|
|
3870
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
3871
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1", children: [
|
|
3872
|
+
/* @__PURE__ */ jsx("div", { className: "text-[13px] font-mono text-muted-foreground shrink-0 w-24 px-1 leading-6 select-none", children: "description" }),
|
|
3873
|
+
/* @__PURE__ */ jsx(
|
|
3874
|
+
TextArea,
|
|
3875
|
+
{
|
|
3876
|
+
id: "feature-description",
|
|
3877
|
+
value: description,
|
|
3878
|
+
onChange: (e) => setDescription(e.target.value),
|
|
3879
|
+
onBlur: () => handleSave(),
|
|
3880
|
+
autoSize: { minRows: 1, maxRows: 5 },
|
|
3881
|
+
placeholder: isEditMode ? "—" : "",
|
|
3882
|
+
readOnly: !isEditMode,
|
|
3883
|
+
className: "flex-1 !text-[13px] !px-1.5 !py-0.5 resize-none",
|
|
3884
|
+
"data-testid": "input-feature-description"
|
|
3885
|
+
}
|
|
3886
|
+
)
|
|
3887
|
+
] }),
|
|
3888
|
+
customProperties.map((prop, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3889
|
+
/* @__PURE__ */ jsx(
|
|
3890
|
+
Input,
|
|
3891
|
+
{
|
|
3892
|
+
value: prop.key,
|
|
3893
|
+
onChange: (e) => handlePropertyKeyChange(index, e.target.value),
|
|
3894
|
+
onBlur: () => handleSave(),
|
|
3895
|
+
placeholder: "Key",
|
|
3896
|
+
className: "shrink-0 w-24 text-[13px] font-mono !h-6 !px-1",
|
|
3897
|
+
readOnly: !isEditMode,
|
|
3898
|
+
"data-testid": `input-property-key-${index}`
|
|
3899
|
+
}
|
|
3900
|
+
),
|
|
3901
|
+
/* @__PURE__ */ jsx(
|
|
3902
|
+
Input,
|
|
3903
|
+
{
|
|
3904
|
+
value: prop.value,
|
|
3905
|
+
onChange: (e) => handlePropertyValueChange(index, e.target.value),
|
|
3906
|
+
onBlur: () => handleSave(),
|
|
3907
|
+
placeholder: "Value",
|
|
3908
|
+
className: "flex-1 text-[13px] !h-6 !px-1.5",
|
|
3909
|
+
readOnly: !isEditMode,
|
|
3910
|
+
"data-testid": `input-property-value-${index}`
|
|
3911
|
+
}
|
|
3912
|
+
),
|
|
3913
|
+
isEditMode && /* @__PURE__ */ jsx(
|
|
3914
|
+
"button",
|
|
3915
|
+
{
|
|
3916
|
+
type: "button",
|
|
3917
|
+
onClick: () => {
|
|
3918
|
+
handleRemoveProperty(index);
|
|
3919
|
+
setTimeout(() => handleSave(), 0);
|
|
3920
|
+
},
|
|
3921
|
+
className: "text-destructive shrink-0 h-6 w-6 flex items-center justify-center rounded hover:bg-destructive/10 transition-colors",
|
|
3922
|
+
"data-testid": `button-remove-property-${index}`,
|
|
3923
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "w-3 h-3" })
|
|
3924
|
+
}
|
|
3925
|
+
)
|
|
3926
|
+
] }, index))
|
|
3927
|
+
] }),
|
|
3928
|
+
isEditMode && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pt-0.5", children: [
|
|
3857
3929
|
/* @__PURE__ */ jsx(
|
|
3858
3930
|
Input,
|
|
3859
3931
|
{
|
|
@@ -3865,8 +3937,8 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3865
3937
|
handleAddProperty();
|
|
3866
3938
|
}
|
|
3867
3939
|
},
|
|
3868
|
-
placeholder: "New property
|
|
3869
|
-
className: "flex-1 text-[13px] !h-
|
|
3940
|
+
placeholder: "New property…",
|
|
3941
|
+
className: "flex-1 text-[13px] !h-6 !px-1.5",
|
|
3870
3942
|
"data-testid": "input-new-property-key"
|
|
3871
3943
|
}
|
|
3872
3944
|
),
|
|
@@ -3876,9 +3948,9 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3876
3948
|
type: "button",
|
|
3877
3949
|
onClick: handleAddProperty,
|
|
3878
3950
|
disabled: !newPropertyKey.trim(),
|
|
3879
|
-
className: "h-
|
|
3951
|
+
className: "h-6 w-6 flex items-center justify-center border border-border rounded disabled:opacity-50 hover:bg-muted transition-colors",
|
|
3880
3952
|
"data-testid": "button-add-property",
|
|
3881
|
-
children: /* @__PURE__ */ jsx(Plus, { className: "w-
|
|
3953
|
+
children: /* @__PURE__ */ jsx(Plus, { className: "w-3 h-3" })
|
|
3882
3954
|
}
|
|
3883
3955
|
)
|
|
3884
3956
|
] })
|
|
@@ -3898,7 +3970,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3898
3970
|
/* @__PURE__ */ jsx("span", { className: "text-[12px] text-muted-foreground", children: "Layer:" }),
|
|
3899
3971
|
/* @__PURE__ */ jsx("span", { className: "text-[12px] text-foreground truncate", children: layerName })
|
|
3900
3972
|
] }),
|
|
3901
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-
|
|
3973
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 flex-wrap", children: /* @__PURE__ */ jsx(Tag, { color: "cyan", className: "!text-[12px] !px-2.5 !py-0.5 !leading-5 !m-0 !font-semibold", children: "Octostar record" }) })
|
|
3902
3974
|
] }),
|
|
3903
3975
|
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
|
|
3904
3976
|
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -3919,93 +3991,73 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
3919
3991
|
) })
|
|
3920
3992
|
] }) }),
|
|
3921
3993
|
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
|
|
3922
|
-
feature.properties.description && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3923
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3924
|
-
/* @__PURE__ */ jsx("label", { className: "text-xs text-muted-foreground", children: "Description" }),
|
|
3925
|
-
/* @__PURE__ */ jsx("p", { className: "text-[13px] text-foreground whitespace-pre-wrap break-words m-0", children: String(feature.properties.description) })
|
|
3926
|
-
] }),
|
|
3927
|
-
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" })
|
|
3928
|
-
] }),
|
|
3929
3994
|
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
3930
3995
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3931
3996
|
/* @__PURE__ */ jsx(MapPin, { className: "w-3 h-3 text-muted-foreground" }),
|
|
3932
3997
|
/* @__PURE__ */ jsx("label", { className: "text-xs text-muted-foreground", children: "Lat / Lng" }),
|
|
3933
3998
|
feature.geometry.type !== "Point" && /* @__PURE__ */ jsx(Tooltip, { title: "Lat and Lng refer to the centroid of this feature", children: /* @__PURE__ */ jsx("span", { className: "text-[13px] text-muted-foreground cursor-help", children: "*" }) })
|
|
3934
3999
|
] }),
|
|
3935
|
-
/* @__PURE__ */
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4000
|
+
/* @__PURE__ */ jsx(
|
|
4001
|
+
LatLngFields,
|
|
4002
|
+
{
|
|
4003
|
+
latitude,
|
|
4004
|
+
longitude,
|
|
4005
|
+
isEditable: feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer,
|
|
4006
|
+
testIdPrefix: "input-record",
|
|
4007
|
+
onLatChange: setLatitude,
|
|
4008
|
+
onLngChange: setLongitude,
|
|
4009
|
+
onLatFocus: () => {
|
|
4010
|
+
latInputFocused.current = true;
|
|
4011
|
+
},
|
|
4012
|
+
onLngFocus: () => {
|
|
4013
|
+
lngInputFocused.current = true;
|
|
4014
|
+
},
|
|
4015
|
+
onLatBlur: () => {
|
|
4016
|
+
latInputFocused.current = false;
|
|
4017
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
4018
|
+
const lat = parseFloat(latitude);
|
|
4019
|
+
const lng = parseFloat(longitude);
|
|
4020
|
+
const coords = feature.geometry.coordinates;
|
|
4021
|
+
if (isNaN(lat)) {
|
|
4022
|
+
toast({ title: "Invalid latitude", description: "Please enter a valid number", variant: "destructive" });
|
|
4023
|
+
setLatitude(coords[1].toFixed(6));
|
|
4024
|
+
} else if (lat < -90 || lat > 90) {
|
|
4025
|
+
toast({ title: "Invalid latitude", description: "Latitude must be between -90 and 90", variant: "destructive" });
|
|
4026
|
+
setLatitude(coords[1].toFixed(6));
|
|
4027
|
+
} else if (isNaN(lng) || lng < -180 || lng > 180) ;
|
|
4028
|
+
else {
|
|
4029
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3960
4030
|
}
|
|
3961
|
-
}
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
"
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
3979
|
-
const lat = parseFloat(latitude);
|
|
3980
|
-
const lng = parseFloat(longitude);
|
|
3981
|
-
const coords = feature.geometry.coordinates;
|
|
3982
|
-
if (isNaN(lng)) {
|
|
3983
|
-
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
3984
|
-
setLongitude(coords[0].toFixed(6));
|
|
3985
|
-
} else if (lng < -180 || lng > 180) {
|
|
3986
|
-
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
3987
|
-
setLongitude(coords[0].toFixed(6));
|
|
3988
|
-
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
3989
|
-
else {
|
|
3990
|
-
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3991
|
-
}
|
|
4031
|
+
}
|
|
4032
|
+
},
|
|
4033
|
+
onLngBlur: () => {
|
|
4034
|
+
lngInputFocused.current = false;
|
|
4035
|
+
if (feature.geometry.type === "Point" && isEditMode && !isReadOnlyLayer && onUpdateGeometry) {
|
|
4036
|
+
const lat = parseFloat(latitude);
|
|
4037
|
+
const lng = parseFloat(longitude);
|
|
4038
|
+
const coords = feature.geometry.coordinates;
|
|
4039
|
+
if (isNaN(lng)) {
|
|
4040
|
+
toast({ title: "Invalid longitude", description: "Please enter a valid number", variant: "destructive" });
|
|
4041
|
+
setLongitude(coords[0].toFixed(6));
|
|
4042
|
+
} else if (lng < -180 || lng > 180) {
|
|
4043
|
+
toast({ title: "Invalid longitude", description: "Longitude must be between -180 and 180", variant: "destructive" });
|
|
4044
|
+
setLongitude(coords[0].toFixed(6));
|
|
4045
|
+
} else if (isNaN(lat) || lat < -90 || lat > 90) ;
|
|
4046
|
+
else {
|
|
4047
|
+
onUpdateGeometry(feature.id, { type: "Point", coordinates: [lng, lat] });
|
|
3992
4048
|
}
|
|
3993
|
-
}
|
|
3994
|
-
placeholder: "Longitude",
|
|
3995
|
-
readOnly: feature.geometry.type !== "Point" || !isEditMode || isReadOnlyLayer,
|
|
3996
|
-
className: "!h-6 text-[13px] flex-1",
|
|
3997
|
-
"data-testid": "input-record-longitude"
|
|
4049
|
+
}
|
|
3998
4050
|
}
|
|
3999
|
-
|
|
4000
|
-
|
|
4051
|
+
}
|
|
4052
|
+
)
|
|
4001
4053
|
] }),
|
|
4002
4054
|
recordProperties.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4003
4055
|
/* @__PURE__ */ jsx(Divider, { className: "!my-1.5" }),
|
|
4004
4056
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
4005
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
4057
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: "Properties" }),
|
|
4006
4058
|
/* @__PURE__ */ jsx("div", { className: "space-y-0.5", children: recordProperties.map(({ key, value }) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 py-0.5", children: [
|
|
4007
4059
|
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground shrink-0 pt-px min-w-[80px]", children: formatPropertyKey(key) }),
|
|
4008
|
-
/* @__PURE__ */ jsx("span", { className: "text-[13px] text-foreground break-
|
|
4060
|
+
/* @__PURE__ */ jsx("span", { className: "text-[13px] text-foreground whitespace-pre-wrap break-words", children: value })
|
|
4009
4061
|
] }, key)) })
|
|
4010
4062
|
] })
|
|
4011
4063
|
] }),
|
|
@@ -4025,7 +4077,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4025
4077
|
return /* @__PURE__ */ jsxs(
|
|
4026
4078
|
"div",
|
|
4027
4079
|
{
|
|
4028
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
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",
|
|
4029
4081
|
style: { maxHeight: "calc(100vh - 6rem)" },
|
|
4030
4082
|
"data-testid": "panel-properties",
|
|
4031
4083
|
children: [
|
|
@@ -4158,7 +4210,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4158
4210
|
return /* @__PURE__ */ jsxs(
|
|
4159
4211
|
"div",
|
|
4160
4212
|
{
|
|
4161
|
-
className: "absolute top-4 right-4 z-10 w-
|
|
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",
|
|
4162
4214
|
style: { maxHeight: "calc(100vh - 6rem)" },
|
|
4163
4215
|
"data-testid": "panel-properties",
|
|
4164
4216
|
children: [
|
|
@@ -5692,6 +5744,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
5692
5744
|
enableProperties = true,
|
|
5693
5745
|
toastProvider,
|
|
5694
5746
|
customGlobalMenuItems,
|
|
5747
|
+
extraLayerToolbarButtons,
|
|
5695
5748
|
layerBadgeProvider,
|
|
5696
5749
|
featureCountProvider,
|
|
5697
5750
|
fitBoundsProvider,
|
|
@@ -5774,6 +5827,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
5774
5827
|
const [cursorCoords, setCursorCoords] = useState(null);
|
|
5775
5828
|
const [contextMenu, setContextMenu] = useState(null);
|
|
5776
5829
|
const timelineStore = useTimelineStore();
|
|
5830
|
+
useEffect(() => () => useTimelineStore.getState().reset(), []);
|
|
5777
5831
|
const { toast: internalToast } = useToast();
|
|
5778
5832
|
const toast = toastProvider ?? internalToast;
|
|
5779
5833
|
useEffect(() => {
|
|
@@ -6137,7 +6191,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6137
6191
|
const sourceData = {
|
|
6138
6192
|
type: "FeatureCollection",
|
|
6139
6193
|
features: allFeatures.map((f) => {
|
|
6140
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
|
6194
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6141
6195
|
const featureId = String(f.id);
|
|
6142
6196
|
const layer = featureToLayer.get(featureId);
|
|
6143
6197
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -6209,8 +6263,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6209
6263
|
featureIconSize = iconConfig.size ?? 24;
|
|
6210
6264
|
}
|
|
6211
6265
|
const isPoint = f.geometry.type === "Point";
|
|
6212
|
-
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled)
|
|
6213
|
-
const hideByCluster = isPoint && ((
|
|
6266
|
+
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled) === true;
|
|
6267
|
+
const hideByCluster = isPoint && ((_j = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _j.enabled) === true && !((_k = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _k.showPointDots);
|
|
6214
6268
|
const isSelected = selectedIds.includes(featureId);
|
|
6215
6269
|
const hideByTrace = false;
|
|
6216
6270
|
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
@@ -6252,7 +6306,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6252
6306
|
"stroke-width": strokeWidth,
|
|
6253
6307
|
"stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
|
|
6254
6308
|
fill: strokeColor,
|
|
6255
|
-
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((
|
|
6309
|
+
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_l = f.properties) == null ? void 0 : _l["fill-opacity"]) ?? 0.2 : 0,
|
|
6256
6310
|
pointRadius,
|
|
6257
6311
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
6258
6312
|
isTimelineHidden: isTimelineVisible ? 0 : 1
|
|
@@ -6638,8 +6692,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6638
6692
|
attributionControl: false,
|
|
6639
6693
|
boxZoom: false,
|
|
6640
6694
|
// Disable default box zoom - we use shift+drag for selection instead
|
|
6641
|
-
maxPitch: 80
|
|
6695
|
+
maxPitch: 80,
|
|
6642
6696
|
// Allow steep camera angles for 3D terrain viewing
|
|
6697
|
+
// Required for `getCanvas().toDataURL()` (used by `captureScreenshot()`
|
|
6698
|
+
// on the imperative handle) to return a populated image instead of a
|
|
6699
|
+
// blank one. In maplibre-gl v5 this lives under
|
|
6700
|
+
// `canvasContextAttributes`, not at the top level. Modern desktop GPUs
|
|
6701
|
+
// absorb the small extra cost without measurable impact on this
|
|
6702
|
+
// editor-grade map.
|
|
6703
|
+
canvasContextAttributes: { preserveDrawingBuffer: true }
|
|
6643
6704
|
});
|
|
6644
6705
|
const attrCtrl = new maplibregl.AttributionControl({
|
|
6645
6706
|
compact: true,
|
|
@@ -6916,7 +6977,26 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
6916
6977
|
// Text features: center anchor; others: top anchor
|
|
6917
6978
|
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
6918
6979
|
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
6919
|
-
|
|
6980
|
+
// Collision behaviour for entity labels.
|
|
6981
|
+
//
|
|
6982
|
+
// `kind === 'text'` features are sticky-note style annotations
|
|
6983
|
+
// where the text IS the content (this layer has no icon-image,
|
|
6984
|
+
// and `text-optional` cannot fall back to anything). If we let
|
|
6985
|
+
// collision detection hide them, the user is left with a tiny
|
|
6986
|
+
// 5px circle and no visible note. Same for trace endpoint
|
|
6987
|
+
// labels — the label IS the meaningful marker.
|
|
6988
|
+
//
|
|
6989
|
+
// Plain entity-name labels are supplementary to the icon/dot,
|
|
6990
|
+
// so it's safe to let MapLibre thin them out in dense areas
|
|
6991
|
+
// (this is the "no more black mass of stacked labels" win).
|
|
6992
|
+
"text-allow-overlap": [
|
|
6993
|
+
"case",
|
|
6994
|
+
["==", ["get", "kind"], "text"],
|
|
6995
|
+
true,
|
|
6996
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6997
|
+
true,
|
|
6998
|
+
false
|
|
6999
|
+
],
|
|
6920
7000
|
"text-ignore-placement": false,
|
|
6921
7001
|
"text-optional": true,
|
|
6922
7002
|
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
@@ -7835,6 +7915,101 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7835
7915
|
if (!map.current || !isMapLoadedRef.current) return;
|
|
7836
7916
|
map.current.flyTo({ center: coords, zoom: zoom ?? map.current.getZoom(), duration: (options == null ? void 0 : options.duration) ?? 2e3 });
|
|
7837
7917
|
},
|
|
7918
|
+
updateLayerConfig: (layerId, config) => {
|
|
7919
|
+
const idx = layersRef.current.findIndex((l) => l.id === layerId);
|
|
7920
|
+
if (idx < 0) return false;
|
|
7921
|
+
const current = layersRef.current[idx];
|
|
7922
|
+
const next = { ...current };
|
|
7923
|
+
if ("visible" in config) {
|
|
7924
|
+
const wantedVisible = config.visible ?? true;
|
|
7925
|
+
if (wantedVisible !== current.visible && !current.readOnly && draw.current) {
|
|
7926
|
+
if (wantedVisible) {
|
|
7927
|
+
const hidden = hiddenFeatures.current.get(layerId) || [];
|
|
7928
|
+
const newIds = [];
|
|
7929
|
+
isApiAddingRef.current = true;
|
|
7930
|
+
try {
|
|
7931
|
+
hidden.forEach((f) => {
|
|
7932
|
+
const ids = draw.current.add(f);
|
|
7933
|
+
newIds.push(ids[0]);
|
|
7934
|
+
});
|
|
7935
|
+
} finally {
|
|
7936
|
+
isApiAddingRef.current = false;
|
|
7937
|
+
}
|
|
7938
|
+
hiddenFeatures.current.delete(layerId);
|
|
7939
|
+
next.visible = true;
|
|
7940
|
+
next.featureIds = newIds;
|
|
7941
|
+
} else {
|
|
7942
|
+
const features = current.featureIds.map((id) => draw.current.get(id)).filter(Boolean);
|
|
7943
|
+
hiddenFeatures.current.set(layerId, features);
|
|
7944
|
+
current.featureIds.forEach((id) => {
|
|
7945
|
+
try {
|
|
7946
|
+
draw.current.delete(id);
|
|
7947
|
+
} catch {
|
|
7948
|
+
}
|
|
7949
|
+
});
|
|
7950
|
+
next.visible = false;
|
|
7951
|
+
next.featureIds = [];
|
|
7952
|
+
}
|
|
7953
|
+
} else {
|
|
7954
|
+
next.visible = wantedVisible;
|
|
7955
|
+
}
|
|
7956
|
+
}
|
|
7957
|
+
if ("visualConfig" in config) next.visualConfig = config.visualConfig;
|
|
7958
|
+
if ("traceConfig" in config) next.traceConfig = config.traceConfig;
|
|
7959
|
+
if ("heatmapConfig" in config) next.heatmapConfig = config.heatmapConfig;
|
|
7960
|
+
if ("clusterConfig" in config) next.clusterConfig = config.clusterConfig;
|
|
7961
|
+
if ("altitudeDisplayMode" in config) next.altitudeDisplayMode = config.altitudeDisplayMode;
|
|
7962
|
+
const updated = [...layersRef.current];
|
|
7963
|
+
updated[idx] = next;
|
|
7964
|
+
layersRef.current = updated;
|
|
7965
|
+
setLayers(updated);
|
|
7966
|
+
if ("visible" in config) {
|
|
7967
|
+
updateFeatureCount();
|
|
7968
|
+
scheduleTimelineUpdate();
|
|
7969
|
+
}
|
|
7970
|
+
requestAnimationFrame(() => syncRef.current());
|
|
7971
|
+
return true;
|
|
7972
|
+
},
|
|
7973
|
+
captureScreenshot: async (options) => {
|
|
7974
|
+
const m = map.current;
|
|
7975
|
+
if (!m || !isMapLoadedRef.current) {
|
|
7976
|
+
toast({
|
|
7977
|
+
title: "Screenshot failed",
|
|
7978
|
+
description: "Map is not ready yet.",
|
|
7979
|
+
variant: "destructive"
|
|
7980
|
+
});
|
|
7981
|
+
throw new Error("Map is not ready");
|
|
7982
|
+
}
|
|
7983
|
+
const SCREENSHOT_RENDER_TIMEOUT_MS = 1e4;
|
|
7984
|
+
try {
|
|
7985
|
+
await new Promise((resolve, reject) => {
|
|
7986
|
+
const onRender = () => {
|
|
7987
|
+
clearTimeout(timeoutId);
|
|
7988
|
+
resolve();
|
|
7989
|
+
};
|
|
7990
|
+
const timeoutId = setTimeout(() => {
|
|
7991
|
+
try {
|
|
7992
|
+
m.off("render", onRender);
|
|
7993
|
+
} catch {
|
|
7994
|
+
}
|
|
7995
|
+
reject(new Error("Screenshot timed out waiting for render (map may have been destroyed)"));
|
|
7996
|
+
}, SCREENSHOT_RENDER_TIMEOUT_MS);
|
|
7997
|
+
m.once("render", onRender);
|
|
7998
|
+
m.triggerRepaint();
|
|
7999
|
+
});
|
|
8000
|
+
} catch (err) {
|
|
8001
|
+
toast({
|
|
8002
|
+
title: "Screenshot failed",
|
|
8003
|
+
description: err instanceof Error ? err.message : "The map did not render in time. Please try again.",
|
|
8004
|
+
variant: "destructive"
|
|
8005
|
+
});
|
|
8006
|
+
throw err;
|
|
8007
|
+
}
|
|
8008
|
+
const canvas = m.getCanvas();
|
|
8009
|
+
const fmt = (options == null ? void 0 : options.format) === "jpeg" ? "image/jpeg" : "image/png";
|
|
8010
|
+
const dataUrl = fmt === "image/jpeg" ? canvas.toDataURL(fmt, options == null ? void 0 : options.quality) : canvas.toDataURL(fmt);
|
|
8011
|
+
return { dataUrl, width: canvas.width, height: canvas.height };
|
|
8012
|
+
},
|
|
7838
8013
|
fitToData: (layerIds) => {
|
|
7839
8014
|
if (!map.current || !isMapLoadedRef.current) return;
|
|
7840
8015
|
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
@@ -7873,11 +8048,25 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7873
8048
|
const newLayer = {
|
|
7874
8049
|
id: layerId,
|
|
7875
8050
|
name,
|
|
7876
|
-
visible
|
|
8051
|
+
// Default to visible. The optional `visible` flag lets restore-flows
|
|
8052
|
+
// recreate a layer that the user had previously hidden, without
|
|
8053
|
+
// racing a follow-up `setLayerVisibility(id, false)` call (which
|
|
8054
|
+
// briefly flashes the layer on screen between addLayer and the
|
|
8055
|
+
// visibility toggle).
|
|
8056
|
+
visible: (options == null ? void 0 : options.visible) ?? true,
|
|
7877
8057
|
featureIds: [],
|
|
7878
8058
|
readOnly: options == null ? void 0 : options.readOnly,
|
|
7879
8059
|
group: options == null ? void 0 : options.group,
|
|
7880
|
-
metadata: options == null ? void 0 : options.metadata
|
|
8060
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
8061
|
+
// Per-layer visual configs are passed through verbatim so that hosts
|
|
8062
|
+
// restoring a saved map (workspace auto-save, file merge, etc.) can
|
|
8063
|
+
// recreate heatmap / cluster / color-by-field / label / size / trace
|
|
8064
|
+
// settings without a follow-up "update visual config" round-trip.
|
|
8065
|
+
visualConfig: options == null ? void 0 : options.visualConfig,
|
|
8066
|
+
traceConfig: options == null ? void 0 : options.traceConfig,
|
|
8067
|
+
heatmapConfig: options == null ? void 0 : options.heatmapConfig,
|
|
8068
|
+
clusterConfig: options == null ? void 0 : options.clusterConfig,
|
|
8069
|
+
altitudeDisplayMode: options == null ? void 0 : options.altitudeDisplayMode
|
|
7881
8070
|
};
|
|
7882
8071
|
if (geojson) {
|
|
7883
8072
|
if (options == null ? void 0 : options.readOnly) {
|
|
@@ -7916,6 +8105,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7916
8105
|
}
|
|
7917
8106
|
}
|
|
7918
8107
|
}
|
|
8108
|
+
if (newLayer.visible === false && !(options == null ? void 0 : options.readOnly) && draw.current && newLayer.featureIds.length > 0) {
|
|
8109
|
+
const features = newLayer.featureIds.map((id) => draw.current.get(id)).filter(Boolean);
|
|
8110
|
+
hiddenFeatures.current.set(layerId, features);
|
|
8111
|
+
newLayer.featureIds.forEach((id) => {
|
|
8112
|
+
try {
|
|
8113
|
+
draw.current.delete(id);
|
|
8114
|
+
} catch {
|
|
8115
|
+
}
|
|
8116
|
+
});
|
|
8117
|
+
newLayer.featureIds = [];
|
|
8118
|
+
}
|
|
7919
8119
|
const updatedLayers = [...layersRef.current, newLayer];
|
|
7920
8120
|
layersRef.current = updatedLayers;
|
|
7921
8121
|
setLayers(updatedLayers);
|
|
@@ -12158,6 +12358,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12158
12358
|
hideBasemapSwitcher,
|
|
12159
12359
|
externalPersistence,
|
|
12160
12360
|
customGlobalMenuItems,
|
|
12361
|
+
extraLayerToolbarButtons,
|
|
12161
12362
|
layerBadgeProvider,
|
|
12162
12363
|
featureCountProvider
|
|
12163
12364
|
}
|