@zag-js/rect-utils
Advanced tools
Comparing version 0.0.0-dev-20240723090825 to 0.0.0-v1-beta-20250220125322
@@ -41,4 +41,4 @@ interface Point { | ||
interface SymmetricRectInset { | ||
dx?: number; | ||
dy?: number; | ||
dx?: number | undefined; | ||
dy?: number | undefined; | ||
} | ||
@@ -94,2 +94,4 @@ interface ScalingOptions { | ||
declare function getPointAngle(rect: Rect, point: Point, reference?: Point): number; | ||
declare const clampPoint: (position: Point, size: Size, boundaryRect: RectInit) => { | ||
@@ -122,5 +124,5 @@ x: number; | ||
declare const isSizeEqual: (a: Size, b: Size) => boolean; | ||
declare const isPointEqual: (a: Point, b: Point) => boolean; | ||
declare const isRectEqual: (a: RectInit, b: RectInit) => boolean; | ||
declare const isSizeEqual: (a: Size, b: Size | undefined) => boolean; | ||
declare const isPointEqual: (a: Point, b: Point | undefined) => boolean; | ||
declare const isRectEqual: (a: RectInit, b: RectInit | undefined) => boolean; | ||
@@ -154,3 +156,3 @@ declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect; | ||
/** | ||
* Creates a rectange from window object | ||
* Creates a rectangle from window object | ||
*/ | ||
@@ -258,2 +260,2 @@ declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect; | ||
export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union }; | ||
export { AffineTransform, type AlignOptions, type Bounds, type CenterPoint, type DistanceValue, type ElementRectOptions, type HAlign, type Point, type Rect, type RectCenter, type RectCenters, type RectCorner, type RectCorners, type RectEdge, type RectEdges, type RectInit, type RectInset, type RectPoint, type RectPoints, type RectSide, type ScalingOptions, type Size, type SymmetricRectInset, type VAlign, type WindowRectOptions, addPoints, alignRect, clampPoint, clampSize, closest, closestSideToPoint, closestSideToRect, collisions, constrainRect, contains, containsPoint, containsRect, createPoint, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getPointAngle, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPoint, isPointEqual, isPointInPolygon, isRect, isRectEqual, isSizeEqual, isSymmetric, resizeRect, rotate, shift, shrink, subtractPoints, toRad, union }; |
@@ -1,76 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
AffineTransform: () => AffineTransform, | ||
addPoints: () => addPoints, | ||
alignRect: () => alignRect, | ||
clampPoint: () => clampPoint, | ||
clampSize: () => clampSize, | ||
closest: () => closest, | ||
closestSideToPoint: () => closestSideToPoint, | ||
closestSideToRect: () => closestSideToRect, | ||
collisions: () => collisions, | ||
constrainRect: () => constrainRect, | ||
contains: () => contains, | ||
containsPoint: () => containsPoint, | ||
containsRect: () => containsRect, | ||
createPoint: () => createPoint, | ||
createRect: () => createRect, | ||
debugPolygon: () => debugPolygon, | ||
distance: () => distance, | ||
distanceBtwEdges: () => distanceBtwEdges, | ||
distanceFromPoint: () => distanceFromPoint, | ||
distanceFromRect: () => distanceFromRect, | ||
expand: () => expand, | ||
fromRange: () => fromRange, | ||
getElementPolygon: () => getElementPolygon, | ||
getElementRect: () => getElementRect, | ||
getRectCenters: () => getRectCenters, | ||
getRectCorners: () => getRectCorners, | ||
getRectEdges: () => getRectEdges, | ||
getRectFromPoints: () => getRectFromPoints, | ||
getRotationRect: () => getRotationRect, | ||
getViewportRect: () => getViewportRect, | ||
getWindowRect: () => getWindowRect, | ||
inset: () => inset, | ||
intersection: () => intersection, | ||
intersects: () => intersects, | ||
isPoint: () => isPoint, | ||
isPointEqual: () => isPointEqual, | ||
isPointInPolygon: () => isPointInPolygon, | ||
isRect: () => isRect, | ||
isRectEqual: () => isRectEqual, | ||
isSizeEqual: () => isSizeEqual, | ||
isSymmetric: () => isSymmetric, | ||
resizeRect: () => resizeRect, | ||
rotate: () => rotate, | ||
shift: () => shift, | ||
shrink: () => shrink, | ||
subtractPoints: () => subtractPoints, | ||
toRad: () => toRad, | ||
union: () => union | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/affine-transform.ts | ||
@@ -260,2 +191,10 @@ var AffineTransform = class _AffineTransform { | ||
// src/angle.ts | ||
function getPointAngle(rect, point, reference = rect.center) { | ||
const x = point.x - reference.x; | ||
const y = point.y - reference.y; | ||
const deg = Math.atan2(x, y) * (180 / Math.PI) + 180; | ||
return 360 - deg; | ||
} | ||
// src/clamp.ts | ||
@@ -450,6 +389,6 @@ var clamp = (value, min3, max2) => Math.min(Math.max(value, min3), max2); | ||
var isSizeEqual = (a, b) => { | ||
return a.width === b.width && a.height === b.height; | ||
return a.width === b?.width && a.height === b?.height; | ||
}; | ||
var isPointEqual = (a, b) => { | ||
return a.x === b.x && a.y === b.y; | ||
return a.x === b?.x && a.y === b?.y; | ||
}; | ||
@@ -785,53 +724,51 @@ var isRectEqual = (a, b) => { | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
AffineTransform, | ||
addPoints, | ||
alignRect, | ||
clampPoint, | ||
clampSize, | ||
closest, | ||
closestSideToPoint, | ||
closestSideToRect, | ||
collisions, | ||
constrainRect, | ||
contains, | ||
containsPoint, | ||
containsRect, | ||
createPoint, | ||
createRect, | ||
debugPolygon, | ||
distance, | ||
distanceBtwEdges, | ||
distanceFromPoint, | ||
distanceFromRect, | ||
expand, | ||
fromRange, | ||
getElementPolygon, | ||
getElementRect, | ||
getRectCenters, | ||
getRectCorners, | ||
getRectEdges, | ||
getRectFromPoints, | ||
getRotationRect, | ||
getViewportRect, | ||
getWindowRect, | ||
inset, | ||
intersection, | ||
intersects, | ||
isPoint, | ||
isPointEqual, | ||
isPointInPolygon, | ||
isRect, | ||
isRectEqual, | ||
isSizeEqual, | ||
isSymmetric, | ||
resizeRect, | ||
rotate, | ||
shift, | ||
shrink, | ||
subtractPoints, | ||
toRad, | ||
union | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
exports.AffineTransform = AffineTransform; | ||
exports.addPoints = addPoints; | ||
exports.alignRect = alignRect; | ||
exports.clampPoint = clampPoint; | ||
exports.clampSize = clampSize; | ||
exports.closest = closest; | ||
exports.closestSideToPoint = closestSideToPoint; | ||
exports.closestSideToRect = closestSideToRect; | ||
exports.collisions = collisions; | ||
exports.constrainRect = constrainRect; | ||
exports.contains = contains; | ||
exports.containsPoint = containsPoint; | ||
exports.containsRect = containsRect; | ||
exports.createPoint = createPoint; | ||
exports.createRect = createRect; | ||
exports.debugPolygon = debugPolygon; | ||
exports.distance = distance; | ||
exports.distanceBtwEdges = distanceBtwEdges; | ||
exports.distanceFromPoint = distanceFromPoint; | ||
exports.distanceFromRect = distanceFromRect; | ||
exports.expand = expand; | ||
exports.fromRange = fromRange; | ||
exports.getElementPolygon = getElementPolygon; | ||
exports.getElementRect = getElementRect; | ||
exports.getPointAngle = getPointAngle; | ||
exports.getRectCenters = getRectCenters; | ||
exports.getRectCorners = getRectCorners; | ||
exports.getRectEdges = getRectEdges; | ||
exports.getRectFromPoints = getRectFromPoints; | ||
exports.getRotationRect = getRotationRect; | ||
exports.getViewportRect = getViewportRect; | ||
exports.getWindowRect = getWindowRect; | ||
exports.inset = inset; | ||
exports.intersection = intersection; | ||
exports.intersects = intersects; | ||
exports.isPoint = isPoint; | ||
exports.isPointEqual = isPointEqual; | ||
exports.isPointInPolygon = isPointInPolygon; | ||
exports.isRect = isRect; | ||
exports.isRectEqual = isRectEqual; | ||
exports.isSizeEqual = isSizeEqual; | ||
exports.isSymmetric = isSymmetric; | ||
exports.resizeRect = resizeRect; | ||
exports.rotate = rotate; | ||
exports.shift = shift; | ||
exports.shrink = shrink; | ||
exports.subtractPoints = subtractPoints; | ||
exports.toRad = toRad; | ||
exports.union = union; |
{ | ||
"name": "@zag-js/rect-utils", | ||
"version": "0.0.0-dev-20240723090825", | ||
"version": "0.0.0-v1-beta-20250220125322", | ||
"description": "", | ||
@@ -16,4 +16,3 @@ "keywords": [ | ||
"files": [ | ||
"dist", | ||
"src" | ||
"dist" | ||
], | ||
@@ -43,5 +42,5 @@ "publishConfig": { | ||
"build": "tsup", | ||
"lint": "eslint src --ext .ts,.tsx", | ||
"lint": "eslint src", | ||
"typecheck": "tsc --noEmit" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63731
7
1686