@zag-js/rect-utils
Advanced tools
Comparing version 0.0.0-dev-20220412162814 to 0.0.0-dev-20220412212252
@@ -1,2 +0,2 @@ | ||
var d=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var W=t=>d(t,"__esModule",{value:!0});var C=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},j=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!I.call(t,i)&&(n||i!=="default")&&d(t,i,{get:()=>e[i],enumerable:!(o=X(e,i))||o.enumerable});return t};var K=(t=>(e,n)=>t&&t.get(e)||(n=j(W({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Q={};C(Q,{Rect:()=>s,closest:()=>N,debugPolygon:()=>J,distance:()=>R,expand:()=>$,getElementRect:()=>k,getEventPoint:()=>B,inset:()=>f,isSymmetric:()=>P,relativeToNode:()=>F,shift:()=>q,shrink:()=>D,withinPolygon:()=>z});var a=(t,e)=>({x:t,y:e}),s=class{constructor(e){this.v=e}static create(e){return new s(e)}set(e){return new s(Object.assign({},this.v,e))}clone(){return new s(this.v)}get x(){return this.v.x}get y(){return this.v.y}get width(){return this.v.width}get height(){return this.v.height}get minX(){return this.v.x}get midX(){return this.v.x+this.v.width/2}get maxX(){return this.v.x+this.v.width}get minY(){return this.v.y}get midY(){return this.v.y+this.v.height/2}get maxY(){return this.v.y+this.v.height}get center(){return a(this.midX,this.midY)}get centers(){let e=a(this.midX,this.minY),n=a(this.maxX,this.midY),o=a(this.midX,this.maxY),i=a(this.minX,this.midY);return{top:e,right:n,bottom:o,left:i}}get corners(){let e=a(this.minX,this.minY),n=a(this.maxX,this.minY),o=a(this.maxX,this.maxY),i=a(this.minX,this.maxY);return{top:e,right:n,bottom:o,left:i}}get edges(){let e=this.corners,n=[e.top,e.right],o=[e.right,e.bottom],i=[e.left,e.bottom],c=[e.top,e.left];return{top:n,right:o,bottom:i,left:c}}};var b=new WeakMap;function v(t){var n;if(!t)return{};let e=b.get(t);return e||(e=((n=t==null?void 0:t.ownerDocument.defaultView)!=null?n:window).getComputedStyle(t),b.set(t,e)),e}function k(t,e={}){return s.create(L(t,e))}function L(t,e={}){let{excludeScrollbar:n=!1,excludeBorders:o=!1}=e,{x:i,y:c,width:u,height:l}=t.getBoundingClientRect(),r={x:i,y:c,width:u,height:l},p=v(t),{borderLeftWidth:h,borderTopWidth:y,borderRightWidth:S,borderBottomWidth:A}=p,g=w(h,S),x=w(y,A);if(o&&(r.width-=g,r.height-=x,r.x+=m(h),r.y+=m(y)),n){let M=t.offsetWidth-t.clientWidth-g,T=t.offsetHeight-t.clientHeight-x;r.width-=M,r.height-=T}return r}var m=t=>parseFloat(t.replace("px","")),w=(...t)=>t.reduce((e,n)=>e+(n?m(n):0),0);var ot=(()=>{let t=0;return()=>(t++,t.toString(36))})();var O=t=>Array.isArray(t);var H=t=>!(t==null||typeof t!="object"||O(t));var E=t=>H(t)&&"touches"in t;function R(t,e={x:0,y:0}){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function N(...t){return e=>{let n=t.map(i=>R(i,e)),o=Math.min.apply(Math,n);return t[n.indexOf(o)]}}var V={pageX:0,pageY:0,clientX:0,clientY:0};function B(t,e="page"){let n=E(t)?t.touches[0]||t.changedTouches[0]||V:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function F(t,e){let n=t.x-e.offsetLeft-e.clientLeft+e.scrollLeft,o=t.y-e.offsetTop-e.clientTop+e.scrollTop;return{point:{x:n,y:o},progress:{x:n/e.offsetWidth,y:o/e.offsetHeight}}}var P=t=>"dx"in t||"dy"in t;function f(t,e){let n=P(e)?{left:e.dx,right:e.dx,top:e.dy,bottom:e.dy}:e,{top:o=0,right:i=0,bottom:c=0,left:u=0}=n;return s.create({x:t.x+u,y:t.y+o,width:t.width-u-i,height:t.height-o-c})}function $(t,e){let n=typeof e=="number"?{dx:-e,dy:-e}:e;return f(t,n)}function D(t,e){let n=typeof e=="number"?{dx:-e,dy:-e}:e;return f(t,n)}function q(t,e){let{x:n=0,y:o=0}=e;return s.create({x:t.x+n,y:t.y+o,width:t.width,height:t.height})}function z(t,e){let{x:n,y:o}=e,i=!1;for(let c=0,u=t.length-1;c<t.length;u=c++){let l=t[c].x,r=t[c].y,p=t[u].x,h=t[u].y;r>o!=h>o&&n<(p-l)*(o-r)/(h-r)+l&&(i=!i)}return i}function G(){let t="debug-polygon",e=document.getElementById(t);if(e)return e;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");Object.assign(n.style,{top:"0",left:"0",width:"100%",height:"100%",opacity:"0.15",position:"fixed",pointerEvents:"none"});let o=document.createElementNS("http://www.w3.org/2000/svg","polygon");return o.setAttribute("id",t),o.setAttribute("points","0,0 0,0"),n.appendChild(o),document.body.appendChild(n),o}function J(t){let e=G(),n=t.map(o=>`${o.x},${o.y}`).join(" ");e.setAttribute("points",n)}module.exports=K(Q); | ||
var d=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var W=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},C=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!I.call(t,i)&&i!==n&&d(t,i,{get:()=>e[i],enumerable:!(o=X(e,i))||o.enumerable});return t};var j=t=>C(d({},"__esModule",{value:!0}),t);var J={};W(J,{Rect:()=>r,closest:()=>H,debugPolygon:()=>G,distance:()=>R,expand:()=>F,getElementRect:()=>K,getEventPoint:()=>V,inset:()=>f,isSymmetric:()=>P,relativeToNode:()=>B,shift:()=>D,shrink:()=>$,withinPolygon:()=>q});module.exports=j(J);var a=(t,e)=>({x:t,y:e}),r=class{constructor(e){this.v=e}static create(e){return new r(e)}set(e){return new r(Object.assign({},this.v,e))}clone(){return new r(this.v)}get x(){return this.v.x}get y(){return this.v.y}get width(){return this.v.width}get height(){return this.v.height}get minX(){return this.v.x}get midX(){return this.v.x+this.v.width/2}get maxX(){return this.v.x+this.v.width}get minY(){return this.v.y}get midY(){return this.v.y+this.v.height/2}get maxY(){return this.v.y+this.v.height}get center(){return a(this.midX,this.midY)}get centers(){let e=a(this.midX,this.minY),n=a(this.maxX,this.midY),o=a(this.midX,this.maxY),i=a(this.minX,this.midY);return{top:e,right:n,bottom:o,left:i}}get corners(){let e=a(this.minX,this.minY),n=a(this.maxX,this.minY),o=a(this.maxX,this.maxY),i=a(this.minX,this.maxY);return{top:e,right:n,bottom:o,left:i}}get edges(){let e=this.corners,n=[e.top,e.right],o=[e.right,e.bottom],i=[e.left,e.bottom],c=[e.top,e.left];return{top:n,right:o,bottom:i,left:c}}};var b=new WeakMap;function v(t){var n;if(!t)return{};let e=b.get(t);return e||(e=((n=t==null?void 0:t.ownerDocument.defaultView)!=null?n:window).getComputedStyle(t),b.set(t,e)),e}function K(t,e={}){return r.create(k(t,e))}function k(t,e={}){let{excludeScrollbar:n=!1,excludeBorders:o=!1}=e,{x:i,y:c,width:u,height:l}=t.getBoundingClientRect(),s={x:i,y:c,width:u,height:l},p=v(t),{borderLeftWidth:h,borderTopWidth:y,borderRightWidth:S,borderBottomWidth:A}=p,g=w(h,S),x=w(y,A);if(o&&(s.width-=g,s.height-=x,s.x+=m(h),s.y+=m(y)),n){let M=t.offsetWidth-t.clientWidth-g,T=t.offsetHeight-t.clientHeight-x;s.width-=M,s.height-=T}return s}var m=t=>parseFloat(t.replace("px","")),w=(...t)=>t.reduce((e,n)=>e+(n?m(n):0),0);var nt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var L=t=>Array.isArray(t);var O=t=>!(t==null||typeof t!="object"||L(t));var E=t=>O(t)&&"touches"in t;function R(t,e={x:0,y:0}){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function H(...t){return e=>{let n=t.map(i=>R(i,e)),o=Math.min.apply(Math,n);return t[n.indexOf(o)]}}var N={pageX:0,pageY:0,clientX:0,clientY:0};function V(t,e="page"){let n=E(t)?t.touches[0]||t.changedTouches[0]||N:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function B(t,e){let n=t.x-e.offsetLeft-e.clientLeft+e.scrollLeft,o=t.y-e.offsetTop-e.clientTop+e.scrollTop;return{point:{x:n,y:o},progress:{x:n/e.offsetWidth,y:o/e.offsetHeight}}}var P=t=>"dx"in t||"dy"in t;function f(t,e){let n=P(e)?{left:e.dx,right:e.dx,top:e.dy,bottom:e.dy}:e,{top:o=0,right:i=0,bottom:c=0,left:u=0}=n;return r.create({x:t.x+u,y:t.y+o,width:t.width-u-i,height:t.height-o-c})}function F(t,e){let n=typeof e=="number"?{dx:-e,dy:-e}:e;return f(t,n)}function $(t,e){let n=typeof e=="number"?{dx:-e,dy:-e}:e;return f(t,n)}function D(t,e){let{x:n=0,y:o=0}=e;return r.create({x:t.x+n,y:t.y+o,width:t.width,height:t.height})}function q(t,e){let{x:n,y:o}=e,i=!1;for(let c=0,u=t.length-1;c<t.length;u=c++){let l=t[c].x,s=t[c].y,p=t[u].x,h=t[u].y;s>o!=h>o&&n<(p-l)*(o-s)/(h-s)+l&&(i=!i)}return i}function z(){let t="debug-polygon",e=document.getElementById(t);if(e)return e;let n=document.createElementNS("http://www.w3.org/2000/svg","svg");Object.assign(n.style,{top:"0",left:"0",width:"100%",height:"100%",opacity:"0.15",position:"fixed",pointerEvents:"none"});let o=document.createElementNS("http://www.w3.org/2000/svg","polygon");return o.setAttribute("id",t),o.setAttribute("points","0,0 0,0"),n.appendChild(o),document.body.appendChild(n),o}function G(t){let e=z(),n=t.map(o=>`${o.x},${o.y}`).join(" ");e.setAttribute("points",n)} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@zag-js/rect-utils", | ||
"version": "0.0.0-dev-20220412162814", | ||
"version": "0.0.0-dev-20220412212252", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "keywords": [ | ||
"author": "Segun Adebayo <sage@adebayosegun.com>", | ||
"homepage": "https://github.com/chakra-ui/ui-machines#readme", | ||
"homepage": "https://github.com/chakra-ui/zag#readme", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/utilities/rect", | ||
"repository": "https://github.com/chakra-ui/zag/tree/main/packages/utilities/rect", | ||
"sideEffects": false, | ||
@@ -27,7 +27,7 @@ "files": [ | ||
"bugs": { | ||
"url": "https://github.com/chakra-ui/ui-machines/issues" | ||
"url": "https://github.com/chakra-ui/zag/issues" | ||
}, | ||
"dependencies": { | ||
"@zag-js/utils": "^0.0.0-dev-20220412162814" | ||
"@zag-js/utils": "^0.0.0-dev-20220412212252" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
51178