terra-draw 1.0.0-beta.7 → 1.0.0-beta.9
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/dist/adapters/common/base.adapter.d.ts +1 -1
- package/dist/adapters/openlayers.adapter.d.ts +8 -0
- package/dist/common.d.ts +4 -1
- package/dist/extend.d.ts +2 -2
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -2
- package/dist/modes/base.mode.d.ts +3 -1
- package/dist/modes/circle/circle.mode.d.ts +3 -2
- package/dist/modes/freehand/freehand.mode.d.ts +8 -2
- package/dist/modes/linestring/linestring.mode.d.ts +2 -2
- package/dist/modes/point/point.mode.d.ts +2 -2
- package/dist/modes/polygon/polygon.mode.d.ts +2 -2
- package/dist/modes/rectangle/rectangle.mode.d.ts +2 -2
- package/dist/modes/render/render.mode.d.ts +2 -1
- package/dist/modes/sector/sector.mode.d.ts +2 -2
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +2 -2
- package/dist/modes/sensor/sensor.mode.d.ts +2 -2
- package/dist/store/store-feature-validation.d.ts +8 -2
- package/dist/store/store.d.ts +5 -1
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +9 -8
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/dist/validation-reasons.d.ts +13 -0
- package/dist/validations/common-validations.d.ts +2 -0
- package/dist/validations/linestring.validation.d.ts +4 -1
- package/dist/validations/max-size.validation.d.ts +3 -1
- package/dist/validations/min-size.validation.d.ts +3 -1
- package/dist/validations/not-self-intersecting.validation.d.ts +4 -1
- package/dist/validations/point.validation.d.ts +4 -1
- package/dist/validations/polygon.validation.d.ts +8 -2
- package/e2e/package-lock.json +5 -4
- package/e2e/package.json +1 -1
- package/eslint.config.js +31 -0
- package/package.json +13 -27
|
@@ -40,7 +40,7 @@ export declare abstract class TerraDrawBaseAdapter implements TerraDrawAdapter {
|
|
|
40
40
|
* @returns {number} The coordinate precision.
|
|
41
41
|
*/
|
|
42
42
|
getCoordinatePrecision(): number;
|
|
43
|
-
|
|
43
|
+
protected getAdapterListeners(): AdapterListener<BasePointerListener>[];
|
|
44
44
|
/**
|
|
45
45
|
* Unregisters the event listeners for the current drawing mode.
|
|
46
46
|
* This is typically called when switching between drawing modes or
|
|
@@ -25,6 +25,7 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
|
25
25
|
constructor(config: {
|
|
26
26
|
map: Map;
|
|
27
27
|
lib: InjectableOL;
|
|
28
|
+
zIndex?: number;
|
|
28
29
|
} & BaseAdapterConfig);
|
|
29
30
|
private stylingFunction;
|
|
30
31
|
private _lib;
|
|
@@ -47,6 +48,12 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
|
47
48
|
private clearLayers;
|
|
48
49
|
private addFeature;
|
|
49
50
|
private removeFeature;
|
|
51
|
+
/**
|
|
52
|
+
* Sorts an array of DOM elements based on their order in the document, from earliest to latest.
|
|
53
|
+
* @param elements - An array of `HTMLElement` objects to be sorted.
|
|
54
|
+
* @returns A new array of `HTMLElement` objects sorted by their document order.
|
|
55
|
+
*/
|
|
56
|
+
private sortElementsByDOMOrder;
|
|
50
57
|
/**
|
|
51
58
|
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
52
59
|
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
@@ -107,6 +114,7 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
|
107
114
|
* @returns void
|
|
108
115
|
* */
|
|
109
116
|
clear(): void;
|
|
117
|
+
private registeredLayerHandlers;
|
|
110
118
|
register(callbacks: TerraDrawCallbacks): void;
|
|
111
119
|
getCoordinatePrecision(): number;
|
|
112
120
|
unregister(): void;
|
package/dist/common.d.ts
CHANGED
|
@@ -68,7 +68,10 @@ export declare enum UpdateTypes {
|
|
|
68
68
|
type ValidationContext = Pick<TerraDrawModeRegisterConfig, "project" | "unproject" | "coordinatePrecision"> & {
|
|
69
69
|
updateType: UpdateTypes;
|
|
70
70
|
};
|
|
71
|
-
export type Validation = (feature: GeoJSONStoreFeatures, context: ValidationContext) =>
|
|
71
|
+
export type Validation = (feature: GeoJSONStoreFeatures, context: ValidationContext) => {
|
|
72
|
+
valid: boolean;
|
|
73
|
+
reason?: string;
|
|
74
|
+
};
|
|
72
75
|
export type TerraDrawModeState = "unregistered" | "registered" | "started" | "drawing" | "selecting" | "stopped";
|
|
73
76
|
export interface TerraDrawCallbacks {
|
|
74
77
|
getState: () => TerraDrawModeState;
|
package/dist/extend.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TerraDrawBaseAdapter, BaseAdapterConfig } from "./adapters/common/base.adapter";
|
|
2
|
-
import { HexColorStyling, NumericStyling } from "./common";
|
|
2
|
+
import { HexColorStyling, NumericStyling, TerraDrawCallbacks } from "./common";
|
|
3
3
|
import { BaseModeOptions, TerraDrawBaseDrawMode } from "./modes/base.mode";
|
|
4
|
-
export { TerraDrawBaseDrawMode, TerraDrawBaseAdapter, BaseAdapterConfig, NumericStyling, HexColorStyling, BaseModeOptions, };
|
|
4
|
+
export { TerraDrawBaseDrawMode, TerraDrawBaseAdapter, BaseAdapterConfig, NumericStyling, HexColorStyling, BaseModeOptions, TerraDrawCallbacks, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { TerraDrawBaseDrawMode, BaseModeOptions, CustomStyling } from "../base.mode";
|
|
3
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
4
4
|
type TerraDrawPolygonModeKeyEvents = {
|
|
5
5
|
cancel?: KeyboardEvent["key"] | null;
|
|
6
6
|
finish?: KeyboardEvent["key"] | null;
|
|
@@ -53,6 +53,6 @@ export declare class TerraDrawAngledRectangleMode extends TerraDrawBaseDrawMode<
|
|
|
53
53
|
cleanUp(): void;
|
|
54
54
|
/** @internal */
|
|
55
55
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
56
|
-
validateFeature(feature: unknown):
|
|
56
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
57
57
|
}
|
|
58
58
|
export {};
|
|
@@ -40,7 +40,9 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
|
40
40
|
protected setStarted(): void;
|
|
41
41
|
protected setStopped(): void;
|
|
42
42
|
register(config: TerraDrawModeRegisterConfig): void;
|
|
43
|
-
validateFeature(feature: unknown):
|
|
43
|
+
validateFeature(feature: unknown): ReturnType<Validation>;
|
|
44
|
+
private performFeatureValidation;
|
|
45
|
+
protected validateModeFeature(feature: unknown, modeValidationFn: (feature: GeoJSONStoreFeatures) => ReturnType<Validation>): ReturnType<Validation>;
|
|
44
46
|
abstract start(): void;
|
|
45
47
|
abstract stop(): void;
|
|
46
48
|
abstract cleanUp(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor, Projection } from "../../common";
|
|
2
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
2
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
3
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
4
|
type TerraDrawCircleModeKeyEvents = {
|
|
5
5
|
cancel: KeyboardEvent["key"] | null;
|
|
@@ -28,6 +28,7 @@ export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePol
|
|
|
28
28
|
private keyEvents;
|
|
29
29
|
private cursors;
|
|
30
30
|
private startingRadiusKilometers;
|
|
31
|
+
private cursorMovedAfterInitialCursorDown;
|
|
31
32
|
/**
|
|
32
33
|
* Create a new circle mode instance
|
|
33
34
|
* @param options - Options to customize the behavior of the circle mode
|
|
@@ -60,7 +61,7 @@ export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePol
|
|
|
60
61
|
cleanUp(): void;
|
|
61
62
|
/** @internal */
|
|
62
63
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
63
|
-
validateFeature(feature: unknown):
|
|
64
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
64
65
|
private updateCircle;
|
|
65
66
|
}
|
|
66
67
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
4
4
|
type TerraDrawFreehandModeKeyEvents = {
|
|
5
5
|
cancel: KeyboardEvent["key"] | null;
|
|
6
6
|
finish: KeyboardEvent["key"] | null;
|
|
@@ -22,6 +22,8 @@ interface Cursors {
|
|
|
22
22
|
interface TerraDrawFreehandModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
23
23
|
minDistance?: number;
|
|
24
24
|
preventPointsNearClose?: boolean;
|
|
25
|
+
autoClose?: boolean;
|
|
26
|
+
autoCloseTimeout?: number;
|
|
25
27
|
keyEvents?: TerraDrawFreehandModeKeyEvents | null;
|
|
26
28
|
cursors?: Cursors;
|
|
27
29
|
}
|
|
@@ -34,6 +36,10 @@ export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<Freehan
|
|
|
34
36
|
private keyEvents;
|
|
35
37
|
private cursors;
|
|
36
38
|
private preventPointsNearClose;
|
|
39
|
+
private autoClose;
|
|
40
|
+
private autoCloseTimeout;
|
|
41
|
+
private hasLeftStartingPoint;
|
|
42
|
+
private preventNewFeature;
|
|
37
43
|
constructor(options?: TerraDrawFreehandModeOptions<FreehandPolygonStyling>);
|
|
38
44
|
private close;
|
|
39
45
|
/** @internal */
|
|
@@ -58,6 +64,6 @@ export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<Freehan
|
|
|
58
64
|
cleanUp(): void;
|
|
59
65
|
/** @internal */
|
|
60
66
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
61
|
-
validateFeature(feature: unknown):
|
|
67
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
62
68
|
}
|
|
63
69
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
3
|
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
4
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
5
5
|
type TerraDrawLineStringModeKeyEvents = {
|
|
6
6
|
cancel: KeyboardEvent["key"] | null;
|
|
7
7
|
finish: KeyboardEvent["key"] | null;
|
|
@@ -73,6 +73,6 @@ export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineS
|
|
|
73
73
|
cleanUp(): void;
|
|
74
74
|
/** @internal */
|
|
75
75
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
76
|
-
validateFeature(feature: unknown):
|
|
76
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
77
77
|
}
|
|
78
78
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, HexColorStyling, Cursor } from "../../common";
|
|
2
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
2
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
3
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
4
|
type PointModeStyling = {
|
|
5
5
|
pointWidth: NumericStyling;
|
|
@@ -39,6 +39,6 @@ export declare class TerraDrawPointMode extends TerraDrawBaseDrawMode<PointModeS
|
|
|
39
39
|
onDragEnd(): void;
|
|
40
40
|
/** @internal */
|
|
41
41
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
42
|
-
validateFeature(feature: unknown):
|
|
42
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
43
43
|
}
|
|
44
44
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { TerraDrawBaseDrawMode, BaseModeOptions, CustomStyling } from "../base.mode";
|
|
3
3
|
import { BehaviorConfig } from "../base.behavior";
|
|
4
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
4
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
5
5
|
type TerraDrawPolygonModeKeyEvents = {
|
|
6
6
|
cancel?: KeyboardEvent["key"] | null;
|
|
7
7
|
finish?: KeyboardEvent["key"] | null;
|
|
@@ -64,6 +64,6 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
|
|
|
64
64
|
cleanUp(): void;
|
|
65
65
|
/** @internal */
|
|
66
66
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
67
|
-
validateFeature(feature: unknown):
|
|
67
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
68
68
|
}
|
|
69
69
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
2
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
3
3
|
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
4
|
type TerraDrawRectangleModeKeyEvents = {
|
|
5
5
|
cancel: KeyboardEvent["key"] | null;
|
|
@@ -50,6 +50,6 @@ export declare class TerraDrawRectangleMode extends TerraDrawBaseDrawMode<Rectan
|
|
|
50
50
|
cleanUp(): void;
|
|
51
51
|
/** @internal */
|
|
52
52
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
53
|
-
validateFeature(feature: unknown):
|
|
53
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
54
54
|
}
|
|
55
55
|
export {};
|
|
@@ -2,6 +2,7 @@ import { HexColorStyling, NumericStyling, TerraDrawAdapterStyling } from "../../
|
|
|
2
2
|
import { BaseModeOptions, CustomStyling, ModeTypes, TerraDrawBaseDrawMode } from "../base.mode";
|
|
3
3
|
import { BehaviorConfig } from "../base.behavior";
|
|
4
4
|
import { GeoJSONStoreFeatures } from "../../terra-draw";
|
|
5
|
+
import { StoreValidation } from "../../store/store";
|
|
5
6
|
type RenderModeStyling = {
|
|
6
7
|
pointColor: HexColorStyling;
|
|
7
8
|
pointWidth: NumericStyling;
|
|
@@ -47,6 +48,6 @@ export declare class TerraDrawRenderMode extends TerraDrawBaseDrawMode<RenderMod
|
|
|
47
48
|
cleanUp(): void;
|
|
48
49
|
/** @internal */
|
|
49
50
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
50
|
-
validateFeature(feature: unknown):
|
|
51
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
51
52
|
}
|
|
52
53
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { TerraDrawBaseDrawMode, BaseModeOptions, CustomStyling } from "../base.mode";
|
|
3
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
4
4
|
type TerraDrawSectorModeKeyEvents = {
|
|
5
5
|
cancel?: KeyboardEvent["key"] | null;
|
|
6
6
|
finish?: KeyboardEvent["key"] | null;
|
|
@@ -55,6 +55,6 @@ export declare class TerraDrawSectorMode extends TerraDrawBaseDrawMode<SectorPol
|
|
|
55
55
|
cleanUp(): void;
|
|
56
56
|
/** @internal */
|
|
57
57
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
58
|
-
validateFeature(feature: unknown):
|
|
58
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
59
59
|
}
|
|
60
60
|
export {};
|
|
@@ -6,10 +6,10 @@ import { MidPointBehavior } from "./midpoint.behavior";
|
|
|
6
6
|
import { FeatureId } from "../../../store/store";
|
|
7
7
|
export declare class DragFeatureBehavior extends TerraDrawModeBehavior {
|
|
8
8
|
readonly config: BehaviorConfig;
|
|
9
|
-
private readonly
|
|
9
|
+
private readonly featuresAtCursorEvent;
|
|
10
10
|
private readonly selectionPoints;
|
|
11
11
|
private readonly midPoints;
|
|
12
|
-
constructor(config: BehaviorConfig,
|
|
12
|
+
constructor(config: BehaviorConfig, featuresAtCursorEvent: FeatureAtPointerEventBehavior, selectionPoints: SelectionPointBehavior, midPoints: MidPointBehavior);
|
|
13
13
|
private draggedFeatureId;
|
|
14
14
|
private dragPosition;
|
|
15
15
|
startDragging(event: TerraDrawMouseEvent, id: FeatureId): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
|
|
2
2
|
import { TerraDrawBaseDrawMode, BaseModeOptions, CustomStyling } from "../base.mode";
|
|
3
|
-
import { GeoJSONStoreFeatures } from "../../store/store";
|
|
3
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
4
4
|
type TerraDrawSensorModeKeyEvents = {
|
|
5
5
|
cancel?: KeyboardEvent["key"] | null;
|
|
6
6
|
finish?: KeyboardEvent["key"] | null;
|
|
@@ -62,7 +62,7 @@ export declare class TerraDrawSensorMode extends TerraDrawBaseDrawMode<SensorPol
|
|
|
62
62
|
cleanUp(): void;
|
|
63
63
|
/** @internal */
|
|
64
64
|
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
65
|
-
validateFeature(feature: unknown):
|
|
65
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
66
66
|
private getDeltaBearing;
|
|
67
67
|
private notInSector;
|
|
68
68
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Validation } from "../common";
|
|
2
|
+
import { FeatureId, IdStrategy } from "./store";
|
|
2
3
|
export declare const StoreValidationErrors: {
|
|
3
4
|
readonly FeatureHasNoId: "Feature has no id";
|
|
4
5
|
readonly FeatureIsNotObject: "Feature is not object";
|
|
@@ -12,5 +13,10 @@ export declare const StoreValidationErrors: {
|
|
|
12
13
|
readonly FeatureCoordinatesNotAnArray: "Feature coordinates is not an array";
|
|
13
14
|
readonly InvalidModeProperty: "Feature does not have a valid mode property";
|
|
14
15
|
};
|
|
16
|
+
export declare function hasModeProperty(feature: unknown): feature is {
|
|
17
|
+
properties: {
|
|
18
|
+
mode: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
15
21
|
export declare function isValidTimestamp(timestamp: unknown): boolean;
|
|
16
|
-
export declare function isValidStoreFeature(feature: unknown, isValidId: IdStrategy<FeatureId>["isValidId"]):
|
|
22
|
+
export declare function isValidStoreFeature(feature: unknown, isValidId: IdStrategy<FeatureId>["isValidId"]): ReturnType<Validation>;
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Feature, Point, Polygon, LineString } from "geojson";
|
|
2
|
+
import { Validation } from "../common";
|
|
2
3
|
type JSON = string | number | boolean | null | JSONArray | JSONObject;
|
|
3
4
|
export interface JSONObject {
|
|
4
5
|
[member: string]: JSON;
|
|
@@ -8,6 +9,9 @@ type DefinedProperties = Record<string, JSON>;
|
|
|
8
9
|
export type GeoJSONStoreGeometries = Polygon | LineString | Point;
|
|
9
10
|
export type BBoxPolygon = Feature<Polygon, DefinedProperties>;
|
|
10
11
|
export type GeoJSONStoreFeatures = Feature<GeoJSONStoreGeometries, DefinedProperties>;
|
|
12
|
+
export type StoreValidation = {
|
|
13
|
+
id?: FeatureId;
|
|
14
|
+
} & ReturnType<Validation>;
|
|
11
15
|
type StoreChangeEvents = "delete" | "create" | "update" | "styling";
|
|
12
16
|
export type StoreChangeHandler = (ids: FeatureId[], change: StoreChangeEvents) => void;
|
|
13
17
|
export type FeatureId = string | number;
|
|
@@ -33,7 +37,7 @@ export declare class GeoJSONStore<Id extends FeatureId = FeatureId> {
|
|
|
33
37
|
private clone;
|
|
34
38
|
getId(): FeatureId;
|
|
35
39
|
has(id: FeatureId): boolean;
|
|
36
|
-
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) =>
|
|
40
|
+
load(data: GeoJSONStoreFeatures[], featureValidation?: (feature: unknown, tracked?: boolean) => StoreValidation): StoreValidation[];
|
|
37
41
|
search(bbox: BBoxPolygon, filter?: (feature: GeoJSONStoreFeatures) => boolean): GeoJSONStoreFeatures[];
|
|
38
42
|
registerOnChange(onChange: StoreChangeHandler): void;
|
|
39
43
|
getGeometryCopy<T extends GeoJSONStoreGeometries>(id: FeatureId): T;
|