Initial commit

This commit is contained in:
Marek Lesko
2025-08-19 16:58:51 +02:00
commit a2f7e2285a
908 changed files with 160315 additions and 0 deletions

View File

@@ -0,0 +1 @@
import getOppositePlacement from"../utils/getOppositePlacement.js";import getBasePlacement from"../utils/getBasePlacement.js";import getOppositeVariationPlacement from"../utils/getOppositeVariationPlacement.js";import detectOverflow from"../utils/detectOverflow.js";import computeAutoPlacement from"../utils/computeAutoPlacement.js";import{bottom,top,start,right,left,auto}from"../enums.js";import getVariation from"../utils/getVariation.js";function getExpandedFallbackPlacements(e){if(getBasePlacement(e)===auto)return[];var t=getOppositePlacement(e);return[getOppositeVariationPlacement(e),t,getOppositeVariationPlacement(t)]}function flip(e){var a=e.state,t=e.options,e=e.name;if(!a.modifiersData[e]._skip){for(var o=t.mainAxis,i=void 0===o||o,o=t.altAxis,n=void 0===o||o,o=t.fallbackPlacements,r=t.padding,l=t.boundary,p=t.rootBoundary,s=t.altBoundary,m=t.flipVariations,c=void 0===m||m,u=t.allowedAutoPlacements,m=a.options.placement,t=getBasePlacement(m),o=o||(t===m||!c?[getOppositePlacement(m)]:getExpandedFallbackPlacements(m)),f=[m].concat(o).reduce(function(e,t){return e.concat(getBasePlacement(t)===auto?computeAutoPlacement(a,{placement:t,boundary:l,rootBoundary:p,padding:r,flipVariations:c,allowedAutoPlacements:u}):t)},[]),d=a.rects.reference,g=a.rects.popper,P=new Map,b=!0,v=f[0],O=0;O<f.length;O++){var B=f[O],k=getBasePlacement(B),y=getVariation(B)===start,h=0<=[top,bottom].indexOf(k),V=h?"width":"height",j=detectOverflow(a,{placement:B,boundary:l,rootBoundary:p,altBoundary:s,padding:r}),h=h?y?right:left:y?bottom:top,y=(d[V]>g[V]&&(h=getOppositePlacement(h)),getOppositePlacement(h)),V=[];if(i&&V.push(j[k]<=0),n&&V.push(j[h]<=0,j[y]<=0),V.every(function(e){return e})){v=B,b=!1;break}P.set(B,V)}if(b)for(var w=c?3:1;0<w;w--)if("break"===function(t){var e=f.find(function(e){e=P.get(e);if(e)return e.slice(0,t).every(function(e){return e})});if(e)return v=e,"break"}(w))break;a.placement!==v&&(a.modifiersData[e]._skip=!0,a.placement=v,a.reset=!0)}}export default{name:"flip",enabled:!0,phase:"main",fn:flip,requiresIfExists:["offset"],data:{_skip:!1}};