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

+22
View File
@@ -0,0 +1,22 @@
export declare class AdapterListener<Callback extends (...args: any[]) => any> {
name: string;
callback: (...args: any[]) => any;
registered: boolean;
register: any;
unregister: any;
/**
* Creates a new AdapterListener instance with the provided configuration.
*
* @param {Object} config - The configuration object for the listener.
* @param {string} config.name - The name of the event listener.
* @param {Function} config.callback - The callback function to be called when the event is triggered.
* @param {Function} config.unregister - The function to unregister the event listeners.
* @param {Function} config.register - The function to register the event listeners.
*/
constructor({ name, callback, unregister, register, }: {
name: string;
callback: Callback;
unregister: (callbacks: Callback) => void;
register: (callback: Callback) => void;
});
}
+1
View File
@@ -0,0 +1 @@
export {};
+63
View File
@@ -0,0 +1,63 @@
import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction, GetLngLatFromEvent, TerraDrawAdapter, TerraDrawHandledEvents } from "../common";
import { AdapterListener } from "./adapter-listener";
type BasePointerListener = (event: PointerEvent) => void;
type BaseKeyboardListener = (event: KeyboardEvent) => void;
type BaseMouseListener = (event: MouseEvent) => void;
export type BaseAdapterConfig = {
ignoreMismatchedPointerEvents?: boolean;
coordinatePrecision?: number;
minPixelDragDistanceDrawing?: number;
minPixelDragDistance?: number;
minPixelDragDistanceSelecting?: number;
};
export declare abstract class TerraDrawBaseAdapter implements TerraDrawAdapter {
constructor(config: BaseAdapterConfig);
private _nextKeyUpIsContextMenu;
private _lastPointerDownEventTarget;
protected _ignoreMismatchedPointerEvents: boolean;
protected _minPixelDragDistance: number;
protected _minPixelDragDistanceDrawing: number;
protected _minPixelDragDistanceSelecting: number;
protected _lastDrawEvent: TerraDrawMouseEvent | undefined;
protected _coordinatePrecision: number;
protected _heldKeys: Set<string>;
protected _listeners: AdapterListener<BasePointerListener | BaseKeyboardListener | BaseMouseListener>[];
protected _dragState: "not-dragging" | "pre-dragging" | "dragging";
protected _currentModeCallbacks: TerraDrawCallbacks | undefined;
abstract getMapEventElement(eventType?: TerraDrawHandledEvents): HTMLElement;
protected getButton(event: PointerEvent | MouseEvent): "left" | "right" | "neither" | "middle";
protected getMapElementXYPosition(event: PointerEvent | MouseEvent): {
containerX: number;
containerY: number;
};
protected getDrawEventFromEvent(event: PointerEvent | MouseEvent, isContextMenu?: boolean): TerraDrawMouseEvent | null;
/**
* Registers the provided callbacks for the current drawing mode and attaches
* the necessary event listeners.
* @param {TerraDrawCallbacks} callbacks - An object containing callback functions
* for handling various drawing events in the current mode.
*/
register(callbacks: TerraDrawCallbacks): void;
/**
* Gets the coordinate precision. The coordinate precision is the number of decimal places in geometry
* coordinates stored in the store.
* @returns {number} The coordinate precision.
*/
getCoordinatePrecision(): number;
protected getAdapterListeners(): AdapterListener<BasePointerListener>[];
/**
* Unregisters the event listeners for the current drawing mode.
* This is typically called when switching between drawing modes or
* stopping the drawing process.
*/
unregister(): void;
abstract clear(): void;
abstract project(...args: Parameters<Project>): ReturnType<Project>;
abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
abstract getLngLatFromEvent(...event: Parameters<GetLngLatFromEvent>): ReturnType<GetLngLatFromEvent>;
abstract setDraggability(enabled: boolean): void;
abstract setDoubleClickToZoom(enabled: boolean): void;
abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
}
export {};
+52
View File
@@ -0,0 +1,52 @@
import type { DrawInteractions } from "../common";
type Check<T> = (value: unknown) => value is T;
/**
* Checks whether a value is a finite, non-negative number.
*
* @param value - The value to validate.
* @returns True when the value is a number >= 0 and finite.
*/
export declare const isFiniteNonNegativeNumber: Check<number>;
/**
* Checks whether a value is a boolean.
*
* @param value - The value to validate.
* @returns True when the value is either true or false.
*/
export declare const isBoolean: Check<boolean>;
/**
* Checks whether a value is null.
*
* @param value - The value to validate.
* @returns True when the value is null.
*/
export declare const isNull: Check<null>;
/**
* Checks whether a value is a non-null object.
*
* @param value - The value to validate.
* @returns True when the value is an object and not null.
*/
export declare const isNonNullObject: Check<Record<string, unknown>>;
/**
* Checks whether a value is a function.
*
* @param value - The value to validate.
* @returns True when the value is a callable function.
*/
export declare const isFunction: Check<Function>;
/**
* Checks whether a value is a string with at least one character.
*
* @param value - The value to validate.
* @returns True when the value is a non-empty string.
*/
export declare const isNonEmptyString: Check<string>;
/**
* Checks whether a value is a supported draw interaction string.
*
* @param value - The value to validate.
* @returns True when the value is one of the DrawInteractions literals.
*/
export declare const isDrawInteraction: Check<DrawInteractions>;
export {};
+1
View File
@@ -0,0 +1 @@
export {};
+8
View File
@@ -0,0 +1,8 @@
export declare const CursorValues: {
readonly Crosshair: "crosshair";
readonly Pointer: "pointer";
readonly Grab: "grab";
readonly Grabbing: "grabbing";
readonly Move: "move";
readonly Unset: "unset";
};
+7
View File
@@ -0,0 +1,7 @@
declare const KeyboardEventKey: {
readonly Enter: "Enter";
readonly Escape: "Escape";
readonly Backspace: "Backspace";
readonly Delete: "Delete";
};
export { KeyboardEventKey };