@element-editor/react 0.2.3 → 0.3.1
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/AGENTS.md +6 -1
- package/dist/element-editor-leaflet.css +1 -1
- package/dist/element-editor.cjs +1 -1
- package/dist/element-editor.css +1 -1
- package/dist/element-editor.es.js +23 -22
- package/dist/leaflet.cjs +1 -1
- package/dist/leaflet.es.js +26 -26
- package/dist/shared.d.cts +2 -2
- package/dist/shared.d.ts +2 -2
- package/dist/shell/types.d.cts +52 -1
- package/dist/shell/types.d.ts +52 -1
- package/dist/useBasemapState-DxeagojX.js +692 -0
- package/dist/useBasemapState-ItAucr9T.cjs +1 -0
- package/package.json +9 -9
- package/dist/useBasemapState-8bWJK84f.cjs +0 -1
- package/dist/useBasemapState-DChxz3lv.js +0 -682
|
@@ -7,7 +7,7 @@ import { jsxs as K, Fragment as X, jsx as v } from "react/jsx-runtime";
|
|
|
7
7
|
import { memo as H, useRef as w, useState as F, useEffect as W, forwardRef as Q, useCallback as ee } from "react";
|
|
8
8
|
import { useBasemap as te, ElementEditorControls as oe, BasemapControl as re } from "@element-editor/adapter-maplibre";
|
|
9
9
|
import { loadErrorCode as ne, warnOnce as P, isDevBuild as ie } from "@element-editor/core/internal";
|
|
10
|
-
import { r as se, F as
|
|
10
|
+
import { r as se, F as ae, a as le, s as ce, u as ue, b as me, p as de, E as pe } from "./useBasemapState-DxeagojX.js";
|
|
11
11
|
import * as x from "maplibre-gl";
|
|
12
12
|
import { useServiceAttribution as fe } from "@element-editor/ui/internal";
|
|
13
13
|
import { loadBasemapStyle as Ee, resolveBasemap as be } from "@element-editor/adapter-maplibre/basemaps";
|
|
@@ -20,7 +20,7 @@ function we(e, t = x) {
|
|
|
20
20
|
const s = he(e, t.getVersion(), t.getWorkerUrl());
|
|
21
21
|
s && t.setWorkerUrl(s);
|
|
22
22
|
}
|
|
23
|
-
const j = { version: 8, sources: {}, layers: [] }, ye = H(function({ basemap: t, themeMode: s, attributionTarget:
|
|
23
|
+
const j = { version: 8, sources: {}, layers: [] }, ye = H(function({ basemap: t, themeMode: s, attributionTarget: a, attributionCorner: b, getFeatureStyle: B, setup: C, onReady: p }) {
|
|
24
24
|
const O = M((o) => o.readonly), f = M((o) => o.reportError), k = M((o) => o.bounds), A = w(null), [n, L] = F(null), g = w({ basemap: t, themeMode: s, scope: R(), setup: C }), S = w(f);
|
|
25
25
|
S.current = f, te(n, t, { theme: s, initialApplied: !0 });
|
|
26
26
|
const r = fe();
|
|
@@ -41,7 +41,7 @@ const j = { version: 8, sources: {}, layers: [] }, ye = H(function({ basemap: t,
|
|
|
41
41
|
...V.mapOptions,
|
|
42
42
|
container: o,
|
|
43
43
|
style: m,
|
|
44
|
-
..."bounds" in d ? { bounds: [[d.bounds[0], d.bounds[1]], [d.bounds[2], d.bounds[3]]], fitBoundsOptions: { padding:
|
|
44
|
+
..."bounds" in d ? { bounds: [[d.bounds[0], d.bounds[1]], [d.bounds[2], d.bounds[3]]], fitBoundsOptions: { padding: le, maxZoom: ae } } : { center: d.center, zoom: d.zoom },
|
|
45
45
|
attributionControl: !1
|
|
46
46
|
});
|
|
47
47
|
if (E = u, typeof m == "string") {
|
|
@@ -60,36 +60,37 @@ const j = { version: 8, sources: {}, layers: [] }, ye = H(function({ basemap: t,
|
|
|
60
60
|
c = !0, clearTimeout(T), i == null || i.disconnect(), E == null || E.remove(), L(null);
|
|
61
61
|
};
|
|
62
62
|
}, []);
|
|
63
|
-
const
|
|
64
|
-
const o =
|
|
63
|
+
const l = w(null), y = ue(n == null ? void 0 : n.getContainer(), () => {
|
|
64
|
+
const o = l.current;
|
|
65
65
|
o && o.classList.contains("maplibregl-compact") && !o.classList.contains("maplibregl-attrib-empty") && o.classList.remove("maplibregl-compact-show");
|
|
66
|
-
}, !!n && !
|
|
66
|
+
}, !!n && !a);
|
|
67
67
|
return W(() => {
|
|
68
68
|
if (!n) return;
|
|
69
69
|
const o = new x.AttributionControl({
|
|
70
|
-
compact: !
|
|
70
|
+
compact: !a,
|
|
71
71
|
...r && { customAttribution: r }
|
|
72
72
|
});
|
|
73
73
|
n.addControl(o, "bottom-right");
|
|
74
74
|
const c = n.getContainer().querySelector(".maplibregl-ctrl-attrib");
|
|
75
|
-
|
|
76
|
-
const E =
|
|
77
|
-
E && c && (c.classList.add(
|
|
75
|
+
l.current = c;
|
|
76
|
+
const E = a ?? b;
|
|
77
|
+
E && c && (c.classList.add(a ? "elm-attribution-bar" : "elm-attribution-corner"), E.appendChild(c));
|
|
78
78
|
const i = c == null ? void 0 : c.querySelector(".maplibregl-ctrl-attrib-button");
|
|
79
79
|
return i == null || i.addEventListener("click", y), () => {
|
|
80
|
-
i == null || i.removeEventListener("click", y),
|
|
80
|
+
i == null || i.removeEventListener("click", y), l.current = null;
|
|
81
81
|
try {
|
|
82
82
|
n.removeControl(o);
|
|
83
83
|
} catch {
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
}, [n,
|
|
86
|
+
}, [n, a, b, r, y]), /* @__PURE__ */ K(X, { children: [
|
|
87
87
|
/* @__PURE__ */ v("div", { ref: A, style: { position: "absolute", inset: 0, zIndex: 0 } }),
|
|
88
88
|
n && /* @__PURE__ */ v(
|
|
89
89
|
oe,
|
|
90
90
|
{
|
|
91
91
|
map: n,
|
|
92
92
|
readonly: O,
|
|
93
|
+
drawingBar: !1,
|
|
93
94
|
getFeatureStyle: B,
|
|
94
95
|
maxBounds: k ?? null,
|
|
95
96
|
onReady: p
|
|
@@ -116,20 +117,20 @@ function ke(e) {
|
|
|
116
117
|
}
|
|
117
118
|
function Ae(e, t, s) {
|
|
118
119
|
if (t === !1) return e;
|
|
119
|
-
const
|
|
120
|
-
return t.find((b) =>
|
|
120
|
+
const a = J(Z, s);
|
|
121
|
+
return t.find((b) => a && z(b) === a) ?? e;
|
|
121
122
|
}
|
|
122
123
|
const Le = ["tileLayer", "renderer"], Se = Q(
|
|
123
|
-
({ basemap: e, defaultBasemap: t = "auto", onBasemapChange: s, basemaps:
|
|
124
|
+
({ basemap: e, defaultBasemap: t = "auto", onBasemapChange: s, basemaps: a, getFeatureStyle: b, mapOptions: B, onMapReady: C, ...p }, O) => {
|
|
124
125
|
for (const r of Le)
|
|
125
126
|
p[r] !== void 0 && P(`maplibre-${r}`, `<ElementEditor ${r}> is a Leaflet prop and is ignored by the default (MapLibre) editor. Import ElementEditor from '@element-editor/react/leaflet' (and '@element-editor/react/leaflet/style.css') to keep using it.`);
|
|
126
|
-
const f =
|
|
127
|
+
const f = a === void 0 ? Ce : a, { current: k, pick: A, api: n } = me(
|
|
127
128
|
e,
|
|
128
129
|
() => Ae(t, f, p.config),
|
|
129
130
|
s,
|
|
130
131
|
(r) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
132
|
+
const l = z(r);
|
|
133
|
+
l && G(Z, l, p.config);
|
|
133
134
|
},
|
|
134
135
|
f !== !1
|
|
135
136
|
);
|
|
@@ -142,8 +143,8 @@ const Le = ["tileLayer", "renderer"], Se = Q(
|
|
|
142
143
|
})), g = w(C);
|
|
143
144
|
g.current = C;
|
|
144
145
|
const S = ee((r) => {
|
|
145
|
-
var
|
|
146
|
-
return (
|
|
146
|
+
var l;
|
|
147
|
+
return (l = g.current) == null ? void 0 : l.call(g, r);
|
|
147
148
|
}, []);
|
|
148
149
|
return /* @__PURE__ */ v(
|
|
149
150
|
pe,
|
|
@@ -160,13 +161,13 @@ const Le = ["tileLayer", "renderer"], Se = Q(
|
|
|
160
161
|
onChange: (r) => A(r, !0)
|
|
161
162
|
}
|
|
162
163
|
),
|
|
163
|
-
renderMap: ({ attributionTarget: r, attributionCorner:
|
|
164
|
+
renderMap: ({ attributionTarget: r, attributionCorner: l, themeMode: y }) => /* @__PURE__ */ v(
|
|
164
165
|
ye,
|
|
165
166
|
{
|
|
166
167
|
basemap: k,
|
|
167
168
|
themeMode: y,
|
|
168
169
|
attributionTarget: r,
|
|
169
|
-
attributionCorner:
|
|
170
|
+
attributionCorner: l,
|
|
170
171
|
getFeatureStyle: b,
|
|
171
172
|
setup: L,
|
|
172
173
|
onReady: S
|
package/dist/leaflet.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),i=require("react"),A=require("react-leaflet"),f=require("@element-editor/ui"),b=require("./useBasemapState-8bWJK84f.cjs"),V=require("@element-editor/adapter-leaflet"),X=require("react-dom"),S=require("leaflet"),B=require("@phosphor-icons/react"),v=require("@element-editor/core"),z=require("@element-editor/core/internal");function D({target:e,corner:r}){var y;const o=A.useMap(),[s,l]=i.useState(!0),E=`elm-attribution${i.useId().replace(/:/g,"")}`,t=(y=o.attributionControl)==null?void 0:y.getContainer(),[d]=i.useState(()=>t==null?void 0:t.parentElement),g=r??d;i.useEffect(()=>{if(!(!t||!d))return e?(t.classList.add("elm-attribution-bar"),e.appendChild(t),()=>{t.classList.remove("elm-attribution-bar"),d.appendChild(t)}):(t.classList.add("elm-attribution-compact"),t.id=E,r&&r.prepend(t),()=>{t.classList.remove("elm-attribution-compact","elm-attribution-open"),r&&d.appendChild(t)})},[t,d,r,e,E]),i.useEffect(()=>{if(e||(t==null||t.classList.toggle("elm-attribution-open",s),!s))return;const n=()=>l(!1),p=T=>{T.key==="Escape"&&n()};return o.on("dragstart",n),document.addEventListener("keydown",p),()=>{o.off("dragstart",n),document.removeEventListener("keydown",p)}},[s,o,t,e]);const u=b.useAttributionAutoCollapse(o.getContainer(),()=>l(!1),!e&&!!t);return!t||!g||e?null:X.createPortal(m.jsx("button",{type:"button",ref:n=>{n&&(S.DomEvent.disableClickPropagation(n),S.DomEvent.disableScrollPropagation(n))},className:"elm-attribution-toggle","aria-label":s?"Hide map attribution":"Show map attribution","aria-expanded":s,"aria-controls":E,onClick:()=>{u(),l(n=>!n)},children:m.jsx(B.Info,{size:16,weight:"bold","aria-hidden":!0})}),g)}function H(){const e=A.useMap(),r=f.useElementEditorConfig(),o=i.useRef(null);return i.useEffect(()=>{function s(){o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{const l=e.getCenter();b.saveView(l.lat,l.lng,e.getZoom(),r)},300)}return e.on("moveend",s),()=>{e.off("moveend",s),o.current&&clearTimeout(o.current)}},[e,r]),i.useEffect(()=>{const s=new ResizeObserver(()=>e.invalidateSize());return s.observe(e.getContainer()),()=>s.disconnect()},[e]),i.useEffect(()=>{},[e]),null}const G=i.memo(function({tileLayer:r,renderer:o,getFeatureStyle:s,attributionTarget:l,attributionCorner:E,setup:t,onReady:d}){const g=f.useUIStore(T=>T.readonly),u=f.useUIStore(T=>T.bounds),y=f.useElementEditorConfig(),[n]=i.useState(()=>b.resolveInitialView(t,y)),p=i.useMemo(()=>m.jsx(V.ElementEditorControls,{readonly:g,bounds:u,renderer:o,getFeatureStyle:s,onReady:d}),[g,u,o,s,d]);return m.jsxs(A.MapContainer,{maxBoundsViscosity:1,...t.mapOptions,..."bounds"in n?{bounds:[[n.bounds[1],n.bounds[0]],[n.bounds[3],n.bounds[2]]],boundsOptions:{padding:[b.FIT_PADDING,b.FIT_PADDING],maxZoom:b.FIT_MAX_ZOOM}}:{center:[n.center[1],n.center[0]],zoom:n.zoom},className:"absolute inset-0 z-0",zoomControl:!1,children:[r,p,m.jsx(H,{}),m.jsx(D,{target:l,corner:E})]})}),Z="data:image/webp;base64,UklGRhAYAABXRUJQVlA4IAQYAABQSgCdASrwAHgAPtFcp08oJKMiKFGcwQAaCUxMpr8L/csRyWi2xRmaOyfptNEGWWAPNvyTOT7WqxAFdln0U/2Hdtc8n6gv7Fv2m9TYNJ4s/uH2p8M/2fsFbqf0fgZ2ney3+C8QJ23aBd4PRH7jei/8nrRNAf+c/3T/ke033tv3b1FOlz6QwjlIuxkq065ohY/x8YZH/DFe5yitzlGumnfFLLhhVJBSNAQ4tWgRfZBbX9N7+ldYmYMYP2lpKoFWZ1MWn7QcZ41mKu7VZBNMF1ar+dcJPjTvEJ16SYZ6hRcci6TO13jYa7vQn3/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RLb+h9GQQshEKDloZpgeybMUhQGtWQD/gG8T+5Q89e4F/u4dozofGpIx9Hl/xUYToyREPyhAxBSAnajvCYI/Jt7Y2guKaC9W8SlgW6wp3hv/eDImWkMdZ4xYVZYW5Wn4Tlv9a1Z3Sbmn4Qzlov4YKOtQlWNOscWT+tHAPQfiSE2EimSKt7fpdAWHYHij4JcXpAzUgfVBNp3Rkg7b1Vg6vbuSJ8sukU32x4JdVHJ+ymRDgQaon4aOB+0jYsCzQW2G5p7HC2Ym87XHIGw5w5KaoKhUu8e74T8Bfu7ZZgAA",R={center:"Use `initialView`.",zoom:"Use `initialView`.",bounds:"Use `initialView={{ bounds }}`.",boundsOptions:"Use `initialView`.",maxBounds:"Use the `bounds` prop.",zoomControl:"Element has its own zoom control (the 'zoom' layout control).",attributionControl:"Element shows the attribution (move it into the status bar with the 'attribution' layout control).",crs:"Element's editing tools assume Web Mercator (EPSG:3857).",renderer:"Use the `renderer` prop.",preferCanvas:"Use the `renderer` prop.",dragging:"Element turns dragging on and off while editing.",boxZoom:"Element turns boxZoom on and off while editing.",doubleClickZoom:"Element turns doubleClickZoom on and off while editing."},I="elm_basemap_leaflet",U='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';function L(e){var o;const r=z.overrideSource({tiles:["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],attribution:U},e,"osmRaster",U);return{id:"osm",label:"OpenStreetMap",thumbnail:Z,url:((o=r.tiles)==null?void 0:o[0])??r.url??"",attribution:r.attribution??"",...r.maxzoom!==void 0&&{maxZoom:r.maxzoom}}}const C=e=>e==="osm"?"osm":e.id??e.url,F=i.forwardRef(({tileLayer:e,basemaps:r,basemap:o,defaultBasemap:s,onBasemapChange:l,renderer:E,getFeatureStyle:t,mapOptions:d,onMapReady:g,...u},y)=>{var P,M;const[n]=i.useState(()=>({initialView:u.initialView,initialData:u.initialData,bounds:u.bounds,mapOptions:b.pickMapOptions(d,R,"leaflet")})),p=i.useRef(g);p.current=g;const T=i.useCallback(a=>{var c;return(c=p.current)==null?void 0:c.call(p,a)},[]);e&&(r||o||s||l)&&z.warnOnce("leaflet-tileLayer-basemaps","<ElementEditor tileLayer> overrides `basemaps`, `basemap`, `defaultBasemap` and `onBasemapChange`: they are ignored (and no basemap picker is shown).");const Q=(M=(P=u.config)==null?void 0:P.network)==null?void 0:M.osmRaster,k=i.useMemo(()=>L(Q),[JSON.stringify(Q)]),W=a=>a==="osm"?k:a,h=r??["osm"],j=!e&&h.length>=2,{current:x,pick:q,api:K}=b.useBasemapState(e?void 0:o,()=>{const a=v.readStorage(I,u.config);return h.find(c=>C(c)===a)??s??h[0]},l,a=>v.writeStorage(I,C(a),u.config),j),{url:O,attribution:J,maxZoom:w}=W(x),N=i.useMemo(()=>e??m.jsx(A.TileLayer,{url:O,attribution:J,...w!==void 0&&{maxZoom:w}},O),[e,O,J,w]);return m.jsx(b.ElementEditorShell,{...u,ref:y,extraApi:K,engine:"leaflet",basemapControl:j&&m.jsx(f.BasemapPicker,{options:h.map(a=>{const c=W(a);return{id:C(a),label:c.label??C(a),thumbnail:c.thumbnail}}),value:C(x),onChange:a=>{const c=h.find(Y=>C(Y)===a);c&&q(c,!0)}}),renderMap:({attributionTarget:a,attributionCorner:c})=>m.jsx(G,{tileLayer:N,renderer:E,getFeatureStyle:t,attributionTarget:a,attributionCorner:c,setup:n,onReady:T})})});F.displayName="ElementEditor";Object.defineProperty(exports,"DEFAULT_LAYOUT",{enumerable:!0,get:()=>f.DEFAULT_LAYOUT});Object.defineProperty(exports,"IconButton",{enumerable:!0,get:()=>f.IconButton});Object.defineProperty(exports,"Tooltip",{enumerable:!0,get:()=>f.Tooltip});Object.defineProperty(exports,"withLayout",{enumerable:!0,get:()=>f.withLayout});Object.defineProperty(exports,"ACCENT_STEPS",{enumerable:!0,get:()=>v.ACCENT_STEPS});Object.defineProperty(exports,"DEFAULT_ACCENT",{enumerable:!0,get:()=>v.DEFAULT_ACCENT});Object.defineProperty(exports,"ElementEditorError",{enumerable:!0,get:()=>v.ElementEditorError});Object.defineProperty(exports,"accentPalette",{enumerable:!0,get:()=>v.accentPalette});exports.ElementEditor=F;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),i=require("react"),A=require("react-leaflet"),f=require("@element-editor/ui"),b=require("./useBasemapState-ItAucr9T.cjs"),V=require("@element-editor/adapter-leaflet"),B=require("react-dom"),S=require("leaflet"),X=require("@phosphor-icons/react"),v=require("@element-editor/core"),z=require("@element-editor/core/internal");function D({target:e,corner:r}){var y;const o=A.useMap(),[s,l]=i.useState(!0),E=`elm-attribution${i.useId().replace(/:/g,"")}`,t=(y=o.attributionControl)==null?void 0:y.getContainer(),[d]=i.useState(()=>t==null?void 0:t.parentElement),g=r??d;i.useEffect(()=>{if(!(!t||!d))return e?(t.classList.add("elm-attribution-bar"),e.appendChild(t),()=>{t.classList.remove("elm-attribution-bar"),d.appendChild(t)}):(t.classList.add("elm-attribution-compact"),t.id=E,r&&r.prepend(t),()=>{t.classList.remove("elm-attribution-compact","elm-attribution-open"),r&&d.appendChild(t)})},[t,d,r,e,E]),i.useEffect(()=>{if(e||(t==null||t.classList.toggle("elm-attribution-open",s),!s))return;const n=()=>l(!1),p=T=>{T.key==="Escape"&&n()};return o.on("dragstart",n),document.addEventListener("keydown",p),()=>{o.off("dragstart",n),document.removeEventListener("keydown",p)}},[s,o,t,e]);const u=b.useAttributionAutoCollapse(o.getContainer(),()=>l(!1),!e&&!!t);return!t||!g||e?null:B.createPortal(m.jsx("button",{type:"button",ref:n=>{n&&(S.DomEvent.disableClickPropagation(n),S.DomEvent.disableScrollPropagation(n))},className:"elm-attribution-toggle","aria-label":s?"Hide map attribution":"Show map attribution","aria-expanded":s,"aria-controls":E,onClick:()=>{u(),l(n=>!n)},children:m.jsx(X.Info,{size:16,weight:"bold","aria-hidden":!0})}),g)}function H(){const e=A.useMap(),r=f.useElementEditorConfig(),o=i.useRef(null);return i.useEffect(()=>{function s(){o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{const l=e.getCenter();b.saveView(l.lat,l.lng,e.getZoom(),r)},300)}return e.on("moveend",s),()=>{e.off("moveend",s),o.current&&clearTimeout(o.current)}},[e,r]),i.useEffect(()=>{const s=new ResizeObserver(()=>e.invalidateSize());return s.observe(e.getContainer()),()=>s.disconnect()},[e]),i.useEffect(()=>{},[e]),null}const G=i.memo(function({tileLayer:r,renderer:o,getFeatureStyle:s,attributionTarget:l,attributionCorner:E,setup:t,onReady:d}){const g=f.useUIStore(T=>T.readonly),u=f.useUIStore(T=>T.bounds),y=f.useElementEditorConfig(),[n]=i.useState(()=>b.resolveInitialView(t,y)),p=i.useMemo(()=>m.jsx(V.ElementEditorControls,{drawingBar:!1,readonly:g,bounds:u,renderer:o,getFeatureStyle:s,onReady:d}),[g,u,o,s,d]);return m.jsxs(A.MapContainer,{maxBoundsViscosity:1,...t.mapOptions,..."bounds"in n?{bounds:[[n.bounds[1],n.bounds[0]],[n.bounds[3],n.bounds[2]]],boundsOptions:{padding:[b.FIT_PADDING,b.FIT_PADDING],maxZoom:b.FIT_MAX_ZOOM}}:{center:[n.center[1],n.center[0]],zoom:n.zoom},className:"absolute inset-0 z-0",zoomControl:!1,children:[r,p,m.jsx(H,{}),m.jsx(D,{target:l,corner:E})]})}),Z="data:image/webp;base64,UklGRhAYAABXRUJQVlA4IAQYAABQSgCdASrwAHgAPtFcp08oJKMiKFGcwQAaCUxMpr8L/csRyWi2xRmaOyfptNEGWWAPNvyTOT7WqxAFdln0U/2Hdtc8n6gv7Fv2m9TYNJ4s/uH2p8M/2fsFbqf0fgZ2ney3+C8QJ23aBd4PRH7jei/8nrRNAf+c/3T/ke033tv3b1FOlz6QwjlIuxkq065ohY/x8YZH/DFe5yitzlGumnfFLLhhVJBSNAQ4tWgRfZBbX9N7+ldYmYMYP2lpKoFWZ1MWn7QcZ41mKu7VZBNMF1ar+dcJPjTvEJ16SYZ6hRcci6TO13jYa7vQn3/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RLb+h9GQQshEKDloZpgeybMUhQGtWQD/gG8T+5Q89e4F/u4dozofGpIx9Hl/xUYToyREPyhAxBSAnajvCYI/Jt7Y2guKaC9W8SlgW6wp3hv/eDImWkMdZ4xYVZYW5Wn4Tlv9a1Z3Sbmn4Qzlov4YKOtQlWNOscWT+tHAPQfiSE2EimSKt7fpdAWHYHij4JcXpAzUgfVBNp3Rkg7b1Vg6vbuSJ8sukU32x4JdVHJ+ymRDgQaon4aOB+0jYsCzQW2G5p7HC2Ym87XHIGw5w5KaoKhUu8e74T8Bfu7ZZgAA",R={center:"Use `initialView`.",zoom:"Use `initialView`.",bounds:"Use `initialView={{ bounds }}`.",boundsOptions:"Use `initialView`.",maxBounds:"Use the `bounds` prop.",zoomControl:"Element has its own zoom control (the 'zoom' layout control).",attributionControl:"Element shows the attribution (move it into the status bar with the 'attribution' layout control).",crs:"Element's editing tools assume Web Mercator (EPSG:3857).",renderer:"Use the `renderer` prop.",preferCanvas:"Use the `renderer` prop.",dragging:"Element turns dragging on and off while editing.",boxZoom:"Element turns boxZoom on and off while editing.",doubleClickZoom:"Element turns doubleClickZoom on and off while editing."},I="elm_basemap_leaflet",U='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';function L(e){var o;const r=z.overrideSource({tiles:["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],attribution:U},e,"osmRaster",U);return{id:"osm",label:"OpenStreetMap",thumbnail:Z,url:((o=r.tiles)==null?void 0:o[0])??r.url??"",attribution:r.attribution??"",...r.maxzoom!==void 0&&{maxZoom:r.maxzoom}}}const C=e=>e==="osm"?"osm":e.id??e.url,F=i.forwardRef(({tileLayer:e,basemaps:r,basemap:o,defaultBasemap:s,onBasemapChange:l,renderer:E,getFeatureStyle:t,mapOptions:d,onMapReady:g,...u},y)=>{var P,M;const[n]=i.useState(()=>({initialView:u.initialView,initialData:u.initialData,bounds:u.bounds,mapOptions:b.pickMapOptions(d,R,"leaflet")})),p=i.useRef(g);p.current=g;const T=i.useCallback(a=>{var c;return(c=p.current)==null?void 0:c.call(p,a)},[]);e&&(r||o||s||l)&&z.warnOnce("leaflet-tileLayer-basemaps","<ElementEditor tileLayer> overrides `basemaps`, `basemap`, `defaultBasemap` and `onBasemapChange`: they are ignored (and no basemap picker is shown).");const Q=(M=(P=u.config)==null?void 0:P.network)==null?void 0:M.osmRaster,k=i.useMemo(()=>L(Q),[JSON.stringify(Q)]),W=a=>a==="osm"?k:a,h=r??["osm"],j=!e&&h.length>=2,{current:x,pick:q,api:K}=b.useBasemapState(e?void 0:o,()=>{const a=v.readStorage(I,u.config);return h.find(c=>C(c)===a)??s??h[0]},l,a=>v.writeStorage(I,C(a),u.config),j),{url:w,attribution:J,maxZoom:O}=W(x),N=i.useMemo(()=>e??m.jsx(A.TileLayer,{url:w,attribution:J,...O!==void 0&&{maxZoom:O}},w),[e,w,J,O]);return m.jsx(b.ElementEditorShell,{...u,ref:y,extraApi:K,engine:"leaflet",basemapControl:j&&m.jsx(f.BasemapPicker,{options:h.map(a=>{const c=W(a);return{id:C(a),label:c.label??C(a),thumbnail:c.thumbnail}}),value:C(x),onChange:a=>{const c=h.find(Y=>C(Y)===a);c&&q(c,!0)}}),renderMap:({attributionTarget:a,attributionCorner:c})=>m.jsx(G,{tileLayer:N,renderer:E,getFeatureStyle:t,attributionTarget:a,attributionCorner:c,setup:n,onReady:T})})});F.displayName="ElementEditor";Object.defineProperty(exports,"DEFAULT_LAYOUT",{enumerable:!0,get:()=>f.DEFAULT_LAYOUT});Object.defineProperty(exports,"IconButton",{enumerable:!0,get:()=>f.IconButton});Object.defineProperty(exports,"Tooltip",{enumerable:!0,get:()=>f.Tooltip});Object.defineProperty(exports,"withLayout",{enumerable:!0,get:()=>f.withLayout});Object.defineProperty(exports,"ACCENT_STEPS",{enumerable:!0,get:()=>v.ACCENT_STEPS});Object.defineProperty(exports,"DEFAULT_ACCENT",{enumerable:!0,get:()=>v.DEFAULT_ACCENT});Object.defineProperty(exports,"ElementEditorError",{enumerable:!0,get:()=>v.ElementEditorError});Object.defineProperty(exports,"accentPalette",{enumerable:!0,get:()=>v.accentPalette});exports.ElementEditor=F;
|
package/dist/leaflet.es.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as c, jsxs as B } from "react/jsx-runtime";
|
|
3
|
-
import { useState as T, useId as H, useEffect as h, memo as q, useMemo as
|
|
3
|
+
import { useState as T, useId as H, useEffect as h, memo as q, useMemo as w, useRef as j, forwardRef as G, useCallback as Z } from "react";
|
|
4
4
|
import { useMap as U, MapContainer as D, TileLayer as R } from "react-leaflet";
|
|
5
5
|
import { useUIStore as z, useElementEditorConfig as Y, BasemapPicker as L } from "@element-editor/ui";
|
|
6
6
|
import { DEFAULT_LAYOUT as ke, IconButton as Fe, Tooltip as Ie, withLayout as Ke } from "@element-editor/ui";
|
|
7
|
-
import { u as _, r as $, F as ee, a as k, s as te, p as oe, b as ne, E as ie } from "./useBasemapState-
|
|
7
|
+
import { u as _, r as $, F as ee, a as k, s as te, p as oe, b as ne, E as ie } from "./useBasemapState-DxeagojX.js";
|
|
8
8
|
import { ElementEditorControls as re } from "@element-editor/adapter-leaflet";
|
|
9
9
|
import { createPortal as se } from "react-dom";
|
|
10
10
|
import F from "leaflet";
|
|
11
11
|
import { Info as ae } from "@phosphor-icons/react";
|
|
12
|
-
import { writeStorage as le, readStorage as
|
|
12
|
+
import { writeStorage as le, readStorage as de } from "@element-editor/core";
|
|
13
13
|
import { ACCENT_STEPS as Ue, DEFAULT_ACCENT as Ye, ElementEditorError as Ne, accentPalette as Se } from "@element-editor/core";
|
|
14
|
-
import { warnOnce as
|
|
14
|
+
import { warnOnce as me, overrideSource as ue } from "@element-editor/core/internal";
|
|
15
15
|
function ce({ target: e, corner: i }) {
|
|
16
16
|
var g;
|
|
17
|
-
const o = U(), [r,
|
|
17
|
+
const o = U(), [r, d] = T(!0), f = `elm-attribution${H().replace(/:/g, "")}`, t = (g = o.attributionControl) == null ? void 0 : g.getContainer(), [m] = T(() => t == null ? void 0 : t.parentElement), p = i ?? m;
|
|
18
18
|
h(() => {
|
|
19
|
-
if (!(!t || !
|
|
19
|
+
if (!(!t || !m))
|
|
20
20
|
return e ? (t.classList.add("elm-attribution-bar"), e.appendChild(t), () => {
|
|
21
|
-
t.classList.remove("elm-attribution-bar"),
|
|
21
|
+
t.classList.remove("elm-attribution-bar"), m.appendChild(t);
|
|
22
22
|
}) : (t.classList.add("elm-attribution-compact"), t.id = f, i && i.prepend(t), () => {
|
|
23
|
-
t.classList.remove("elm-attribution-compact", "elm-attribution-open"), i &&
|
|
23
|
+
t.classList.remove("elm-attribution-compact", "elm-attribution-open"), i && m.appendChild(t);
|
|
24
24
|
});
|
|
25
|
-
}, [t,
|
|
25
|
+
}, [t, m, i, e, f]), h(() => {
|
|
26
26
|
if (e || (t == null || t.classList.toggle("elm-attribution-open", r), !r)) return;
|
|
27
|
-
const n = () =>
|
|
27
|
+
const n = () => d(!1), u = (b) => {
|
|
28
28
|
b.key === "Escape" && n();
|
|
29
29
|
};
|
|
30
30
|
return o.on("dragstart", n), document.addEventListener("keydown", u), () => {
|
|
31
31
|
o.off("dragstart", n), document.removeEventListener("keydown", u);
|
|
32
32
|
};
|
|
33
33
|
}, [r, o, t, e]);
|
|
34
|
-
const a = _(o.getContainer(), () =>
|
|
34
|
+
const a = _(o.getContainer(), () => d(!1), !e && !!t);
|
|
35
35
|
return !t || !p || e ? null : se(
|
|
36
36
|
/* @__PURE__ */ c(
|
|
37
37
|
"button",
|
|
@@ -45,7 +45,7 @@ function ce({ target: e, corner: i }) {
|
|
|
45
45
|
"aria-expanded": r,
|
|
46
46
|
"aria-controls": f,
|
|
47
47
|
onClick: () => {
|
|
48
|
-
a(),
|
|
48
|
+
a(), d((n) => !n);
|
|
49
49
|
},
|
|
50
50
|
children: /* @__PURE__ */ c(ae, { size: 16, weight: "bold", "aria-hidden": !0 })
|
|
51
51
|
}
|
|
@@ -58,8 +58,8 @@ function pe() {
|
|
|
58
58
|
return h(() => {
|
|
59
59
|
function r() {
|
|
60
60
|
o.current && clearTimeout(o.current), o.current = setTimeout(() => {
|
|
61
|
-
const
|
|
62
|
-
te(
|
|
61
|
+
const d = e.getCenter();
|
|
62
|
+
te(d.lat, d.lng, e.getZoom(), i);
|
|
63
63
|
}, 300);
|
|
64
64
|
}
|
|
65
65
|
return e.on("moveend", r), () => {
|
|
@@ -71,10 +71,10 @@ function pe() {
|
|
|
71
71
|
}, [e]), h(() => {
|
|
72
72
|
}, [e]), null;
|
|
73
73
|
}
|
|
74
|
-
const fe = q(function({ tileLayer: i, renderer: o, getFeatureStyle: r, attributionTarget:
|
|
75
|
-
const p = z((b) => b.readonly), a = z((b) => b.bounds), g = Y(), [n] = T(() => $(t, g)), u =
|
|
76
|
-
() => /* @__PURE__ */ c(re, { readonly: p, bounds: a, renderer: o, getFeatureStyle: r, onReady:
|
|
77
|
-
[p, a, o, r,
|
|
74
|
+
const fe = q(function({ tileLayer: i, renderer: o, getFeatureStyle: r, attributionTarget: d, attributionCorner: f, setup: t, onReady: m }) {
|
|
75
|
+
const p = z((b) => b.readonly), a = z((b) => b.bounds), g = Y(), [n] = T(() => $(t, g)), u = w(
|
|
76
|
+
() => /* @__PURE__ */ c(re, { drawingBar: !1, readonly: p, bounds: a, renderer: o, getFeatureStyle: r, onReady: m }),
|
|
77
|
+
[p, a, o, r, m]
|
|
78
78
|
);
|
|
79
79
|
return /* @__PURE__ */ B(
|
|
80
80
|
D,
|
|
@@ -88,7 +88,7 @@ const fe = q(function({ tileLayer: i, renderer: o, getFeatureStyle: r, attributi
|
|
|
88
88
|
i,
|
|
89
89
|
u,
|
|
90
90
|
/* @__PURE__ */ c(pe, {}),
|
|
91
|
-
/* @__PURE__ */ c(ce, { target:
|
|
91
|
+
/* @__PURE__ */ c(ce, { target: d, corner: f })
|
|
92
92
|
]
|
|
93
93
|
}
|
|
94
94
|
);
|
|
@@ -117,30 +117,30 @@ function ve(e) {
|
|
|
117
117
|
);
|
|
118
118
|
return { id: "osm", label: "OpenStreetMap", thumbnail: be, url: ((o = i.tiles) == null ? void 0 : o[0]) ?? i.url ?? "", attribution: i.attribution ?? "", ...i.maxzoom !== void 0 && { maxZoom: i.maxzoom } };
|
|
119
119
|
}
|
|
120
|
-
const v = (e) => e === "osm" ? "osm" : e.id ?? e.url, Ce = G(({ tileLayer: e, basemaps: i, basemap: o, defaultBasemap: r, onBasemapChange:
|
|
120
|
+
const v = (e) => e === "osm" ? "osm" : e.id ?? e.url, Ce = G(({ tileLayer: e, basemaps: i, basemap: o, defaultBasemap: r, onBasemapChange: d, renderer: f, getFeatureStyle: t, mapOptions: m, onMapReady: p, ...a }, g) => {
|
|
121
121
|
var x, M;
|
|
122
122
|
const [n] = T(() => ({
|
|
123
123
|
initialView: a.initialView,
|
|
124
124
|
initialData: a.initialData,
|
|
125
125
|
bounds: a.bounds,
|
|
126
|
-
mapOptions: oe(
|
|
126
|
+
mapOptions: oe(m, ge, "leaflet")
|
|
127
127
|
})), u = j(p);
|
|
128
128
|
u.current = p;
|
|
129
129
|
const b = Z((s) => {
|
|
130
130
|
var l;
|
|
131
131
|
return (l = u.current) == null ? void 0 : l.call(u, s);
|
|
132
132
|
}, []);
|
|
133
|
-
e && (i || o || r ||
|
|
134
|
-
const
|
|
133
|
+
e && (i || o || r || d) && me("leaflet-tileLayer-basemaps", "<ElementEditor tileLayer> overrides `basemaps`, `basemap`, `defaultBasemap` and `onBasemapChange`: they are ignored (and no basemap picker is shown).");
|
|
134
|
+
const A = (M = (x = a.config) == null ? void 0 : x.network) == null ? void 0 : M.osmRaster, N = w(() => ve(A), [JSON.stringify(A)]), Q = (s) => s === "osm" ? N : s, C = i ?? ["osm"], W = !e && C.length >= 2, { current: O, pick: S, api: V } = ne(
|
|
135
135
|
e ? void 0 : o,
|
|
136
136
|
() => {
|
|
137
|
-
const s =
|
|
137
|
+
const s = de(I, a.config);
|
|
138
138
|
return C.find((l) => v(l) === s) ?? r ?? C[0];
|
|
139
139
|
},
|
|
140
|
-
|
|
140
|
+
d,
|
|
141
141
|
(s) => le(I, v(s), a.config),
|
|
142
142
|
W
|
|
143
|
-
), { url: E, attribution: J, maxZoom: y } = Q(O), P =
|
|
143
|
+
), { url: E, attribution: J, maxZoom: y } = Q(O), P = w(() => e ?? // No `maxZoom={undefined}`: Leaflet would copy it over the default and the map's max zoom becomes NaN (fitBounds breaks).
|
|
144
144
|
/* @__PURE__ */ c(R, { url: E, attribution: J, ...y !== void 0 && { maxZoom: y } }, E), [e, E, J, y]);
|
|
145
145
|
return /* @__PURE__ */ c(
|
|
146
146
|
ie,
|
package/dist/shared.d.cts
CHANGED
|
@@ -6,8 +6,8 @@ export type { MutationOptions, SetFeatureCollectionOptions, ValidationReport } f
|
|
|
6
6
|
export { ElementEditorError } from '@element-editor/core';
|
|
7
7
|
export { IconButton, Tooltip } from '@element-editor/ui';
|
|
8
8
|
export { accentPalette, DEFAULT_ACCENT, ACCENT_STEPS } from '@element-editor/core';
|
|
9
|
-
export type { AccentShade } from '@element-editor/core';
|
|
9
|
+
export type { AccentShade, GeometryType } from '@element-editor/core';
|
|
10
10
|
export type { FeatureStyle } from '@element-editor/core';
|
|
11
11
|
export type { ElementEditorBaseProps } from './shell/types.cjs';
|
|
12
12
|
export type { InitialView } from './shell/savedView.cjs';
|
|
13
|
-
export type { BBox, BoundsInput, FlyToOptions } from '@element-editor/core';
|
|
13
|
+
export type { BBox, BoundsInput, CoordinateOptions, FlyToOptions } from '@element-editor/core';
|
package/dist/shared.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export type { MutationOptions, SetFeatureCollectionOptions, ValidationReport } f
|
|
|
6
6
|
export { ElementEditorError } from '@element-editor/core';
|
|
7
7
|
export { IconButton, Tooltip } from '@element-editor/ui';
|
|
8
8
|
export { accentPalette, DEFAULT_ACCENT, ACCENT_STEPS } from '@element-editor/core';
|
|
9
|
-
export type { AccentShade } from '@element-editor/core';
|
|
9
|
+
export type { AccentShade, GeometryType } from '@element-editor/core';
|
|
10
10
|
export type { FeatureStyle } from '@element-editor/core';
|
|
11
11
|
export type { ElementEditorBaseProps } from './shell/types.js';
|
|
12
12
|
export type { InitialView } from './shell/savedView.js';
|
|
13
|
-
export type { BBox, BoundsInput, FlyToOptions } from '@element-editor/core';
|
|
13
|
+
export type { BBox, BoundsInput, CoordinateOptions, FlyToOptions } from '@element-editor/core';
|
package/dist/shell/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { FeatureCollection, FeatureCollectionInput, Schema, GeoJSONFeature, GeoJSONFeatureInput } from '../types/geojson.cjs';
|
|
3
|
-
import { BoundsInput } from '@element-editor/core';
|
|
3
|
+
import { BoundsInput, CoordinateOptions, GeometryType } from '@element-editor/core';
|
|
4
4
|
import { InitialView } from './savedView.cjs';
|
|
5
5
|
import { ElementEditorEvent, ElementEditorErrorHandler, ElementEditorConfig, DrawTool } from '@element-editor/ui';
|
|
6
6
|
export interface ElementEditorBaseProps {
|
|
@@ -64,6 +64,51 @@ export interface ElementEditorBaseProps {
|
|
|
64
64
|
* @default undefined (no limit; imports are still capped at 50,000 features)
|
|
65
65
|
*/
|
|
66
66
|
maxFeatures?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Geometry types the editor accepts, as GeoJSON type names; omit to allow all. Enforced for every
|
|
69
|
+
* way a geometry gets in (drawing, paste, import, `initialData`, merge, break apart, boolean ops,
|
|
70
|
+
* buffer, the ref API, ...): a refusal changes nothing and reports an `error` event, `code:
|
|
71
|
+
* 'geometry-type-not-allowed'`. Drawing tools that can't draw an allowed type are left out, and
|
|
72
|
+
* menu actions whose result would be refused are hidden. Works with `tools` and `maxFeatures`.
|
|
73
|
+
*
|
|
74
|
+
* @default undefined (every type)
|
|
75
|
+
* @example geometryTypes={['Polygon', 'MultiPolygon']}
|
|
76
|
+
*/
|
|
77
|
+
geometryTypes?: GeometryType[];
|
|
78
|
+
/**
|
|
79
|
+
* With `maxFeatures={1}`: a draw tool (point, line, area, rectangle, circle, freehand, route, picker)
|
|
80
|
+
* replaces the only feature's geometry instead of being refused, keeping its `id`, properties, schema
|
|
81
|
+
* and group. One undo step, one `onFeatureUpdate`. Tools stay available at the limit. Paste, duplicate,
|
|
82
|
+
* import merge and the ref's `addFeature` still refuse. Ignored (with a dev warning) for any other
|
|
83
|
+
* `maxFeatures`. For a "pick the location" field: `tools={['point']} maxFeatures={1} replaceAtLimit`.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
replaceAtLimit?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* `true`: every drawing tool turns off after a finished shape (the new shape is selected and
|
|
90
|
+
* `onToolChange(null)` fires), for a one-shape-at-a-time flow. `false`: tools stay on. Either
|
|
91
|
+
* wins over the user's saved setting ("Return to select after each shape"), is never saved to
|
|
92
|
+
* their browser, and makes that Settings toggle read-only. Unset: the user's setting decides
|
|
93
|
+
* (default: tools stay on).
|
|
94
|
+
*/
|
|
95
|
+
autoExitAfterDraw?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Opt-in clean-up of every committed coordinate (drawing, vertex edits, transforms, import, paste,
|
|
98
|
+
* undo/redo, `initialData`, ref methods), so the store, `onChange` and undo history hold the same
|
|
99
|
+
* values. Both parts are off unless set:
|
|
100
|
+
* - `wrap: true` shifts a feature as a whole by a multiple of 360 degrees so the centre of its
|
|
101
|
+
* longitude range lies in [-180, 180] (RFC 7946 positions). Vertices stay continuous, so a shape
|
|
102
|
+
* crossing the antimeridian keeps its outline; one side may then lie beyond +-180. Latitudes
|
|
103
|
+
* beyond +-90 are clamped; others are left alone.
|
|
104
|
+
* - `precision: n` rounds x and y to `n` decimals (integer 0 to 15; 6 is about 0.1 m). Altitude is kept
|
|
105
|
+
* untouched. Consecutive duplicate vertices created by rounding are dropped when the shape stays valid.
|
|
106
|
+
*
|
|
107
|
+
* Unrelated to `config.units.precision`, which only formats what is displayed.
|
|
108
|
+
*
|
|
109
|
+
* @default undefined (coordinates are stored as the map reports them)
|
|
110
|
+
*/
|
|
111
|
+
coordinates?: CoordinateOptions;
|
|
67
112
|
/**
|
|
68
113
|
* Restricts panning to this box: the user can't drag the map outside it. The map starts fitted
|
|
69
114
|
* to it only when nothing else gives a start view (see `initialView`). A GeoJSON bbox `[west, south, east, north]`
|
|
@@ -189,6 +234,12 @@ export interface ElementEditorBaseProps {
|
|
|
189
234
|
* changed it.
|
|
190
235
|
*/
|
|
191
236
|
onToolChange?: (tool: DrawTool | null) => void;
|
|
237
|
+
/**
|
|
238
|
+
* Called with the id of the feature that entered point editing (vertex edit, as
|
|
239
|
+
* `ref.getVertexEdit()` reports it), or `null` when point editing ended, whether the user
|
|
240
|
+
* (double-click, Enter, Esc, a click away, delete, undo) or your app (`ref.setVertexEdit`) changed it.
|
|
241
|
+
*/
|
|
242
|
+
onVertexEditChange?: (id: string | null) => void;
|
|
192
243
|
/**
|
|
193
244
|
* Receives every message the editor would show the user (errors, warnings, confirmations,
|
|
194
245
|
* `feature:deleted` with an `undo`, …). With it set, the editor shows no toasts: your app
|
package/dist/shell/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { FeatureCollection, FeatureCollectionInput, Schema, GeoJSONFeature, GeoJSONFeatureInput } from '../types/geojson.js';
|
|
3
|
-
import { BoundsInput } from '@element-editor/core';
|
|
3
|
+
import { BoundsInput, CoordinateOptions, GeometryType } from '@element-editor/core';
|
|
4
4
|
import { InitialView } from './savedView.js';
|
|
5
5
|
import { ElementEditorEvent, ElementEditorErrorHandler, ElementEditorConfig, DrawTool } from '@element-editor/ui';
|
|
6
6
|
export interface ElementEditorBaseProps {
|
|
@@ -64,6 +64,51 @@ export interface ElementEditorBaseProps {
|
|
|
64
64
|
* @default undefined (no limit; imports are still capped at 50,000 features)
|
|
65
65
|
*/
|
|
66
66
|
maxFeatures?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Geometry types the editor accepts, as GeoJSON type names; omit to allow all. Enforced for every
|
|
69
|
+
* way a geometry gets in (drawing, paste, import, `initialData`, merge, break apart, boolean ops,
|
|
70
|
+
* buffer, the ref API, ...): a refusal changes nothing and reports an `error` event, `code:
|
|
71
|
+
* 'geometry-type-not-allowed'`. Drawing tools that can't draw an allowed type are left out, and
|
|
72
|
+
* menu actions whose result would be refused are hidden. Works with `tools` and `maxFeatures`.
|
|
73
|
+
*
|
|
74
|
+
* @default undefined (every type)
|
|
75
|
+
* @example geometryTypes={['Polygon', 'MultiPolygon']}
|
|
76
|
+
*/
|
|
77
|
+
geometryTypes?: GeometryType[];
|
|
78
|
+
/**
|
|
79
|
+
* With `maxFeatures={1}`: a draw tool (point, line, area, rectangle, circle, freehand, route, picker)
|
|
80
|
+
* replaces the only feature's geometry instead of being refused, keeping its `id`, properties, schema
|
|
81
|
+
* and group. One undo step, one `onFeatureUpdate`. Tools stay available at the limit. Paste, duplicate,
|
|
82
|
+
* import merge and the ref's `addFeature` still refuse. Ignored (with a dev warning) for any other
|
|
83
|
+
* `maxFeatures`. For a "pick the location" field: `tools={['point']} maxFeatures={1} replaceAtLimit`.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
replaceAtLimit?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* `true`: every drawing tool turns off after a finished shape (the new shape is selected and
|
|
90
|
+
* `onToolChange(null)` fires), for a one-shape-at-a-time flow. `false`: tools stay on. Either
|
|
91
|
+
* wins over the user's saved setting ("Return to select after each shape"), is never saved to
|
|
92
|
+
* their browser, and makes that Settings toggle read-only. Unset: the user's setting decides
|
|
93
|
+
* (default: tools stay on).
|
|
94
|
+
*/
|
|
95
|
+
autoExitAfterDraw?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Opt-in clean-up of every committed coordinate (drawing, vertex edits, transforms, import, paste,
|
|
98
|
+
* undo/redo, `initialData`, ref methods), so the store, `onChange` and undo history hold the same
|
|
99
|
+
* values. Both parts are off unless set:
|
|
100
|
+
* - `wrap: true` shifts a feature as a whole by a multiple of 360 degrees so the centre of its
|
|
101
|
+
* longitude range lies in [-180, 180] (RFC 7946 positions). Vertices stay continuous, so a shape
|
|
102
|
+
* crossing the antimeridian keeps its outline; one side may then lie beyond +-180. Latitudes
|
|
103
|
+
* beyond +-90 are clamped; others are left alone.
|
|
104
|
+
* - `precision: n` rounds x and y to `n` decimals (integer 0 to 15; 6 is about 0.1 m). Altitude is kept
|
|
105
|
+
* untouched. Consecutive duplicate vertices created by rounding are dropped when the shape stays valid.
|
|
106
|
+
*
|
|
107
|
+
* Unrelated to `config.units.precision`, which only formats what is displayed.
|
|
108
|
+
*
|
|
109
|
+
* @default undefined (coordinates are stored as the map reports them)
|
|
110
|
+
*/
|
|
111
|
+
coordinates?: CoordinateOptions;
|
|
67
112
|
/**
|
|
68
113
|
* Restricts panning to this box: the user can't drag the map outside it. The map starts fitted
|
|
69
114
|
* to it only when nothing else gives a start view (see `initialView`). A GeoJSON bbox `[west, south, east, north]`
|
|
@@ -189,6 +234,12 @@ export interface ElementEditorBaseProps {
|
|
|
189
234
|
* changed it.
|
|
190
235
|
*/
|
|
191
236
|
onToolChange?: (tool: DrawTool | null) => void;
|
|
237
|
+
/**
|
|
238
|
+
* Called with the id of the feature that entered point editing (vertex edit, as
|
|
239
|
+
* `ref.getVertexEdit()` reports it), or `null` when point editing ended, whether the user
|
|
240
|
+
* (double-click, Enter, Esc, a click away, delete, undo) or your app (`ref.setVertexEdit`) changed it.
|
|
241
|
+
*/
|
|
242
|
+
onVertexEditChange?: (id: string | null) => void;
|
|
192
243
|
/**
|
|
193
244
|
* Receives every message the editor would show the user (errors, warnings, confirmations,
|
|
194
245
|
* `feature:deleted` with an `undo`, …). With it set, the editor shows no toasts: your app
|