@zag-js/rect-utils 2.0.0-next.3 → 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/from-window.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { Rect } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
excludeScrollbar?: boolean | undefined;
|
|
1
|
+
import { Rect } from "./types.js";
|
|
2
|
+
export type WindowRectOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to exclude the element's scrollbar size from the calculation.
|
|
5
|
+
*/
|
|
6
|
+
excludeScrollbar?: boolean | undefined;
|
|
8
7
|
};
|
|
9
8
|
/**
|
|
10
9
|
* Creates a rectangle from window object
|
|
11
10
|
*/
|
|
12
|
-
declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
|
|
11
|
+
export declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
|
|
13
12
|
/**
|
|
14
13
|
* Get the rect of the window with the option to exclude the scrollbar
|
|
15
14
|
*/
|
|
16
|
-
declare function getViewportRect(win: Window, opts: WindowRectOptions): {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { type WindowRectOptions, getViewportRect, getWindowRect };
|
|
15
|
+
export declare function getViewportRect(win: Window, opts: WindowRectOptions): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
package/dist/from-window.js
CHANGED
|
@@ -1,49 +1,34 @@
|
|
|
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-window.ts
|
|
21
|
-
var from_window_exports = {};
|
|
22
|
-
__export(from_window_exports, {
|
|
23
|
-
getViewportRect: () => getViewportRect,
|
|
24
|
-
getWindowRect: () => getWindowRect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
const require_rect = require("./rect.js");
|
|
6
|
+
// src/from-window.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a rectangle from window object
|
|
9
|
+
*/
|
|
28
10
|
function getWindowRect(win, opts = {}) {
|
|
29
|
-
|
|
11
|
+
return require_rect.createRect(getViewportRect(win, opts));
|
|
30
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the rect of the window with the option to exclude the scrollbar
|
|
15
|
+
*/
|
|
31
16
|
function getViewportRect(win, opts) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
const { excludeScrollbar = false } = opts;
|
|
18
|
+
const { innerWidth, innerHeight, document: doc, visualViewport } = win;
|
|
19
|
+
const rect = {
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
width: visualViewport?.width || innerWidth,
|
|
23
|
+
height: visualViewport?.height || innerHeight
|
|
24
|
+
};
|
|
25
|
+
if (excludeScrollbar) {
|
|
26
|
+
const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
|
|
27
|
+
const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
|
|
28
|
+
rect.width -= scrollbarWidth;
|
|
29
|
+
rect.height -= scrollbarHeight;
|
|
30
|
+
}
|
|
31
|
+
return rect;
|
|
44
32
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
getViewportRect,
|
|
48
|
-
getWindowRect
|
|
49
|
-
});
|
|
33
|
+
exports.getViewportRect = getViewportRect;
|
|
34
|
+
exports.getWindowRect = getWindowRect;
|
package/dist/from-window.mjs
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
// src/from-window.ts
|
|
2
1
|
import { createRect } from "./rect.mjs";
|
|
2
|
+
// src/from-window.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a rectangle from window object
|
|
5
|
+
*/
|
|
3
6
|
function getWindowRect(win, opts = {}) {
|
|
4
|
-
|
|
7
|
+
return createRect(getViewportRect(win, opts));
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the rect of the window with the option to exclude the scrollbar
|
|
11
|
+
*/
|
|
6
12
|
function getViewportRect(win, opts) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const { excludeScrollbar = false } = opts;
|
|
14
|
+
const { innerWidth, innerHeight, document: doc, visualViewport } = win;
|
|
15
|
+
const rect = {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: visualViewport?.width || innerWidth,
|
|
19
|
+
height: visualViewport?.height || innerHeight
|
|
20
|
+
};
|
|
21
|
+
if (excludeScrollbar) {
|
|
22
|
+
const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
|
|
23
|
+
const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
|
|
24
|
+
rect.width -= scrollbarWidth;
|
|
25
|
+
rect.height -= scrollbarHeight;
|
|
26
|
+
}
|
|
27
|
+
return rect;
|
|
19
28
|
}
|
|
20
|
-
export {
|
|
21
|
-
getViewportRect,
|
|
22
|
-
getWindowRect
|
|
23
|
-
};
|
|
29
|
+
export { getViewportRect, getWindowRect };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { alignRect } from "./align.mjs";
|
|
2
|
+
import { getPointAngle } from "./angle.mjs";
|
|
3
|
+
import { clampPoint, clampSize } from "./clamp.mjs";
|
|
4
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.mjs";
|
|
5
|
+
import { constrainRect } from "./constrain.mjs";
|
|
6
|
+
import { contains, containsPoint, containsRect } from "./contains.mjs";
|
|
7
|
+
import { DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.mjs";
|
|
8
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.mjs";
|
|
9
|
+
import { ElementRectOptions, getElementRect } from "./from-element.mjs";
|
|
10
|
+
import { getRectFromPoints } from "./from-points.mjs";
|
|
11
|
+
import { fromRange } from "./from-range.mjs";
|
|
12
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.mjs";
|
|
13
|
+
import { WindowRectOptions, getViewportRect, getWindowRect } from "./from-window.mjs";
|
|
14
|
+
import { collisions, intersection, intersects } from "./intersection.mjs";
|
|
15
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.mjs";
|
|
16
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.mjs";
|
|
17
|
+
import { ZERO_POINT, addPoints, createPoint, createRect, getCenterPoint, getMidpoint, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, isVisibleSize, roundRect, scaleRect, scaleSize, subtractPoints } from "./rect.mjs";
|
|
18
|
+
import { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, Size, SymmetricRectInset, VAlign } from "./types.mjs";
|
|
19
|
+
import { HandlePosition, MoveOptions, ResizeOptions, applyMove, applyResize, centerInRect, centerOnPoint, clampPointInRange, getArrowKeyDelta, getDirectionDelta, getKeyboardResizeDelta, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isRightHandle, isTopHandle, isVerticalHandle } from "./interact.mjs";
|
|
20
|
+
import { union } from "./union.mjs";
|
|
21
|
+
export { AlignOptions, Bounds, CenterPoint, DistanceValue, ElementRectOptions, HAlign, HandlePosition, MoveOptions, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ResizeOptions, Size, SymmetricRectInset, VAlign, WindowRectOptions, ZERO_POINT, addPoints, alignRect, applyMove, applyResize, centerInRect, centerOnPoint, clampPoint, clampPointInRange, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getArrowKeyDelta, getCenterPoint, getDirectionDelta, getElementPolygon, getElementRect, getKeyboardResizeDelta, getMidpoint, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isRightHandle, isSizeEqual, isSymmetric, isTopHandle, isVerticalHandle, isVisibleSize, rotate, roundRect, scaleRect, scaleSize, shift, shrink, subtractPoints, toRad, union };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { alignRect } from "./align.js";
|
|
2
|
+
import { getPointAngle } from "./angle.js";
|
|
3
|
+
import { clampPoint, clampSize } from "./clamp.js";
|
|
4
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.js";
|
|
5
|
+
import { constrainRect } from "./constrain.js";
|
|
6
|
+
import { contains, containsPoint, containsRect } from "./contains.js";
|
|
7
|
+
import { DistanceValue, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.js";
|
|
8
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.js";
|
|
9
|
+
import { ElementRectOptions, getElementRect } from "./from-element.js";
|
|
10
|
+
import { getRectFromPoints } from "./from-points.js";
|
|
11
|
+
import { fromRange } from "./from-range.js";
|
|
12
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.js";
|
|
13
|
+
import { WindowRectOptions, getViewportRect, getWindowRect } from "./from-window.js";
|
|
14
|
+
import { collisions, intersection, intersects } from "./intersection.js";
|
|
15
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.js";
|
|
16
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.js";
|
|
17
|
+
import { ZERO_POINT, addPoints, createPoint, createRect, getCenterPoint, getMidpoint, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, isVisibleSize, roundRect, scaleRect, scaleSize, subtractPoints } from "./rect.js";
|
|
18
|
+
import { AlignOptions, Bounds, CenterPoint, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, Size, SymmetricRectInset, VAlign } from "./types.js";
|
|
19
|
+
import { HandlePosition, MoveOptions, ResizeOptions, applyMove, applyResize, centerInRect, centerOnPoint, clampPointInRange, getArrowKeyDelta, getDirectionDelta, getKeyboardResizeDelta, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isRightHandle, isTopHandle, isVerticalHandle } from "./interact.js";
|
|
20
|
+
import { union } from "./union.js";
|
|
21
|
+
export { AlignOptions, Bounds, CenterPoint, DistanceValue, ElementRectOptions, HAlign, HandlePosition, MoveOptions, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInit, RectInset, RectPoint, RectPoints, RectSide, ResizeOptions, Size, SymmetricRectInset, VAlign, WindowRectOptions, ZERO_POINT, addPoints, alignRect, applyMove, applyResize, centerInRect, centerOnPoint, clampPoint, clampPointInRange, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getArrowKeyDelta, getCenterPoint, getDirectionDelta, getElementPolygon, getElementRect, getKeyboardResizeDelta, getMidpoint, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isRightHandle, isSizeEqual, isSymmetric, isTopHandle, isVerticalHandle, isVisibleSize, rotate, roundRect, scaleRect, scaleSize, shift, shrink, subtractPoints, toRad, union };
|
package/dist/index.js
CHANGED
|
@@ -1,62 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
|
|
17
|
-
// src/index.ts
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./align.js"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./angle.js"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./clamp.js"), module.exports);
|
|
23
|
-
__reExport(index_exports, require("./closest.js"), module.exports);
|
|
24
|
-
__reExport(index_exports, require("./constrain.js"), module.exports);
|
|
25
|
-
__reExport(index_exports, require("./contains.js"), module.exports);
|
|
26
|
-
__reExport(index_exports, require("./distance.js"), module.exports);
|
|
27
|
-
__reExport(index_exports, require("./equality.js"), module.exports);
|
|
28
|
-
__reExport(index_exports, require("./from-element.js"), module.exports);
|
|
29
|
-
__reExport(index_exports, require("./from-points.js"), module.exports);
|
|
30
|
-
__reExport(index_exports, require("./from-range.js"), module.exports);
|
|
31
|
-
__reExport(index_exports, require("./from-rotation.js"), module.exports);
|
|
32
|
-
__reExport(index_exports, require("./from-window.js"), module.exports);
|
|
33
|
-
__reExport(index_exports, require("./intersection.js"), module.exports);
|
|
34
|
-
__reExport(index_exports, require("./operations.js"), module.exports);
|
|
35
|
-
__reExport(index_exports, require("./polygon.js"), module.exports);
|
|
36
|
-
__reExport(index_exports, require("./rect.js"), module.exports);
|
|
37
|
-
__reExport(index_exports, require("./types.js"), module.exports);
|
|
38
|
-
__reExport(index_exports, require("./interact.js"), module.exports);
|
|
39
|
-
__reExport(index_exports, require("./union.js"), module.exports);
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
...require("./align.js"),
|
|
43
|
-
...require("./angle.js"),
|
|
44
|
-
...require("./clamp.js"),
|
|
45
|
-
...require("./closest.js"),
|
|
46
|
-
...require("./constrain.js"),
|
|
47
|
-
...require("./contains.js"),
|
|
48
|
-
...require("./distance.js"),
|
|
49
|
-
...require("./equality.js"),
|
|
50
|
-
...require("./from-element.js"),
|
|
51
|
-
...require("./from-points.js"),
|
|
52
|
-
...require("./from-range.js"),
|
|
53
|
-
...require("./from-rotation.js"),
|
|
54
|
-
...require("./from-window.js"),
|
|
55
|
-
...require("./intersection.js"),
|
|
56
|
-
...require("./operations.js"),
|
|
57
|
-
...require("./polygon.js"),
|
|
58
|
-
...require("./rect.js"),
|
|
59
|
-
...require("./types.js"),
|
|
60
|
-
...require("./interact.js"),
|
|
61
|
-
...require("./union.js")
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
62
4
|
});
|
|
5
|
+
const require_align = require("./align.js");
|
|
6
|
+
const require_angle = require("./angle.js");
|
|
7
|
+
const require_clamp = require("./clamp.js");
|
|
8
|
+
const require_closest = require("./closest.js");
|
|
9
|
+
const require_constrain = require("./constrain.js");
|
|
10
|
+
const require_contains = require("./contains.js");
|
|
11
|
+
const require_distance = require("./distance.js");
|
|
12
|
+
const require_equality = require("./equality.js");
|
|
13
|
+
const require_from_element = require("./from-element.js");
|
|
14
|
+
const require_from_points = require("./from-points.js");
|
|
15
|
+
const require_from_range = require("./from-range.js");
|
|
16
|
+
const require_from_rotation = require("./from-rotation.js");
|
|
17
|
+
const require_from_window = require("./from-window.js");
|
|
18
|
+
const require_intersection = require("./intersection.js");
|
|
19
|
+
const require_operations = require("./operations.js");
|
|
20
|
+
const require_polygon = require("./polygon.js");
|
|
21
|
+
const require_rect = require("./rect.js");
|
|
22
|
+
const require_interact = require("./interact.js");
|
|
23
|
+
const require_union = require("./union.js");
|
|
24
|
+
exports.ZERO_POINT = require_rect.ZERO_POINT;
|
|
25
|
+
exports.addPoints = require_rect.addPoints;
|
|
26
|
+
exports.alignRect = require_align.alignRect;
|
|
27
|
+
exports.applyMove = require_interact.applyMove;
|
|
28
|
+
exports.applyResize = require_interact.applyResize;
|
|
29
|
+
exports.centerInRect = require_interact.centerInRect;
|
|
30
|
+
exports.centerOnPoint = require_interact.centerOnPoint;
|
|
31
|
+
exports.clampPoint = require_clamp.clampPoint;
|
|
32
|
+
exports.clampPointInRange = require_interact.clampPointInRange;
|
|
33
|
+
exports.clampSize = require_clamp.clampSize;
|
|
34
|
+
exports.closest = require_closest.closest;
|
|
35
|
+
exports.closestSideToPoint = require_closest.closestSideToPoint;
|
|
36
|
+
exports.closestSideToRect = require_closest.closestSideToRect;
|
|
37
|
+
exports.collisions = require_intersection.collisions;
|
|
38
|
+
exports.constrainRect = require_constrain.constrainRect;
|
|
39
|
+
exports.contains = require_contains.contains;
|
|
40
|
+
exports.containsPoint = require_contains.containsPoint;
|
|
41
|
+
exports.containsRect = require_contains.containsRect;
|
|
42
|
+
exports.createPoint = require_rect.createPoint;
|
|
43
|
+
exports.createRect = require_rect.createRect;
|
|
44
|
+
exports.debugPolygon = require_polygon.debugPolygon;
|
|
45
|
+
exports.distance = require_distance.distance;
|
|
46
|
+
exports.distanceBtwEdges = require_distance.distanceBtwEdges;
|
|
47
|
+
exports.distanceFromPoint = require_distance.distanceFromPoint;
|
|
48
|
+
exports.distanceFromRect = require_distance.distanceFromRect;
|
|
49
|
+
exports.expand = require_operations.expand;
|
|
50
|
+
exports.fromRange = require_from_range.fromRange;
|
|
51
|
+
exports.getArrowKeyDelta = require_interact.getArrowKeyDelta;
|
|
52
|
+
exports.getCenterPoint = require_rect.getCenterPoint;
|
|
53
|
+
exports.getDirectionDelta = require_interact.getDirectionDelta;
|
|
54
|
+
exports.getElementPolygon = require_polygon.getElementPolygon;
|
|
55
|
+
exports.getElementRect = require_from_element.getElementRect;
|
|
56
|
+
exports.getKeyboardResizeDelta = require_interact.getKeyboardResizeDelta;
|
|
57
|
+
exports.getMidpoint = require_rect.getMidpoint;
|
|
58
|
+
exports.getPointAngle = require_angle.getPointAngle;
|
|
59
|
+
exports.getRectCenters = require_rect.getRectCenters;
|
|
60
|
+
exports.getRectCorners = require_rect.getRectCorners;
|
|
61
|
+
exports.getRectEdges = require_rect.getRectEdges;
|
|
62
|
+
exports.getRectFromPoints = require_from_points.getRectFromPoints;
|
|
63
|
+
exports.getRotationRect = require_from_rotation.getRotationRect;
|
|
64
|
+
exports.getViewportRect = require_from_window.getViewportRect;
|
|
65
|
+
exports.getWindowRect = require_from_window.getWindowRect;
|
|
66
|
+
exports.inset = require_operations.inset;
|
|
67
|
+
exports.intersection = require_intersection.intersection;
|
|
68
|
+
exports.intersects = require_intersection.intersects;
|
|
69
|
+
exports.isBottomHandle = require_interact.isBottomHandle;
|
|
70
|
+
exports.isCornerHandle = require_interact.isCornerHandle;
|
|
71
|
+
exports.isHorizontalHandle = require_interact.isHorizontalHandle;
|
|
72
|
+
exports.isLeftHandle = require_interact.isLeftHandle;
|
|
73
|
+
exports.isPoint = require_rect.isPoint;
|
|
74
|
+
exports.isPointEqual = require_equality.isPointEqual;
|
|
75
|
+
exports.isPointInPolygon = require_polygon.isPointInPolygon;
|
|
76
|
+
exports.isRect = require_rect.isRect;
|
|
77
|
+
exports.isRectEqual = require_equality.isRectEqual;
|
|
78
|
+
exports.isRightHandle = require_interact.isRightHandle;
|
|
79
|
+
exports.isSizeEqual = require_equality.isSizeEqual;
|
|
80
|
+
exports.isSymmetric = require_operations.isSymmetric;
|
|
81
|
+
exports.isTopHandle = require_interact.isTopHandle;
|
|
82
|
+
exports.isVerticalHandle = require_interact.isVerticalHandle;
|
|
83
|
+
exports.isVisibleSize = require_rect.isVisibleSize;
|
|
84
|
+
exports.rotate = require_from_rotation.rotate;
|
|
85
|
+
exports.roundRect = require_rect.roundRect;
|
|
86
|
+
exports.scaleRect = require_rect.scaleRect;
|
|
87
|
+
exports.scaleSize = require_rect.scaleSize;
|
|
88
|
+
exports.shift = require_operations.shift;
|
|
89
|
+
exports.shrink = require_operations.shrink;
|
|
90
|
+
exports.subtractPoints = require_rect.subtractPoints;
|
|
91
|
+
exports.toRad = require_from_rotation.toRad;
|
|
92
|
+
exports.union = require_union.union;
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
export * from "./union.mjs";
|
|
1
|
+
import { alignRect } from "./align.mjs";
|
|
2
|
+
import { getPointAngle } from "./angle.mjs";
|
|
3
|
+
import { clampPoint, clampSize } from "./clamp.mjs";
|
|
4
|
+
import { closest, closestSideToPoint, closestSideToRect } from "./closest.mjs";
|
|
5
|
+
import { constrainRect } from "./constrain.mjs";
|
|
6
|
+
import { contains, containsPoint, containsRect } from "./contains.mjs";
|
|
7
|
+
import { distance, distanceBtwEdges, distanceFromPoint, distanceFromRect } from "./distance.mjs";
|
|
8
|
+
import { isPointEqual, isRectEqual, isSizeEqual } from "./equality.mjs";
|
|
9
|
+
import { getElementRect } from "./from-element.mjs";
|
|
10
|
+
import { getRectFromPoints } from "./from-points.mjs";
|
|
11
|
+
import { fromRange } from "./from-range.mjs";
|
|
12
|
+
import { getRotationRect, rotate, toRad } from "./from-rotation.mjs";
|
|
13
|
+
import { getViewportRect, getWindowRect } from "./from-window.mjs";
|
|
14
|
+
import { collisions, intersection, intersects } from "./intersection.mjs";
|
|
15
|
+
import { expand, inset, isSymmetric, shift, shrink } from "./operations.mjs";
|
|
16
|
+
import { debugPolygon, getElementPolygon, isPointInPolygon } from "./polygon.mjs";
|
|
17
|
+
import { ZERO_POINT, addPoints, createPoint, createRect, getCenterPoint, getMidpoint, getRectCenters, getRectCorners, getRectEdges, isPoint, isRect, isVisibleSize, roundRect, scaleRect, scaleSize, subtractPoints } from "./rect.mjs";
|
|
18
|
+
import { applyMove, applyResize, centerInRect, centerOnPoint, clampPointInRange, getArrowKeyDelta, getDirectionDelta, getKeyboardResizeDelta, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isRightHandle, isTopHandle, isVerticalHandle } from "./interact.mjs";
|
|
19
|
+
import { union } from "./union.mjs";
|
|
20
|
+
export { ZERO_POINT, addPoints, alignRect, applyMove, applyResize, centerInRect, centerOnPoint, clampPoint, clampPointInRange, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getArrowKeyDelta, getCenterPoint, getDirectionDelta, getElementPolygon, getElementRect, getKeyboardResizeDelta, getMidpoint, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isRightHandle, isSizeEqual, isSymmetric, isTopHandle, isVerticalHandle, isVisibleSize, rotate, roundRect, scaleRect, scaleSize, shift, shrink, subtractPoints, toRad, union };
|
package/dist/interact.d.mts
CHANGED
|
@@ -1,71 +1,68 @@
|
|
|
1
|
-
import { CompassDirection } from
|
|
2
|
-
import { RectInit, Size
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
gridSize?: number | undefined;
|
|
1
|
+
import { CompassDirection } from "./compass.mjs";
|
|
2
|
+
import { Point, RectInit, Size } from "./types.mjs";
|
|
3
|
+
export type HandlePosition = CompassDirection;
|
|
4
|
+
export declare const isLeftHandle: (h: HandlePosition) => boolean;
|
|
5
|
+
export declare const isRightHandle: (h: HandlePosition) => boolean;
|
|
6
|
+
export declare const isTopHandle: (h: HandlePosition) => boolean;
|
|
7
|
+
export declare const isBottomHandle: (h: HandlePosition) => boolean;
|
|
8
|
+
export declare const isCornerHandle: (h: HandlePosition) => boolean;
|
|
9
|
+
export declare const isHorizontalHandle: (h: HandlePosition) => boolean;
|
|
10
|
+
export declare const isVerticalHandle: (h: HandlePosition) => boolean;
|
|
11
|
+
export interface MoveOptions {
|
|
12
|
+
/** Containing boundary rect. Move is unconstrained if omitted. */
|
|
13
|
+
boundary?: RectInit | undefined;
|
|
14
|
+
/** Snap-to-grid step size. Default: 1 (no snapping). */
|
|
15
|
+
gridSize?: number | undefined;
|
|
17
16
|
}
|
|
18
|
-
interface ResizeOptions {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
export interface ResizeOptions {
|
|
18
|
+
/** Containing boundary rect. Resize is unconstrained if omitted. */
|
|
19
|
+
boundary?: RectInit | undefined;
|
|
20
|
+
/** Minimum allowed size. */
|
|
21
|
+
minSize?: Size | undefined;
|
|
22
|
+
/** Maximum allowed size. */
|
|
23
|
+
maxSize?: Size | undefined;
|
|
24
|
+
/** Fixed width/height ratio. Omit for free resize. */
|
|
25
|
+
aspectRatio?: number | undefined;
|
|
26
|
+
/** Scale from the opposite corner ("extent") or center ("center"). Default: "extent". */
|
|
27
|
+
origin?: "extent" | "center" | undefined;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* Compute the position that centers a `size` within a boundary rect.
|
|
32
31
|
*/
|
|
33
|
-
declare function centerInRect(size: Size, boundary: RectInit): Point;
|
|
32
|
+
export declare function centerInRect(size: Size, boundary: RectInit): Point;
|
|
34
33
|
/**
|
|
35
34
|
* Center a rect (given by size) on a point, then clamp within a boundary.
|
|
36
35
|
*/
|
|
37
|
-
declare function centerOnPoint(size: Size, center: Point, boundary: RectInit): Point;
|
|
36
|
+
export declare function centerOnPoint(size: Size, center: Point, boundary: RectInit): Point;
|
|
38
37
|
/**
|
|
39
38
|
* Clamp a point's x/y independently between a min and max point.
|
|
40
39
|
* Useful for constraining offsets, positions, or pan values.
|
|
41
40
|
*/
|
|
42
|
-
declare function clampPointInRange(point: Point, minPoint: Point, maxPoint: Point): Point;
|
|
41
|
+
export declare function clampPointInRange(point: Point, minPoint: Point, maxPoint: Point): Point;
|
|
43
42
|
/**
|
|
44
43
|
* Compute a new rect after moving by a pointer delta.
|
|
45
44
|
* Grid-snaps the delta and clamps within the boundary.
|
|
46
45
|
*/
|
|
47
|
-
declare function applyMove(rect: RectInit, delta: Point, options?: MoveOptions): RectInit;
|
|
46
|
+
export declare function applyMove(rect: RectInit, delta: Point, options?: MoveOptions): RectInit;
|
|
48
47
|
/**
|
|
49
48
|
* Compute a new rect after resizing via a handle drag.
|
|
50
49
|
* Handles size limits, boundary containment, aspect ratio, and scaling origin.
|
|
51
50
|
*/
|
|
52
|
-
declare function applyResize(rect: RectInit, delta: Point, handle: HandlePosition, options?: ResizeOptions): RectInit;
|
|
51
|
+
export declare function applyResize(rect: RectInit, delta: Point, handle: HandlePosition, options?: ResizeOptions): RectInit;
|
|
53
52
|
/**
|
|
54
53
|
* Convert an arrow-key direction and step into a Point delta.
|
|
55
54
|
* Useful for keyboard-driven move/resize.
|
|
56
55
|
*/
|
|
57
|
-
declare function getDirectionDelta(direction: "left" | "right" | "up" | "down", step: number): Point;
|
|
56
|
+
export declare function getDirectionDelta(direction: "left" | "right" | "up" | "down", step: number): Point;
|
|
58
57
|
/**
|
|
59
58
|
* Convert an ArrowKey event key and step into a Point delta.
|
|
60
59
|
* Like `getDirectionDelta` but accepts `"ArrowLeft"` / `"ArrowRight"` / etc.
|
|
61
60
|
*/
|
|
62
|
-
declare function getArrowKeyDelta(key: string, step: number): Point;
|
|
61
|
+
export declare function getArrowKeyDelta(key: string, step: number): Point;
|
|
63
62
|
/**
|
|
64
63
|
* Compute the delta for a keyboard-driven resize given an arrow key and handle.
|
|
65
64
|
*
|
|
66
65
|
* The convention: pressing an arrow key in the handle's "outward" direction
|
|
67
66
|
* expands the rect; pressing inward shrinks it. For corners, both axes move.
|
|
68
67
|
*/
|
|
69
|
-
declare function getKeyboardResizeDelta(key: string, handle: HandlePosition, step: number): Point;
|
|
70
|
-
|
|
71
|
-
export { type HandlePosition, type MoveOptions, type ResizeOptions, applyMove, applyResize, centerInRect, centerOnPoint, clampPointInRange, getArrowKeyDelta, getDirectionDelta, getKeyboardResizeDelta, isBottomHandle, isCornerHandle, isHorizontalHandle, isLeftHandle, isRightHandle, isTopHandle, isVerticalHandle };
|
|
68
|
+
export declare function getKeyboardResizeDelta(key: string, handle: HandlePosition, step: number): Point;
|