@zag-js/rect-utils 1.47.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.
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
- package/dist/affine-transform.d.mts +36 -39
- package/dist/affine-transform.d.ts +36 -39
- package/dist/affine-transform.js +189 -187
- package/dist/affine-transform.mjs +185 -164
- package/dist/align.d.mts +2 -5
- package/dist/align.d.ts +2 -5
- package/dist/align.js +27 -44
- package/dist/align.mjs +23 -21
- package/dist/angle.d.mts +2 -5
- package/dist/angle.d.ts +2 -5
- package/dist/angle.js +8 -32
- package/dist/angle.mjs +4 -9
- package/dist/clamp.d.mts +8 -11
- package/dist/clamp.d.ts +8 -11
- package/dist/clamp.js +23 -46
- package/dist/clamp.mjs +18 -22
- package/dist/closest.d.mts +4 -7
- package/dist/closest.d.ts +4 -7
- package/dist/closest.js +35 -62
- package/dist/closest.mjs +29 -37
- package/dist/compass.d.mts +4 -7
- package/dist/compass.d.ts +4 -7
- package/dist/compass.js +48 -48
- package/dist/compass.mjs +43 -24
- package/dist/constrain.d.mts +2 -5
- package/dist/constrain.d.ts +2 -5
- package/dist/constrain.js +12 -37
- package/dist/constrain.mjs +8 -14
- package/dist/contains.d.mts +4 -7
- package/dist/contains.d.ts +4 -7
- package/dist/contains.js +11 -36
- package/dist/contains.mjs +5 -11
- package/dist/distance.d.mts +7 -10
- package/dist/distance.d.ts +7 -10
- package/dist/distance.js +55 -60
- package/dist/distance.mjs +48 -34
- package/dist/equality.d.mts +4 -7
- package/dist/equality.d.ts +4 -7
- package/dist/equality.js +13 -38
- package/dist/equality.mjs +7 -13
- package/dist/from-element.d.mts +12 -15
- package/dist/from-element.d.ts +12 -15
- package/dist/from-element.js +39 -58
- package/dist/from-element.mjs +35 -35
- package/dist/from-points.d.mts +2 -5
- package/dist/from-points.d.ts +2 -5
- package/dist/from-points.js +18 -36
- package/dist/from-points.mjs +14 -13
- package/dist/from-range.d.mts +2 -5
- package/dist/from-range.d.ts +2 -5
- package/dist/from-range.js +25 -46
- package/dist/from-range.mjs +19 -21
- package/dist/from-rotation.d.mts +4 -7
- package/dist/from-rotation.d.ts +4 -7
- package/dist/from-rotation.js +31 -56
- package/dist/from-rotation.mjs +25 -31
- package/dist/from-window.d.mts +13 -16
- package/dist/from-window.d.ts +13 -16
- package/dist/from-window.js +29 -44
- package/dist/from-window.mjs +24 -20
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +22 -22
- package/dist/index.js +72 -63
- package/dist/index.mjs +21 -22
- package/dist/intersection.d.mts +4 -7
- package/dist/intersection.d.ts +4 -7
- package/dist/intersection.js +34 -45
- package/dist/intersection.mjs +28 -20
- package/dist/operations.d.mts +6 -9
- package/dist/operations.d.ts +6 -9
- package/dist/operations.js +38 -57
- package/dist/operations.mjs +30 -30
- package/dist/polygon.d.mts +6 -9
- package/dist/polygon.d.ts +6 -9
- package/dist/polygon.js +73 -82
- package/dist/polygon.mjs +67 -57
- package/dist/rect.d.mts +49 -52
- package/dist/rect.d.ts +49 -52
- package/dist/rect.js +57 -82
- package/dist/rect.mjs +46 -52
- package/dist/resize.d.mts +3 -6
- package/dist/resize.d.ts +3 -6
- package/dist/resize.js +73 -102
- package/dist/resize.mjs +68 -78
- package/dist/types.d.mts +45 -49
- package/dist/types.d.ts +45 -49
- package/dist/types.js +4 -18
- package/dist/types.mjs +1 -0
- package/dist/union.d.mts +2 -5
- package/dist/union.d.ts +2 -5
- package/dist/union.js +16 -39
- package/dist/union.mjs +12 -16
- package/package.json +3 -3
- package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/contains.js
CHANGED
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
28
|
-
|
|
5
|
+
const require_rect = require("./rect.js");
|
|
6
|
+
// src/contains.ts
|
|
29
7
|
function containsPoint(r, p) {
|
|
30
|
-
|
|
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
|
-
|
|
11
|
+
return Object.values(require_rect.getRectCorners(b)).every((c) => containsPoint(a, c));
|
|
34
12
|
}
|
|
35
13
|
function contains(r, v) {
|
|
36
|
-
|
|
14
|
+
return require_rect.isRect(v) ? containsRect(r, v) : containsPoint(r, v);
|
|
37
15
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
return Object.values(getRectCorners(b)).every((c) => containsPoint(a, c));
|
|
10
8
|
}
|
|
11
9
|
function contains(r, v) {
|
|
12
|
-
|
|
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 };
|
package/dist/distance.d.mts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { Point, Rect, RectSide } from
|
|
2
|
-
|
|
3
|
-
|
|
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>;
|
package/dist/distance.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { Point, Rect, RectSide } from
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
function distance(a, b = {
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 };
|
package/dist/equality.d.mts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point, RectInit, Size } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
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;
|
package/dist/equality.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Point, RectInit, Size } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
// src/equality.ts
|
|
6
|
+
const isSizeEqual = (a, b) => {
|
|
7
|
+
return a.width === b?.width && a.height === b?.height;
|
|
30
8
|
};
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
const isPointEqual = (a, b) => {
|
|
10
|
+
return a.x === b?.x && a.y === b?.y;
|
|
33
11
|
};
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
const isRectEqual = (a, b) => {
|
|
13
|
+
return isPointEqual(a, b) && isSizeEqual(a, b);
|
|
36
14
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
5
|
-
|
|
2
|
+
const isSizeEqual = (a, b) => {
|
|
3
|
+
return a.width === b?.width && a.height === b?.height;
|
|
6
4
|
};
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const isPointEqual = (a, b) => {
|
|
6
|
+
return a.x === b?.x && a.y === b?.y;
|
|
9
7
|
};
|
|
10
|
-
|
|
11
|
-
|
|
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 };
|
package/dist/from-element.d.mts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { Rect } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
package/dist/from-element.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { Rect } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
package/dist/from-element.js
CHANGED
|
@@ -1,65 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
const require_rect = require("./rect.js");
|
|
6
|
+
// src/from-element.ts
|
|
7
|
+
const styleCache = /* @__PURE__ */ new WeakMap();
|
|
28
8
|
function getCacheComputedStyle(el) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
16
|
+
return require_rect.createRect(getClientRect(el, opts));
|
|
37
17
|
}
|
|
38
18
|
function getClientRect(el, opts = {}) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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;
|