@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,19 @@
|
|
|
1
|
+
import { TooltipSide } from './Tooltip.cjs';
|
|
2
|
+
interface ToolButtonProps {
|
|
3
|
+
active: boolean;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
label: string;
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
/** Shortcut id (`data-elm-shortcut`): the key flashes this button pressed. */
|
|
8
|
+
shortcutId?: string;
|
|
9
|
+
color?: 'blue' | 'emerald' | 'amber' | 'violet';
|
|
10
|
+
/** Tooltip side. Omit to auto-pick from toolbar position/direction. */
|
|
11
|
+
tooltipSide?: TooltipSide;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function ToolButton({ active, onClick, label, shortcut, shortcutId, color, tooltipSide, disabled, children }: ToolButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function ToolbarDivider({ vertical }?: {
|
|
17
|
+
vertical?: boolean;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TooltipSide } from './Tooltip.js';
|
|
2
|
+
interface ToolButtonProps {
|
|
3
|
+
active: boolean;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
label: string;
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
/** Shortcut id (`data-elm-shortcut`): the key flashes this button pressed. */
|
|
8
|
+
shortcutId?: string;
|
|
9
|
+
color?: 'blue' | 'emerald' | 'amber' | 'violet';
|
|
10
|
+
/** Tooltip side. Omit to auto-pick from toolbar position/direction. */
|
|
11
|
+
tooltipSide?: TooltipSide;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function ToolButton({ active, onClick, label, shortcut, shortcutId, color, tooltipSide, disabled, children }: ToolButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function ToolbarDivider({ vertical }?: {
|
|
17
|
+
vertical?: boolean;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type TooltipSide = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
shortcut?: ReactNode;
|
|
6
|
+
side?: TooltipSide;
|
|
7
|
+
/** Wrap long text at a max width instead of one long line. */
|
|
8
|
+
multiline?: boolean;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare function Tooltip({ content, shortcut, side, multiline, children }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type TooltipSide = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
shortcut?: ReactNode;
|
|
6
|
+
side?: TooltipSide;
|
|
7
|
+
/** Wrap long text at a max width instead of one long line. */
|
|
8
|
+
multiline?: boolean;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare function Tooltip({ content, shortcut, side, multiline, children }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const panelHeaderIconBtn = "items-center justify-center flex-shrink-0 p-[3px] rounded-elm-control text-elm-text-secondary hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) active:scale-[0.95] disabled:text-elm-text-disabled disabled:hover:bg-transparent disabled:active:scale-100 disabled:cursor-not-allowed transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring";
|
|
2
|
+
export declare const panelHeaderBar = "h-10 box-border flex items-center flex-shrink-0 border-b border-elm-border bg-elm-surface-sunken";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const panelHeaderIconBtn = "items-center justify-center flex-shrink-0 p-[3px] rounded-elm-control text-elm-text-secondary hover:bg-(--elm-surface-hover,var(--color-gray-100)) dark:hover:bg-(--elm-surface-hover,var(--color-gray-700)) active:scale-[0.95] disabled:text-elm-text-disabled disabled:hover:bg-transparent disabled:active:scale-100 disabled:cursor-not-allowed transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-elm-focus-ring";
|
|
2
|
+
export declare const panelHeaderBar = "h-10 box-border flex items-center flex-shrink-0 border-b border-elm-border bg-elm-surface-sunken";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Vertical edge on a panel's left side (col-resize). */
|
|
2
|
+
export declare const resizeEdgeLeft = "absolute left-0 top-0 h-full w-1 z-20 cursor-col-resize after:inset-y-0 after:left-0 after:w-0.5 after:absolute after:transition-colors hover:after:bg-elm-focus-ring data-[dragging]:after:bg-elm-focus-ring";
|
|
3
|
+
/** Horizontal edge on a panel's top side (row-resize). */
|
|
4
|
+
export declare const resizeEdgeTop = "absolute top-0 left-0 right-0 h-1 z-10 cursor-row-resize after:inset-x-0 after:top-0 after:h-0.5 after:absolute after:transition-colors hover:after:bg-elm-focus-ring data-[dragging]:after:bg-elm-focus-ring";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Vertical edge on a panel's left side (col-resize). */
|
|
2
|
+
export declare const resizeEdgeLeft = "absolute left-0 top-0 h-full w-1 z-20 cursor-col-resize after:inset-y-0 after:left-0 after:w-0.5 after:absolute after:transition-colors hover:after:bg-elm-focus-ring data-[dragging]:after:bg-elm-focus-ring";
|
|
3
|
+
/** Horizontal edge on a panel's top side (row-resize). */
|
|
4
|
+
export declare const resizeEdgeTop = "absolute top-0 left-0 right-0 h-1 z-10 cursor-row-resize after:inset-x-0 after:top-0 after:h-0.5 after:absolute after:transition-colors hover:after:bg-elm-focus-ring data-[dragging]:after:bg-elm-focus-ring";
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { NetworkConfig } from '@element-editor/core';
|
|
3
|
+
export type DrawTool = 'polygon' | 'rectangle' | 'circle' | 'line' | 'point' | 'freehand' | 'route' | 'picker' | 'measure' | 'search';
|
|
4
|
+
/** The editing mode each tool turns on (`'search'` is a box, not a mode). The tools that add a feature are all but `measure`. */
|
|
5
|
+
export declare const TOOL_MODES: {
|
|
6
|
+
readonly point: "place-point";
|
|
7
|
+
readonly line: "draw-line";
|
|
8
|
+
readonly polygon: "draw-polygon";
|
|
9
|
+
readonly route: "draw-route";
|
|
10
|
+
readonly circle: "draw-circle";
|
|
11
|
+
readonly rectangle: "draw-rect";
|
|
12
|
+
readonly freehand: "draw-freehand";
|
|
13
|
+
readonly picker: "pick-shape";
|
|
14
|
+
readonly measure: "measure";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Where a control can go (`config.ui.layout`): eight places on the map (four
|
|
18
|
+
* corners, four edge centers) and the two ends of the status bar under it.
|
|
19
|
+
*/
|
|
20
|
+
export type LayoutSlot = MapSlot | StatusSlot;
|
|
21
|
+
/** The eight places on the map. */
|
|
22
|
+
export type MapSlot = 'topLeft' | 'topCenter' | 'topRight' | 'leftCenter' | 'rightCenter' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
23
|
+
/** The two ends of the status bar under the map. */
|
|
24
|
+
export type StatusSlot = 'statusLeft' | 'statusRight';
|
|
25
|
+
/** Every placeable built-in control. */
|
|
26
|
+
export type LayoutControl = 'toolbar' | 'undo' | 'redo' | 'fitBounds' | 'locate' | 'zoomIndicator' | 'table' | 'schema' | 'geojson' | 'settings' | 'keyboard' | 'applyChanges' | 'attribution' | 'basemap';
|
|
27
|
+
type MapControl = Exclude<LayoutControl, 'attribution'>;
|
|
28
|
+
type StatusControl = Exclude<LayoutControl, 'toolbar' | 'applyChanges'>;
|
|
29
|
+
/** Controls drawn as one joined pill on the map. No toolbar or basemap picker inside. */
|
|
30
|
+
export type MapGroup = {
|
|
31
|
+
group: ReadonlyArray<Exclude<MapControl, 'toolbar' | 'basemap'> | 'separator'>;
|
|
32
|
+
};
|
|
33
|
+
/** Controls drawn as a tight cluster in the status bar. */
|
|
34
|
+
export type StatusGroup = {
|
|
35
|
+
group: ReadonlyArray<Exclude<StatusControl, 'basemap'> | 'separator'>;
|
|
36
|
+
};
|
|
37
|
+
/** A map slot entry. No bare `'separator'` (nothing to draw it on over the tiles): put it in a group. */
|
|
38
|
+
export type MapEntry = MapControl | MapGroup;
|
|
39
|
+
export type StatusEntry = StatusControl | 'separator' | StatusGroup;
|
|
40
|
+
export type MapSlotConfig = readonly MapEntry[] | {
|
|
41
|
+
items: readonly MapEntry[];
|
|
42
|
+
direction?: 'horizontal' | 'vertical';
|
|
43
|
+
};
|
|
44
|
+
/** Status slots are always horizontal. */
|
|
45
|
+
export type StatusSlotConfig = readonly StatusEntry[];
|
|
46
|
+
export type LayoutGroup = MapGroup | StatusGroup;
|
|
47
|
+
export type LayoutEntry = MapEntry | StatusEntry;
|
|
48
|
+
export type LayoutSlotConfig = MapSlotConfig | StatusSlotConfig;
|
|
49
|
+
/** Where every built-in control goes (`config.ui.layout`). Each slot only takes the entries it can show. */
|
|
50
|
+
export type LayoutConfig = {
|
|
51
|
+
[S in MapSlot]?: MapSlotConfig;
|
|
52
|
+
} & {
|
|
53
|
+
[S in StatusSlot]?: StatusSlotConfig;
|
|
54
|
+
};
|
|
55
|
+
/** A slot after resolution: duplicates and invalid entries removed, groups normalised. */
|
|
56
|
+
export type ResolvedLayout = Record<LayoutSlot, {
|
|
57
|
+
items: LayoutEntry[];
|
|
58
|
+
direction: 'horizontal' | 'vertical';
|
|
59
|
+
}>;
|
|
60
|
+
/** Slot order. A control listed twice stays at its first place in this order. */
|
|
61
|
+
export declare const LAYOUT_SLOTS: readonly LayoutSlot[];
|
|
62
|
+
/**
|
|
63
|
+
* Layout used when `ui.layout` isn't set.
|
|
64
|
+
* Deep-frozen (shared by every editor on the page). To change it, use {@link withLayout}.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DEFAULT_LAYOUT: LayoutConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Drop separators that would show nothing useful: at the start or end of a
|
|
69
|
+
* section and right after another separator. Call it after hidden buttons
|
|
70
|
+
* are removed, so a separator next to a hidden button disappears too.
|
|
71
|
+
*/
|
|
72
|
+
export declare function collapseSeparators<T>(entries: readonly (T | 'separator')[]): (T | 'separator')[];
|
|
73
|
+
/**
|
|
74
|
+
* Whether a placed control renders at all, given the visibility flags.
|
|
75
|
+
* `<ElementEditor>` uses it both to render a control and to decide whether a
|
|
76
|
+
* slot, group or the status bar has anything left to show, so they can't drift.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isControlVisible(id: LayoutControl, ui: ResolvedConfig['ui'], ctx: {
|
|
79
|
+
readonly: boolean;
|
|
80
|
+
canSubmit: boolean;
|
|
81
|
+
hasBasemaps: boolean;
|
|
82
|
+
}): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* A slot's entries with hidden controls removed, then empty groups and
|
|
85
|
+
* dangling separators (also inside groups) dropped.
|
|
86
|
+
*/
|
|
87
|
+
export declare function visibleLayoutEntries(entries: readonly LayoutEntry[], isVisible: (id: LayoutControl) => boolean): LayoutEntry[];
|
|
88
|
+
/** A raster tile basemap (XYZ). Engine-neutral, so the Leaflet drop-in needs no MapLibre types. */
|
|
89
|
+
export interface RasterBasemap {
|
|
90
|
+
id?: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
thumbnail?: string;
|
|
93
|
+
url: string;
|
|
94
|
+
attribution: string;
|
|
95
|
+
maxZoom?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Where the floating toolbar is anchored inside the map container
|
|
99
|
+
* (`ResolvedConfig.toolbar.position`, derived from the toolbar's layout slot).
|
|
100
|
+
*
|
|
101
|
+
* Eight positions — the four corners, the four edge-centers:
|
|
102
|
+
*
|
|
103
|
+
* top-left top-center top-right
|
|
104
|
+
* left-center · right-center
|
|
105
|
+
* bottom-left bottom-center bottom-right
|
|
106
|
+
*/
|
|
107
|
+
export type ToolbarPosition = 'top-left' | 'top-center' | 'top-right' | 'left-center' | 'right-center' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
108
|
+
export interface ElementEditorConfig {
|
|
109
|
+
/** Color theme. Default: 'system' (follows OS preference). */
|
|
110
|
+
mode?: 'light' | 'dark' | 'system';
|
|
111
|
+
/**
|
|
112
|
+
* Brand accent: any CSS colour (`'#ea580c'`, `'rebeccapurple'`, `'oklch(…)'`).
|
|
113
|
+
* The whole primary 50…950 scale (buttons, active tools, selection, checkboxes,
|
|
114
|
+
* links) is derived from it in CSS. Applied as `--elm-accent` on the editor
|
|
115
|
+
* root and on Element's portals; updates live. Default: undefined (blue).
|
|
116
|
+
* `<ElementEditor accentColor>` wins over this.
|
|
117
|
+
*/
|
|
118
|
+
accentColor?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Default colour of every feature (polygon outline + fill, line, point): any
|
|
121
|
+
* CSS colour. Opacity and weight keep their defaults. `getFeatureStyle` (per
|
|
122
|
+
* field) and the selected / hovered looks win over it. Updates live.
|
|
123
|
+
* `<ElementEditor featureColor>` wins over this. Default: undefined (slate `#475569`).
|
|
124
|
+
*/
|
|
125
|
+
featureColor?: string;
|
|
126
|
+
/** Which drawing tools are available. Default: 'all'. */
|
|
127
|
+
tools?: DrawTool[] | 'all';
|
|
128
|
+
/**
|
|
129
|
+
* Namespace for everything this editor remembers in localStorage (theme,
|
|
130
|
+
* settings, units, shortcuts, window positions/sizes, panel widths, map view,
|
|
131
|
+
* basemap pick, last schema): `elm_theme` becomes `elm_<persistKey>_theme`.
|
|
132
|
+
* Give each editor on an origin its own key so they don't overwrite each other.
|
|
133
|
+
* Default: undefined (the shared `elm_*` keys).
|
|
134
|
+
*/
|
|
135
|
+
persistKey?: string;
|
|
136
|
+
/** `false`: read and write nothing in localStorage (every reload starts from config). Default: true. */
|
|
137
|
+
persist?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Every third-party server this editor talks to: basemap tiles, glyphs, sprite and elevation,
|
|
140
|
+
* the Picker's Overpass lookups, the Route tool's routing, the search box's geocoder, plus a
|
|
141
|
+
* `fetch` for Element's own requests. Per editor. `false` on a service hides what needs it.
|
|
142
|
+
* Map tiles are read when a basemap loads (changes apply on the next basemap switch). Headers
|
|
143
|
+
* for map resources: the MapLibre drop-in's `mapOptions.transformRequest`.
|
|
144
|
+
* See the "Third-party services and self-hosting" guide.
|
|
145
|
+
*
|
|
146
|
+
* @example network: { routing: { apiKey: ORS_KEY }, nominatim: { url: 'https://geo.example.com/search' } }
|
|
147
|
+
*/
|
|
148
|
+
network?: NetworkConfig;
|
|
149
|
+
/** UI element visibility. All default to true. */
|
|
150
|
+
ui?: {
|
|
151
|
+
/** Drawing action hints in the active toolbar (e.g. "Click and drag to size"). Default: true */
|
|
152
|
+
hints?: boolean;
|
|
153
|
+
/** Data table panel (spreadsheet view of all features). Default: true */
|
|
154
|
+
dataTable?: boolean;
|
|
155
|
+
/** Layers/features list panel. Default: true */
|
|
156
|
+
layerList?: boolean;
|
|
157
|
+
/** Schema editor button. Default: true */
|
|
158
|
+
schemaEditor?: boolean;
|
|
159
|
+
/** GeoJSON editor button. Default: true */
|
|
160
|
+
geojsonEditor?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Open the GeoJSON inspector when the editor mounts (initial state only;
|
|
163
|
+
* the user's toggles win afterwards), in the user's last Dock/Undock mode,
|
|
164
|
+
* docked beside the map by default. `'docked'` behaves like `true` (the
|
|
165
|
+
* dock is the default now). Ignored when
|
|
166
|
+
* `geojsonEditor` is false. With an adapter it sets `codeModalOpen`; render
|
|
167
|
+
* `GeoJSONModal` from it. Default: false
|
|
168
|
+
*/
|
|
169
|
+
geojsonEditorOpen?: boolean | 'docked';
|
|
170
|
+
/** Editor settings button. Default: true */
|
|
171
|
+
settings?: boolean;
|
|
172
|
+
/** "Fit all features" zoom button. Default: true */
|
|
173
|
+
zoomToAll?: boolean;
|
|
174
|
+
/** Click-to-edit zoom level indicator. Default: true */
|
|
175
|
+
zoomIndicator?: boolean;
|
|
176
|
+
/** "Fly to my location" geolocation button. Default: true */
|
|
177
|
+
locateButton?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Where every built-in control goes: a map of slots to ordered entries.
|
|
180
|
+
* Map slots: `topLeft`, `topCenter`, `topRight`, `leftCenter`,
|
|
181
|
+
* `rightCenter`, `bottomLeft`, `bottomCenter`, `bottomRight`; status bar
|
|
182
|
+
* (under the map): `statusLeft`, `statusRight`.
|
|
183
|
+
*
|
|
184
|
+
* An entry is a control id, `'separator'`, or `{ group: [...] }` (one
|
|
185
|
+
* joined pill). A slot is an array, or `{ items, direction }` to pick a
|
|
186
|
+
* direction (map slots; default vertical for `leftCenter`/`rightCenter`,
|
|
187
|
+
* horizontal elsewhere). The first item sits at the slot's edge.
|
|
188
|
+
*
|
|
189
|
+
* Controls not listed are hidden, except `'attribution'`, which stays on
|
|
190
|
+
* the map unless placed in a status slot. A control listed twice stays at
|
|
191
|
+
* its first place. The visibility flags (`zoomToAll`, `dataTable`, …) still
|
|
192
|
+
* apply on top.
|
|
193
|
+
*
|
|
194
|
+
* `'separator'` (a thin divider) only goes inside a group or in a status
|
|
195
|
+
* slot; directly in a map slot there's no surface to draw it on.
|
|
196
|
+
*
|
|
197
|
+
* To move, add or hide a few controls and keep the rest of the default,
|
|
198
|
+
* use {@link withLayout}: `layout: withLayout({ move: { table: 'topRight' } })`.
|
|
199
|
+
* Default: {@link DEFAULT_LAYOUT}.
|
|
200
|
+
*
|
|
201
|
+
* @example layout: { topCenter: ['toolbar'], bottomLeft: ['fitBounds', { group: ['table', 'separator', 'schema'] }], statusRight: ['attribution'] }
|
|
202
|
+
*/
|
|
203
|
+
layout?: LayoutConfig;
|
|
204
|
+
/**
|
|
205
|
+
* Keyboard shortcuts control.
|
|
206
|
+
* Pass `false` to disable shortcuts entirely.
|
|
207
|
+
* Pass `{ enabled, show, mapZoom }` for fine-grained control.
|
|
208
|
+
* Default: `{ enabled: true, show: true, mapZoom: false }`.
|
|
209
|
+
*
|
|
210
|
+
* `mapZoom`: when true, intercepts Cmd/Ctrl + (`+`/`=`) and Cmd/Ctrl + (`-`)
|
|
211
|
+
* to zoom the map (only while the cursor is over the editor and no input
|
|
212
|
+
* is focused). Defaults to false because hijacking the browser's
|
|
213
|
+
* page-zoom shortcut is a behavior change consumers should opt into.
|
|
214
|
+
*/
|
|
215
|
+
keyboardShortcuts?: boolean | {
|
|
216
|
+
enabled?: boolean;
|
|
217
|
+
show?: boolean;
|
|
218
|
+
mapZoom?: boolean;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/** Floating toolbar layout. Its place is the `'toolbar'` entry in `ui.layout`. */
|
|
222
|
+
toolbar?: {
|
|
223
|
+
/**
|
|
224
|
+
* How tool buttons are laid out inside the toolbar.
|
|
225
|
+
* 'vertical' hides the search bar and stacks tools top-to-bottom.
|
|
226
|
+
* Default: 'horizontal'.
|
|
227
|
+
*/
|
|
228
|
+
direction?: 'horizontal' | 'vertical';
|
|
229
|
+
};
|
|
230
|
+
/** Measurement and number display settings. */
|
|
231
|
+
units?: {
|
|
232
|
+
/** Length unit. 'auto' picks metric/imperial from the browser locale. Default: 'auto' */
|
|
233
|
+
length?: 'metric' | 'imperial' | 'auto';
|
|
234
|
+
/** Area unit. 'auto' picks metric/imperial from the browser locale. Default: 'auto' */
|
|
235
|
+
area?: 'metric' | 'imperial' | 'auto';
|
|
236
|
+
/** Number display style. 'human' = "1.2 km", 'raw' = "1234.56 m". Default: 'human' */
|
|
237
|
+
display?: 'human' | 'raw';
|
|
238
|
+
/** Decimal places in 'raw' display mode. Default: 2 */
|
|
239
|
+
precision?: number;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
export interface ResolvedConfig {
|
|
243
|
+
mode: 'light' | 'dark' | 'system';
|
|
244
|
+
/** Storage scope; pass the resolved config itself to the core storage helpers. */
|
|
245
|
+
persistKey: string | undefined;
|
|
246
|
+
persist: boolean;
|
|
247
|
+
/** `config.network` as given (`{}` when absent); `fetch` is a stable wrapper around the latest one. */
|
|
248
|
+
network: NetworkConfig;
|
|
249
|
+
accentColor: string | undefined;
|
|
250
|
+
featureColor: string | undefined;
|
|
251
|
+
tools: DrawTool[] | 'all';
|
|
252
|
+
ui: {
|
|
253
|
+
hints: boolean;
|
|
254
|
+
dataTable: boolean;
|
|
255
|
+
layerList: boolean;
|
|
256
|
+
schemaEditor: boolean;
|
|
257
|
+
geojsonEditor: boolean;
|
|
258
|
+
/** Already false when `geojsonEditor` is false. */
|
|
259
|
+
geojsonEditorOpen: boolean | 'docked';
|
|
260
|
+
settings: boolean;
|
|
261
|
+
zoomToAll: boolean;
|
|
262
|
+
zoomIndicator: boolean;
|
|
263
|
+
locateButton: boolean;
|
|
264
|
+
keyboardShortcuts: {
|
|
265
|
+
enabled: boolean;
|
|
266
|
+
show: boolean;
|
|
267
|
+
mapZoom: boolean;
|
|
268
|
+
};
|
|
269
|
+
/** Every slot, resolved from `ui.layout` (or `DEFAULT_LAYOUT`). Rendering reads only this. */
|
|
270
|
+
layout: ResolvedLayout;
|
|
271
|
+
};
|
|
272
|
+
toolbar: {
|
|
273
|
+
/** The toolbar's slot as a position (tooltip/popup sides, standalone placement). */
|
|
274
|
+
position: ToolbarPosition;
|
|
275
|
+
direction: 'horizontal' | 'vertical';
|
|
276
|
+
};
|
|
277
|
+
units: {
|
|
278
|
+
length: 'metric' | 'imperial' | 'auto';
|
|
279
|
+
area: 'metric' | 'imperial' | 'auto';
|
|
280
|
+
display: 'human' | 'raw';
|
|
281
|
+
precision: number;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Normalise a `ui.layout` map: every slot present, groups as `{ group }`,
|
|
286
|
+
* invalid entries and repeats dropped (first place wins, in `LAYOUT_SLOTS`
|
|
287
|
+
* order then array order) with a dev-only warning, dangling separators gone.
|
|
288
|
+
*/
|
|
289
|
+
export declare function resolveLayout(layout: LayoutConfig): ResolvedLayout;
|
|
290
|
+
/** The slots a control may go to (`'attribution'` only in the status bar, `'toolbar'` / `'applyChanges'` only on the map). */
|
|
291
|
+
export type SlotFor<C extends LayoutControl> = C extends 'attribution' ? StatusSlot : C extends 'toolbar' | 'applyChanges' ? MapSlot : LayoutSlot;
|
|
292
|
+
/** Changes to a layout for {@link withLayout}. */
|
|
293
|
+
export interface LayoutPatch {
|
|
294
|
+
/**
|
|
295
|
+
* Put a control in a slot, wherever it was before (or add it if it wasn't
|
|
296
|
+
* placed). It goes at the end of the slot (farthest from the slot's edge),
|
|
297
|
+
* or first with `{ slot, at: 'start' }`. A control moved out of a group
|
|
298
|
+
* leaves the rest of the group in place.
|
|
299
|
+
*/
|
|
300
|
+
move?: {
|
|
301
|
+
[C in LayoutControl]?: SlotFor<C> | {
|
|
302
|
+
slot: SlotFor<C>;
|
|
303
|
+
at?: 'start' | 'end';
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
/** Take controls off the layout (the feature itself stays; use the `ui` flags to turn it off). Wins over `move`. */
|
|
307
|
+
hide?: readonly LayoutControl[];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* A copy of `base` (default {@link DEFAULT_LAYOUT}) with a few controls moved,
|
|
311
|
+
* added or hidden, so you don't have to relist every other control:
|
|
312
|
+
*
|
|
313
|
+
* @example layout: withLayout({ move: { table: 'topRight', attribution: 'statusRight' }, hide: ['keyboard'] })
|
|
314
|
+
*/
|
|
315
|
+
export declare function withLayout(patch: LayoutPatch, base?: LayoutConfig): LayoutConfig;
|
|
316
|
+
/**
|
|
317
|
+
* Dev-only check that a layout doesn't leave something unreachable by surprise:
|
|
318
|
+
* the drawing toolbar, the "Apply changes" button with `onSubmit`, undo/redo
|
|
319
|
+
* with keyboard shortcuts off. Looks at placement only, so turning a control
|
|
320
|
+
* off with its `ui` flag never counts. Returns one message per gap.
|
|
321
|
+
*/
|
|
322
|
+
export declare function layoutGaps(layout: ResolvedLayout, ctx: {
|
|
323
|
+
readonly: boolean;
|
|
324
|
+
canSubmit: boolean;
|
|
325
|
+
tools: readonly string[] | null;
|
|
326
|
+
shortcuts: boolean;
|
|
327
|
+
}): string[];
|
|
328
|
+
export declare function resolveConfig(config?: ElementEditorConfig): ResolvedConfig;
|
|
329
|
+
/** Runtime user override for units. Persists to localStorage so the choice
|
|
330
|
+
* sticks across reloads. Any provided field overrides the consumer-supplied
|
|
331
|
+
* `config.units.*`; missing fields fall through to the consumer config. */
|
|
332
|
+
export type UnitsOverride = Partial<{
|
|
333
|
+
length: 'metric' | 'imperial' | 'auto';
|
|
334
|
+
area: 'metric' | 'imperial' | 'auto';
|
|
335
|
+
display: 'human' | 'raw';
|
|
336
|
+
precision: number;
|
|
337
|
+
}>;
|
|
338
|
+
interface UnitsContextValue {
|
|
339
|
+
override: UnitsOverride;
|
|
340
|
+
setUnits: (next: UnitsOverride | ((prev: UnitsOverride) => UnitsOverride)) => void;
|
|
341
|
+
resetUnits: () => void;
|
|
342
|
+
}
|
|
343
|
+
export declare function ElementEditorConfigProvider({ config, children, }: {
|
|
344
|
+
config?: ElementEditorConfig;
|
|
345
|
+
children: ReactNode;
|
|
346
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
347
|
+
export declare function useElementEditorConfig(): ResolvedConfig;
|
|
348
|
+
/** Read/write the user's persisted units override. Use this from settings UIs;
|
|
349
|
+
* consumers reading current values should prefer `useElementEditorConfig().units`. */
|
|
350
|
+
export declare function useUnitsOverride(): UnitsContextValue;
|
|
351
|
+
export {};
|