@zag-js/rect-utils 1.46.0 → 1.48.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 (102) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
  9. package/dist/affine-transform.d.mts +36 -39
  10. package/dist/affine-transform.d.ts +36 -39
  11. package/dist/affine-transform.js +189 -187
  12. package/dist/affine-transform.mjs +185 -164
  13. package/dist/align.d.mts +2 -5
  14. package/dist/align.d.ts +2 -5
  15. package/dist/align.js +27 -44
  16. package/dist/align.mjs +23 -21
  17. package/dist/angle.d.mts +2 -5
  18. package/dist/angle.d.ts +2 -5
  19. package/dist/angle.js +8 -32
  20. package/dist/angle.mjs +4 -9
  21. package/dist/clamp.d.mts +8 -11
  22. package/dist/clamp.d.ts +8 -11
  23. package/dist/clamp.js +23 -46
  24. package/dist/clamp.mjs +18 -22
  25. package/dist/closest.d.mts +4 -7
  26. package/dist/closest.d.ts +4 -7
  27. package/dist/closest.js +35 -62
  28. package/dist/closest.mjs +29 -37
  29. package/dist/compass.d.mts +4 -7
  30. package/dist/compass.d.ts +4 -7
  31. package/dist/compass.js +48 -48
  32. package/dist/compass.mjs +43 -24
  33. package/dist/constrain.d.mts +2 -5
  34. package/dist/constrain.d.ts +2 -5
  35. package/dist/constrain.js +12 -37
  36. package/dist/constrain.mjs +8 -14
  37. package/dist/contains.d.mts +4 -7
  38. package/dist/contains.d.ts +4 -7
  39. package/dist/contains.js +11 -36
  40. package/dist/contains.mjs +5 -11
  41. package/dist/distance.d.mts +7 -10
  42. package/dist/distance.d.ts +7 -10
  43. package/dist/distance.js +55 -60
  44. package/dist/distance.mjs +48 -34
  45. package/dist/equality.d.mts +4 -7
  46. package/dist/equality.d.ts +4 -7
  47. package/dist/equality.js +13 -38
  48. package/dist/equality.mjs +7 -13
  49. package/dist/from-element.d.mts +12 -15
  50. package/dist/from-element.d.ts +12 -15
  51. package/dist/from-element.js +39 -58
  52. package/dist/from-element.mjs +35 -35
  53. package/dist/from-points.d.mts +2 -5
  54. package/dist/from-points.d.ts +2 -5
  55. package/dist/from-points.js +18 -36
  56. package/dist/from-points.mjs +14 -13
  57. package/dist/from-range.d.mts +2 -5
  58. package/dist/from-range.d.ts +2 -5
  59. package/dist/from-range.js +25 -46
  60. package/dist/from-range.mjs +19 -21
  61. package/dist/from-rotation.d.mts +4 -7
  62. package/dist/from-rotation.d.ts +4 -7
  63. package/dist/from-rotation.js +31 -56
  64. package/dist/from-rotation.mjs +25 -31
  65. package/dist/from-window.d.mts +13 -16
  66. package/dist/from-window.d.ts +13 -16
  67. package/dist/from-window.js +29 -44
  68. package/dist/from-window.mjs +24 -20
  69. package/dist/index.d.mts +22 -22
  70. package/dist/index.d.ts +22 -22
  71. package/dist/index.js +72 -63
  72. package/dist/index.mjs +21 -22
  73. package/dist/intersection.d.mts +4 -7
  74. package/dist/intersection.d.ts +4 -7
  75. package/dist/intersection.js +34 -45
  76. package/dist/intersection.mjs +28 -20
  77. package/dist/operations.d.mts +6 -9
  78. package/dist/operations.d.ts +6 -9
  79. package/dist/operations.js +38 -57
  80. package/dist/operations.mjs +30 -30
  81. package/dist/polygon.d.mts +6 -9
  82. package/dist/polygon.d.ts +6 -9
  83. package/dist/polygon.js +73 -82
  84. package/dist/polygon.mjs +67 -57
  85. package/dist/rect.d.mts +49 -52
  86. package/dist/rect.d.ts +49 -52
  87. package/dist/rect.js +57 -82
  88. package/dist/rect.mjs +46 -52
  89. package/dist/resize.d.mts +3 -6
  90. package/dist/resize.d.ts +3 -6
  91. package/dist/resize.js +73 -102
  92. package/dist/resize.mjs +68 -78
  93. package/dist/types.d.mts +45 -49
  94. package/dist/types.d.ts +45 -49
  95. package/dist/types.js +4 -18
  96. package/dist/types.mjs +1 -0
  97. package/dist/union.d.mts +2 -5
  98. package/dist/union.d.ts +2 -5
  99. package/dist/union.js +16 -39
  100. package/dist/union.mjs +12 -16
  101. package/package.json +3 -3
  102. package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/contains.js CHANGED
@@ -1,43 +1,18 @@
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/contains.ts
21
- var contains_exports = {};
22
- __export(contains_exports, {
23
- contains: () => contains,
24
- containsPoint: () => containsPoint,
25
- containsRect: () => containsRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(contains_exports);
28
- var import_rect = require("./rect.js");
5
+ const require_rect = require("./rect.js");
6
+ // src/contains.ts
29
7
  function containsPoint(r, p) {
30
- return r.minX <= p.x && p.x <= r.maxX && r.minY <= p.y && p.y <= r.maxY;
8
+ return r.minX <= p.x && p.x <= r.maxX && r.minY <= p.y && p.y <= r.maxY;
31
9
  }
32
10
  function containsRect(a, b) {
33
- return Object.values((0, import_rect.getRectCorners)(b)).every((c) => containsPoint(a, c));
11
+ return Object.values(require_rect.getRectCorners(b)).every((c) => containsPoint(a, c));
34
12
  }
35
13
  function contains(r, v) {
36
- return (0, import_rect.isRect)(v) ? containsRect(r, v) : containsPoint(r, v);
14
+ return require_rect.isRect(v) ? containsRect(r, v) : containsPoint(r, v);
37
15
  }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- contains,
41
- containsPoint,
42
- containsRect
43
- });
16
+ exports.contains = contains;
17
+ exports.containsPoint = containsPoint;
18
+ exports.containsRect = containsRect;
package/dist/contains.mjs CHANGED
@@ -1,18 +1,12 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/contains.ts
4
1
  import { getRectCorners, isRect } from "./rect.mjs";
2
+ // src/contains.ts
5
3
  function containsPoint(r, p) {
6
- return r.minX <= p.x && p.x <= r.maxX && r.minY <= p.y && p.y <= r.maxY;
4
+ return r.minX <= p.x && p.x <= r.maxX && r.minY <= p.y && p.y <= r.maxY;
7
5
  }
8
6
  function containsRect(a, b) {
9
- return Object.values(getRectCorners(b)).every((c) => containsPoint(a, c));
7
+ return Object.values(getRectCorners(b)).every((c) => containsPoint(a, c));
10
8
  }
11
9
  function contains(r, v) {
12
- return isRect(v) ? containsRect(r, v) : containsPoint(r, v);
10
+ return isRect(v) ? containsRect(r, v) : containsPoint(r, v);
13
11
  }
14
- export {
15
- contains,
16
- containsPoint,
17
- containsRect
18
- };
12
+ export { contains, containsPoint, containsRect };
@@ -1,11 +1,8 @@
1
- import { Point, Rect, RectSide } from './types.mjs';
2
-
3
- interface DistanceValue extends Point {
4
- value: number;
1
+ import { Point, Rect, RectSide } from "./types.mjs";
2
+ export interface DistanceValue extends Point {
3
+ value: number;
5
4
  }
6
- declare function distance(a: Point, b?: Point): number;
7
- declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
8
- declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
9
- declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
10
-
11
- export { type DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect };
5
+ export declare function distance(a: Point, b?: Point): number;
6
+ export declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
7
+ export declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
8
+ export declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
@@ -1,11 +1,8 @@
1
- import { Point, Rect, RectSide } from './types.js';
2
-
3
- interface DistanceValue extends Point {
4
- value: number;
1
+ import { Point, Rect, RectSide } from "./types.js";
2
+ export interface DistanceValue extends Point {
3
+ value: number;
5
4
  }
6
- declare function distance(a: Point, b?: Point): number;
7
- declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
8
- declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
9
- declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
10
-
11
- export { type DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect };
5
+ export declare function distance(a: Point, b?: Point): number;
6
+ export declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
7
+ export declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
8
+ export declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
package/dist/distance.js CHANGED
@@ -1,68 +1,63 @@
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/distance.ts
21
- var distance_exports = {};
22
- __export(distance_exports, {
23
- distance: () => distance,
24
- distanceBtwEdges: () => distanceBtwEdges,
25
- distanceFromPoint: () => distanceFromPoint,
26
- distanceFromRect: () => distanceFromRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
27
4
  });
28
- module.exports = __toCommonJS(distance_exports);
29
- var import_intersection = require("./intersection.js");
30
- function distance(a, b = { x: 0, y: 0 }) {
31
- return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
5
+ const require_intersection = require("./intersection.js");
6
+ // src/distance.ts
7
+ function distance(a, b = {
8
+ x: 0,
9
+ y: 0
10
+ }) {
11
+ return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
32
12
  }
33
13
  function distanceFromPoint(r, p) {
34
- let x = 0;
35
- let y = 0;
36
- if (p.x < r.x) x = r.x - p.x;
37
- else if (p.x > r.maxX) x = p.x - r.maxX;
38
- if (p.y < r.y) y = r.y - p.y;
39
- else if (p.y > r.maxY) y = p.y - r.maxY;
40
- return { x, y, value: distance({ x, y }) };
14
+ let x = 0;
15
+ let y = 0;
16
+ if (p.x < r.x) x = r.x - p.x;
17
+ else if (p.x > r.maxX) x = p.x - r.maxX;
18
+ if (p.y < r.y) y = r.y - p.y;
19
+ else if (p.y > r.maxY) y = p.y - r.maxY;
20
+ return {
21
+ x,
22
+ y,
23
+ value: distance({
24
+ x,
25
+ y
26
+ })
27
+ };
41
28
  }
42
29
  function distanceFromRect(a, b) {
43
- if ((0, import_intersection.intersects)(a, b)) return { x: 0, y: 0, value: 0 };
44
- const left = a.x < b.x ? a : b;
45
- const right = b.x < a.x ? a : b;
46
- const upper = a.y < b.y ? a : b;
47
- const lower = b.y < a.y ? a : b;
48
- let x = left.x === right.x ? 0 : right.x - left.maxX;
49
- x = Math.max(0, x);
50
- let y = upper.y === lower.y ? 0 : lower.y - upper.maxY;
51
- y = Math.max(0, y);
52
- return { x, y, value: distance({ x, y }) };
30
+ if (require_intersection.intersects(a, b)) return {
31
+ x: 0,
32
+ y: 0,
33
+ value: 0
34
+ };
35
+ const left = a.x < b.x ? a : b;
36
+ const right = b.x < a.x ? a : b;
37
+ const upper = a.y < b.y ? a : b;
38
+ const lower = b.y < a.y ? a : b;
39
+ let x = left.x === right.x ? 0 : right.x - left.maxX;
40
+ x = Math.max(0, x);
41
+ let y = upper.y === lower.y ? 0 : lower.y - upper.maxY;
42
+ y = Math.max(0, y);
43
+ return {
44
+ x,
45
+ y,
46
+ value: distance({
47
+ x,
48
+ y
49
+ })
50
+ };
53
51
  }
54
52
  function distanceBtwEdges(a, b) {
55
- return {
56
- left: b.x - a.x,
57
- top: b.y - a.y,
58
- right: a.maxX - b.maxX,
59
- bottom: a.maxY - b.maxY
60
- };
53
+ return {
54
+ left: b.x - a.x,
55
+ top: b.y - a.y,
56
+ right: a.maxX - b.maxX,
57
+ bottom: a.maxY - b.maxY
58
+ };
61
59
  }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- distance,
65
- distanceBtwEdges,
66
- distanceFromPoint,
67
- distanceFromRect
68
- });
60
+ exports.distance = distance;
61
+ exports.distanceBtwEdges = distanceBtwEdges;
62
+ exports.distanceFromPoint = distanceFromPoint;
63
+ exports.distanceFromRect = distanceFromRect;
package/dist/distance.mjs CHANGED
@@ -1,42 +1,56 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/distance.ts
4
1
  import { intersects } from "./intersection.mjs";
5
- function distance(a, b = { x: 0, y: 0 }) {
6
- return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
2
+ // src/distance.ts
3
+ function distance(a, b = {
4
+ x: 0,
5
+ y: 0
6
+ }) {
7
+ return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
7
8
  }
8
9
  function distanceFromPoint(r, p) {
9
- let x = 0;
10
- let y = 0;
11
- if (p.x < r.x) x = r.x - p.x;
12
- else if (p.x > r.maxX) x = p.x - r.maxX;
13
- if (p.y < r.y) y = r.y - p.y;
14
- else if (p.y > r.maxY) y = p.y - r.maxY;
15
- return { x, y, value: distance({ x, y }) };
10
+ let x = 0;
11
+ let y = 0;
12
+ if (p.x < r.x) x = r.x - p.x;
13
+ else if (p.x > r.maxX) x = p.x - r.maxX;
14
+ if (p.y < r.y) y = r.y - p.y;
15
+ else if (p.y > r.maxY) y = p.y - r.maxY;
16
+ return {
17
+ x,
18
+ y,
19
+ value: distance({
20
+ x,
21
+ y
22
+ })
23
+ };
16
24
  }
17
25
  function distanceFromRect(a, b) {
18
- if (intersects(a, b)) return { x: 0, y: 0, value: 0 };
19
- const left = a.x < b.x ? a : b;
20
- const right = b.x < a.x ? a : b;
21
- const upper = a.y < b.y ? a : b;
22
- const lower = b.y < a.y ? a : b;
23
- let x = left.x === right.x ? 0 : right.x - left.maxX;
24
- x = Math.max(0, x);
25
- let y = upper.y === lower.y ? 0 : lower.y - upper.maxY;
26
- y = Math.max(0, y);
27
- return { x, y, value: distance({ x, y }) };
26
+ if (intersects(a, b)) return {
27
+ x: 0,
28
+ y: 0,
29
+ value: 0
30
+ };
31
+ const left = a.x < b.x ? a : b;
32
+ const right = b.x < a.x ? a : b;
33
+ const upper = a.y < b.y ? a : b;
34
+ const lower = b.y < a.y ? a : b;
35
+ let x = left.x === right.x ? 0 : right.x - left.maxX;
36
+ x = Math.max(0, x);
37
+ let y = upper.y === lower.y ? 0 : lower.y - upper.maxY;
38
+ y = Math.max(0, y);
39
+ return {
40
+ x,
41
+ y,
42
+ value: distance({
43
+ x,
44
+ y
45
+ })
46
+ };
28
47
  }
29
48
  function distanceBtwEdges(a, b) {
30
- return {
31
- left: b.x - a.x,
32
- top: b.y - a.y,
33
- right: a.maxX - b.maxX,
34
- bottom: a.maxY - b.maxY
35
- };
49
+ return {
50
+ left: b.x - a.x,
51
+ top: b.y - a.y,
52
+ right: a.maxX - b.maxX,
53
+ bottom: a.maxY - b.maxY
54
+ };
36
55
  }
37
- export {
38
- distance,
39
- distanceBtwEdges,
40
- distanceFromPoint,
41
- distanceFromRect
42
- };
56
+ export { distance, distanceBtwEdges, distanceFromPoint, distanceFromRect };
@@ -1,7 +1,4 @@
1
- import { Point, RectInit, Size } from './types.mjs';
2
-
3
- declare const isSizeEqual: (a: Size, b: Size | undefined) => boolean;
4
- declare const isPointEqual: (a: Point, b: Point | undefined) => boolean;
5
- declare const isRectEqual: (a: RectInit, b: RectInit | undefined) => boolean;
6
-
7
- export { isPointEqual, isRectEqual, isSizeEqual };
1
+ import { Point, RectInit, Size } from "./types.mjs";
2
+ export declare const isSizeEqual: (a: Size, b: Size | undefined) => boolean;
3
+ export declare const isPointEqual: (a: Point, b: Point | undefined) => boolean;
4
+ export declare const isRectEqual: (a: RectInit, b: RectInit | undefined) => boolean;
@@ -1,7 +1,4 @@
1
- import { Point, RectInit, Size } from './types.js';
2
-
3
- declare const isSizeEqual: (a: Size, b: Size | undefined) => boolean;
4
- declare const isPointEqual: (a: Point, b: Point | undefined) => boolean;
5
- declare const isRectEqual: (a: RectInit, b: RectInit | undefined) => boolean;
6
-
7
- export { isPointEqual, isRectEqual, isSizeEqual };
1
+ import { Point, RectInit, Size } from "./types.js";
2
+ export declare const isSizeEqual: (a: Size, b: Size | undefined) => boolean;
3
+ export declare const isPointEqual: (a: Point, b: Point | undefined) => boolean;
4
+ export declare const isRectEqual: (a: RectInit, b: RectInit | undefined) => boolean;
package/dist/equality.js CHANGED
@@ -1,42 +1,17 @@
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/equality.ts
21
- var equality_exports = {};
22
- __export(equality_exports, {
23
- isPointEqual: () => isPointEqual,
24
- isRectEqual: () => isRectEqual,
25
- isSizeEqual: () => isSizeEqual
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(equality_exports);
28
- var isSizeEqual = (a, b) => {
29
- return a.width === b?.width && a.height === b?.height;
5
+ // src/equality.ts
6
+ const isSizeEqual = (a, b) => {
7
+ return a.width === b?.width && a.height === b?.height;
30
8
  };
31
- var isPointEqual = (a, b) => {
32
- return a.x === b?.x && a.y === b?.y;
9
+ const isPointEqual = (a, b) => {
10
+ return a.x === b?.x && a.y === b?.y;
33
11
  };
34
- var isRectEqual = (a, b) => {
35
- return isPointEqual(a, b) && isSizeEqual(a, b);
12
+ const isRectEqual = (a, b) => {
13
+ return isPointEqual(a, b) && isSizeEqual(a, b);
36
14
  };
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- isPointEqual,
40
- isRectEqual,
41
- isSizeEqual
42
- });
15
+ exports.isPointEqual = isPointEqual;
16
+ exports.isRectEqual = isRectEqual;
17
+ exports.isSizeEqual = isSizeEqual;
package/dist/equality.mjs CHANGED
@@ -1,17 +1,11 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
1
  // src/equality.ts
4
- var isSizeEqual = (a, b) => {
5
- return a.width === b?.width && a.height === b?.height;
2
+ const isSizeEqual = (a, b) => {
3
+ return a.width === b?.width && a.height === b?.height;
6
4
  };
7
- var isPointEqual = (a, b) => {
8
- return a.x === b?.x && a.y === b?.y;
5
+ const isPointEqual = (a, b) => {
6
+ return a.x === b?.x && a.y === b?.y;
9
7
  };
10
- var isRectEqual = (a, b) => {
11
- return isPointEqual(a, b) && isSizeEqual(a, b);
12
- };
13
- export {
14
- isPointEqual,
15
- isRectEqual,
16
- isSizeEqual
8
+ const isRectEqual = (a, b) => {
9
+ return isPointEqual(a, b) && isSizeEqual(a, b);
17
10
  };
11
+ export { isPointEqual, isRectEqual, isSizeEqual };
@@ -1,15 +1,12 @@
1
- import { Rect } from './types.mjs';
2
-
3
- declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
4
- type ElementRectOptions = {
5
- /**
6
- * Whether to exclude the element's scrollbar size from the calculation.
7
- */
8
- excludeScrollbar?: boolean | undefined;
9
- /**
10
- * Whether to exclude the element's borders from the calculation.
11
- */
12
- excludeBorders?: boolean | undefined;
13
- };
14
-
15
- export { type ElementRectOptions, getElementRect };
1
+ import { Rect } from "./types.mjs";
2
+ export declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
3
+ export type ElementRectOptions = {
4
+ /**
5
+ * Whether to exclude the element's scrollbar size from the calculation.
6
+ */
7
+ excludeScrollbar?: boolean | undefined;
8
+ /**
9
+ * Whether to exclude the element's borders from the calculation.
10
+ */
11
+ excludeBorders?: boolean | undefined;
12
+ };
@@ -1,15 +1,12 @@
1
- import { Rect } from './types.js';
2
-
3
- declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
4
- type ElementRectOptions = {
5
- /**
6
- * Whether to exclude the element's scrollbar size from the calculation.
7
- */
8
- excludeScrollbar?: boolean | undefined;
9
- /**
10
- * Whether to exclude the element's borders from the calculation.
11
- */
12
- excludeBorders?: boolean | undefined;
13
- };
14
-
15
- export { type ElementRectOptions, getElementRect };
1
+ import { Rect } from "./types.js";
2
+ export declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
3
+ export type ElementRectOptions = {
4
+ /**
5
+ * Whether to exclude the element's scrollbar size from the calculation.
6
+ */
7
+ excludeScrollbar?: boolean | undefined;
8
+ /**
9
+ * Whether to exclude the element's borders from the calculation.
10
+ */
11
+ excludeBorders?: boolean | undefined;
12
+ };
@@ -1,65 +1,46 @@
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/from-element.ts
21
- var from_element_exports = {};
22
- __export(from_element_exports, {
23
- getElementRect: () => getElementRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(from_element_exports);
26
- var import_rect = require("./rect.js");
27
- var styleCache = /* @__PURE__ */ new WeakMap();
5
+ const require_rect = require("./rect.js");
6
+ // src/from-element.ts
7
+ const styleCache = /* @__PURE__ */ new WeakMap();
28
8
  function getCacheComputedStyle(el) {
29
- if (!styleCache.has(el)) {
30
- const win = el.ownerDocument.defaultView || window;
31
- styleCache.set(el, win.getComputedStyle(el));
32
- }
33
- return styleCache.get(el);
9
+ if (!styleCache.has(el)) {
10
+ const win = el.ownerDocument.defaultView || window;
11
+ styleCache.set(el, win.getComputedStyle(el));
12
+ }
13
+ return styleCache.get(el);
34
14
  }
35
15
  function getElementRect(el, opts = {}) {
36
- return (0, import_rect.createRect)(getClientRect(el, opts));
16
+ return require_rect.createRect(getClientRect(el, opts));
37
17
  }
38
18
  function getClientRect(el, opts = {}) {
39
- const { excludeScrollbar = false, excludeBorders = false } = opts;
40
- const { x, y, width, height } = el.getBoundingClientRect();
41
- const r = { x, y, width, height };
42
- const style = getCacheComputedStyle(el);
43
- const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style;
44
- const borderXWidth = sum(borderLeftWidth, borderRightWidth);
45
- const borderYWidth = sum(borderTopWidth, borderBottomWidth);
46
- if (excludeBorders) {
47
- r.width -= borderXWidth;
48
- r.height -= borderYWidth;
49
- r.x += px(borderLeftWidth);
50
- r.y += px(borderTopWidth);
51
- }
52
- if (excludeScrollbar) {
53
- const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
54
- const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
55
- r.width -= scrollbarWidth;
56
- r.height -= scrollbarHeight;
57
- }
58
- return r;
19
+ const { excludeScrollbar = false, excludeBorders = false } = opts;
20
+ const { x, y, width, height } = el.getBoundingClientRect();
21
+ const r = {
22
+ x,
23
+ y,
24
+ width,
25
+ height
26
+ };
27
+ const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = getCacheComputedStyle(el);
28
+ const borderXWidth = sum(borderLeftWidth, borderRightWidth);
29
+ const borderYWidth = sum(borderTopWidth, borderBottomWidth);
30
+ if (excludeBorders) {
31
+ r.width -= borderXWidth;
32
+ r.height -= borderYWidth;
33
+ r.x += px(borderLeftWidth);
34
+ r.y += px(borderTopWidth);
35
+ }
36
+ if (excludeScrollbar) {
37
+ const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
38
+ const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
39
+ r.width -= scrollbarWidth;
40
+ r.height -= scrollbarHeight;
41
+ }
42
+ return r;
59
43
  }
60
- var px = (v) => parseFloat(v.replace("px", ""));
61
- var sum = (...vals) => vals.reduce((sum2, v) => sum2 + (v ? px(v) : 0), 0);
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- getElementRect
65
- });
44
+ const px = (v) => parseFloat(v.replace("px", ""));
45
+ const sum = (...vals) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0);
46
+ exports.getElementRect = getElementRect;