@dnd-kit/geometry 0.0.3 → 0.0.4-beta-20240621131401

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.
@@ -0,0 +1,157 @@
1
+ declare enum Axis {
2
+ Horizontal = "x",
3
+ Vertical = "y"
4
+ }
5
+ declare const Axes: Axis[];
6
+
7
+ type Coordinates = Record<Axis, number>;
8
+
9
+ interface BoundingRectangle {
10
+ width: number;
11
+ height: number;
12
+ left: number;
13
+ right: number;
14
+ top: number;
15
+ bottom: number;
16
+ }
17
+
18
+ /**
19
+ * A Point represents a location in a two-dimensional coordinate system.
20
+ *
21
+ */
22
+ declare class Point implements Coordinates {
23
+ x: number;
24
+ y: number;
25
+ /**
26
+ * @param {number} Coordinate of the point on the horizontal axis
27
+ * @param {number} Coordinate of the point on the vertical axis
28
+ */
29
+ constructor(x: number, y: number);
30
+ /**
31
+ * Returns the delta between this point and another point.
32
+ *
33
+ * @param {Point} a - A point
34
+ * @param {Point} b - Another point
35
+ */
36
+ static delta(a: Point, b: Point): Point;
37
+ /**
38
+ * Returns the distance (hypotenuse) between this point and another point.
39
+ *
40
+ * @param {Point} a - A point
41
+ * @param {Point} b - Another point
42
+ */
43
+ static distance(a: Point, b: Point): number;
44
+ /**
45
+ * Returns true if both points are equal.
46
+ *
47
+ * @param {Point} a - A point
48
+ * @param {Point} b - Another point
49
+ */
50
+ static equals(a: Point, b: Point): boolean;
51
+ static from({ x, y }: Coordinates): Point;
52
+ }
53
+
54
+ /**
55
+ * An abstract class representing a 2D geometric shape, such as
56
+ * a polygon or circle. Shapes are used for collision detection
57
+ * during drag and drop operations.
58
+ */
59
+ declare abstract class Shape {
60
+ /**
61
+ * Get the bounding rectangle of the 2D shape.
62
+ * @returns The bounding rectangle of the shape.
63
+ */
64
+ abstract get boundingRectangle(): BoundingRectangle;
65
+ /**
66
+ * Get the center point of the 2D shape.
67
+ * @returns The center point of the shape.
68
+ */
69
+ abstract get center(): Point;
70
+ /**
71
+ * Get the total space taken up by the 2D shape.
72
+ * @returns The area of the shape.
73
+ */
74
+ abstract get area(): number;
75
+ /**
76
+ * Get the scale transformation of the shape on the 2D plane.
77
+ * @returns The scale of the shape.
78
+ */
79
+ abstract get scale(): {
80
+ x: number;
81
+ y: number;
82
+ };
83
+ /**
84
+ * Get the inverse scale transformation of the shape on the 2D plane.
85
+ * @returns The inverse scale of the shape.
86
+ */
87
+ abstract get inverseScale(): {
88
+ x: number;
89
+ y: number;
90
+ };
91
+ /**
92
+ * Returns whether or not this shape is equal to another shape.
93
+ *
94
+ * @param shape The other shape to compare with.
95
+ * @returns Whether or not the two shapes are equal.
96
+ */
97
+ abstract equals(shape: Shape): boolean;
98
+ /**
99
+ * Returns the intersection area between this shape and another shape.
100
+ *
101
+ * @param shape The other shape to calculate the intersection area with.
102
+ * @returns The intersection area between the two shapes.
103
+ */
104
+ abstract intersectionArea(shape: Shape): number;
105
+ /**
106
+ * Test a point for containment within this shape.
107
+ *
108
+ * @param point A point in world coordinates.
109
+ */
110
+ abstract containsPoint(point: Point): boolean;
111
+ }
112
+
113
+ declare class Rectangle implements Shape {
114
+ left: number;
115
+ top: number;
116
+ width: number;
117
+ height: number;
118
+ constructor(left: number, top: number, width: number, height: number);
119
+ scale: {
120
+ x: number;
121
+ y: number;
122
+ };
123
+ get inverseScale(): {
124
+ x: number;
125
+ y: number;
126
+ };
127
+ translate(x: number, y: number): Rectangle;
128
+ get boundingRectangle(): BoundingRectangle;
129
+ get center(): Point;
130
+ get area(): number;
131
+ equals(shape: Shape): boolean;
132
+ containsPoint(point: Point): boolean;
133
+ intersectionArea(shape: Shape): number;
134
+ intersectionRatio(shape: Shape): number;
135
+ get bottom(): number;
136
+ get right(): number;
137
+ }
138
+
139
+ declare class Position {
140
+ constructor(initialValue: Coordinates);
141
+ accessor initial: Point;
142
+ accessor previous: Point;
143
+ accessor current: Point;
144
+ get delta(): Point;
145
+ get direction(): "right" | "left" | "down" | "up" | null;
146
+ reset(coordinates: Coordinates): void;
147
+ update(coordinates: Coordinates): void;
148
+ }
149
+
150
+ type Distance = number | Coordinates | Pick<Coordinates, Axis.Horizontal> | Pick<Coordinates, Axis.Vertical>;
151
+
152
+ /**
153
+ * Returns true if a set of relative coordinates exceeds a given distance.
154
+ */
155
+ declare function exceedsDistance({ x, y }: Coordinates, distance: Distance): boolean;
156
+
157
+ export { Axes, Axis, type BoundingRectangle, type Coordinates, type Distance, Point, Position, Rectangle, Shape, exceedsDistance };
package/dist/index.d.ts CHANGED
@@ -138,9 +138,9 @@ declare class Rectangle implements Shape {
138
138
 
139
139
  declare class Position {
140
140
  constructor(initialValue: Coordinates);
141
- initial: Point;
142
- previous: Point;
143
- current: Point;
141
+ accessor initial: Point;
142
+ accessor previous: Point;
143
+ accessor current: Point;
144
144
  get delta(): Point;
145
145
  get direction(): "right" | "left" | "down" | "up" | null;
146
146
  reset(coordinates: Coordinates): void;
@@ -154,4 +154,4 @@ type Distance = number | Coordinates | Pick<Coordinates, Axis.Horizontal> | Pick
154
154
  */
155
155
  declare function exceedsDistance({ x, y }: Coordinates, distance: Distance): boolean;
156
156
 
157
- export { Axes, Axis, BoundingRectangle, Coordinates, Distance, Point, Position, Rectangle, Shape, exceedsDistance };
157
+ export { Axes, Axis, type BoundingRectangle, type Coordinates, type Distance, Point, Position, Rectangle, Shape, exceedsDistance };
package/dist/index.js CHANGED
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
10
+ var __typeError = (msg) => {
11
+ throw TypeError(msg);
12
+ };
8
13
  var __pow = Math.pow;
9
14
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
15
  var __spreadValues = (a, b) => {
@@ -18,6 +23,7 @@ var __spreadValues = (a, b) => {
18
23
  }
19
24
  return a;
20
25
  };
26
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
21
27
  var __export = (target, all) => {
22
28
  for (var name in all)
23
29
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -31,15 +37,48 @@ var __copyProps = (to, from, except, desc) => {
31
37
  return to;
32
38
  };
33
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
- var __decorateClass = (decorators, target, key, kind) => {
35
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
36
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
37
- if (decorator = decorators[i])
38
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
39
- if (kind && result)
40
- __defProp(target, key, result);
41
- return result;
40
+ var __decoratorStart = (base) => {
41
+ var _a;
42
+ return [, , , __create((_a = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a : null)];
43
+ };
44
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
45
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
46
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
47
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
48
+ var __runInitializers = (array, flags, self, value) => {
49
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
50
+ return value;
51
+ };
52
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
53
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
54
+ var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
55
+ var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
56
+ var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
57
+ return __privateGet(this, extra);
58
+ }, set [name](x) {
59
+ return __privateSet(this, extra, x);
60
+ } }, name));
61
+ k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
62
+ for (var i = decorators.length - 1; i >= 0; i--) {
63
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
64
+ if (k) {
65
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
66
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
67
+ if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
68
+ }
69
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
70
+ if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
71
+ else if (typeof it !== "object" || it === null) __typeError("Object expected");
72
+ else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
73
+ }
74
+ return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
42
75
  };
76
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
77
+ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
78
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
79
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
80
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
81
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
43
82
 
44
83
  // src/index.ts
45
84
  var src_exports = {};
@@ -54,7 +93,7 @@ __export(src_exports, {
54
93
  module.exports = __toCommonJS(src_exports);
55
94
 
56
95
  // src/point/Point.ts
57
- var Point = class {
96
+ var Point = class _Point {
58
97
  /**
59
98
  * @param {number} Coordinate of the point on the horizontal axis
60
99
  * @param {number} Coordinate of the point on the vertical axis
@@ -70,7 +109,7 @@ var Point = class {
70
109
  * @param {Point} b - Another point
71
110
  */
72
111
  static delta(a, b) {
73
- return new Point(a.x - b.x, a.y - b.y);
112
+ return new _Point(a.x - b.x, a.y - b.y);
74
113
  }
75
114
  /**
76
115
  * Returns the distance (hypotenuse) between this point and another point.
@@ -91,12 +130,12 @@ var Point = class {
91
130
  return a.x === b.x && a.y === b.y;
92
131
  }
93
132
  static from({ x, y }) {
94
- return new Point(x, y);
133
+ return new _Point(x, y);
95
134
  }
96
135
  };
97
136
 
98
137
  // src/shapes/Rectangle.ts
99
- var Rectangle = class {
138
+ var Rectangle = class _Rectangle {
100
139
  constructor(left, top, width, height) {
101
140
  this.left = left;
102
141
  this.top = top;
@@ -115,7 +154,7 @@ var Rectangle = class {
115
154
  }
116
155
  translate(x, y) {
117
156
  const { top, left, width, height, scale } = this;
118
- const newShape = new Rectangle(left + x, top + y, width, height);
157
+ const newShape = new _Rectangle(left + x, top + y, width, height);
119
158
  newShape.scale = __spreadValues({}, scale);
120
159
  return newShape;
121
160
  }
@@ -132,7 +171,7 @@ var Rectangle = class {
132
171
  return width * height;
133
172
  }
134
173
  equals(shape) {
135
- if (!(shape instanceof Rectangle)) {
174
+ if (!(shape instanceof _Rectangle)) {
136
175
  return false;
137
176
  }
138
177
  const { left, top, width, height } = this;
@@ -143,7 +182,7 @@ var Rectangle = class {
143
182
  return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right;
144
183
  }
145
184
  intersectionArea(shape) {
146
- if (shape instanceof Rectangle) {
185
+ if (shape instanceof _Rectangle) {
147
186
  return rectangleRectangleIntersection(this, shape);
148
187
  }
149
188
  return 0;
@@ -180,8 +219,14 @@ function rectangleRectangleIntersection(a, b) {
180
219
  // src/position/position.ts
181
220
  var import_state = require("@dnd-kit/state");
182
221
  var SENSITIVITY = 10;
222
+ var _direction_dec, _delta_dec, _current_dec, _previous_dec, _initial_dec, _init, _initial, _previous, _current;
223
+ _initial_dec = [import_state.reactive], _previous_dec = [import_state.reactive], _current_dec = [import_state.reactive], _delta_dec = [import_state.derived], _direction_dec = [import_state.derived];
183
224
  var Position = class {
184
225
  constructor(initialValue) {
226
+ __runInitializers(_init, 5, this);
227
+ __privateAdd(this, _initial, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
228
+ __privateAdd(this, _previous, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
229
+ __privateAdd(this, _current, __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
185
230
  const point = Point.from(initialValue);
186
231
  this.initial = point;
187
232
  this.current = point;
@@ -227,21 +272,16 @@ var Position = class {
227
272
  this.current = point;
228
273
  }
229
274
  };
230
- __decorateClass([
231
- import_state.reactive
232
- ], Position.prototype, "initial", 2);
233
- __decorateClass([
234
- import_state.reactive
235
- ], Position.prototype, "previous", 2);
236
- __decorateClass([
237
- import_state.reactive
238
- ], Position.prototype, "current", 2);
239
- __decorateClass([
240
- import_state.derived
241
- ], Position.prototype, "delta", 1);
242
- __decorateClass([
243
- import_state.derived
244
- ], Position.prototype, "direction", 1);
275
+ _init = __decoratorStart(null);
276
+ _initial = new WeakMap();
277
+ _previous = new WeakMap();
278
+ _current = new WeakMap();
279
+ __decorateElement(_init, 4, "initial", _initial_dec, Position, _initial);
280
+ __decorateElement(_init, 4, "previous", _previous_dec, Position, _previous);
281
+ __decorateElement(_init, 4, "current", _current_dec, Position, _current);
282
+ __decorateElement(_init, 2, "delta", _delta_dec, Position);
283
+ __decorateElement(_init, 2, "direction", _direction_dec, Position);
284
+ __decoratorMetadata(_init, Position);
245
285
 
246
286
  // src/distance/distance.ts
247
287
  function exceedsDistance({ x, y }, distance) {
package/dist/index.mjs CHANGED
@@ -1,8 +1,13 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
6
11
  var __pow = Math.pow;
7
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
13
  var __spreadValues = (a, b) => {
@@ -16,18 +21,52 @@ var __spreadValues = (a, b) => {
16
21
  }
17
22
  return a;
18
23
  };
19
- var __decorateClass = (decorators, target, key, kind) => {
20
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
- if (decorator = decorators[i])
23
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
- if (kind && result)
25
- __defProp(target, key, result);
26
- return result;
24
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __decoratorStart = (base) => {
26
+ var _a;
27
+ return [, , , __create((_a = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a : null)];
28
+ };
29
+ var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
30
+ var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
31
+ var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
32
+ var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
33
+ var __runInitializers = (array, flags, self, value) => {
34
+ for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
35
+ return value;
36
+ };
37
+ var __decorateElement = (array, flags, name, decorators, target, extra) => {
38
+ var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
39
+ var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
40
+ var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
41
+ var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
42
+ return __privateGet(this, extra);
43
+ }, set [name](x) {
44
+ return __privateSet(this, extra, x);
45
+ } }, name));
46
+ k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
47
+ for (var i = decorators.length - 1; i >= 0; i--) {
48
+ ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
49
+ if (k) {
50
+ ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
51
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
52
+ if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
53
+ }
54
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
55
+ if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
56
+ else if (typeof it !== "object" || it === null) __typeError("Object expected");
57
+ else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
58
+ }
59
+ return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
27
60
  };
61
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
62
+ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
63
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
64
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
65
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
66
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
28
67
 
29
68
  // src/point/Point.ts
30
- var Point = class {
69
+ var Point = class _Point {
31
70
  /**
32
71
  * @param {number} Coordinate of the point on the horizontal axis
33
72
  * @param {number} Coordinate of the point on the vertical axis
@@ -43,7 +82,7 @@ var Point = class {
43
82
  * @param {Point} b - Another point
44
83
  */
45
84
  static delta(a, b) {
46
- return new Point(a.x - b.x, a.y - b.y);
85
+ return new _Point(a.x - b.x, a.y - b.y);
47
86
  }
48
87
  /**
49
88
  * Returns the distance (hypotenuse) between this point and another point.
@@ -64,12 +103,12 @@ var Point = class {
64
103
  return a.x === b.x && a.y === b.y;
65
104
  }
66
105
  static from({ x, y }) {
67
- return new Point(x, y);
106
+ return new _Point(x, y);
68
107
  }
69
108
  };
70
109
 
71
110
  // src/shapes/Rectangle.ts
72
- var Rectangle = class {
111
+ var Rectangle = class _Rectangle {
73
112
  constructor(left, top, width, height) {
74
113
  this.left = left;
75
114
  this.top = top;
@@ -88,7 +127,7 @@ var Rectangle = class {
88
127
  }
89
128
  translate(x, y) {
90
129
  const { top, left, width, height, scale } = this;
91
- const newShape = new Rectangle(left + x, top + y, width, height);
130
+ const newShape = new _Rectangle(left + x, top + y, width, height);
92
131
  newShape.scale = __spreadValues({}, scale);
93
132
  return newShape;
94
133
  }
@@ -105,7 +144,7 @@ var Rectangle = class {
105
144
  return width * height;
106
145
  }
107
146
  equals(shape) {
108
- if (!(shape instanceof Rectangle)) {
147
+ if (!(shape instanceof _Rectangle)) {
109
148
  return false;
110
149
  }
111
150
  const { left, top, width, height } = this;
@@ -116,7 +155,7 @@ var Rectangle = class {
116
155
  return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right;
117
156
  }
118
157
  intersectionArea(shape) {
119
- if (shape instanceof Rectangle) {
158
+ if (shape instanceof _Rectangle) {
120
159
  return rectangleRectangleIntersection(this, shape);
121
160
  }
122
161
  return 0;
@@ -153,8 +192,14 @@ function rectangleRectangleIntersection(a, b) {
153
192
  // src/position/position.ts
154
193
  import { batch, derived, reactive } from "@dnd-kit/state";
155
194
  var SENSITIVITY = 10;
195
+ var _direction_dec, _delta_dec, _current_dec, _previous_dec, _initial_dec, _init, _initial, _previous, _current;
196
+ _initial_dec = [reactive], _previous_dec = [reactive], _current_dec = [reactive], _delta_dec = [derived], _direction_dec = [derived];
156
197
  var Position = class {
157
198
  constructor(initialValue) {
199
+ __runInitializers(_init, 5, this);
200
+ __privateAdd(this, _initial, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
201
+ __privateAdd(this, _previous, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
202
+ __privateAdd(this, _current, __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
158
203
  const point = Point.from(initialValue);
159
204
  this.initial = point;
160
205
  this.current = point;
@@ -200,21 +245,16 @@ var Position = class {
200
245
  this.current = point;
201
246
  }
202
247
  };
203
- __decorateClass([
204
- reactive
205
- ], Position.prototype, "initial", 2);
206
- __decorateClass([
207
- reactive
208
- ], Position.prototype, "previous", 2);
209
- __decorateClass([
210
- reactive
211
- ], Position.prototype, "current", 2);
212
- __decorateClass([
213
- derived
214
- ], Position.prototype, "delta", 1);
215
- __decorateClass([
216
- derived
217
- ], Position.prototype, "direction", 1);
248
+ _init = __decoratorStart(null);
249
+ _initial = new WeakMap();
250
+ _previous = new WeakMap();
251
+ _current = new WeakMap();
252
+ __decorateElement(_init, 4, "initial", _initial_dec, Position, _initial);
253
+ __decorateElement(_init, 4, "previous", _previous_dec, Position, _previous);
254
+ __decorateElement(_init, 4, "current", _current_dec, Position, _current);
255
+ __decorateElement(_init, 2, "delta", _delta_dec, Position);
256
+ __decorateElement(_init, 2, "direction", _direction_dec, Position);
257
+ __decoratorMetadata(_init, Position);
218
258
 
219
259
  // src/distance/distance.ts
220
260
  function exceedsDistance({ x, y }, distance) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnd-kit/geometry",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-beta-20240621131401",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -16,14 +16,14 @@
16
16
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
17
17
  },
18
18
  "dependencies": {
19
- "@dnd-kit/state": "^0.0.3",
19
+ "@dnd-kit/state": "0.0.4-beta-20240621131401",
20
20
  "tslib": "^2.6.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@dnd-kit/eslint-config": "*",
24
24
  "eslint": "^8.38.0",
25
- "tsup": "^6.7.0",
26
- "typescript": "^5.0.4"
25
+ "tsup": "^8.1.0",
26
+ "typescript": "^5.5.2"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"