@floating-ui/core
Advanced tools
Comparing version 0.6.2 to 0.7.0
@@ -335,3 +335,8 @@ function getSide(placement) { | ||
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); | ||
const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; | ||
let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; | ||
if (clientSize === 0) { | ||
clientSize = rects.floating[length]; | ||
} | ||
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center | ||
@@ -695,7 +700,9 @@ // point is outside of the floating element's bounds | ||
function convertValueToCoords(placement, rects, value, rtl) { | ||
if (rtl === void 0) { | ||
rtl = false; | ||
} | ||
async function convertValueToCoords(middlewareArguments, value) { | ||
const { | ||
placement, | ||
platform, | ||
elements | ||
} = middlewareArguments; | ||
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); | ||
const side = getSide(placement); | ||
@@ -706,5 +713,3 @@ const alignment = getAlignment(placement); | ||
const crossAxisMulti = rtl && isVertical ? -1 : 1; | ||
const rawValue = typeof value === 'function' ? value({ ...rects, | ||
placement | ||
}) : value; // eslint-disable-next-line prefer-const | ||
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const | ||
@@ -755,9 +760,5 @@ let { | ||
x, | ||
y, | ||
placement, | ||
rects, | ||
platform, | ||
elements | ||
y | ||
} = middlewareArguments; | ||
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); | ||
const diffCoords = await convertValueToCoords(middlewareArguments, value); | ||
return { | ||
@@ -980,8 +981,8 @@ x: x + diffCoords.x, | ||
const dimensions = { | ||
height: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]), | ||
width: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide]) | ||
availableHeight: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]), | ||
availableWidth: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide]) | ||
}; | ||
const prevDimensions = await platform.getDimensions(elements.floating); | ||
apply == null ? void 0 : apply({ ...dimensions, | ||
...rects | ||
apply == null ? void 0 : apply({ ...middlewareArguments, | ||
...dimensions | ||
}); | ||
@@ -988,0 +989,0 @@ const nextDimensions = await platform.getDimensions(elements.floating); |
{ | ||
"name": "@floating-ui/core", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"@rollingversions": { | ||
@@ -15,17 +15,20 @@ "baseVersion": [ | ||
}, | ||
"main": "dist/floating-ui.core.js", | ||
"module": "dist/floating-ui.core.esm.js", | ||
"unpkg": "dist/floating-ui.core.min.js", | ||
"type": "module", | ||
"main": "./dist/floating-ui.core.umd.js", | ||
"module": "./dist/floating-ui.core.esm.js", | ||
"unpkg": "./dist/floating-ui.core.umd.min.js", | ||
"types": "./index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"import": { | ||
"development": "./dist/floating-ui.core.esm.development.js", | ||
"production": "./dist/floating-ui.core.esm.min.js", | ||
"default": "./dist/floating-ui.core.esm.js" | ||
"browser": { | ||
"development": "./dist/floating-ui.core.browser.mjs", | ||
"default": "./dist/floating-ui.core.browser.min.mjs" | ||
}, | ||
"default": "./dist/floating-ui.core.mjs" | ||
}, | ||
"require": "./dist/floating-ui.core.cjs" | ||
"module": "./dist/floating-ui.core.esm.js", | ||
"default": "./dist/floating-ui.core.umd.js" | ||
}, | ||
"./package.json": "./package.json", | ||
"./src/index.ts": "./src/index.ts" | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -32,0 +35,0 @@ "sideEffects": false, |
@@ -1,2 +0,2 @@ | ||
import type { Placement, Rect, Coords, Middleware, ElementRects } from '../types'; | ||
import type { Coords, Middleware, MiddlewareArguments } from '../types'; | ||
declare type OffsetValue = number | { | ||
@@ -22,9 +22,5 @@ /** | ||
}; | ||
declare type OffsetFunction = (args: { | ||
floating: Rect; | ||
reference: Rect; | ||
placement: Placement; | ||
}) => OffsetValue; | ||
declare type OffsetFunction = (args: MiddlewareArguments) => OffsetValue; | ||
export declare type Options = OffsetValue | OffsetFunction; | ||
export declare function convertValueToCoords(placement: Placement, rects: ElementRects, value: Options, rtl?: boolean): Coords; | ||
export declare function convertValueToCoords(middlewareArguments: MiddlewareArguments, value: Options): Promise<Coords>; | ||
/** | ||
@@ -31,0 +27,0 @@ * Displaces the floating element from its reference element. |
@@ -1,2 +0,2 @@ | ||
import type { Dimensions, ElementRects, Middleware } from '../types'; | ||
import type { Middleware, MiddlewareArguments } from '../types'; | ||
import { Options as DetectOverflowOptions } from '../detectOverflow'; | ||
@@ -9,3 +9,6 @@ export interface Options { | ||
*/ | ||
apply(args: Dimensions & ElementRects): void; | ||
apply(args: MiddlewareArguments & { | ||
availableWidth: number; | ||
availableHeight: number; | ||
}): void; | ||
} | ||
@@ -12,0 +15,0 @@ /** |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
178277
4511
1
No