@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.
- 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 -19
- 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 -7
- 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 -20
- 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 -35
- package/dist/compass.d.mts +1 -3
- package/dist/compass.d.ts +1 -3
- package/dist/compass.js +4 -18
- package/dist/compass.mjs +1 -0
- 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 -12
- 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 -9
- 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 -32
- 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 -11
- 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 -33
- 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 -11
- 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 -19
- 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 -29
- 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 -18
- package/dist/index.d.mts +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +91 -61
- package/dist/index.mjs +20 -21
- package/dist/interact.d.mts +34 -37
- package/dist/interact.d.ts +34 -37
- package/dist/interact.js +414 -350
- package/dist/interact.mjs +396 -311
- 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 -18
- 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 -28
- 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 -55
- package/dist/rect.d.mts +55 -58
- package/dist/rect.d.ts +55 -58
- package/dist/rect.js +88 -117
- package/dist/rect.mjs +70 -78
- package/dist/types.d.mts +42 -46
- package/dist/types.d.ts +42 -46
- 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 -14
- package/package.json +2 -2
package/dist/rect.mjs
CHANGED
|
@@ -1,97 +1,89 @@
|
|
|
1
1
|
// src/rect.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const ZERO_POINT = Object.freeze({
|
|
3
|
+
x: 0,
|
|
4
|
+
y: 0
|
|
5
|
+
});
|
|
6
|
+
const createPoint = (x, y) => ({
|
|
7
|
+
x,
|
|
8
|
+
y
|
|
9
|
+
});
|
|
10
|
+
const subtractPoints = (a, b) => {
|
|
11
|
+
if (!b) return a;
|
|
12
|
+
return createPoint(a.x - b.x, a.y - b.y);
|
|
7
13
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const addPoints = (a, b) => createPoint(a.x + b.x, a.y + b.y);
|
|
15
|
+
const getMidpoint = (a, b, offset) => ({
|
|
16
|
+
x: (a.x + b.x) / 2 - (offset?.x ?? 0),
|
|
17
|
+
y: (a.y + b.y) / 2 - (offset?.y ?? 0)
|
|
12
18
|
});
|
|
13
19
|
function isPoint(v) {
|
|
14
|
-
|
|
20
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y");
|
|
15
21
|
}
|
|
16
22
|
function createRect(r) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
const { x, y, width, height } = r;
|
|
24
|
+
const midX = x + width / 2;
|
|
25
|
+
const midY = y + height / 2;
|
|
26
|
+
return {
|
|
27
|
+
x,
|
|
28
|
+
y,
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
minX: x,
|
|
32
|
+
minY: y,
|
|
33
|
+
maxX: x + width,
|
|
34
|
+
maxY: y + height,
|
|
35
|
+
midX,
|
|
36
|
+
midY,
|
|
37
|
+
center: createPoint(midX, midY)
|
|
38
|
+
};
|
|
33
39
|
}
|
|
34
40
|
function isRect(v) {
|
|
35
|
-
|
|
41
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y") && Reflect.has(v, "width") && Reflect.has(v, "height");
|
|
36
42
|
}
|
|
37
43
|
function getRectCenters(v) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
return {
|
|
45
|
+
top: createPoint(v.midX, v.minY),
|
|
46
|
+
right: createPoint(v.maxX, v.midY),
|
|
47
|
+
bottom: createPoint(v.midX, v.maxY),
|
|
48
|
+
left: createPoint(v.minX, v.midY)
|
|
49
|
+
};
|
|
43
50
|
}
|
|
44
51
|
function getRectCorners(v) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
return {
|
|
53
|
+
top: createPoint(v.minX, v.minY),
|
|
54
|
+
right: createPoint(v.maxX, v.minY),
|
|
55
|
+
bottom: createPoint(v.maxX, v.maxY),
|
|
56
|
+
left: createPoint(v.minX, v.maxY)
|
|
57
|
+
};
|
|
50
58
|
}
|
|
51
59
|
function getRectEdges(v) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const c = getRectCorners(v);
|
|
61
|
+
return {
|
|
62
|
+
top: [c.top, c.right],
|
|
63
|
+
right: [c.right, c.bottom],
|
|
64
|
+
bottom: [c.left, c.bottom],
|
|
65
|
+
left: [c.top, c.left]
|
|
66
|
+
};
|
|
58
67
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
const getCenterPoint = (rect) => ({
|
|
69
|
+
x: rect.x + rect.width / 2,
|
|
70
|
+
y: rect.y + rect.height / 2
|
|
62
71
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
const isVisibleSize = (size) => size.width > 0 && size.height > 0;
|
|
73
|
+
const scaleSize = (size, factor) => ({
|
|
74
|
+
width: size.width * factor,
|
|
75
|
+
height: size.height * factor
|
|
67
76
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
const scaleRect = (rect, scale) => ({
|
|
78
|
+
x: rect.x * scale.x,
|
|
79
|
+
y: rect.y * scale.y,
|
|
80
|
+
width: rect.width * scale.x,
|
|
81
|
+
height: rect.height * scale.y
|
|
73
82
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
const roundRect = (rect) => ({
|
|
84
|
+
x: Math.round(rect.x),
|
|
85
|
+
y: Math.round(rect.y),
|
|
86
|
+
width: Math.round(rect.width),
|
|
87
|
+
height: Math.round(rect.height)
|
|
79
88
|
});
|
|
80
|
-
export {
|
|
81
|
-
ZERO_POINT,
|
|
82
|
-
addPoints,
|
|
83
|
-
createPoint,
|
|
84
|
-
createRect,
|
|
85
|
-
getCenterPoint,
|
|
86
|
-
getMidpoint,
|
|
87
|
-
getRectCenters,
|
|
88
|
-
getRectCorners,
|
|
89
|
-
getRectEdges,
|
|
90
|
-
isPoint,
|
|
91
|
-
isRect,
|
|
92
|
-
isVisibleSize,
|
|
93
|
-
roundRect,
|
|
94
|
-
scaleRect,
|
|
95
|
-
scaleSize,
|
|
96
|
-
subtractPoints
|
|
97
|
-
};
|
|
89
|
+
export { ZERO_POINT, addPoints, createPoint, createRect, getCenterPoint, getMidpoint, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, isVisibleSize, roundRect, scaleRect, scaleSize, subtractPoints };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
|
-
interface Point {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
interface Size {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
interface Bounds {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
interface CenterPoint {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
interface RectInit extends Point, Size {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
|
|
28
|
-
type RectEdges = Record<RectSide, RectEdge> & {
|
|
29
|
-
value: RectEdge[];
|
|
1
|
+
export interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Size {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Bounds {
|
|
10
|
+
minX: number;
|
|
11
|
+
midX: number;
|
|
12
|
+
maxX: number;
|
|
13
|
+
minY: number;
|
|
14
|
+
midY: number;
|
|
15
|
+
maxY: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CenterPoint {
|
|
18
|
+
center: Point;
|
|
19
|
+
}
|
|
20
|
+
export interface RectInit extends Point, Size {}
|
|
21
|
+
export interface Rect extends Point, Size, Bounds, CenterPoint {}
|
|
22
|
+
export type RectSide = "top" | "right" | "bottom" | "left";
|
|
23
|
+
export type RectPoint = "top-left" | "top-center" | "top-right" | "right-center" | "left-center" | "bottom-left" | "bottom-right" | "bottom-center" | "center";
|
|
24
|
+
export type RectEdge = [Point, Point];
|
|
25
|
+
export type RectPoints = [Point, Point, Point, Point];
|
|
26
|
+
export type RectEdges = Record<RectSide, RectEdge> & {
|
|
27
|
+
value: RectEdge[];
|
|
30
28
|
};
|
|
31
|
-
type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
32
|
-
type RectCorners = Record<RectCorner, Point> & {
|
|
33
|
-
|
|
29
|
+
export type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
30
|
+
export type RectCorners = Record<RectCorner, Point> & {
|
|
31
|
+
value: RectPoints;
|
|
34
32
|
};
|
|
35
|
-
type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
|
|
36
|
-
type RectCenters = Record<RectCenter, Point> & {
|
|
37
|
-
|
|
33
|
+
export type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
|
|
34
|
+
export type RectCenters = Record<RectCenter, Point> & {
|
|
35
|
+
value: RectPoints;
|
|
38
36
|
};
|
|
39
|
-
type RectInset = Partial<Record<RectSide, number>>;
|
|
40
|
-
interface SymmetricRectInset {
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
export type RectInset = Partial<Record<RectSide, number>>;
|
|
38
|
+
export interface SymmetricRectInset {
|
|
39
|
+
dx?: number | undefined;
|
|
40
|
+
dy?: number | undefined;
|
|
43
41
|
}
|
|
44
|
-
interface AlignOptions {
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
export interface AlignOptions {
|
|
43
|
+
h: HAlign;
|
|
44
|
+
v: VAlign;
|
|
47
45
|
}
|
|
48
|
-
type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
|
|
49
|
-
type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
|
|
50
|
-
|
|
51
|
-
export type { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, Size, SymmetricRectInset, VAlign };
|
|
46
|
+
export type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
|
|
47
|
+
export type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
|
-
interface Point {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
interface Size {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
interface Bounds {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
interface CenterPoint {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
interface RectInit extends Point, Size {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
|
|
28
|
-
type RectEdges = Record<RectSide, RectEdge> & {
|
|
29
|
-
value: RectEdge[];
|
|
1
|
+
export interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Size {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Bounds {
|
|
10
|
+
minX: number;
|
|
11
|
+
midX: number;
|
|
12
|
+
maxX: number;
|
|
13
|
+
minY: number;
|
|
14
|
+
midY: number;
|
|
15
|
+
maxY: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CenterPoint {
|
|
18
|
+
center: Point;
|
|
19
|
+
}
|
|
20
|
+
export interface RectInit extends Point, Size {}
|
|
21
|
+
export interface Rect extends Point, Size, Bounds, CenterPoint {}
|
|
22
|
+
export type RectSide = "top" | "right" | "bottom" | "left";
|
|
23
|
+
export type RectPoint = "top-left" | "top-center" | "top-right" | "right-center" | "left-center" | "bottom-left" | "bottom-right" | "bottom-center" | "center";
|
|
24
|
+
export type RectEdge = [Point, Point];
|
|
25
|
+
export type RectPoints = [Point, Point, Point, Point];
|
|
26
|
+
export type RectEdges = Record<RectSide, RectEdge> & {
|
|
27
|
+
value: RectEdge[];
|
|
30
28
|
};
|
|
31
|
-
type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
32
|
-
type RectCorners = Record<RectCorner, Point> & {
|
|
33
|
-
|
|
29
|
+
export type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
30
|
+
export type RectCorners = Record<RectCorner, Point> & {
|
|
31
|
+
value: RectPoints;
|
|
34
32
|
};
|
|
35
|
-
type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
|
|
36
|
-
type RectCenters = Record<RectCenter, Point> & {
|
|
37
|
-
|
|
33
|
+
export type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
|
|
34
|
+
export type RectCenters = Record<RectCenter, Point> & {
|
|
35
|
+
value: RectPoints;
|
|
38
36
|
};
|
|
39
|
-
type RectInset = Partial<Record<RectSide, number>>;
|
|
40
|
-
interface SymmetricRectInset {
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
export type RectInset = Partial<Record<RectSide, number>>;
|
|
38
|
+
export interface SymmetricRectInset {
|
|
39
|
+
dx?: number | undefined;
|
|
40
|
+
dy?: number | undefined;
|
|
43
41
|
}
|
|
44
|
-
interface AlignOptions {
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
export interface AlignOptions {
|
|
43
|
+
h: HAlign;
|
|
44
|
+
v: VAlign;
|
|
47
45
|
}
|
|
48
|
-
type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
|
|
49
|
-
type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
|
|
50
|
-
|
|
51
|
-
export type { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, Size, SymmetricRectInset, VAlign };
|
|
46
|
+
export type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
|
|
47
|
+
export type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
|
package/dist/types.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
package/dist/types.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/union.d.mts
CHANGED
package/dist/union.d.ts
CHANGED
package/dist/union.js
CHANGED
|
@@ -1,42 +1,19 @@
|
|
|
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/union.ts
|
|
21
|
-
var union_exports = {};
|
|
22
|
-
__export(union_exports, {
|
|
23
|
-
union: () => union
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
4
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
const require_from_points = require("./from-points.js");
|
|
6
|
+
// src/union.ts
|
|
7
|
+
const { min, max } = Math;
|
|
28
8
|
function union(...rs) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
const pMin = {
|
|
10
|
+
x: min(...rs.map((r) => r.minX)),
|
|
11
|
+
y: min(...rs.map((r) => r.minY))
|
|
12
|
+
};
|
|
13
|
+
const pMax = {
|
|
14
|
+
x: max(...rs.map((r) => r.maxX)),
|
|
15
|
+
y: max(...rs.map((r) => r.maxY))
|
|
16
|
+
};
|
|
17
|
+
return require_from_points.getRectFromPoints(pMin, pMax);
|
|
38
18
|
}
|
|
39
|
-
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
union
|
|
42
|
-
});
|
|
19
|
+
exports.union = union;
|
package/dist/union.mjs
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
// src/union.ts
|
|
2
1
|
import { getRectFromPoints } from "./from-points.mjs";
|
|
3
|
-
|
|
2
|
+
// src/union.ts
|
|
3
|
+
const { min, max } = Math;
|
|
4
4
|
function union(...rs) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const pMin = {
|
|
6
|
+
x: min(...rs.map((r) => r.minX)),
|
|
7
|
+
y: min(...rs.map((r) => r.minY))
|
|
8
|
+
};
|
|
9
|
+
const pMax = {
|
|
10
|
+
x: max(...rs.map((r) => r.maxX)),
|
|
11
|
+
y: max(...rs.map((r) => r.maxY))
|
|
12
|
+
};
|
|
13
|
+
return getRectFromPoints(pMin, pMax);
|
|
14
14
|
}
|
|
15
|
-
export {
|
|
16
|
-
union
|
|
17
|
-
};
|
|
15
|
+
export { union };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/rect-utils",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"./package.json": "./package.json"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "
|
|
48
|
+
"build": "tsdown",
|
|
49
49
|
"lint": "oxlint src",
|
|
50
50
|
"typecheck": "tsc --noEmit"
|
|
51
51
|
}
|