the editable site (validation-lab)

This commit is contained in:
kpgarrod committed 2026-11-21 08:03:55 +01:00
commit 3ac81d5a52
13454 files changed
+2227005

No files matched your search

@@ -0,0 +1,27 @@
import { Position } from "geojson";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { FeatureId } from "../../../store/store";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export declare class CoordinatePointBehavior extends TerraDrawModeBehavior {
private readonly readFeature;
private readonly mutateFeature;
constructor(config: BehaviorConfig, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
setEnabled(enabled: boolean): void;
createOrUpdate({ featureId, featureCoordinates, }: {
featureId: FeatureId;
featureCoordinates: Position[] | Position[][];
}): void;
deletePointsByFeatureIds(features: FeatureId[]): void;
updateOneAtIndex(featureId: FeatureId, index: number, updatedCoordinate: Position): void;
updateAllInPlace({ featureId, featureCoordinates, }: {
featureId: FeatureId;
featureCoordinates: Position[] | Position[][];
}): void;
private createPoints;
private syncCurrentlyDrawing;
private setFeatureCoordinatePoints;
private deleteCoordinatePoints;
private deleteIfPresent;
private deleteOrphanedPoints;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,71 @@
import { TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
import { MidPointBehavior } from "./midpoint.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export type ResizeOptions = "center" | "opposite" | "center-fixed" | "opposite-fixed";
export declare class DragCoordinateResizeBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly pixelDistance;
private readonly selectionPoints;
private readonly midPoints;
private readonly coordinatePoints;
private readonly readFeature;
private readonly mutateFeature;
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
private minimumScale;
private draggedCoordinate;
private centerOrigin;
private oppositeOrigin;
private oppositeClosestBBoxIndex;
private boundingBoxMaps;
private getClosestCoordinate;
private isValidDragWebMercator;
private getSelectedFeatureDataWebMercator;
private centerWebMercatorDrag;
private centerFixedWebMercatorDrag;
private scaleFixedWebMercator;
private oppositeFixedWebMercatorDrag;
private oppositeWebMercatorDrag;
private scaleWebMercator;
private getFeature;
private getNormalisedCoordinates;
private validateScale;
private performWebMercatorScale;
private getBBoxWebMercator;
private getIndexesWebMercator;
/**
* @returns - true if the feature is being dragged (resized), false otherwise
*/
isDragging(): boolean;
/**
* Starts the resizing of the feature
* @param id - feature id of the feature that is being dragged
* @param index - index of the coordinate that is being dragged
* @returns - void
*/
startDragging(id: FeatureId, index: number): void;
/**
* Stops the resizing of the feature
* @returns - void *
*/
stopDragging(): void;
/**
* Returns the index of the coordinate that is going to be dragged
* @param event - cursor event
* @param selectedId - feature id of the feature that is selected
* @returns - the index to be dragged
*/
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
/**
* Resizes the feature based on the cursor event
* @param event - cursor event
* @param resizeOption - the resize option, either "center" or "opposite"
* @returns - true is resize was successful, false otherwise
*/
drag(event: TerraDrawMouseEvent, resizeOption: ResizeOptions): boolean;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,37 @@
import { Snapping, TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
import { MidPointBehavior } from "./midpoint.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { CoordinateSnappingBehavior } from "../../coordinate-snapping.behavior";
import { LineSnappingBehavior } from "../../line-snapping.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export declare class DragCoordinateBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly pixelDistance;
private readonly selectionPoints;
private readonly midPoints;
private readonly coordinatePoints;
private readonly coordinateSnapping;
private readonly lineSnapping;
private readonly readFeature;
private readonly mutateFeature;
private readonly featureSnapping;
constructor(config: BehaviorConfig, pixelDistance: PixelDistanceBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, coordinateSnapping: CoordinateSnappingBehavior, lineSnapping: LineSnappingBehavior, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
private draggedCoordinate;
private getClosestCoordinate;
getDraggable(event: TerraDrawMouseEvent, selectedId: FeatureId): {
dist: number;
index: number;
isFirstOrLastPolygonCoord: boolean;
};
getDraggableIndex(event: TerraDrawMouseEvent, selectedId: FeatureId): number;
private snapCoordinate;
drag(event: TerraDrawMouseEvent, allowSelfIntersection: boolean, snapping: Snapping): boolean;
isDragging(): boolean;
startDragging(id: FeatureId, index: number): void;
stopDragging(): void;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,26 @@
import { TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { FeatureAtPointerEventBehavior } from "./feature-at-pointer-event.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { MidPointBehavior } from "./midpoint.behavior";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly featuresAtCursorEvent;
private readonly selectionPoints;
private readonly midPoints;
private readonly coordinatePoints;
private readonly readFeature;
private readonly mutateFeature;
constructor(config: BehaviorConfig, featuresAtCursorEvent: FeatureAtPointerEventBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
private draggedFeatureId;
private dragPosition;
startDragging(event: TerraDrawMouseEvent, id: FeatureId): void;
stopDragging(): void;
isDragging(): boolean;
canDrag(event: TerraDrawMouseEvent, selectedId: FeatureId): boolean;
drag(event: TerraDrawMouseEvent): false | undefined;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,14 @@
import { TerraDrawMouseEvent } from "../../../common";
import { GeoJSONStoreFeatures } from "../../../store/store";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { ClickBoundingBoxBehavior } from "../../click-bounding-box.behavior";
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
export declare class FeatureAtPointerEventBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly createClickBoundingBox;
private readonly pixelDistance;
constructor(config: BehaviorConfig, createClickBoundingBox: ClickBoundingBoxBehavior, pixelDistance: PixelDistanceBehavior);
find(event: TerraDrawMouseEvent, hasSelection: boolean): {
clickedFeature: GeoJSONStoreFeatures | undefined;
};
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,36 @@
import { Position } from "geojson";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { TerraDrawMouseEvent } from "../../../common";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { PixelDistanceBehavior } from "../../pixel-distance.behavior";
export declare class MidPointBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly selectionPointBehavior;
private readonly coordinatePointBehavior;
private readonly mutateFeature;
private readonly readFeature;
private readonly pixelDistance;
constructor(config: BehaviorConfig, selectionPointBehavior: SelectionPointBehavior, coordinatePointBehavior: CoordinatePointBehavior, mutateFeature: MutateFeatureBehavior, readFeature: ReadFeatureBehavior, pixelDistance: PixelDistanceBehavior);
private _midPoints;
private getMidpointConfig;
get ids(): FeatureId[];
set ids(_: FeatureId[]);
getNearestMidPoint(event: TerraDrawMouseEvent): undefined;
insert({ featureId, midPointId, }: {
featureId: FeatureId;
midPointId: FeatureId;
}): void;
create({ featureCoordinates, featureId, }: {
featureCoordinates: Position[] | Position[][];
featureId: FeatureId;
}): void;
delete(): void;
updateAllInPlace({ featureCoordinates, }: {
featureCoordinates: Position[] | Position[][];
}): undefined;
updateOneAtIndex(index: number, featureCoordinates: Position[] | Position[][]): undefined;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,23 @@
import { TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { SelectionPointBehavior } from "./selection-point.behavior";
import { MidPointBehavior } from "./midpoint.behavior";
import { FeatureId } from "../../../store/store";
import { CoordinatePointBehavior } from "./coordinate-point.behavior";
import { ReadFeatureBehavior } from "../../read-feature.behavior";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export declare class RotateFeatureBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly selectionPoints;
private readonly midPoints;
private readonly coordinatePoints;
private readonly readFeature;
private readonly mutateFeature;
constructor(config: BehaviorConfig, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior, coordinatePoints: CoordinatePointBehavior, readFeature: ReadFeatureBehavior, mutateFeature: MutateFeatureBehavior);
private lastBearing;
private selectedGeometry;
private selectedGeometryCentroid;
private selectedGeometryWebMercatorCentroid;
reset(): void;
rotate(event: TerraDrawMouseEvent, selectedId: FeatureId): false | undefined;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,11 @@
import { TerraDrawMouseEvent } from "../../../common";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { FeatureId } from "../../../store/store";
import { DragCoordinateResizeBehavior } from "./drag-coordinate-resize.behavior";
export declare class ScaleFeatureBehavior extends TerraDrawModeBehavior {
readonly config: BehaviorConfig;
private readonly dragCoordinateResizeBehavior;
constructor(config: BehaviorConfig, dragCoordinateResizeBehavior: DragCoordinateResizeBehavior);
scale(event: TerraDrawMouseEvent, featureId: FeatureId): void;
reset(): void;
}
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,27 @@
import { Position } from "geojson";
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
import { FeatureId } from "../../../store/store";
import { SELECT_PROPERTIES } from "../../../common";
import { MutateFeatureBehavior } from "../../mutate-feature.behavior";
export type SelectionPointProperties = {
mode: string;
index: number;
[SELECT_PROPERTIES.SELECTION_POINT_FEATURE_ID]: string;
[SELECT_PROPERTIES.SELECTION_POINT]: true;
};
export declare class SelectionPointBehavior extends TerraDrawModeBehavior {
constructor(config: BehaviorConfig, mutateFeatureBehavior: MutateFeatureBehavior);
private mutateFeature;
private _selectionPoints;
get ids(): FeatureId[];
set ids(_: FeatureId[]);
create({ featureId, featureCoordinates, }: {
featureId: FeatureId;
featureCoordinates: Position[] | Position[][];
}): void;
delete(): void;
updateAllInPlace({ featureCoordinates, }: {
featureCoordinates: Position[] | Position[][];
}): void;
updateOneAtIndex(index: number, updatedCoordinate: Position): void;
}
@@ -0,0 +1 @@
export {};
+153
View File
@@ -0,0 +1,153 @@
import { TerraDrawMouseEvent, TerraDrawKeyboardEvent, TerraDrawAdapterStyling, HexColorStyling, NumericStyling, Cursor, Validation, Snapping, UrlStyling, DashArrayStyling, MarkerAnchorStyling } from "../../common";
import { BaseModeOptions, CustomStyling, ModeUpdateOptions, TerraDrawBaseSelectMode } from "../base.mode";
import { BehaviorConfig } from "../base.behavior";
import { FeatureId, GeoJSONStoreFeatures } from "../../store/store";
import { ResizeOptions } from "./behaviors/drag-coordinate-resize.behavior";
type TerraDrawSelectModeKeyEvents = {
deselect: KeyboardEvent["key"] | null;
delete: KeyboardEvent["key"] | null;
rotate: KeyboardEvent["key"][] | null;
scale: KeyboardEvent["key"][] | null;
};
type ModeFlags = {
feature?: {
validation?: Validation;
draggable?: boolean;
rotateable?: boolean;
scaleable?: boolean;
selfIntersectable?: boolean;
coordinates?: {
snappable?: boolean | Snapping;
midpoints?: boolean | {
draggable?: boolean;
};
draggable?: boolean;
resizable?: ResizeOptions;
deletable?: boolean;
};
};
};
type SelectionStyling = {
selectedPointColor: HexColorStyling;
selectedPointWidth: NumericStyling;
selectedPointOpacity: NumericStyling;
selectedPointOutlineColor: HexColorStyling;
selectedPointOutlineWidth: NumericStyling;
selectedPointOutlineOpacity: NumericStyling;
selectedMarkerUrl: UrlStyling;
selectedMarkerHeight: NumericStyling;
selectedMarkerWidth: NumericStyling;
selectedMarkerAnchor: MarkerAnchorStyling;
selectedLineStringColor: HexColorStyling;
selectedLineStringWidth: NumericStyling;
selectedLineStringOpacity: NumericStyling;
selectedLineStringDash: DashArrayStyling;
selectedPolygonColor: HexColorStyling;
selectedPolygonFillOpacity: NumericStyling;
selectedPolygonOutlineColor: HexColorStyling;
selectedPolygonOutlineOpacity: NumericStyling;
selectedPolygonOutlineWidth: NumericStyling;
selectionPointWidth: NumericStyling;
selectionPointColor: HexColorStyling;
selectionPointOpacity: NumericStyling;
selectionPointOutlineColor: HexColorStyling;
selectionPointOutlineWidth: NumericStyling;
selectionPointOutlineOpacity: NumericStyling;
midPointColor: HexColorStyling;
midPointOutlineColor: HexColorStyling;
midPointOpacity: NumericStyling;
midPointWidth: NumericStyling;
midPointOutlineWidth: NumericStyling;
midPointOutlineOpacity: NumericStyling;
};
interface Cursors {
pointerOver?: Cursor;
pointerOverFeature?: Cursor;
pointerOverCoordinate?: Cursor;
pointerOverResizeHandle?: Cursor;
dragStart?: Cursor;
dragEnd?: Cursor;
insertMidpoint?: Cursor;
}
interface TerraDrawSelectModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
pointerDistance?: number;
flags?: {
[mode: string]: ModeFlags;
};
keyEvents?: TerraDrawSelectModeKeyEvents | null;
dragEventThrottle?: number;
cursors?: Cursors;
allowManualDeselection?: boolean;
allowManualSelection?: boolean;
}
export declare class TerraDrawSelectMode extends TerraDrawBaseSelectMode<SelectionStyling> {
mode: string;
private allowManualDeselection;
private allowManualSelection;
private dragEventThrottle;
private dragEventCount;
private selected;
private flags;
private keyEvents;
private cursors;
private validations;
private dragTarget;
private selectionPoints;
private midPoints;
private coordinateSnap;
private featuresAtMouseEvent;
private pixelDistance;
private clickBoundingBox;
private dragFeature;
private dragCoordinate;
private rotateFeature;
private scaleFeature;
private dragCoordinateResizeFeature;
private coordinatePoints;
private lineSnap;
private mutateFeature;
private readFeature;
private getPointerOverFeatureCursor;
private getPointerOverCoordinateCursor;
private getPointerOverResizeHandleCursor;
constructor(options?: TerraDrawSelectModeOptions<SelectionStyling>);
updateOptions(options?: ModeUpdateOptions<TerraDrawSelectModeOptions<SelectionStyling>>): void;
selectFeature(featureId: FeatureId): void;
setSelecting(): void;
registerBehaviors(config: BehaviorConfig): void;
deselectFeature(id: FeatureId): void;
private deselect;
private deleteSelected;
private clearDragTargetAndCursor;
private getSelectedFlags;
private onRightClick;
private select;
private onLeftClick;
/** @internal */
start(): void;
/** @internal */
stop(): void;
/** @internal */
onClick(event: TerraDrawMouseEvent): void;
private canScale;
private canRotate;
private preventDefaultKeyEvent;
/** @internal */
onKeyDown(event: TerraDrawKeyboardEvent): void;
/** @internal */
onKeyUp(event: TerraDrawKeyboardEvent): void;
/** @internal */
cleanUp(): void;
/** @internal */
onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
/** @internal */
onDrag(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
/** @internal */
onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
/** @internal */
onMouseMove(event: TerraDrawMouseEvent): void;
/** @internal */
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
afterFeatureUpdated(feature: GeoJSONStoreFeatures): void;
}
export {};
+1
View File
@@ -0,0 +1 @@
export {};