terra-draw 1.1.0 → 1.3.0

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 (33) hide show
  1. package/dist/geometry/boolean/is-valid-coordinate.d.ts +3 -1
  2. package/dist/geometry/boolean/right-hand-rule.d.ts +7 -0
  3. package/dist/geometry/boolean/right-hand-rule.spec.d.ts +1 -0
  4. package/dist/geometry/ensure-right-hand-rule.d.ts +2 -0
  5. package/dist/geometry/ensure-right-hand-rule.spec.d.ts +1 -0
  6. package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -1
  7. package/dist/modes/base.mode.d.ts +10 -9
  8. package/dist/modes/circle/circle.mode.d.ts +2 -1
  9. package/dist/modes/freehand/freehand.mode.d.ts +2 -1
  10. package/dist/modes/linestring/linestring.mode.d.ts +20 -4
  11. package/dist/modes/point/point.mode.d.ts +5 -1
  12. package/dist/modes/polygon/polygon.mode.d.ts +18 -8
  13. package/dist/modes/rectangle/rectangle.mode.d.ts +2 -1
  14. package/dist/modes/render/render.mode.d.ts +2 -1
  15. package/dist/modes/sector/sector.mode.d.ts +2 -1
  16. package/dist/modes/select/select.mode.d.ts +7 -4
  17. package/dist/modes/sensor/sensor.mode.d.ts +2 -1
  18. package/dist/modes/static/static.mode.d.ts +1 -1
  19. package/dist/store/store.d.ts +1 -0
  20. package/dist/terra-draw.cjs +1 -1
  21. package/dist/terra-draw.cjs.map +1 -1
  22. package/dist/terra-draw.d.ts +20 -0
  23. package/dist/terra-draw.modern.js +1 -1
  24. package/dist/terra-draw.modern.js.map +1 -1
  25. package/dist/terra-draw.module.js +1 -1
  26. package/dist/terra-draw.module.js.map +1 -1
  27. package/dist/terra-draw.umd.js +1 -1
  28. package/dist/terra-draw.umd.js.map +1 -1
  29. package/dist/validation-reasons.d.ts +1 -0
  30. package/dist/validations/linestring.validation.d.ts +2 -0
  31. package/dist/validations/point.validation.d.ts +1 -0
  32. package/dist/validations/polygon.validation.d.ts +1 -0
  33. package/package.json +1 -1
@@ -21,6 +21,7 @@ import { TerraDrawSectorMode } from "./modes/sector/sector.mode";
21
21
  import { TerraDrawSensorMode } from "./modes/sensor/sensor.mode";
22
22
  import * as TerraDrawExtend from "./extend";
23
23
  import { ValidationReasons } from "./validation-reasons";
24
+ type InstanceType<T extends new (...args: any[]) => any> = T extends new (...args: any[]) => infer R ? R : never;
24
25
  type FinishListener = (id: FeatureId, context: OnFinishContext) => void;
25
26
  type ChangeListener = (ids: FeatureId[], type: string) => void;
26
27
  type SelectListener = (id: FeatureId) => void;
@@ -52,6 +53,9 @@ declare class TerraDraw {
52
53
  private featuresAtLocation;
53
54
  private getSelectMode;
54
55
  /**
56
+ * @deprecated This method is scheduled for removal in the next major version. Instead use the 'updateModeOptions' method passing the
57
+ * styles property in the options object, and this will dynamically update the styles for the mode.
58
+ *
55
59
  * Allows the setting of a style for a given mode
56
60
  *
57
61
  * @param mode - The mode you wish to set a style for
@@ -59,12 +63,28 @@ declare class TerraDraw {
59
63
  * the same as the initialisation style schema
60
64
  */
61
65
  setModeStyles<Styling extends Record<string, number | HexColor>>(mode: string, styles: Styling): void;
66
+ /**
67
+ * Allow updating of the current options passed to the mode dynamically
68
+ * after the mode has been started. You can also use this method to update styles
69
+ * as these are passed from the options object.
70
+ * @param mode - the mode name you wish to update (the mode name is the public 'mode' property of the mode class)
71
+ * @param options - the options object - this allows _partial_ updating of the modes options (i.e. you do not need to pass the whole options object)
72
+ */
73
+ updateModeOptions<Mode extends {
74
+ new (...args: any[]): any;
75
+ }>(mode: InstanceType<Mode>["mode"], options: ConstructorParameters<Mode>[0]): void;
62
76
  /**
63
77
  * Allows the user to get a snapshot (copy) of all given features
64
78
  *
65
79
  * @returns An array of all given Feature Geometries in the instances store
66
80
  */
67
81
  getSnapshot(): GeoJSONStoreFeatures[];
82
+ /**
83
+ * Allows the user to get a snapshot (copy) of a given feature by id
84
+ *
85
+ * @returns A copy of the feature geometry in the instances store
86
+ */
87
+ getSnapshotFeature(id: FeatureId): GeoJSONStoreFeatures | undefined;
68
88
  /**
69
89
  * Removes all data from the current store and removes any rendered layers
70
90
  * via the registering the adapter.