@element-editor/react 0.0.0-stage → 0.2.0
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 +429 -0
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/element-editor-leaflet.css +1 -0
- package/dist/element-editor.cjs +1 -0
- package/dist/element-editor.css +1 -0
- package/dist/element-editor.es.js +178 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/leaflet/CompactAttribution.d.cts +23 -0
- package/dist/leaflet/CompactAttribution.d.ts +23 -0
- package/dist/leaflet/ElementEditor.d.cts +81 -0
- package/dist/leaflet/ElementEditor.d.ts +81 -0
- package/dist/leaflet/MapView.d.cts +28 -0
- package/dist/leaflet/MapView.d.ts +28 -0
- package/dist/leaflet/index.d.cts +3 -0
- package/dist/leaflet/index.d.ts +3 -0
- package/dist/leaflet.cjs +1 -0
- package/dist/leaflet.d.cts +2 -0
- package/dist/leaflet.d.ts +2 -0
- package/dist/leaflet.es.js +181 -0
- package/dist/maplibre/ElementEditor.d.cts +68 -0
- package/dist/maplibre/ElementEditor.d.ts +68 -0
- package/dist/maplibre/MapLibreMapView.d.cts +34 -0
- package/dist/maplibre/MapLibreMapView.d.ts +34 -0
- package/dist/maplibre/index.d.cts +2 -0
- package/dist/maplibre/index.d.ts +2 -0
- package/dist/shared.d.cts +13 -0
- package/dist/shared.d.ts +13 -0
- package/dist/shell/ElementEditorShell.d.cts +32 -0
- package/dist/shell/ElementEditorShell.d.ts +32 -0
- package/dist/shell/FileDropBox.d.cts +13 -0
- package/dist/shell/FileDropBox.d.ts +13 -0
- package/dist/shell/ShellControl.d.cts +19 -0
- package/dist/shell/ShellControl.d.ts +19 -0
- package/dist/shell/ShellPanels.d.cts +13 -0
- package/dist/shell/ShellPanels.d.ts +13 -0
- package/dist/shell/savedView.d.cts +49 -0
- package/dist/shell/savedView.d.ts +49 -0
- package/dist/shell/types.d.cts +253 -0
- package/dist/shell/types.d.ts +253 -0
- package/dist/shell/useAttributionAutoCollapse.d.cts +17 -0
- package/dist/shell/useAttributionAutoCollapse.d.ts +17 -0
- package/dist/shell/useBasemapState.d.cts +20 -0
- package/dist/shell/useBasemapState.d.ts +20 -0
- package/dist/shell/useDevChecks.d.cts +11 -0
- package/dist/shell/useDevChecks.d.ts +11 -0
- package/dist/shell/useResolvedTheme.d.cts +14 -0
- package/dist/shell/useResolvedTheme.d.ts +14 -0
- package/dist/shell/useSlotAutoLayout.d.cts +23 -0
- package/dist/shell/useSlotAutoLayout.d.ts +23 -0
- package/dist/store/StoreContext.d.cts +1 -0
- package/dist/store/StoreContext.d.ts +1 -0
- package/dist/types/geojson.d.cts +1 -0
- package/dist/types/geojson.d.ts +1 -0
- package/dist/useBasemapState-8bWJK84f.cjs +1 -0
- package/dist/useBasemapState-DChxz3lv.js +682 -0
- package/package.json +150 -3
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ElementEditorError as q, writeStorage as G, readStorage as J } from "@element-editor/core";
|
|
3
|
+
import { ACCENT_STEPS as _e, DEFAULT_ACCENT as Ne, ElementEditorError as De, accentPalette as Fe } from "@element-editor/core";
|
|
4
|
+
import { useUIStore as x, useElementEditorConfig as R } from "@element-editor/ui";
|
|
5
|
+
import { DEFAULT_LAYOUT as Ze, IconButton as je, Tooltip as ze, withLayout as Ye } from "@element-editor/ui";
|
|
6
|
+
import { jsxs as W, Fragment as K, jsx as v } from "react/jsx-runtime";
|
|
7
|
+
import { memo as X, useRef as w, useState as P, useEffect as _, forwardRef as H, useCallback as Q } from "react";
|
|
8
|
+
import { useBasemap as ee, ElementEditorControls as te, BasemapControl as oe } from "@element-editor/adapter-maplibre";
|
|
9
|
+
import { loadErrorCode as ne, warnOnce as Z, isDevBuild as re } from "@element-editor/core/internal";
|
|
10
|
+
import { r as ie, F as se, a as ae, s as le, u as ce, b as me, p as ue, E as de } from "./useBasemapState-DChxz3lv.js";
|
|
11
|
+
import N from "maplibre-gl";
|
|
12
|
+
import { useServiceAttribution as pe } from "@element-editor/ui/internal";
|
|
13
|
+
import { loadBasemapStyle as fe, resolveBasemap as Ee } from "@element-editor/adapter-maplibre/basemaps";
|
|
14
|
+
const D = { version: 8, sources: {}, layers: [] }, be = X(function({ basemap: r, themeMode: E, attributionTarget: s, attributionCorner: b, getFeatureStyle: O, setup: C, onReady: d }) {
|
|
15
|
+
const T = x((t) => t.readonly), p = x((t) => t.reportError), A = x((t) => t.bounds), L = w(null), [n, S] = P(null), h = w({ basemap: r, themeMode: E, scope: R(), setup: C }), B = w(p);
|
|
16
|
+
B.current = p, ee(n, r, { theme: E, initialApplied: !0 });
|
|
17
|
+
const o = pe();
|
|
18
|
+
_(() => {
|
|
19
|
+
const t = L.current;
|
|
20
|
+
if (!t) return;
|
|
21
|
+
let l = !1, f = null, i = null, k;
|
|
22
|
+
const { basemap: Y, themeMode: I, scope: M, setup: U } = h.current, V = (m) => {
|
|
23
|
+
const u = `The basemap could not be loaded (${m instanceof Error ? m.message : String(m)}). The map shows no basemap; editing still works.`;
|
|
24
|
+
console.error(`[element-editor] ${u}`), B.current(new q(ne(m), "basemap", u, { cause: m }));
|
|
25
|
+
};
|
|
26
|
+
return fe(Ee(Y, I), { network: M.network, theme: I }).catch((m) => (l || V(m), D)).then((m) => {
|
|
27
|
+
if (l) return;
|
|
28
|
+
const u = ie(U, M), c = new N.Map({
|
|
29
|
+
...U.mapOptions,
|
|
30
|
+
container: t,
|
|
31
|
+
style: m,
|
|
32
|
+
..."bounds" in u ? { bounds: [[u.bounds[0], u.bounds[1]], [u.bounds[2], u.bounds[3]]], fitBoundsOptions: { padding: ae, maxZoom: se } } : { center: u.center, zoom: u.zoom },
|
|
33
|
+
attributionControl: !1
|
|
34
|
+
});
|
|
35
|
+
if (f = c, typeof m == "string") {
|
|
36
|
+
const g = ($) => {
|
|
37
|
+
c.off("error", g), V($.error), c.setStyle(D, { diff: !1 });
|
|
38
|
+
};
|
|
39
|
+
c.on("error", g), c.once("styledata", () => c.off("error", g));
|
|
40
|
+
}
|
|
41
|
+
c.on("moveend", () => {
|
|
42
|
+
clearTimeout(k), k = setTimeout(() => {
|
|
43
|
+
const g = c.getCenter();
|
|
44
|
+
le(g.lat, g.lng, c.getZoom(), M);
|
|
45
|
+
}, 300);
|
|
46
|
+
}), i = new ResizeObserver(() => c.resize()), i.observe(t), S(c);
|
|
47
|
+
}), () => {
|
|
48
|
+
l = !0, clearTimeout(k), i == null || i.disconnect(), f == null || f.remove(), S(null);
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
const a = w(null), y = ce(n == null ? void 0 : n.getContainer(), () => {
|
|
52
|
+
const t = a.current;
|
|
53
|
+
t && t.classList.contains("maplibregl-compact") && !t.classList.contains("maplibregl-attrib-empty") && t.classList.remove("maplibregl-compact-show");
|
|
54
|
+
}, !!n && !s);
|
|
55
|
+
return _(() => {
|
|
56
|
+
if (!n) return;
|
|
57
|
+
const t = new N.AttributionControl({
|
|
58
|
+
compact: !s,
|
|
59
|
+
...o && { customAttribution: o }
|
|
60
|
+
});
|
|
61
|
+
n.addControl(t, "bottom-right");
|
|
62
|
+
const l = n.getContainer().querySelector(".maplibregl-ctrl-attrib");
|
|
63
|
+
a.current = l;
|
|
64
|
+
const f = s ?? b;
|
|
65
|
+
f && l && (l.classList.add(s ? "elm-attribution-bar" : "elm-attribution-corner"), f.appendChild(l));
|
|
66
|
+
const i = l == null ? void 0 : l.querySelector(".maplibregl-ctrl-attrib-button");
|
|
67
|
+
return i == null || i.addEventListener("click", y), () => {
|
|
68
|
+
i == null || i.removeEventListener("click", y), a.current = null;
|
|
69
|
+
try {
|
|
70
|
+
n.removeControl(t);
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}, [n, s, b, o, y]), /* @__PURE__ */ W(K, { children: [
|
|
75
|
+
/* @__PURE__ */ v("div", { ref: L, style: { position: "absolute", inset: 0, zIndex: 0 } }),
|
|
76
|
+
n && /* @__PURE__ */ v(
|
|
77
|
+
te,
|
|
78
|
+
{
|
|
79
|
+
map: n,
|
|
80
|
+
readonly: T,
|
|
81
|
+
getFeatureStyle: O,
|
|
82
|
+
maxBounds: A ?? null,
|
|
83
|
+
onReady: d
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] });
|
|
87
|
+
}), he = {
|
|
88
|
+
container: "Element creates the map container.",
|
|
89
|
+
style: "Use the `basemap` / `defaultBasemap` prop.",
|
|
90
|
+
center: "Use `initialView`.",
|
|
91
|
+
zoom: "Use `initialView`.",
|
|
92
|
+
bounds: "Use `initialView={{ bounds }}`.",
|
|
93
|
+
fitBoundsOptions: "Use `initialView`.",
|
|
94
|
+
maxBounds: "Use the `bounds` prop.",
|
|
95
|
+
attributionControl: "Element shows the attribution (move it into the status bar with the 'attribution' layout control).",
|
|
96
|
+
interactive: "Element turns map interactions on and off while editing.",
|
|
97
|
+
dragPan: "Element turns dragPan on and off while editing.",
|
|
98
|
+
boxZoom: "Element turns boxZoom on and off while editing.",
|
|
99
|
+
doubleClickZoom: "Element turns doubleClickZoom on and off while editing."
|
|
100
|
+
}, j = "elm_basemap", ge = ["auto", "streets", "terrain", "light", "dark", "osm"], z = (e) => typeof e == "string" ? e : e.id, F = (e) => typeof e == "object" && !e.id && !e.label && "style" in e && typeof e.style != "string";
|
|
101
|
+
function we(e) {
|
|
102
|
+
const r = w(e);
|
|
103
|
+
re() && e !== r.current && F(e) && F(r.current) && JSON.stringify(e) === JSON.stringify(r.current) && Z("basemap-anon-style", "<ElementEditor basemap>: an id-less style object is passed as a new object on every render, so the style is re-applied each time. Give it an `id` or keep the object stable (module-level or useMemo)."), r.current = e;
|
|
104
|
+
}
|
|
105
|
+
function ye(e, r, E) {
|
|
106
|
+
if (r === !1) return e;
|
|
107
|
+
const s = J(j, E);
|
|
108
|
+
return r.find((b) => s && z(b) === s) ?? e;
|
|
109
|
+
}
|
|
110
|
+
const ve = ["tileLayer", "renderer"], Ce = H(
|
|
111
|
+
({ basemap: e, defaultBasemap: r = "auto", onBasemapChange: E, basemaps: s, getFeatureStyle: b, mapOptions: O, onMapReady: C, ...d }, T) => {
|
|
112
|
+
for (const o of ve)
|
|
113
|
+
d[o] !== void 0 && Z(`maplibre-${o}`, `<ElementEditor ${o}> 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.`);
|
|
114
|
+
const p = s === void 0 ? ge : s, { current: A, pick: L, api: n } = me(
|
|
115
|
+
e,
|
|
116
|
+
() => ye(r, p, d.config),
|
|
117
|
+
E,
|
|
118
|
+
(o) => {
|
|
119
|
+
const a = z(o);
|
|
120
|
+
a && G(j, a, d.config);
|
|
121
|
+
},
|
|
122
|
+
p !== !1
|
|
123
|
+
);
|
|
124
|
+
we(e);
|
|
125
|
+
const [S] = P(() => ({
|
|
126
|
+
initialView: d.initialView,
|
|
127
|
+
initialData: d.initialData,
|
|
128
|
+
bounds: d.bounds,
|
|
129
|
+
mapOptions: ue(O, he, "maplibre")
|
|
130
|
+
})), h = w(C);
|
|
131
|
+
h.current = C;
|
|
132
|
+
const B = Q((o) => {
|
|
133
|
+
var a;
|
|
134
|
+
return (a = h.current) == null ? void 0 : a.call(h, o);
|
|
135
|
+
}, []);
|
|
136
|
+
return /* @__PURE__ */ v(
|
|
137
|
+
de,
|
|
138
|
+
{
|
|
139
|
+
...d,
|
|
140
|
+
ref: T,
|
|
141
|
+
extraApi: n,
|
|
142
|
+
engine: "maplibre",
|
|
143
|
+
basemapControl: p === !1 ? void 0 : /* @__PURE__ */ v(
|
|
144
|
+
oe,
|
|
145
|
+
{
|
|
146
|
+
basemaps: p,
|
|
147
|
+
value: A,
|
|
148
|
+
onChange: (o) => L(o, !0)
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
renderMap: ({ attributionTarget: o, attributionCorner: a, themeMode: y }) => /* @__PURE__ */ v(
|
|
152
|
+
be,
|
|
153
|
+
{
|
|
154
|
+
basemap: A,
|
|
155
|
+
themeMode: y,
|
|
156
|
+
attributionTarget: o,
|
|
157
|
+
attributionCorner: a,
|
|
158
|
+
getFeatureStyle: b,
|
|
159
|
+
setup: S,
|
|
160
|
+
onReady: B
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
Ce.displayName = "ElementEditor";
|
|
168
|
+
export {
|
|
169
|
+
_e as ACCENT_STEPS,
|
|
170
|
+
Ne as DEFAULT_ACCENT,
|
|
171
|
+
Ze as DEFAULT_LAYOUT,
|
|
172
|
+
Ce as ElementEditor,
|
|
173
|
+
De as ElementEditorError,
|
|
174
|
+
je as IconButton,
|
|
175
|
+
ze as Tooltip,
|
|
176
|
+
Fe as accentPalette,
|
|
177
|
+
Ye as withLayout
|
|
178
|
+
};
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ElementEditor } from './maplibre/index.cjs';
|
|
2
|
+
export type { ElementEditorProps, ElementEditorRef, ImportResult } from './maplibre/index.cjs';
|
|
3
|
+
export * from './shared.cjs';
|
|
4
|
+
export type { BasemapInput, BuiltinBasemapId } from '@element-editor/adapter-maplibre/basemaps';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ElementEditor } from './maplibre/index.js';
|
|
2
|
+
export type { ElementEditorProps, ElementEditorRef, ImportResult } from './maplibre/index.js';
|
|
3
|
+
export * from './shared.js';
|
|
4
|
+
export type { BasemapInput, BuiltinBasemapId } from '@element-editor/adapter-maplibre/basemaps';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapLibre-style compact attribution for Leaflet: Leaflet's own attribution
|
|
3
|
+
* control stays (so tileLayer attributions and `addAttribution` keep working)
|
|
4
|
+
* and a round "i" toggle collapses / expands it. Per the OSM Foundation
|
|
5
|
+
* attribution guidelines it starts expanded and collapses on the first map
|
|
6
|
+
* interaction or after five seconds (useAttributionAutoCollapse); dragging the
|
|
7
|
+
* map or Escape closes it again after the user reopens it. The toggle is
|
|
8
|
+
* portalled into the control's corner, not the control itself, because
|
|
9
|
+
* Leaflet rewrites the control's innerHTML whenever an attribution changes.
|
|
10
|
+
*
|
|
11
|
+
* With `target` (the status bar's `'attribution'` entry) the control element
|
|
12
|
+
* itself is moved there instead and no toggle renders. Leaflet keeps updating
|
|
13
|
+
* the same element, so the bar stays in sync with layer changes for free; it
|
|
14
|
+
* moves back to its map corner when `target` goes away.
|
|
15
|
+
*
|
|
16
|
+
* With `corner` (the shell's element at the bottom-right end of its slot row)
|
|
17
|
+
* the control and its toggle move there, so the shell lays its bottom
|
|
18
|
+
* controls out around the attribution instead of over it.
|
|
19
|
+
*/
|
|
20
|
+
export default function CompactAttribution({ target, corner: shellCorner }: {
|
|
21
|
+
target?: HTMLElement | null;
|
|
22
|
+
corner?: HTMLElement | null;
|
|
23
|
+
}): import('react').ReactPortal | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapLibre-style compact attribution for Leaflet: Leaflet's own attribution
|
|
3
|
+
* control stays (so tileLayer attributions and `addAttribution` keep working)
|
|
4
|
+
* and a round "i" toggle collapses / expands it. Per the OSM Foundation
|
|
5
|
+
* attribution guidelines it starts expanded and collapses on the first map
|
|
6
|
+
* interaction or after five seconds (useAttributionAutoCollapse); dragging the
|
|
7
|
+
* map or Escape closes it again after the user reopens it. The toggle is
|
|
8
|
+
* portalled into the control's corner, not the control itself, because
|
|
9
|
+
* Leaflet rewrites the control's innerHTML whenever an attribution changes.
|
|
10
|
+
*
|
|
11
|
+
* With `target` (the status bar's `'attribution'` entry) the control element
|
|
12
|
+
* itself is moved there instead and no toggle renders. Leaflet keeps updating
|
|
13
|
+
* the same element, so the bar stays in sync with layer changes for free; it
|
|
14
|
+
* moves back to its map corner when `target` goes away.
|
|
15
|
+
*
|
|
16
|
+
* With `corner` (the shell's element at the bottom-right end of its slot row)
|
|
17
|
+
* the control and its toggle move there, so the shell lays its bottom
|
|
18
|
+
* controls out around the attribution instead of over it.
|
|
19
|
+
*/
|
|
20
|
+
export default function CompactAttribution({ target, corner: shellCorner }: {
|
|
21
|
+
target?: HTMLElement | null;
|
|
22
|
+
corner?: HTMLElement | null;
|
|
23
|
+
}): import('react').ReactPortal | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RasterBasemap } from '@element-editor/ui';
|
|
3
|
+
import { FeatureStyleFn } from '@element-editor/adapter-leaflet';
|
|
4
|
+
import { Map as LeafletMap, MapOptions } from 'leaflet';
|
|
5
|
+
import { ElementEditorRef as ShellRef } from '../shell/ElementEditorShell.cjs';
|
|
6
|
+
import { ElementEditorBaseProps } from '../shell/types.cjs';
|
|
7
|
+
import { BasemapRefAPI } from '../shell/useBasemapState.cjs';
|
|
8
|
+
export type { ImportResult } from '../shell/ElementEditorShell.cjs';
|
|
9
|
+
/** A Leaflet drop-in basemap: a raster entry or `'osm'` (OpenStreetMap). */
|
|
10
|
+
export type LeafletBasemap = RasterBasemap | 'osm';
|
|
11
|
+
/**
|
|
12
|
+
* Imperative handle of the Leaflet `<ElementEditor ref>`; `getMap()` returns the `L.Map`,
|
|
13
|
+
* `getBasemap()` / `setBasemap()` read and switch the basemap.
|
|
14
|
+
*/
|
|
15
|
+
export type ElementEditorRef = ShellRef<LeafletMap> & BasemapRefAPI<LeafletBasemap>;
|
|
16
|
+
/** `L.Map` options Element sets itself; not accepted in `mapOptions`. */
|
|
17
|
+
export type OwnedMapOption = 'center' | 'zoom' | 'maxBounds' | 'zoomControl' | 'attributionControl' | 'crs' | 'renderer' | 'preferCanvas' | 'dragging' | 'boxZoom' | 'doubleClickZoom';
|
|
18
|
+
export interface ElementEditorProps extends ElementEditorBaseProps {
|
|
19
|
+
/**
|
|
20
|
+
* Tile layer to render under the features. Pass any react-leaflet tile
|
|
21
|
+
* component (`<TileLayer />`, `<MapboxTileLayer />`, vector tiles, etc.).
|
|
22
|
+
* If omitted, defaults to OpenStreetMap.
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* tileLayer={<TileLayer url="https://tiles.example.com/{z}/{x}/{y}.png" attribution="..." />}
|
|
26
|
+
*/
|
|
27
|
+
tileLayer?: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Raster basemaps to choose from. The first entry is the default (a single entry is simply
|
|
30
|
+
* used as the basemap); with two or more entries a basemap picker appears and the user's pick
|
|
31
|
+
* is remembered (localStorage `elm_basemap_leaflet`, namespaced by `config.persistKey`). `'osm'` is OpenStreetMap. Off by default
|
|
32
|
+
* (a single OpenStreetMap layer). Entries are told apart by `id`, else by `url`. Ignored when `tileLayer` is set.
|
|
33
|
+
*/
|
|
34
|
+
basemaps?: LeafletBasemap[];
|
|
35
|
+
/**
|
|
36
|
+
* The basemap shown, controlled by your app: an entry of `basemaps` (matched by `id`, else
|
|
37
|
+
* `url`), `'osm'`, or any other raster basemap (the picker then shows none selected). Update it
|
|
38
|
+
* from `onBasemapChange`, or the picker can't change it. Nothing is remembered in localStorage.
|
|
39
|
+
* Leave it out to let Element keep the choice (`defaultBasemap`). Ignored when `tileLayer` is set.
|
|
40
|
+
*/
|
|
41
|
+
basemap?: LeafletBasemap;
|
|
42
|
+
/**
|
|
43
|
+
* Starting basemap when `basemap` isn't set. Default: the first `basemaps` entry. The user's
|
|
44
|
+
* remembered pick wins over it on reload.
|
|
45
|
+
*/
|
|
46
|
+
defaultBasemap?: LeafletBasemap;
|
|
47
|
+
/** Called with the newly chosen basemap (as it appears in `basemaps`) when the user picks one or you call `ref.setBasemap()`. Not called when `basemap` changes. */
|
|
48
|
+
onBasemapChange?: (basemap: LeafletBasemap) => void;
|
|
49
|
+
/**
|
|
50
|
+
* How unselected features are drawn. `'canvas'` (default) paints them on one
|
|
51
|
+
* shared `<canvas>`, which keeps panning and zooming smooth with thousands of
|
|
52
|
+
* features. `'svg'` gives every feature its own `<path>` element. Selected
|
|
53
|
+
* features and editing handles are always SVG.
|
|
54
|
+
*/
|
|
55
|
+
renderer?: 'canvas' | 'svg';
|
|
56
|
+
/**
|
|
57
|
+
* Per-feature style: return a `FeatureStyle` `{ color, fillColor, opacity, fillOpacity, weight }`
|
|
58
|
+
* or any Leaflet `PathOptions` (`dashArray`, …); `fillColor` falls back to `color`; `undefined`/`null`
|
|
59
|
+
* = default look. Applies to polygons, lines and point pins (pins take `fillColor`, then `color`).
|
|
60
|
+
* Wins over `featureColor` per key; the selected / hovered looks win over both. Called on every
|
|
61
|
+
* render of each feature, so keep it fast and stable (module-level or `useCallback`).
|
|
62
|
+
*
|
|
63
|
+
* @example getFeatureStyle={(f) => ({ color: f.properties.status === 'done' ? '#16a34a' : '#00a2f0' })}
|
|
64
|
+
*/
|
|
65
|
+
getFeatureStyle?: FeatureStyleFn;
|
|
66
|
+
/**
|
|
67
|
+
* Extra `L.Map` options: `minZoom`, `maxZoom`, `zoomSnap`, `scrollWheelZoom`, `worldCopyJump`,
|
|
68
|
+
* `maxBoundsViscosity`, … Read once, when the map is created; change them later on the map
|
|
69
|
+
* itself (`onMapReady` / `ref.getMap()`, e.g. `map.setMaxZoom(18)`). Options Element sets itself
|
|
70
|
+
* (`center`, `zoom`, `maxBounds`, `crs`, `renderer`, the zoom / attribution controls, the drag /
|
|
71
|
+
* box / double-click zoom handlers) are left out; use `initialView`, `bounds` and `renderer`.
|
|
72
|
+
*/
|
|
73
|
+
mapOptions?: Omit<MapOptions, OwnedMapOption>;
|
|
74
|
+
/**
|
|
75
|
+
* Called once per map, as soon as Element's layers and panes are on it: the place to add your
|
|
76
|
+
* own layers. If the editor remounts, it is called again with the new map (the old one is
|
|
77
|
+
* removed).
|
|
78
|
+
*/
|
|
79
|
+
onMapReady?: (map: LeafletMap) => void;
|
|
80
|
+
}
|
|
81
|
+
export declare const ElementEditor: React.ForwardRefExoticComponent<ElementEditorProps & React.RefAttributes<ElementEditorRef>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RasterBasemap } from '@element-editor/ui';
|
|
3
|
+
import { FeatureStyleFn } from '@element-editor/adapter-leaflet';
|
|
4
|
+
import { Map as LeafletMap, MapOptions } from 'leaflet';
|
|
5
|
+
import { ElementEditorRef as ShellRef } from '../shell/ElementEditorShell.js';
|
|
6
|
+
import { ElementEditorBaseProps } from '../shell/types.js';
|
|
7
|
+
import { BasemapRefAPI } from '../shell/useBasemapState.js';
|
|
8
|
+
export type { ImportResult } from '../shell/ElementEditorShell.js';
|
|
9
|
+
/** A Leaflet drop-in basemap: a raster entry or `'osm'` (OpenStreetMap). */
|
|
10
|
+
export type LeafletBasemap = RasterBasemap | 'osm';
|
|
11
|
+
/**
|
|
12
|
+
* Imperative handle of the Leaflet `<ElementEditor ref>`; `getMap()` returns the `L.Map`,
|
|
13
|
+
* `getBasemap()` / `setBasemap()` read and switch the basemap.
|
|
14
|
+
*/
|
|
15
|
+
export type ElementEditorRef = ShellRef<LeafletMap> & BasemapRefAPI<LeafletBasemap>;
|
|
16
|
+
/** `L.Map` options Element sets itself; not accepted in `mapOptions`. */
|
|
17
|
+
export type OwnedMapOption = 'center' | 'zoom' | 'maxBounds' | 'zoomControl' | 'attributionControl' | 'crs' | 'renderer' | 'preferCanvas' | 'dragging' | 'boxZoom' | 'doubleClickZoom';
|
|
18
|
+
export interface ElementEditorProps extends ElementEditorBaseProps {
|
|
19
|
+
/**
|
|
20
|
+
* Tile layer to render under the features. Pass any react-leaflet tile
|
|
21
|
+
* component (`<TileLayer />`, `<MapboxTileLayer />`, vector tiles, etc.).
|
|
22
|
+
* If omitted, defaults to OpenStreetMap.
|
|
23
|
+
*
|
|
24
|
+
* Example:
|
|
25
|
+
* tileLayer={<TileLayer url="https://tiles.example.com/{z}/{x}/{y}.png" attribution="..." />}
|
|
26
|
+
*/
|
|
27
|
+
tileLayer?: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Raster basemaps to choose from. The first entry is the default (a single entry is simply
|
|
30
|
+
* used as the basemap); with two or more entries a basemap picker appears and the user's pick
|
|
31
|
+
* is remembered (localStorage `elm_basemap_leaflet`, namespaced by `config.persistKey`). `'osm'` is OpenStreetMap. Off by default
|
|
32
|
+
* (a single OpenStreetMap layer). Entries are told apart by `id`, else by `url`. Ignored when `tileLayer` is set.
|
|
33
|
+
*/
|
|
34
|
+
basemaps?: LeafletBasemap[];
|
|
35
|
+
/**
|
|
36
|
+
* The basemap shown, controlled by your app: an entry of `basemaps` (matched by `id`, else
|
|
37
|
+
* `url`), `'osm'`, or any other raster basemap (the picker then shows none selected). Update it
|
|
38
|
+
* from `onBasemapChange`, or the picker can't change it. Nothing is remembered in localStorage.
|
|
39
|
+
* Leave it out to let Element keep the choice (`defaultBasemap`). Ignored when `tileLayer` is set.
|
|
40
|
+
*/
|
|
41
|
+
basemap?: LeafletBasemap;
|
|
42
|
+
/**
|
|
43
|
+
* Starting basemap when `basemap` isn't set. Default: the first `basemaps` entry. The user's
|
|
44
|
+
* remembered pick wins over it on reload.
|
|
45
|
+
*/
|
|
46
|
+
defaultBasemap?: LeafletBasemap;
|
|
47
|
+
/** Called with the newly chosen basemap (as it appears in `basemaps`) when the user picks one or you call `ref.setBasemap()`. Not called when `basemap` changes. */
|
|
48
|
+
onBasemapChange?: (basemap: LeafletBasemap) => void;
|
|
49
|
+
/**
|
|
50
|
+
* How unselected features are drawn. `'canvas'` (default) paints them on one
|
|
51
|
+
* shared `<canvas>`, which keeps panning and zooming smooth with thousands of
|
|
52
|
+
* features. `'svg'` gives every feature its own `<path>` element. Selected
|
|
53
|
+
* features and editing handles are always SVG.
|
|
54
|
+
*/
|
|
55
|
+
renderer?: 'canvas' | 'svg';
|
|
56
|
+
/**
|
|
57
|
+
* Per-feature style: return a `FeatureStyle` `{ color, fillColor, opacity, fillOpacity, weight }`
|
|
58
|
+
* or any Leaflet `PathOptions` (`dashArray`, …); `fillColor` falls back to `color`; `undefined`/`null`
|
|
59
|
+
* = default look. Applies to polygons, lines and point pins (pins take `fillColor`, then `color`).
|
|
60
|
+
* Wins over `featureColor` per key; the selected / hovered looks win over both. Called on every
|
|
61
|
+
* render of each feature, so keep it fast and stable (module-level or `useCallback`).
|
|
62
|
+
*
|
|
63
|
+
* @example getFeatureStyle={(f) => ({ color: f.properties.status === 'done' ? '#16a34a' : '#00a2f0' })}
|
|
64
|
+
*/
|
|
65
|
+
getFeatureStyle?: FeatureStyleFn;
|
|
66
|
+
/**
|
|
67
|
+
* Extra `L.Map` options: `minZoom`, `maxZoom`, `zoomSnap`, `scrollWheelZoom`, `worldCopyJump`,
|
|
68
|
+
* `maxBoundsViscosity`, … Read once, when the map is created; change them later on the map
|
|
69
|
+
* itself (`onMapReady` / `ref.getMap()`, e.g. `map.setMaxZoom(18)`). Options Element sets itself
|
|
70
|
+
* (`center`, `zoom`, `maxBounds`, `crs`, `renderer`, the zoom / attribution controls, the drag /
|
|
71
|
+
* box / double-click zoom handlers) are left out; use `initialView`, `bounds` and `renderer`.
|
|
72
|
+
*/
|
|
73
|
+
mapOptions?: Omit<MapOptions, OwnedMapOption>;
|
|
74
|
+
/**
|
|
75
|
+
* Called once per map, as soon as Element's layers and panes are on it: the place to add your
|
|
76
|
+
* own layers. If the editor remounts, it is called again with the new map (the old one is
|
|
77
|
+
* removed).
|
|
78
|
+
*/
|
|
79
|
+
onMapReady?: (map: LeafletMap) => void;
|
|
80
|
+
}
|
|
81
|
+
export declare const ElementEditor: React.ForwardRefExoticComponent<ElementEditorProps & React.RefAttributes<ElementEditorRef>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Map as LeafletMap, MapOptions } from 'leaflet';
|
|
3
|
+
import { BoundsInput, FeatureCollectionInput, GeoJSONFeatureInput } from '@element-editor/core';
|
|
4
|
+
import { FeatureRenderer, FeatureStyleFn } from '@element-editor/adapter-leaflet';
|
|
5
|
+
import { InitialView } from '../shell/savedView.cjs';
|
|
6
|
+
/** Creation-time inputs of the map, read once (the entry passes the first values). */
|
|
7
|
+
export interface MapSetup {
|
|
8
|
+
initialView?: InitialView;
|
|
9
|
+
initialData?: FeatureCollectionInput | GeoJSONFeatureInput | null;
|
|
10
|
+
bounds?: BoundsInput;
|
|
11
|
+
/** Already filtered of the keys Element owns. */
|
|
12
|
+
mapOptions?: Partial<MapOptions>;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: import('react').NamedExoticComponent<{
|
|
15
|
+
/** The basemap layer (the drop-in always passes one: `tileLayer` or the chosen raster). */
|
|
16
|
+
tileLayer: ReactNode;
|
|
17
|
+
renderer?: FeatureRenderer;
|
|
18
|
+
getFeatureStyle?: FeatureStyleFn;
|
|
19
|
+
/** Status bar element to move the attribution control into (instead of the compact "i" toggle). */
|
|
20
|
+
attributionTarget?: HTMLElement | null;
|
|
21
|
+
/** Shell element (bottom-right end of the slot row) for the compact attribution; else the map's corner. */
|
|
22
|
+
attributionCorner?: HTMLElement | null;
|
|
23
|
+
/** Start view + extra map options; only the first value is used. */
|
|
24
|
+
setup: MapSetup;
|
|
25
|
+
/** Stable: called once per map once Element's layers are on it. */
|
|
26
|
+
onReady?: (map: LeafletMap) => void;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Map as LeafletMap, MapOptions } from 'leaflet';
|
|
3
|
+
import { BoundsInput, FeatureCollectionInput, GeoJSONFeatureInput } from '@element-editor/core';
|
|
4
|
+
import { FeatureRenderer, FeatureStyleFn } from '@element-editor/adapter-leaflet';
|
|
5
|
+
import { InitialView } from '../shell/savedView.js';
|
|
6
|
+
/** Creation-time inputs of the map, read once (the entry passes the first values). */
|
|
7
|
+
export interface MapSetup {
|
|
8
|
+
initialView?: InitialView;
|
|
9
|
+
initialData?: FeatureCollectionInput | GeoJSONFeatureInput | null;
|
|
10
|
+
bounds?: BoundsInput;
|
|
11
|
+
/** Already filtered of the keys Element owns. */
|
|
12
|
+
mapOptions?: Partial<MapOptions>;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: import('react').NamedExoticComponent<{
|
|
15
|
+
/** The basemap layer (the drop-in always passes one: `tileLayer` or the chosen raster). */
|
|
16
|
+
tileLayer: ReactNode;
|
|
17
|
+
renderer?: FeatureRenderer;
|
|
18
|
+
getFeatureStyle?: FeatureStyleFn;
|
|
19
|
+
/** Status bar element to move the attribution control into (instead of the compact "i" toggle). */
|
|
20
|
+
attributionTarget?: HTMLElement | null;
|
|
21
|
+
/** Shell element (bottom-right end of the slot row) for the compact attribution; else the map's corner. */
|
|
22
|
+
attributionCorner?: HTMLElement | null;
|
|
23
|
+
/** Start view + extra map options; only the first value is used. */
|
|
24
|
+
setup: MapSetup;
|
|
25
|
+
/** Stable: called once per map once Element's layers are on it. */
|
|
26
|
+
onReady?: (map: LeafletMap) => void;
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
package/dist/leaflet.cjs
ADDED
|
@@ -0,0 +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/aMTTqaO9Vj2egZjgYJ4x4Y6rEB7MBWeuhlwI46a+KRtwhZT6NXsdlRSuWZlCmLjdPRfZq3Yqctea7sUM8A58fgpS0UQ0DggJOAktwv1UPV/gqLNTHgMCz5ePo6HKajMMm/sFVxI/kHJQJkpJqy1CZNz9qG3KKsgvfr9UVdf44mX4ekO04A2OwYySfby/6/CIeiv7KOjU0VrKvmxzUJ/vPg87r5LDXZlKyz6+shhFAv5+6hah9OKQMc/Qf7BPb2bGAKW9yVvn9h8l+EiCULvZq+uSs+M7uTO5tAGTGPCFJ7WwYlUnCi5rXQdcZ0lS0/uormwHy100cy2PrbxbiCjygwgLLCdhriDsPaHyETTuVnT8sAceojkrGl+e5xkDScT3xGumuoFczvNUVcvf9bzLoM1r0jUIdp7iL6pmRKpuPTIAN4DEpa6FoMvBS0YzHbVeDVaO5v01o3nhNhS5fRxXVXgH50UONmfYx5JidcQyWvtAA/viEwRq9BTj0tGEuJaKYfFfvKVuoOePbRJP1v6GGHAt6deDm+PUB18PidZT5y55v7/EmzGAy70M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1m/MFrttjKxz+/uJB76MyB9Btknkd9Gf9bx/eKJFIUBMSu/yEZK87VB/2u3fYqEdDMeHUbMLtmzi5IdNDIg2beZoZoiu57TYp8FqBYUYSNPddamvRyUhbdKms/RkFpm07sQVf4erNfkF20b4+pLepuVJDSmGSKQbOMrizT3dOI1qgWyq8HfrKvoc6Xvw7JA2DmbtJWRwm5VwHuOAwBG870zcg4FJ3WFqIXxtH/Wk1ohZror37iMxlNifRzBPJg/sGrw0hvc2t8zSCWu9qiae82PUTz1qb1hfVtFuXw7H3zz+qe7FCsHLIfl40qWoafUEsLZkDpizYyRXIJgnY8sgz0JFUWT/Sqlv945PjHvEJRPSqJNAvqmsIuHr1pZz7yrgeJ6edCJW0OLsawz/cb20vIDJEW1Qv5ZiYoiJdjCQLxrsVz+3OXefeAVzHTjp21fbXuTIq5beXOY80RIW8QwY3a3vBtjVYMqQiwYSXmkVFSNVv1k2vKU06uILk/sMee+ElGhRLb+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;
|