@zag-js/rect-utils 0.1.1 → 0.1.2
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/index.js +4 -1
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +4 -1
- package/dist/index.mjs.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -152,9 +152,12 @@ var px = (v) => parseFloat(v.replace("px", ""));
|
|
|
152
152
|
var sum = (...vals) => vals.reduce((sum2, v) => sum2 + (v ? px(v) : 0), 0);
|
|
153
153
|
|
|
154
154
|
// ../core/dist/index.mjs
|
|
155
|
+
var isDom = () => typeof window !== "undefined";
|
|
155
156
|
var isArray = (v) => Array.isArray(v);
|
|
156
157
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
157
|
-
var
|
|
158
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
159
|
+
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
|
|
160
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
158
161
|
|
|
159
162
|
// src/point.ts
|
|
160
163
|
function distance(a, b = { x: 0, y: 0 }) {
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/rect.ts", "../src/computed-style.ts", "../src/from-element.ts", "../../core/src/array.ts", "../../core/src/
|
|
4
|
-
"sourcesContent": ["export * from \"./rect\"\nexport * from \"./types\"\nexport * from \"./from-element\"\nexport * from \"./point\"\nexport * from \"./operations\"\nexport * from \"./polygon\"\n", "import { RectEdge, RectValue } from \"./types\"\n\nconst point = (x: number, y: number) => ({ x, y })\n\nexport class Rect {\n static create(v: RectValue) {\n return new Rect(v)\n }\n protected constructor(private v: RectValue) {}\n set(n: Partial<RectValue>) {\n return new Rect(Object.assign({}, this.v, n))\n }\n clone() {\n return new Rect(this.v)\n }\n get x() {\n return this.v.x\n }\n get y() {\n return this.v.y\n }\n get width() {\n return this.v.width\n }\n get height() {\n return this.v.height\n }\n get minX() {\n return this.v.x\n }\n get midX() {\n return this.v.x + this.v.width / 2\n }\n get maxX() {\n return this.v.x + this.v.width\n }\n get minY() {\n return this.v.y\n }\n get midY() {\n return this.v.y + this.v.height / 2\n }\n get maxY() {\n return this.v.y + this.v.height\n }\n get center() {\n return point(this.midX, this.midY)\n }\n get centers() {\n const top = point(this.midX, this.minY)\n const right = point(this.maxX, this.midY)\n const bottom = point(this.midX, this.maxY)\n const left = point(this.minX, this.midY)\n return { top, right, bottom, left }\n }\n get corners() {\n const top = point(this.minX, this.minY)\n const right = point(this.maxX, this.minY)\n const bottom = point(this.maxX, this.maxY)\n const left = point(this.minX, this.maxY)\n return { top, right, bottom, left }\n }\n\n get edges() {\n const c = this.corners\n const top: RectEdge = [c.top, c.right]\n const right: RectEdge = [c.right, c.bottom]\n const bottom: RectEdge = [c.left, c.bottom]\n const left: RectEdge = [c.top, c.left]\n return { top, right, bottom, left }\n }\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n", "import { Rect } from \"./rect\"\nimport { getComputedStyle } from \"./computed-style\"\n\nexport function getElementRect(el: HTMLElement, opts: ElementRectOptions = {}): Rect {\n return Rect.create(getClientRect(el, opts))\n}\n\nexport type ElementRectOptions = {\n /**\n * Whether to exclude the element's scrollbar size from the calculation.\n */\n excludeScrollbar?: boolean\n /**\n * Whether to exclude the element's borders from the calculation.\n */\n excludeBorders?: boolean\n}\n\nfunction getClientRect(el: HTMLElement, opts: ElementRectOptions = {}) {\n const { excludeScrollbar = false, excludeBorders = false } = opts\n\n const { x, y, width, height } = el.getBoundingClientRect()\n const r = { x, y, width, height }\n\n const style = getComputedStyle(el)\n\n const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style\n\n const borderXWidth = sum(borderLeftWidth, borderRightWidth)\n const borderYWidth = sum(borderTopWidth, borderBottomWidth)\n\n if (excludeBorders) {\n r.width -= borderXWidth\n r.height -= borderYWidth\n r.x += px(borderLeftWidth)\n r.y += px(borderTopWidth)\n }\n\n if (excludeScrollbar) {\n const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth\n const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth\n r.width -= scrollbarWidth\n r.height -= scrollbarHeight\n }\n\n return r\n}\n\nconst px = (v: string) => parseFloat(v.replace(\"px\", \"\"))\n\nconst sum = (...vals: string[]) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0)\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\" | \"altKey\">) =>\n v.ctrlKey || v.altKey || v.metaKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { isTouchEvent } from \"@zag-js/utils\"\nimport { Point } from \"./types\"\n\nexport function distance(a: Point, b: Point = { x: 0, y: 0 }): number {\n return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2))\n}\n\nexport function closest(...pts: Point[]) {\n return (a: Point): Point => {\n const ds = pts.map((b) => distance(b, a))\n const c = Math.min.apply(Math, ds)\n return pts[ds.indexOf(c)]\n }\n}\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function getEventPoint(e: AnyPointerEvent, t: PointType = \"page\"): Point {\n const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e\n return { x: p[`${t}X`], y: p[`${t}Y`] }\n}\n\nexport function relativeToNode(p: Point, el: HTMLElement): RelativeValue {\n const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft\n const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop\n return {\n point: { x: dx, y: dy },\n progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight },\n }\n}\n\ntype AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent\n\ntype RelativeValue = {\n point: Point\n progress: { x: number; y: number }\n}\n\ntype PointType = \"page\" | \"client\"\n", "import { Rect } from \"./rect\"\nimport type { Point, RectInset, SymmetricRectInset } from \"./types\"\n\nexport const isSymmetric = (v: any): v is SymmetricRectInset => \"dx\" in v || \"dy\" in v\n\nexport function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect {\n const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i\n const { top = 0, right = 0, bottom = 0, left = 0 } = v\n return Rect.create({ x: r.x + left, y: r.y + top, width: r.width - left - right, height: r.height - top - bottom })\n}\n\nexport function expand(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shrink(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shift(r: Rect, o: Partial<Point>): Rect {\n const { x = 0, y = 0 } = o\n return Rect.create({ x: r.x + x, y: r.y + y, width: r.width, height: r.height })\n}\n", "import { Point } from \"./types\"\n\nexport function withinPolygon(polygon: Point[], point: Point) {\n const { x, y } = point\n let c = false\n\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x\n const yi = polygon[i].y\n const xj = polygon[j].x\n const yj = polygon[j].y\n\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {\n c = !c\n }\n }\n return c\n}\n\nfunction createPolygonElement() {\n const id = \"debug-polygon\"\n const existingPolygon = document.getElementById(id)\n if (existingPolygon) {\n return existingPolygon\n }\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n Object.assign(svg.style, {\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n opacity: \"0.15\",\n position: \"fixed\",\n pointerEvents: \"none\",\n })\n\n const polygon = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polygon\")\n polygon.setAttribute(\"id\", id)\n polygon.setAttribute(\"points\", \"0,0 0,0\")\n svg.appendChild(polygon)\n document.body.appendChild(svg)\n return polygon\n}\n\nexport function debugPolygon(polygon: Point[]) {\n const el = createPolygonElement()\n const points = polygon.map((point) => `${point.x},${point.y}`).join(\" \")\n el.setAttribute(\"points\", points)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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I,EAAE,GAAG,GAAG,OAAO,OAAO;AAEhC,QAAM,QAAQ,iBAAiB,EAAE;AAEjC,QAAM,EAAE,iBAAiB,gBAAgB,kBAAkB,sBAAsB;AAEjF,QAAM,eAAe,IAAI,iBAAiB,gBAAgB;AAC1D,QAAM,eAAe,IAAI,gBAAgB,iBAAiB;AAE1D,MAAI,gBAAgB;AAClB,MAAE,SAAS;AACX,MAAE,UAAU;AACZ,MAAE,KAAK,GAAG,eAAe;AACzB,MAAE,KAAK,GAAG,cAAc;AAAA,EAC1B;AAEA,MAAI,kBAAkB;AACpB,UAAM,iBAAiB,GAAG,cAAc,GAAG,cAAc;AACzD,UAAM,kBAAkB,GAAG,eAAe,GAAG,eAAe;AAC5D,MAAE,SAAS;AACX,MAAE,UAAU;AAAA,EACd;AAEA,SAAO;AACT;AAEA,IAAM,KAAK,CAAC,MAAc,WAAW,EAAE,QAAQ,MAAM,EAAE,CAAC;AAExD,IAAM,MAAM,IAAI,SAAmB,KAAK,OAAO,CAAC,MAAK,MAAM,OAAO,KAAI,GAAG,CAAC,IAAI,IAAI,CAAC;;;
|
|
3
|
+
"sources": ["../src/index.ts", "../src/rect.ts", "../src/computed-style.ts", "../src/from-element.ts", "../../core/src/array.ts", "../../core/src/guard.ts", "../../core/src/platform.ts", "../../core/src/events.ts", "../../core/src/functions.ts", "../../core/src/warning.ts", "../src/point.ts", "../src/operations.ts", "../src/polygon.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./rect\"\nexport * from \"./types\"\nexport * from \"./from-element\"\nexport * from \"./point\"\nexport * from \"./operations\"\nexport * from \"./polygon\"\n", "import { RectEdge, RectValue } from \"./types\"\n\nconst point = (x: number, y: number) => ({ x, y })\n\nexport class Rect {\n static create(v: RectValue) {\n return new Rect(v)\n }\n protected constructor(private v: RectValue) {}\n set(n: Partial<RectValue>) {\n return new Rect(Object.assign({}, this.v, n))\n }\n clone() {\n return new Rect(this.v)\n }\n get x() {\n return this.v.x\n }\n get y() {\n return this.v.y\n }\n get width() {\n return this.v.width\n }\n get height() {\n return this.v.height\n }\n get minX() {\n return this.v.x\n }\n get midX() {\n return this.v.x + this.v.width / 2\n }\n get maxX() {\n return this.v.x + this.v.width\n }\n get minY() {\n return this.v.y\n }\n get midY() {\n return this.v.y + this.v.height / 2\n }\n get maxY() {\n return this.v.y + this.v.height\n }\n get center() {\n return point(this.midX, this.midY)\n }\n get centers() {\n const top = point(this.midX, this.minY)\n const right = point(this.maxX, this.midY)\n const bottom = point(this.midX, this.maxY)\n const left = point(this.minX, this.midY)\n return { top, right, bottom, left }\n }\n get corners() {\n const top = point(this.minX, this.minY)\n const right = point(this.maxX, this.minY)\n const bottom = point(this.maxX, this.maxY)\n const left = point(this.minX, this.maxY)\n return { top, right, bottom, left }\n }\n\n get edges() {\n const c = this.corners\n const top: RectEdge = [c.top, c.right]\n const right: RectEdge = [c.right, c.bottom]\n const bottom: RectEdge = [c.left, c.bottom]\n const left: RectEdge = [c.top, c.left]\n return { top, right, bottom, left }\n }\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n", "import { Rect } from \"./rect\"\nimport { getComputedStyle } from \"./computed-style\"\n\nexport function getElementRect(el: HTMLElement, opts: ElementRectOptions = {}): Rect {\n return Rect.create(getClientRect(el, opts))\n}\n\nexport type ElementRectOptions = {\n /**\n * Whether to exclude the element's scrollbar size from the calculation.\n */\n excludeScrollbar?: boolean\n /**\n * Whether to exclude the element's borders from the calculation.\n */\n excludeBorders?: boolean\n}\n\nfunction getClientRect(el: HTMLElement, opts: ElementRectOptions = {}) {\n const { excludeScrollbar = false, excludeBorders = false } = opts\n\n const { x, y, width, height } = el.getBoundingClientRect()\n const r = { x, y, width, height }\n\n const style = getComputedStyle(el)\n\n const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style\n\n const borderXWidth = sum(borderLeftWidth, borderRightWidth)\n const borderYWidth = sum(borderTopWidth, borderBottomWidth)\n\n if (excludeBorders) {\n r.width -= borderXWidth\n r.height -= borderYWidth\n r.x += px(borderLeftWidth)\n r.y += px(borderTopWidth)\n }\n\n if (excludeScrollbar) {\n const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth\n const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth\n r.width -= scrollbarWidth\n r.height -= scrollbarHeight\n }\n\n return r\n}\n\nconst px = (v: string) => parseFloat(v.replace(\"px\", \"\"))\n\nconst sum = (...vals: string[]) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0)\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => typeof window !== \"undefined\"\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const hasProp = <T extends string>(obj: any, prop: T): obj is Record<T, any> =>\n Object.prototype.hasOwnProperty.call(obj, prop)\n", "import { isDom } from \"./guard\"\n\nexport function getPlatform() {\n const agent = (navigator as any).userAgentData\n return agent?.platform ?? navigator.platform\n}\n\nconst pt = (v: RegExp) => isDom() && v.test(getPlatform())\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\nconst vn = (v: RegExp) => isDom() && v.test(navigator.vendor)\n\nexport const isTouchDevice = isDom() && !!navigator.maxTouchPoints\nexport const isMac = () => pt(/^Mac/) && !isTouchDevice\nexport const isIPhone = () => pt(/^iPhone/)\nexport const isSafari = () => isApple() && vn(/apple/i)\nexport const isFirefox = () => ua(/firefox\\//i)\nexport const isApple = () => pt(/mac|iphone|ipad|ipod/i)\nexport const isIos = () => isApple() && !isMac()\n", "import { hasProp, isDom, isObject } from \"./guard\"\nimport { isMac } from \"./platform\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && hasProp(v, \"button\")\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && hasProp(v, \"touches\")\nexport const isLeftClick = (v: { button: number }) => v.button === 0\nexport const isRightClick = (v: { button: number }) => v.button === 2\nexport const isModifiedEvent = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\" | \"altKey\">) =>\n v.ctrlKey || v.altKey || v.metaKey\n\nexport const isCtrlKey = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\">) =>\n isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { isTouchEvent } from \"@zag-js/utils\"\nimport { Point } from \"./types\"\n\nexport function distance(a: Point, b: Point = { x: 0, y: 0 }): number {\n return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2))\n}\n\nexport function closest(...pts: Point[]) {\n return (a: Point): Point => {\n const ds = pts.map((b) => distance(b, a))\n const c = Math.min.apply(Math, ds)\n return pts[ds.indexOf(c)]\n }\n}\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function getEventPoint(e: AnyPointerEvent, t: PointType = \"page\"): Point {\n const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e\n return { x: p[`${t}X`], y: p[`${t}Y`] }\n}\n\nexport function relativeToNode(p: Point, el: HTMLElement): RelativeValue {\n const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft\n const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop\n return {\n point: { x: dx, y: dy },\n progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight },\n }\n}\n\ntype AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent\n\ntype RelativeValue = {\n point: Point\n progress: { x: number; y: number }\n}\n\ntype PointType = \"page\" | \"client\"\n", "import { Rect } from \"./rect\"\nimport type { Point, RectInset, SymmetricRectInset } from \"./types\"\n\nexport const isSymmetric = (v: any): v is SymmetricRectInset => \"dx\" in v || \"dy\" in v\n\nexport function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect {\n const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i\n const { top = 0, right = 0, bottom = 0, left = 0 } = v\n return Rect.create({ x: r.x + left, y: r.y + top, width: r.width - left - right, height: r.height - top - bottom })\n}\n\nexport function expand(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shrink(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shift(r: Rect, o: Partial<Point>): Rect {\n const { x = 0, y = 0 } = o\n return Rect.create({ x: r.x + x, y: r.y + y, width: r.width, height: r.height })\n}\n", "import { Point } from \"./types\"\n\nexport function withinPolygon(polygon: Point[], point: Point) {\n const { x, y } = point\n let c = false\n\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x\n const yi = polygon[i].y\n const xj = polygon[j].x\n const yj = polygon[j].y\n\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {\n c = !c\n }\n }\n return c\n}\n\nfunction createPolygonElement() {\n const id = \"debug-polygon\"\n const existingPolygon = document.getElementById(id)\n if (existingPolygon) {\n return existingPolygon\n }\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n Object.assign(svg.style, {\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n opacity: \"0.15\",\n position: \"fixed\",\n pointerEvents: \"none\",\n })\n\n const polygon = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polygon\")\n polygon.setAttribute(\"id\", id)\n polygon.setAttribute(\"points\", \"0,0 0,0\")\n svg.appendChild(polygon)\n document.body.appendChild(svg)\n return polygon\n}\n\nexport function debugPolygon(polygon: Point[]) {\n const el = createPolygonElement()\n const points = polygon.map((point) => `${point.x},${point.y}`).join(\" \")\n el.setAttribute(\"points\", points)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,QAAQ,CAAC,GAAW,MAAe,GAAE,GAAG,EAAE;AAEzC,iBAAW;AAAA,EAIN,YAAoB,GAAc;AAAd;AAAA,EAAe;AAAA,SAHtC,OAAO,GAAc;AAC1B,WAAO,IAAI,KAAK,CAAC;AAAA,EACnB;AAAA,EAEA,IAAI,GAAuB;AACzB,WAAO,IAAI,KAAK,OAAO,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAAA,EAC9C;AAAA,EACA,QAAQ;AACN,WAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACxB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,QAAQ;AACV,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,SAAS;AACX,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,QAAQ;AAAA,EACnC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,SAAS;AAAA,EACpC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,SAAS;AACX,WAAO,MAAM,KAAK,MAAM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AgB,8BAA8B,KAAK;AACxE,SAAO,OAAO,IAAI,OAAO;AAAA,IACvB,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,eAAe;AAAA,EACjB,CAAC;AAED,QAAM,UAAU,SAAS,gBAAgB,8BAA8B,SAAS;AAChF,UAAQ,aAAa,MAAM,EAAE;AAC7B,UAAQ,aAAa,UAAU,SAAS;AACxC,MAAI,YAAY,OAAO;AACvB,WAAS,KAAK,YAAY,GAAG;AAC7B,SAAO;AACT;AAEO,sBAAsB,SAAkB;AAC7C,QAAM,KAAK,qBAAqB;AAChC,QAAM,SAAS,QAAQ,IAAI,CAAC,WAAU,GAAG,OAAM,KAAK,OAAM,GAAG,EAAE,KAAK,GAAG;AACvE,KAAG,aAAa,UAAU,MAAM;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -115,9 +115,12 @@ var px = (v) => parseFloat(v.replace("px", ""));
|
|
|
115
115
|
var sum = (...vals) => vals.reduce((sum2, v) => sum2 + (v ? px(v) : 0), 0);
|
|
116
116
|
|
|
117
117
|
// ../core/dist/index.mjs
|
|
118
|
+
var isDom = () => typeof window !== "undefined";
|
|
118
119
|
var isArray = (v) => Array.isArray(v);
|
|
119
120
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
120
|
-
var
|
|
121
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
122
|
+
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
|
|
123
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
121
124
|
|
|
122
125
|
// src/point.ts
|
|
123
126
|
function distance(a, b = { x: 0, y: 0 }) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/rect.ts", "../src/computed-style.ts", "../src/from-element.ts", "../../core/src/array.ts", "../../core/src/
|
|
4
|
-
"sourcesContent": ["import { RectEdge, RectValue } from \"./types\"\n\nconst point = (x: number, y: number) => ({ x, y })\n\nexport class Rect {\n static create(v: RectValue) {\n return new Rect(v)\n }\n protected constructor(private v: RectValue) {}\n set(n: Partial<RectValue>) {\n return new Rect(Object.assign({}, this.v, n))\n }\n clone() {\n return new Rect(this.v)\n }\n get x() {\n return this.v.x\n }\n get y() {\n return this.v.y\n }\n get width() {\n return this.v.width\n }\n get height() {\n return this.v.height\n }\n get minX() {\n return this.v.x\n }\n get midX() {\n return this.v.x + this.v.width / 2\n }\n get maxX() {\n return this.v.x + this.v.width\n }\n get minY() {\n return this.v.y\n }\n get midY() {\n return this.v.y + this.v.height / 2\n }\n get maxY() {\n return this.v.y + this.v.height\n }\n get center() {\n return point(this.midX, this.midY)\n }\n get centers() {\n const top = point(this.midX, this.minY)\n const right = point(this.maxX, this.midY)\n const bottom = point(this.midX, this.maxY)\n const left = point(this.minX, this.midY)\n return { top, right, bottom, left }\n }\n get corners() {\n const top = point(this.minX, this.minY)\n const right = point(this.maxX, this.minY)\n const bottom = point(this.maxX, this.maxY)\n const left = point(this.minX, this.maxY)\n return { top, right, bottom, left }\n }\n\n get edges() {\n const c = this.corners\n const top: RectEdge = [c.top, c.right]\n const right: RectEdge = [c.right, c.bottom]\n const bottom: RectEdge = [c.left, c.bottom]\n const left: RectEdge = [c.top, c.left]\n return { top, right, bottom, left }\n }\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n", "import { Rect } from \"./rect\"\nimport { getComputedStyle } from \"./computed-style\"\n\nexport function getElementRect(el: HTMLElement, opts: ElementRectOptions = {}): Rect {\n return Rect.create(getClientRect(el, opts))\n}\n\nexport type ElementRectOptions = {\n /**\n * Whether to exclude the element's scrollbar size from the calculation.\n */\n excludeScrollbar?: boolean\n /**\n * Whether to exclude the element's borders from the calculation.\n */\n excludeBorders?: boolean\n}\n\nfunction getClientRect(el: HTMLElement, opts: ElementRectOptions = {}) {\n const { excludeScrollbar = false, excludeBorders = false } = opts\n\n const { x, y, width, height } = el.getBoundingClientRect()\n const r = { x, y, width, height }\n\n const style = getComputedStyle(el)\n\n const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style\n\n const borderXWidth = sum(borderLeftWidth, borderRightWidth)\n const borderYWidth = sum(borderTopWidth, borderBottomWidth)\n\n if (excludeBorders) {\n r.width -= borderXWidth\n r.height -= borderYWidth\n r.x += px(borderLeftWidth)\n r.y += px(borderTopWidth)\n }\n\n if (excludeScrollbar) {\n const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth\n const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth\n r.width -= scrollbarWidth\n r.height -= scrollbarHeight\n }\n\n return r\n}\n\nconst px = (v: string) => parseFloat(v.replace(\"px\", \"\"))\n\nconst sum = (...vals: string[]) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0)\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\" | \"altKey\">) =>\n v.ctrlKey || v.altKey || v.metaKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { isTouchEvent } from \"@zag-js/utils\"\nimport { Point } from \"./types\"\n\nexport function distance(a: Point, b: Point = { x: 0, y: 0 }): number {\n return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2))\n}\n\nexport function closest(...pts: Point[]) {\n return (a: Point): Point => {\n const ds = pts.map((b) => distance(b, a))\n const c = Math.min.apply(Math, ds)\n return pts[ds.indexOf(c)]\n }\n}\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function getEventPoint(e: AnyPointerEvent, t: PointType = \"page\"): Point {\n const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e\n return { x: p[`${t}X`], y: p[`${t}Y`] }\n}\n\nexport function relativeToNode(p: Point, el: HTMLElement): RelativeValue {\n const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft\n const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop\n return {\n point: { x: dx, y: dy },\n progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight },\n }\n}\n\ntype AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent\n\ntype RelativeValue = {\n point: Point\n progress: { x: number; y: number }\n}\n\ntype PointType = \"page\" | \"client\"\n", "import { Rect } from \"./rect\"\nimport type { Point, RectInset, SymmetricRectInset } from \"./types\"\n\nexport const isSymmetric = (v: any): v is SymmetricRectInset => \"dx\" in v || \"dy\" in v\n\nexport function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect {\n const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i\n const { top = 0, right = 0, bottom = 0, left = 0 } = v\n return Rect.create({ x: r.x + left, y: r.y + top, width: r.width - left - right, height: r.height - top - bottom })\n}\n\nexport function expand(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shrink(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shift(r: Rect, o: Partial<Point>): Rect {\n const { x = 0, y = 0 } = o\n return Rect.create({ x: r.x + x, y: r.y + y, width: r.width, height: r.height })\n}\n", "import { Point } from \"./types\"\n\nexport function withinPolygon(polygon: Point[], point: Point) {\n const { x, y } = point\n let c = false\n\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x\n const yi = polygon[i].y\n const xj = polygon[j].x\n const yj = polygon[j].y\n\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {\n c = !c\n }\n }\n return c\n}\n\nfunction createPolygonElement() {\n const id = \"debug-polygon\"\n const existingPolygon = document.getElementById(id)\n if (existingPolygon) {\n return existingPolygon\n }\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n Object.assign(svg.style, {\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n opacity: \"0.15\",\n position: \"fixed\",\n pointerEvents: \"none\",\n })\n\n const polygon = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polygon\")\n polygon.setAttribute(\"id\", id)\n polygon.setAttribute(\"points\", \"0,0 0,0\")\n svg.appendChild(polygon)\n document.body.appendChild(svg)\n return polygon\n}\n\nexport function debugPolygon(polygon: Point[]) {\n const el = createPolygonElement()\n const points = polygon.map((point) => `${point.x},${point.y}`).join(\" \")\n el.setAttribute(\"points\", points)\n}\n"],
|
|
5
|
-
"mappings": ";AAEA,IAAM,QAAQ,CAAC,GAAW,MAAe,GAAE,GAAG,EAAE;AAEzC,iBAAW;AAAA,EAIN,YAAoB,GAAc;AAAd;AAAA,EAAe;AAAA,SAHtC,OAAO,GAAc;AAC1B,WAAO,IAAI,KAAK,CAAC;AAAA,EACnB;AAAA,EAEA,IAAI,GAAuB;AACzB,WAAO,IAAI,KAAK,OAAO,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAAA,EAC9C;AAAA,EACA,QAAQ;AACN,WAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACxB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,QAAQ;AACV,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,SAAS;AACX,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,QAAQ;AAAA,EACnC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,SAAS;AAAA,EACpC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,SAAS;AACX,WAAO,MAAM,KAAK,MAAM,KAAK,IAAI;AAAA,EACnC;AAAA,MACI,UAAU;AAC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AAiB,OAA2B,CAAC,GAAG;AACrE,QAAM,EAAE,mBAAmB,OAAO,iBAAiB,UAAU;AAE7D,QAAM,EAAE,GAAG,GAAG,OAAO,WAAW,GAAG,sBAAsB;AACzD,QAAM,IAAI,EAAE,GAAG,GAAG,OAAO,OAAO;AAEhC,QAAM,QAAQ,iBAAiB,EAAE;AAEjC,QAAM,EAAE,iBAAiB,gBAAgB,kBAAkB,sBAAsB;AAEjF,QAAM,eAAe,IAAI,iBAAiB,gBAAgB;AAC1D,QAAM,eAAe,IAAI,gBAAgB,iBAAiB;AAE1D,MAAI,gBAAgB;AAClB,MAAE,SAAS;AACX,MAAE,UAAU;AACZ,MAAE,KAAK,GAAG,eAAe;AACzB,MAAE,KAAK,GAAG,cAAc;AAAA,EAC1B;AAEA,MAAI,kBAAkB;AACpB,UAAM,iBAAiB,GAAG,cAAc,GAAG,cAAc;AACzD,UAAM,kBAAkB,GAAG,eAAe,GAAG,eAAe;AAC5D,MAAE,SAAS;AACX,MAAE,UAAU;AAAA,EACd;AAEA,SAAO;AACT;AAEA,IAAM,KAAK,CAAC,MAAc,WAAW,EAAE,QAAQ,MAAM,EAAE,CAAC;AAExD,IAAM,MAAM,IAAI,SAAmB,KAAK,OAAO,CAAC,MAAK,MAAM,OAAO,KAAI,GAAG,CAAC,IAAI,IAAI,CAAC;;;
|
|
3
|
+
"sources": ["../src/rect.ts", "../src/computed-style.ts", "../src/from-element.ts", "../../core/src/array.ts", "../../core/src/guard.ts", "../../core/src/platform.ts", "../../core/src/events.ts", "../../core/src/functions.ts", "../../core/src/warning.ts", "../src/point.ts", "../src/operations.ts", "../src/polygon.ts"],
|
|
4
|
+
"sourcesContent": ["import { RectEdge, RectValue } from \"./types\"\n\nconst point = (x: number, y: number) => ({ x, y })\n\nexport class Rect {\n static create(v: RectValue) {\n return new Rect(v)\n }\n protected constructor(private v: RectValue) {}\n set(n: Partial<RectValue>) {\n return new Rect(Object.assign({}, this.v, n))\n }\n clone() {\n return new Rect(this.v)\n }\n get x() {\n return this.v.x\n }\n get y() {\n return this.v.y\n }\n get width() {\n return this.v.width\n }\n get height() {\n return this.v.height\n }\n get minX() {\n return this.v.x\n }\n get midX() {\n return this.v.x + this.v.width / 2\n }\n get maxX() {\n return this.v.x + this.v.width\n }\n get minY() {\n return this.v.y\n }\n get midY() {\n return this.v.y + this.v.height / 2\n }\n get maxY() {\n return this.v.y + this.v.height\n }\n get center() {\n return point(this.midX, this.midY)\n }\n get centers() {\n const top = point(this.midX, this.minY)\n const right = point(this.maxX, this.midY)\n const bottom = point(this.midX, this.maxY)\n const left = point(this.minX, this.midY)\n return { top, right, bottom, left }\n }\n get corners() {\n const top = point(this.minX, this.minY)\n const right = point(this.maxX, this.minY)\n const bottom = point(this.maxX, this.maxY)\n const left = point(this.minX, this.maxY)\n return { top, right, bottom, left }\n }\n\n get edges() {\n const c = this.corners\n const top: RectEdge = [c.top, c.right]\n const right: RectEdge = [c.right, c.bottom]\n const bottom: RectEdge = [c.left, c.bottom]\n const left: RectEdge = [c.top, c.left]\n return { top, right, bottom, left }\n }\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n if (!el) return {} as Styles\n let style: Styles | undefined = styleCache.get(el)\n if (!style) {\n const win = el?.ownerDocument.defaultView ?? window\n style = win.getComputedStyle(el) as Styles\n styleCache.set(el, style)\n }\n return style\n}\n", "import { Rect } from \"./rect\"\nimport { getComputedStyle } from \"./computed-style\"\n\nexport function getElementRect(el: HTMLElement, opts: ElementRectOptions = {}): Rect {\n return Rect.create(getClientRect(el, opts))\n}\n\nexport type ElementRectOptions = {\n /**\n * Whether to exclude the element's scrollbar size from the calculation.\n */\n excludeScrollbar?: boolean\n /**\n * Whether to exclude the element's borders from the calculation.\n */\n excludeBorders?: boolean\n}\n\nfunction getClientRect(el: HTMLElement, opts: ElementRectOptions = {}) {\n const { excludeScrollbar = false, excludeBorders = false } = opts\n\n const { x, y, width, height } = el.getBoundingClientRect()\n const r = { x, y, width, height }\n\n const style = getComputedStyle(el)\n\n const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style\n\n const borderXWidth = sum(borderLeftWidth, borderRightWidth)\n const borderYWidth = sum(borderTopWidth, borderBottomWidth)\n\n if (excludeBorders) {\n r.width -= borderXWidth\n r.height -= borderYWidth\n r.x += px(borderLeftWidth)\n r.y += px(borderTopWidth)\n }\n\n if (excludeScrollbar) {\n const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth\n const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth\n r.width -= scrollbarWidth\n r.height -= scrollbarHeight\n }\n\n return r\n}\n\nconst px = (v: string) => parseFloat(v.replace(\"px\", \"\"))\n\nconst sum = (...vals: string[]) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0)\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n if (!v) return []\n return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n if (i > -1) v.splice(i, 1)\n return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n while (v.length > 0) v.pop()\n return v\n}\n\nexport type IndexOptions = {\n step?: number\n loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n const next = idx + step\n const len = v.length\n const last = len - 1\n if (idx === -1) return step > 0 ? 0 : last\n if (next < 0) return loop ? last : 0\n if (next >= len) return loop ? 0 : idx > len ? len : idx\n return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n const { step = 1, loop = true } = opts\n return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n const res: T[][] = []\n return v.reduce((rows, value, index) => {\n if (index % size === 0) rows.push([value])\n else last(rows)?.push(value)\n return rows\n }, res)\n}\n", "export const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => typeof window !== \"undefined\"\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const hasProp = <T extends string>(obj: any, prop: T): obj is Record<T, any> =>\n Object.prototype.hasOwnProperty.call(obj, prop)\n", "import { isDom } from \"./guard\"\n\nexport function getPlatform() {\n const agent = (navigator as any).userAgentData\n return agent?.platform ?? navigator.platform\n}\n\nconst pt = (v: RegExp) => isDom() && v.test(getPlatform())\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\nconst vn = (v: RegExp) => isDom() && v.test(navigator.vendor)\n\nexport const isTouchDevice = isDom() && !!navigator.maxTouchPoints\nexport const isMac = () => pt(/^Mac/) && !isTouchDevice\nexport const isIPhone = () => pt(/^iPhone/)\nexport const isSafari = () => isApple() && vn(/apple/i)\nexport const isFirefox = () => ua(/firefox\\//i)\nexport const isApple = () => pt(/mac|iphone|ipad|ipod/i)\nexport const isIos = () => isApple() && !isMac()\n", "import { hasProp, isDom, isObject } from \"./guard\"\nimport { isMac } from \"./platform\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && hasProp(v, \"button\")\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && hasProp(v, \"touches\")\nexport const isLeftClick = (v: { button: number }) => v.button === 0\nexport const isRightClick = (v: { button: number }) => v.button === 2\nexport const isModifiedEvent = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\" | \"altKey\">) =>\n v.ctrlKey || v.altKey || v.metaKey\n\nexport const isCtrlKey = (v: Pick<KeyboardEvent, \"ctrlKey\" | \"metaKey\">) =>\n isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey\n", "export const runIfFn = <T>(\n v: T | undefined,\n ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T> => {\n const res = typeof v === \"function\" ? v(...a) : v\n return res ?? undefined\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n <T>(...fns: Array<(a: T) => T>) =>\n (v: T) =>\n fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n (...a: Parameters<T>) => {\n fns.forEach(function (fn) {\n fn?.(...a)\n })\n }\n\nexport const uuid = /*#__PURE__*/ (() => {\n let id = 0\n return () => {\n id++\n return id.toString(36)\n }\n})()\n\nexport function merge<T, U>(origin: T, patch: U): T & U {\n if (!(typeof patch === \"object\")) return patch as any\n const result = !(typeof origin === \"object\") ? {} : Object.assign({}, origin)\n for (const key of Object.keys(patch)) {\n const value = patch[key]\n const src = result[key]\n if (value === null) delete result[key]\n else if (Array.isArray(value) || Array.isArray(src)) result[key] = (src || []).concat(value || [])\n else result[key] = merge(src, value)\n }\n return result as any\n}\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n console.warn(m)\n }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n const m = a.length === 1 ? a[0] : a[1]\n const c = a.length === 2 ? a[0] : true\n if (c && process.env.NODE_ENV !== \"production\") {\n throw new Error(m)\n }\n}\n", "import { isTouchEvent } from \"@zag-js/utils\"\nimport { Point } from \"./types\"\n\nexport function distance(a: Point, b: Point = { x: 0, y: 0 }): number {\n return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2))\n}\n\nexport function closest(...pts: Point[]) {\n return (a: Point): Point => {\n const ds = pts.map((b) => distance(b, a))\n const c = Math.min.apply(Math, ds)\n return pts[ds.indexOf(c)]\n }\n}\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function getEventPoint(e: AnyPointerEvent, t: PointType = \"page\"): Point {\n const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e\n return { x: p[`${t}X`], y: p[`${t}Y`] }\n}\n\nexport function relativeToNode(p: Point, el: HTMLElement): RelativeValue {\n const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft\n const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop\n return {\n point: { x: dx, y: dy },\n progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight },\n }\n}\n\ntype AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent\n\ntype RelativeValue = {\n point: Point\n progress: { x: number; y: number }\n}\n\ntype PointType = \"page\" | \"client\"\n", "import { Rect } from \"./rect\"\nimport type { Point, RectInset, SymmetricRectInset } from \"./types\"\n\nexport const isSymmetric = (v: any): v is SymmetricRectInset => \"dx\" in v || \"dy\" in v\n\nexport function inset(r: Rect, i: RectInset | SymmetricRectInset): Rect {\n const v = isSymmetric(i) ? { left: i.dx, right: i.dx, top: i.dy, bottom: i.dy } : i\n const { top = 0, right = 0, bottom = 0, left = 0 } = v\n return Rect.create({ x: r.x + left, y: r.y + top, width: r.width - left - right, height: r.height - top - bottom })\n}\n\nexport function expand(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shrink(r: Rect, v: number | SymmetricRectInset): Rect {\n const value = typeof v === \"number\" ? { dx: -v, dy: -v } : v\n return inset(r, value)\n}\n\nexport function shift(r: Rect, o: Partial<Point>): Rect {\n const { x = 0, y = 0 } = o\n return Rect.create({ x: r.x + x, y: r.y + y, width: r.width, height: r.height })\n}\n", "import { Point } from \"./types\"\n\nexport function withinPolygon(polygon: Point[], point: Point) {\n const { x, y } = point\n let c = false\n\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x\n const yi = polygon[i].y\n const xj = polygon[j].x\n const yj = polygon[j].y\n\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {\n c = !c\n }\n }\n return c\n}\n\nfunction createPolygonElement() {\n const id = \"debug-polygon\"\n const existingPolygon = document.getElementById(id)\n if (existingPolygon) {\n return existingPolygon\n }\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n Object.assign(svg.style, {\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n opacity: \"0.15\",\n position: \"fixed\",\n pointerEvents: \"none\",\n })\n\n const polygon = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polygon\")\n polygon.setAttribute(\"id\", id)\n polygon.setAttribute(\"points\", \"0,0 0,0\")\n svg.appendChild(polygon)\n document.body.appendChild(svg)\n return polygon\n}\n\nexport function debugPolygon(polygon: Point[]) {\n const el = createPolygonElement()\n const points = polygon.map((point) => `${point.x},${point.y}`).join(\" \")\n el.setAttribute(\"points\", points)\n}\n"],
|
|
5
|
+
"mappings": ";AAEA,IAAM,QAAQ,CAAC,GAAW,MAAe,GAAE,GAAG,EAAE;AAEzC,iBAAW;AAAA,EAIN,YAAoB,GAAc;AAAd;AAAA,EAAe;AAAA,SAHtC,OAAO,GAAc;AAC1B,WAAO,IAAI,KAAK,CAAC;AAAA,EACnB;AAAA,EAEA,IAAI,GAAuB;AACzB,WAAO,IAAI,KAAK,OAAO,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAAA,EAC9C;AAAA,EACA,QAAQ;AACN,WAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACxB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,IAAI;AACN,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,QAAQ;AACV,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,SAAS;AACX,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,QAAQ;AAAA,EACnC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE;AAAA,EAChB;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE,SAAS;AAAA,EACpC;AAAA,MACI,OAAO;AACT,WAAO,KAAK,EAAE,IAAI,KAAK,EAAE;AAAA,EAC3B;AAAA,MACI,SAAS;AACX,WAAO,MAAM,KAAK,MAAM,KAAK,IAAI;AAAA,EACnC;AAAA,MACI,UAAU;AACZ,UAAM,MAAM,MAAM,KAAK,MAAM,KAAK,IA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AA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,eAAe;AAAA,EACjB,CAAC;AAED,QAAM,UAAU,SAAS,gBAAgB,8BAA8B,SAAS;AAChF,UAAQ,aAAa,MAAM,EAAE;AAC7B,UAAQ,aAAa,UAAU,SAAS;AACxC,MAAI,YAAY,OAAO;AACvB,WAAS,KAAK,YAAY,GAAG;AAC7B,SAAO;AACT;AAEO,sBAAsB,SAAkB;AAC7C,QAAM,KAAK,qBAAqB;AAChC,QAAM,SAAS,QAAQ,IAAI,CAAC,WAAU,GAAG,OAAM,KAAK,OAAM,GAAG,EAAE,KAAK,GAAG;AACvE,KAAG,aAAa,UAAU,MAAM;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/rect-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zag-js/utils": "0.1.
|
|
28
|
+
"@zag-js/utils": "0.1.2"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build:fast": "zag build",
|