@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/interact.d.ts
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.js";
|
|
2
|
+
import { Point, RectInit, Size } from "./types.js";
|
|
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;
|