@element-editor/ui 0.0.0-stage → 0.2.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 +65 -0
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/dist/BooleanOperations-BRO7NHUY.js +111 -0
- package/dist/BooleanOperations-C2uOHRu3.cjs +1 -0
- package/dist/DataTable-B-2VjBEz.cjs +2 -0
- package/dist/DataTable-CS-3dIqY.js +510 -0
- package/dist/DataTablePanel-58LwzXQR.cjs +1 -0
- package/dist/DataTablePanel-DDFUmMaM.js +208 -0
- package/dist/EditToolbarBtn-Ch9HCLHq.cjs +3 -0
- package/dist/EditToolbarBtn-SR4xHd8G.js +378 -0
- package/dist/FeatureEditModal-Cc8N6vei.cjs +1 -0
- package/dist/FeatureEditModal-Dr10p3nE.js +77 -0
- package/dist/FeatureList-Bo9w9nre.js +520 -0
- package/dist/FeatureList-VRYesXCq.cjs +1 -0
- package/dist/FeatureRowContextMenu-CtBqdC1j.cjs +1 -0
- package/dist/FeatureRowContextMenu-DCUIiDwc.js +130 -0
- package/dist/GeoJSONModal-BV9Tamf4.js +886 -0
- package/dist/GeoJSONModal-Dd-nBufy.cjs +9 -0
- package/dist/SchemaEditor-B4L17K1e.cjs +1 -0
- package/dist/SchemaEditor-ryoTgaLb.js +293 -0
- package/dist/SchemaModal-DvMbWskS.js +95 -0
- package/dist/SchemaModal-gAuDkd-L.cjs +1 -0
- package/dist/SettingsModal-BScVTjpn.js +237 -0
- package/dist/SettingsModal-CqaSFxxR.cjs +1 -0
- package/dist/ShortcutsModal-D1Y2bGT8.cjs +1 -0
- package/dist/ShortcutsModal-ozuS2Ysb.js +299 -0
- package/dist/components/ActiveDrawingToolbar.d.cts +1 -0
- package/dist/components/ActiveDrawingToolbar.d.ts +1 -0
- package/dist/components/BasemapPicker.d.cts +26 -0
- package/dist/components/BasemapPicker.d.ts +26 -0
- package/dist/components/BooleanOperations.d.cts +1 -0
- package/dist/components/BooleanOperations.d.ts +1 -0
- package/dist/components/BufferPanel.d.cts +1 -0
- package/dist/components/BufferPanel.d.ts +1 -0
- package/dist/components/DataTable.d.cts +9 -0
- package/dist/components/DataTable.d.ts +9 -0
- package/dist/components/DataTablePanel.d.cts +10 -0
- package/dist/components/DataTablePanel.d.ts +10 -0
- package/dist/components/EditingToolbar.d.cts +1 -0
- package/dist/components/EditingToolbar.d.ts +1 -0
- package/dist/components/ElementEditorErrorBoundary.d.cts +28 -0
- package/dist/components/ElementEditorErrorBoundary.d.ts +28 -0
- package/dist/components/ElementEditorUIProvider.d.cts +50 -0
- package/dist/components/ElementEditorUIProvider.d.ts +50 -0
- package/dist/components/FeatureMapContextMenu.d.cts +23 -0
- package/dist/components/FeatureMapContextMenu.d.ts +23 -0
- package/dist/components/FitBoundsButton.d.cts +6 -0
- package/dist/components/FitBoundsButton.d.ts +6 -0
- package/dist/components/FloatingToolbar.d.cts +3 -0
- package/dist/components/FloatingToolbar.d.ts +3 -0
- package/dist/components/LocateButton.d.cts +11 -0
- package/dist/components/LocateButton.d.ts +11 -0
- package/dist/components/ReadonlyBanner.d.cts +1 -0
- package/dist/components/ReadonlyBanner.d.ts +1 -0
- package/dist/components/ShortcutsModal.d.cts +1 -0
- package/dist/components/ShortcutsModal.d.ts +1 -0
- package/dist/components/SimplifyPanel.d.cts +1 -0
- package/dist/components/SimplifyPanel.d.ts +1 -0
- package/dist/components/SmoothPanel.d.cts +1 -0
- package/dist/components/SmoothPanel.d.ts +1 -0
- package/dist/components/UndoRedoToolbar.d.cts +20 -0
- package/dist/components/UndoRedoToolbar.d.ts +20 -0
- package/dist/components/VertexSelectionBar.d.cts +12 -0
- package/dist/components/VertexSelectionBar.d.ts +12 -0
- package/dist/components/ZoomIndicator.d.cts +15 -0
- package/dist/components/ZoomIndicator.d.ts +15 -0
- package/dist/components/dialogs/DynamicFieldRenderer.d.cts +11 -0
- package/dist/components/dialogs/DynamicFieldRenderer.d.ts +11 -0
- package/dist/components/dialogs/SettingsModal.d.cts +1 -0
- package/dist/components/dialogs/SettingsModal.d.ts +1 -0
- package/dist/components/lazyParts.d.cts +12 -0
- package/dist/components/lazyParts.d.ts +12 -0
- package/dist/components/sidebar/FeatureEditModal.d.cts +6 -0
- package/dist/components/sidebar/FeatureEditModal.d.ts +6 -0
- package/dist/components/sidebar/FeatureList.d.cts +4 -0
- package/dist/components/sidebar/FeatureList.d.ts +4 -0
- package/dist/components/sidebar/FeatureRow.d.cts +38 -0
- package/dist/components/sidebar/FeatureRow.d.ts +38 -0
- package/dist/components/sidebar/FeatureRowContextMenu.d.cts +12 -0
- package/dist/components/sidebar/FeatureRowContextMenu.d.ts +12 -0
- package/dist/components/sidebar/FeatureSidePanel.d.cts +8 -0
- package/dist/components/sidebar/FeatureSidePanel.d.ts +8 -0
- package/dist/components/sidebar/GeoJSONModal.d.cts +5 -0
- package/dist/components/sidebar/GeoJSONModal.d.ts +5 -0
- package/dist/components/sidebar/GroupRow.d.cts +21 -0
- package/dist/components/sidebar/GroupRow.d.ts +21 -0
- package/dist/components/sidebar/HideLayersToggle.d.cts +2 -0
- package/dist/components/sidebar/HideLayersToggle.d.ts +2 -0
- package/dist/components/sidebar/LayersPanel.d.cts +5 -0
- package/dist/components/sidebar/LayersPanel.d.ts +5 -0
- package/dist/components/sidebar/PartSubRow.d.cts +9 -0
- package/dist/components/sidebar/PartSubRow.d.ts +9 -0
- package/dist/components/sidebar/SchemaEditor.d.cts +4 -0
- package/dist/components/sidebar/SchemaEditor.d.ts +4 -0
- package/dist/components/sidebar/SchemaModal.d.cts +5 -0
- package/dist/components/sidebar/SchemaModal.d.ts +5 -0
- package/dist/components/sidebar/codeDock.d.cts +21 -0
- package/dist/components/sidebar/codeDock.d.ts +21 -0
- package/dist/components/ui/Button.d.cts +9 -0
- package/dist/components/ui/Button.d.ts +9 -0
- package/dist/components/ui/CloseButton.d.cts +6 -0
- package/dist/components/ui/CloseButton.d.ts +6 -0
- package/dist/components/ui/ContextMenu.d.cts +28 -0
- package/dist/components/ui/ContextMenu.d.ts +28 -0
- package/dist/components/ui/EditToolbarBtn.d.cts +13 -0
- package/dist/components/ui/EditToolbarBtn.d.ts +13 -0
- package/dist/components/ui/ElementToaster.d.cts +3 -0
- package/dist/components/ui/ElementToaster.d.ts +3 -0
- package/dist/components/ui/GeometryTypeIcon.d.cts +7 -0
- package/dist/components/ui/GeometryTypeIcon.d.ts +7 -0
- package/dist/components/ui/IconButton.d.cts +28 -0
- package/dist/components/ui/IconButton.d.ts +28 -0
- package/dist/components/ui/Input.d.cts +14 -0
- package/dist/components/ui/Input.d.ts +14 -0
- package/dist/components/ui/JsonCode.d.cts +4 -0
- package/dist/components/ui/JsonCode.d.ts +4 -0
- package/dist/components/ui/Kbd.d.cts +16 -0
- package/dist/components/ui/Kbd.d.ts +16 -0
- package/dist/components/ui/NoFeaturesEmptyState.d.cts +1 -0
- package/dist/components/ui/NoFeaturesEmptyState.d.ts +1 -0
- package/dist/components/ui/SearchDropdown.d.cts +28 -0
- package/dist/components/ui/SearchDropdown.d.ts +28 -0
- package/dist/components/ui/ToolButton.d.cts +19 -0
- package/dist/components/ui/ToolButton.d.ts +19 -0
- package/dist/components/ui/Tooltip.d.cts +12 -0
- package/dist/components/ui/Tooltip.d.ts +12 -0
- package/dist/components/ui/panelHeader.d.cts +2 -0
- package/dist/components/ui/panelHeader.d.ts +2 -0
- package/dist/components/ui/resizeEdge.d.cts +4 -0
- package/dist/components/ui/resizeEdge.d.ts +4 -0
- package/dist/contexts/ElementEditorConfigContext.d.cts +351 -0
- package/dist/contexts/ElementEditorConfigContext.d.ts +351 -0
- package/dist/contexts/EventContext.d.cts +69 -0
- package/dist/contexts/EventContext.d.ts +69 -0
- package/dist/contexts/MapControllerContext.d.cts +24 -0
- package/dist/contexts/MapControllerContext.d.ts +24 -0
- package/dist/contexts/ShortcutConfigContext.d.cts +16 -0
- package/dist/contexts/ShortcutConfigContext.d.ts +16 -0
- package/dist/contexts/ThemeContext.d.cts +12 -0
- package/dist/contexts/ThemeContext.d.ts +12 -0
- package/dist/element-editor-ui.cjs +1 -0
- package/dist/element-editor-ui.es.js +102 -0
- package/dist/geometryWorker-CCwg4tNC.cjs +1 -0
- package/dist/geometryWorker-DgQCFSmD.js +25 -0
- package/dist/hooks/dragShield.d.cts +7 -0
- package/dist/hooks/dragShield.d.ts +7 -0
- package/dist/hooks/themeInputs.d.cts +14 -0
- package/dist/hooks/themeInputs.d.ts +14 -0
- package/dist/hooks/useAccentPalette.d.cts +15 -0
- package/dist/hooks/useAccentPalette.d.ts +15 -0
- package/dist/hooks/useAccentStyle.d.cts +39 -0
- package/dist/hooks/useAccentStyle.d.ts +39 -0
- package/dist/hooks/useAdapterControls.d.cts +280 -0
- package/dist/hooks/useAdapterControls.d.ts +280 -0
- package/dist/hooks/useBalancedWrap.d.cts +8 -0
- package/dist/hooks/useBalancedWrap.d.ts +8 -0
- package/dist/hooks/useContextMenu.d.cts +11 -0
- package/dist/hooks/useContextMenu.d.ts +11 -0
- package/dist/hooks/useDataChangeSubscription.d.cts +9 -0
- package/dist/hooks/useDataChangeSubscription.d.ts +9 -0
- package/dist/hooks/useDragWindow.d.cts +9 -0
- package/dist/hooks/useDragWindow.d.ts +9 -0
- package/dist/hooks/useFocusTrap.d.cts +7 -0
- package/dist/hooks/useFocusTrap.d.ts +7 -0
- package/dist/hooks/useGeoJSONDrop.d.cts +40 -0
- package/dist/hooks/useGeoJSONDrop.d.ts +40 -0
- package/dist/hooks/useGeoJSONExport.d.cts +69 -0
- package/dist/hooks/useGeoJSONExport.d.ts +69 -0
- package/dist/hooks/useGeoJSONFileImport.d.cts +24 -0
- package/dist/hooks/useGeoJSONFileImport.d.ts +24 -0
- package/dist/hooks/useInlineRename.d.cts +26 -0
- package/dist/hooks/useInlineRename.d.ts +26 -0
- package/dist/hooks/useJumpToFeature.d.cts +3 -0
- package/dist/hooks/useJumpToFeature.d.ts +3 -0
- package/dist/hooks/useKeyboardShortcuts.d.cts +9 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +9 -0
- package/dist/hooks/useNominatim.d.cts +24 -0
- package/dist/hooks/useNominatim.d.ts +24 -0
- package/dist/hooks/usePanelOffset.d.cts +14 -0
- package/dist/hooks/usePanelOffset.d.ts +14 -0
- package/dist/hooks/useResizablePanel.d.cts +4 -0
- package/dist/hooks/useResizablePanel.d.ts +4 -0
- package/dist/hooks/useRootTokens.d.cts +27 -0
- package/dist/hooks/useRootTokens.d.ts +27 -0
- package/dist/hooks/useSearchState.d.cts +23 -0
- package/dist/hooks/useSearchState.d.ts +23 -0
- package/dist/hooks/useServiceAttribution.d.cts +13 -0
- package/dist/hooks/useServiceAttribution.d.ts +13 -0
- package/dist/hooks/useWindowEscape.d.cts +25 -0
- package/dist/hooks/useWindowEscape.d.ts +25 -0
- package/dist/hooks/useWindowFocus.d.cts +4 -0
- package/dist/hooks/useWindowFocus.d.ts +4 -0
- package/dist/hooks/useWorkerGeometryPreview.d.cts +22 -0
- package/dist/hooks/useWorkerGeometryPreview.d.ts +22 -0
- package/dist/index-CILw1Du5.js +3165 -0
- package/dist/index-DG4wEjGj.cjs +1 -0
- package/dist/index.d.cts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/internal.cjs +1 -0
- package/dist/internal.d.cts +16 -0
- package/dist/internal.d.ts +16 -0
- package/dist/internal.es.js +42 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.cts +19 -0
- package/dist/primitives.d.ts +19 -0
- package/dist/primitives.es.js +17 -0
- package/dist/store/StoreContext.d.cts +17 -0
- package/dist/store/StoreContext.d.ts +17 -0
- package/dist/types/events.d.cts +95 -0
- package/dist/types/events.d.ts +95 -0
- package/dist/useAccentStyle-CPo2XqAn.js +412 -0
- package/dist/useAccentStyle-hsGvyHZc.cjs +1 -0
- package/dist/useAdapterControls-BBObhzVX.cjs +1 -0
- package/dist/useAdapterControls-DVjkwRZ_.js +691 -0
- package/dist/useContextMenu-DJ2Cti85.js +10 -0
- package/dist/useContextMenu-DbxMvb1s.cjs +1 -0
- package/dist/useFocusTrap-BBjPCfDR.cjs +1 -0
- package/dist/useFocusTrap-CKxKT8De.js +25 -0
- package/dist/useJumpToFeature-Bdz2hqOC.js +16 -0
- package/dist/useJumpToFeature-LwjxGzfy.cjs +1 -0
- package/dist/useWindowFocus-DuQVjnHE.js +80 -0
- package/dist/useWindowFocus-EemgNOuz.cjs +1 -0
- package/dist/utils/booleanValue.d.cts +4 -0
- package/dist/utils/booleanValue.d.ts +4 -0
- package/dist/utils/clipboardError.d.cts +3 -0
- package/dist/utils/clipboardError.d.ts +3 -0
- package/dist/utils/download.d.cts +42 -0
- package/dist/utils/download.d.ts +42 -0
- package/dist/utils/geojsonDocument.d.cts +168 -0
- package/dist/utils/geojsonDocument.d.ts +168 -0
- package/dist/utils/geometryWorkerClient.d.cts +6 -0
- package/dist/utils/geometryWorkerClient.d.ts +6 -0
- package/dist/utils/layerOrder.d.cts +9 -0
- package/dist/utils/layerOrder.d.ts +9 -0
- package/dist/utils/lazyWithPreload.d.cts +24 -0
- package/dist/utils/lazyWithPreload.d.ts +24 -0
- package/dist/utils/lineSmooth.d.cts +7 -0
- package/dist/utils/lineSmooth.d.ts +7 -0
- package/dist/utils/platform.d.cts +2 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/workers/geometryWorker.d.cts +1 -0
- package/dist/workers/geometryWorker.d.ts +1 -0
- package/package.json +133 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var Jt=Object.defineProperty;var Wt=(e,n,t)=>n in e?Jt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var ot=(e,n,t)=>Wt(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),k=require("react"),oe=require("./useAdapterControls-BBObhzVX.cjs"),ee=require("./index-DG4wEjGj.cjs"),Je=require("./useAccentStyle-hsGvyHZc.cjs"),We=require("@element-editor/core"),zt=require("react-dom"),le=require("@phosphor-icons/react"),Fe=require("./useWindowFocus-EemgNOuz.cjs"),te=require("@codemirror/view"),D=require("@codemirror/state"),Ht=require("@codemirror/lang-json"),Bt=require("@codemirror/theme-one-dark"),Gt=require("codemirror"),rt=require("@codemirror/lint"),Ut=require("./useFocusTrap-BBjPCfDR.cjs"),Vt=require("./useJumpToFeature-LwjxGzfy.cjs"),we=require("./EditToolbarBtn-Ch9HCLHq.cjs");function $t(e){const{_validation:n,...t}=e,o=JSON.stringify(t,null,2).split(`
|
|
2
|
+
`);for(let r=0;r<o.length;r++)o[r]=" "+o[r];return o}function Le(e,n,t){const o=JSON.stringify({type:"FeatureCollection",metadata:{schemas:e,groups:n},features:[]},null,2);return(t?o:o.slice(0,-3)).split(`
|
|
3
|
+
`)}const Ct=[" ]","}"];function je(e,n,t=[]){for(let o=0;o<e.length;o++){const r=n(e[o]);for(let s=0;s<r.length;s++)t.push(r[s]);o<e.length-1&&(t[t.length-1]+=",")}return t}function st(e,n,t,o){const r=Le(n,t,e.length===0),s={features:e,counts:e.map(h=>o(h).length),headerLines:r.length,schemas:n,groups:t};if(!e.length)return{text:D.Text.of(r),map:s};const l=je(e,o,r);return l.push(...Ct),{text:D.Text.of(l),map:s}}function*Yt(e,n,t,o){if(yield Le(n,t,e.length===0),!!e.length){for(let r=0;r<e.length;r++){const s=o(e[r]);if(r===e.length-1){yield s;break}const l=s.slice();l[l.length-1]+=",",yield l}yield Ct}}function Kt(e,n,t,o){return{features:e,counts:e.map(r=>o(r).length),headerLines:Le(n,t,e.length===0).length,schemas:n,groups:t}}const Xt=(e,n)=>e===n||e.length===n.length&&e.every((t,o)=>t===n[o]);function pe(e){const n=new Array(e.counts.length);let t=e.headerLines+1;for(let o=0;o<e.counts.length;o++)n[o]=t,t+=e.counts[o];return n}function Zt(e,n){let t=e.headerLines+1;for(let o=0;o<e.counts.length;o++){if(n<t)return-1;if(n<t+e.counts[o])return o;t+=e.counts[o]}return-1}function Qt(e,n,t,o,r,s){const l=n.features;if(!l.length||!t.length)return null;const h=pe(n),v=c=>c===l.length-1,j=c=>e.line(h[c]).from,i=c=>e.line(h[c]+n.counts[c]-1).to-(v(c)?0:1),p=[];let T=n.headerLines;if(o!==n.schemas||r!==n.groups){const c=Le(o,r,!1);p.push({from:0,to:e.line(n.headerLines).to,insert:D.Text.of(c)}),T=c.length}let S=0;const B=Math.min(l.length,t.length);for(;S<B&&l[S]===t[S];)S++;let A=0;for(;A<B-S&&l[l.length-1-A]===t[t.length-1-A];)A++;const m=l.length-A,I=t.length-A,J=n.counts.slice(0,S);if(m-S===I-S)for(let c=S;c<m;c++){if(l[c]===t[c]||Xt(s(l[c]),s(t[c]))){J.push(n.counts[c]);continue}p.push({from:j(c),to:i(c),insert:D.Text.of(s(t[c]))}),J.push(s(t[c]).length)}else{const c=t.slice(S,I);for(const b of c)J.push(s(b).length);if(m>S&&c.length)p.push({from:j(S),to:i(m-1),insert:D.Text.of(je(c,s))});else if(m>S)S>0?p.push({from:i(S-1),to:i(m-1)}):p.push({from:j(0),to:j(m)});else{const b=je(c,s);S>0?p.push({from:i(S-1),insert:D.Text.of([",",...b])}):(b[b.length-1]+=",",b.push(""),p.push({from:j(0),insert:D.Text.of(b)}))}}for(let c=m;c<l.length;c++)J.push(n.counts[c]);return{changes:p,map:{features:t,counts:J,headerLines:T,schemas:o,groups:r}}}const en=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon","GeometryCollection"],kt=e=>{const n=e;return!n||typeof n!="object"||!en.includes(n.type)?!1:n.type==="GeometryCollection"?Array.isArray(n.geometries)&&n.geometries.every(kt):Array.isArray(n.coordinates)};function Ce(e){return!!e&&typeof e=="object"&&e.type==="Feature"&&kt(e.geometry)}function ct(e){return!e||typeof e!="object"||Array.isArray(e)?'Expected a feature: { "type": "Feature", … }':e.type!=="Feature"?'A feature needs "type": "Feature"':'A feature needs a geometry with a valid "type" and "coordinates"'}function it(e){const n=e.length;let t=0;const o=(i,p=t)=>{throw new lt(p,i)},r=()=>{for(;t<n;t++){const i=e.charCodeAt(t);if(i!==32&&i!==10&&i!==13&&i!==9)break}},s=/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y,l='"\\/bfnrt',h=()=>{const i=t++;for(;;){t>=n&&o("Missing a closing quote",i);const p=e.charCodeAt(t);if(p===34){t++;return}if(p===92){const T=e[t+1];T==="u"&&/^[0-9a-fA-F]{4}$/.test(e.slice(t+2,t+6))?t+=6:T!==void 0&&l.includes(T)?t+=2:o("Invalid escape in a string (a backslash must be doubled)")}else p<32?o(p===10?"Missing a closing quote":"Control character in a string",p===10?i:t):t++}},v=(i,p)=>{t++;for(let T=0;;T++){r();let S=0;for(;e[t]===",";)t++,S++,r();if(t>=n&&o(`Missing a closing ${i}`),e[t]===i){t++;return}T&&!S&&o(`Expected a comma or a closing ${i}`),p()}},j=()=>{r();const i=e[t];if(i===void 0)o("Expected a value, the text ends here");else if(i==="{")v("}",()=>{e[t]!=='"'&&o("Expected a property name in double quotes"),h(),r(),e[t]!==":"&&o("Expected a colon after the property name"),t++,j()});else if(i==="[")v("]",j);else if(i==='"')h();else if(i==="-"||i>="0"&&i<="9"){s.lastIndex=t;const p=s.exec(e);p||o("Invalid number"),t+=p[0].length}else{const p=["true","false","null"].find(T=>e.startsWith(T,t));p||o("Expected a value (text needs double quotes)"),t+=p.length}};try{if(!e.trim())return null;for(j(),r();e[t]===",";)t++,r();return t<n&&o("Unexpected text after the end"),null}catch(i){return i instanceof lt?{pos:i.pos,message:i.message}:null}}class lt{constructor(n,t){this.pos=n,this.message=t}}function tn(e,n,t,o){const r=n.features.length;if(!r)return{kind:"full"};const s=pe(n),l=c=>e.line(s[c]).from,h=c=>e.line(s[c]+n.counts[c]-1).to,v=c=>h(c)-(c===r-1?0:1),j=c=>{const b=e.lineAt(c).number;let w=0,L=r-1;for(;w<L;){const g=w+L+1>>1;s[g]<=b?w=g:L=g-1}return w},i=[];let p=!1;if(t.iterChangedRanges((c,b)=>{if(p)return;if(c<l(0)||b>h(r-1)){p=!0;return}let w=j(c),L=Math.max(w,j(b));c>v(w)&&(L===w?L=w+1:w++),b>v(L)&&L<r-1&&L++;const g=i[i.length-1];g&&w<=g[1]?g[1]=Math.max(g[1],L):i.push([w,L])}),p||!i.length)return{kind:"full"};const T=n.features.slice(),S=n.counts.slice(),B=[];let A=!1,m=null;for(let c=i.length-1;c>=0;c--){const[b,w]=i[c],L=t.mapPos(l(b),-1),g=t.mapPos(v(w),1),R=ze("["+o.sliceString(L,g)+"]");if(!Array.isArray(R)||!R.every(Ce)){m={from:L,to:g};continue}m||(T.splice(b,w-b+1,...R),R.length===1?S.splice(b,w-b+1,o.lineAt(g).number-o.lineAt(L).number+1):R.length?A=!0:S.splice(b,w-b+1),B[c]=R.length)}if(m)return{kind:"invalid",...m};const I=[];let J=0;return i.forEach(([c,b],w)=>{const L=c+J;for(let g=L-1;g<=L+B[w];g++)I.push(g);J+=B[w]-(b-c+1)}),{kind:"ok",features:T,counts:A?null:S,around:I,runs:i.map(([c,b],w)=>({i:c,j:b,length:B[w]}))}}function Et(e,n,t=0){if(e===n)return null;const o=Math.min(e.length,n.length);let r=0;for(;r<o&&e.charCodeAt(r)===n.charCodeAt(r);)r++;let s=0;for(;s<o-r&&e.charCodeAt(e.length-1-s)===n.charCodeAt(n.length-1-s);)s++;return{from:t+r,to:t+e.length-s,insert:n.slice(r,n.length-s)}}function nn(e,n,t,o,r,s,l){const h=n.features.length,v=pe(n),j=m=>e.line(v[m]).from,i=m=>e.line(v[m]+n.counts[m]-1).to,p=[];let T=0;for(const m of r){const I=p[p.length-1];I&&m.i===I.j+1?(I.j=m.j,I.length+=m.length):p.push({...m,at:m.i+T}),T+=m.length-(m.j-m.i+1)}const S=[],B=[];let A=0;for(const{i:m,j:I,at:J,length:c}of p){for(;A<m;A++)B.push(n.counts[A]);A=I+1;const b=s.slice(J,J+c);for(const P of b)B.push(l(P).length);const w=m>0,L=I<h-1,g=t.mapPos(w?i(m-1)-1:j(0)-1,-1),R=t.mapPos(L?j(I+1):i(h-1)+1,1),ae=c?(w?",":"")+`
|
|
4
|
+
`+je(b,l).join(`
|
|
5
|
+
`)+(L?",":"")+`
|
|
6
|
+
`:(w&&L?",":"")+`
|
|
7
|
+
`,ue=Et(o.sliceString(g,R),ae,g);ue&&S.push(ue)}for(;A<h;A++)B.push(n.counts[A]);return{changes:S,counts:B}}function on(e,n,t,o){const r=t.length;if(!r)return null;const s=pe({headerLines:n,counts:t}),l=[];for(const h of o){if(h<0||h>=r)continue;const v=s[h],j=v+t[h]-1;if(j+1>e.lines||e.line(v).text!==" {")return null;const i=e.line(j);if(h<r-1){if(i.text!==" },")return null;continue}if(e.line(j+1).text!==" ]")return null;if(i.text===" },")l.push({from:i.to-1,to:i.to+1,insert:`
|
|
8
|
+
`});else if(i.text!==" }")return null}return l}function rn(e,n){const t=[];e.iterChangedRanges((r,s)=>{t.push([r,s])});let o=!1;return n.iterChangedRanges((r,s)=>{o||(o=t.some(([l,h])=>l<=s&&r<=h))}),o}function Ie(e,n,t=1){let o=0,r=t,s=-1,l=-1;for(const h=e.iterLines(t);!h.next().done;r++){const v=h.value;if(v===" {"){if(s!==-1)return{start:s,end:r-1};o++===n&&(s=r)}else s!==-1&&l===-1&&(v===" }"||v===" },")&&(l=r)}return s===-1?null:{start:s,end:l===-1?s:l}}function ze(e){if(!e.trim())return{type:"FeatureCollection",features:[]};try{return JSON.parse(e)}catch{}const n=[];let t=0,o=!1,r="";for(let s=0;s<e.length;s++){const l=e[s];if(o){l==="\\"?s++:l==='"'&&(o=!1);continue}if(l==='"'){o=!0,r=l;continue}if(!(l===" "||l===`
|
|
9
|
+
`||l==="\r"||l===" ")){if(l===","){let h=s+1;for(;h<e.length&&/\s/.test(e[h]);)h++;const v=e[h];if(r==="["||r==="{"||r===","||v==="]"||v==="}"||v===","||v===void 0){n.push(e.slice(t,s)),t=s+1;continue}}r=l}}n.push(e.slice(t));try{return JSON.parse(n.join(""))}catch{return null}}const at="elm_code_win_size",ut=100,ft=2e6,sn={syntax:e=>`Invalid JSON at line ${e}`,feature:e=>`Invalid feature at line ${e}`,collection:()=>"Not a GeoJSON FeatureCollection"},Pe=new WeakMap;function dt(e,n,t){n=Math.max(0,Math.min(n,e.length));const o=e.lineAt(n);let r=n;for(;r<o.to&&(r===n||!/[\s,:{}[\]]/.test(o.text[r-o.from]));)r++;return{kind:"syntax",from:n,to:r,message:t}}function _e(e,n,t,o){const r=e.line(Math.max(1,Math.min(n,e.lines)));return{kind:t,from:r.from+(r.text.length-r.text.trimStart().length),to:r.to,message:o}}const He=D.StateEffect.define(),cn=te.Decoration.line({class:"cm-feature-highlight"}),ke=D.StateField.define({create:()=>null,update(e,n){for(const t of n.effects)if(t.is(He))return t.value;return e&&n.docChanged?{from:n.changes.mapPos(e.from,1),to:n.changes.mapPos(e.to,-1)}:e}});function ht(e){const n=e.state.field(ke);if(!n)return te.Decoration.none;const t=e.state.doc,o=new D.RangeSetBuilder;let r=0;for(const{from:s,to:l}of e.visibleRanges){const h=Math.min(l,n.to);for(let v=Math.max(s,n.from,r);v<=h;){const j=t.lineAt(v);o.add(j.from,j.from,cn),v=r=j.to+1}}return o.finish()}const ln=[ke,te.ViewPlugin.fromClass(class{constructor(e){ot(this,"decorations");this.decorations=ht(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.field(ke)!==e.state.field(ke))&&(this.decorations=ht(e.view))}},{decorations:e=>e.decorations})],Ee=D.Annotation.define(),he=[Ee.of(!0),D.Transaction.addToHistory.of(!1)],qe=5e3,mt=12,an=200,gt=2e4;function Mt(e,n){if(!e)return 1;if(e.type==="GeometryCollection")return e.geometries.reduce((o,r)=>o+Mt(r,n),0);const t=o=>{if(!Array.isArray(o)||typeof o[0]=="number")return 1;let r=0;for(const s of o)if(r+=t(s),r>n)break;return r};return t(e.coordinates)}const Me=()=>{const e=globalThis.scheduler;return e!=null&&e.yield?e.yield():new Promise(n=>setTimeout(n,0))};async function pt(e,n){const o=[];for(let r=0;r<e.length;r+=1048576)o.push(e.sliceString(r,Math.min(e.length,r+1048576))),o.length%4===0&&await Me();return new Blob(o,{type:n})}const un=te.EditorView.theme({"&":{height:"100%",fontSize:"14px"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--elm-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)",lineHeight:"1.65",overflow:"auto"}}),bt=D.Prec.highest(te.EditorView.theme({"&":{backgroundColor:"transparent",color:"var(--elm-text, #262626)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--elm-text-subtle, #a3a3a3)",borderRight:"1px solid var(--elm-border, #e5e5e5)"},".cm-activeLine":{backgroundColor:"rgb(0 0 0 / 0.03)"},".cm-activeLineGutter":{backgroundColor:"rgb(0 0 0 / 0.04)",color:"var(--elm-text-secondary, #525252)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--elm-text, #262626)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--elm-border, #e5e5e5)"},".cm-selectionMatch":{backgroundColor:"rgb(0 0 0 / 0.06)"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"rgb(0 0 0 / 0.1)",outline:"none"},".cm-searchMatch":{backgroundColor:"rgb(0 0 0 / 0.08)",outline:"1px solid rgb(0 0 0 / 0.15)"},".cm-foldPlaceholder":{backgroundColor:"var(--elm-surface-hover, #f5f5f5)",border:"1px solid var(--elm-border, #e5e5e5)",color:"var(--elm-text-muted, #737373)"},".cm-tooltip, .cm-panels":{backgroundColor:"var(--elm-surface-raised, #ffffff)",border:"1px solid var(--elm-border, #e5e5e5)"},".cm-feature-highlight":{backgroundColor:"rgb(0 0 0 / 0.05)"}})),xt=[Bt.oneDark,D.Prec.highest(te.EditorView.theme({"&":{backgroundColor:"transparent",color:"var(--elm-text, #e5e5e5)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--elm-text-subtle, #737373)",borderRight:"1px solid var(--elm-border, #404040)"},".cm-activeLine":{backgroundColor:"rgb(255 255 255 / 0.04)"},".cm-activeLineGutter":{backgroundColor:"rgb(255 255 255 / 0.06)",color:"var(--elm-text-secondary, #d4d4d4)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--elm-text, #e5e5e5)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--elm-border, #404040)"},".cm-selectionMatch":{backgroundColor:"rgb(255 255 255 / 0.1)"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"rgb(255 255 255 / 0.15)",outline:"none"},".cm-searchMatch":{backgroundColor:"rgb(255 255 255 / 0.12)",outline:"1px solid rgb(255 255 255 / 0.2)"},".cm-foldPlaceholder":{backgroundColor:"var(--elm-surface-raised, #262626)",border:"1px solid var(--elm-border, #404040)",color:"var(--elm-text-muted, #a3a3a3)"},".cm-tooltip, .cm-panels":{backgroundColor:"var(--elm-surface-raised, #262626)",border:"1px solid var(--elm-border, #404040)"},".cm-feature-highlight":{backgroundColor:"rgb(255 255 255 / 0.07)"}},{dark:!0}))],yt=320,vt=240,wt=520,St=480,Se=`flex ${ee.panelHeaderIconBtn}`;function fn({onClose:e}){const{uiStore:n}=oe.useGeoStore(),t=Je.useElementEditorConfig(),[o,r]=k.useState(ee.useInitialCodeDocked()),[s,l]=k.useState(()=>!oe.inspectorOpenedOnLoad.has(n)),h=()=>{r(!o),l(!0),We.writeStorage(ee.CODE_DOCKED_KEY,o?"0":"1",t)};return x.jsx(dn,{onClose:e,autoFocus:s,docked:o,onToggleDock:h},String(o))}function dn({onClose:e,autoFocus:n,docked:t,onToggleDock:o}){var Xe;const r=(Xe=k.useContext(oe.EventContext))==null?void 0:Xe.emit,{pos:s,onHandleMouseDown:l}=Fe.useDragWindow("elm_code_win",{x:100,y:100}),h=Je.useElementEditorConfig(),{zIndex:v,focus:j}=Fe.useWindowFocus(),{dataStore:i,uiStore:p}=oe.useGeoStore(),T=oe.useDataStore(a=>a.features),S=oe.useDataStore(a=>a.schemas),B=oe.useDataStore(a=>a.groups),A=oe.useDataStore(a=>a.selectedIds),m=oe.useTheme(),I=Je.useAccentStyle(),J=ee.useCodeDock(t),c=k.useRef(null),b=k.useRef(null),w=k.useRef(new D.Compartment),L=k.useRef(new D.Compartment),g=k.useRef(null),R=k.useRef(null),ae=k.useRef(null),ue=k.useRef(()=>{}),P=k.useRef(null),Be=k.useRef(m),me=k.useRef(null),Ge=k.useRef(null),Ne=k.useRef(null),Ue=Vt.useJumpToFeature(),Ve=k.useRef(Ue);Ve.current=Ue;const[se,jt]=k.useState(!0),[Lt,Nt]=k.useState(0),[Te,$e]=k.useState(!1),[be,Tt]=k.useState(null),[xe,Rt]=k.useState(()=>{try{const a=We.readStorage(at,h);return a?JSON.parse(a):{w:wt,h:St}}catch{return{w:wt,h:St}}}),Dt=k.useCallback((a,E)=>{We.writeStorage(at,JSON.stringify({w:a,h:E}),h)},[h]);k.useEffect(()=>{Be.current=m},[m]),ee.usePanelOffset(me,t),ee.useWindowEscape(me,!0,e,v,{topWindow:!t});function Ot(a){a.preventDefault(),a.stopPropagation();const E=a.clientX,$=a.clientY,O=xe.w,Z=xe.h,Y=ee.startDragShield("se-resize");function G(K){const _=Math.max(yt,Math.min(window.innerWidth*.9,O+K.clientX-E)),ne=Math.max(vt,Math.min(window.innerHeight*.85,Z+K.clientY-$));Rt({w:_,h:ne})}function U(){Y(),document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",U);const K=me.current;K&&Dt(K.offsetWidth,K.offsetHeight)}document.addEventListener("mousemove",G),document.addEventListener("mouseup",U)}k.useEffect(()=>{if(!c.current)return;let a=!1,E=!1,$=!0,O=!1,Z=null,Y=null;const G=new WeakMap,U=u=>{let d=G.get(u);return d||(d=$t(u),G.set(u,d)),d};let K=0;function _(u){E||!u&&!Z||(Z=u,N.dispatch(rt.setDiagnostics(N.state,u?[{from:u.from,to:u.to,severity:"error",message:u.message}]:[])),Tt(u&&{kind:u.kind,line:N.state.doc.lineAt(u.from).number}))}function ne(){O=!1,Y=null,_(null)}function ye(u,d){const f=N.state.doc,C="["+f.sliceString(u,d)+"]",y=it(C),M=y?null:ze(C);if(!Array.isArray(M))return dt(f,u+(y?y.pos-1:0),(y==null?void 0:y.message)??"Invalid JSON");const z=Math.max(0,M.findIndex(V=>!Ce(V))),q=Ie(f,z,f.lineAt(u).number);return _e(f,q?q.start:f.lineAt(u).number,"feature",ct(M[z]))}function Pt(u,d){const f=N.state.doc;if(!d){const M=it(u);return dt(f,M?M.pos:0,(M==null?void 0:M.message)??"Invalid JSON")}if(d.type!=="FeatureCollection"||!Array.isArray(d.features))return _e(f,1,"collection",'Expected { "type": "FeatureCollection", "features": [ … ] }');const C=d.features.findIndex(M=>!Ce(M)),y=Ie(f,C);return _e(f,y?y.start:1,"feature",ct(d.features[C]))}function ge(u=!1){const d=g.current,f=R.current,C=i.getState(),y=C.features;if(d&&d.features!==y)return;let M=null;if(d&&f){const H=tn(f.base,d,f.changes,N.state.doc);if(H.kind==="ok"&&H.features.length){const Oe=H.counts&&on(N.state.doc,d.headerLines,H.counts,H.around);C.updateFeaturesFromEditor({type:"FeatureCollection",features:H.features});const de=i.getState().features;if(de===y){_(null);return}if(ne(),R.current=null,ae.current=de,Oe)Oe.length&&N.dispatch({changes:Oe,annotations:Ee.of(!0)}),g.current={...d,features:de,counts:H.counts};else{const Ae=nn(f.base,d,f.changes,N.state.doc,H.runs,de,U);Ae.changes.length&&N.dispatch({changes:Ae.changes,annotations:he}),g.current={...d,features:de,counts:Ae.counts}}Ze(de);return}if(H.kind==="invalid"&&(M=H,N.state.doc.length>ft)){_(ye(H.from,H.to));return}}const z=N.state.doc,q=z.length>ft&&!u?z.length/1e4-(performance.now()-K):0;if(q>0){P.current=setTimeout(ge,q);return}const V=z.toString(),F=ze(V);if((F==null?void 0:F.type)!=="FeatureCollection"||!Array.isArray(F.features)||!F.features.every(Ce)){_(M?ye(M.from,M.to):Pt(V,F));return}C.updateFeaturesFromEditor(F);const re=i.getState().features;if(re===y){_(null);return}ne(),R.current=null,ae.current=re;const{schemas:ce,groups:Q}=i.getState(),{text:X,map:ie}=st(re,ce,Q,U);if(X.eq(z))g.current=ie;else if(JSON.stringify(F.metadata)===JSON.stringify({schemas:ce,groups:Q})){const H=Et(V,X.toString());H&&N.dispatch({changes:H,annotations:he}),g.current=ie}else g.current=null;Ze(re)}function Ze(u){const d=p.getState(),f=d.dialogState;f.type==="edit"&&!u.some(C=>C.id===f.featureId)&&d.closeDialog()}const Re=i.getState();let W=Pe.get(i)??null;Pe.delete(i),W&&!W.map&&!(W.store.features===Re.features&&W.store.schemas===Re.schemas&&W.store.groups===Re.groups)&&(W=null);const N=new te.EditorView({state:D.EditorState.create({doc:W?W.doc:"",extensions:[Gt.basicSetup,Ht.json(),ln,L.current.of(D.EditorState.readOnly.of(!0)),w.current.of(Be.current==="dark"?xt:bt),un,te.EditorView.updateListener.of(u=>{if(u.selectionSet&&!u.docChanged&&u.transactions.some(f=>f.isUserEvent("select.pointer"))){const f=u.state.selection.main,C=g.current;if(f.empty&&C&&!R.current){const y=C.features[Zt(C,u.state.doc.lineAt(f.head).number)],{selectedIds:M,selectFeature:z}=i.getState();y&&!(M.length===1&&M[0]===y.id)&&(Ne.current=y.id,z(y.id),Ve.current(y))}}let d=!1;for(const f of u.transactions){if(!f.docChanged||f.annotation(Ee)||(d=!0,!g.current))continue;const C=R.current;R.current=C?{base:C.base,changes:C.changes.compose(f.changes)}:{base:f.startState.doc,changes:f.changes}}d&&(O=!0,K=performance.now(),u.transactions.some(f=>f.docChanged&&f.annotation(Ee))&&(g.current=null,R.current=null),P.current&&clearTimeout(P.current),P.current=setTimeout(ge,ut))})]}),parent:c.current});let Qe=!0;const et=()=>{const u=Qe||p.getState().readonly;u!==$&&($=u,N.dispatch({effects:L.current.reconfigure(D.EditorState.readOnly.of(u))}))},tt=u=>{Qe=u,et()},_t=p.subscribe((u,d)=>{u.readonly!==d.readonly&&et()});async function qt(u,d,f){P.current&&clearTimeout(P.current),R.current=null,g.current=null,O=!1,_(null);let C=0,y=[];const M=async()=>{for(let q=0;q<y.length;q+=gt){const V=y.slice(q,q+gt),F=N.state.doc;if(N.dispatch({changes:C++?{from:F.length,insert:D.Text.of(["",...V])}:{from:0,to:F.length,insert:D.Text.of(V)},annotations:he}),await Me(),a)return!1}return y=[],!0};let z=performance.now();for(const q of Yt(u,d,f,U)){for(const V of q)y.push(V);if(C<2?!C||y.length>an:performance.now()-z>mt){if(!await M())return!1;z=performance.now()}}return await M()?(g.current=Kt(u,d,f,U),!0):!1}let ve=!1,De=!1;async function nt(){if(ve){De=!0;return}ve=!0;let u=!1;try{do{De=!1;const{features:d,schemas:f,groups:C}=i.getState(),y=g.current,M=y??Y;if(M&&M.features===d&&M.schemas===f&&M.groups===C)continue;Y=null;const z=d.filter(X=>!G.has(X));let q=0;for(const X of z)if(q+=Mt(X.geometry,qe),q>qe)break;const V=!y||!y.features.length||!d.length;if(q>qe){if(u=!0,tt(!0),V){if(!await qt(d,f,C))return;continue}if(await Me(),a)return;let X=performance.now();for(const ie of z)if(U(ie),performance.now()-X>mt){if(await Me(),a)return;X=performance.now()}}const F=R.current,re=F?F.base:N.state.doc,ce=y&&!V?Qt(re,y,d,f,C,U):null,Q=ce&&D.ChangeSet.of(ce.changes,re.length);if(Q&&!F)N.dispatch({changes:Q,annotations:he}),g.current=ce.map;else if(Q&&F&&!rn(Q,F.changes))N.dispatch({changes:Q.map(F.changes),annotations:he}),R.current={base:Q.apply(re),changes:F.changes.map(Q,!0)},g.current=ce.map,P.current&&clearTimeout(P.current),P.current=setTimeout(ge,ut);else{P.current&&clearTimeout(P.current),R.current=null;const{text:X,map:ie}=st(d,f,C,U);N.dispatch({changes:{from:0,to:N.state.doc.length,insert:X},annotations:he}),g.current=ie,O=!1,_(null)}}while(De)}finally{ve=!1,a||(tt(!1),jt(!1),u&&Nt(d=>d+1))}}return b.current=N,g.current=W?W.map:null,R.current=W?W.edit:null,W&&(O=!0,Y=W.map?null:W.store,P.current=setTimeout(ge,0)),ue.current=()=>{nt()},n&&N.focus(),nt(),()=>{if(_t(),ue.current=()=>{},E=!0,P.current&&clearTimeout(P.current),O&&!ve&&ge(!0),a=!0,O){const{features:u,schemas:d,groups:f}=i.getState();Pe.set(i,{doc:N.state.doc,map:g.current,edit:R.current,store:{features:u,schemas:d,groups:f}})}N.destroy(),b.current=null}},[]),k.useEffect(()=>{if(T===ae.current){ae.current=null;return}ue.current()},[T,S,B]),k.useEffect(()=>{const a=b.current,E=m==="dark"?xt:bt;!a||w.current.get(a.state)===E||a.dispatch({effects:w.current.reconfigure(E)})},[m]),k.useEffect(()=>{const a=b.current;if(!a||se)return;const E=A[0]??null,$=E!==Ge.current;Ge.current=E;const O=Ne.current===E;if(Ne.current=null,E===null){a.dispatch({effects:He.of(null)});return}const Z=a.state.doc,Y=R.current?null:g.current;let G;if(Y){const _=Y.features.findIndex(ye=>ye.id===E);if(_===-1)return;const ne=pe(Y)[_];G={start:ne,end:ne+Y.counts[_]-1}}else{const _=T.findIndex(ne=>ne.id===E);if(_===-1)return;G=Ie(Z,_)}if(!G||G.start>Z.lines)return;const U=Z.line(G.start).from,K=$&&!O?[te.EditorView.scrollIntoView(U,{y:"center"})]:[];a.dispatch({effects:[He.of({from:U,to:Z.line(Math.min(G.end,Z.lines)).to}),...K]})},[A,T,se,Lt]),Ut.useFocusTrap(me,!t);function At(){const a=b.current;if(!a)return;const E=a.state.doc;Promise.resolve().then(()=>typeof ClipboardItem<"u"?navigator.clipboard.write([new ClipboardItem({"text/plain":pt(E,"text/plain")})]):navigator.clipboard.writeText(E.toString())).then(()=>{$e(!0),setTimeout(()=>$e(!1),2e3)},O=>r==null?void 0:r(ee.clipboardErrorEvent(O)))}function Ft(){const a=b.current;if(!a)return;let E=-1;rt.forEachDiagnostic(a.state,($,O)=>{E<0&&(E=O)}),!(E<0)&&(a.dispatch({selection:{anchor:E},effects:te.EditorView.scrollIntoView(E,{y:"center"})}),a.focus())}async function It(){const a=b.current;if(!a)return;const E=await pt(a.state.doc,"application/geo+json"),$=URL.createObjectURL(E),O=document.createElement("a");O.href=$,O.download="features.geojson",document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL($)}const Ye=T.length,fe=16,Ke=x.jsxs("div",{ref:me,onMouseDownCapture:t?void 0:j,role:t?"region":"dialog","aria-label":"GeoJSON inspector",[ee.WINDOW_ATTR]:"","aria-busy":se||void 0,"data-loading":se||void 0,"data-elm-code-docked":t||void 0,className:t?J.className:"fixed flex flex-col bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm-raised rounded-elm-window overflow-hidden",style:t?J.style:{left:s.x,top:s.y,zIndex:v,minWidth:yt,minHeight:vt,width:xe.w,height:xe.h,maxWidth:"90vw",maxHeight:"85vh"},children:[t&&x.jsx("div",{onMouseDown:J.onHandleMouseDown,className:ee.resizeEdgeLeft,title:"Drag to resize panel"}),x.jsxs("div",{onMouseDown:t?void 0:l,className:`flex items-center justify-between border-b border-elm-border flex-shrink-0 select-none ${t?"px-3 py-1.5 bg-elm-surface-sunken":"px-4 py-3"}`,style:t?void 0:{cursor:"grab"},children:[x.jsx("span",{className:t?"text-xs font-medium text-elm-text-secondary":"text-sm font-semibold text-(--elm-text,var(--color-gray-900)) dark:text-(--elm-text,var(--color-gray-100))",children:"GeoJSON"}),x.jsxs("div",{className:`flex items-center gap-0.5 ${t?"h-6":""}`,children:[x.jsxs("span",{className:"text-xs text-elm-text-subtle mr-1.5",children:[Ye," feature",Ye!==1?"s":""]}),x.jsx(we.Tooltip,{content:Te?"Copied":"Copy",side:"bottom",children:x.jsx("button",{onMouseDown:a=>a.stopPropagation(),onClick:At,disabled:se,"aria-label":Te?"Copied":"Copy",className:Se,children:Te?x.jsx(le.Check,{size:fe,className:"text-green-500"}):x.jsx(le.Copy,{size:fe})})}),x.jsx(we.Tooltip,{content:"Download",side:"bottom",children:x.jsx("button",{onMouseDown:a=>a.stopPropagation(),onClick:It,disabled:se,"aria-label":"Download GeoJSON",className:Se,children:x.jsx(le.DownloadSimple,{size:fe})})}),x.jsx(we.Tooltip,{content:t?"Undock":"Dock to the side",side:"bottom",children:x.jsx("button",{onMouseDown:a=>a.stopPropagation(),onClick:o,"aria-label":t?"Undock GeoJSON inspector":"Dock GeoJSON inspector",className:Se,children:t?x.jsx(le.ArrowSquareOut,{size:fe}):x.jsx(le.SidebarSimple,{size:fe,className:"-scale-x-100"})})}),t?x.jsx(we.Tooltip,{content:"Close",side:"bottom",children:x.jsx("button",{onClick:e,"aria-label":"Close",className:Se,children:x.jsx(le.X,{size:fe})})}):x.jsx(Fe.CloseButton,{onClick:e})]})]}),x.jsxs("div",{className:"relative flex-1 flex flex-col min-h-0",children:[x.jsx("div",{ref:c,className:"flex-1 overflow-hidden min-h-0"}),se&&x.jsx("div",{className:"absolute bottom-2 right-4 text-xs text-elm-text-subtle pointer-events-none",children:"Loading…"})]}),x.jsx("div",{role:"status","aria-live":"polite",className:"flex-shrink-0",children:be&&x.jsxs("button",{type:"button",onClick:Ft,title:"Go to the error","data-elm-inspector-problem":be.kind,className:`flex w-full items-center gap-1.5 border-t border-elm-border py-1.5 text-left text-xs text-(--elm-text-secondary,var(--color-gray-600)) dark:text-(--elm-text-secondary,var(--color-gray-300)) hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,color-mix(in_oklab,var(--color-gray-800)_60%,transparent)) ${t?"px-3":"pl-4 pr-6"}`,children:[x.jsx(le.WarningCircle,{size:14,className:"flex-shrink-0 text-elm-text-muted"}),x.jsxs("span",{className:"min-w-0 truncate",children:[sn[be.kind](be.line)," — no changes apply until it's fixed"]})]})}),!t&&x.jsx("div",{onMouseDown:Ot,className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize select-none",style:{zIndex:10},"aria-hidden":!0,children:x.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"absolute bottom-1 right-1 text-elm-text-disabled",children:x.jsx("path",{d:"M9 1L1 9M9 5L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]});return t?Ke:zt.createPortal(x.jsx("div",{"data-elm-theme":m,style:I,children:Ke}),document.body)}exports.default=fn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react"),B=require("clsx"),b=require("@phosphor-icons/react"),v=require("./useAdapterControls-BBObhzVX.cjs"),K=require("zustand/react/shallow"),S=require("@element-editor/core/internal"),h=require("./EditToolbarBtn-Ch9HCLHq.cjs");function M({field:l,existingKeys:o,onUpdate:i,onDelete:k,isProtected:d}){const[u,g]=c.useState(!1),[n,j]=c.useState(""),[x,p]=c.useState(l.label);c.useEffect(()=>p(l.label),[l.label]);function y(){if(x===l.label)return;const t=d?l.key:S.uniqueKey(x,o);i({label:x,key:t})}function w(){const t=n.trim();if(!t)return;const a=l.options??[];a.includes(t)||(i({options:[...a,t]}),j(""))}function N(t){i({options:(l.options??[]).filter(a=>a!==t)})}return r.jsxs("div",{className:"bg-elm-surface-raised border border-elm-border rounded-elm-card p-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-xs text-elm-text-subtle",children:["key: ",r.jsx("code",{className:"font-elm-mono text-elm-text-muted",children:l.key})]}),r.jsx(h.Tooltip,{content:d?"Required field — cannot be removed":"Remove field",children:r.jsx("button",{onClick:k,disabled:d,className:"flex-shrink-0 text-elm-text disabled:opacity-25 disabled:cursor-not-allowed transition-colors p-1 rounded-elm-chip hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700))","aria-label":d?"Cannot remove required field":"Remove field",children:r.jsx(b.X,{size:14})})})]}),r.jsx(h.Input,{value:x,onChange:t=>p(t.target.value),onBlur:y,onKeyDown:t=>t.key==="Enter"&&t.target.blur(),placeholder:"Field label",className:"w-full text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))"}),r.jsx(h.SelectInput,{value:l.type,onChange:t=>{const a=t.target.value;i({type:a,options:a==="select"?l.options??[]:void 0}),g(a==="select")},className:"w-full text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))",children:S.FIELD_TYPES.map(t=>r.jsx("option",{value:t.value,children:t.label},t.value))}),r.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-elm-text-muted cursor-pointer select-none w-fit",children:[r.jsx("input",{type:"checkbox",checked:l.required,onChange:t=>i({required:t.target.checked}),className:"elm-checkbox"}),"Required"]}),l.type==="number"&&r.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-(--elm-border-subtle,var(--color-gray-100)) dark:border-(--elm-border-subtle,var(--color-gray-700))",children:[r.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-elm-text-muted w-1/2",children:["Min",r.jsx(h.Input,{type:"number",value:l.min??"",onChange:t=>i({min:t.target.value?parseFloat(t.target.value):void 0}),className:"flex-1 w-full min-w-0",placeholder:"Any"})]}),r.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-elm-text-muted w-1/2",children:["Max",r.jsx(h.Input,{type:"number",value:l.max??"",onChange:t=>i({max:t.target.value?parseFloat(t.target.value):void 0}),className:"flex-1 w-full min-w-0",placeholder:"Any"})]})]}),l.type==="select"&&r.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-(--elm-border-subtle,var(--color-gray-100)) dark:border-(--elm-border-subtle,var(--color-gray-700))",children:[r.jsxs("button",{onClick:()=>g(t=>!t),className:"text-xs text-primary-500 hover:text-primary-700 hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) rounded-elm-chip px-1 -mx-1 py-0.5 flex items-center gap-1 transition-colors",children:[u?r.jsx(b.CaretUp,{size:11}):r.jsx(b.CaretDown,{size:11}),u?"Hide options":`Options (${(l.options??[]).length})`]}),u&&r.jsxs("div",{className:"space-y-1",children:[(l.options??[]).map(t=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"flex-1 text-xs text-elm-text-secondary bg-(--elm-surface-sunken,var(--color-gray-50)) dark:bg-(--elm-surface-sunken,var(--color-gray-700)) border border-(--elm-border,var(--color-gray-200)) dark:border-(--elm-border,var(--color-gray-600)) rounded-elm-chip px-2 py-1 truncate",children:t}),r.jsx("button",{onClick:()=>N(t),className:"text-elm-text hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) transition-colors p-0.5 rounded-elm-chip","aria-label":`Remove "${t}" option`,children:r.jsx(b.X,{size:12})})]},t)),r.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[r.jsx(h.Input,{value:n,onChange:t=>j(t.target.value),onKeyDown:t=>t.key==="Enter"&&w(),placeholder:"New option…",className:"flex-1 min-w-0 text-xs text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))"}),r.jsx(h.Button,{variant:"secondary",size:"sm",onClick:w,children:"Add"})]})]})]})]})}const z=c.forwardRef(function({schema:o,onRename:i},k){const[d,u]=c.useState(o.name);c.useEffect(()=>u(o.name),[o.name]);function g(){const n=d.trim();if(!n){u(o.name);return}n!==o.name&&i(n)}return r.jsx("input",{ref:k,type:"text",value:d,onChange:n=>u(n.target.value),onBlur:g,onKeyDown:n=>n.key==="Enter"&&n.target.blur(),className:"w-full text-sm font-semibold text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) bg-transparent border-b border-transparent hover:border-(--elm-border-strong,var(--color-gray-300)) dark:hover:border-(--elm-border-strong,var(--color-gray-600)) focus:border-primary-400 focus:outline-none px-0 py-0 leading-snug"})});function O({containerRef:l}){var C,q,D;const o=v.useDataStore(K.useShallow(e=>e.getVisibleSchemas())),i=v.useDataStore(e=>e.addSchema),k=v.useDataStore(e=>e.updateSchema),d=v.useDataStore(e=>e.deleteSchema),u=v.useDataStore(e=>e.addSchemaField),g=v.useDataStore(e=>e.updateSchemaField),n=v.useDataStore(e=>e.removeSchemaField),[j,x]=c.useState(((C=o[0])==null?void 0:C.id)??null),[p,y]=c.useState(null),w=c.useRef(new Map),N=c.useRef(null),t=c.useRef(null),a=o.find(e=>e.id===j)??o[0]??null;c.useEffect(()=>{if(!a||t.current!==a.id)return;t.current=null;const e=N.current;e&&(e.focus(),e.select())},[a==null?void 0:a.id]);function F(e){const m=new Set(e.fields.map(f=>f.key)),s=S.uniqueKey("field",m);u(e.id,{key:s,label:"",type:"text",required:!1})}function I(){const e=i("New schema",[{key:S.uniqueKey("field",new Set),label:"",type:"text",required:!1}]);t.current=e,x(e)}function A(e,m){var f;e.preventDefault();const s=((f=l==null?void 0:l.current)==null?void 0:f.getBoundingClientRect())??{left:0,top:0};y({schemaId:m,offsetX:e.clientX-s.left,offsetY:e.clientY-s.top})}function E(e){var s;if(o.length<=1)return;d(e);const m=o.filter(f=>f.id!==e);x(((s=m[0])==null?void 0:s.id)??null),y(null)}return r.jsxs("div",{className:"flex h-full min-h-0",onClick:()=>y(null),children:[r.jsx("div",{className:"w-44 flex-shrink-0 flex flex-col border-r border-elm-border min-h-0",children:r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 py-1",children:[o.map(e=>{const m=((a==null?void 0:a.id)??j)===e.id;return r.jsx("button",{ref:s=>{s?w.current.set(e.id,s):w.current.delete(e.id)},onClick:()=>x(e.id),onContextMenu:s=>A(s,e.id),className:B.clsx("w-full text-left px-3 py-2 text-sm transition-colors flex items-center gap-1.5",m?"bg-primary-50 dark:bg-white/10 hover:bg-primary-100 dark:hover:bg-white/15 text-primary-700 dark:text-primary-300 font-medium border-r-2 border-primary-500":"text-elm-text-muted hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-800)) hover:text-(--elm-text,var(--color-gray-800)) dark:hover:text-(--elm-text,var(--color-gray-200)) border-r-2 border-transparent"),children:r.jsx("span",{className:"flex-1 truncate leading-snug",children:e.name})},e.id)}),r.jsxs("button",{onClick:I,className:"w-full flex items-center gap-1.5 px-3 py-2 text-xs text-elm-text-subtle hover:text-(--elm-text-secondary,var(--color-gray-700)) dark:hover:text-(--elm-text-secondary,var(--color-gray-200)) hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-800)) transition-colors border-r-2 border-transparent",children:[r.jsx(b.Plus,{size:11}),"Add schema"]})]})}),a?r.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 bg-(--elm-surface-sunken,color-mix(in_oklab,var(--color-gray-50)_60%,transparent)) dark:bg-(--elm-surface-sunken,color-mix(in_oklab,var(--color-gray-800)_30%,transparent))",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-elm-border-subtle flex-shrink-0",children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx(z,{ref:N,schema:a,onRename:e=>k(a.id,{name:e})},a.id)}),r.jsxs("button",{onClick:()=>F(a),className:"flex-shrink-0 flex items-center gap-1 text-xs text-elm-text-subtle hover:text-primary-500 dark:hover:text-primary-400 transition-colors px-1.5 py-1 rounded-elm-chip hover:bg-primary-50 dark:hover:bg-white/5",children:[r.jsx(b.Plus,{size:11}),"Add field"]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-3 space-y-2",children:a.fields.map(e=>{const m=new Set(a.fields.map(s=>s.key).filter(s=>s!==e.key));return r.jsx(M,{field:e,existingKeys:m,onUpdate:s=>g(a.id,e.key,s),onDelete:()=>n(a.id,e.key),isProtected:e.key==="name"},e.key)})})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-elm-text-disabled",children:"Select a schema"}),p&&r.jsx(h.ContextMenu,{x:(((q=l==null?void 0:l.current)==null?void 0:q.getBoundingClientRect().left)??0)+p.offsetX,y:(((D=l==null?void 0:l.current)==null?void 0:D.getBoundingClientRect().top)??0)+p.offsetY,onClose:()=>y(null),items:[{label:o.length<=1?"Cannot delete last":"Delete schema",icon:r.jsx(b.Trash,{size:16}),disabled:o.length<=1,onClick:()=>E(p.schemaId)}]})]})}exports.default=O;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as S, useEffect as D, forwardRef as _ } from "react";
|
|
3
|
+
import { clsx as j } from "clsx";
|
|
4
|
+
import { Plus as q, Trash as L, X as z, CaretUp as X, CaretDown as Y } from "@phosphor-icons/react";
|
|
5
|
+
import { f as p } from "./useAdapterControls-DVjkwRZ_.js";
|
|
6
|
+
import { useShallow as T } from "zustand/react/shallow";
|
|
7
|
+
import { uniqueKey as F, FIELD_TYPES as $ } from "@element-editor/core/internal";
|
|
8
|
+
import { C as H, f as R, I as C, c as V, B as G } from "./EditToolbarBtn-SR4xHd8G.js";
|
|
9
|
+
function J({
|
|
10
|
+
field: l,
|
|
11
|
+
existingKeys: s,
|
|
12
|
+
onUpdate: i,
|
|
13
|
+
onDelete: y,
|
|
14
|
+
isProtected: d
|
|
15
|
+
}) {
|
|
16
|
+
const [m, v] = f(!1), [c, k] = f(""), [x, h] = f(l.label);
|
|
17
|
+
D(() => h(l.label), [l.label]);
|
|
18
|
+
function b() {
|
|
19
|
+
if (x === l.label) return;
|
|
20
|
+
const r = d ? l.key : F(x, s);
|
|
21
|
+
i({ label: x, key: r });
|
|
22
|
+
}
|
|
23
|
+
function w() {
|
|
24
|
+
const r = c.trim();
|
|
25
|
+
if (!r) return;
|
|
26
|
+
const a = l.options ?? [];
|
|
27
|
+
a.includes(r) || (i({ options: [...a, r] }), k(""));
|
|
28
|
+
}
|
|
29
|
+
function N(r) {
|
|
30
|
+
i({ options: (l.options ?? []).filter((a) => a !== r) });
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ n("div", { className: "bg-elm-surface-raised border border-elm-border rounded-elm-card p-3 space-y-2", children: [
|
|
33
|
+
/* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
|
|
34
|
+
/* @__PURE__ */ n("p", { className: "text-xs text-elm-text-subtle", children: [
|
|
35
|
+
"key: ",
|
|
36
|
+
/* @__PURE__ */ t("code", { className: "font-elm-mono text-elm-text-muted", children: l.key })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ t(R, { content: d ? "Required field — cannot be removed" : "Remove field", children: /* @__PURE__ */ t(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
onClick: y,
|
|
42
|
+
disabled: d,
|
|
43
|
+
className: "flex-shrink-0 text-elm-text disabled:opacity-25 disabled:cursor-not-allowed transition-colors p-1 rounded-elm-chip hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700))",
|
|
44
|
+
"aria-label": d ? "Cannot remove required field" : "Remove field",
|
|
45
|
+
children: /* @__PURE__ */ t(z, { size: 14 })
|
|
46
|
+
}
|
|
47
|
+
) })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ t(
|
|
50
|
+
C,
|
|
51
|
+
{
|
|
52
|
+
value: x,
|
|
53
|
+
onChange: (r) => h(r.target.value),
|
|
54
|
+
onBlur: b,
|
|
55
|
+
onKeyDown: (r) => r.key === "Enter" && r.target.blur(),
|
|
56
|
+
placeholder: "Field label",
|
|
57
|
+
className: "w-full text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))"
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ t(
|
|
61
|
+
V,
|
|
62
|
+
{
|
|
63
|
+
value: l.type,
|
|
64
|
+
onChange: (r) => {
|
|
65
|
+
const a = r.target.value;
|
|
66
|
+
i({ type: a, options: a === "select" ? l.options ?? [] : void 0 }), v(a === "select");
|
|
67
|
+
},
|
|
68
|
+
className: "w-full text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))",
|
|
69
|
+
children: $.map((r) => /* @__PURE__ */ t("option", { value: r.value, children: r.label }, r.value))
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ n("label", { className: "flex items-center gap-1.5 text-xs text-elm-text-muted cursor-pointer select-none w-fit", children: [
|
|
73
|
+
/* @__PURE__ */ t(
|
|
74
|
+
"input",
|
|
75
|
+
{
|
|
76
|
+
type: "checkbox",
|
|
77
|
+
checked: l.required,
|
|
78
|
+
onChange: (r) => i({ required: r.target.checked }),
|
|
79
|
+
className: "elm-checkbox"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
"Required"
|
|
83
|
+
] }),
|
|
84
|
+
l.type === "number" && /* @__PURE__ */ n("div", { className: "flex items-center gap-2 pt-1 border-t border-(--elm-border-subtle,var(--color-gray-100)) dark:border-(--elm-border-subtle,var(--color-gray-700))", children: [
|
|
85
|
+
/* @__PURE__ */ n("label", { className: "flex items-center gap-1.5 text-xs text-elm-text-muted w-1/2", children: [
|
|
86
|
+
"Min",
|
|
87
|
+
/* @__PURE__ */ t(
|
|
88
|
+
C,
|
|
89
|
+
{
|
|
90
|
+
type: "number",
|
|
91
|
+
value: l.min ?? "",
|
|
92
|
+
onChange: (r) => i({ min: r.target.value ? parseFloat(r.target.value) : void 0 }),
|
|
93
|
+
className: "flex-1 w-full min-w-0",
|
|
94
|
+
placeholder: "Any"
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ n("label", { className: "flex items-center gap-1.5 text-xs text-elm-text-muted w-1/2", children: [
|
|
99
|
+
"Max",
|
|
100
|
+
/* @__PURE__ */ t(
|
|
101
|
+
C,
|
|
102
|
+
{
|
|
103
|
+
type: "number",
|
|
104
|
+
value: l.max ?? "",
|
|
105
|
+
onChange: (r) => i({ max: r.target.value ? parseFloat(r.target.value) : void 0 }),
|
|
106
|
+
className: "flex-1 w-full min-w-0",
|
|
107
|
+
placeholder: "Any"
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
] })
|
|
111
|
+
] }),
|
|
112
|
+
l.type === "select" && /* @__PURE__ */ n("div", { className: "space-y-1.5 pt-1 border-t border-(--elm-border-subtle,var(--color-gray-100)) dark:border-(--elm-border-subtle,var(--color-gray-700))", children: [
|
|
113
|
+
/* @__PURE__ */ n(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
onClick: () => v((r) => !r),
|
|
117
|
+
className: "text-xs text-primary-500 hover:text-primary-700 hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) rounded-elm-chip px-1 -mx-1 py-0.5 flex items-center gap-1 transition-colors",
|
|
118
|
+
children: [
|
|
119
|
+
m ? /* @__PURE__ */ t(X, { size: 11 }) : /* @__PURE__ */ t(Y, { size: 11 }),
|
|
120
|
+
m ? "Hide options" : `Options (${(l.options ?? []).length})`
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
m && /* @__PURE__ */ n("div", { className: "space-y-1", children: [
|
|
125
|
+
(l.options ?? []).map((r) => /* @__PURE__ */ n("div", { className: "flex items-center gap-1.5", children: [
|
|
126
|
+
/* @__PURE__ */ t("span", { className: "flex-1 text-xs text-elm-text-secondary bg-(--elm-surface-sunken,var(--color-gray-50)) dark:bg-(--elm-surface-sunken,var(--color-gray-700)) border border-(--elm-border,var(--color-gray-200)) dark:border-(--elm-border,var(--color-gray-600)) rounded-elm-chip px-2 py-1 truncate", children: r }),
|
|
127
|
+
/* @__PURE__ */ t("button", { onClick: () => N(r), className: "text-elm-text hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) transition-colors p-0.5 rounded-elm-chip", "aria-label": `Remove "${r}" option`, children: /* @__PURE__ */ t(z, { size: 12 }) })
|
|
128
|
+
] }, r)),
|
|
129
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-1.5 pt-1", children: [
|
|
130
|
+
/* @__PURE__ */ t(
|
|
131
|
+
C,
|
|
132
|
+
{
|
|
133
|
+
value: c,
|
|
134
|
+
onChange: (r) => k(r.target.value),
|
|
135
|
+
onKeyDown: (r) => r.key === "Enter" && w(),
|
|
136
|
+
placeholder: "New option…",
|
|
137
|
+
className: "flex-1 min-w-0 text-xs text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-200))"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ t(G, { variant: "secondary", size: "sm", onClick: w, children: "Add" })
|
|
141
|
+
] })
|
|
142
|
+
] })
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
const P = _(
|
|
147
|
+
function({ schema: s, onRename: i }, y) {
|
|
148
|
+
const [d, m] = f(s.name);
|
|
149
|
+
D(() => m(s.name), [s.name]);
|
|
150
|
+
function v() {
|
|
151
|
+
const c = d.trim();
|
|
152
|
+
if (!c) {
|
|
153
|
+
m(s.name);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
c !== s.name && i(c);
|
|
157
|
+
}
|
|
158
|
+
return /* @__PURE__ */ t(
|
|
159
|
+
"input",
|
|
160
|
+
{
|
|
161
|
+
ref: y,
|
|
162
|
+
type: "text",
|
|
163
|
+
value: d,
|
|
164
|
+
onChange: (c) => m(c.target.value),
|
|
165
|
+
onBlur: v,
|
|
166
|
+
onKeyDown: (c) => c.key === "Enter" && c.target.blur(),
|
|
167
|
+
className: "w-full text-sm font-semibold text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) bg-transparent border-b border-transparent hover:border-(--elm-border-strong,var(--color-gray-300)) dark:hover:border-(--elm-border-strong,var(--color-gray-600)) focus:border-primary-400 focus:outline-none px-0 py-0 leading-snug"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
function ae({ containerRef: l }) {
|
|
173
|
+
var A, B, I;
|
|
174
|
+
const s = p(T((e) => e.getVisibleSchemas())), i = p((e) => e.addSchema), y = p((e) => e.updateSchema), d = p((e) => e.deleteSchema), m = p((e) => e.addSchemaField), v = p((e) => e.updateSchemaField), c = p((e) => e.removeSchemaField), [k, x] = f(((A = s[0]) == null ? void 0 : A.id) ?? null), [h, b] = f(null), w = S(/* @__PURE__ */ new Map()), N = S(null), r = S(null), a = s.find((e) => e.id === k) ?? s[0] ?? null;
|
|
175
|
+
D(() => {
|
|
176
|
+
if (!a || r.current !== a.id) return;
|
|
177
|
+
r.current = null;
|
|
178
|
+
const e = N.current;
|
|
179
|
+
e && (e.focus(), e.select());
|
|
180
|
+
}, [a == null ? void 0 : a.id]);
|
|
181
|
+
function M(e) {
|
|
182
|
+
const u = new Set(e.fields.map((g) => g.key)), o = F("field", u);
|
|
183
|
+
m(e.id, { key: o, label: "", type: "text", required: !1 });
|
|
184
|
+
}
|
|
185
|
+
function E() {
|
|
186
|
+
const e = i("New schema", [{ key: F("field", /* @__PURE__ */ new Set()), label: "", type: "text", required: !1 }]);
|
|
187
|
+
r.current = e, x(e);
|
|
188
|
+
}
|
|
189
|
+
function K(e, u) {
|
|
190
|
+
var g;
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
const o = ((g = l == null ? void 0 : l.current) == null ? void 0 : g.getBoundingClientRect()) ?? { left: 0, top: 0 };
|
|
193
|
+
b({ schemaId: u, offsetX: e.clientX - o.left, offsetY: e.clientY - o.top });
|
|
194
|
+
}
|
|
195
|
+
function O(e) {
|
|
196
|
+
var o;
|
|
197
|
+
if (s.length <= 1) return;
|
|
198
|
+
d(e);
|
|
199
|
+
const u = s.filter((g) => g.id !== e);
|
|
200
|
+
x(((o = u[0]) == null ? void 0 : o.id) ?? null), b(null);
|
|
201
|
+
}
|
|
202
|
+
return /* @__PURE__ */ n("div", { className: "flex h-full min-h-0", onClick: () => b(null), children: [
|
|
203
|
+
/* @__PURE__ */ t("div", { className: "w-44 flex-shrink-0 flex flex-col border-r border-elm-border min-h-0", children: /* @__PURE__ */ n("div", { className: "flex-1 overflow-y-auto min-h-0 py-1", children: [
|
|
204
|
+
s.map((e) => {
|
|
205
|
+
const u = ((a == null ? void 0 : a.id) ?? k) === e.id;
|
|
206
|
+
return /* @__PURE__ */ t(
|
|
207
|
+
"button",
|
|
208
|
+
{
|
|
209
|
+
ref: (o) => {
|
|
210
|
+
o ? w.current.set(e.id, o) : w.current.delete(e.id);
|
|
211
|
+
},
|
|
212
|
+
onClick: () => x(e.id),
|
|
213
|
+
onContextMenu: (o) => K(o, e.id),
|
|
214
|
+
className: j(
|
|
215
|
+
"w-full text-left px-3 py-2 text-sm transition-colors flex items-center gap-1.5",
|
|
216
|
+
u ? "bg-primary-50 dark:bg-white/10 hover:bg-primary-100 dark:hover:bg-white/15 text-primary-700 dark:text-primary-300 font-medium border-r-2 border-primary-500" : "text-elm-text-muted hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-800)) hover:text-(--elm-text,var(--color-gray-800)) dark:hover:text-(--elm-text,var(--color-gray-200)) border-r-2 border-transparent"
|
|
217
|
+
),
|
|
218
|
+
children: /* @__PURE__ */ t("span", { className: "flex-1 truncate leading-snug", children: e.name })
|
|
219
|
+
},
|
|
220
|
+
e.id
|
|
221
|
+
);
|
|
222
|
+
}),
|
|
223
|
+
/* @__PURE__ */ n(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
onClick: E,
|
|
227
|
+
className: "w-full flex items-center gap-1.5 px-3 py-2 text-xs text-elm-text-subtle hover:text-(--elm-text-secondary,var(--color-gray-700)) dark:hover:text-(--elm-text-secondary,var(--color-gray-200)) hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-800)) transition-colors border-r-2 border-transparent",
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ t(q, { size: 11 }),
|
|
230
|
+
"Add schema"
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] }) }),
|
|
235
|
+
a ? /* @__PURE__ */ n("div", { className: "flex-1 flex flex-col min-w-0 min-h-0 bg-(--elm-surface-sunken,color-mix(in_oklab,var(--color-gray-50)_60%,transparent)) dark:bg-(--elm-surface-sunken,color-mix(in_oklab,var(--color-gray-800)_30%,transparent))", children: [
|
|
236
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-2 px-3 py-2.5 border-b border-elm-border-subtle flex-shrink-0", children: [
|
|
237
|
+
/* @__PURE__ */ t("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ t(
|
|
238
|
+
P,
|
|
239
|
+
{
|
|
240
|
+
ref: N,
|
|
241
|
+
schema: a,
|
|
242
|
+
onRename: (e) => y(a.id, { name: e })
|
|
243
|
+
},
|
|
244
|
+
a.id
|
|
245
|
+
) }),
|
|
246
|
+
/* @__PURE__ */ n(
|
|
247
|
+
"button",
|
|
248
|
+
{
|
|
249
|
+
onClick: () => M(a),
|
|
250
|
+
className: "flex-shrink-0 flex items-center gap-1 text-xs text-elm-text-subtle hover:text-primary-500 dark:hover:text-primary-400 transition-colors px-1.5 py-1 rounded-elm-chip hover:bg-primary-50 dark:hover:bg-white/5",
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ t(q, { size: 11 }),
|
|
253
|
+
"Add field"
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] }),
|
|
258
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto min-h-0 p-3 space-y-2", children: a.fields.map((e) => {
|
|
259
|
+
const u = new Set(
|
|
260
|
+
a.fields.map((o) => o.key).filter((o) => o !== e.key)
|
|
261
|
+
);
|
|
262
|
+
return /* @__PURE__ */ t(
|
|
263
|
+
J,
|
|
264
|
+
{
|
|
265
|
+
field: e,
|
|
266
|
+
existingKeys: u,
|
|
267
|
+
onUpdate: (o) => v(a.id, e.key, o),
|
|
268
|
+
onDelete: () => c(a.id, e.key),
|
|
269
|
+
isProtected: e.key === "name"
|
|
270
|
+
},
|
|
271
|
+
e.key
|
|
272
|
+
);
|
|
273
|
+
}) })
|
|
274
|
+
] }) : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-sm text-elm-text-disabled", children: "Select a schema" }),
|
|
275
|
+
h && /* @__PURE__ */ t(
|
|
276
|
+
H,
|
|
277
|
+
{
|
|
278
|
+
x: (((B = l == null ? void 0 : l.current) == null ? void 0 : B.getBoundingClientRect().left) ?? 0) + h.offsetX,
|
|
279
|
+
y: (((I = l == null ? void 0 : l.current) == null ? void 0 : I.getBoundingClientRect().top) ?? 0) + h.offsetY,
|
|
280
|
+
onClose: () => b(null),
|
|
281
|
+
items: [{
|
|
282
|
+
label: s.length <= 1 ? "Cannot delete last" : "Delete schema",
|
|
283
|
+
icon: /* @__PURE__ */ t(L, { size: 16 }),
|
|
284
|
+
disabled: s.length <= 1,
|
|
285
|
+
onClick: () => O(h.schemaId)
|
|
286
|
+
}]
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
] });
|
|
290
|
+
}
|
|
291
|
+
export {
|
|
292
|
+
ae as default
|
|
293
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as t, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as _, useState as k, useCallback as H, useEffect as C } from "react";
|
|
3
|
+
import { u as I, W as L, s as R } from "./index-CILw1Du5.js";
|
|
4
|
+
import { u as $, e as T } from "./useAccentStyle-CPo2XqAn.js";
|
|
5
|
+
import { readStorage as Y, writeStorage as j } from "@element-editor/core";
|
|
6
|
+
import { createPortal as O } from "react-dom";
|
|
7
|
+
import { u as X, a as A, C as B } from "./useWindowFocus-DuQVjnHE.js";
|
|
8
|
+
import { u as F } from "./useFocusTrap-CKxKT8De.js";
|
|
9
|
+
import J from "./SchemaEditor-ryoTgaLb.js";
|
|
10
|
+
import { d as P } from "./useAdapterControls-DVjkwRZ_.js";
|
|
11
|
+
const f = "elm_schema_win_size", r = 450, p = 200;
|
|
12
|
+
function ne({ onClose: c }) {
|
|
13
|
+
const { pos: m, onHandleMouseDown: w } = X("elm_schema_win", { x: 80, y: 120 }), i = $(), { zIndex: l, focus: x } = A(), v = P(), b = T(), o = _(null), [n, g] = k(() => {
|
|
14
|
+
try {
|
|
15
|
+
const e = Y(f, i);
|
|
16
|
+
return e ? JSON.parse(e) : { w: r, h: 520 };
|
|
17
|
+
} catch {
|
|
18
|
+
return { w: r, h: 520 };
|
|
19
|
+
}
|
|
20
|
+
}), S = H((e, a) => {
|
|
21
|
+
j(f, JSON.stringify({ w: e, h: a }), i);
|
|
22
|
+
}, [i]);
|
|
23
|
+
function M(e) {
|
|
24
|
+
e.preventDefault(), e.stopPropagation();
|
|
25
|
+
const a = e.clientX, y = e.clientY, W = n.w, E = n.h, N = R("se-resize");
|
|
26
|
+
function d(s) {
|
|
27
|
+
const z = Math.max(r, Math.min(window.innerWidth * 0.9, W + s.clientX - a)), D = Math.max(p, Math.min(window.innerHeight * 0.85, E + s.clientY - y));
|
|
28
|
+
g({ w: z, h: D });
|
|
29
|
+
}
|
|
30
|
+
function u() {
|
|
31
|
+
N(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", u);
|
|
32
|
+
const s = o.current;
|
|
33
|
+
s && S(s.offsetWidth, s.offsetHeight);
|
|
34
|
+
}
|
|
35
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", u);
|
|
36
|
+
}
|
|
37
|
+
return F(o), I(o, !0, c, l), C(() => {
|
|
38
|
+
var e;
|
|
39
|
+
(e = o.current) == null || e.focus();
|
|
40
|
+
}, []), O(
|
|
41
|
+
/* @__PURE__ */ t("div", { "data-elm-theme": v, style: b, children: /* @__PURE__ */ h(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
ref: o,
|
|
45
|
+
[L]: "",
|
|
46
|
+
onMouseDownCapture: x,
|
|
47
|
+
role: "dialog",
|
|
48
|
+
"aria-label": "Schema editor",
|
|
49
|
+
tabIndex: -1,
|
|
50
|
+
className: "fixed flex flex-col bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm-raised rounded-elm-window overflow-hidden outline-none",
|
|
51
|
+
style: {
|
|
52
|
+
// Clamp into the viewport so a saved/default position never pushes the window off-screen on narrow screens.
|
|
53
|
+
left: `clamp(8px, ${m.x}px, calc(100vw - min(${n.w}px, 90vw) - 8px))`,
|
|
54
|
+
top: `clamp(8px, ${m.y}px, calc(100vh - min(${n.h}px, 85vh) - 8px))`,
|
|
55
|
+
zIndex: l,
|
|
56
|
+
minWidth: `min(${r}px, 90vw)`,
|
|
57
|
+
minHeight: p,
|
|
58
|
+
width: n.w,
|
|
59
|
+
height: n.h,
|
|
60
|
+
maxWidth: "90vw",
|
|
61
|
+
maxHeight: "85vh"
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ h(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
onMouseDown: w,
|
|
68
|
+
className: "flex items-center justify-between px-4 py-3 border-b border-elm-border flex-shrink-0 select-none",
|
|
69
|
+
style: { cursor: "grab" },
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ t("span", { className: "text-sm font-semibold text-(--elm-text,var(--color-gray-900)) dark:text-(--elm-text,var(--color-gray-100))", children: "Schema" }),
|
|
72
|
+
/* @__PURE__ */ t(B, { onClick: c, label: "Close schema editor" })
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-hidden min-h-0", children: /* @__PURE__ */ t(J, { containerRef: o }) }),
|
|
77
|
+
/* @__PURE__ */ t(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
onMouseDown: M,
|
|
81
|
+
className: "absolute bottom-0 right-0 w-4 h-4 cursor-se-resize select-none",
|
|
82
|
+
style: { zIndex: 10 },
|
|
83
|
+
"aria-hidden": !0,
|
|
84
|
+
children: /* @__PURE__ */ t("svg", { width: "10", height: "10", viewBox: "0 0 10 10", className: "absolute bottom-1 right-1 text-elm-text-disabled", children: /* @__PURE__ */ t("path", { d: "M9 1L1 9M9 5L5 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) })
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
) }),
|
|
90
|
+
document.body
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
ne as default
|
|
95
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),l=require("./index-DG4wEjGj.cjs"),f=require("./useAccentStyle-hsGvyHZc.cjs"),p=require("@element-editor/core"),H=require("react-dom"),d=require("./useWindowFocus-EemgNOuz.cjs"),C=require("./useFocusTrap-BBjPCfDR.cjs"),I=require("./SchemaEditor-B4L17K1e.cjs"),L=require("./useAdapterControls-BBObhzVX.cjs"),v="elm_schema_win_size",i=450,b=200;function R({onClose:u}){const{pos:m,onHandleMouseDown:g}=d.useDragWindow("elm_schema_win",{x:80,y:120}),c=f.useElementEditorConfig(),{zIndex:h,focus:S}=d.useWindowFocus(),y=L.useTheme(),M=f.useAccentStyle(),o=r.useRef(null),[n,W]=r.useState(()=>{try{const e=p.readStorage(v,c);return e?JSON.parse(e):{w:i,h:520}}catch{return{w:i,h:520}}}),j=r.useCallback((e,a)=>{p.writeStorage(v,JSON.stringify({w:e,h:a}),c)},[c]);function E(e){e.preventDefault(),e.stopPropagation();const a=e.clientX,N=e.clientY,q=n.w,D=n.h,z=l.startDragShield("se-resize");function x(s){const _=Math.max(i,Math.min(window.innerWidth*.9,q+s.clientX-a)),k=Math.max(b,Math.min(window.innerHeight*.85,D+s.clientY-N));W({w:_,h:k})}function w(){z(),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",w);const s=o.current;s&&j(s.offsetWidth,s.offsetHeight)}document.addEventListener("mousemove",x),document.addEventListener("mouseup",w)}return C.useFocusTrap(o),l.useWindowEscape(o,!0,u,h),r.useEffect(()=>{var e;(e=o.current)==null||e.focus()},[]),H.createPortal(t.jsx("div",{"data-elm-theme":y,style:M,children:t.jsxs("div",{ref:o,[l.WINDOW_ATTR]:"",onMouseDownCapture:S,role:"dialog","aria-label":"Schema editor",tabIndex:-1,className:"fixed flex flex-col bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm-raised rounded-elm-window overflow-hidden outline-none",style:{left:`clamp(8px, ${m.x}px, calc(100vw - min(${n.w}px, 90vw) - 8px))`,top:`clamp(8px, ${m.y}px, calc(100vh - min(${n.h}px, 85vh) - 8px))`,zIndex:h,minWidth:`min(${i}px, 90vw)`,minHeight:b,width:n.w,height:n.h,maxWidth:"90vw",maxHeight:"85vh"},children:[t.jsxs("div",{onMouseDown:g,className:"flex items-center justify-between px-4 py-3 border-b border-elm-border flex-shrink-0 select-none",style:{cursor:"grab"},children:[t.jsx("span",{className:"text-sm font-semibold text-(--elm-text,var(--color-gray-900)) dark:text-(--elm-text,var(--color-gray-100))",children:"Schema"}),t.jsx(d.CloseButton,{onClick:u,label:"Close schema editor"})]}),t.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:t.jsx(I.default,{containerRef:o})}),t.jsx("div",{onMouseDown:E,className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize select-none",style:{zIndex:10},"aria-hidden":!0,children:t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"absolute bottom-1 right-1 text-elm-text-disabled",children:t.jsx("path",{d:"M9 1L1 9M9 5L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})}),document.body)}exports.default=R;
|