@element-editor/react 0.2.2 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@element-editor/react",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Drop-in React map editor: one component with drawing tools, vertex editing, snapping, a data table and a GeoJSON inspector, on MapLibre GL or Leaflet.",
5
5
  "keywords": [
6
6
  "element-editor",
@@ -85,12 +85,12 @@
85
85
  "dependencies": {
86
86
  "@phosphor-icons/react": "^2.1.10",
87
87
  "sonner": "^2.0.7",
88
- "@element-editor/adapter-maplibre": "0.2.2",
89
- "@element-editor/core": "0.2.2",
90
- "@element-editor/ui": "0.2.2"
88
+ "@element-editor/adapter-maplibre": "0.3.0",
89
+ "@element-editor/core": "0.3.0",
90
+ "@element-editor/ui": "0.3.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@playwright/test": "^1.58.2",
93
+ "@playwright/test": "^1.65.1",
94
94
  "@tailwindcss/vite": "^4.2.1",
95
95
  "@testing-library/dom": "^10.4.1",
96
96
  "@testing-library/jest-dom": "^6.9.1",
@@ -106,7 +106,7 @@
106
106
  "jsdom": "^29.0.0",
107
107
  "leaflet": "^1.9.0",
108
108
  "maplibre-gl": "^6.18.0",
109
- "playwright": "^1.59.1",
109
+ "playwright": "^1.65.1",
110
110
  "react-data-grid": "7.0.0-beta.57",
111
111
  "react-leaflet": "^5.0.0",
112
112
  "tailwindcss": "^4.2.1",
@@ -114,7 +114,7 @@
114
114
  "vite": "^6.0.5",
115
115
  "vite-plugin-dts": "^4.5.4",
116
116
  "vitest": "^4.1.0",
117
- "@element-editor/adapter-leaflet": "0.2.2"
117
+ "@element-editor/adapter-leaflet": "0.3.0"
118
118
  },
119
119
  "peerDependencies": {
120
120
  "leaflet": "^1.9.0",
@@ -122,7 +122,7 @@
122
122
  "react": "^19.2.0",
123
123
  "react-dom": "^19.2.0",
124
124
  "react-leaflet": "^5.0.0",
125
- "@element-editor/adapter-leaflet": "^0.2.2"
125
+ "@element-editor/adapter-leaflet": "^0.3.0"
126
126
  },
127
127
  "peerDependenciesMeta": {
128
128
  "@element-editor/adapter-leaflet": {
@@ -1 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),l=require("react"),n=require("@element-editor/ui"),F=require("@element-editor/ui/internal"),J=require("@element-editor/core"),L=require("@element-editor/core/internal"),U=require("@phosphor-icons/react"),Me="elm_mapView",Te=1,rt={center:[10,48],zoom:5},nt=40,st=16;function Be(o){try{const r=J.readPersisted(Me,Te,e=>{if(!e||typeof e!="object")return null;const s=e;return typeof s.lat=="number"&&typeof s.lng=="number"&&typeof s.zoom=="number"?{lat:s.lat,lng:s.lng,zoom:s.zoom}:null},o);if(r)return{center:[r.lng,r.lat],zoom:r.zoom}}catch{}return null}function at(o,r,e,s){J.writePersisted(Me,Te,{lat:o,lng:r,zoom:e},s)}const Oe=(...o)=>o.every(r=>typeof r=="number"&&Number.isFinite(r));function Le(o){if(!o)return null;try{const r=o,e=r.type==="Feature"?{type:"FeatureCollection",features:[r]}:r;return J.getFeatureCollectionBBox(e)}catch{return null}}function lt(o,r){if(o==="data")return(e=>e?{bounds:e}:null)(Le(r));if(o&&typeof o=="object"){if("bounds"in o){const e=o.bounds;if(Array.isArray(e)&&e.length===4&&Oe(...e))return{bounds:[e[0],e[1],e[2],e[3]]}}else if("center"in o){const e=o.center;if(Array.isArray(e)&&e.length===2&&Oe(e[0],e[1],o.zoom))return{center:[e[0],e[1]],zoom:o.zoom}}}return L.warnOnce("initialView-invalid",`initialView=${JSON.stringify(o)} is not { center: [lng, lat], zoom }, { bounds: [west, south, east, north] } or 'data'; it was ignored.`),null}function it({initialView:o,initialData:r,bounds:e},s){const a=o===void 0?null:lt(o,r);if(a)return a;const i=Be(s);if(i)return i;const m=o==="data"?null:Le(r);if(m)return{bounds:m};const c=L.normalizeBounds(e);return c?{bounds:c}:rt}function ct(o,r,e){if(!o||typeof o!="object")return{};const s={};for(const[a,i]of Object.entries(o))a in r?i!==void 0&&L.warnOnce(`mapOptions-${e}-${a}`,`<ElementEditor mapOptions.${a}> is set by Element and was ignored. ${r[a]}`):s[a]=i;return s}const ut="--elm-row-hover",dt=1500;function ft(o,r){l.useEffect(()=>{if(!L.isDevBuild())return;const e=o.current;if(!e||typeof getComputedStyle!="function")return;const s=r==="leaflet"?"@element-editor/react/leaflet/style.css":"@element-editor/react/style.css",a=requestAnimationFrame(()=>{if(!e.isConnected||e.getClientRects().length===0)return;const{width:m,height:c}=e.getBoundingClientRect();(c===0||m===0)&&L.warnOnce("editor-zero-size",`<ElementEditor> is ${Math.round(m)}×${Math.round(c)} px, so the map is blank. It fills its parent element (width and height 100%): give the parent an explicit size, e.g. <div style={{ height: 600 }}><ElementEditor /></div>, or a flex / grid layout that gives it one (a parent with only \`height: auto\` collapses to 0).`)}),i=setTimeout(()=>{e.isConnected&&getComputedStyle(e).getPropertyValue(ut).trim()===""&&L.warnOnce("editor-css-missing",`Element's stylesheet is not loaded, so the toolbar and panels are unstyled. Import it once, near your app's entry point: import '${s}'`)},dt);return()=>{cancelAnimationFrame(a),clearTimeout(i)}},[o,r])}function mt(o){const r=n.useElementEditorConfig(),{uiStore:e}=n.useGeoStore(),s=n.useUIStore(c=>c.userTheme),a=l.useRef(!1);a.current||(a.current=!0,o===void 0&&r.mode!=="system"&&(J.readStorage("elm_theme",r)||e.setState({userTheme:r.mode}))),l.useLayoutEffect(()=>{o!==void 0&&e.setState({userTheme:o==="auto"?"system":o})},[o,e]);const[i,m]=l.useState(()=>typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches);return l.useEffect(()=>{if(s!=="system")return;const c=window.matchMedia("(prefers-color-scheme: dark)"),x=d=>m(d.matches);return c.addEventListener("change",x),()=>c.removeEventListener("change",x)},[s]),s==="dark"?"dark":s==="light"?"light":i?"dark":"light"}function pt(o,r){const e=l.useRef(null),s=l.useRef(null),a=l.useRef(null),i=l.useRef(null),m=l.useRef(null),c=l.useRef(null),x=l.useRef(null),d=l.useRef(null),f=l.useRef(null),w=l.useRef(null),b=l.useRef(null);return l.useLayoutEffect(()=>{const E=e.current;if(!E||o)return;const k=()=>parseFloat(E.style.getPropertyValue("--elm-panel-offset"))||0,O=u=>u&&u.offsetWidth>0?u.getBoundingClientRect():null,H=u=>u.flatMap(g=>getComputedStyle(g).display==="contents"?H([...g.children]):[g.offsetWidth]),ie=u=>{const g=H([...u.children]).filter(y=>y>0);return g.length?getComputedStyle(u).flexDirection.startsWith("column")?Math.max(...g):g.reduce((y,h)=>y+h,0)+8*(g.length-1):0},X=(u,g,y)=>{var T;if(!u)return!0;const h=(((T=u.parentElement)==null?void 0:T.clientWidth)??0)-32-k(),R=`${Math.max(0,Math.floor(h))}px`;u.style.getPropertyValue("--elm-row-room")!==R&&u.style.setProperty("--elm-row-room",R);const j=[...u.children].reduce((C,V)=>C+ie(V),16)+g>h+.5,S=j&&g?`${g}px`:"";return u.dataset.elmClearance=String(g),u.hasAttribute("data-elm-wrap")===j&&u.style.paddingRight===S?!0:y?!1:(u.toggleAttribute("data-elm-wrap",j),u.style.paddingRight=S,!0)};let D=0;const _=(u=!1)=>{if(!(X(s.current,r,u)&&X(a.current,0,u))){D||(D=requestAnimationFrame(()=>{D=0,_()}));return}const y=O(x.current),h=O(a.current),R=O(i.current),I=O(m.current),j=O(c.current),S=C=>!!(y&&C&&y.left<C.right+8&&C.left<y.right+8);let T=I?I.height+8:0;h&&(S(R)||S(j))&&(T=Math.max(T,h.height+8)),E.style.setProperty("--elm-bottom-row-height",`${T}px`),Y(w.current,"--elm-left-center-shift"),Y(b.current,"--elm-right-center-shift")},Z={},Y=(u,g)=>{const y=Z[g]??0,h=O(u);let R=0;if(h){const I=h.top-y;let j=-1/0,S=1/0;for(const C of[s.current,a.current])for(const V of(C==null?void 0:C.children)??[]){const N=O(V);!N||N.height===0||N.right+8<=h.left||h.right+8<=N.left||(C===s.current?j=Math.max(j,N.bottom+8):S=Math.min(S,N.top-8))}R=(I<j?j:I+h.height>S?Math.max(j,S-h.height):I)-I}R!==y&&(Z[g]=R,E.style.setProperty(g,`${R}px`))},v=new ResizeObserver(()=>_(!0));for(const u of[s,a,i,m,c,x,d,f,w,b])u.current&&v.observe(u.current);for(const u of[s.current,a.current])for(const g of(u==null?void 0:u.children)??[]){v.observe(g);for(const y of g.querySelectorAll(":scope > *, :scope > .contents > *"))v.observe(y)}const Q=u=>{var g,y;(u.target===E||(y=(g=u.target).matches)!=null&&y.call(g,"[data-elm-slot], [data-elm-edge]"))&&_()};E.addEventListener("transitionend",Q);let K=k();const z=new MutationObserver(()=>{k()!==K&&(K=k(),_())});return z.observe(E,{attributes:!0,attributeFilter:["style"]}),_(),()=>{cancelAnimationFrame(D),v.disconnect(),z.disconnect(),E.removeEventListener("transitionend",Q);for(const u of["--elm-bottom-row-height","--elm-left-center-shift","--elm-right-center-shift"])E.style.setProperty(u,"0px")}},[o,r]),{rootRef:e,topRowRef:s,bottomRowRef:a,bottomLeftRef:i,bottomCenterRef:m,bottomRightRef:c,contextualRef:x,leftEdgeRef:d,rightEdgeRef:f,leftCenterRef:w,rightCenterRef:b}}function ht({size:o,tooltipSide:r}){const e=n.useUIStore(c=>c.shortcutsModalOpen),s=n.useUIStore(c=>c.openShortcutsModal),a=n.useUIStore(c=>c.closeShortcutsModal),{getKey:i}=n.useShortcutConfig(),m=i("show-shortcuts").toUpperCase();return t.jsx(n.IconButton,{label:"Show keyboard shortcuts",shortcutId:"show-shortcuts",tooltipContent:"Keyboard shortcuts",shortcut:t.jsx(n.KbdDark,{children:m}),onClick:e?a:s,active:e,size:o,tooltipSide:r,children:t.jsx(U.Keyboard,{size:24})})}function gt({size:o,side:r}){const e=n.useUIStore(i=>i.tableOpen),s=n.useUIStore(i=>i.toggleTable),{getKey:a}=n.useShortcutConfig();return t.jsx(n.IconButton,{size:o,tooltipSide:r,label:e?"Hide table":"Show table",shortcutId:"toggle-table",shortcut:t.jsx(n.KbdDark,{children:a("toggle-table").toUpperCase()}),onClick:s,active:e,children:t.jsx(U.Table,{size:24})})}function xt({size:o,side:r}){const e=n.useUIStore(i=>i.schemaModalOpen),s=n.useUIStore(i=>i.toggleSchemaModal),{getKey:a}=n.useShortcutConfig();return t.jsx(n.IconButton,{size:o,tooltipSide:r,label:"Edit schema",shortcutId:"toggle-schema",shortcut:t.jsx(n.KbdDark,{children:a("toggle-schema").toUpperCase()}),onClick:s,active:e,children:t.jsx(U.TreeStructure,{size:24})})}function bt({size:o,side:r}){const e=n.useUIStore(i=>i.codeModalOpen),s=n.useUIStore(i=>i.toggleCodeModal),{getKey:a}=n.useShortcutConfig();return t.jsx(n.IconButton,{size:o,tooltipSide:r,label:"Show GeoJSON",shortcutId:"toggle-geojson",shortcut:t.jsx(n.KbdDark,{children:a("toggle-geojson").toUpperCase()}),onClick:s,active:e,children:t.jsx(U.Code,{size:24})})}function yt({size:o,side:r}){const e=n.useUIStore(a=>a.settingsModalOpen),s=n.useUIStore(a=>a.setSettingsModalOpen);return t.jsx(n.IconButton,{size:o,tooltipSide:r,label:"Editor settings",onClick:()=>s(!e),active:e,children:t.jsx(U.SlidersHorizontal,{size:24})})}function vt({id:o,size:r,side:e,onSubmit:s,basemapControl:a,attributionRef:i}){switch(o){case"toolbar":return t.jsx(n.FloatingToolbar,{embedded:!0});case"undo":return t.jsx(n.UndoButton,{size:r,tooltipSide:e});case"redo":return t.jsx(n.RedoButton,{size:r,tooltipSide:e});case"fitBounds":return t.jsx(n.FitBoundsButton,{size:r,tooltipSide:e});case"locate":return t.jsx(n.LocateButton,{size:r,tooltipSide:e});case"zoomIndicator":return t.jsx(n.ZoomIndicator,{size:r,tooltipSide:e});case"table":return t.jsx(gt,{size:r,side:e});case"schema":return t.jsx(xt,{size:r,side:e});case"geojson":return t.jsx(bt,{size:r,side:e});case"settings":return t.jsx(yt,{size:r,side:e});case"keyboard":return t.jsx(ht,{size:r,tooltipSide:e});case"applyChanges":return t.jsxs(n.Button,{variant:"primary",onClick:s,className:r==="group"?"h-8 !rounded-elm-control !px-3 gap-1.5 !text-sm":"h-12 !rounded-elm shadow-elm-control !px-5 gap-2 !text-sm",children:[t.jsx(U.Check,{size:20,weight:"bold"}),"Apply changes"]});case"attribution":return t.jsx("span",{ref:i,"data-elm-attribution":"",onMouseEnter:m=>{var c;m.currentTarget.title=((c=m.currentTarget.textContent)==null?void 0:c.trim())??""}});case"basemap":return l.isValidElement(a)?l.cloneElement(a,{size:r,tooltipSide:e}):null;default:return null}}function St(){const o=n.useElementEditorConfig();return t.jsxs("div",{className:"absolute bottom-0 left-0 w-full h-1/3 bg-elm-surface border-t border-elm-border z-[400] flex shadow-[0_-8px_12px_-8px_rgb(0_0_0/0.12)]",children:[o.ui.dataTable&&t.jsx("div",{className:"flex-1 h-full relative overflow-hidden border-r border-elm-border",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.DataTablePanel,{embedded:!0})})}),o.ui.layerList&&t.jsx("div",{className:"w-[320px] flex-shrink-0 h-full relative overflow-hidden bg-elm-surface",children:t.jsx(n.LayersPanel,{})})]})}function jt({layout:o}){const r=n.useElementEditorConfig(),e=n.useUIStore(f=>f.dialogState),s=n.useUIStore(f=>f.schemaModalOpen),a=n.useUIStore(f=>f.toggleSchemaModal),i=n.useUIStore(f=>f.readonly),m=n.useUIStore(f=>f.codeModalOpen),c=n.useUIStore(f=>f.toggleCodeModal),x=n.useUIStore(f=>f.settingsModalOpen),d=n.useUIStore(f=>f.shortcutsModalOpen);return t.jsxs(t.Fragment,{children:[o==="minimal"&&e.type!=="closed"&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.FeatureEditModal,{dialogState:e})}),r.ui.dataTable&&o!=="split"&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.DataTablePanel,{})}),r.ui.keyboardShortcuts.show&&d&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.ShortcutsModal,{})}),r.ui.settings&&x&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.SettingsModal,{})}),r.ui.schemaEditor&&s&&!i&&t.jsx(l.Suspense,{fallback:null,children:t.jsx(n.SchemaModal,{onClose:a})}),r.ui.geojsonEditor&&m&&t.jsx(l.Suspense,{fallback:t.jsx(n.GeoJSONDockPlaceholder,{}),children:t.jsx(n.GeoJSONModal,{onClose:c})})]})}const le=o=>{var r,e,s,a;return!((e=(r=o.dataTransfer)==null?void 0:r.types)!=null&&e.includes("Files"))||!!((a=(s=o.target).closest)!=null&&a.call(s,".cm-editor"))};function Ct(o){const r=F.useGeoJSONFileImport(),[e,s]=l.useState(!1),a=l.useRef(0),i=l.useCallback(d=>{!o||le(d)||(d.preventDefault(),d.stopPropagation(),a.current+=1,s(!0))},[o]),m=l.useCallback(d=>{!o||le(d)||(d.preventDefault(),d.stopPropagation(),d.dataTransfer.dropEffect="copy")},[o]),c=l.useCallback(d=>{!o||le(d)||(d.stopPropagation(),a.current=Math.max(0,a.current-1),a.current===0&&s(!1))},[o]),x=l.useCallback(d=>{var w;if(a.current=0,s(!1),!o||le(d))return;d.preventDefault(),d.stopPropagation();const f=(w=d.dataTransfer.files)==null?void 0:w[0];f&&r(f)},[o,r]);return{active:o&&e,handlers:{onDragEnter:i,onDragOver:m,onDragLeave:c,onDrop:x}}}function wt({enabled:o,children:r,footer:e}){const s=Ct(o);return t.jsxs("div",{style:{display:"contents"},...s.handlers,children:[t.jsxs("div",{className:"relative flex-1 min-h-0 flex",children:[r,s.active&&t.jsx("div",{"data-elm-file-drop":"",className:"absolute inset-0 z-[1000] flex items-center justify-center pointer-events-none bg-gray-900/10 dark:bg-black/30 border-2 border-dashed border-primary-500 rounded-sm",children:t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm rounded-elm text-sm text-(--elm-text-secondary,var(--color-gray-700)) dark:text-(--elm-text-secondary,var(--color-gray-200)) antialiased select-none",children:[t.jsx(U.FileArrowUp,{size:20,className:"text-elm-text-muted"}),t.jsx("span",{children:"Drop GeoJSON to import"})]})})]}),e]})}const ge="in-data-[elm-wrap]:flex-wrap in-data-[elm-wrap]:max-w-full",xe="in-data-[elm-wrap]:flex-wrap-reverse in-data-[elm-wrap]:max-w-full",Et={topLeft:[`flex-row items-start ${ge}`,"flex-col items-start"],topCenter:[`flex-row items-start justify-center ${ge}`,"flex-col items-center"],topRight:[`flex-row-reverse items-start ${ge}`,"flex-col items-end"],leftCenter:["flex-row items-center","flex-col items-start"],rightCenter:["flex-row-reverse items-center","flex-col items-end"],bottomLeft:[`flex-row items-end ${xe}`,"flex-col-reverse items-start"],bottomCenter:[`flex-row items-end justify-center ${xe}`,"flex-col-reverse items-center"],bottomRight:[`flex-row-reverse items-end ${xe}`,"flex-col-reverse items-end"]},Rt=l.forwardRef(({initialData:o,initialView:r,schema:e,tools:s,maxFeatures:a,bounds:i,readonly:m=!1,layout:c="panel",className:x="",style:d,theme:f,onChange:w,onSubmit:b,onValidationError:E,onFeatureSelect:k,onZoomChange:O,onEvent:H,onError:ie,onFeatureAdd:X,onFeatureUpdate:D,onFeatureDelete:_,onSelectionChange:Z,onToolChange:Y,slots:v,renderMap:Q,basemapControl:K,extraApi:z,fileDrop:u=!0,engine:g="maplibre"},y)=>{const h=n.useElementEditorConfig(),{dataStore:R,uiStore:I}=n.useGeoStore(),j=n.useMapController(),S=s||(h.tools==="all"?null:h.tools),[T]=l.useState(()=>r==="data"||r===void 0&&!Be(h)),[C,V]=l.useState(null),N=l.useCallback((p,B)=>{if(!B||!T)return;const M=J.getFeatureCollectionBBox({type:"FeatureCollection",metadata:{schemas:[],groups:[]},features:R.getState().features});M&&V(M)},[T,R]);l.useEffect(()=>{!C||!j.fitBounds||(j.fitBounds(C),V(null))},[C,j]);const ee=n.useAdapterControls({initialData:o,schema:e,layout:c,readonly:m,tools:S,maxFeatures:a,onChange:w,onSubmit:b,onValidationError:E,onFeatureAdd:X,onFeatureUpdate:D,onFeatureDelete:_,onSelectionChange:Z,onFeatureSelect:k,onZoomChange:O,onToolChange:Y,onInitialDataApplied:N}),ce=l.useMemo(()=>z?{...ee,...z}:ee,[ee,z]);l.useImperativeHandle(y,()=>ce,[ce]),l.useEffect(()=>{},[R,I,ce]),l.useLayoutEffect(()=>{I.getState().setBounds(i)},[i,I]);const P=n.useUIStore(p=>p.tableFullscreen),Ae=n.useUIStore(p=>p.sidebarOpen),ue=f!==null&&typeof f=="object";l.useEffect(()=>{ue&&L.warnOnce("theme-object","<ElementEditor theme> takes only 'light' | 'dark' | 'auto'; the object is ignored. Set CSS variables with `style` (e.g. style={{ '--elm-accent': '#7c3aed' }}) or the brand colour with `accentColor`.")},[ue]);const de=mt(ue?void 0:f),Ne={...h.accentColor?{"--elm-accent":h.accentColor}:{},"--elm-bottom-stack-offset":c==="split"?"calc(33.33% + 16px + var(--elm-bottom-row-height, 0px))":"calc(var(--elm-table-offset, 0px) + var(--elm-bottom-row-height, 0px) + 16px)",...d},be=d?Object.entries(d).filter(([p,B])=>p.startsWith("--")&&B!=null&&B!==""):[],fe=be.length?JSON.stringify(be):"",$e=l.useMemo(()=>fe?Object.fromEntries(JSON.parse(fe)):void 0,[fe]),Fe=p=>F.isControlVisible(p,h.ui,{readonly:m,canSubmit:!!b,hasBasemaps:!!K}),te=p=>F.visibleLayoutEntries(h.ui.layout[p].items,Fe),ye=h.ui.keyboardShortcuts.enabled,_e=(S==null?void 0:S.join())??null;l.useEffect(()=>{for(const p of F.layoutGaps(h.ui.layout,{readonly:m,canSubmit:!!b,tools:S,shortcuts:ye}))L.warnOnce(`layoutGap:${p}`,`config.ui.layout: ${p}.`)},[h.ui.layout,m,!!b,_e,ye]);const[ve,Ue]=l.useState(null),[De,ze]=l.useState(null),Se=(p,B,M)=>t.jsx(vt,{id:p,size:B,side:M,onSubmit:ee.submit,basemapControl:K,attributionRef:Ue},p),me=(p,B)=>{const M=p==="statusLeft"||p==="statusRight",G=h.ui.layout[p].direction==="vertical",se=G?p.endsWith("Right")||p==="rightCenter"?"left":"right":p.startsWith("top")?"bottom":"top",W=A=>t.jsx("div",{"aria-hidden":!0,"data-elm-separator":"",className:`flex-shrink-0 bg-elm-border ${M?"w-px h-4 mx-1":G?"h-px w-5 my-0.5":"w-px h-5 mx-1"}`},A);return B.map((A,q)=>{if(A==="separator")return W(`sep-${q}`);if(typeof A=="string")return Se(A,M?"sm":"md",se);const ae=A.group.map((ke,ot)=>ke==="separator"?W(`gsep-${ot}`):Se(ke,M?"sm":"group",se));return M?t.jsx("div",{"data-elm-group":"",className:"flex items-center",children:ae},`group-${q}`):t.jsx(n.ControlGroup,{direction:G?"vertical":"horizontal",children:ae},`group-${q}`)})},je=F.LAYOUT_SLOTS.find(p=>te(p).includes("toolbar")),$=(p,B,M,G,se)=>{const W=te(p),A=v==null?void 0:v[p],[q,ae]=Et[p];return t.jsxs("div",{ref:G,"data-elm-slot":p,style:M,className:`flex ${h.ui.layout[p].direction==="vertical"?ae:q} gap-2 ${W.length||A?"pointer-events-auto":""} ${B}`,children:[se,A,me(p,W)]})},oe=(...p)=>je&&p.includes(je)?"z-[500]":"z-[400]",Ce=c==="panel"&&h.ui.layerList&&!Ae?56:0,re="var(--elm-panel-offset, 0px)",pe=c==="split"?"calc(33.33% + 16px)":"calc(var(--elm-table-offset, 0px) + 16px)",{rootRef:ne,topRowRef:Ve,bottomRowRef:Ke,bottomLeftRef:Ge,bottomCenterRef:We,bottomRightRef:qe,contextualRef:Je,leftEdgeRef:He,rightEdgeRef:Xe,leftCenterRef:Ze,rightCenterRef:Ye}=pt(P,Ce);ft(ne,g);const[Qe,et]=l.useState(null);l.useLayoutEffect(()=>{et(ne.current)},[ne]);const tt=F.useRootTokens(Qe),we=te("statusLeft"),Ee=te("statusRight"),Re=we.length+Ee.length>0,he=Re&&!!ve;return t.jsx(n.ThemeContext.Provider,{value:de,children:t.jsx(F.RootCssVarsContext.Provider,{value:$e,children:t.jsx(F.RootTokensContext.Provider,{value:tt,children:t.jsx(n.EventProvider,{onEvent:H,onError:ie,toaster:!0,children:t.jsx("div",{ref:ne,"data-elm-theme":de,className:`relative w-full h-full overflow-clip bg-(--elm-surface-sunken,var(--color-gray-50)) dark:bg-(--elm-surface-sunken,var(--color-gray-950)) flex flex-col ${x}`,style:Ne,children:t.jsxs(wt,{enabled:u&&!m,footer:Re&&t.jsxs("div",{"data-elm-status-bar":"",role:"toolbar","aria-label":"Status bar",className:"flex-shrink-0 h-7 px-2 flex items-center justify-between gap-1 bg-elm-surface border-t border-elm-border z-[400]",children:[t.jsx("div",{"data-elm-slot":"statusLeft",className:"flex items-center gap-1 min-w-0",children:me("statusLeft",we)}),t.jsx("div",{"data-elm-slot":"statusRight",className:"flex items-center gap-1 min-w-0",children:me("statusRight",Ee)})]}),children:[Q({attributionTarget:he?ve:null,attributionCorner:he?null:De,themeMode:de}),!P&&(v==null?void 0:v.toolbar),!P&&(v==null?void 0:v.mapOverlay)&&t.jsx("div",{className:"absolute inset-0 z-[300] pointer-events-none",children:v.mapOverlay}),!P&&t.jsxs("div",{ref:Ve,"data-elm-edge":"top",style:{top:16,left:16,right:`calc(${re} + 16px)`},className:`absolute ${oe("topLeft","topCenter","topRight")} transition-[right] duration-200 grid grid-cols-[1fr_auto_1fr] items-start gap-2 pointer-events-none data-[elm-wrap]:flex data-[elm-wrap]:flex-wrap`,children:[$("topLeft","justify-self-start"),$("topCenter","justify-self-center mx-auto"),$("topRight","justify-self-end ml-auto transition-[margin] duration-200 in-data-[elm-wrap]:mr-0!",{marginRight:Ce})]}),!P&&t.jsx("div",{ref:He,"data-elm-edge":"left",style:{top:16,bottom:pe,left:16},className:`absolute ${oe("leftCenter")} flex flex-col justify-center pointer-events-none`,children:$("leftCenter","relative",{top:"var(--elm-left-center-shift, 0px)"},Ze)}),!P&&t.jsx("div",{ref:Xe,"data-elm-edge":"right",style:{top:16,bottom:pe,right:`calc(${re} + 16px)`},className:`absolute ${oe("rightCenter")} flex flex-col justify-center pointer-events-none transition-[right] duration-200`,children:$("rightCenter","relative",{top:"var(--elm-right-center-shift, 0px)"},Ye)}),!P&&t.jsxs("div",{ref:Ke,"data-elm-edge":"bottom",style:{bottom:pe,left:16,right:`calc(${re} + 16px)`},className:`absolute ${oe("bottomLeft","bottomCenter","bottomRight")} transition-[right] duration-200 grid grid-cols-[1fr_auto_1fr] items-end gap-2 pointer-events-none data-[elm-wrap]:flex data-[elm-wrap]:flex-wrap-reverse`,children:[$("bottomLeft","justify-self-start",void 0,Ge),$("bottomCenter","justify-self-center mx-auto",void 0,We),$("bottomRight","justify-self-end ml-auto max-w-full",void 0,qe,!he&&t.jsx("div",{ref:ze,"data-elm-attribution-corner":"",className:"pointer-events-auto flex items-end justify-end w-max",style:{maxWidth:"var(--elm-row-room, 100%)"}}))]}),!P&&t.jsx("div",{className:"absolute z-[400] flex justify-center pointer-events-none transition-[right] duration-200",style:{bottom:"var(--elm-bottom-stack-offset)",left:16,right:`calc(${re} + 16px)`},children:t.jsxs("div",{ref:Je,"data-elm-contextual":"",className:"flex flex-wrap justify-center gap-2 max-w-full min-w-0",children:[t.jsx(n.EditingToolbar,{}),t.jsx(n.ActiveDrawingToolbar,{}),t.jsx(n.SimplifyPanel,{}),t.jsx(n.SmoothPanel,{}),t.jsx(n.BufferPanel,{}),t.jsx(n.ReadonlyBanner,{})]})}),!P&&h.ui.layerList&&c==="panel"&&t.jsx(n.LayersPanel,{footer:v==null?void 0:v.panelFooter}),c==="split"&&t.jsx(St,{}),t.jsx(jt,{layout:c})]})})})})})})}),Pe=l.forwardRef((o,r)=>{var f;const{config:e,accentColor:s,featureColor:a,routingApiKey:i,onError:m}=o;i!==void 0&&L.warnOnce("routingApiKey","The `routingApiKey` prop is deprecated: use `config.network.routing.apiKey`.");const c=(f=e==null?void 0:e.network)==null?void 0:f.routing,x=!!i&&c!==!1&&!(c!=null&&c.apiKey),d=l.useMemo(()=>s||a||x?{...e,...s&&{accentColor:s},...a&&{featureColor:a},...x&&{network:{...e==null?void 0:e.network,routing:{...c||{},apiKey:i}}}}:e,[e,s,a,x,c,i]);return t.jsx(n.ElementEditorErrorBoundary,{onError:m,children:t.jsx(n.ElementEditorConfigProvider,{config:d,children:t.jsx(n.GeoStoreProvider,{children:t.jsx(n.ShortcutConfigProvider,{children:t.jsx(n.MapControllerProvider,{children:t.jsx(Rt,{...o,ref:r})})})})})})});Pe.displayName="ElementEditorShell";const kt=5e3,Ot=".leaflet-control-attribution, .elm-attribution-toggle, .maplibregl-ctrl-attrib";function It(o,r,e=!0){const s=l.useRef(r);l.useLayoutEffect(()=>{s.current=r});const a=l.useRef(()=>{});return l.useEffect(()=>{if(!e||!o)return;let i=!1,m;const c=()=>{i=!0,clearTimeout(m),document.removeEventListener("visibilitychange",w);for(const b of Ie)o.removeEventListener(b,d,!0)},x=()=>{i||(c(),s.current())},d=b=>{b.target instanceof Element&&b.target.closest(Ot)||x()},f=()=>{m||(m=setTimeout(x,kt))};function w(){document.visibilityState==="visible"&&f()}for(const b of Ie)o.addEventListener(b,d,{capture:!0,passive:!0});return document.visibilityState==="hidden"?document.addEventListener("visibilitychange",w):f(),a.current=c,()=>{c(),a.current=()=>{}}},[o,e]),l.useCallback(()=>a.current(),[])}const Ie=["pointerdown","wheel","keydown"];function Mt(o,r,e,s,a){const i=o!==void 0;i&&a&&!e&&L.warnOnce("basemap-controlled","<ElementEditor basemap> is controlled: the picker can't change it without `onBasemapChange`. Pass `onBasemapChange` (and update `basemap` in it), or use `defaultBasemap` for a starting basemap the user can change.");const[m,c]=l.useState(()=>o!==void 0?o:r()),x=i?o:m,d=l.useRef({current:x,controlled:i,onChange:e,remember:s});d.current={current:x,controlled:i,onChange:e,remember:s};const f=l.useCallback((b,E)=>{var O;const k=d.current;k.controlled||(c(b),E&&k.remember(b)),(O=k.onChange)==null||O.call(k,b)},[]),w=l.useMemo(()=>({getBasemap:()=>d.current.current,setBasemap:b=>f(b,!1)}),[f]);return{current:x,pick:f,api:w}}exports.ElementEditorShell=Pe;exports.FIT_MAX_ZOOM=st;exports.FIT_PADDING=nt;exports.pickMapOptions=ct;exports.resolveInitialView=it;exports.saveView=at;exports.useAttributionAutoCollapse=It;exports.useBasemapState=Mt;