@zag-js/rect-utils 0.1.4 → 0.1.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Chakra UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -1,16 +1,186 @@
1
- export * from "./align";
2
- export * from "./closest";
3
- export * from "./contains";
4
- export * from "./distance";
5
- export * from "./from-element";
6
- export * from "./from-points";
7
- export * from "./from-range";
8
- export * from "./from-rotation";
9
- export * from "./from-window";
10
- export * from "./get-polygon";
11
- export * from "./intersection";
12
- export * from "./operations";
13
- export * from "./polygon";
14
- export * from "./rect";
15
- export * from "./types";
16
- export * from "./union";
1
+ declare type Point = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ declare type RectValue = {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ };
11
+ declare type RectSide = "top" | "right" | "bottom" | "left";
12
+ declare type RectPoint = "top-left" | "top-center" | "top-right" | "right-center" | "left-center" | "bottom-left" | "bottom-right" | "bottom-center" | "center";
13
+ declare type RectEdge = [Point, Point];
14
+ declare type RectPoints = [Point, Point, Point, Point];
15
+ declare type RectEdges = Record<RectSide, RectEdge> & {
16
+ value: RectEdge[];
17
+ };
18
+ declare type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
19
+ declare type RectCorners = Record<RectCorner, Point> & {
20
+ value: RectPoints;
21
+ };
22
+ declare type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
23
+ declare type RectCenters = Record<RectCenter, Point> & {
24
+ value: RectPoints;
25
+ };
26
+ declare type RectInset = Partial<Record<RectSide, number>>;
27
+ declare type SymmetricRectInset = {
28
+ dx?: number;
29
+ dy?: number;
30
+ };
31
+
32
+ declare function createRect(r: RectValue): {
33
+ x: number;
34
+ y: number;
35
+ width: number;
36
+ height: number;
37
+ minX: number;
38
+ minY: number;
39
+ maxX: number;
40
+ maxY: number;
41
+ midX: number;
42
+ midY: number;
43
+ center: {
44
+ x: number;
45
+ y: number;
46
+ };
47
+ };
48
+ declare type Rect = ReturnType<typeof createRect>;
49
+ declare function isRect(v: any): v is Rect;
50
+ declare function getRectCenters(v: Rect): {
51
+ top: {
52
+ x: number;
53
+ y: number;
54
+ };
55
+ right: {
56
+ x: number;
57
+ y: number;
58
+ };
59
+ bottom: {
60
+ x: number;
61
+ y: number;
62
+ };
63
+ left: {
64
+ x: number;
65
+ y: number;
66
+ };
67
+ };
68
+ declare function getRectCorners(v: Rect): {
69
+ top: {
70
+ x: number;
71
+ y: number;
72
+ };
73
+ right: {
74
+ x: number;
75
+ y: number;
76
+ };
77
+ bottom: {
78
+ x: number;
79
+ y: number;
80
+ };
81
+ left: {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ };
86
+ declare function getRectEdges(v: Rect): {
87
+ top: RectEdge;
88
+ right: RectEdge;
89
+ bottom: RectEdge;
90
+ left: RectEdge;
91
+ };
92
+
93
+ declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
94
+ declare type AlignOptions = {
95
+ h: HAlign;
96
+ v: VAlign;
97
+ };
98
+ declare type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
99
+ declare type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
100
+
101
+ declare function closest(...pts: Point[]): (a: Point) => Point;
102
+ declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
103
+ declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
104
+
105
+ declare function containsPoint(r: Rect, p: Point): boolean;
106
+ declare function containsRect(a: Rect, b: Rect): boolean;
107
+ declare function contains(r: Rect, v: Rect | Point): boolean;
108
+
109
+ declare type DistanceValue = Point & {
110
+ value: number;
111
+ };
112
+ declare function distance(a: Point, b?: Point): number;
113
+ declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
114
+ declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
115
+ declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
116
+
117
+ declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
118
+ declare type ElementRectOptions = {
119
+ /**
120
+ * Whether to exclude the element's scrollbar size from the calculation.
121
+ */
122
+ excludeScrollbar?: boolean;
123
+ /**
124
+ * Whether to exclude the element's borders from the calculation.
125
+ */
126
+ excludeBorders?: boolean;
127
+ };
128
+
129
+ declare function getRectFromPoints(...pts: Point[]): Rect;
130
+
131
+ declare function fromRange(range: Range): Rect;
132
+
133
+ declare function toRad(d: number): number;
134
+ declare function rotate(a: Point, d: number, c: Point): Point;
135
+ declare function getRotationRect(r: Rect, deg: number): Rect;
136
+
137
+ declare type WindowRectOptions = {
138
+ /**
139
+ * Whether to exclude the element's scrollbar size from the calculation.
140
+ */
141
+ excludeScrollbar?: boolean;
142
+ };
143
+ /**
144
+ * Creates a rectange from window object
145
+ */
146
+ declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
147
+ /**
148
+ * Get the rect of the window with the option to exclude the scrollbar
149
+ */
150
+ declare function getViewportRect(win: Window, opts: WindowRectOptions): {
151
+ x: number;
152
+ y: number;
153
+ width: number;
154
+ height: number;
155
+ };
156
+
157
+ declare function getElementPolygon(rectValue: RectValue, placement: string): {
158
+ x: number;
159
+ y: number;
160
+ }[] | undefined;
161
+
162
+ /**
163
+ * Checks if a Rect intersects another Rect
164
+ */
165
+ declare function intersects(a: Rect, b: Rect): boolean;
166
+ /**
167
+ * Returns a new Rect that represents the intersection between two Rects
168
+ */
169
+ declare function intersection(a: Rect, b: Rect): Rect;
170
+ /**
171
+ * Returns whether two rects collide along each edge
172
+ */
173
+ declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
174
+
175
+ declare const isSymmetric: (v: any) => v is SymmetricRectInset;
176
+ declare function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect;
177
+ declare function expand(r: Rect, v: number | SymmetricRectInset): Rect;
178
+ declare function shrink(r: Rect, v: number | SymmetricRectInset): Rect;
179
+ declare function shift(r: Rect, o: Partial<Point>): Rect;
180
+
181
+ declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
182
+ declare function debugPolygon(polygon: Point[]): () => void;
183
+
184
+ declare function union(...rs: Rect[]): Rect;
185
+
186
+ export { AlignOptions, DistanceValue, ElementRectOptions, HAlign, Point, Rect, RectCenter, RectCenters, RectCorner, RectCorners, RectEdge, RectEdges, RectInset, RectPoint, RectPoints, RectSide, RectValue, SymmetricRectInset, VAlign, WindowRectOptions, alignRect, closest, closestSideToPoint, closestSideToRect, collisions, contains, containsPoint, containsRect, createRect, debugPolygon, distance, distanceBtwEdges, distanceFromPoint, distanceFromRect, expand, fromRange, getElementPolygon, getElementRect, getRectCenters, getRectCorners, getRectEdges, getRectFromPoints, getRotationRect, getViewportRect, getWindowRect, inset, intersection, intersects, isPointInPolygon, isRect, isSymmetric, rotate, shift, shrink, toRad, union };
package/dist/index.js CHANGED
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -94,7 +77,7 @@ function hAlign(a, ref, h) {
94
77
  if (h === "center") {
95
78
  x = ref.midX - ref.width / 2;
96
79
  }
97
- return __spreadProps(__spreadValues({}, a), { x });
80
+ return { ...a, x };
98
81
  }
99
82
  function vAlign(a, ref, v) {
100
83
  let y = ref.minY;
@@ -113,7 +96,7 @@ function vAlign(a, ref, v) {
113
96
  if (v === "center") {
114
97
  y = ref.midY - a.height / 2;
115
98
  }
116
- return __spreadProps(__spreadValues({}, a), { y });
99
+ return { ...a, y };
117
100
  }
118
101
  function alignRect(a, ref, options) {
119
102
  const { h, v } = options;
@@ -291,13 +274,12 @@ function getCache() {
291
274
  return g.__styleCache;
292
275
  }
293
276
  function getComputedStyle(el) {
294
- var _a;
295
277
  if (!el)
296
278
  return {};
297
279
  const cache = getCache();
298
280
  let style = cache.get(el);
299
281
  if (!style) {
300
- const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
282
+ const win = (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
301
283
  style = win.getComputedStyle(el);
302
284
  cache.set(el, style);
303
285
  }
@@ -372,7 +354,7 @@ function fromRange(range) {
372
354
  }
373
355
  if (start instanceof HTMLElement) {
374
356
  const r = getElementRect(start);
375
- rs.push(__spreadProps(__spreadValues({}, r), { x: r.maxX, width: 0 }));
357
+ rs.push({ ...r, x: r.maxX, width: 0 });
376
358
  }
377
359
  return union.apply(void 0, rs);
378
360
  }
@@ -517,3 +499,42 @@ function debugPolygon(polygon) {
517
499
  el.remove();
518
500
  };
519
501
  }
502
+ // Annotate the CommonJS export names for ESM import in node:
503
+ 0 && (module.exports = {
504
+ alignRect,
505
+ closest,
506
+ closestSideToPoint,
507
+ closestSideToRect,
508
+ collisions,
509
+ contains,
510
+ containsPoint,
511
+ containsRect,
512
+ createRect,
513
+ debugPolygon,
514
+ distance,
515
+ distanceBtwEdges,
516
+ distanceFromPoint,
517
+ distanceFromRect,
518
+ expand,
519
+ fromRange,
520
+ getElementPolygon,
521
+ getElementRect,
522
+ getRectCenters,
523
+ getRectCorners,
524
+ getRectEdges,
525
+ getRectFromPoints,
526
+ getRotationRect,
527
+ getViewportRect,
528
+ getWindowRect,
529
+ inset,
530
+ intersection,
531
+ intersects,
532
+ isPointInPolygon,
533
+ isRect,
534
+ isSymmetric,
535
+ rotate,
536
+ shift,
537
+ shrink,
538
+ toRad,
539
+ union
540
+ });
package/dist/index.mjs CHANGED
@@ -1,23 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/align.ts
22
2
  function hAlign(a, ref, h) {
23
3
  let x = ref.minX;
@@ -36,7 +16,7 @@ function hAlign(a, ref, h) {
36
16
  if (h === "center") {
37
17
  x = ref.midX - ref.width / 2;
38
18
  }
39
- return __spreadProps(__spreadValues({}, a), { x });
19
+ return { ...a, x };
40
20
  }
41
21
  function vAlign(a, ref, v) {
42
22
  let y = ref.minY;
@@ -55,7 +35,7 @@ function vAlign(a, ref, v) {
55
35
  if (v === "center") {
56
36
  y = ref.midY - a.height / 2;
57
37
  }
58
- return __spreadProps(__spreadValues({}, a), { y });
38
+ return { ...a, y };
59
39
  }
60
40
  function alignRect(a, ref, options) {
61
41
  const { h, v } = options;
@@ -233,13 +213,12 @@ function getCache() {
233
213
  return g.__styleCache;
234
214
  }
235
215
  function getComputedStyle(el) {
236
- var _a;
237
216
  if (!el)
238
217
  return {};
239
218
  const cache = getCache();
240
219
  let style = cache.get(el);
241
220
  if (!style) {
242
- const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
221
+ const win = (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
243
222
  style = win.getComputedStyle(el);
244
223
  cache.set(el, style);
245
224
  }
@@ -314,7 +293,7 @@ function fromRange(range) {
314
293
  }
315
294
  if (start instanceof HTMLElement) {
316
295
  const r = getElementRect(start);
317
- rs.push(__spreadProps(__spreadValues({}, r), { x: r.maxX, width: 0 }));
296
+ rs.push({ ...r, x: r.maxX, width: 0 });
318
297
  }
319
298
  return union.apply(void 0, rs);
320
299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/rect-utils",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "js",
@@ -24,17 +24,18 @@
24
24
  "bugs": {
25
25
  "url": "https://github.com/chakra-ui/zag/issues"
26
26
  },
27
- "dependencies": {
28
- "@zag-js/dom-utils": "0.1.7",
29
- "@zag-js/utils": "0.1.2"
27
+ "devDependencies": {
28
+ "@zag-js/dom-utils": "0.1.8",
29
+ "@zag-js/utils": "0.1.3"
30
30
  },
31
31
  "scripts": {
32
- "build:fast": "zag build",
33
- "start": "zag build --watch",
34
- "build": "zag build --prod",
32
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
33
+ "start": "pnpm build --watch",
34
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
35
35
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
36
36
  "lint": "eslint src --ext .ts,.tsx",
37
- "test:ci": "yarn test --ci --runInBand",
38
- "test:watch": "yarn test --watch --updateSnapshot"
37
+ "test-ci": "pnpm test --ci --runInBand",
38
+ "test-watch": "pnpm test --watch -u",
39
+ "typecheck": "tsc --noEmit"
39
40
  }
40
- }
41
+ }
package/dist/align.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { Rect } from "./rect";
2
- export declare function alignRect(a: Rect, ref: Rect, options: AlignOptions): Rect;
3
- export declare type AlignOptions = {
4
- h: HAlign;
5
- v: VAlign;
6
- };
7
- export declare type HAlign = "left-inside" | "left-outside" | "center" | "right-inside" | "right-outside";
8
- export declare type VAlign = "top-inside" | "top-outside" | "center" | "bottom-inside" | "bottom-outside";
package/dist/closest.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Rect } from "./rect";
2
- import type { Point, RectSide } from "./types";
3
- export declare function closest(...pts: Point[]): (a: Point) => Point;
4
- export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
5
- export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
@@ -1,5 +0,0 @@
1
- import { Rect } from "./rect";
2
- import type { Point } from "./types";
3
- export declare function containsPoint(r: Rect, p: Point): boolean;
4
- export declare function containsRect(a: Rect, b: Rect): boolean;
5
- export declare function contains(r: Rect, v: Rect | Point): boolean;
@@ -1,9 +0,0 @@
1
- import type { Rect } from "./rect";
2
- import type { Point, RectSide } from "./types";
3
- export declare type DistanceValue = Point & {
4
- value: number;
5
- };
6
- export declare function distance(a: Point, b?: Point): number;
7
- export declare function distanceFromPoint(r: Rect, p: Point): DistanceValue;
8
- export declare function distanceFromRect(a: Rect, b: Rect): DistanceValue;
9
- export declare function distanceBtwEdges(a: Rect, b: Rect): Record<RectSide, number>;
@@ -1,12 +0,0 @@
1
- import { Rect } from "./rect";
2
- export declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): Rect;
3
- export declare type ElementRectOptions = {
4
- /**
5
- * Whether to exclude the element's scrollbar size from the calculation.
6
- */
7
- excludeScrollbar?: boolean;
8
- /**
9
- * Whether to exclude the element's borders from the calculation.
10
- */
11
- excludeBorders?: boolean;
12
- };
@@ -1,3 +0,0 @@
1
- import { Rect } from "./rect";
2
- import type { Point } from "./types";
3
- export declare function getRectFromPoints(...pts: Point[]): Rect;
@@ -1,2 +0,0 @@
1
- import { Rect } from "./rect";
2
- export declare function fromRange(range: Range): Rect;
@@ -1,5 +0,0 @@
1
- import { Rect } from "./rect";
2
- import type { Point } from "./types";
3
- export declare function toRad(d: number): number;
4
- export declare function rotate(a: Point, d: number, c: Point): Point;
5
- export declare function getRotationRect(r: Rect, deg: number): Rect;
@@ -1,20 +0,0 @@
1
- import { Rect } from "./rect";
2
- export declare type WindowRectOptions = {
3
- /**
4
- * Whether to exclude the element's scrollbar size from the calculation.
5
- */
6
- excludeScrollbar?: boolean;
7
- };
8
- /**
9
- * Creates a rectange from window object
10
- */
11
- export declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
12
- /**
13
- * Get the rect of the window with the option to exclude the scrollbar
14
- */
15
- export declare function getViewportRect(win: Window, opts: WindowRectOptions): {
16
- x: number;
17
- y: number;
18
- width: number;
19
- height: number;
20
- };
@@ -1,5 +0,0 @@
1
- import type { RectValue } from "./types";
2
- export declare function getElementPolygon(rectValue: RectValue, placement: string): {
3
- x: number;
4
- y: number;
5
- }[];
@@ -1,14 +0,0 @@
1
- import { Rect } from "./rect";
2
- import type { RectSide } from "./types";
3
- /**
4
- * Checks if a Rect intersects another Rect
5
- */
6
- export declare function intersects(a: Rect, b: Rect): boolean;
7
- /**
8
- * Returns a new Rect that represents the intersection between two Rects
9
- */
10
- export declare function intersection(a: Rect, b: Rect): Rect;
11
- /**
12
- * Returns whether two rects collide along each edge
13
- */
14
- export declare function collisions(a: Rect, b: Rect): Record<RectSide, boolean>;
@@ -1,7 +0,0 @@
1
- import { Rect } from "./rect";
2
- import type { Point, RectInset, SymmetricRectInset } from "./types";
3
- export declare const isSymmetric: (v: any) => v is SymmetricRectInset;
4
- export declare function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect;
5
- export declare function expand(r: Rect, v: number | SymmetricRectInset): Rect;
6
- export declare function shrink(r: Rect, v: number | SymmetricRectInset): Rect;
7
- export declare function shift(r: Rect, o: Partial<Point>): Rect;
package/dist/polygon.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Point } from "./types";
2
- export declare function isPointInPolygon(polygon: Point[], point: Point): boolean;
3
- export declare function debugPolygon(polygon: Point[]): () => void;
package/dist/rect.d.ts DELETED
@@ -1,61 +0,0 @@
1
- import type { RectEdge, RectValue } from "./types";
2
- export declare function createRect(r: RectValue): {
3
- x: number;
4
- y: number;
5
- width: number;
6
- height: number;
7
- minX: number;
8
- minY: number;
9
- maxX: number;
10
- maxY: number;
11
- midX: number;
12
- midY: number;
13
- center: {
14
- x: number;
15
- y: number;
16
- };
17
- };
18
- export declare type Rect = ReturnType<typeof createRect>;
19
- export declare function isRect(v: any): v is Rect;
20
- export declare function getRectCenters(v: Rect): {
21
- top: {
22
- x: number;
23
- y: number;
24
- };
25
- right: {
26
- x: number;
27
- y: number;
28
- };
29
- bottom: {
30
- x: number;
31
- y: number;
32
- };
33
- left: {
34
- x: number;
35
- y: number;
36
- };
37
- };
38
- export declare function getRectCorners(v: Rect): {
39
- top: {
40
- x: number;
41
- y: number;
42
- };
43
- right: {
44
- x: number;
45
- y: number;
46
- };
47
- bottom: {
48
- x: number;
49
- y: number;
50
- };
51
- left: {
52
- x: number;
53
- y: number;
54
- };
55
- };
56
- export declare function getRectEdges(v: Rect): {
57
- top: RectEdge;
58
- right: RectEdge;
59
- bottom: RectEdge;
60
- left: RectEdge;
61
- };
package/dist/types.d.ts DELETED
@@ -1,30 +0,0 @@
1
- export declare type Point = {
2
- x: number;
3
- y: number;
4
- };
5
- export declare type RectValue = {
6
- x: number;
7
- y: number;
8
- width: number;
9
- height: number;
10
- };
11
- export declare type RectSide = "top" | "right" | "bottom" | "left";
12
- export declare type RectPoint = "top-left" | "top-center" | "top-right" | "right-center" | "left-center" | "bottom-left" | "bottom-right" | "bottom-center" | "center";
13
- export declare type RectEdge = [Point, Point];
14
- export declare type RectPoints = [Point, Point, Point, Point];
15
- export declare type RectEdges = Record<RectSide, RectEdge> & {
16
- value: RectEdge[];
17
- };
18
- export declare type RectCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
19
- export declare type RectCorners = Record<RectCorner, Point> & {
20
- value: RectPoints;
21
- };
22
- export declare type RectCenter = "topCenter" | "rightCenter" | "leftCenter" | "bottomCenter";
23
- export declare type RectCenters = Record<RectCenter, Point> & {
24
- value: RectPoints;
25
- };
26
- export declare type RectInset = Partial<Record<RectSide, number>>;
27
- export declare type SymmetricRectInset = {
28
- dx?: number;
29
- dy?: number;
30
- };
package/dist/union.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Rect } from "./rect";
2
- export declare function union(...rs: Rect[]): Rect;