@floating-ui/core
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -216,3 +216,3 @@ function getAlignment(placement) { | ||
* Resolves with an object of overflow side offsets that determine how much the | ||
* element is overflowing a given clipping boundary. | ||
* element is overflowing a given clipping boundary on each side. | ||
* - positive = overflowing the boundary by that number of pixels | ||
@@ -223,3 +223,3 @@ * - negative = how many pixels left before it will overflow | ||
*/ | ||
async function detectOverflow(middlewareArguments, options) { | ||
async function detectOverflow(state, options) { | ||
var _await$platform$isEle; | ||
@@ -236,3 +236,3 @@ if (options === void 0) { | ||
strategy | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -289,5 +289,4 @@ boundary = 'clippingAncestors', | ||
/** | ||
* A data provider that provides data to position an inner element of the | ||
* floating element (usually a triangle or caret) so that it is centered to the | ||
* reference element. | ||
* Provides data to position an inner element of the floating element so that it | ||
* appears centered to the reference element. | ||
* @see https://floating-ui.com/docs/arrow | ||
@@ -298,3 +297,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
// Since `element` is required, we don't Partial<> the type. | ||
@@ -311,3 +310,3 @@ const { | ||
platform | ||
} = middlewareArguments; | ||
} = state; | ||
if (element == null) { | ||
@@ -409,3 +408,5 @@ if (process.env.NODE_ENV !== "production") { | ||
/** | ||
* Automatically chooses the `placement` which has the most space available. | ||
* Optimizes the visibility of the floating element by choosing the placement | ||
* that has the most space available automatically, without needing to specify a | ||
* preferred placement. Alternative to `flip`. | ||
* @see https://floating-ui.com/docs/autoPlacement | ||
@@ -420,3 +421,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; | ||
@@ -429,3 +430,3 @@ const { | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -439,3 +440,3 @@ crossAxis = false, | ||
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; | ||
@@ -542,8 +543,5 @@ const currentPlacement = placements[currentIndex]; | ||
/** | ||
* A visibility optimizer that changes the placement of the floating element in | ||
* order to keep it in view. By default, only the opposite placement is tried. | ||
* | ||
* It has the ability to flip to any placement, not just the opposite one. You | ||
* can use a series of “fallback” placements, where each placement is | ||
* progressively tried until the one that fits can be used. | ||
* Optimizes the visibility of the floating element by flipping the `placement` | ||
* in order to keep it in view when the preferred placement(s) will overflow the | ||
* clipping boundary. Alternative to `autoPlacement`. | ||
* @see https://floating-ui.com/docs/flip | ||
@@ -558,3 +556,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
var _middlewareData$flip; | ||
@@ -568,3 +566,3 @@ const { | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -587,3 +585,3 @@ mainAxis: checkMainAxis = true, | ||
const placements = [initialPlacement, ...fallbackPlacements]; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const overflows = []; | ||
@@ -670,5 +668,4 @@ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; | ||
/** | ||
* A data provider that allows you to hide the floating element in applicable | ||
* situations, usually when it’s not within the same clipping context as the | ||
* reference element. | ||
* Provides data to hide the floating element in applicable situations, such as | ||
* when it is not in the same clipping context as the reference element. | ||
* @see https://floating-ui.com/docs/hide | ||
@@ -683,3 +680,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -691,7 +688,7 @@ strategy = 'referenceHidden', | ||
rects | ||
} = middlewareArguments; | ||
} = state; | ||
switch (strategy) { | ||
case 'referenceHidden': | ||
{ | ||
const overflow = await detectOverflow(middlewareArguments, { | ||
const overflow = await detectOverflow(state, { | ||
...detectOverflowOptions, | ||
@@ -710,3 +707,3 @@ elementContext: 'reference' | ||
{ | ||
const overflow = await detectOverflow(middlewareArguments, { | ||
const overflow = await detectOverflow(state, { | ||
...detectOverflowOptions, | ||
@@ -744,3 +741,3 @@ altBoundary: true | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -752,3 +749,3 @@ placement, | ||
strategy | ||
} = middlewareArguments; | ||
} = state; | ||
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a | ||
@@ -841,3 +838,3 @@ // ClientRect's bounds, despite the event listener being triggered. A | ||
async function convertValueToCoords(middlewareArguments, value) { | ||
async function convertValueToCoords(state, value) { | ||
const { | ||
@@ -847,3 +844,3 @@ placement, | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); | ||
@@ -855,3 +852,3 @@ const side = getSide(placement); | ||
const crossAxisMulti = rtl && isVertical ? -1 : 1; | ||
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; | ||
const rawValue = typeof value === 'function' ? value(state) : value; | ||
@@ -886,4 +883,4 @@ // eslint-disable-next-line prefer-const | ||
/** | ||
* A placement modifier that translates the floating element along the specified | ||
* axes. | ||
* Modifies the placement by translating the floating element along the | ||
* specified axes. | ||
* A number (shorthand for `mainAxis` or distance), or an axes configuration | ||
@@ -900,8 +897,8 @@ * object may be passed. | ||
options: value, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
x, | ||
y | ||
} = middlewareArguments; | ||
const diffCoords = await convertValueToCoords(middlewareArguments, value); | ||
} = state; | ||
const diffCoords = await convertValueToCoords(state, value); | ||
return { | ||
@@ -921,4 +918,4 @@ x: x + diffCoords.x, | ||
/** | ||
* A visibility optimizer that shifts the floating element along the specified | ||
* axes in order to keep it in view. | ||
* Optimizes the visibility of the floating element by shifting it in order to | ||
* keep it in view when it will overflow the clipping boundary. | ||
* @see https://floating-ui.com/docs/shift | ||
@@ -933,3 +930,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -939,3 +936,3 @@ x, | ||
placement | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -962,3 +959,3 @@ mainAxis: checkMainAxis = true, | ||
}; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const mainAxis = getMainAxisFromPlacement(getSide(placement)); | ||
@@ -983,3 +980,3 @@ const crossAxis = getCrossAxis(mainAxis); | ||
const limitedCoords = limiter.fn({ | ||
...middlewareArguments, | ||
...state, | ||
[mainAxis]: mainAxisCoord, | ||
@@ -1007,3 +1004,3 @@ [crossAxis]: crossAxisCoord | ||
options, | ||
fn(middlewareArguments) { | ||
fn(state) { | ||
const { | ||
@@ -1015,3 +1012,3 @@ x, | ||
middlewareData | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -1030,3 +1027,3 @@ offset = 0, | ||
let crossAxisCoord = coords[crossAxis]; | ||
const rawOffset = typeof offset === 'function' ? offset(middlewareArguments) : offset; | ||
const rawOffset = typeof offset === 'function' ? offset(state) : offset; | ||
const computedOffset = typeof rawOffset === 'number' ? { | ||
@@ -1071,5 +1068,5 @@ mainAxis: rawOffset, | ||
/** | ||
* Provides data to change the size of the floating element. For instance, | ||
* prevent it from overflowing its clipping boundary or match the width of the | ||
* reference element. | ||
* Provides data that allows you to change the size of the floating element — | ||
* for instance, prevent it from overflowing the clipping boundary or match the | ||
* width of the reference element. | ||
* @see https://floating-ui.com/docs/size | ||
@@ -1084,3 +1081,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -1091,3 +1088,3 @@ placement, | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -1097,3 +1094,3 @@ apply = () => {}, | ||
} = options; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const side = getSide(placement); | ||
@@ -1129,3 +1126,3 @@ const alignment = getAlignment(placement); | ||
} | ||
if (!middlewareArguments.middlewareData.shift && !alignment) { | ||
if (!state.middlewareData.shift && !alignment) { | ||
const xMin = max(overflow.left, 0); | ||
@@ -1142,3 +1139,3 @@ const xMax = max(overflow.right, 0); | ||
await apply({ | ||
...middlewareArguments, | ||
...state, | ||
availableWidth, | ||
@@ -1145,0 +1142,0 @@ availableHeight |
@@ -222,3 +222,3 @@ (function (global, factory) { | ||
* Resolves with an object of overflow side offsets that determine how much the | ||
* element is overflowing a given clipping boundary. | ||
* element is overflowing a given clipping boundary on each side. | ||
* - positive = overflowing the boundary by that number of pixels | ||
@@ -229,3 +229,3 @@ * - negative = how many pixels left before it will overflow | ||
*/ | ||
async function detectOverflow(middlewareArguments, options) { | ||
async function detectOverflow(state, options) { | ||
var _await$platform$isEle; | ||
@@ -242,3 +242,3 @@ if (options === void 0) { | ||
strategy | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -294,5 +294,4 @@ boundary = 'clippingAncestors', | ||
/** | ||
* A data provider that provides data to position an inner element of the | ||
* floating element (usually a triangle or caret) so that it is centered to the | ||
* reference element. | ||
* Provides data to position an inner element of the floating element so that it | ||
* appears centered to the reference element. | ||
* @see https://floating-ui.com/docs/arrow | ||
@@ -303,3 +302,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
// Since `element` is required, we don't Partial<> the type. | ||
@@ -316,3 +315,3 @@ const { | ||
platform | ||
} = middlewareArguments; | ||
} = state; | ||
if (element == null) { | ||
@@ -414,3 +413,5 @@ { | ||
/** | ||
* Automatically chooses the `placement` which has the most space available. | ||
* Optimizes the visibility of the floating element by choosing the placement | ||
* that has the most space available automatically, without needing to specify a | ||
* preferred placement. Alternative to `flip`. | ||
* @see https://floating-ui.com/docs/autoPlacement | ||
@@ -425,3 +426,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; | ||
@@ -434,3 +435,3 @@ const { | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -444,3 +445,3 @@ crossAxis = false, | ||
const placements = alignment !== undefined || allowedPlacements === allPlacements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; | ||
@@ -547,8 +548,5 @@ const currentPlacement = placements[currentIndex]; | ||
/** | ||
* A visibility optimizer that changes the placement of the floating element in | ||
* order to keep it in view. By default, only the opposite placement is tried. | ||
* | ||
* It has the ability to flip to any placement, not just the opposite one. You | ||
* can use a series of “fallback” placements, where each placement is | ||
* progressively tried until the one that fits can be used. | ||
* Optimizes the visibility of the floating element by flipping the `placement` | ||
* in order to keep it in view when the preferred placement(s) will overflow the | ||
* clipping boundary. Alternative to `autoPlacement`. | ||
* @see https://floating-ui.com/docs/flip | ||
@@ -563,3 +561,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
var _middlewareData$flip; | ||
@@ -573,3 +571,3 @@ const { | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -592,3 +590,3 @@ mainAxis: checkMainAxis = true, | ||
const placements = [initialPlacement, ...fallbackPlacements]; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const overflows = []; | ||
@@ -675,5 +673,4 @@ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; | ||
/** | ||
* A data provider that allows you to hide the floating element in applicable | ||
* situations, usually when it’s not within the same clipping context as the | ||
* reference element. | ||
* Provides data to hide the floating element in applicable situations, such as | ||
* when it is not in the same clipping context as the reference element. | ||
* @see https://floating-ui.com/docs/hide | ||
@@ -688,3 +685,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -696,7 +693,7 @@ strategy = 'referenceHidden', | ||
rects | ||
} = middlewareArguments; | ||
} = state; | ||
switch (strategy) { | ||
case 'referenceHidden': | ||
{ | ||
const overflow = await detectOverflow(middlewareArguments, { | ||
const overflow = await detectOverflow(state, { | ||
...detectOverflowOptions, | ||
@@ -715,3 +712,3 @@ elementContext: 'reference' | ||
{ | ||
const overflow = await detectOverflow(middlewareArguments, { | ||
const overflow = await detectOverflow(state, { | ||
...detectOverflowOptions, | ||
@@ -749,3 +746,3 @@ altBoundary: true | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -757,3 +754,3 @@ placement, | ||
strategy | ||
} = middlewareArguments; | ||
} = state; | ||
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a | ||
@@ -846,3 +843,3 @@ // ClientRect's bounds, despite the event listener being triggered. A | ||
async function convertValueToCoords(middlewareArguments, value) { | ||
async function convertValueToCoords(state, value) { | ||
const { | ||
@@ -852,3 +849,3 @@ placement, | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); | ||
@@ -860,3 +857,3 @@ const side = getSide(placement); | ||
const crossAxisMulti = rtl && isVertical ? -1 : 1; | ||
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; | ||
const rawValue = typeof value === 'function' ? value(state) : value; | ||
@@ -891,4 +888,4 @@ // eslint-disable-next-line prefer-const | ||
/** | ||
* A placement modifier that translates the floating element along the specified | ||
* axes. | ||
* Modifies the placement by translating the floating element along the | ||
* specified axes. | ||
* A number (shorthand for `mainAxis` or distance), or an axes configuration | ||
@@ -905,8 +902,8 @@ * object may be passed. | ||
options: value, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
x, | ||
y | ||
} = middlewareArguments; | ||
const diffCoords = await convertValueToCoords(middlewareArguments, value); | ||
} = state; | ||
const diffCoords = await convertValueToCoords(state, value); | ||
return { | ||
@@ -926,4 +923,4 @@ x: x + diffCoords.x, | ||
/** | ||
* A visibility optimizer that shifts the floating element along the specified | ||
* axes in order to keep it in view. | ||
* Optimizes the visibility of the floating element by shifting it in order to | ||
* keep it in view when it will overflow the clipping boundary. | ||
* @see https://floating-ui.com/docs/shift | ||
@@ -938,3 +935,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -944,3 +941,3 @@ x, | ||
placement | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -967,3 +964,3 @@ mainAxis: checkMainAxis = true, | ||
}; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const mainAxis = getMainAxisFromPlacement(getSide(placement)); | ||
@@ -988,3 +985,3 @@ const crossAxis = getCrossAxis(mainAxis); | ||
const limitedCoords = limiter.fn({ | ||
...middlewareArguments, | ||
...state, | ||
[mainAxis]: mainAxisCoord, | ||
@@ -1012,3 +1009,3 @@ [crossAxis]: crossAxisCoord | ||
options, | ||
fn(middlewareArguments) { | ||
fn(state) { | ||
const { | ||
@@ -1020,3 +1017,3 @@ x, | ||
middlewareData | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -1035,3 +1032,3 @@ offset = 0, | ||
let crossAxisCoord = coords[crossAxis]; | ||
const rawOffset = typeof offset === 'function' ? offset(middlewareArguments) : offset; | ||
const rawOffset = typeof offset === 'function' ? offset(state) : offset; | ||
const computedOffset = typeof rawOffset === 'number' ? { | ||
@@ -1076,5 +1073,5 @@ mainAxis: rawOffset, | ||
/** | ||
* Provides data to change the size of the floating element. For instance, | ||
* prevent it from overflowing its clipping boundary or match the width of the | ||
* reference element. | ||
* Provides data that allows you to change the size of the floating element — | ||
* for instance, prevent it from overflowing the clipping boundary or match the | ||
* width of the reference element. | ||
* @see https://floating-ui.com/docs/size | ||
@@ -1089,3 +1086,3 @@ */ | ||
options, | ||
async fn(middlewareArguments) { | ||
async fn(state) { | ||
const { | ||
@@ -1096,3 +1093,3 @@ placement, | ||
elements | ||
} = middlewareArguments; | ||
} = state; | ||
const { | ||
@@ -1102,3 +1099,3 @@ apply = () => {}, | ||
} = options; | ||
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions); | ||
const overflow = await detectOverflow(state, detectOverflowOptions); | ||
const side = getSide(placement); | ||
@@ -1134,3 +1131,3 @@ const alignment = getAlignment(placement); | ||
} | ||
if (!middlewareArguments.middlewareData.shift && !alignment) { | ||
if (!state.middlewareData.shift && !alignment) { | ||
const xMin = max(overflow.left, 0); | ||
@@ -1147,3 +1144,3 @@ const xMax = max(overflow.right, 0); | ||
await apply({ | ||
...middlewareArguments, | ||
...state, | ||
availableWidth, | ||
@@ -1150,0 +1147,0 @@ availableHeight |
{ | ||
"name": "@floating-ui/core", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"@rollingversions": { | ||
@@ -5,0 +5,0 @@ "baseVersion": [ |
@@ -1,2 +0,2 @@ | ||
import type { Boundary, ElementContext, MiddlewareArguments, Padding, RootBoundary, SideObject } from './types'; | ||
import type { Boundary, ElementContext, MiddlewareState, Padding, RootBoundary, SideObject } from './types'; | ||
export interface Options { | ||
@@ -32,3 +32,3 @@ /** | ||
* Resolves with an object of overflow side offsets that determine how much the | ||
* element is overflowing a given clipping boundary. | ||
* element is overflowing a given clipping boundary on each side. | ||
* - positive = overflowing the boundary by that number of pixels | ||
@@ -39,2 +39,2 @@ * - negative = how many pixels left before it will overflow | ||
*/ | ||
export declare function detectOverflow(middlewareArguments: MiddlewareArguments, options?: Partial<Options>): Promise<SideObject>; | ||
export declare function detectOverflow(state: MiddlewareState, options?: Partial<Options>): Promise<SideObject>; |
@@ -16,7 +16,6 @@ import type { Middleware, Padding } from '../types'; | ||
/** | ||
* A data provider that provides data to position an inner element of the | ||
* floating element (usually a triangle or caret) so that it is centered to the | ||
* reference element. | ||
* Provides data to position an inner element of the floating element so that it | ||
* appears centered to the reference element. | ||
* @see https://floating-ui.com/docs/arrow | ||
*/ | ||
export declare const arrow: (options: Options) => Middleware; |
@@ -30,5 +30,7 @@ import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
/** | ||
* Automatically chooses the `placement` which has the most space available. | ||
* Optimizes the visibility of the floating element by choosing the placement | ||
* that has the most space available automatically, without needing to specify a | ||
* preferred placement. Alternative to `flip`. | ||
* @see https://floating-ui.com/docs/autoPlacement | ||
*/ | ||
export declare const autoPlacement: (options?: Partial<Options & DetectOverflowOptions>) => Middleware; |
@@ -40,10 +40,7 @@ import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
/** | ||
* A visibility optimizer that changes the placement of the floating element in | ||
* order to keep it in view. By default, only the opposite placement is tried. | ||
* | ||
* It has the ability to flip to any placement, not just the opposite one. You | ||
* can use a series of “fallback” placements, where each placement is | ||
* progressively tried until the one that fits can be used. | ||
* Optimizes the visibility of the floating element by flipping the `placement` | ||
* in order to keep it in view when the preferred placement(s) will overflow the | ||
* clipping boundary. Alternative to `autoPlacement`. | ||
* @see https://floating-ui.com/docs/flip | ||
*/ | ||
export declare const flip: (options?: Partial<Options & DetectOverflowOptions>) => Middleware; |
@@ -10,7 +10,6 @@ import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
/** | ||
* A data provider that allows you to hide the floating element in applicable | ||
* situations, usually when it’s not within the same clipping context as the | ||
* reference element. | ||
* Provides data to hide the floating element in applicable situations, such as | ||
* when it is not in the same clipping context as the reference element. | ||
* @see https://floating-ui.com/docs/hide | ||
*/ | ||
export declare const hide: (options?: Partial<Options & DetectOverflowOptions>) => Middleware; |
@@ -1,2 +0,2 @@ | ||
import type { Coords, Middleware, MiddlewareArguments } from '../types'; | ||
import type { Coords, Middleware, MiddlewareState } from '../types'; | ||
type OffsetValue = number | { | ||
@@ -28,8 +28,8 @@ /** | ||
}; | ||
type OffsetFunction = (args: MiddlewareArguments) => OffsetValue; | ||
type OffsetFunction = (state: MiddlewareState) => OffsetValue; | ||
export type Options = OffsetValue | OffsetFunction; | ||
export declare function convertValueToCoords(middlewareArguments: MiddlewareArguments, value: Options): Promise<Coords>; | ||
export declare function convertValueToCoords(state: MiddlewareState, value: Options): Promise<Coords>; | ||
/** | ||
* A placement modifier that translates the floating element along the specified | ||
* axes. | ||
* Modifies the placement by translating the floating element along the | ||
* specified axes. | ||
* A number (shorthand for `mainAxis` or distance), or an axes configuration | ||
@@ -36,0 +36,0 @@ * object may be passed. |
import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
import type { Coords, Middleware, MiddlewareArguments } from '../types'; | ||
import type { Coords, Middleware, MiddlewareState } from '../types'; | ||
export interface Options { | ||
@@ -21,3 +21,3 @@ /** | ||
limiter: { | ||
fn: (middlewareArguments: MiddlewareArguments) => Coords; | ||
fn: (state: MiddlewareState) => Coords; | ||
options?: any; | ||
@@ -27,8 +27,8 @@ }; | ||
/** | ||
* A visibility optimizer that shifts the floating element along the specified | ||
* axes in order to keep it in view. | ||
* Optimizes the visibility of the floating element by shifting it in order to | ||
* keep it in view when it will overflow the clipping boundary. | ||
* @see https://floating-ui.com/docs/shift | ||
*/ | ||
export declare const shift: (options?: Partial<Options & DetectOverflowOptions>) => Middleware; | ||
type LimitShiftOffset = ((args: MiddlewareArguments) => number | { | ||
type LimitShiftOffset = ((args: MiddlewareState) => number | { | ||
/** | ||
@@ -79,4 +79,4 @@ * Offset the limiting of the axis that runs along the alignment of the | ||
options: Partial<LimitShiftOffset>; | ||
fn: (middlewareArguments: MiddlewareArguments) => Coords; | ||
fn: (state: MiddlewareState) => Coords; | ||
}; | ||
export {}; |
import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
import type { Middleware, MiddlewareArguments } from '../types'; | ||
import type { Middleware, MiddlewareState } from '../types'; | ||
export interface Options { | ||
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
apply(args: MiddlewareArguments & { | ||
apply(args: MiddlewareState & { | ||
availableWidth: number; | ||
@@ -16,7 +16,7 @@ availableHeight: number; | ||
/** | ||
* Provides data to change the size of the floating element. For instance, | ||
* prevent it from overflowing its clipping boundary or match the width of the | ||
* reference element. | ||
* Provides data that allows you to change the size of the floating element — | ||
* for instance, prevent it from overflowing the clipping boundary or match the | ||
* width of the reference element. | ||
* @see https://floating-ui.com/docs/size | ||
*/ | ||
export declare const size: (options?: Partial<Options & DetectOverflowOptions>) => Middleware; |
@@ -99,3 +99,3 @@ export type Alignment = 'start' | 'end'; | ||
options?: any; | ||
fn: (middlewareArguments: MiddlewareArguments) => Promisable<MiddlewareReturn>; | ||
fn: (state: MiddlewareState) => Promisable<MiddlewareReturn>; | ||
}; | ||
@@ -124,3 +124,3 @@ export type Dimensions = { | ||
} | ||
export interface MiddlewareArguments extends Coords { | ||
export interface MiddlewareState extends Coords { | ||
initialPlacement: Placement; | ||
@@ -134,2 +134,6 @@ placement: Placement; | ||
} | ||
/** | ||
* @deprecated use `MiddlewareState` instead. | ||
*/ | ||
export type MiddlewareArguments = MiddlewareState; | ||
export type ClientRectObject = Rect & SideObject; | ||
@@ -136,0 +140,0 @@ export type Padding = number | Partial<SideObject>; |
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
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
194432
4961