terra-draw 0.0.1-alpha.43 → 0.0.1-alpha.45

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +2 -1
  3. package/dist/adapters/common/base.adapter.d.ts +2 -0
  4. package/dist/common.d.ts +5 -1
  5. package/dist/modes/circle/circle.mode.d.ts +9 -4
  6. package/dist/modes/freehand/freehand.mode.d.ts +7 -1
  7. package/dist/modes/greatcircle/great-circle.mode.d.ts +7 -1
  8. package/dist/modes/linestring/linestring.mode.d.ts +7 -1
  9. package/dist/modes/point/point.mode.d.ts +6 -1
  10. package/dist/modes/polygon/polygon.mode.d.ts +7 -1
  11. package/dist/modes/rectangle/rectangle.mode.d.ts +6 -1
  12. package/dist/modes/render/render.mode.d.ts +1 -0
  13. package/dist/modes/select/select.mode.d.ts +9 -1
  14. package/dist/terra-draw.cjs +1 -1
  15. package/dist/terra-draw.cjs.map +1 -1
  16. package/dist/terra-draw.d.ts +1 -3
  17. package/dist/terra-draw.modern.js +1 -1
  18. package/dist/terra-draw.modern.js.map +1 -1
  19. package/dist/terra-draw.module.js +1 -1
  20. package/dist/terra-draw.module.js.map +1 -1
  21. package/dist/terra-draw.umd.js +1 -1
  22. package/dist/terra-draw.umd.js.map +1 -1
  23. package/guides/COMMON_PATTERNS.md +157 -0
  24. package/guides/GETTING_STARTED.md +13 -129
  25. package/package.json +2 -1
  26. package/scratch/release.sh +5 -5
  27. package/dist/adapters/common/base-adapter.d.ts +0 -31
  28. package/dist/bundle.js +0 -6
  29. package/dist/bundle.js.LICENSE.txt +0 -4
  30. package/dist/extend-types.d.ts +0 -4
  31. package/dist/geometry/create-circle.d.ts +0 -6
  32. package/dist/geometry/get-pixel-distance-to-line.d.ts +0 -10
  33. package/dist/geometry/get-pixel-distance.d.ts +0 -7
  34. package/dist/geometry/haversine-distance.d.ts +0 -1
  35. package/dist/geometry/point-in-polygon.d.ts +0 -1
  36. package/dist/geometry/self-intersects.d.ts +0 -2
  37. package/dist/modes/circle.mode.d.ts +0 -18
  38. package/dist/modes/freehand.mode.d.ts +0 -20
  39. package/dist/modes/line-string.mode.d.ts +0 -21
  40. package/dist/modes/point.mode.d.ts +0 -14
  41. package/dist/modes/polygon/behaviors/start-end-point.behavior.d.ts +0 -11
  42. package/dist/modes/polygon.mode.d.ts +0 -21
  43. package/dist/modes/select.mode.d.ts +0 -21
  44. package/dist/modes/static.mode.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.1-alpha.45](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.44...v0.0.1-alpha.45) (2023-08-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * add basic tests for arcgis maps sdk adapter ([7fe12a3](https://github.com/JamesLMilner/terra-draw/commit/7fe12a3eb583b39bca409671f2c55e144cb17be9))
11
+ * add Esri ArcGIS Maps SDK adapter ([0fece22](https://github.com/JamesLMilner/terra-draw/commit/0fece229c6ccd3fb573b634f6c5314c3192da76d))
12
+ * add tests for render method ([14a3733](https://github.com/JamesLMilner/terra-draw/commit/14a3733c373a222bea569735eff4eb2f4c793587))
13
+ * adjust styling to equal other map adapters ([2d07973](https://github.com/JamesLMilner/terra-draw/commit/2d07973fa24d96943064c444d18beb227615dd87))
14
+ * allow cursors to be configured for built in modes ([57a5db2](https://github.com/JamesLMilner/terra-draw/commit/57a5db299b6424f7375a852c231fde0d6e0a4131))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * better registration of selections by ignoring microdrags even when not drawing ([cd7a8ea](https://github.com/JamesLMilner/terra-draw/commit/cd7a8eaac209ba95784a961d823f7693038dd2ff))
20
+ * pass modes as array rather than object ([80885cc](https://github.com/JamesLMilner/terra-draw/commit/80885cc62a15ec9ef32cf739771628cb2fe6edb2))
21
+
22
+
23
+ ### Chore
24
+
25
+ * add ArcGIS JavaScript SDK to the README ([1801e50](https://github.com/JamesLMilner/terra-draw/commit/1801e5003a2d3b079c641d323d1ac70ccca58b36))
26
+ * split out common patterns guide to its own file ([ef721cf](https://github.com/JamesLMilner/terra-draw/commit/ef721cf0385d9d3754a5a951fc930c1792405401))
27
+ * update docs ([f1d1832](https://github.com/JamesLMilner/terra-draw/commit/f1d1832a5a95003a422d7e129c56e4c295a25e44))
28
+
29
+ ### [0.0.1-alpha.44](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.43...v0.0.1-alpha.44) (2023-07-25)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * ensure that coordinate precision is limited when dragging a feature ([b7da22a](https://github.com/JamesLMilner/terra-draw/commit/b7da22a7ab4db2f5daec4db916997a02dc2c0193))
35
+
36
+
37
+ ### Chore
38
+
39
+ * naive handling of antimeridian crossing for dragging coordinates ([8cdb7ab](https://github.com/JamesLMilner/terra-draw/commit/8cdb7ab5dc124d8240dee6378c5d3f194d2716bc))
40
+
5
41
  ### [0.0.1-alpha.43](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.42...v0.0.1-alpha.43) (2023-07-24)
6
42
 
7
43
 
package/README.md CHANGED
@@ -18,10 +18,11 @@ Terra Draw uses the concept of 'adapters' to allow it to work with a host of dif
18
18
  - [Mapbox GL JS](https://www.mapbox.com/mapbox-gljs) v2
19
19
  - [MapLibre](https://maplibre.org/projects/maplibre-gl-js/) v2/v3
20
20
  - [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/overview) v3
21
+ - [ArcGIS JavaScript SDK](https://developers.arcgis.com/javascript/latest/) v4 (MapView)
21
22
 
22
23
  ### Getting Started
23
24
 
24
- Please see the [the getting started guide](./guides/GETTING_STARTED.md)
25
+ Please see the [the getting started guide](./guides/GETTING_STARTED.md) - this provides a host of information on how get up and running with Terra Draw. You may also find some useful pointers for things you may be finding yourself wanting to do in the [common patterns guide](./guides/COMMON_PATTERNS.md).
25
26
 
26
27
  ### Development
27
28
 
@@ -6,9 +6,11 @@ type BaseMouseListener = (event: MouseEvent) => void;
6
6
  export declare abstract class TerraDrawBaseAdapter {
7
7
  constructor(config: {
8
8
  coordinatePrecision?: number;
9
+ minPixelDragDistanceDrawing?: number;
9
10
  minPixelDragDistance?: number;
10
11
  });
11
12
  protected _minPixelDragDistance: number;
13
+ protected _minPixelDragDistanceDrawing: number;
12
14
  protected _lastDrawEvent: TerraDrawMouseEvent | undefined;
13
15
  protected _coordinatePrecision: number;
14
16
  protected _heldKeys: Set<string>;
package/dist/common.d.ts CHANGED
@@ -28,7 +28,11 @@ export interface TerraDrawKeyboardEvent {
28
28
  heldKeys: string[];
29
29
  preventDefault: () => void;
30
30
  }
31
- export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer" | "wait") => void;
31
+ export type Required<T> = {
32
+ [P in keyof T]-?: T[P];
33
+ };
34
+ export type Cursor = Parameters<SetCursor>[0];
35
+ export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer" | "wait" | "move") => void;
32
36
  export type Project = (lng: number, lat: number) => {
33
37
  x: number;
34
38
  y: number;
@@ -1,25 +1,30 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { GeoJSONStoreFeatures } from "../../store/store";
3
3
  import { TerraDrawBaseDrawMode } from "../base.mode";
4
4
  type TerraDrawCircleModeKeyEvents = {
5
5
  cancel: KeyboardEvent["key"] | null;
6
6
  finish: KeyboardEvent["key"] | null;
7
7
  };
8
- type FreehandPolygonStyling = {
8
+ type CirclePolygonStyling = {
9
9
  fillColor: HexColorStyling;
10
10
  outlineColor: HexColorStyling;
11
11
  outlineWidth: NumericStyling;
12
12
  fillOpacity: NumericStyling;
13
13
  };
14
- export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> {
14
+ interface Cursors {
15
+ start?: Cursor;
16
+ }
17
+ export declare class TerraDrawCircleMode extends TerraDrawBaseDrawMode<CirclePolygonStyling> {
15
18
  mode: string;
16
19
  private center;
17
20
  private clickCount;
18
21
  private currentCircleId;
19
22
  private keyEvents;
23
+ private cursors;
20
24
  constructor(options?: {
21
- styles?: Partial<FreehandPolygonStyling>;
25
+ styles?: Partial<CirclePolygonStyling>;
22
26
  keyEvents?: TerraDrawCircleModeKeyEvents | null;
27
+ cursors?: Cursors;
23
28
  });
24
29
  private close;
25
30
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { TerraDrawBaseDrawMode } from "../base.mode";
3
3
  import { GeoJSONStoreFeatures } from "../../store/store";
4
4
  type TerraDrawFreehandModeKeyEvents = {
@@ -15,6 +15,10 @@ type FreehandPolygonStyling = {
15
15
  closingPointOutlineColor: HexColorStyling;
16
16
  closingPointOutlineWidth: NumericStyling;
17
17
  };
18
+ interface Cursors {
19
+ start?: Cursor;
20
+ close?: Cursor;
21
+ }
18
22
  export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> {
19
23
  mode: string;
20
24
  private startingClick;
@@ -22,10 +26,12 @@ export declare class TerraDrawFreehandMode extends TerraDrawBaseDrawMode<Freehan
22
26
  private closingPointId;
23
27
  private minDistance;
24
28
  private keyEvents;
29
+ private cursors;
25
30
  constructor(options?: {
26
31
  styles?: Partial<FreehandPolygonStyling>;
27
32
  minDistance?: number;
28
33
  keyEvents?: TerraDrawFreehandModeKeyEvents | null;
34
+ cursors?: Cursors;
29
35
  });
30
36
  private close;
31
37
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { TerraDrawBaseDrawMode } from "../base.mode";
3
3
  import { BehaviorConfig } from "../base.behavior";
4
4
  import { GeoJSONStoreFeatures } from "../../store/store";
@@ -14,6 +14,10 @@ type GreateCircleStyling = {
14
14
  closingPointOutlineColor: HexColorStyling;
15
15
  closingPointOutlineWidth: NumericStyling;
16
16
  };
17
+ interface Cursors {
18
+ start?: Cursor;
19
+ close?: Cursor;
20
+ }
17
21
  export declare class TerraDrawGreatCircleMode extends TerraDrawBaseDrawMode<GreateCircleStyling> {
18
22
  mode: string;
19
23
  private currentCoordinate;
@@ -21,12 +25,14 @@ export declare class TerraDrawGreatCircleMode extends TerraDrawBaseDrawMode<Grea
21
25
  private closingPointId;
22
26
  private keyEvents;
23
27
  private snappingEnabled;
28
+ private cursors;
24
29
  private snapping;
25
30
  constructor(options?: {
26
31
  snapping?: boolean;
27
32
  pointerDistance?: number;
28
33
  styles?: Partial<GreateCircleStyling>;
29
34
  keyEvents?: TerraDrawGreateCircleModeKeyEvents | null;
35
+ cursors?: Cursors;
30
36
  });
31
37
  private close;
32
38
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { TerraDrawBaseDrawMode } from "../base.mode";
3
3
  import { BehaviorConfig } from "../base.behavior";
4
4
  import { GeoJSONStoreFeatures } from "../../store/store";
@@ -14,6 +14,10 @@ type LineStringStyling = {
14
14
  closingPointOutlineColor: HexColorStyling;
15
15
  closingPointOutlineWidth: NumericStyling;
16
16
  };
17
+ interface Cursors {
18
+ start?: Cursor;
19
+ close?: Cursor;
20
+ }
17
21
  export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineStringStyling> {
18
22
  mode: string;
19
23
  private currentCoordinate;
@@ -22,6 +26,7 @@ export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineS
22
26
  private allowSelfIntersections;
23
27
  private keyEvents;
24
28
  private snappingEnabled;
29
+ private cursors;
25
30
  private mouseMove;
26
31
  private snapping;
27
32
  constructor(options?: {
@@ -30,6 +35,7 @@ export declare class TerraDrawLineStringMode extends TerraDrawBaseDrawMode<LineS
30
35
  pointerDistance?: number;
31
36
  styles?: Partial<LineStringStyling>;
32
37
  keyEvents?: TerraDrawLineStringModeKeyEvents | null;
38
+ cursors?: Cursors;
33
39
  });
34
40
  private close;
35
41
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, HexColorStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, HexColorStyling, Cursor } from "../../common";
2
2
  import { GeoJSONStoreFeatures } from "../../store/store";
3
3
  import { TerraDrawBaseDrawMode } from "../base.mode";
4
4
  type PointModeStyling = {
@@ -7,10 +7,15 @@ type PointModeStyling = {
7
7
  pointOutlineColor: HexColorStyling;
8
8
  pointOutlineWidth: NumericStyling;
9
9
  };
10
+ interface Cursors {
11
+ create?: Cursor;
12
+ }
10
13
  export declare class TerraDrawPointMode extends TerraDrawBaseDrawMode<PointModeStyling> {
11
14
  mode: string;
15
+ private cursors;
12
16
  constructor(options?: {
13
17
  styles?: Partial<PointModeStyling>;
18
+ cursors?: Cursors;
14
19
  });
15
20
  /** @internal */
16
21
  start(): void;
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { TerraDrawBaseDrawMode } from "../base.mode";
3
3
  import { BehaviorConfig } from "../base.behavior";
4
4
  import { GeoJSONStoreFeatures } from "../../store/store";
@@ -16,6 +16,10 @@ type PolygonStyling = {
16
16
  closingPointOutlineWidth: NumericStyling;
17
17
  closingPointOutlineColor: HexColorStyling;
18
18
  };
19
+ interface Cursors {
20
+ start?: Cursor;
21
+ close?: Cursor;
22
+ }
19
23
  export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonStyling> {
20
24
  mode: string;
21
25
  private currentCoordinate;
@@ -26,6 +30,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
26
30
  private snapping;
27
31
  private pixelDistance;
28
32
  private closingPoints;
33
+ private cursors;
29
34
  private mouseMove;
30
35
  constructor(options?: {
31
36
  allowSelfIntersections?: boolean;
@@ -33,6 +38,7 @@ export declare class TerraDrawPolygonMode extends TerraDrawBaseDrawMode<PolygonS
33
38
  pointerDistance?: number;
34
39
  styles?: Partial<PolygonStyling>;
35
40
  keyEvents?: TerraDrawPolygonModeKeyEvents | null;
41
+ cursors?: Cursors;
36
42
  });
37
43
  private close;
38
44
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawAdapterStyling, TerraDrawKeyboardEvent, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { GeoJSONStoreFeatures } from "../../store/store";
3
3
  import { TerraDrawBaseDrawMode } from "../base.mode";
4
4
  type TerraDrawRectangleModeKeyEvents = {
@@ -11,15 +11,20 @@ type RectanglePolygonStyling = {
11
11
  outlineWidth: NumericStyling;
12
12
  fillOpacity: NumericStyling;
13
13
  };
14
+ interface Cursors {
15
+ start?: Cursor;
16
+ }
14
17
  export declare class TerraDrawRectangleMode extends TerraDrawBaseDrawMode<RectanglePolygonStyling> {
15
18
  mode: string;
16
19
  private center;
17
20
  private clickCount;
18
21
  private currentRectangleId;
19
22
  private keyEvents;
23
+ private cursors;
20
24
  constructor(options?: {
21
25
  styles?: Partial<RectanglePolygonStyling>;
22
26
  keyEvents?: TerraDrawRectangleModeKeyEvents | null;
27
+ cursors?: Cursors;
23
28
  });
24
29
  private updateRectangle;
25
30
  private close;
@@ -19,6 +19,7 @@ export declare class TerraDrawRenderMode extends TerraDrawBaseDrawMode<RenderMod
19
19
  type: ModeTypes;
20
20
  mode: string;
21
21
  constructor(options: {
22
+ modeName: string;
22
23
  styles: Partial<RenderModeStyling>;
23
24
  });
24
25
  /** @internal */
@@ -1,4 +1,4 @@
1
- import { TerraDrawMouseEvent, TerraDrawKeyboardEvent, TerraDrawAdapterStyling, HexColorStyling, NumericStyling } from "../../common";
1
+ import { TerraDrawMouseEvent, TerraDrawKeyboardEvent, TerraDrawAdapterStyling, HexColorStyling, NumericStyling, Cursor } from "../../common";
2
2
  import { ModeTypes, TerraDrawBaseDrawMode } from "../base.mode";
3
3
  import { BehaviorConfig } from "../base.behavior";
4
4
  import { GeoJSONStoreFeatures } from "../../store/store";
@@ -40,6 +40,12 @@ type SelectionStyling = {
40
40
  midPointWidth: NumericStyling;
41
41
  midPointOutlineWidth: NumericStyling;
42
42
  };
43
+ interface Cursors {
44
+ pointerOver?: Cursor;
45
+ dragStart?: Cursor;
46
+ dragEnd?: Cursor;
47
+ insertMidpoint?: Cursor;
48
+ }
43
49
  export declare class TerraDrawSelectMode extends TerraDrawBaseDrawMode<SelectionStyling> {
44
50
  type: ModeTypes;
45
51
  mode: string;
@@ -57,6 +63,7 @@ export declare class TerraDrawSelectMode extends TerraDrawBaseDrawMode<Selection
57
63
  private dragCoordinate;
58
64
  private rotateFeature;
59
65
  private scaleFeature;
66
+ private cursors;
60
67
  constructor(options?: {
61
68
  styles?: Partial<SelectionStyling>;
62
69
  pointerDistance?: number;
@@ -65,6 +72,7 @@ export declare class TerraDrawSelectMode extends TerraDrawBaseDrawMode<Selection
65
72
  };
66
73
  keyEvents?: TerraDrawSelectModeKeyEvents | null;
67
74
  dragEventThrottle?: number;
75
+ cursors?: Cursors;
68
76
  });
69
77
  registerBehaviors(config: BehaviorConfig): void;
70
78
  private deselect;