@zag-js/rect-utils 2.0.0-next.2 → 2.0.0-next.4

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 (89) hide show
  1. package/dist/align.d.mts +2 -5
  2. package/dist/align.d.ts +2 -5
  3. package/dist/align.js +27 -44
  4. package/dist/align.mjs +23 -19
  5. package/dist/angle.d.mts +2 -5
  6. package/dist/angle.d.ts +2 -5
  7. package/dist/angle.js +8 -32
  8. package/dist/angle.mjs +4 -7
  9. package/dist/clamp.d.mts +8 -11
  10. package/dist/clamp.d.ts +8 -11
  11. package/dist/clamp.js +23 -46
  12. package/dist/clamp.mjs +18 -20
  13. package/dist/closest.d.mts +4 -7
  14. package/dist/closest.d.ts +4 -7
  15. package/dist/closest.js +35 -62
  16. package/dist/closest.mjs +29 -35
  17. package/dist/compass.d.mts +1 -3
  18. package/dist/compass.d.ts +1 -3
  19. package/dist/compass.js +4 -18
  20. package/dist/compass.mjs +1 -0
  21. package/dist/constrain.d.mts +2 -5
  22. package/dist/constrain.d.ts +2 -5
  23. package/dist/constrain.js +12 -37
  24. package/dist/constrain.mjs +8 -12
  25. package/dist/contains.d.mts +4 -7
  26. package/dist/contains.d.ts +4 -7
  27. package/dist/contains.js +11 -36
  28. package/dist/contains.mjs +5 -9
  29. package/dist/distance.d.mts +7 -10
  30. package/dist/distance.d.ts +7 -10
  31. package/dist/distance.js +55 -60
  32. package/dist/distance.mjs +48 -32
  33. package/dist/equality.d.mts +4 -7
  34. package/dist/equality.d.ts +4 -7
  35. package/dist/equality.js +13 -38
  36. package/dist/equality.mjs +7 -11
  37. package/dist/from-element.d.mts +12 -15
  38. package/dist/from-element.d.ts +12 -15
  39. package/dist/from-element.js +39 -58
  40. package/dist/from-element.mjs +35 -33
  41. package/dist/from-points.d.mts +2 -5
  42. package/dist/from-points.d.ts +2 -5
  43. package/dist/from-points.js +18 -36
  44. package/dist/from-points.mjs +14 -11
  45. package/dist/from-range.d.mts +2 -5
  46. package/dist/from-range.d.ts +2 -5
  47. package/dist/from-range.js +25 -46
  48. package/dist/from-range.mjs +19 -19
  49. package/dist/from-rotation.d.mts +4 -7
  50. package/dist/from-rotation.d.ts +4 -7
  51. package/dist/from-rotation.js +31 -56
  52. package/dist/from-rotation.mjs +25 -29
  53. package/dist/from-window.d.mts +13 -16
  54. package/dist/from-window.d.ts +13 -16
  55. package/dist/from-window.js +29 -44
  56. package/dist/from-window.mjs +24 -18
  57. package/dist/index.d.mts +21 -21
  58. package/dist/index.d.ts +21 -21
  59. package/dist/index.js +91 -61
  60. package/dist/index.mjs +20 -21
  61. package/dist/interact.d.mts +34 -37
  62. package/dist/interact.d.ts +34 -37
  63. package/dist/interact.js +414 -350
  64. package/dist/interact.mjs +396 -311
  65. package/dist/intersection.d.mts +4 -7
  66. package/dist/intersection.d.ts +4 -7
  67. package/dist/intersection.js +34 -45
  68. package/dist/intersection.mjs +28 -18
  69. package/dist/operations.d.mts +6 -9
  70. package/dist/operations.d.ts +6 -9
  71. package/dist/operations.js +38 -57
  72. package/dist/operations.mjs +30 -28
  73. package/dist/polygon.d.mts +6 -9
  74. package/dist/polygon.d.ts +6 -9
  75. package/dist/polygon.js +73 -82
  76. package/dist/polygon.mjs +67 -55
  77. package/dist/rect.d.mts +55 -58
  78. package/dist/rect.d.ts +55 -58
  79. package/dist/rect.js +88 -117
  80. package/dist/rect.mjs +70 -78
  81. package/dist/types.d.mts +42 -46
  82. package/dist/types.d.ts +42 -46
  83. package/dist/types.js +4 -18
  84. package/dist/types.mjs +1 -0
  85. package/dist/union.d.mts +2 -5
  86. package/dist/union.d.ts +2 -5
  87. package/dist/union.js +16 -39
  88. package/dist/union.mjs +12 -14
  89. package/package.json +2 -2
package/dist/align.d.mts CHANGED
@@ -1,5 +1,2 @@
1
- import { Rect, AlignOptions } from './types.mjs';
2
-
3
- declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
4
-
5
- export { alignRect };
1
+ import { AlignOptions, Rect } from "./types.mjs";
2
+ export declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
package/dist/align.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- import { Rect, AlignOptions } from './types.js';
2
-
3
- declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
4
-
5
- export { alignRect };
1
+ import { AlignOptions, Rect } from "./types.js";
2
+ export declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
package/dist/align.js CHANGED
@@ -1,51 +1,34 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/align.ts
21
- var align_exports = {};
22
- __export(align_exports, {
23
- alignRect: () => alignRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(align_exports);
5
+ // src/align.ts
26
6
  function hAlign(a, ref, h) {
27
- let x = ref.minX;
28
- if (h === "left-inside") x = ref.minX;
29
- if (h === "left-outside") x = ref.minX - ref.width;
30
- if (h === "right-inside") x = ref.maxX - ref.width;
31
- if (h === "right-outside") x = ref.maxX;
32
- if (h === "center") x = ref.midX - ref.width / 2;
33
- return { ...a, x };
7
+ let x = ref.minX;
8
+ if (h === "left-inside") x = ref.minX;
9
+ if (h === "left-outside") x = ref.minX - ref.width;
10
+ if (h === "right-inside") x = ref.maxX - ref.width;
11
+ if (h === "right-outside") x = ref.maxX;
12
+ if (h === "center") x = ref.midX - ref.width / 2;
13
+ return {
14
+ ...a,
15
+ x
16
+ };
34
17
  }
35
18
  function vAlign(a, ref, v) {
36
- let y = ref.minY;
37
- if (v === "top-inside") y = ref.minY;
38
- if (v === "top-outside") y = ref.minY - a.height;
39
- if (v === "bottom-inside") y = ref.maxY - a.height;
40
- if (v === "bottom-outside") y = ref.maxY;
41
- if (v === "center") y = ref.midY - a.height / 2;
42
- return { ...a, y };
19
+ let y = ref.minY;
20
+ if (v === "top-inside") y = ref.minY;
21
+ if (v === "top-outside") y = ref.minY - a.height;
22
+ if (v === "bottom-inside") y = ref.maxY - a.height;
23
+ if (v === "bottom-outside") y = ref.maxY;
24
+ if (v === "center") y = ref.midY - a.height / 2;
25
+ return {
26
+ ...a,
27
+ y
28
+ };
43
29
  }
44
30
  function alignRect(a, ref, options) {
45
- const { h, v } = options;
46
- return vAlign(hAlign(a, ref, h), ref, v);
31
+ const { h, v } = options;
32
+ return vAlign(hAlign(a, ref, h), ref, v);
47
33
  }
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- alignRect
51
- });
34
+ exports.alignRect = alignRect;
package/dist/align.mjs CHANGED
@@ -1,26 +1,30 @@
1
1
  // src/align.ts
2
2
  function hAlign(a, ref, h) {
3
- let x = ref.minX;
4
- if (h === "left-inside") x = ref.minX;
5
- if (h === "left-outside") x = ref.minX - ref.width;
6
- if (h === "right-inside") x = ref.maxX - ref.width;
7
- if (h === "right-outside") x = ref.maxX;
8
- if (h === "center") x = ref.midX - ref.width / 2;
9
- return { ...a, x };
3
+ let x = ref.minX;
4
+ if (h === "left-inside") x = ref.minX;
5
+ if (h === "left-outside") x = ref.minX - ref.width;
6
+ if (h === "right-inside") x = ref.maxX - ref.width;
7
+ if (h === "right-outside") x = ref.maxX;
8
+ if (h === "center") x = ref.midX - ref.width / 2;
9
+ return {
10
+ ...a,
11
+ x
12
+ };
10
13
  }
11
14
  function vAlign(a, ref, v) {
12
- let y = ref.minY;
13
- if (v === "top-inside") y = ref.minY;
14
- if (v === "top-outside") y = ref.minY - a.height;
15
- if (v === "bottom-inside") y = ref.maxY - a.height;
16
- if (v === "bottom-outside") y = ref.maxY;
17
- if (v === "center") y = ref.midY - a.height / 2;
18
- return { ...a, y };
15
+ let y = ref.minY;
16
+ if (v === "top-inside") y = ref.minY;
17
+ if (v === "top-outside") y = ref.minY - a.height;
18
+ if (v === "bottom-inside") y = ref.maxY - a.height;
19
+ if (v === "bottom-outside") y = ref.maxY;
20
+ if (v === "center") y = ref.midY - a.height / 2;
21
+ return {
22
+ ...a,
23
+ y
24
+ };
19
25
  }
20
26
  function alignRect(a, ref, options) {
21
- const { h, v } = options;
22
- return vAlign(hAlign(a, ref, h), ref, v);
27
+ const { h, v } = options;
28
+ return vAlign(hAlign(a, ref, h), ref, v);
23
29
  }
24
- export {
25
- alignRect
26
- };
30
+ export { alignRect };
package/dist/angle.d.mts CHANGED
@@ -1,5 +1,2 @@
1
- import { Rect, Point } from './types.mjs';
2
-
3
- declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
4
-
5
- export { getPointAngle };
1
+ import { Point, Rect } from "./types.mjs";
2
+ export declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
package/dist/angle.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- import { Rect, Point } from './types.js';
2
-
3
- declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
4
-
5
- export { getPointAngle };
1
+ import { Point, Rect } from "./types.js";
2
+ export declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number;
package/dist/angle.js CHANGED
@@ -1,35 +1,11 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/angle.ts
21
- var angle_exports = {};
22
- __export(angle_exports, {
23
- getPointAngle: () => getPointAngle
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(angle_exports);
5
+ // src/angle.ts
26
6
  function getPointAngle(rect, point, reference = rect.center) {
27
- const x = point.x - reference.x;
28
- const y = point.y - reference.y;
29
- const deg = Math.atan2(x, y) * (180 / Math.PI) + 180;
30
- return 360 - deg;
7
+ const x = point.x - reference.x;
8
+ const y = point.y - reference.y;
9
+ return 360 - (Math.atan2(x, y) * (180 / Math.PI) + 180);
31
10
  }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- getPointAngle
35
- });
11
+ exports.getPointAngle = getPointAngle;
package/dist/angle.mjs CHANGED
@@ -1,10 +1,7 @@
1
1
  // src/angle.ts
2
2
  function getPointAngle(rect, point, reference = rect.center) {
3
- const x = point.x - reference.x;
4
- const y = point.y - reference.y;
5
- const deg = Math.atan2(x, y) * (180 / Math.PI) + 180;
6
- return 360 - deg;
3
+ const x = point.x - reference.x;
4
+ const y = point.y - reference.y;
5
+ return 360 - (Math.atan2(x, y) * (180 / Math.PI) + 180);
7
6
  }
8
- export {
9
- getPointAngle
10
- };
7
+ export { getPointAngle };
package/dist/clamp.d.mts CHANGED
@@ -1,12 +1,9 @@
1
- import { Point, Size, RectInit } from './types.mjs';
2
-
3
- declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
4
- x: number;
5
- y: number;
1
+ import { Point, RectInit, Size } from "./types.mjs";
2
+ export declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
3
+ x: number;
4
+ y: number;
6
5
  };
7
- declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
8
- width: number;
9
- height: number;
10
- };
11
-
12
- export { clampPoint, clampSize };
6
+ export declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
7
+ width: number;
8
+ height: number;
9
+ };
package/dist/clamp.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { Point, Size, RectInit } from './types.js';
2
-
3
- declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
4
- x: number;
5
- y: number;
1
+ import { Point, RectInit, Size } from "./types.js";
2
+ export declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => {
3
+ x: number;
4
+ y: number;
6
5
  };
7
- declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
8
- width: number;
9
- height: number;
10
- };
11
-
12
- export { clampPoint, clampSize };
6
+ export declare const clampSize: (size: Size, minSize?: Size, maxSize?: Size) => {
7
+ width: number;
8
+ height: number;
9
+ };
package/dist/clamp.js CHANGED
@@ -1,51 +1,28 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/clamp.ts
21
- var clamp_exports = {};
22
- __export(clamp_exports, {
23
- clampPoint: () => clampPoint,
24
- clampSize: () => clampSize
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
25
4
  });
26
- module.exports = __toCommonJS(clamp_exports);
27
- var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
28
- var clampPoint = (position, size, boundaryRect) => {
29
- const x = clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width);
30
- const y = clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height);
31
- return { x, y };
5
+ // src/clamp.ts
6
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
7
+ const clampPoint = (position, size, boundaryRect) => {
8
+ return {
9
+ x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
10
+ y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
11
+ };
32
12
  };
33
- var defaultMinSize = {
34
- width: 0,
35
- height: 0
13
+ const defaultMinSize = {
14
+ width: 0,
15
+ height: 0
36
16
  };
37
- var defaultMaxSize = {
38
- width: Infinity,
39
- height: Infinity
17
+ const defaultMaxSize = {
18
+ width: 1e400,
19
+ height: 1e400
40
20
  };
41
- var clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
42
- return {
43
- width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
44
- height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
45
- };
21
+ const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
22
+ return {
23
+ width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
24
+ height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
25
+ };
46
26
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- clampPoint,
50
- clampSize
51
- });
27
+ exports.clampPoint = clampPoint;
28
+ exports.clampSize = clampSize;
package/dist/clamp.mjs CHANGED
@@ -1,25 +1,23 @@
1
1
  // src/clamp.ts
2
- var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
3
- var clampPoint = (position, size, boundaryRect) => {
4
- const x = clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width);
5
- const y = clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height);
6
- return { x, y };
2
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
3
+ const clampPoint = (position, size, boundaryRect) => {
4
+ return {
5
+ x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
6
+ y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
7
+ };
7
8
  };
8
- var defaultMinSize = {
9
- width: 0,
10
- height: 0
9
+ const defaultMinSize = {
10
+ width: 0,
11
+ height: 0
11
12
  };
12
- var defaultMaxSize = {
13
- width: Infinity,
14
- height: Infinity
13
+ const defaultMaxSize = {
14
+ width: 1e400,
15
+ height: 1e400
15
16
  };
16
- var clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
17
- return {
18
- width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
19
- height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
20
- };
21
- };
22
- export {
23
- clampPoint,
24
- clampSize
17
+ const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
18
+ return {
19
+ width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
20
+ height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
21
+ };
25
22
  };
23
+ export { clampPoint, clampSize };
@@ -1,7 +1,4 @@
1
- import { Point, Rect, RectSide } from './types.mjs';
2
-
3
- declare function closest(...pts: Point[]): (a: Point) => Point;
4
- declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
5
- declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
6
-
7
- export { closest, closestSideToPoint, closestSideToRect };
1
+ import { Point, Rect, RectSide } from "./types.mjs";
2
+ export declare function closest(...pts: Point[]): (a: Point) => Point;
3
+ export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
4
+ export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
package/dist/closest.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { Point, Rect, RectSide } from './types.js';
2
-
3
- declare function closest(...pts: Point[]): (a: Point) => Point;
4
- declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
5
- declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
6
-
7
- export { closest, closestSideToPoint, closestSideToRect };
1
+ import { Point, Rect, RectSide } from "./types.js";
2
+ export declare function closest(...pts: Point[]): (a: Point) => Point;
3
+ export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
4
+ export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
package/dist/closest.js CHANGED
@@ -1,69 +1,42 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/closest.ts
21
- var closest_exports = {};
22
- __export(closest_exports, {
23
- closest: () => closest,
24
- closestSideToPoint: () => closestSideToPoint,
25
- closestSideToRect: () => closestSideToRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(closest_exports);
28
- var import_distance = require("./distance.js");
5
+ const require_distance = require("./distance.js");
6
+ // src/closest.ts
29
7
  function closest(...pts) {
30
- return (a) => {
31
- const ds = pts.map((b) => (0, import_distance.distance)(b, a));
32
- const c = Math.min.apply(Math, ds);
33
- return pts[ds.indexOf(c)];
34
- };
8
+ return (a) => {
9
+ const ds = pts.map((b) => require_distance.distance(b, a));
10
+ const c = Math.min.apply(Math, ds);
11
+ return pts[ds.indexOf(c)];
12
+ };
35
13
  }
36
14
  function closestSideToRect(ref, r) {
37
- if (r.maxX <= ref.minX) return "left";
38
- if (r.minX >= ref.maxX) return "right";
39
- if (r.maxY <= ref.minY) return "top";
40
- if (r.minY >= ref.maxY) return "bottom";
41
- return "left";
15
+ if (r.maxX <= ref.minX) return "left";
16
+ if (r.minX >= ref.maxX) return "right";
17
+ if (r.maxY <= ref.minY) return "top";
18
+ if (r.minY >= ref.maxY) return "bottom";
19
+ return "left";
42
20
  }
43
21
  function closestSideToPoint(ref, p) {
44
- const { x, y } = p;
45
- const dl = x - ref.minX;
46
- const dr = ref.maxX - x;
47
- const dt = y - ref.minY;
48
- const db = ref.maxY - y;
49
- let closest2 = dl;
50
- let side = "left";
51
- if (dr < closest2) {
52
- closest2 = dr;
53
- side = "right";
54
- }
55
- if (dt < closest2) {
56
- closest2 = dt;
57
- side = "top";
58
- }
59
- if (db < closest2) {
60
- side = "bottom";
61
- }
62
- return side;
22
+ const { x, y } = p;
23
+ const dl = x - ref.minX;
24
+ const dr = ref.maxX - x;
25
+ const dt = y - ref.minY;
26
+ const db = ref.maxY - y;
27
+ let closest = dl;
28
+ let side = "left";
29
+ if (dr < closest) {
30
+ closest = dr;
31
+ side = "right";
32
+ }
33
+ if (dt < closest) {
34
+ closest = dt;
35
+ side = "top";
36
+ }
37
+ if (db < closest) side = "bottom";
38
+ return side;
63
39
  }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- closest,
67
- closestSideToPoint,
68
- closestSideToRect
69
- });
40
+ exports.closest = closest;
41
+ exports.closestSideToPoint = closestSideToPoint;
42
+ exports.closestSideToRect = closestSideToRect;
package/dist/closest.mjs CHANGED
@@ -1,42 +1,36 @@
1
- // src/closest.ts
2
1
  import { distance } from "./distance.mjs";
2
+ // src/closest.ts
3
3
  function closest(...pts) {
4
- return (a) => {
5
- const ds = pts.map((b) => distance(b, a));
6
- const c = Math.min.apply(Math, ds);
7
- return pts[ds.indexOf(c)];
8
- };
4
+ return (a) => {
5
+ const ds = pts.map((b) => distance(b, a));
6
+ const c = Math.min.apply(Math, ds);
7
+ return pts[ds.indexOf(c)];
8
+ };
9
9
  }
10
10
  function closestSideToRect(ref, r) {
11
- if (r.maxX <= ref.minX) return "left";
12
- if (r.minX >= ref.maxX) return "right";
13
- if (r.maxY <= ref.minY) return "top";
14
- if (r.minY >= ref.maxY) return "bottom";
15
- return "left";
11
+ if (r.maxX <= ref.minX) return "left";
12
+ if (r.minX >= ref.maxX) return "right";
13
+ if (r.maxY <= ref.minY) return "top";
14
+ if (r.minY >= ref.maxY) return "bottom";
15
+ return "left";
16
16
  }
17
17
  function closestSideToPoint(ref, p) {
18
- const { x, y } = p;
19
- const dl = x - ref.minX;
20
- const dr = ref.maxX - x;
21
- const dt = y - ref.minY;
22
- const db = ref.maxY - y;
23
- let closest2 = dl;
24
- let side = "left";
25
- if (dr < closest2) {
26
- closest2 = dr;
27
- side = "right";
28
- }
29
- if (dt < closest2) {
30
- closest2 = dt;
31
- side = "top";
32
- }
33
- if (db < closest2) {
34
- side = "bottom";
35
- }
36
- return side;
18
+ const { x, y } = p;
19
+ const dl = x - ref.minX;
20
+ const dr = ref.maxX - x;
21
+ const dt = y - ref.minY;
22
+ const db = ref.maxY - y;
23
+ let closest = dl;
24
+ let side = "left";
25
+ if (dr < closest) {
26
+ closest = dr;
27
+ side = "right";
28
+ }
29
+ if (dt < closest) {
30
+ closest = dt;
31
+ side = "top";
32
+ }
33
+ if (db < closest) side = "bottom";
34
+ return side;
37
35
  }
38
- export {
39
- closest,
40
- closestSideToPoint,
41
- closestSideToRect
42
- };
36
+ export { closest, closestSideToPoint, closestSideToRect };
@@ -1,3 +1 @@
1
- type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
2
-
3
- export type { CompassDirection };
1
+ export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
package/dist/compass.d.ts CHANGED
@@ -1,3 +1 @@
1
- type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
2
-
3
- export type { CompassDirection };
1
+ export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
package/dist/compass.js CHANGED
@@ -1,18 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/compass.ts
17
- var compass_exports = {};
18
- module.exports = __toCommonJS(compass_exports);
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
package/dist/compass.mjs CHANGED
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,2 @@
1
- import { RectInit } from './types.mjs';
2
-
3
- declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
4
-
5
- export { constrainRect };
1
+ import { RectInit } from "./types.mjs";
2
+ export declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;