Socket
Socket
Sign inDemoInstall

@floating-ui/core

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/core - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

84

dist/floating-ui.core.js

@@ -164,6 +164,6 @@ (function (global, factory) {

});
x = nextX ?? x;
y = nextY ?? y;
x = nextX != null ? nextX : x;
y = nextY != null ? nextY : y;
middlewareData = { ...middlewareData,
[name]: data ?? {}
[name]: data != null ? data : {}
};

@@ -223,4 +223,7 @@

async function detectOverflow(middlewareArguments) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
async function detectOverflow(middlewareArguments, options) {
if (options === void 0) {
options = {};
}
const {

@@ -303,3 +306,3 @@ x,

padding = 0
} = options ?? {};
} = options != null ? options : {};
const {

@@ -394,3 +397,3 @@ x,

const basePlacements = ['top', 'right', 'bottom', 'left'];
const allPlacements = basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, `${basePlacement}-start`, `${basePlacement}-end`), []);
const allPlacements = basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);

@@ -406,4 +409,7 @@ function getPlacementList(alignment, autoAlignment, allowedPlacements) {

}
const autoPlacement = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const autoPlacement = function (options) {
if (options === void 0) {
options = {};
}
return {

@@ -413,3 +419,3 @@ name: 'autoPlacement',

async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _placementsSortedByLe;
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;

@@ -431,3 +437,3 @@ const {

if ((_middlewareData$autoP = middlewareData.autoPlacement) !== null && _middlewareData$autoP !== void 0 && _middlewareData$autoP.skip) {
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};

@@ -438,3 +444,3 @@ }

const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = ((_middlewareData$autoP2 = middlewareData.autoPlacement) === null || _middlewareData$autoP2 === void 0 ? void 0 : _middlewareData$autoP2.index) ?? 0;
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentPlacement = placements[currentIndex];

@@ -457,3 +463,3 @@ const {

const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main], overflow[cross]];
const allOverflows = [...(((_middlewareData$autoP3 = middlewareData.autoPlacement) === null || _middlewareData$autoP3 === void 0 ? void 0 : _middlewareData$autoP3.overflows) ?? []), {
const allOverflows = [...((_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : []), {
placement: currentPlacement,

@@ -482,3 +488,3 @@ overflows: currentOverflows

return overflows.every(overflow => overflow <= 0);
})) === null || _placementsSortedByLe === void 0 ? void 0 : _placementsSortedByLe.placement;
})) == null ? void 0 : _placementsSortedByLe.placement;
return {

@@ -489,3 +495,3 @@ data: {

reset: {
placement: placementThatFitsOnAllSides ?? placementsSortedByLeastOverflow[0].placement
placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement
}

@@ -503,4 +509,7 @@ };

const flip = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const flip = function (options) {
if (options === void 0) {
options = {};
}
return {

@@ -519,3 +528,3 @@ name: 'flip',

if ((_middlewareData$flip = middlewareData.flip) !== null && _middlewareData$flip !== void 0 && _middlewareData$flip.skip) {
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};

@@ -538,3 +547,3 @@ }

const overflows = [];
let overflowsData = ((_middlewareData$flip2 = middlewareData.flip) === null || _middlewareData$flip2 === void 0 ? void 0 : _middlewareData$flip2.overflows) || [];
let overflowsData = ((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.overflows) || [];

@@ -559,5 +568,5 @@ if (checkMainAxis) {

if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip3;
var _middlewareData$flip$, _middlewareData$flip3;
const nextIndex = (((_middlewareData$flip3 = middlewareData.flip) === null || _middlewareData$flip3 === void 0 ? void 0 : _middlewareData$flip3.index) ?? 0) + 1;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements[nextIndex];

@@ -585,3 +594,3 @@

const placement = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0) - b.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0))[0]) === null || _overflowsData$slice$ === void 0 ? void 0 : _overflowsData$slice$.placement;
const placement = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0) - b.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;

@@ -713,4 +722,7 @@ if (placement) {

const shift = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const shift = function (options) {
if (options === void 0) {
options = {};
}
return {

@@ -774,4 +786,7 @@ name: 'shift',

};
const limitShift = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const limitShift = function (options) {
if (options === void 0) {
options = {};
}
return async middlewareArguments => {

@@ -827,7 +842,7 @@ const {

if (checkCrossAxis) {
var _middlewareData$offse, _middlewareData$offse2;
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
const len = mainAxis === 'y' ? 'width' : 'height';
const limitMin = rects.reference[crossAxis] - rects.floating[len] - (((_middlewareData$offse = middlewareData.offset) === null || _middlewareData$offse === void 0 ? void 0 : _middlewareData$offse[mainAxis]) ?? 0) + computedOffset.crossAxis;
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (((_middlewareData$offse2 = middlewareData.offset) === null || _middlewareData$offse2 === void 0 ? void 0 : _middlewareData$offse2[mainAxis]) ?? 0) + computedOffset.crossAxis;
const limitMin = rects.reference[crossAxis] - rects.floating[len] - ((_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[mainAxis]) != null ? _middlewareData$offse : 0) + computedOffset.crossAxis;
const limitMax = rects.reference[crossAxis] + rects.reference[len] + ((_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[mainAxis]) != null ? _middlewareData$offse3 : 0) + computedOffset.crossAxis;

@@ -848,4 +863,7 @@ if (crossAxisCoord < limitMin) {

const size = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const size = function (options) {
if (options === void 0) {
options = {};
}
return {

@@ -885,7 +903,7 @@ name: 'size',

if ((_middlewareData$size = middlewareData.size) !== null && _middlewareData$size !== void 0 && _middlewareData$size.skip) {
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
apply === null || apply === void 0 ? void 0 : apply(dimensions);
apply == null ? void 0 : apply(dimensions);
return {

@@ -892,0 +910,0 @@ data: {

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUICore={})}(this,(function(e){"use strict";function t(e){return e.split("-")[0]}function n(e){return e.split("-")[1]}function o(e){return["top","bottom"].includes(t(e))?"x":"y"}function i(e){return"y"===e?"height":"width"}function r(e){let{reference:r,floating:a,placement:l}=e;const s=r.x+r.width/2-a.width/2,c=r.y+r.height/2-a.height/2;let f;switch(t(l)){case"top":f={x:s,y:r.y-a.height};break;case"bottom":f={x:s,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:c};break;case"left":f={x:r.x-a.width,y:c};break;default:f={x:r.x,y:r.y}}const m=o(l),u=i(m);switch(n(l)){case"start":f[m]=f[m]-(r[u]/2-a[u]/2);break;case"end":f[m]=f[m]+(r[u]/2-a[u]/2)}return f}function a(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function l(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{x:n,y:o,platform:i,rects:r,elements:s,strategy:c}=e,{boundary:f="clippingParents",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:d=!1,padding:p=0}=t,g=a(p),y="floating"===u?"reference":"floating",h=s[d?y:u],x=await i.getClippingClientRect({element:await i.isElement(h)?h:h.contextElement||await i.getDocumentElement({element:s.floating}),boundary:f,rootBoundary:m}),w=l(await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===u?{...r.floating,x:n,y:o}:r.reference,offsetParent:await i.getOffsetParent({element:s.floating}),strategy:c}));return{top:x.top-w.top+g.top,bottom:w.bottom-x.bottom+g.bottom,left:x.left-w.left+g.left,right:w.right-x.right+g.right}}function c(e,t,n){return Math.max(e,Math.min(t,n))}const f={left:"right",right:"left",bottom:"top",top:"bottom"};function m(e){return e.replace(/left|right|bottom|top/g,(e=>f[e]))}function u(e,t){const r="start"===n(e),a=o(e),l=i(a);let s="x"===a?r?"right":"left":r?"bottom":"top";return t.reference[l]>t.floating[l]&&(s=m(s)),{main:s,cross:m(s)}}const d={start:"end",end:"start"};function p(e){return e.replace(/start|end/g,(e=>d[e]))}const g=["top","right","bottom","left"],y=g.reduce(((e,t)=>e.concat(t,`${t}-start`,`${t}-end`)),[]);function h(e,o,i){return i.filter((i=>e?n(i)===e||!!o&&p(i)!==i:t(i)===i))}function x(e){const t=m(e);return[p(e),t,p(t)]}function w(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function v(e){return g.some((t=>e[t]>=0))}function b(e){return"x"===e?"y":"x"}e.arrow=e=>({name:"arrow",async fn(n){const{element:r,padding:l=0}=e??{},{x:s,y:f,placement:m,rects:u,platform:d}=n;if(null==r)return{};const p=a(l),g={x:s,y:f},y=o(t(m)),h=i(y),x=await d.getDimensions({element:r}),w="y"===y?"top":"left",v="y"===y?"bottom":"right",b=u.reference[h]+u.reference[y]-g[y]-u.floating[h],A=g[y]-u.reference[y],P=await d.getOffsetParent({element:r}),k=P?"y"===y?P.clientHeight||0:P.clientWidth||0:0,D=b/2-A/2,O=p[w],R=k-x[h]-p[v],C=k/2-x[h]/2+D,E=c(O,C,R);return{data:{[y]:E,centerOffset:C-E}}}}),e.autoPlacement=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{name:"autoPlacement",async fn(o){var i,r,a,l;const{x:c,y:f,rects:m,middlewareData:d,placement:p}=o,{alignment:g=null,crossAxis:x=!1,allowedPlacements:w=y,autoAlignment:v=!0,...b}=e;if(null!==(i=d.autoPlacement)&&void 0!==i&&i.skip)return{};const A=h(g,v,w),P=await s(o,b),k=(null===(r=d.autoPlacement)||void 0===r?void 0:r.index)??0,D=A[k],{main:O,cross:R}=u(D,m);if(p!==D)return{x:c,y:f,reset:{placement:A[0]}};const C=[P[t(D)],P[O],P[R]],E=[...(null===(a=d.autoPlacement)||void 0===a?void 0:a.overflows)??[],{placement:D,overflows:C}],B=A[k+1];if(B)return{data:{index:k+1,overflows:E},reset:{placement:B}};const T=E.slice().sort(x||v&&n(p)?(e,t)=>e.overflows.reduce(((e,t)=>e+t),0)-t.overflows.reduce(((e,t)=>e+t),0):(e,t)=>e.overflows[0]-t.overflows[0]),j=null===(l=T.find((e=>{let{overflows:t}=e;return t.every((e=>e<=0))})))||void 0===l?void 0:l.placement;return{data:{skip:!0},reset:{placement:j??T[0].placement}}}}},e.computePosition=async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:a=[],platform:l}=n;let s=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:f}=r({...s,placement:o}),m=o,u={};for(let n=0;n<a.length;n++){0===n&&({x:c,y:f}=r({...s,placement:m}));const{name:d,fn:p}=a[n],{x:g,y:y,data:h,reset:x}=await p({x:c,y:f,initialPlacement:o,placement:m,strategy:i,middlewareData:u,rects:s,platform:l,elements:{reference:e,floating:t}});c=g??c,f=y??f,u={...u,[d]:h??{}},x&&("object"==typeof x&&x.placement&&(m=x.placement),s=await l.getElementRects({reference:e,floating:t,strategy:i}),n=-1)}return{x:c,y:f,placement:m,strategy:i,middlewareData:u}},e.detectOverflow=s,e.flip=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{name:"flip",async fn(n){var o,i;const{placement:r,middlewareData:a,rects:l,initialPlacement:c}=n;if(null!==(o=a.flip)&&void 0!==o&&o.skip)return{};const{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",flipAlignment:y=!0,...h}=e,w=t(r),v=[c,...p||(w===c||!y?[m(c)]:x(c))],b=await s(n,h),A=[];let P=(null===(i=a.flip)||void 0===i?void 0:i.overflows)||[];if(f&&A.push(b[w]),d){const{main:e,cross:t}=u(r,l);A.push(b[e],b[t])}if(P=[...P,{placement:r,overflows:A}],!A.every((e=>e<=0))){var k;const e=((null===(k=a.flip)||void 0===k?void 0:k.index)??0)+1,t=v[e];if(t)return{data:{index:e,overflows:P},reset:{placement:t}};let n="bottom";switch(g){case"bestFit":{var D;const e=null===(D=P.slice().sort(((e,t)=>e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)-t.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)))[0])||void 0===D?void 0:D.placement;e&&(n=e);break}case"initialPlacement":n=c}return{data:{skip:!0},reset:{placement:n}}}return{}}}},e.hide=()=>({name:"hide",async fn(e){const t=await s(e,{elementContext:"reference"}),n=await s(e,{altBoundary:!0}),o=w(t,e.rects.reference),i=w(n,e.rects.floating);return{data:{referenceHidden:v(o),referenceHiddenOffsets:o,escaped:v(i),escapedOffsets:i}}}}),e.limitShift=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return async n=>{const{x:i,y:r,placement:a,rects:l,middlewareData:s}=n,{offset:c=0,mainAxis:f=!0,crossAxis:m=!0}=e,u={x:i,y:r},d=o(t(a)),p=b(d);let g=u[d],y=u[p];const h="function"==typeof c?c({...l,placement:a}):{mainAxis:c,crossAxis:0},x="number"==typeof h?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(f){const e="y"===d?"height":"width",t=l.reference[d]-l.floating[e]+x.mainAxis,n=l.reference[d]+l.reference[e]-x.mainAxis;g<t?g=t:g>n&&(g=n)}if(m){var w,v;const e="y"===d?"width":"height",t=l.reference[p]-l.floating[e]-((null===(w=s.offset)||void 0===w?void 0:w[d])??0)+x.crossAxis,n=l.reference[p]+l.reference[e]+((null===(v=s.offset)||void 0===v?void 0:v[d])??0)+x.crossAxis;y<t?y=t:y>n&&(y=n)}return{[d]:g,[p]:y}}},e.offset=e=>({name:"offset",fn(n){const{x:i,y:r,placement:a,rects:l}=n,s=function(e){let{placement:n,rects:i,value:r}=e;const a=t(n),l=["left","top"].includes(a)?-1:1,s="function"==typeof r?r({...i,placement:n}):r,{mainAxis:c,crossAxis:f}="number"==typeof s?{mainAxis:s,crossAxis:0}:{mainAxis:0,crossAxis:0,...s};return"x"===o(a)?{x:f,y:c*l}:{x:c*l,y:f}}({placement:a,rects:l,value:e});return{x:i+s.x,y:r+s.y,data:s}}}),e.rectToClientRect=l,e.shift=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{name:"shift",async fn(n){const{x:i,y:r,placement:a}=n,{mainAxis:l=!0,crossAxis:f=!1,limiter:m=(e=>{let{x:t,y:n}=e;return{x:t,y:n}}),...u}=e,d={x:i,y:r},p=await s(n,u),g=o(t(a)),y=b(g);let h=d[g],x=d[y];if(l){const e="y"===g?"bottom":"right";h=c(h+p["y"===g?"top":"left"],h,h-p[e])}if(f){const e="y"===y?"bottom":"right";x=c(x+p["y"===y?"top":"left"],x,x-p[e])}return m({...n,[g]:h,[y]:x})}}},e.size=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{name:"size",async fn(o){var i;const{placement:r,rects:a,middlewareData:l}=o,{apply:c,...f}=e,m=await s(o,f),u=t(r),d="end"===n(r);let p,g;"top"===u||"bottom"===u?(p=u,g=d?"left":"right"):(g=u,p=d?"top":"bottom");const y={height:a.floating.height-m[p],width:a.floating.width-m[g]};return null!==(i=l.size)&&void 0!==i&&i.skip?{}:(null==c||c(y),{data:{skip:!0},reset:!0})}}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUICore={})}(this,(function(e){"use strict";function t(e){return e.split("-")[0]}function n(e){return e.split("-")[1]}function r(e){return["top","bottom"].includes(t(e))?"x":"y"}function o(e){return"y"===e?"height":"width"}function i(e){let{reference:i,floating:a,placement:l}=e;const s=i.x+i.width/2-a.width/2,c=i.y+i.height/2-a.height/2;let f;switch(t(l)){case"top":f={x:s,y:i.y-a.height};break;case"bottom":f={x:s,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:c};break;case"left":f={x:i.x-a.width,y:c};break;default:f={x:i.x,y:i.y}}const u=r(l),m=o(u);switch(n(l)){case"start":f[u]=f[u]-(i[m]/2-a[m]/2);break;case"end":f[u]=f[u]+(i[m]/2-a[m]/2)}return f}function a(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function l(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function s(e,t){void 0===t&&(t={});const{x:n,y:r,platform:o,rects:i,elements:s,strategy:c}=e,{boundary:f="clippingParents",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:p=0}=t,y=a(p),g=s[d?"floating"===m?"reference":"floating":m],h=await o.getClippingClientRect({element:await o.isElement(g)?g:g.contextElement||await o.getDocumentElement({element:s.floating}),boundary:f,rootBoundary:u}),x=l(await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:"floating"===m?{...i.floating,x:n,y:r}:i.reference,offsetParent:await o.getOffsetParent({element:s.floating}),strategy:c}));return{top:h.top-x.top+y.top,bottom:x.bottom-h.bottom+y.bottom,left:h.left-x.left+y.left,right:x.right-h.right+y.right}}function c(e,t,n){return Math.max(e,Math.min(t,n))}const f={left:"right",right:"left",bottom:"top",top:"bottom"};function u(e){return e.replace(/left|right|bottom|top/g,(e=>f[e]))}function m(e,t){const i="start"===n(e),a=r(e),l=o(a);let s="x"===a?i?"right":"left":i?"bottom":"top";return t.reference[l]>t.floating[l]&&(s=u(s)),{main:s,cross:u(s)}}const d={start:"end",end:"start"};function p(e){return e.replace(/start|end/g,(e=>d[e]))}const y=["top","right","bottom","left"],g=y.reduce(((e,t)=>e.concat(t,t+"-start",t+"-end")),[]);function h(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function x(e){return y.some((t=>e[t]>=0))}function w(e){return"x"===e?"y":"x"}e.arrow=e=>({name:"arrow",async fn(n){const{element:i,padding:l=0}=null!=e?e:{},{x:s,y:f,placement:u,rects:m,platform:d}=n;if(null==i)return{};const p=a(l),y={x:s,y:f},g=r(t(u)),h=o(g),x=await d.getDimensions({element:i}),w="y"===g?"top":"left",b="y"===g?"bottom":"right",v=m.reference[h]+m.reference[g]-y[g]-m.floating[h],A=y[g]-m.reference[g],P=await d.getOffsetParent({element:i}),k=P?"y"===g?P.clientHeight||0:P.clientWidth||0:0,D=v/2-A/2,O=p[w],R=k-x[h]-p[b],C=k/2-x[h]/2+D,E=c(O,C,R);return{data:{[g]:E,centerOffset:C-E}}}}),e.autoPlacement=function(e){return void 0===e&&(e={}),{name:"autoPlacement",async fn(r){var o,i,a,l,c,f;const{x:u,y:d,rects:y,middlewareData:h,placement:x}=r,{alignment:w=null,crossAxis:b=!1,allowedPlacements:v=g,autoAlignment:A=!0,...P}=e;if(null!=(o=h.autoPlacement)&&o.skip)return{};const k=function(e,r,o){return o.filter((o=>e?n(o)===e||!!r&&p(o)!==o:t(o)===o))}(w,A,v),D=await s(r,P),O=null!=(i=null==(a=h.autoPlacement)?void 0:a.index)?i:0,R=k[O],{main:C,cross:E}=m(R,y);if(x!==R)return{x:u,y:d,reset:{placement:k[0]}};const B=[D[t(R)],D[C],D[E]],T=[...null!=(l=null==(c=h.autoPlacement)?void 0:c.overflows)?l:[],{placement:R,overflows:B}],j=k[O+1];if(j)return{data:{index:O+1,overflows:T},reset:{placement:j}};const z=T.slice().sort(b||A&&n(x)?(e,t)=>e.overflows.reduce(((e,t)=>e+t),0)-t.overflows.reduce(((e,t)=>e+t),0):(e,t)=>e.overflows[0]-t.overflows[0]),F=null==(f=z.find((e=>{let{overflows:t}=e;return t.every((e=>e<=0))})))?void 0:f.placement;return{data:{skip:!0},reset:{placement:null!=F?F:z[0].placement}}}}},e.computePosition=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n;let s=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:f}=i({...s,placement:r}),u=r,m={};for(let n=0;n<a.length;n++){0===n&&({x:c,y:f}=i({...s,placement:u}));const{name:d,fn:p}=a[n],{x:y,y:g,data:h,reset:x}=await p({x:c,y:f,initialPlacement:r,placement:u,strategy:o,middlewareData:m,rects:s,platform:l,elements:{reference:e,floating:t}});c=null!=y?y:c,f=null!=g?g:f,m={...m,[d]:null!=h?h:{}},x&&("object"==typeof x&&x.placement&&(u=x.placement),s=await l.getElementRects({reference:e,floating:t,strategy:o}),n=-1)}return{x:c,y:f,placement:u,strategy:o,middlewareData:m}},e.detectOverflow=s,e.flip=function(e){return void 0===e&&(e={}),{name:"flip",async fn(n){var r,o;const{placement:i,middlewareData:a,rects:l,initialPlacement:c}=n;if(null!=(r=a.flip)&&r.skip)return{};const{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:y,fallbackStrategy:g="bestFit",flipAlignment:h=!0,...x}=e,w=t(i),b=y||(w===c||!h?[u(c)]:function(e){const t=u(e);return[p(e),t,p(t)]}(c)),v=[c,...b],A=await s(n,x),P=[];let k=(null==(o=a.flip)?void 0:o.overflows)||[];if(f&&P.push(A[w]),d){const{main:e,cross:t}=m(i,l);P.push(A[e],A[t])}if(k=[...k,{placement:i,overflows:P}],!P.every((e=>e<=0))){var D,O;const e=(null!=(D=null==(O=a.flip)?void 0:O.index)?D:0)+1,t=v[e];if(t)return{data:{index:e,overflows:k},reset:{placement:t}};let n="bottom";switch(g){case"bestFit":{var R;const e=null==(R=k.slice().sort(((e,t)=>e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)-t.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)))[0])?void 0:R.placement;e&&(n=e);break}case"initialPlacement":n=c}return{data:{skip:!0},reset:{placement:n}}}return{}}}},e.hide=()=>({name:"hide",async fn(e){const t=await s(e,{elementContext:"reference"}),n=await s(e,{altBoundary:!0}),r=h(t,e.rects.reference),o=h(n,e.rects.floating);return{data:{referenceHidden:x(r),referenceHiddenOffsets:r,escaped:x(o),escapedOffsets:o}}}}),e.limitShift=function(e){return void 0===e&&(e={}),async n=>{const{x:o,y:i,placement:a,rects:l,middlewareData:s}=n,{offset:c=0,mainAxis:f=!0,crossAxis:u=!0}=e,m={x:o,y:i},d=r(t(a)),p=w(d);let y=m[d],g=m[p];const h="function"==typeof c?c({...l,placement:a}):{mainAxis:c,crossAxis:0},x="number"==typeof h?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(f){const e="y"===d?"height":"width",t=l.reference[d]-l.floating[e]+x.mainAxis,n=l.reference[d]+l.reference[e]-x.mainAxis;y<t?y=t:y>n&&(y=n)}if(u){var b,v,A,P;const e="y"===d?"width":"height",t=l.reference[p]-l.floating[e]-(null!=(b=null==(v=s.offset)?void 0:v[d])?b:0)+x.crossAxis,n=l.reference[p]+l.reference[e]+(null!=(A=null==(P=s.offset)?void 0:P[d])?A:0)+x.crossAxis;g<t?g=t:g>n&&(g=n)}return{[d]:y,[p]:g}}},e.offset=e=>({name:"offset",fn(n){const{x:o,y:i,placement:a,rects:l}=n,s=function(e){let{placement:n,rects:o,value:i}=e;const a=t(n),l=["left","top"].includes(a)?-1:1,s="function"==typeof i?i({...o,placement:n}):i,{mainAxis:c,crossAxis:f}="number"==typeof s?{mainAxis:s,crossAxis:0}:{mainAxis:0,crossAxis:0,...s};return"x"===r(a)?{x:f,y:c*l}:{x:c*l,y:f}}({placement:a,rects:l,value:e});return{x:o+s.x,y:i+s.y,data:s}}}),e.rectToClientRect=l,e.shift=function(e){return void 0===e&&(e={}),{name:"shift",async fn(n){const{x:o,y:i,placement:a}=n,{mainAxis:l=!0,crossAxis:f=!1,limiter:u=(e=>{let{x:t,y:n}=e;return{x:t,y:n}}),...m}=e,d={x:o,y:i},p=await s(n,m),y=r(t(a)),g=w(y);let h=d[y],x=d[g];if(l){const e="y"===y?"bottom":"right";h=c(h+p["y"===y?"top":"left"],h,h-p[e])}if(f){const e="y"===g?"bottom":"right";x=c(x+p["y"===g?"top":"left"],x,x-p[e])}return u({...n,[y]:h,[g]:x})}}},e.size=function(e){return void 0===e&&(e={}),{name:"size",async fn(r){var o;const{placement:i,rects:a,middlewareData:l}=r,{apply:c,...f}=e,u=await s(r,f),m=t(i),d="end"===n(i);let p,y;"top"===m||"bottom"===m?(p=m,y=d?"left":"right"):(y=m,p=d?"top":"bottom");const g={height:a.floating.height-u[p],width:a.floating.width-u[y]};return null!=(o=l.size)&&o.skip?{}:(null==c||c(g),{data:{skip:!0},reset:!0})}}},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@floating-ui/core",
"version": "0.1.0",
"version": "0.1.1",
"description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",

@@ -14,3 +14,3 @@ "main": "dist/floating-ui.core.js",

],
"browserslist": "> 1%, not dead",
"browserslist": "> 0.5%, not dead, not IE 11",
"scripts": {

@@ -17,0 +17,0 @@ "test": "jest test",

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