Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interop-ui/popper

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interop-ui/popper - npm Package Compare versions

Comparing version 0.0.1-15 to 0.2.0-rc.1

13

dist/index.d.ts
import * as CSS from "csstype";
import { Side, Align, Size } from "@interop-ui/utils";
export const SIDE_OPTIONS: readonly ["top", "right", "bottom", "left"];
export const ALIGN_OPTIONS: readonly ["start", "center", "end"];
export type Side = typeof SIDE_OPTIONS[number];
export type Align = typeof ALIGN_OPTIONS[number];
type Size = {
width: number;
height: number;
};
type GetPlacementDataOptions = {

@@ -22,2 +29,4 @@ /** The rect of the anchor we are placing around */

shouldAvoidCollisions?: boolean;
/** The rect which represents the boundaries for collision checks */
collisionBoundariesRect?: ClientRect;
/** The tolerance used for collisions, ie. if we want them to trigger a bit earlier (default: 0) */

@@ -43,4 +52,4 @@ collisionTolerance?: number;

*/
export function getPlacementData({ anchorRect, popperSize, arrowSize, arrowOffset, side, sideOffset, align, alignOffset, shouldAvoidCollisions, collisionTolerance, }: GetPlacementDataOptions): PlacementData;
export function getPlacementData({ anchorRect, popperSize, arrowSize, arrowOffset, side, sideOffset, align, alignOffset, shouldAvoidCollisions, collisionBoundariesRect, collisionTolerance, }: GetPlacementDataOptions): PlacementData;
//# sourceMappingURL=index.d.ts.map

2

dist/index.js

@@ -1,2 +0,2 @@

var t=require("@interop-ui/utils"),e=t.makeRect,r=t.getOppositeSide,n=t.getCollisions;function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t,e,r){var n=t["x"===r?"left":"top"],o="x"===r?"width":"height",i=t[o],a=e[o];return{before:n-a,start:n,center:n+(i-a)/2,end:n+i-a,after:n+i}}function p(t){var e=Math.round(t.x+window.scrollX),r=Math.round(t.y+window.scrollY);return{position:"absolute",top:0,left:0,willChange:"transform",transform:"translate3d(".concat(e,"px, ").concat(r,"px, 0)")}}function s(t,e,r,n,o){var i="top"===e||"bottom"===e,a=o?o.width:0,c=o?o.height:0,p=a/2+n,s="",l="";return i?(s={start:"".concat(p,"px"),center:"center",end:"".concat(t.width-p,"px")}[r],l="".concat("top"===e?t.height+c:-c,"px")):(s="".concat("left"===e?t.width+c:-c,"px"),l={start:"".concat(p,"px"),center:"center",end:"".concat(t.height-p,"px")}[r]),"".concat(s," ").concat(l)}exports.getPlacementData=function(t){var o=t.anchorRect,u=t.popperSize,h=t.arrowSize,g=t.arrowOffset,x=void 0===g?0:g,w=t.side,y=t.sideOffset,b=void 0===y?0:y,v=t.align,O=t.alignOffset,m=void 0===O?0:O,S=t.shouldAvoidCollisions,j=void 0===S||S,P=t.collisionTolerance,z=void 0===P?0:P;if(!o||!u)return{popperStyles:l,arrowStyles:f};var D=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,i=o?o.height:0,a=c(e,t,"x"),p=c(e,t,"y"),s=p.before-r-i,l=p.after+r+i,f=a.before-r-i,d=a.after+r+i;return{top:{start:{x:a.start+n,y:s},center:{x:a.center,y:s},end:{x:a.end-n,y:s}},right:{start:{x:d,y:p.start+n},center:{x:d,y:p.center},end:{x:d,y:p.end-n}},bottom:{start:{x:a.start+n,y:l},center:{x:a.center,y:l},end:{x:a.end-n,y:l}},left:{start:{x:f,y:p.start+n},center:{x:f,y:p.center},end:{x:f,y:p.end-n}}}}(u,o,b,m,h),C=D[w][v];if(!1===j){var A=p(C),E=f;h&&(E=d({popperSize:u,arrowSize:h,arrowOffset:x,side:w,align:v}));var M=s(u,w,v,x,h);return{popperStyles:i(i({},A),{},a({},"--radix-popper-transform-origin",M)),arrowStyles:E,placedSide:w,placedAlign:v}}var k=e(u,C),R=n(k,z),q=D[r(w)][v],T=e(u,q),X=function(t,e,n){var o=r(t);return e[t]&&!n[o]?o:t}(w,R,n(T,z)),Y=function(t,e,r,n,o){var i="top"===r||"bottom"===r,a=i?"left":"top",c=i?"right":"bottom",p=i?"width":"height",s=e[p]>t[p];if(("start"===n||"center"===n)&&(o[a]&&s||o[c]&&!s))return"end";if(("end"===n||"center"===n)&&(o[c]&&s||o[a]&&!s))return"start";return n}(u,o,w,v,R),B=p(D[X][Y]),F=f;h&&(F=d({popperSize:u,arrowSize:h,arrowOffset:x,side:X,align:Y}));var G=s(u,X,Y,x,h);return{popperStyles:i(i({},B),{},a({},"--radix-popper-transform-origin",G)),arrowStyles:F,placedSide:X,placedAlign:Y}};var l={position:"fixed",top:0,left:0,opacity:0,pointerEvents:"none"},f={position:"absolute",opacity:0};function d(t){var e,r=t.popperSize,n=t.arrowSize,o=t.arrowOffset,i=t.side,c=t.align,p=(r.width-n.width)/2,s=(r.height-n.width)/2,l={top:0,right:90,bottom:180,left:-90}[i],f=Math.max(n.width,n.height),d=(a(e={width:"".concat(f,"px"),height:"".concat(f,"px"),transform:"rotate(".concat(l,"deg)"),willChange:"transform",position:"absolute"},i,"100%"),a(e,"direction",function(t,e){if(("top"===t||"right"===t)&&"end"===e)return"rtl";if(("bottom"===t||"left"===t)&&"end"!==e)return"rtl";return"ltr"}(i,c)),e);return"top"!==i&&"bottom"!==i||("start"===c&&(d.left="".concat(o,"px")),"center"===c&&(d.left="".concat(p,"px")),"end"===c&&(d.right="".concat(o,"px"))),"left"!==i&&"right"!==i||("start"===c&&(d.top="".concat(o,"px")),"center"===c&&(d.top="".concat(s,"px")),"end"===c&&(d.bottom="".concat(o,"px"))),d}
exports.SIDE_OPTIONS=["top","right","bottom","left"];function t(t,e,r){const o=t["x"===r?"left":"top"],n="x"===r?"width":"height",i=t[n],p=e[n];return{before:o-p,start:o,center:o+(i-p)/2,end:o+i-p,after:o+i}}function e(t){return{position:"absolute",top:0,left:0,minWidth:"max-content",willChange:"transform",transform:`translate3d(${Math.round(t.x+window.scrollX)}px, ${Math.round(t.y+window.scrollY)}px, 0)`}}function r(t,e,r,o,n){const i="top"===e||"bottom"===e,p=n?n.width:0,a=n?n.height:0,s=p/2+o;let c="",f="";return i?(c={start:`${s}px`,center:"center",end:t.width-s+"px"}[r],f="top"===e?`${t.height+a}px`:-a+"px"):(c="left"===e?`${t.width+a}px`:-a+"px",f={start:`${s}px`,center:"center",end:t.height-s+"px"}[r]),`${c} ${f}`}exports.ALIGN_OPTIONS=["start","center","end"],exports.getPlacementData=function({anchorRect:p,popperSize:c,arrowSize:f,arrowOffset:l=0,side:d,sideOffset:h=0,align:x,alignOffset:g=0,shouldAvoidCollisions:u=!0,collisionBoundariesRect:w,collisionTolerance:m=0}){if(!p||!c||!w)return{popperStyles:o,arrowStyles:n};const y=function(e,r,o=0,n=0,i){const p=i?i.height:0,a=t(r,e,"x"),s=t(r,e,"y"),c=s.before-o-p,f=s.after+o+p,l=a.before-o-p,d=a.after+o+p;return{top:{start:{x:a.start+n,y:c},center:{x:a.center,y:c},end:{x:a.end-n,y:c}},right:{start:{x:d,y:s.start+n},center:{x:d,y:s.center},end:{x:d,y:s.end-n}},bottom:{start:{x:a.start+n,y:f},center:{x:a.center,y:f},end:{x:a.end-n,y:f}},left:{start:{x:l,y:s.start+n},center:{x:l,y:s.center},end:{x:l,y:s.end-n}}}}(c,p,h,g,f),b=y[d][x];if(!1===u){const t=e(b);let o=n;f&&(o=i({popperSize:c,arrowSize:f,arrowOffset:l,side:d,align:x}));return{popperStyles:{...t,"--radix-popper-transform-origin":r(c,d,x,l,f)},arrowStyles:o,placedSide:d,placedAlign:x}}const S=DOMRect.fromRect({...c,...b}),$=(O=w,z=m,DOMRect.fromRect({width:O.width-2*z,height:O.height-2*z,x:O.left+z,y:O.top+z}));var O,z;const R=s(S,$),M=y[a(d)][x],D=function(t,e,r){const o=a(t);return e[t]&&!r[o]?o:t}(d,R,s(DOMRect.fromRect({...c,...M}),$)),A=function(t,e,r,o,n){const i="top"===r||"bottom"===r,p=i?"left":"top",a=i?"right":"bottom",s=i?"width":"height",c=e[s]>t[s];if(("start"===o||"center"===o)&&(n[p]&&c||n[a]&&!c))return"end";if(("end"===o||"center"===o)&&(n[a]&&c||n[p]&&!c))return"start";return o}(c,p,d,x,R),I=e(y[D][A]);let C=n;return f&&(C=i({popperSize:c,arrowSize:f,arrowOffset:l,side:D,align:A})),{popperStyles:{...I,"--radix-popper-transform-origin":r(c,D,A,l,f)},arrowStyles:C,placedSide:D,placedAlign:A}};const o={position:"fixed",top:0,left:0,opacity:0,transform:"translate3d(0, -200%, 0)"},n={position:"absolute",opacity:0};function i({popperSize:t,arrowSize:e,arrowOffset:r,side:o,align:n}){const i=(t.width-e.width)/2,a=(t.height-e.width)/2,s={top:0,right:90,bottom:180,left:-90}[o],c=Math.max(e.width,e.height),f={width:`${c}px`,height:`${c}px`,transform:`rotate(${s}deg)`,willChange:"transform",position:"absolute",[o]:"100%",direction:p(o,n)};return"top"!==o&&"bottom"!==o||("start"===n&&(f.left=`${r}px`),"center"===n&&(f.left=`${i}px`),"end"===n&&(f.right=`${r}px`)),"left"!==o&&"right"!==o||("start"===n&&(f.top=`${r}px`),"center"===n&&(f.top=`${a}px`),"end"===n&&(f.bottom=`${r}px`)),f}function p(t,e){return("top"!==t&&"right"!==t||"end"!==e)&&("bottom"!==t&&"left"!==t||"end"===e)?"ltr":"rtl"}function a(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]}function s(t,e){return{top:t.top<e.top,right:t.right>e.right,bottom:t.bottom>e.bottom,left:t.left<e.left}}
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{makeRect as t,getOppositeSide as e,getCollisions as r}from"@interop-ui/utils";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}export function getPlacementData({anchorRect:n,popperSize:c,arrowSize:d,arrowOffset:u=0,side:h,sideOffset:x=0,align:g,alignOffset:w=0,shouldAvoidCollisions:y=!0,collisionTolerance:b=0}){if(!n||!c)return{popperStyles:s,arrowStyles:f};const O=function(t,e,r=0,n=0,o){const c=o?o.height:0,a=i(e,t,"x"),p=i(e,t,"y"),s=p.before-r-c,f=p.after+r+c,l=a.before-r-c,d=a.after+r+c;return{top:{start:{x:a.start+n,y:s},center:{x:a.center,y:s},end:{x:a.end-n,y:s}},right:{start:{x:d,y:p.start+n},center:{x:d,y:p.center},end:{x:d,y:p.end-n}},bottom:{start:{x:a.start+n,y:f},center:{x:a.center,y:f},end:{x:a.end-n,y:f}},left:{start:{x:l,y:p.start+n},center:{x:l,y:p.center},end:{x:l,y:p.end-n}}}}(c,n,x,w,d),m=O[h][g];if(!1===y){const t=a(m);let e=f;d&&(e=l({popperSize:c,arrowSize:d,arrowOffset:u,side:h,align:g}));const r=p(c,h,g,u,d);return{popperStyles:o(o({},t),{},{"--radix-popper-transform-origin":r}),arrowStyles:e,placedSide:h,placedAlign:g}}const S=t(c,m),j=r(S,b),P=O[e(h)][g],z=t(c,P),v=function(t,r,n){const o=e(t);return r[t]&&!n[o]?o:t}(h,j,r(z,b)),D=function(t,e,r,n,o){const c="top"===r||"bottom"===r,i=c?"left":"top",a=c?"right":"bottom",p=c?"width":"height",s=e[p]>t[p];if(("start"===n||"center"===n)&&(o[i]&&s||o[a]&&!s))return"end";if(("end"===n||"center"===n)&&(o[a]&&s||o[i]&&!s))return"start";return n}(c,n,h,g,j),A=a(O[v][D]);let C=f;d&&(C=l({popperSize:c,arrowSize:d,arrowOffset:u,side:v,align:D}));const E=p(c,v,D,u,d);return{popperStyles:o(o({},A),{},{"--radix-popper-transform-origin":E}),arrowStyles:C,placedSide:v,placedAlign:D}}function i(t,e,r){const n=t["x"===r?"left":"top"],o="x"===r?"width":"height",c=t[o],i=e[o];return{before:n-i,start:n,center:n+(c-i)/2,end:n+c-i,after:n+c}}function a(t){const e=Math.round(t.x+window.scrollX),r=Math.round(t.y+window.scrollY);return{position:"absolute",top:0,left:0,willChange:"transform",transform:"translate3d(".concat(e,"px, ").concat(r,"px, 0)")}}function p(t,e,r,n,o){const c="top"===e||"bottom"===e,i=o?o.width:0,a=o?o.height:0,p=i/2+n;let s="",f="";return c?(s={start:"".concat(p,"px"),center:"center",end:"".concat(t.width-p,"px")}[r],f="".concat("top"===e?t.height+a:-a,"px")):(s="".concat("left"===e?t.width+a:-a,"px"),f={start:"".concat(p,"px"),center:"center",end:"".concat(t.height-p,"px")}[r]),"".concat(s," ").concat(f)}const s={position:"fixed",top:0,left:0,opacity:0,pointerEvents:"none"},f={position:"absolute",opacity:0};function l({popperSize:t,arrowSize:e,arrowOffset:r,side:n,align:o}){const c=(t.width-e.width)/2,i=(t.height-e.width)/2,a={top:0,right:90,bottom:180,left:-90}[n],p=Math.max(e.width,e.height),s={width:"".concat(p,"px"),height:"".concat(p,"px"),transform:"rotate(".concat(a,"deg)"),willChange:"transform",position:"absolute",[n]:"100%",direction:d(n,o)};return"top"!==n&&"bottom"!==n||("start"===o&&(s.left="".concat(r,"px")),"center"===o&&(s.left="".concat(c,"px")),"end"===o&&(s.right="".concat(r,"px"))),"left"!==n&&"right"!==n||("start"===o&&(s.top="".concat(r,"px")),"center"===o&&(s.top="".concat(i,"px")),"end"===o&&(s.bottom="".concat(r,"px"))),s}function d(t,e){return("top"!==t&&"right"!==t||"end"!==e)&&("bottom"!==t&&"left"!==t||"end"===e)?"ltr":"rtl"}
export const SIDE_OPTIONS=["top","right","bottom","left"];export const ALIGN_OPTIONS=["start","center","end"];export function getPlacementData({anchorRect:p,popperSize:c,arrowSize:f,arrowOffset:l=0,side:d,sideOffset:h=0,align:x,alignOffset:g=0,shouldAvoidCollisions:u=!0,collisionBoundariesRect:w,collisionTolerance:m=0}){if(!p||!c||!w)return{popperStyles:o,arrowStyles:n};const y=function(e,r,o=0,n=0,i){const p=i?i.height:0,a=t(r,e,"x"),s=t(r,e,"y"),c=s.before-o-p,f=s.after+o+p,l=a.before-o-p,d=a.after+o+p;return{top:{start:{x:a.start+n,y:c},center:{x:a.center,y:c},end:{x:a.end-n,y:c}},right:{start:{x:d,y:s.start+n},center:{x:d,y:s.center},end:{x:d,y:s.end-n}},bottom:{start:{x:a.start+n,y:f},center:{x:a.center,y:f},end:{x:a.end-n,y:f}},left:{start:{x:l,y:s.start+n},center:{x:l,y:s.center},end:{x:l,y:s.end-n}}}}(c,p,h,g,f),b=y[d][x];if(!1===u){const t=e(b);let o=n;f&&(o=i({popperSize:c,arrowSize:f,arrowOffset:l,side:d,align:x}));return{popperStyles:{...t,"--radix-popper-transform-origin":r(c,d,x,l,f)},arrowStyles:o,placedSide:d,placedAlign:x}}const S=DOMRect.fromRect({...c,...b}),$=(O=w,z=m,DOMRect.fromRect({width:O.width-2*z,height:O.height-2*z,x:O.left+z,y:O.top+z}));var O,z;const R=s(S,$),M=y[a(d)][x],D=function(t,e,r){const o=a(t);return e[t]&&!r[o]?o:t}(d,R,s(DOMRect.fromRect({...c,...M}),$)),A=function(t,e,r,o,n){const i="top"===r||"bottom"===r,p=i?"left":"top",a=i?"right":"bottom",s=i?"width":"height",c=e[s]>t[s];if(("start"===o||"center"===o)&&(n[p]&&c||n[a]&&!c))return"end";if(("end"===o||"center"===o)&&(n[a]&&c||n[p]&&!c))return"start";return o}(c,p,d,x,R),I=e(y[D][A]);let C=n;f&&(C=i({popperSize:c,arrowSize:f,arrowOffset:l,side:D,align:A}));return{popperStyles:{...I,"--radix-popper-transform-origin":r(c,D,A,l,f)},arrowStyles:C,placedSide:D,placedAlign:A}}function t(t,e,r){const o=t["x"===r?"left":"top"],n="x"===r?"width":"height",i=t[n],p=e[n];return{before:o-p,start:o,center:o+(i-p)/2,end:o+i-p,after:o+i}}function e(t){return{position:"absolute",top:0,left:0,minWidth:"max-content",willChange:"transform",transform:`translate3d(${Math.round(t.x+window.scrollX)}px, ${Math.round(t.y+window.scrollY)}px, 0)`}}function r(t,e,r,o,n){const i="top"===e||"bottom"===e,p=n?n.width:0,a=n?n.height:0,s=p/2+o;let c="",f="";return i?(c={start:`${s}px`,center:"center",end:t.width-s+"px"}[r],f="top"===e?`${t.height+a}px`:-a+"px"):(c="left"===e?`${t.width+a}px`:-a+"px",f={start:`${s}px`,center:"center",end:t.height-s+"px"}[r]),`${c} ${f}`}const o={position:"fixed",top:0,left:0,opacity:0,transform:"translate3d(0, -200%, 0)"},n={position:"absolute",opacity:0};function i({popperSize:t,arrowSize:e,arrowOffset:r,side:o,align:n}){const i=(t.width-e.width)/2,a=(t.height-e.width)/2,s={top:0,right:90,bottom:180,left:-90}[o],c=Math.max(e.width,e.height),f={width:`${c}px`,height:`${c}px`,transform:`rotate(${s}deg)`,willChange:"transform",position:"absolute",[o]:"100%",direction:p(o,n)};return"top"!==o&&"bottom"!==o||("start"===n&&(f.left=`${r}px`),"center"===n&&(f.left=`${i}px`),"end"===n&&(f.right=`${r}px`)),"left"!==o&&"right"!==o||("start"===n&&(f.top=`${r}px`),"center"===n&&(f.top=`${a}px`),"end"===n&&(f.bottom=`${r}px`)),f}function p(t,e){return("top"!==t&&"right"!==t||"end"!==e)&&("bottom"!==t&&"left"!==t||"end"===e)?"ltr":"rtl"}function a(t){return{top:"bottom",right:"left",bottom:"top",left:"right"}[t]}function s(t,e){return{top:t.top<e.top,right:t.right>e.right,bottom:t.bottom>e.bottom,left:t.left<e.left}}
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/popper",
"version": "0.0.1-15",
"version": "0.2.0-rc.1",
"license": "MIT",

@@ -15,14 +15,18 @@ "source": "src/index.ts",

"scripts": {
"build": "parcel build src/index.ts --no-cache",
"clean": "rm -rf dist",
"version": "yarn version",
"prepublish": "yarn clean && yarn build"
"version": "yarn version"
},
"dependencies": {
"@interop-ui/utils": "0.0.1-8",
"@babel/runtime": "^7.13.10",
"csstype": "^3.0.4"
},
"devDependencies": {
"parcel": "^2.0.0-beta.1"
}
"homepage": "https://radix-ui.com/primitives",
"repository": {
"type": "git",
"url": "git+https://github.com/radix-ui/primitives.git"
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
},
"stableVersion": "0.1.0"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc