UNPKG

leaflet-polydraw

Version:

Advanced Leaflet plugin for freehand polygon drawing, with smart merging and powerful editing tools. Compatible with both Leaflet v1.x and v2.x.

97 lines 2.86 kB
import { DrawMode } from '../enums'; import type { PolydrawConfig } from '../types/polydraw-interfaces'; import { EventManager } from './event-manager'; /** * Represents the current state of all user interactions in Polydraw */ export interface InteractionState { polygonDragging: boolean; markerDragging: boolean; edgeClicking: boolean; polygonClicking: boolean; canStartDrawing: boolean; canCompletePolygon: boolean; mapDragging: boolean; mapZooming: boolean; mapDoubleClickZoom: boolean; currentMode: DrawMode; isDrawingActive: boolean; isModifierKeyHeld: boolean; showCrosshairCursor: boolean; showDragCursor: boolean; } /** * Centralized manager for all interaction states in Polydraw. * Acts as a single source of truth for what interactions are enabled/disabled. */ export declare class ModeManager { private state; private config; private eventManager; constructor(config: PolydrawConfig, eventManager: EventManager); /** * Create the initial interaction state */ private createInitialState; /** * Update the interaction state when the draw mode changes */ updateStateForMode(mode: DrawMode): void; /** * Set interaction state for Off mode (normal editing) */ private setOffModeState; /** * Set interaction state for drawing modes (Add, Subtract) */ private setDrawingModeState; /** * Set interaction state for Point-to-Point mode */ private setPointToPointModeState; /** * Set interaction state for clone mode (drag to duplicate) */ private setCloneModeState; /** * Update modifier key state */ setModifierKeyState(isHeld: boolean): void; /** * Check if a specific action is currently allowed */ canPerformAction(action: InteractionAction): boolean; /** * Check if any drawing mode is active */ isInDrawingMode(): boolean; /** * Check if currently in Off mode (normal editing) */ isInOffMode(): boolean; /** * Get the current draw mode */ getCurrentMode(): DrawMode; /** * Get read-only access to the current state */ getState(): Readonly<InteractionState>; /** * Check if crosshair cursor should be shown */ shouldShowCrosshairCursor(): boolean; /** * Check if drag cursor should be shown */ shouldShowDragCursor(): boolean; /** * Update configuration and recalculate state */ updateConfig(config: PolydrawConfig): void; } /** * All possible interaction actions that can be checked */ export type InteractionAction = 'polygonDrag' | 'markerDrag' | 'edgeClick' | 'polygonClick' | 'startDrawing' | 'completePolygon' | 'mapDrag' | 'mapZoom' | 'mapDoubleClickZoom'; //# sourceMappingURL=mode-manager.d.ts.map