From 90548bb87f05059718134a928f9e62b7437018d2 Mon Sep 17 00:00:00 2001 From: Erin McLaughlin Date: Sun, 19 May 2024 13:04:51 -0400 Subject: [PATCH] add popover options --- .../Dropdown/SimpleDropdownExample.razor | 2 +- .../Behaviors/HBPopoverAlignment.cs | 11 + .../Behaviors/HBPopoverBehavior.razor | 16 +- .../Behaviors/HBPopoverBehavior.razor.js | 22 +- .../Behaviors/HBPopoverOptions.cs | 7 + .../Behaviors/HBPopoverSide.cs | 12 + .../wwwroot/@floating-ui/core/LICENSE | 20 - .../wwwroot/@floating-ui/core/README.md | 4 - .../core/dist/floating-ui.core.browser.mjs | 1153 ---------------- .../core/dist/floating-ui.core.d.mts | 521 -------- .../core/dist/floating-ui.core.d.ts | 521 -------- .../core/dist/floating-ui.core.esm.js | 1025 -------------- .../core/dist/floating-ui.core.mjs | 1025 -------------- .../core/dist/floating-ui.core.umd.js | 1172 ----------------- .../core/dist/floating-ui.core.umd.min.js | 1 - .../wwwroot/@floating-ui/core/package.json | 63 - .../wwwroot/@floating-ui/dom/LICENSE | 20 - .../wwwroot/@floating-ui/dom/README.md | 4 - .../dom/dist/floating-ui.dom.browser.min.mjs | 1 - .../dom/dist/floating-ui.dom.browser.mjs | 852 ------------ .../dom/dist/floating-ui.dom.d.mts | 353 ----- .../dom/dist/floating-ui.dom.d.ts | 353 ----- .../dom/dist/floating-ui.dom.esm.js | 715 ---------- .../@floating-ui/dom/dist/floating-ui.dom.mjs | 715 ---------- .../dom/dist/floating-ui.dom.umd.js | 871 ------------ .../dom/dist/floating-ui.dom.umd.min.js | 1 - .../wwwroot/@floating-ui/dom/package.json | 71 - .../wwwroot/@floating-ui/utils/LICENSE | 20 - .../wwwroot/@floating-ui/utils/README.md | 4 - .../utils/dist/floating-ui.utils.d.mts | 98 -- .../utils/dist/floating-ui.utils.d.ts | 98 -- .../utils/dist/floating-ui.utils.dom.d.mts | 43 - .../utils/dist/floating-ui.utils.dom.d.ts | 43 - .../utils/dist/floating-ui.utils.dom.esm.js | 127 -- .../utils/dist/floating-ui.utils.dom.mjs | 127 -- .../utils/dist/floating-ui.utils.dom.umd.js | 152 --- .../dist/floating-ui.utils.dom.umd.min.js | 1 - .../utils/dist/floating-ui.utils.esm.js | 138 -- .../utils/dist/floating-ui.utils.mjs | 138 -- .../utils/dist/floating-ui.utils.umd.js | 169 --- .../utils/dist/floating-ui.utils.umd.min.js | 1 - .../utils/dom/floating-ui.utils.dom.d.ts | 43 - .../utils/dom/floating-ui.utils.dom.esm.js | 127 -- .../utils/dom/floating-ui.utils.dom.umd.js | 152 --- .../@floating-ui/utils/dom/package.json | 6 - .../wwwroot/@floating-ui/utils/package.json | 70 - .../floating-ui.core.browser.min.mjs | 0 .../wwwroot/floating-ui.dom.browser.min.mjs | 1 + src/HeadlessBlazor.Dropdown/HBDropdown.cs | 9 +- 49 files changed, 61 insertions(+), 11037 deletions(-) create mode 100644 src/HeadlessBlazor.Core/Behaviors/HBPopoverAlignment.cs create mode 100644 src/HeadlessBlazor.Core/Behaviors/HBPopoverOptions.cs create mode 100644 src/HeadlessBlazor.Core/Behaviors/HBPopoverSide.cs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/LICENSE delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/README.md delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.browser.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.mts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.ts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.esm.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.min.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/package.json delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/LICENSE delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/README.md delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.d.mts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.d.ts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.esm.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.umd.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.umd.min.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/package.json delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/LICENSE delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/README.md delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.d.mts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.d.ts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.esm.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.umd.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.dom.umd.min.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.esm.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.mjs delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.umd.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dist/floating-ui.utils.umd.min.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dom/floating-ui.utils.dom.esm.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dom/floating-ui.utils.dom.umd.js delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/dom/package.json delete mode 100644 src/HeadlessBlazor.Core/wwwroot/@floating-ui/utils/package.json rename src/HeadlessBlazor.Core/wwwroot/{@floating-ui/core/dist => }/floating-ui.core.browser.min.mjs (100%) create mode 100644 src/HeadlessBlazor.Core/wwwroot/floating-ui.dom.browser.min.mjs diff --git a/docs/HeadlessBlazor.Docs.Client/Examples/Dropdown/SimpleDropdownExample.razor b/docs/HeadlessBlazor.Docs.Client/Examples/Dropdown/SimpleDropdownExample.razor index ff386f9..d00c541 100644 --- a/docs/HeadlessBlazor.Docs.Client/Examples/Dropdown/SimpleDropdownExample.razor +++ b/docs/HeadlessBlazor.Docs.Client/Examples/Dropdown/SimpleDropdownExample.razor @@ -12,7 +12,7 @@ Link (Prevent Default and Stop Propagation) - + Click Me Default diff --git a/src/HeadlessBlazor.Core/Behaviors/HBPopoverAlignment.cs b/src/HeadlessBlazor.Core/Behaviors/HBPopoverAlignment.cs new file mode 100644 index 0000000..5159f52 --- /dev/null +++ b/src/HeadlessBlazor.Core/Behaviors/HBPopoverAlignment.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace HeadlessBlazor.Behaviors; + +[JsonConverter(typeof(JsonStringEnumConverter))] +public enum HBPopoverAlignment +{ + Start, + Center, + End +} diff --git a/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor b/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor index 0b8aa04..5f76a41 100644 --- a/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor +++ b/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor @@ -1,14 +1,19 @@ @implements IAsyncDisposable @code { - private DotNetObjectReference? dotNetObjRef; private IJSObjectReference? popover; [Inject] private IJSRuntime JS { get; set; } = default!; + [Parameter] + public HBPopoverAlignment? Alignment { get; set; } + [Parameter] public IReferenceable Container { get; set; } = default!; + [Parameter] + public HBPopoverSide? Side { get; set; } + public async ValueTask DisposeAsync() { if (popover is not null) @@ -17,18 +22,19 @@ await popover.DisposeAsync(); popover = null; } - - dotNetObjRef?.Dispose(); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { - dotNetObjRef ??= DotNetObjectReference.Create(this); var moduleName = nameof(HBPopoverBehavior); var module = await JS.InvokeAsync("import", $"./_content/HeadlessBlazor.Core/Behaviors/{moduleName}.razor.js"); - popover = await module.InvokeAsync($"{moduleName}.createInstance", Container.ElementReference, dotNetObjRef); + popover = await module.InvokeAsync($"{moduleName}.createInstance", Container.ElementReference, new HBPopoverOptions + { + Alignment = Alignment, + Side = Side + }); await module.DisposeAsync(); } } diff --git a/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor.js b/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor.js index b63c318..b01e277 100644 --- a/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor.js +++ b/src/HeadlessBlazor.Core/Behaviors/HBPopoverBehavior.razor.js @@ -1,38 +1,36 @@ -import { - autoUpdate, - computePosition, - flip -} from '../@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs'; +import { autoUpdate, computePosition, flip } from '../floating-ui.dom.browser.min.mjs'; export class HBPopoverBehavior { /** * @static * @param {Element} container - * @param {any} dotNetRef + * @param {any} options * @returns {HBPopoverBehavior} */ - static createInstance(container) { - return new HBPopoverBehavior(container); + static createInstance(container, options) { + return new HBPopoverBehavior(container, options); } /** * Creates a new instance of HBPopoverBehavior. * @constructor * @param {Element} container - * @param {any} dotNetRef + * @param {any} options */ - constructor(container) { + constructor(container, options) { const anchor = container.querySelector('[hb-popover-anchor]'); const floater = container.querySelector('[hb-popover]'); + + const side = (options && options.Side) || 'bottom'; + const align = (options && options.Alignment) || 'start'; this.dispose = autoUpdate(anchor, floater, () => { computePosition(anchor, floater, { - placement: 'bottom-start', + placement: `${side}-${align}`, middleware: [flip()] }).then(({ x, y }) => { Object.assign(floater.style, { - display: `block`, left: `${x}px`, top: `${y}px`, }); diff --git a/src/HeadlessBlazor.Core/Behaviors/HBPopoverOptions.cs b/src/HeadlessBlazor.Core/Behaviors/HBPopoverOptions.cs new file mode 100644 index 0000000..8caa6fc --- /dev/null +++ b/src/HeadlessBlazor.Core/Behaviors/HBPopoverOptions.cs @@ -0,0 +1,7 @@ +namespace HeadlessBlazor.Behaviors; + +public sealed record HBPopoverOptions +{ + public HBPopoverAlignment? Alignment { get; init; } + public HBPopoverSide? Side { get; init; } +} diff --git a/src/HeadlessBlazor.Core/Behaviors/HBPopoverSide.cs b/src/HeadlessBlazor.Core/Behaviors/HBPopoverSide.cs new file mode 100644 index 0000000..2b38b68 --- /dev/null +++ b/src/HeadlessBlazor.Core/Behaviors/HBPopoverSide.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace HeadlessBlazor.Behaviors; + +[JsonConverter(typeof(JsonStringEnumConverter))] +public enum HBPopoverSide +{ + Top, + Right, + Bottom, + Left +} diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/LICENSE b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/LICENSE deleted file mode 100644 index 639cdc6..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright (c) 2021-present Floating UI contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/README.md b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/README.md deleted file mode 100644 index c4b69b2..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# @floating-ui/core - -This is the platform-agnostic core of Floating UI, exposing the main -`computePosition` function but no platform interface logic. diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.browser.mjs b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.browser.mjs deleted file mode 100644 index c43c057..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.browser.mjs +++ /dev/null @@ -1,1153 +0,0 @@ -/** - * Custom positioning reference element. - * @see https://floating-ui.com/docs/virtual-elements - */ - -const sides = ['top', 'right', 'bottom', 'left']; -const alignments = ['start', 'end']; -const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []); -const min = Math.min; -const max = Math.max; -const oppositeSideMap = { - left: 'right', - right: 'left', - bottom: 'top', - top: 'bottom' -}; -const oppositeAlignmentMap = { - start: 'end', - end: 'start' -}; -function clamp(start, value, end) { - return max(start, min(value, end)); -} -function evaluate(value, param) { - return typeof value === 'function' ? value(param) : value; -} -function getSide(placement) { - return placement.split('-')[0]; -} -function getAlignment(placement) { - return placement.split('-')[1]; -} -function getOppositeAxis(axis) { - return axis === 'x' ? 'y' : 'x'; -} -function getAxisLength(axis) { - return axis === 'y' ? 'height' : 'width'; -} -function getSideAxis(placement) { - return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x'; -} -function getAlignmentAxis(placement) { - return getOppositeAxis(getSideAxis(placement)); -} -function getAlignmentSides(placement, rects, rtl) { - if (rtl === void 0) { - rtl = false; - } - const alignment = getAlignment(placement); - const alignmentAxis = getAlignmentAxis(placement); - const length = getAxisLength(alignmentAxis); - let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top'; - if (rects.reference[length] > rects.floating[length]) { - mainAlignmentSide = getOppositePlacement(mainAlignmentSide); - } - return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; -} -function getExpandedPlacements(placement) { - const oppositePlacement = getOppositePlacement(placement); - return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; -} -function getOppositeAlignmentPlacement(placement) { - return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]); -} -function getSideList(side, isStart, rtl) { - const lr = ['left', 'right']; - const rl = ['right', 'left']; - const tb = ['top', 'bottom']; - const bt = ['bottom', 'top']; - switch (side) { - case 'top': - case 'bottom': - if (rtl) return isStart ? rl : lr; - return isStart ? lr : rl; - case 'left': - case 'right': - return isStart ? tb : bt; - default: - return []; - } -} -function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { - const alignment = getAlignment(placement); - let list = getSideList(getSide(placement), direction === 'start', rtl); - if (alignment) { - list = list.map(side => side + "-" + alignment); - if (flipAlignment) { - list = list.concat(list.map(getOppositeAlignmentPlacement)); - } - } - return list; -} -function getOppositePlacement(placement) { - return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]); -} -function expandPaddingObject(padding) { - return { - top: 0, - right: 0, - bottom: 0, - left: 0, - ...padding - }; -} -function getPaddingObject(padding) { - return typeof padding !== 'number' ? expandPaddingObject(padding) : { - top: padding, - right: padding, - bottom: padding, - left: padding - }; -} -function rectToClientRect(rect) { - const { - x, - y, - width, - height - } = rect; - return { - width, - height, - top: y, - left: x, - right: x + width, - bottom: y + height, - x, - y - }; -} - -function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === 'y'; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case 'top': - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case 'bottom': - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case 'right': - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case 'left': - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case 'start': - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case 'end': - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; - } - return coords; -} - -/** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ -const computePosition = async (reference, floating, config) => { - const { - placement = 'bottom', - strategy = 'absolute', - middleware = [], - platform - } = config; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); - let rects = await platform.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i = 0; i < validMiddleware.length; i++) { - const { - name, - fn - } = validMiddleware[i]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y = nextY != null ? nextY : y; - middlewareData = { - ...middlewareData, - [name]: { - ...middlewareData[name], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === 'object') { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); - } - i = -1; - } - } - return { - x, - y, - placement: statefulPlacement, - strategy, - middlewareData - }; -}; - -/** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ -async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; - } - const { - x, - y, - platform, - rects, - elements, - strategy - } = state; - const { - boundary = 'clippingAncestors', - rootBoundary = 'viewport', - elementContext = 'floating', - altBoundary = false, - padding = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding); - const altContext = elementContext === 'floating' ? 'reference' : 'floating'; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform.getClippingRect({ - element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === 'floating' ? { - x, - y, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); - const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; -} - -/** - * 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 - */ -const arrow = options => ({ - name: 'arrow', - options, - async fn(state) { - const { - x, - y, - placement, - rects, - platform, - elements, - middlewareData - } = state; - // Since `element` is required, we don't Partial<> the type. - const { - element, - padding = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; - } - const paddingObject = getPaddingObject(padding); - const coords = { - x, - y - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform.getDimensions(element); - const isYAxis = axis === 'y'; - const minProp = isYAxis ? 'top' : 'left'; - const maxProp = isYAxis ? 'bottom' : 'right'; - const clientProp = isYAxis ? 'clientHeight' : 'clientWidth'; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - - // DOM platform can return `window` as the `offsetParent`. - if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; - } - const centerToReference = endDiff / 2 - startDiff / 2; - - // If the padding is large enough that it causes the arrow to no longer be - // centered, modify the padding so that it is centered. - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); - - // Make sure the arrow doesn't overflow the floating element if the center - // point is outside the floating element's bounds. - const min$1 = minPadding; - const max = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset = clamp(min$1, center, max); - - // If the reference is small enough that the arrow's padding causes it to - // to point to nothing for an aligned placement, adjust the offset of the - // floating element itself. To ensure `shift()` continues to take action, - // a single reset is performed when this is true. - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset, - centerOffset: center - offset - alignmentOffset, - ...(shouldAddOffset && { - alignmentOffset - }) - }, - reset: shouldAddOffset - }; - } -}); - -function getPlacementList(alignment, autoAlignment, allowedPlacements) { - const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement); - return allowedPlacementsSortedByAlignment.filter(placement => { - if (alignment) { - return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false); - } - return true; - }); -} -/** - * 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 - */ -const autoPlacement = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'autoPlacement', - options, - async fn(state) { - var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; - const { - rects, - middlewareData, - placement, - platform, - elements - } = state; - const { - crossAxis = false, - alignment, - allowedPlacements = placements, - autoAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; - const overflow = await detectOverflow(state, detectOverflowOptions); - const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; - const currentPlacement = placements$1[currentIndex]; - if (currentPlacement == null) { - return {}; - } - const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); - - // Make `computeCoords` start from the right place. - if (placement !== currentPlacement) { - return { - reset: { - placement: placements$1[0] - } - }; - } - const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]]; - const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), { - placement: currentPlacement, - overflows: currentOverflows - }]; - const nextPlacement = placements$1[currentIndex + 1]; - - // There are more placements to check. - if (nextPlacement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: nextPlacement - } - }; - } - const placementsSortedByMostSpace = allOverflows.map(d => { - const alignment = getAlignment(d.placement); - return [d.placement, alignment && crossAxis ? - // Check along the mainAxis and main crossAxis side. - d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) : - // Check only the mainAxis. - d.overflows[0], d.overflows]; - }).sort((a, b) => a[1] - b[1]); - const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0, - // Aligned placements should not check their opposite crossAxis - // side. - getAlignment(d[0]) ? 2 : 3).every(v => v <= 0)); - const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; - if (resetPlacement !== placement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: resetPlacement - } - }; - } - return {}; - } - }; -}; - -/** - * 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 - */ -const flip = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'flip', - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = 'bestFit', - fallbackAxisSideDirection = 'none', - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - - // If a reset by the arrow was caused due to an alignment offset being - // added, we should skip any logic now since `flip()` has already done its - // work. - // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); - } - if (checkCrossAxis) { - const sides = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides[0]], overflow[sides[1]]); - } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - - // One or more sides is overflowing. - if (!overflows.every(side => side <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements[nextIndex]; - if (nextPlacement) { - // Try next placement and re-run the lifecycle. - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - - // First, find the candidates that fit on the mainAxis side of overflow, - // then find the placement that fits the best on the main crossAxis side. - let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - - // Otherwise fallback. - if (!resetPlacement) { - switch (fallbackStrategy) { - case 'bestFit': - { - var _overflowsData$map$so; - const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; - if (placement) { - resetPlacement = placement; - } - break; - } - case 'initialPlacement': - resetPlacement = initialPlacement; - break; - } - } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; - } - } - return {}; - } - }; -}; - -function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; -} -function isAnySideFullyClipped(overflow) { - return sides.some(side => overflow[side] >= 0); -} -/** - * 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 - */ -const hide = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'hide', - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = 'referenceHidden', - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case 'referenceHidden': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: 'reference' - }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; - } - case 'escaped': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: - { - return {}; - } - } - } - }; -}; - -function getBoundingRect(rects) { - const minX = min(...rects.map(rect => rect.left)); - const minY = min(...rects.map(rect => rect.top)); - const maxX = max(...rects.map(rect => rect.right)); - const maxY = max(...rects.map(rect => rect.bottom)); - return { - x: minX, - y: minY, - width: maxX - minX, - height: maxY - minY - }; -} -function getRectsByLine(rects) { - const sortedRects = rects.slice().sort((a, b) => a.y - b.y); - const groups = []; - let prevRect = null; - for (let i = 0; i < sortedRects.length; i++) { - const rect = sortedRects[i]; - if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) { - groups.push([rect]); - } else { - groups[groups.length - 1].push(rect); - } - prevRect = rect; - } - return groups.map(rect => rectToClientRect(getBoundingRect(rect))); -} -/** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ -const inline = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'inline', - options, - async fn(state) { - const { - placement, - elements, - rects, - platform, - strategy - } = state; - // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a - // ClientRect's bounds, despite the event listener being triggered. A - // padding of 2 seems to handle this issue. - const { - padding = 2, - x, - y - } = evaluate(options, state); - const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []); - const clientRects = getRectsByLine(nativeClientRects); - const fallback = rectToClientRect(getBoundingRect(nativeClientRects)); - const paddingObject = getPaddingObject(padding); - function getBoundingClientRect() { - // There are two rects and they are disjoined. - if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) { - // Find the first rect in which the point is fully inside. - return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback; - } - - // There are 2 or more connected rects. - if (clientRects.length >= 2) { - if (getSideAxis(placement) === 'y') { - const firstRect = clientRects[0]; - const lastRect = clientRects[clientRects.length - 1]; - const isTop = getSide(placement) === 'top'; - const top = firstRect.top; - const bottom = lastRect.bottom; - const left = isTop ? firstRect.left : lastRect.left; - const right = isTop ? firstRect.right : lastRect.right; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - const isLeftSide = getSide(placement) === 'left'; - const maxRight = max(...clientRects.map(rect => rect.right)); - const minLeft = min(...clientRects.map(rect => rect.left)); - const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight); - const top = measureRects[0].top; - const bottom = measureRects[measureRects.length - 1].bottom; - const left = minLeft; - const right = maxRight; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - return fallback; - } - const resetRects = await platform.getElementRects({ - reference: { - getBoundingClientRect - }, - floating: elements.floating, - strategy - }); - if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) { - return { - reset: { - rects: resetRects - } - }; - } - return {}; - } - }; -}; - -// For type backwards-compatibility, the `OffsetOptions` type was also -// Derivable. - -async function convertValueToCoords(state, options) { - const { - placement, - platform, - elements - } = state; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === 'y'; - const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - - // eslint-disable-next-line prefer-const - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === 'number' ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === 'number') { - crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; -} - -/** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ -const offset = function (options) { - if (options === void 0) { - options = 0; - } - return { - name: 'offset', - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - - // If the placement is the same and the arrow caused an alignment offset - // then we don't need to change the positioning coordinates. - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - return { - x: x + diffCoords.x, - y: y + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; -}; - -/** - * 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 - */ -const shift = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'shift', - options, - async fn(state) { - const { - x, - y, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: _ref => { - let { - x, - y - } = _ref; - return { - x, - y - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === 'y' ? 'top' : 'left'; - const maxSide = mainAxis === 'y' ? 'bottom' : 'right'; - const min = mainAxisCoord + overflow[minSide]; - const max = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp(min, mainAxisCoord, max); - } - if (checkCrossAxis) { - const minSide = crossAxis === 'y' ? 'top' : 'left'; - const maxSide = crossAxis === 'y' ? 'bottom' : 'right'; - const min = crossAxisCoord + overflow[minSide]; - const max = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp(min, crossAxisCoord, max); - } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y - } - }; - } - }; -}; -/** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ -const limitShift = function (options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y, - placement, - rects, - middlewareData - } = state; - const { - offset = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset, state); - const computedOffset = typeof rawOffset === 'number' ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === 'y' ? 'height' : 'width'; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === 'y' ? 'width' : 'height'; - const isOriginSide = ['top', 'left'].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } - } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; -}; - -/** - * 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 - */ -const size = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'size', - options, - async fn(state) { - const { - placement, - rects, - platform, - elements - } = state; - const { - apply = () => {}, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === 'y'; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === 'top' || side === 'bottom') { - heightSide = side; - widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right'; - } else { - widthSide = side; - heightSide = alignment === 'end' ? 'top' : 'bottom'; - } - const maximumClippingHeight = height - overflow.top - overflow.bottom; - const maximumClippingWidth = width - overflow.left - overflow.right; - const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); - const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); - } - } - await apply({ - ...state, - availableWidth, - availableHeight - }); - const nextDimensions = await platform.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; - } - return {}; - } - }; -}; - -export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, rectToClientRect, shift, size }; diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.mts b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.mts deleted file mode 100644 index df276ee..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.mts +++ /dev/null @@ -1,521 +0,0 @@ -import { AlignedPlacement } from '@floating-ui/utils'; -import { Alignment } from '@floating-ui/utils'; -import { Axis } from '@floating-ui/utils'; -import { ClientRectObject } from '@floating-ui/utils'; -import { Coords } from '@floating-ui/utils'; -import { Dimensions } from '@floating-ui/utils'; -import { ElementRects } from '@floating-ui/utils'; -import { Length } from '@floating-ui/utils'; -import { Padding } from '@floating-ui/utils'; -import { Placement } from '@floating-ui/utils'; -import { Rect } from '@floating-ui/utils'; -import { rectToClientRect } from '@floating-ui/utils'; -import { Side } from '@floating-ui/utils'; -import { SideObject } from '@floating-ui/utils'; -import { Strategy } from '@floating-ui/utils'; -import { VirtualElement } from '@floating-ui/utils'; - -export { AlignedPlacement } - -export { Alignment } - -/** - * 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: ArrowOptions | Derivable) => Middleware; - -export declare interface ArrowOptions { - /** - * The arrow element to be positioned. - * @default undefined - */ - element: any; - /** - * The padding between the arrow element and the floating element edges. - * Useful when the floating element has rounded corners. - * @default 0 - */ - padding?: Padding; -} - -/** - * 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?: AutoPlacementOptions | Derivable) => Middleware; - -export declare type AutoPlacementOptions = Partial; -}>; - -export { Axis } - -export declare type Boundary = any; - -export { ClientRectObject } - -export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise; - -/** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ -export declare const computePosition: ComputePosition; - -export declare interface ComputePositionConfig { - /** - * Object to interface with the current platform. - */ - platform: Platform; - /** - * Where to place the floating element relative to the reference element. - */ - placement?: Placement; - /** - * The strategy to use when positioning the floating element. - */ - strategy?: Strategy; - /** - * Array of middleware objects to modify the positioning or provide data for - * rendering. - */ - middleware?: Array; -} - -export declare interface ComputePositionReturn extends Coords { - /** - * The final chosen placement of the floating element. - */ - placement: Placement; - /** - * The strategy used to position the floating element. - */ - strategy: Strategy; - /** - * Object containing data returned from all middleware, keyed by their name. - */ - middlewareData: MiddlewareData; -} - -export { Coords } - -/** - * Function option to derive middleware options from state. - */ -export declare type Derivable = (state: MiddlewareState) => T; - -/** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ -export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable): Promise; - -export declare type DetectOverflowOptions = Partial<{ - /** - * The clipping element(s) or area in which overflow will be checked. - * @default 'clippingAncestors' - */ - boundary: Boundary; - /** - * The root clipping area in which overflow will be checked. - * @default 'viewport' - */ - rootBoundary: RootBoundary; - /** - * The element in which overflow is being checked relative to a boundary. - * @default 'floating' - */ - elementContext: ElementContext; - /** - * Whether to check for overflow using the alternate element's boundary - * (`clippingAncestors` boundary only). - * @default false - */ - altBoundary: boolean; - /** - * Virtual padding for the resolved overflow detection offsets. - * @default 0 - */ - padding: Padding; -}>; - -export { Dimensions } - -export declare type ElementContext = 'reference' | 'floating'; - -export { ElementRects } - -export declare interface Elements { - reference: ReferenceElement; - floating: FloatingElement; -} - -/** - * 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?: FlipOptions | Derivable) => Middleware; - -export declare type FlipOptions = Partial; - /** - * What strategy to use when no placements fit. - * @default 'bestFit' - */ - fallbackStrategy: 'bestFit' | 'initialPlacement'; - /** - * Whether to allow fallback to the perpendicular axis of the preferred - * placement, and if so, which side direction along the axis to prefer. - * @default 'none' (disallow fallback) - */ - fallbackAxisSideDirection: 'none' | 'start' | 'end'; - /** - * Whether to flip to placements with the opposite alignment if they fit - * better. - * @default true - */ - flipAlignment: boolean; -}>; - -export declare type FloatingElement = any; - -/** - * 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?: HideOptions | Derivable) => Middleware; - -export declare type HideOptions = Partial; - -/** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ -export declare const inline: (options?: InlineOptions | Derivable) => Middleware; - -export declare type InlineOptions = Partial<{ - /** - * Viewport-relative `x` coordinate to choose a `ClientRect`. - * @default undefined - */ - x: number; - /** - * Viewport-relative `y` coordinate to choose a `ClientRect`. - * @default undefined - */ - y: number; - /** - * Represents the padding around a disjoined rect when choosing it. - * @default 2 - */ - padding: Padding; -}>; - -export { Length } - -/** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ -export declare const limitShift: (options?: LimitShiftOptions | Derivable) => { - options: any; - fn: (state: MiddlewareState) => Coords; -}; - -declare type LimitShiftOffset = number | Partial<{ - /** - * Offset the limiting of the axis that runs along the alignment of the - * floating element. - */ - mainAxis: number; - /** - * Offset the limiting of the axis that runs along the side of the - * floating element. - */ - crossAxis: number; -}>; - -export declare type LimitShiftOptions = Partial<{ - /** - * Offset when limiting starts. `0` will limit when the opposite edges of the - * reference and floating elements are aligned. - * - positive = start limiting earlier - * - negative = start limiting later - */ - offset: LimitShiftOffset | Derivable; - /** - * Whether to limit the axis that runs along the alignment of the floating - * element. - */ - mainAxis: boolean; - /** - * Whether to limit the axis that runs along the side of the floating element. - */ - crossAxis: boolean; -}>; - -export declare type Middleware = { - name: string; - options?: any; - fn: (state: MiddlewareState) => Promisable; -}; - -/** - * @deprecated use `MiddlewareState` instead. - */ -export declare type MiddlewareArguments = MiddlewareState; - -export declare interface MiddlewareData { - [key: string]: any; - arrow?: Partial & { - centerOffset: number; - alignmentOffset?: number; - }; - autoPlacement?: { - index?: number; - overflows: Array<{ - placement: Placement; - overflows: Array; - }>; - }; - flip?: { - index?: number; - overflows: Array<{ - placement: Placement; - overflows: Array; - }>; - }; - hide?: { - referenceHidden?: boolean; - escaped?: boolean; - referenceHiddenOffsets?: SideObject; - escapedOffsets?: SideObject; - }; - offset?: Coords & { - placement: Placement; - }; - shift?: Coords; -} - -export declare interface MiddlewareReturn extends Partial { - data?: { - [key: string]: any; - }; - reset?: boolean | { - placement?: Placement; - rects?: boolean | ElementRects; - }; -} - -export declare interface MiddlewareState extends Coords { - initialPlacement: Placement; - placement: Placement; - strategy: Strategy; - middlewareData: MiddlewareData; - elements: Elements; - rects: ElementRects; - platform: Platform; -} - -/** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ -export declare const offset: (options?: OffsetOptions) => Middleware; - -export declare type OffsetOptions = OffsetValue | Derivable; - -declare type OffsetValue = number | Partial<{ - /** - * The axis that runs along the side of the floating element. Represents - * the distance (gutter or margin) between the reference and floating - * element. - * @default 0 - */ - mainAxis: number; - /** - * The axis that runs along the alignment of the floating element. - * Represents the skidding between the reference and floating element. - * @default 0 - */ - crossAxis: number; - /** - * The same axis as `crossAxis` but applies only to aligned placements - * and inverts the `end` alignment. When set to a number, it overrides the - * `crossAxis` value. - * - * A positive number will move the floating element in the direction of - * the opposite edge to the one that is aligned, while a negative number - * the reverse. - * @default null - */ - alignmentAxis: number | null; -}>; - -export { Padding } - -export { Placement } - -/** - * Platform interface methods to work with the current platform. - * @see https://floating-ui.com/docs/platform - */ -export declare interface Platform { - getElementRects: (args: { - reference: ReferenceElement; - floating: FloatingElement; - strategy: Strategy; - }) => Promisable; - getClippingRect: (args: { - element: any; - boundary: Boundary; - rootBoundary: RootBoundary; - strategy: Strategy; - }) => Promisable; - getDimensions: (element: any) => Promisable; - convertOffsetParentRelativeRectToViewportRelativeRect?: (args: { - elements?: Elements; - rect: Rect; - offsetParent: any; - strategy: Strategy; - }) => Promisable; - getOffsetParent?: (element: any) => Promisable; - isElement?: (value: any) => Promisable; - getDocumentElement?: (element: any) => Promisable; - getClientRects?: (element: any) => Promisable>; - isRTL?: (element: any) => Promisable; - getScale?: (element: any) => Promisable<{ - x: number; - y: number; - }>; -} - -declare type Promisable = T | Promise; - -export { Rect } - -export { rectToClientRect } - -export declare type ReferenceElement = any; - -export declare type RootBoundary = 'viewport' | 'document' | Rect; - -/** - * 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?: ShiftOptions | Derivable) => Middleware; - -export declare type ShiftOptions = Partial Coords; - options?: any; - }; -}>; - -export { Side } - -export { SideObject } - -/** - * 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?: SizeOptions | Derivable) => Middleware; - -export declare type SizeOptions = Partial; -}>; - -export { Strategy } - -export { VirtualElement } - -export { } diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.ts b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.ts deleted file mode 100644 index df276ee..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.d.ts +++ /dev/null @@ -1,521 +0,0 @@ -import { AlignedPlacement } from '@floating-ui/utils'; -import { Alignment } from '@floating-ui/utils'; -import { Axis } from '@floating-ui/utils'; -import { ClientRectObject } from '@floating-ui/utils'; -import { Coords } from '@floating-ui/utils'; -import { Dimensions } from '@floating-ui/utils'; -import { ElementRects } from '@floating-ui/utils'; -import { Length } from '@floating-ui/utils'; -import { Padding } from '@floating-ui/utils'; -import { Placement } from '@floating-ui/utils'; -import { Rect } from '@floating-ui/utils'; -import { rectToClientRect } from '@floating-ui/utils'; -import { Side } from '@floating-ui/utils'; -import { SideObject } from '@floating-ui/utils'; -import { Strategy } from '@floating-ui/utils'; -import { VirtualElement } from '@floating-ui/utils'; - -export { AlignedPlacement } - -export { Alignment } - -/** - * 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: ArrowOptions | Derivable) => Middleware; - -export declare interface ArrowOptions { - /** - * The arrow element to be positioned. - * @default undefined - */ - element: any; - /** - * The padding between the arrow element and the floating element edges. - * Useful when the floating element has rounded corners. - * @default 0 - */ - padding?: Padding; -} - -/** - * 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?: AutoPlacementOptions | Derivable) => Middleware; - -export declare type AutoPlacementOptions = Partial; -}>; - -export { Axis } - -export declare type Boundary = any; - -export { ClientRectObject } - -export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise; - -/** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ -export declare const computePosition: ComputePosition; - -export declare interface ComputePositionConfig { - /** - * Object to interface with the current platform. - */ - platform: Platform; - /** - * Where to place the floating element relative to the reference element. - */ - placement?: Placement; - /** - * The strategy to use when positioning the floating element. - */ - strategy?: Strategy; - /** - * Array of middleware objects to modify the positioning or provide data for - * rendering. - */ - middleware?: Array; -} - -export declare interface ComputePositionReturn extends Coords { - /** - * The final chosen placement of the floating element. - */ - placement: Placement; - /** - * The strategy used to position the floating element. - */ - strategy: Strategy; - /** - * Object containing data returned from all middleware, keyed by their name. - */ - middlewareData: MiddlewareData; -} - -export { Coords } - -/** - * Function option to derive middleware options from state. - */ -export declare type Derivable = (state: MiddlewareState) => T; - -/** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ -export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable): Promise; - -export declare type DetectOverflowOptions = Partial<{ - /** - * The clipping element(s) or area in which overflow will be checked. - * @default 'clippingAncestors' - */ - boundary: Boundary; - /** - * The root clipping area in which overflow will be checked. - * @default 'viewport' - */ - rootBoundary: RootBoundary; - /** - * The element in which overflow is being checked relative to a boundary. - * @default 'floating' - */ - elementContext: ElementContext; - /** - * Whether to check for overflow using the alternate element's boundary - * (`clippingAncestors` boundary only). - * @default false - */ - altBoundary: boolean; - /** - * Virtual padding for the resolved overflow detection offsets. - * @default 0 - */ - padding: Padding; -}>; - -export { Dimensions } - -export declare type ElementContext = 'reference' | 'floating'; - -export { ElementRects } - -export declare interface Elements { - reference: ReferenceElement; - floating: FloatingElement; -} - -/** - * 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?: FlipOptions | Derivable) => Middleware; - -export declare type FlipOptions = Partial; - /** - * What strategy to use when no placements fit. - * @default 'bestFit' - */ - fallbackStrategy: 'bestFit' | 'initialPlacement'; - /** - * Whether to allow fallback to the perpendicular axis of the preferred - * placement, and if so, which side direction along the axis to prefer. - * @default 'none' (disallow fallback) - */ - fallbackAxisSideDirection: 'none' | 'start' | 'end'; - /** - * Whether to flip to placements with the opposite alignment if they fit - * better. - * @default true - */ - flipAlignment: boolean; -}>; - -export declare type FloatingElement = any; - -/** - * 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?: HideOptions | Derivable) => Middleware; - -export declare type HideOptions = Partial; - -/** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ -export declare const inline: (options?: InlineOptions | Derivable) => Middleware; - -export declare type InlineOptions = Partial<{ - /** - * Viewport-relative `x` coordinate to choose a `ClientRect`. - * @default undefined - */ - x: number; - /** - * Viewport-relative `y` coordinate to choose a `ClientRect`. - * @default undefined - */ - y: number; - /** - * Represents the padding around a disjoined rect when choosing it. - * @default 2 - */ - padding: Padding; -}>; - -export { Length } - -/** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ -export declare const limitShift: (options?: LimitShiftOptions | Derivable) => { - options: any; - fn: (state: MiddlewareState) => Coords; -}; - -declare type LimitShiftOffset = number | Partial<{ - /** - * Offset the limiting of the axis that runs along the alignment of the - * floating element. - */ - mainAxis: number; - /** - * Offset the limiting of the axis that runs along the side of the - * floating element. - */ - crossAxis: number; -}>; - -export declare type LimitShiftOptions = Partial<{ - /** - * Offset when limiting starts. `0` will limit when the opposite edges of the - * reference and floating elements are aligned. - * - positive = start limiting earlier - * - negative = start limiting later - */ - offset: LimitShiftOffset | Derivable; - /** - * Whether to limit the axis that runs along the alignment of the floating - * element. - */ - mainAxis: boolean; - /** - * Whether to limit the axis that runs along the side of the floating element. - */ - crossAxis: boolean; -}>; - -export declare type Middleware = { - name: string; - options?: any; - fn: (state: MiddlewareState) => Promisable; -}; - -/** - * @deprecated use `MiddlewareState` instead. - */ -export declare type MiddlewareArguments = MiddlewareState; - -export declare interface MiddlewareData { - [key: string]: any; - arrow?: Partial & { - centerOffset: number; - alignmentOffset?: number; - }; - autoPlacement?: { - index?: number; - overflows: Array<{ - placement: Placement; - overflows: Array; - }>; - }; - flip?: { - index?: number; - overflows: Array<{ - placement: Placement; - overflows: Array; - }>; - }; - hide?: { - referenceHidden?: boolean; - escaped?: boolean; - referenceHiddenOffsets?: SideObject; - escapedOffsets?: SideObject; - }; - offset?: Coords & { - placement: Placement; - }; - shift?: Coords; -} - -export declare interface MiddlewareReturn extends Partial { - data?: { - [key: string]: any; - }; - reset?: boolean | { - placement?: Placement; - rects?: boolean | ElementRects; - }; -} - -export declare interface MiddlewareState extends Coords { - initialPlacement: Placement; - placement: Placement; - strategy: Strategy; - middlewareData: MiddlewareData; - elements: Elements; - rects: ElementRects; - platform: Platform; -} - -/** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ -export declare const offset: (options?: OffsetOptions) => Middleware; - -export declare type OffsetOptions = OffsetValue | Derivable; - -declare type OffsetValue = number | Partial<{ - /** - * The axis that runs along the side of the floating element. Represents - * the distance (gutter or margin) between the reference and floating - * element. - * @default 0 - */ - mainAxis: number; - /** - * The axis that runs along the alignment of the floating element. - * Represents the skidding between the reference and floating element. - * @default 0 - */ - crossAxis: number; - /** - * The same axis as `crossAxis` but applies only to aligned placements - * and inverts the `end` alignment. When set to a number, it overrides the - * `crossAxis` value. - * - * A positive number will move the floating element in the direction of - * the opposite edge to the one that is aligned, while a negative number - * the reverse. - * @default null - */ - alignmentAxis: number | null; -}>; - -export { Padding } - -export { Placement } - -/** - * Platform interface methods to work with the current platform. - * @see https://floating-ui.com/docs/platform - */ -export declare interface Platform { - getElementRects: (args: { - reference: ReferenceElement; - floating: FloatingElement; - strategy: Strategy; - }) => Promisable; - getClippingRect: (args: { - element: any; - boundary: Boundary; - rootBoundary: RootBoundary; - strategy: Strategy; - }) => Promisable; - getDimensions: (element: any) => Promisable; - convertOffsetParentRelativeRectToViewportRelativeRect?: (args: { - elements?: Elements; - rect: Rect; - offsetParent: any; - strategy: Strategy; - }) => Promisable; - getOffsetParent?: (element: any) => Promisable; - isElement?: (value: any) => Promisable; - getDocumentElement?: (element: any) => Promisable; - getClientRects?: (element: any) => Promisable>; - isRTL?: (element: any) => Promisable; - getScale?: (element: any) => Promisable<{ - x: number; - y: number; - }>; -} - -declare type Promisable = T | Promise; - -export { Rect } - -export { rectToClientRect } - -export declare type ReferenceElement = any; - -export declare type RootBoundary = 'viewport' | 'document' | Rect; - -/** - * 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?: ShiftOptions | Derivable) => Middleware; - -export declare type ShiftOptions = Partial Coords; - options?: any; - }; -}>; - -export { Side } - -export { SideObject } - -/** - * 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?: SizeOptions | Derivable) => Middleware; - -export declare type SizeOptions = Partial; -}>; - -export { Strategy } - -export { VirtualElement } - -export { } diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.esm.js b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.esm.js deleted file mode 100644 index 74f6fd5..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.esm.js +++ /dev/null @@ -1,1025 +0,0 @@ -import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils'; -export { rectToClientRect } from '@floating-ui/utils'; - -function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === 'y'; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case 'top': - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case 'bottom': - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case 'right': - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case 'left': - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case 'start': - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case 'end': - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; - } - return coords; -} - -/** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ -const computePosition = async (reference, floating, config) => { - const { - placement = 'bottom', - strategy = 'absolute', - middleware = [], - platform - } = config; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); - let rects = await platform.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i = 0; i < validMiddleware.length; i++) { - const { - name, - fn - } = validMiddleware[i]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y = nextY != null ? nextY : y; - middlewareData = { - ...middlewareData, - [name]: { - ...middlewareData[name], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === 'object') { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); - } - i = -1; - } - } - return { - x, - y, - placement: statefulPlacement, - strategy, - middlewareData - }; -}; - -/** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ -async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; - } - const { - x, - y, - platform, - rects, - elements, - strategy - } = state; - const { - boundary = 'clippingAncestors', - rootBoundary = 'viewport', - elementContext = 'floating', - altBoundary = false, - padding = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding); - const altContext = elementContext === 'floating' ? 'reference' : 'floating'; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform.getClippingRect({ - element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === 'floating' ? { - x, - y, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); - const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; -} - -/** - * 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 - */ -const arrow = options => ({ - name: 'arrow', - options, - async fn(state) { - const { - x, - y, - placement, - rects, - platform, - elements, - middlewareData - } = state; - // Since `element` is required, we don't Partial<> the type. - const { - element, - padding = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; - } - const paddingObject = getPaddingObject(padding); - const coords = { - x, - y - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform.getDimensions(element); - const isYAxis = axis === 'y'; - const minProp = isYAxis ? 'top' : 'left'; - const maxProp = isYAxis ? 'bottom' : 'right'; - const clientProp = isYAxis ? 'clientHeight' : 'clientWidth'; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - - // DOM platform can return `window` as the `offsetParent`. - if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; - } - const centerToReference = endDiff / 2 - startDiff / 2; - - // If the padding is large enough that it causes the arrow to no longer be - // centered, modify the padding so that it is centered. - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); - - // Make sure the arrow doesn't overflow the floating element if the center - // point is outside the floating element's bounds. - const min$1 = minPadding; - const max = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset = clamp(min$1, center, max); - - // If the reference is small enough that the arrow's padding causes it to - // to point to nothing for an aligned placement, adjust the offset of the - // floating element itself. To ensure `shift()` continues to take action, - // a single reset is performed when this is true. - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset, - centerOffset: center - offset - alignmentOffset, - ...(shouldAddOffset && { - alignmentOffset - }) - }, - reset: shouldAddOffset - }; - } -}); - -function getPlacementList(alignment, autoAlignment, allowedPlacements) { - const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement); - return allowedPlacementsSortedByAlignment.filter(placement => { - if (alignment) { - return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false); - } - return true; - }); -} -/** - * 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 - */ -const autoPlacement = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'autoPlacement', - options, - async fn(state) { - var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; - const { - rects, - middlewareData, - placement, - platform, - elements - } = state; - const { - crossAxis = false, - alignment, - allowedPlacements = placements, - autoAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; - const overflow = await detectOverflow(state, detectOverflowOptions); - const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; - const currentPlacement = placements$1[currentIndex]; - if (currentPlacement == null) { - return {}; - } - const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); - - // Make `computeCoords` start from the right place. - if (placement !== currentPlacement) { - return { - reset: { - placement: placements$1[0] - } - }; - } - const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]]; - const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), { - placement: currentPlacement, - overflows: currentOverflows - }]; - const nextPlacement = placements$1[currentIndex + 1]; - - // There are more placements to check. - if (nextPlacement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: nextPlacement - } - }; - } - const placementsSortedByMostSpace = allOverflows.map(d => { - const alignment = getAlignment(d.placement); - return [d.placement, alignment && crossAxis ? - // Check along the mainAxis and main crossAxis side. - d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) : - // Check only the mainAxis. - d.overflows[0], d.overflows]; - }).sort((a, b) => a[1] - b[1]); - const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0, - // Aligned placements should not check their opposite crossAxis - // side. - getAlignment(d[0]) ? 2 : 3).every(v => v <= 0)); - const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; - if (resetPlacement !== placement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: resetPlacement - } - }; - } - return {}; - } - }; -}; - -/** - * 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 - */ -const flip = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'flip', - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = 'bestFit', - fallbackAxisSideDirection = 'none', - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - - // If a reset by the arrow was caused due to an alignment offset being - // added, we should skip any logic now since `flip()` has already done its - // work. - // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); - } - if (checkCrossAxis) { - const sides = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides[0]], overflow[sides[1]]); - } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - - // One or more sides is overflowing. - if (!overflows.every(side => side <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements[nextIndex]; - if (nextPlacement) { - // Try next placement and re-run the lifecycle. - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - - // First, find the candidates that fit on the mainAxis side of overflow, - // then find the placement that fits the best on the main crossAxis side. - let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - - // Otherwise fallback. - if (!resetPlacement) { - switch (fallbackStrategy) { - case 'bestFit': - { - var _overflowsData$map$so; - const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; - if (placement) { - resetPlacement = placement; - } - break; - } - case 'initialPlacement': - resetPlacement = initialPlacement; - break; - } - } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; - } - } - return {}; - } - }; -}; - -function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; -} -function isAnySideFullyClipped(overflow) { - return sides.some(side => overflow[side] >= 0); -} -/** - * 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 - */ -const hide = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'hide', - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = 'referenceHidden', - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case 'referenceHidden': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: 'reference' - }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; - } - case 'escaped': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: - { - return {}; - } - } - } - }; -}; - -function getBoundingRect(rects) { - const minX = min(...rects.map(rect => rect.left)); - const minY = min(...rects.map(rect => rect.top)); - const maxX = max(...rects.map(rect => rect.right)); - const maxY = max(...rects.map(rect => rect.bottom)); - return { - x: minX, - y: minY, - width: maxX - minX, - height: maxY - minY - }; -} -function getRectsByLine(rects) { - const sortedRects = rects.slice().sort((a, b) => a.y - b.y); - const groups = []; - let prevRect = null; - for (let i = 0; i < sortedRects.length; i++) { - const rect = sortedRects[i]; - if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) { - groups.push([rect]); - } else { - groups[groups.length - 1].push(rect); - } - prevRect = rect; - } - return groups.map(rect => rectToClientRect(getBoundingRect(rect))); -} -/** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ -const inline = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'inline', - options, - async fn(state) { - const { - placement, - elements, - rects, - platform, - strategy - } = state; - // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a - // ClientRect's bounds, despite the event listener being triggered. A - // padding of 2 seems to handle this issue. - const { - padding = 2, - x, - y - } = evaluate(options, state); - const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []); - const clientRects = getRectsByLine(nativeClientRects); - const fallback = rectToClientRect(getBoundingRect(nativeClientRects)); - const paddingObject = getPaddingObject(padding); - function getBoundingClientRect() { - // There are two rects and they are disjoined. - if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) { - // Find the first rect in which the point is fully inside. - return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback; - } - - // There are 2 or more connected rects. - if (clientRects.length >= 2) { - if (getSideAxis(placement) === 'y') { - const firstRect = clientRects[0]; - const lastRect = clientRects[clientRects.length - 1]; - const isTop = getSide(placement) === 'top'; - const top = firstRect.top; - const bottom = lastRect.bottom; - const left = isTop ? firstRect.left : lastRect.left; - const right = isTop ? firstRect.right : lastRect.right; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - const isLeftSide = getSide(placement) === 'left'; - const maxRight = max(...clientRects.map(rect => rect.right)); - const minLeft = min(...clientRects.map(rect => rect.left)); - const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight); - const top = measureRects[0].top; - const bottom = measureRects[measureRects.length - 1].bottom; - const left = minLeft; - const right = maxRight; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - return fallback; - } - const resetRects = await platform.getElementRects({ - reference: { - getBoundingClientRect - }, - floating: elements.floating, - strategy - }); - if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) { - return { - reset: { - rects: resetRects - } - }; - } - return {}; - } - }; -}; - -// For type backwards-compatibility, the `OffsetOptions` type was also -// Derivable. - -async function convertValueToCoords(state, options) { - const { - placement, - platform, - elements - } = state; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === 'y'; - const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - - // eslint-disable-next-line prefer-const - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === 'number' ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === 'number') { - crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; -} - -/** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ -const offset = function (options) { - if (options === void 0) { - options = 0; - } - return { - name: 'offset', - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - - // If the placement is the same and the arrow caused an alignment offset - // then we don't need to change the positioning coordinates. - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - return { - x: x + diffCoords.x, - y: y + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; -}; - -/** - * 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 - */ -const shift = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'shift', - options, - async fn(state) { - const { - x, - y, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: _ref => { - let { - x, - y - } = _ref; - return { - x, - y - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === 'y' ? 'top' : 'left'; - const maxSide = mainAxis === 'y' ? 'bottom' : 'right'; - const min = mainAxisCoord + overflow[minSide]; - const max = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp(min, mainAxisCoord, max); - } - if (checkCrossAxis) { - const minSide = crossAxis === 'y' ? 'top' : 'left'; - const maxSide = crossAxis === 'y' ? 'bottom' : 'right'; - const min = crossAxisCoord + overflow[minSide]; - const max = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp(min, crossAxisCoord, max); - } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y - } - }; - } - }; -}; -/** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ -const limitShift = function (options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y, - placement, - rects, - middlewareData - } = state; - const { - offset = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset, state); - const computedOffset = typeof rawOffset === 'number' ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === 'y' ? 'height' : 'width'; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === 'y' ? 'width' : 'height'; - const isOriginSide = ['top', 'left'].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } - } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; -}; - -/** - * 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 - */ -const size = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'size', - options, - async fn(state) { - const { - placement, - rects, - platform, - elements - } = state; - const { - apply = () => {}, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === 'y'; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === 'top' || side === 'bottom') { - heightSide = side; - widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right'; - } else { - widthSide = side; - heightSide = alignment === 'end' ? 'top' : 'bottom'; - } - const maximumClippingHeight = height - overflow.top - overflow.bottom; - const maximumClippingWidth = width - overflow.left - overflow.right; - const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); - const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); - } - } - await apply({ - ...state, - availableWidth, - availableHeight - }); - const nextDimensions = await platform.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; - } - return {}; - } - }; -}; - -export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size }; diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.mjs b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.mjs deleted file mode 100644 index 74f6fd5..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.mjs +++ /dev/null @@ -1,1025 +0,0 @@ -import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils'; -export { rectToClientRect } from '@floating-ui/utils'; - -function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === 'y'; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case 'top': - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case 'bottom': - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case 'right': - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case 'left': - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case 'start': - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case 'end': - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; - } - return coords; -} - -/** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ -const computePosition = async (reference, floating, config) => { - const { - placement = 'bottom', - strategy = 'absolute', - middleware = [], - platform - } = config; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); - let rects = await platform.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i = 0; i < validMiddleware.length; i++) { - const { - name, - fn - } = validMiddleware[i]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y = nextY != null ? nextY : y; - middlewareData = { - ...middlewareData, - [name]: { - ...middlewareData[name], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === 'object') { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); - } - i = -1; - } - } - return { - x, - y, - placement: statefulPlacement, - strategy, - middlewareData - }; -}; - -/** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ -async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; - } - const { - x, - y, - platform, - rects, - elements, - strategy - } = state; - const { - boundary = 'clippingAncestors', - rootBoundary = 'viewport', - elementContext = 'floating', - altBoundary = false, - padding = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding); - const altContext = elementContext === 'floating' ? 'reference' : 'floating'; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform.getClippingRect({ - element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === 'floating' ? { - x, - y, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); - const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; -} - -/** - * 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 - */ -const arrow = options => ({ - name: 'arrow', - options, - async fn(state) { - const { - x, - y, - placement, - rects, - platform, - elements, - middlewareData - } = state; - // Since `element` is required, we don't Partial<> the type. - const { - element, - padding = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; - } - const paddingObject = getPaddingObject(padding); - const coords = { - x, - y - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform.getDimensions(element); - const isYAxis = axis === 'y'; - const minProp = isYAxis ? 'top' : 'left'; - const maxProp = isYAxis ? 'bottom' : 'right'; - const clientProp = isYAxis ? 'clientHeight' : 'clientWidth'; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - - // DOM platform can return `window` as the `offsetParent`. - if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; - } - const centerToReference = endDiff / 2 - startDiff / 2; - - // If the padding is large enough that it causes the arrow to no longer be - // centered, modify the padding so that it is centered. - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); - - // Make sure the arrow doesn't overflow the floating element if the center - // point is outside the floating element's bounds. - const min$1 = minPadding; - const max = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset = clamp(min$1, center, max); - - // If the reference is small enough that the arrow's padding causes it to - // to point to nothing for an aligned placement, adjust the offset of the - // floating element itself. To ensure `shift()` continues to take action, - // a single reset is performed when this is true. - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset, - centerOffset: center - offset - alignmentOffset, - ...(shouldAddOffset && { - alignmentOffset - }) - }, - reset: shouldAddOffset - }; - } -}); - -function getPlacementList(alignment, autoAlignment, allowedPlacements) { - const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement); - return allowedPlacementsSortedByAlignment.filter(placement => { - if (alignment) { - return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false); - } - return true; - }); -} -/** - * 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 - */ -const autoPlacement = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'autoPlacement', - options, - async fn(state) { - var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; - const { - rects, - middlewareData, - placement, - platform, - elements - } = state; - const { - crossAxis = false, - alignment, - allowedPlacements = placements, - autoAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; - const overflow = await detectOverflow(state, detectOverflowOptions); - const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; - const currentPlacement = placements$1[currentIndex]; - if (currentPlacement == null) { - return {}; - } - const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); - - // Make `computeCoords` start from the right place. - if (placement !== currentPlacement) { - return { - reset: { - placement: placements$1[0] - } - }; - } - const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]]; - const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), { - placement: currentPlacement, - overflows: currentOverflows - }]; - const nextPlacement = placements$1[currentIndex + 1]; - - // There are more placements to check. - if (nextPlacement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: nextPlacement - } - }; - } - const placementsSortedByMostSpace = allOverflows.map(d => { - const alignment = getAlignment(d.placement); - return [d.placement, alignment && crossAxis ? - // Check along the mainAxis and main crossAxis side. - d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) : - // Check only the mainAxis. - d.overflows[0], d.overflows]; - }).sort((a, b) => a[1] - b[1]); - const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0, - // Aligned placements should not check their opposite crossAxis - // side. - getAlignment(d[0]) ? 2 : 3).every(v => v <= 0)); - const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; - if (resetPlacement !== placement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: resetPlacement - } - }; - } - return {}; - } - }; -}; - -/** - * 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 - */ -const flip = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'flip', - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = 'bestFit', - fallbackAxisSideDirection = 'none', - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - - // If a reset by the arrow was caused due to an alignment offset being - // added, we should skip any logic now since `flip()` has already done its - // work. - // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); - } - if (checkCrossAxis) { - const sides = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides[0]], overflow[sides[1]]); - } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - - // One or more sides is overflowing. - if (!overflows.every(side => side <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements[nextIndex]; - if (nextPlacement) { - // Try next placement and re-run the lifecycle. - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - - // First, find the candidates that fit on the mainAxis side of overflow, - // then find the placement that fits the best on the main crossAxis side. - let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - - // Otherwise fallback. - if (!resetPlacement) { - switch (fallbackStrategy) { - case 'bestFit': - { - var _overflowsData$map$so; - const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; - if (placement) { - resetPlacement = placement; - } - break; - } - case 'initialPlacement': - resetPlacement = initialPlacement; - break; - } - } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; - } - } - return {}; - } - }; -}; - -function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; -} -function isAnySideFullyClipped(overflow) { - return sides.some(side => overflow[side] >= 0); -} -/** - * 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 - */ -const hide = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'hide', - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = 'referenceHidden', - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case 'referenceHidden': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: 'reference' - }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; - } - case 'escaped': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: - { - return {}; - } - } - } - }; -}; - -function getBoundingRect(rects) { - const minX = min(...rects.map(rect => rect.left)); - const minY = min(...rects.map(rect => rect.top)); - const maxX = max(...rects.map(rect => rect.right)); - const maxY = max(...rects.map(rect => rect.bottom)); - return { - x: minX, - y: minY, - width: maxX - minX, - height: maxY - minY - }; -} -function getRectsByLine(rects) { - const sortedRects = rects.slice().sort((a, b) => a.y - b.y); - const groups = []; - let prevRect = null; - for (let i = 0; i < sortedRects.length; i++) { - const rect = sortedRects[i]; - if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) { - groups.push([rect]); - } else { - groups[groups.length - 1].push(rect); - } - prevRect = rect; - } - return groups.map(rect => rectToClientRect(getBoundingRect(rect))); -} -/** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ -const inline = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'inline', - options, - async fn(state) { - const { - placement, - elements, - rects, - platform, - strategy - } = state; - // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a - // ClientRect's bounds, despite the event listener being triggered. A - // padding of 2 seems to handle this issue. - const { - padding = 2, - x, - y - } = evaluate(options, state); - const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []); - const clientRects = getRectsByLine(nativeClientRects); - const fallback = rectToClientRect(getBoundingRect(nativeClientRects)); - const paddingObject = getPaddingObject(padding); - function getBoundingClientRect() { - // There are two rects and they are disjoined. - if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) { - // Find the first rect in which the point is fully inside. - return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback; - } - - // There are 2 or more connected rects. - if (clientRects.length >= 2) { - if (getSideAxis(placement) === 'y') { - const firstRect = clientRects[0]; - const lastRect = clientRects[clientRects.length - 1]; - const isTop = getSide(placement) === 'top'; - const top = firstRect.top; - const bottom = lastRect.bottom; - const left = isTop ? firstRect.left : lastRect.left; - const right = isTop ? firstRect.right : lastRect.right; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - const isLeftSide = getSide(placement) === 'left'; - const maxRight = max(...clientRects.map(rect => rect.right)); - const minLeft = min(...clientRects.map(rect => rect.left)); - const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight); - const top = measureRects[0].top; - const bottom = measureRects[measureRects.length - 1].bottom; - const left = minLeft; - const right = maxRight; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - return fallback; - } - const resetRects = await platform.getElementRects({ - reference: { - getBoundingClientRect - }, - floating: elements.floating, - strategy - }); - if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) { - return { - reset: { - rects: resetRects - } - }; - } - return {}; - } - }; -}; - -// For type backwards-compatibility, the `OffsetOptions` type was also -// Derivable. - -async function convertValueToCoords(state, options) { - const { - placement, - platform, - elements - } = state; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === 'y'; - const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - - // eslint-disable-next-line prefer-const - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === 'number' ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === 'number') { - crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; -} - -/** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ -const offset = function (options) { - if (options === void 0) { - options = 0; - } - return { - name: 'offset', - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - - // If the placement is the same and the arrow caused an alignment offset - // then we don't need to change the positioning coordinates. - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - return { - x: x + diffCoords.x, - y: y + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; -}; - -/** - * 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 - */ -const shift = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'shift', - options, - async fn(state) { - const { - x, - y, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: _ref => { - let { - x, - y - } = _ref; - return { - x, - y - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === 'y' ? 'top' : 'left'; - const maxSide = mainAxis === 'y' ? 'bottom' : 'right'; - const min = mainAxisCoord + overflow[minSide]; - const max = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp(min, mainAxisCoord, max); - } - if (checkCrossAxis) { - const minSide = crossAxis === 'y' ? 'top' : 'left'; - const maxSide = crossAxis === 'y' ? 'bottom' : 'right'; - const min = crossAxisCoord + overflow[minSide]; - const max = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp(min, crossAxisCoord, max); - } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y - } - }; - } - }; -}; -/** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ -const limitShift = function (options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y, - placement, - rects, - middlewareData - } = state; - const { - offset = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset, state); - const computedOffset = typeof rawOffset === 'number' ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === 'y' ? 'height' : 'width'; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === 'y' ? 'width' : 'height'; - const isOriginSide = ['top', 'left'].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } - } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; -}; - -/** - * 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 - */ -const size = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'size', - options, - async fn(state) { - const { - placement, - rects, - platform, - elements - } = state; - const { - apply = () => {}, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === 'y'; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === 'top' || side === 'bottom') { - heightSide = side; - widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right'; - } else { - widthSide = side; - heightSide = alignment === 'end' ? 'top' : 'bottom'; - } - const maximumClippingHeight = height - overflow.top - overflow.bottom; - const maximumClippingWidth = width - overflow.left - overflow.right; - const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); - const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); - } - } - await apply({ - ...state, - availableWidth, - availableHeight - }); - const nextDimensions = await platform.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; - } - return {}; - } - }; -}; - -export { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size }; diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.js b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.js deleted file mode 100644 index dcc5541..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.js +++ /dev/null @@ -1,1172 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUICore = {})); -})(this, (function (exports) { 'use strict'; - - /** - * Custom positioning reference element. - * @see https://floating-ui.com/docs/virtual-elements - */ - - const sides = ['top', 'right', 'bottom', 'left']; - const alignments = ['start', 'end']; - const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []); - const min = Math.min; - const max = Math.max; - const oppositeSideMap = { - left: 'right', - right: 'left', - bottom: 'top', - top: 'bottom' - }; - const oppositeAlignmentMap = { - start: 'end', - end: 'start' - }; - function clamp(start, value, end) { - return max(start, min(value, end)); - } - function evaluate(value, param) { - return typeof value === 'function' ? value(param) : value; - } - function getSide(placement) { - return placement.split('-')[0]; - } - function getAlignment(placement) { - return placement.split('-')[1]; - } - function getOppositeAxis(axis) { - return axis === 'x' ? 'y' : 'x'; - } - function getAxisLength(axis) { - return axis === 'y' ? 'height' : 'width'; - } - function getSideAxis(placement) { - return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x'; - } - function getAlignmentAxis(placement) { - return getOppositeAxis(getSideAxis(placement)); - } - function getAlignmentSides(placement, rects, rtl) { - if (rtl === void 0) { - rtl = false; - } - const alignment = getAlignment(placement); - const alignmentAxis = getAlignmentAxis(placement); - const length = getAxisLength(alignmentAxis); - let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top'; - if (rects.reference[length] > rects.floating[length]) { - mainAlignmentSide = getOppositePlacement(mainAlignmentSide); - } - return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; - } - function getExpandedPlacements(placement) { - const oppositePlacement = getOppositePlacement(placement); - return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; - } - function getOppositeAlignmentPlacement(placement) { - return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]); - } - function getSideList(side, isStart, rtl) { - const lr = ['left', 'right']; - const rl = ['right', 'left']; - const tb = ['top', 'bottom']; - const bt = ['bottom', 'top']; - switch (side) { - case 'top': - case 'bottom': - if (rtl) return isStart ? rl : lr; - return isStart ? lr : rl; - case 'left': - case 'right': - return isStart ? tb : bt; - default: - return []; - } - } - function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { - const alignment = getAlignment(placement); - let list = getSideList(getSide(placement), direction === 'start', rtl); - if (alignment) { - list = list.map(side => side + "-" + alignment); - if (flipAlignment) { - list = list.concat(list.map(getOppositeAlignmentPlacement)); - } - } - return list; - } - function getOppositePlacement(placement) { - return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]); - } - function expandPaddingObject(padding) { - return { - top: 0, - right: 0, - bottom: 0, - left: 0, - ...padding - }; - } - function getPaddingObject(padding) { - return typeof padding !== 'number' ? expandPaddingObject(padding) : { - top: padding, - right: padding, - bottom: padding, - left: padding - }; - } - function rectToClientRect(rect) { - const { - x, - y, - width, - height - } = rect; - return { - width, - height, - top: y, - left: x, - right: x + width, - bottom: y + height, - x, - y - }; - } - - function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === 'y'; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case 'top': - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case 'bottom': - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case 'right': - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case 'left': - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case 'start': - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case 'end': - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; - } - return coords; - } - - /** - * Computes the `x` and `y` coordinates that will place the floating element - * next to a given reference element. - * - * This export does not have any `platform` interface logic. You will need to - * write one for the platform you are using Floating UI with. - */ - const computePosition = async (reference, floating, config) => { - const { - placement = 'bottom', - strategy = 'absolute', - middleware = [], - platform - } = config; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); - let rects = await platform.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i = 0; i < validMiddleware.length; i++) { - const { - name, - fn - } = validMiddleware[i]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y = nextY != null ? nextY : y; - middlewareData = { - ...middlewareData, - [name]: { - ...middlewareData[name], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === 'object') { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); - } - i = -1; - } - } - return { - x, - y, - placement: statefulPlacement, - strategy, - middlewareData - }; - }; - - /** - * Resolves with an object of overflow side offsets that determine how much the - * element is overflowing a given clipping boundary on each side. - * - positive = overflowing the boundary by that number of pixels - * - negative = how many pixels left before it will overflow - * - 0 = lies flush with the boundary - * @see https://floating-ui.com/docs/detectOverflow - */ - async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; - } - const { - x, - y, - platform, - rects, - elements, - strategy - } = state; - const { - boundary = 'clippingAncestors', - rootBoundary = 'viewport', - elementContext = 'floating', - altBoundary = false, - padding = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding); - const altContext = elementContext === 'floating' ? 'reference' : 'floating'; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform.getClippingRect({ - element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === 'floating' ? { - x, - y, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); - const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; - } - - /** - * 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 - */ - const arrow = options => ({ - name: 'arrow', - options, - async fn(state) { - const { - x, - y, - placement, - rects, - platform, - elements, - middlewareData - } = state; - // Since `element` is required, we don't Partial<> the type. - const { - element, - padding = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; - } - const paddingObject = getPaddingObject(padding); - const coords = { - x, - y - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform.getDimensions(element); - const isYAxis = axis === 'y'; - const minProp = isYAxis ? 'top' : 'left'; - const maxProp = isYAxis ? 'bottom' : 'right'; - const clientProp = isYAxis ? 'clientHeight' : 'clientWidth'; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - - // DOM platform can return `window` as the `offsetParent`. - if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; - } - const centerToReference = endDiff / 2 - startDiff / 2; - - // If the padding is large enough that it causes the arrow to no longer be - // centered, modify the padding so that it is centered. - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); - - // Make sure the arrow doesn't overflow the floating element if the center - // point is outside the floating element's bounds. - const min$1 = minPadding; - const max = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset = clamp(min$1, center, max); - - // If the reference is small enough that the arrow's padding causes it to - // to point to nothing for an aligned placement, adjust the offset of the - // floating element itself. To ensure `shift()` continues to take action, - // a single reset is performed when this is true. - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset, - centerOffset: center - offset - alignmentOffset, - ...(shouldAddOffset && { - alignmentOffset - }) - }, - reset: shouldAddOffset - }; - } - }); - - function getPlacementList(alignment, autoAlignment, allowedPlacements) { - const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement); - return allowedPlacementsSortedByAlignment.filter(placement => { - if (alignment) { - return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false); - } - return true; - }); - } - /** - * 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 - */ - const autoPlacement = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'autoPlacement', - options, - async fn(state) { - var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; - const { - rects, - middlewareData, - placement, - platform, - elements - } = state; - const { - crossAxis = false, - alignment, - allowedPlacements = placements, - autoAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; - const overflow = await detectOverflow(state, detectOverflowOptions); - const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; - const currentPlacement = placements$1[currentIndex]; - if (currentPlacement == null) { - return {}; - } - const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); - - // Make `computeCoords` start from the right place. - if (placement !== currentPlacement) { - return { - reset: { - placement: placements$1[0] - } - }; - } - const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]]; - const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), { - placement: currentPlacement, - overflows: currentOverflows - }]; - const nextPlacement = placements$1[currentIndex + 1]; - - // There are more placements to check. - if (nextPlacement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: nextPlacement - } - }; - } - const placementsSortedByMostSpace = allOverflows.map(d => { - const alignment = getAlignment(d.placement); - return [d.placement, alignment && crossAxis ? - // Check along the mainAxis and main crossAxis side. - d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) : - // Check only the mainAxis. - d.overflows[0], d.overflows]; - }).sort((a, b) => a[1] - b[1]); - const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0, - // Aligned placements should not check their opposite crossAxis - // side. - getAlignment(d[0]) ? 2 : 3).every(v => v <= 0)); - const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; - if (resetPlacement !== placement) { - return { - data: { - index: currentIndex + 1, - overflows: allOverflows - }, - reset: { - placement: resetPlacement - } - }; - } - return {}; - } - }; - }; - - /** - * 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 - */ - const flip = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'flip', - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = 'bestFit', - fallbackAxisSideDirection = 'none', - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - - // If a reset by the arrow was caused due to an alignment offset being - // added, we should skip any logic now since `flip()` has already done its - // work. - // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); - } - if (checkCrossAxis) { - const sides = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides[0]], overflow[sides[1]]); - } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - - // One or more sides is overflowing. - if (!overflows.every(side => side <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements[nextIndex]; - if (nextPlacement) { - // Try next placement and re-run the lifecycle. - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - - // First, find the candidates that fit on the mainAxis side of overflow, - // then find the placement that fits the best on the main crossAxis side. - let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - - // Otherwise fallback. - if (!resetPlacement) { - switch (fallbackStrategy) { - case 'bestFit': - { - var _overflowsData$map$so; - const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; - if (placement) { - resetPlacement = placement; - } - break; - } - case 'initialPlacement': - resetPlacement = initialPlacement; - break; - } - } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; - } - } - return {}; - } - }; - }; - - function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; - } - function isAnySideFullyClipped(overflow) { - return sides.some(side => overflow[side] >= 0); - } - /** - * 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 - */ - const hide = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'hide', - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = 'referenceHidden', - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case 'referenceHidden': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: 'reference' - }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; - } - case 'escaped': - { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: - { - return {}; - } - } - } - }; - }; - - function getBoundingRect(rects) { - const minX = min(...rects.map(rect => rect.left)); - const minY = min(...rects.map(rect => rect.top)); - const maxX = max(...rects.map(rect => rect.right)); - const maxY = max(...rects.map(rect => rect.bottom)); - return { - x: minX, - y: minY, - width: maxX - minX, - height: maxY - minY - }; - } - function getRectsByLine(rects) { - const sortedRects = rects.slice().sort((a, b) => a.y - b.y); - const groups = []; - let prevRect = null; - for (let i = 0; i < sortedRects.length; i++) { - const rect = sortedRects[i]; - if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) { - groups.push([rect]); - } else { - groups[groups.length - 1].push(rect); - } - prevRect = rect; - } - return groups.map(rect => rectToClientRect(getBoundingRect(rect))); - } - /** - * Provides improved positioning for inline reference elements that can span - * over multiple lines, such as hyperlinks or range selections. - * @see https://floating-ui.com/docs/inline - */ - const inline = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'inline', - options, - async fn(state) { - const { - placement, - elements, - rects, - platform, - strategy - } = state; - // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a - // ClientRect's bounds, despite the event listener being triggered. A - // padding of 2 seems to handle this issue. - const { - padding = 2, - x, - y - } = evaluate(options, state); - const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []); - const clientRects = getRectsByLine(nativeClientRects); - const fallback = rectToClientRect(getBoundingRect(nativeClientRects)); - const paddingObject = getPaddingObject(padding); - function getBoundingClientRect() { - // There are two rects and they are disjoined. - if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) { - // Find the first rect in which the point is fully inside. - return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback; - } - - // There are 2 or more connected rects. - if (clientRects.length >= 2) { - if (getSideAxis(placement) === 'y') { - const firstRect = clientRects[0]; - const lastRect = clientRects[clientRects.length - 1]; - const isTop = getSide(placement) === 'top'; - const top = firstRect.top; - const bottom = lastRect.bottom; - const left = isTop ? firstRect.left : lastRect.left; - const right = isTop ? firstRect.right : lastRect.right; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - const isLeftSide = getSide(placement) === 'left'; - const maxRight = max(...clientRects.map(rect => rect.right)); - const minLeft = min(...clientRects.map(rect => rect.left)); - const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight); - const top = measureRects[0].top; - const bottom = measureRects[measureRects.length - 1].bottom; - const left = minLeft; - const right = maxRight; - const width = right - left; - const height = bottom - top; - return { - top, - bottom, - left, - right, - width, - height, - x: left, - y: top - }; - } - return fallback; - } - const resetRects = await platform.getElementRects({ - reference: { - getBoundingClientRect - }, - floating: elements.floating, - strategy - }); - if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) { - return { - reset: { - rects: resetRects - } - }; - } - return {}; - } - }; - }; - - // For type backwards-compatibility, the `OffsetOptions` type was also - // Derivable. - - async function convertValueToCoords(state, options) { - const { - placement, - platform, - elements - } = state; - const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === 'y'; - const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - - // eslint-disable-next-line prefer-const - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === 'number' ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === 'number') { - crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; - } - - /** - * Modifies the placement by translating the floating element along the - * specified axes. - * A number (shorthand for `mainAxis` or distance), or an axes configuration - * object may be passed. - * @see https://floating-ui.com/docs/offset - */ - const offset = function (options) { - if (options === void 0) { - options = 0; - } - return { - name: 'offset', - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - - // If the placement is the same and the arrow caused an alignment offset - // then we don't need to change the positioning coordinates. - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - return { - x: x + diffCoords.x, - y: y + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; - }; - - /** - * 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 - */ - const shift = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'shift', - options, - async fn(state) { - const { - x, - y, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: _ref => { - let { - x, - y - } = _ref; - return { - x, - y - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === 'y' ? 'top' : 'left'; - const maxSide = mainAxis === 'y' ? 'bottom' : 'right'; - const min = mainAxisCoord + overflow[minSide]; - const max = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp(min, mainAxisCoord, max); - } - if (checkCrossAxis) { - const minSide = crossAxis === 'y' ? 'top' : 'left'; - const maxSide = crossAxis === 'y' ? 'bottom' : 'right'; - const min = crossAxisCoord + overflow[minSide]; - const max = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp(min, crossAxisCoord, max); - } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y - } - }; - } - }; - }; - /** - * Built-in `limiter` that will stop `shift()` at a certain point. - */ - const limitShift = function (options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y, - placement, - rects, - middlewareData - } = state; - const { - offset = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset, state); - const computedOffset = typeof rawOffset === 'number' ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === 'y' ? 'height' : 'width'; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === 'y' ? 'width' : 'height'; - const isOriginSide = ['top', 'left'].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } - } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; - }; - - /** - * 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 - */ - const size = function (options) { - if (options === void 0) { - options = {}; - } - return { - name: 'size', - options, - async fn(state) { - const { - placement, - rects, - platform, - elements - } = state; - const { - apply = () => {}, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === 'y'; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === 'top' || side === 'bottom') { - heightSide = side; - widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right'; - } else { - widthSide = side; - heightSide = alignment === 'end' ? 'top' : 'bottom'; - } - const maximumClippingHeight = height - overflow.top - overflow.bottom; - const maximumClippingWidth = width - overflow.left - overflow.right; - const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); - const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); - } - } - await apply({ - ...state, - availableWidth, - availableHeight - }); - const nextDimensions = await platform.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; - } - return {}; - } - }; - }; - - exports.arrow = arrow; - exports.autoPlacement = autoPlacement; - exports.computePosition = computePosition; - exports.detectOverflow = detectOverflow; - exports.flip = flip; - exports.hide = hide; - exports.inline = inline; - exports.limitShift = limitShift; - exports.offset = offset; - exports.rectToClientRect = rectToClientRect; - exports.shift = shift; - exports.size = size; - -})); diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.min.js b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.min.js deleted file mode 100644 index 3cbbcb2..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/dist/floating-ui.core.umd.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUICore={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],i=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),o=Math.min,r=Math.max,a={left:"right",right:"left",bottom:"top",top:"bottom"},l={start:"end",end:"start"};function s(t,e,n){return r(t,o(e,n))}function f(t,e){return"function"==typeof t?t(e):t}function c(t){return t.split("-")[0]}function u(t){return t.split("-")[1]}function m(t){return"x"===t?"y":"x"}function d(t){return"y"===t?"height":"width"}function g(t){return["top","bottom"].includes(c(t))?"y":"x"}function p(t){return m(g(t))}function h(t,e,n){void 0===n&&(n=!1);const i=u(t),o=p(t),r=d(o);let a="x"===o?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=w(a)),[a,w(a)]}function y(t){return t.replace(/start|end/g,(t=>l[t]))}function w(t){return t.replace(/left|right|bottom|top/g,(t=>a[t]))}function x(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function v(t){const{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function b(t,e,n){let{reference:i,floating:o}=t;const r=g(e),a=p(e),l=d(a),s=c(e),f="y"===r,m=i.x+i.width/2-o.width/2,h=i.y+i.height/2-o.height/2,y=i[l]/2-o[l]/2;let w;switch(s){case"top":w={x:m,y:i.y-o.height};break;case"bottom":w={x:m,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:h};break;case"left":w={x:i.x-o.width,y:h};break;default:w={x:i.x,y:i.y}}switch(u(e)){case"start":w[a]-=y*(n&&f?-1:1);break;case"end":w[a]+=y*(n&&f?-1:1)}return w}async function A(t,e){var n;void 0===e&&(e={});const{x:i,y:o,platform:r,rects:a,elements:l,strategy:s}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:d=!1,padding:g=0}=f(e,t),p=x(g),h=l[d?"floating"===m?"reference":"floating":m],y=v(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(h)))||n?h:h.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:s})),w="floating"===m?{x:i,y:o,width:a.floating.width,height:a.floating.height}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(l.floating)),A=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},R=v(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:b,strategy:s}):w);return{top:(y.top-R.top+p.top)/A.y,bottom:(R.bottom-y.bottom+p.bottom)/A.y,left:(y.left-R.left+p.left)/A.x,right:(R.right-y.right+p.right)/A.x}}function R(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function P(t){return e.some((e=>t[e]>=0))}function T(t){const e=o(...t.map((t=>t.left))),n=o(...t.map((t=>t.top)));return{x:e,y:n,width:r(...t.map((t=>t.right)))-e,height:r(...t.map((t=>t.bottom)))-n}}t.arrow=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:a,platform:l,elements:c,middlewareData:m}=e,{element:g,padding:h=0}=f(t,e)||{};if(null==g)return{};const y=x(h),w={x:n,y:i},v=p(r),b=d(v),A=await l.getDimensions(g),R="y"===v,P=R?"top":"left",T=R?"bottom":"right",D=R?"clientHeight":"clientWidth",O=a.reference[b]+a.reference[v]-w[v]-a.floating[b],E=w[v]-a.reference[v],L=await(null==l.getOffsetParent?void 0:l.getOffsetParent(g));let k=L?L[D]:0;k&&await(null==l.isElement?void 0:l.isElement(L))||(k=c.floating[D]||a.floating[b]);const C=O/2-E/2,B=k/2-A[b]/2-1,H=o(y[P],B),S=o(y[T],B),F=H,j=k-A[b]-S,z=k/2-A[b]/2+C,M=s(F,z,j),V=!m.arrow&&null!=u(r)&&z!==M&&a.reference[b]/2-(zu(e)===t)),...n.filter((e=>u(e)!==t))]:n.filter((t=>c(t)===t))).filter((n=>!t||u(n)===t||!!e&&y(n)!==n))}(p||null,x,w):w,R=await A(e,v),P=(null==(n=l.autoPlacement)?void 0:n.index)||0,T=b[P];if(null==T)return{};const D=h(T,a,await(null==m.isRTL?void 0:m.isRTL(d.floating)));if(s!==T)return{reset:{placement:b[0]}};const O=[R[c(T)],R[D[0]],R[D[1]]],E=[...(null==(o=l.autoPlacement)?void 0:o.overflows)||[],{placement:T,overflows:O}],L=b[P+1];if(L)return{data:{index:P+1,overflows:E},reset:{placement:L}};const k=E.map((t=>{const e=u(t.placement);return[t.placement,e&&g?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),C=(null==(r=k.filter((t=>t[2].slice(0,u(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||k[0][0];return C!==s?{data:{index:P+1,overflows:E},reset:{placement:C}}:{}}}},t.computePosition=async(t,e,n)=>{const{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:a}=n,l=r.filter(Boolean),s=await(null==a.isRTL?void 0:a.isRTL(e));let f=await a.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:u}=b(f,i,s),m=i,d={},g=0;for(let n=0;nt+"-"+o)),e&&(r=r.concat(r.map(y)))),r}(l,b,v,D));const E=[l,...O],L=await A(e,R),k=[];let C=(null==(i=r.flip)?void 0:i.overflows)||[];if(d&&k.push(L[P]),g){const t=h(o,a,D);k.push(L[t[0]],L[t[1]])}if(C=[...C,{placement:o,overflows:k}],!k.every((t=>t<=0))){var B,H;const t=((null==(B=r.flip)?void 0:B.index)||0)+1,e=E[t];if(e)return{data:{index:t,overflows:C},reset:{placement:e}};let n=null==(H=C.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:H.placement;if(!n)switch(x){case"bestFit":{var S;const t=null==(S=C.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:S[0];t&&(n=t);break}case"initialPlacement":n=l}if(o!==n)return{reset:{placement:n}}}return{}}}},t.hide=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:i="referenceHidden",...o}=f(t,e);switch(i){case"referenceHidden":{const t=R(await A(e,{...o,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:P(t)}}}case"escaped":{const t=R(await A(e,{...o,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:P(t)}}}default:return{}}}}},t.inline=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:i,rects:a,platform:l,strategy:s}=e,{padding:u=2,x:m,y:d}=f(t,e),p=Array.from(await(null==l.getClientRects?void 0:l.getClientRects(i.reference))||[]),h=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let i=null;for(let t=0;ti.height/2?n.push([o]):n[n.length-1].push(o),i=o}return n.map((t=>v(T(t))))}(p),y=v(T(p)),w=x(u);const b=await l.getElementRects({reference:{getBoundingClientRect:function(){if(2===h.length&&h[0].left>h[1].right&&null!=m&&null!=d)return h.find((t=>m>t.left-w.left&&mt.top-w.top&&d=2){if("y"===g(n)){const t=h[0],e=h[h.length-1],i="top"===c(n),o=t.top,r=e.bottom,a=i?t.left:e.left,l=i?t.right:e.right;return{top:o,bottom:r,left:a,right:l,width:l-a,height:r-o,x:a,y:o}}const t="left"===c(n),e=r(...h.map((t=>t.right))),i=o(...h.map((t=>t.left))),a=h.filter((n=>t?n.left===i:n.right===e)),l=a[0].top,s=a[a.length-1].bottom;return{top:l,bottom:s,left:i,right:e,width:e-i,height:s-l,x:i,y:l}}return y}},floating:i.floating,strategy:s});return a.reference.x!==b.reference.x||a.reference.y!==b.reference.y||a.reference.width!==b.reference.width||a.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}},t.limitShift=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:i,placement:o,rects:r,middlewareData:a}=e,{offset:l=0,mainAxis:s=!0,crossAxis:u=!0}=f(t,e),d={x:n,y:i},p=g(o),h=m(p);let y=d[h],w=d[p];const x=f(l,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(s){const t="y"===h?"height":"width",e=r.reference[h]-r.floating[t]+v.mainAxis,n=r.reference[h]+r.reference[t]-v.mainAxis;yn&&(y=n)}if(u){var b,A;const t="y"===h?"width":"height",e=["top","left"].includes(c(o)),n=r.reference[p]-r.floating[t]+(e&&(null==(b=a.offset)?void 0:b[p])||0)+(e?0:v.crossAxis),i=r.reference[p]+r.reference[t]+(e?0:(null==(A=a.offset)?void 0:A[p])||0)-(e?v.crossAxis:0);wi&&(w=i)}return{[h]:y,[p]:w}}}},t.offset=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:o,y:r,placement:a,middlewareData:l}=e,s=await async function(t,e){const{placement:n,platform:i,elements:o}=t,r=await(null==i.isRTL?void 0:i.isRTL(o.floating)),a=c(n),l=u(n),s="y"===g(n),m=["left","top"].includes(a)?-1:1,d=r&&s?-1:1,p=f(e,t);let{mainAxis:h,crossAxis:y,alignmentAxis:w}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return l&&"number"==typeof w&&(y="end"===l?-1*w:w),s?{x:y*d,y:h*m}:{x:h*m,y:y*d}}(e,t);return a===(null==(n=l.offset)?void 0:n.placement)&&null!=(i=l.arrow)&&i.alignmentOffset?{}:{x:o+s.x,y:r+s.y,data:{...s,placement:a}}}}},t.rectToClientRect=v,t.shift=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:o}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...u}=f(t,e),d={x:n,y:i},p=await A(e,u),h=g(c(o)),y=m(h);let w=d[y],x=d[h];if(r){const t="y"===y?"bottom":"right";w=s(w+p["y"===y?"top":"left"],w,w-p[t])}if(a){const t="y"===h?"bottom":"right";x=s(x+p["y"===h?"top":"left"],x,x-p[t])}const v=l.fn({...e,[y]:w,[h]:x});return{...v,data:{x:v.x-n,y:v.y-i}}}}},t.size=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:i,platform:a,elements:l}=e,{apply:s=(()=>{}),...m}=f(t,e),d=await A(e,m),p=c(n),h=u(n),y="y"===g(n),{width:w,height:x}=i.floating;let v,b;"top"===p||"bottom"===p?(v=p,b=h===(await(null==a.isRTL?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,v="end"===h?"top":"bottom");const R=x-d.top-d.bottom,P=w-d.left-d.right,T=o(x-d[v],R),D=o(w-d[b],P),O=!e.middlewareData.shift;let E=T,L=D;if(y?L=h||O?o(D,P):P:E=h||O?o(T,R):R,O&&!h){const t=r(d.left,0),e=r(d.right,0),n=r(d.top,0),i=r(d.bottom,0);y?L=w-2*(0!==t||0!==e?t+e:r(d.left,d.right)):E=x-2*(0!==n||0!==i?n+i:r(d.top,d.bottom))}await s({...e,availableWidth:L,availableHeight:E});const k=await a.getDimensions(l.floating);return w!==k.width||x!==k.height?{reset:{rects:!0}}:{}}}}})); diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/package.json b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/package.json deleted file mode 100644 index 03069d3..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/core/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@floating-ui/core", - "version": "1.6.2", - "description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more", - "publishConfig": { - "access": "public" - }, - "main": "./dist/floating-ui.core.umd.js", - "module": "./dist/floating-ui.core.esm.js", - "unpkg": "./dist/floating-ui.core.umd.min.js", - "types": "./dist/floating-ui.core.d.ts", - "exports": { - "./package.json": "./package.json", - ".": { - "import": { - "types": "./dist/floating-ui.core.d.mts", - "default": "./dist/floating-ui.core.mjs" - }, - "types": "./dist/floating-ui.core.d.ts", - "module": "./dist/floating-ui.core.esm.js", - "default": "./dist/floating-ui.core.umd.js" - } - }, - "sideEffects": false, - "files": [ - "dist" - ], - "author": "atomiks", - "license": "MIT", - "bugs": "https://github.com/floating-ui/floating-ui", - "repository": { - "type": "git", - "url": "https://github.com/floating-ui/floating-ui.git", - "directory": "packages/core" - }, - "homepage": "https://floating-ui.com", - "keywords": [ - "tooltip", - "popover", - "dropdown", - "menu", - "popup", - "positioning" - ], - "dependencies": { - "@floating-ui/utils": "^0.2.0" - }, - "devDependencies": { - "config": "0.0.0" - }, - "scripts": { - "test": "vitest run", - "test:watch": "vitest watch", - "lint": "eslint .", - "format": "prettier --write .", - "clean": "rimraf dist out-tsc", - "dev": "rollup -c -w", - "build": "rollup -c", - "build:api": "build-api --tsc tsconfig.lib.json", - "publint": "publint", - "typecheck": "tsc -b" - } -} \ No newline at end of file diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/LICENSE b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/LICENSE deleted file mode 100644 index 639cdc6..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright (c) 2021-present Floating UI contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/README.md b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/README.md deleted file mode 100644 index 47ef927..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# @floating-ui/dom - -This is the library to use Floating UI on the web, wrapping `@floating-ui/core` -with DOM interface logic. diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs deleted file mode 100644 index a455a0f..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs +++ /dev/null @@ -1 +0,0 @@ -import{rectToClientRect as t,detectOverflow as e,offset as n,autoPlacement as o,shift as i,flip as r,size as c,hide as l,arrow as s,inline as f,limitShift as u,computePosition as a}from"../../core/dist/floating-ui.core.browser.min.mjs";const d=Math.min,h=Math.max,p=Math.round,m=Math.floor,g=t=>({x:t,y:t});function y(t){return x(t)?(t.nodeName||"").toLowerCase():"#document"}function w(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function v(t){var e;return null==(e=(x(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function x(t){return t instanceof Node||t instanceof w(t).Node}function b(t){return t instanceof Element||t instanceof w(t).Element}function L(t){return t instanceof HTMLElement||t instanceof w(t).HTMLElement}function T(t){return"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof w(t).ShadowRoot)}function R(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=O(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function E(t){return["table","td","th"].includes(y(t))}function S(t){const e=C(),n=O(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function C(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function F(t){return["html","body","#document"].includes(y(t))}function O(t){return w(t).getComputedStyle(t)}function D(t){return b(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function H(t){if("html"===y(t))return t;const e=t.assignedSlot||t.parentNode||T(t)&&t.host||v(t);return T(e)?e.host:e}function W(t){const e=H(t);return F(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&R(e)?e:W(e)}function M(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=W(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),c=w(i);return r?e.concat(c,c.visualViewport||[],R(i)?i:[],c.frameElement&&n?M(c.frameElement):[]):e.concat(i,M(i,[],n))}function z(t){const e=O(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=L(t),r=i?t.offsetWidth:n,c=i?t.offsetHeight:o,l=p(n)!==r||p(o)!==c;return l&&(n=r,o=c),{width:n,height:o,$:l}}function P(t){return b(t)?t:t.contextElement}function V(t){const e=P(t);if(!L(e))return g(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=z(e);let c=(r?p(n.width):n.width)/o,l=(r?p(n.height):n.height)/i;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const A=g(0);function N(t){const e=w(t);return C()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:A}function B(e,n,o,i){void 0===n&&(n=!1),void 0===o&&(o=!1);const r=e.getBoundingClientRect(),c=P(e);let l=g(1);n&&(i?b(i)&&(l=V(i)):l=V(e));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==w(t))&&e}(c,o,i)?N(c):g(0);let f=(r.left+s.x)/l.x,u=(r.top+s.y)/l.y,a=r.width/l.x,d=r.height/l.y;if(c){const t=w(c),e=i&&b(i)?w(i):i;let n=t,o=n.frameElement;for(;o&&i&&e!==n;){const t=V(o),e=o.getBoundingClientRect(),i=O(o),r=e.left+(o.clientLeft+parseFloat(i.paddingLeft))*t.x,c=e.top+(o.clientTop+parseFloat(i.paddingTop))*t.y;f*=t.x,u*=t.y,a*=t.x,d*=t.y,f+=r,u+=c,n=w(o),o=n.frameElement}}return t({width:a,height:d,x:f,y:u})}const k=[":popover-open",":modal"];function I(t){return k.some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function q(t){return B(v(t)).left+D(t).scrollLeft}function X(e,n,o){let i;if("viewport"===n)i=function(t,e){const n=w(t),o=v(t),i=n.visualViewport;let r=o.clientWidth,c=o.clientHeight,l=0,s=0;if(i){r=i.width,c=i.height;const t=C();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,s=i.offsetTop)}return{width:r,height:c,x:l,y:s}}(e,o);else if("document"===n)i=function(t){const e=v(t),n=D(t),o=t.ownerDocument.body,i=h(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=h(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+q(t);const l=-n.scrollTop;return"rtl"===O(o).direction&&(c+=h(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:c,y:l}}(v(e));else if(b(n))i=function(t,e){const n=B(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=L(t)?V(t):g(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(n,o);else{const t=N(e);i={...n,x:n.x-t.x,y:n.y-t.y}}return t(i)}function Y(t,e){const n=H(t);return!(n===e||!b(n)||F(n))&&("fixed"===O(n).position||Y(n,e))}function $(t,e,n){const o=L(e),i=v(e),r="fixed"===n,c=B(t,!0,r,e);let l={scrollLeft:0,scrollTop:0};const s=g(0);if(o||!o&&!r)if(("body"!==y(e)||R(i))&&(l=D(e)),o){const t=B(e,!0,r,e);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&(s.x=q(i));return{x:c.left+l.scrollLeft-s.x,y:c.top+l.scrollTop-s.y,width:c.width,height:c.height}}function _(t){return"static"===O(t).position}function j(t,e){return L(t)&&"fixed"!==O(t).position?e?e(t):t.offsetParent:null}function G(t,e){const n=w(t);if(I(t))return n;if(!L(t)){let e=H(t);for(;e&&!F(e);){if(b(e)&&!_(e))return e;e=H(e)}return n}let o=j(t,e);for(;o&&E(o)&&_(o);)o=j(o,e);return o&&F(o)&&_(o)&&!S(o)?n:o||function(t){let e=H(t);for(;L(e)&&!F(e);){if(S(e))return e;e=H(e)}return null}(t)||n}const J={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,c=v(o),l=!!e&&I(e.floating);if(o===c||l&&r)return n;let s={scrollLeft:0,scrollTop:0},f=g(1);const u=g(0),a=L(o);if((a||!a&&!r)&&(("body"!==y(o)||R(c))&&(s=D(o)),L(o))){const t=B(o);f=V(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-s.scrollLeft*f.x+u.x,y:n.y*f.y-s.scrollTop*f.y+u.y}},getDocumentElement:v,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?I(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=M(t,[],!1).filter((t=>b(t)&&"body"!==y(t))),i=null;const r="fixed"===O(t).position;let c=r?H(t):t;for(;b(c)&&!F(c);){const e=O(c),n=S(c);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||R(c)&&!n&&Y(t,c))?o=o.filter((t=>t!==c)):i=e,c=H(c)}return e.set(t,o),o}(e,this._c):[].concat(n),o],c=r[0],l=r.reduce(((t,n)=>{const o=X(e,n,i);return t.top=h(o.top,t.top),t.right=d(o.right,t.right),t.bottom=d(o.bottom,t.bottom),t.left=h(o.left,t.left),t}),X(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:G,getElementRects:async function(t){const e=this.getOffsetParent||G,n=this.getDimensions,o=await n(t.floating);return{reference:$(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=z(t);return{width:e,height:n}},getScale:V,isElement:b,isRTL:function(t){return"rtl"===O(t).direction}};function K(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:c="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,f=P(t),u=i||r?[...f?M(f):[],...M(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const a=f&&l?function(t,e){let n,o=null;const i=v(t);function r(){var t;clearTimeout(n),null==(t=o)||t.disconnect(),o=null}return function c(l,s){void 0===l&&(l=!1),void 0===s&&(s=1),r();const{left:f,top:u,width:a,height:p}=t.getBoundingClientRect();if(l||e(),!a||!p)return;const g={rootMargin:-m(u)+"px "+-m(i.clientWidth-(f+a))+"px "+-m(i.clientHeight-(u+p))+"px "+-m(f)+"px",threshold:h(0,d(1,s))||1};let y=!0;function w(t){const e=t[0].intersectionRatio;if(e!==s){if(!y)return c();e?c(!1,e):n=setTimeout((()=>{c(!1,1e-7)}),1e3)}y=!1}try{o=new IntersectionObserver(w,{...g,root:i.ownerDocument})}catch(t){o=new IntersectionObserver(w,g)}o.observe(t)}(!0),r}(f,n):null;let p,g=-1,y=null;c&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===f&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame((()=>{var t;null==(t=y)||t.observe(e)}))),n()})),f&&!s&&y.observe(f),y.observe(e));let w=s?B(t):null;return s&&function e(){const o=B(t);!w||o.x===w.x&&o.y===w.y&&o.width===w.width&&o.height===w.height||n();w=o,p=requestAnimationFrame(e)}(),n(),()=>{var t;u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),null==a||a(),null==(t=y)||t.disconnect(),y=null,s&&cancelAnimationFrame(p)}}const Q=e,U=n,Z=o,tt=i,et=r,nt=c,ot=l,it=s,rt=f,ct=u,lt=(t,e,n)=>{const o=new Map,i={platform:J,...n},r={...i.platform,_c:o};return a(t,e,{...i,platform:r})};export{it as arrow,Z as autoPlacement,K as autoUpdate,lt as computePosition,Q as detectOverflow,et as flip,M as getOverflowAncestors,ot as hide,rt as inline,ct as limitShift,U as offset,J as platform,tt as shift,nt as size}; diff --git a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.mjs b/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.mjs deleted file mode 100644 index 26ac042..0000000 --- a/src/HeadlessBlazor.Core/wwwroot/@floating-ui/dom/dist/floating-ui.dom.browser.mjs +++ /dev/null @@ -1,852 +0,0 @@ -import { rectToClientRect, detectOverflow as detectOverflow$1, offset as offset$1, autoPlacement as autoPlacement$1, shift as shift$1, flip as flip$1, size as size$1, hide as hide$1, arrow as arrow$1, inline as inline$1, limitShift as limitShift$1, computePosition as computePosition$1 } from '@floating-ui/core'; - -/** - * Custom positioning reference element. - * @see https://floating-ui.com/docs/virtual-elements - */ - -const min = Math.min; -const max = Math.max; -const round = Math.round; -const floor = Math.floor; -const createCoords = v => ({ - x: v, - y: v -}); - -function getNodeName(node) { - if (isNode(node)) { - return (node.nodeName || '').toLowerCase(); - } - // Mocked nodes in testing environments may not be instances of Node. By - // returning `#document` an infinite loop won't occur. - // https://github.com/floating-ui/floating-ui/issues/2317 - return '#document'; -} -function getWindow(node) { - var _node$ownerDocument; - return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; -} -function getDocumentElement(node) { - var _ref; - return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; -} -function isNode(value) { - return value instanceof Node || value instanceof getWindow(value).Node; -} -function isElement(value) { - return value instanceof Element || value instanceof getWindow(value).Element; -} -function isHTMLElement(value) { - return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; -} -function isShadowRoot(value) { - // Browsers without `ShadowRoot` support. - if (typeof ShadowRoot === 'undefined') { - return false; - } - return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; -} -function isOverflowElement(element) { - const { - overflow, - overflowX, - overflowY, - display - } = getComputedStyle(element); - return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display); -} -function isTableElement(element) { - return ['table', 'td', 'th'].includes(getNodeName(element)); -} -function isContainingBlock(element) { - const webkit = isWebKit(); - const css = getComputedStyle(element); - - // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block - return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value)); -} -function getContainingBlock(element) { - let currentNode = getParentNode(element); - while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { - if (isContainingBlock(currentNode)) { - return currentNode; - } - currentNode = getParentNode(currentNode); - } - return null; -} -function isWebKit() { - if (typeof CSS === 'undefined' || !CSS.supports) return false; - return CSS.supports('-webkit-backdrop-filter', 'none'); -} -function isLastTraversableNode(node) { - return ['html', 'body', '#document'].includes(getNodeName(node)); -} -function getComputedStyle(element) { - return getWindow(element).getComputedStyle(element); -} -function getNodeScroll(element) { - if (isElement(element)) { - return { - scrollLeft: element.scrollLeft, - scrollTop: element.scrollTop - }; - } - return { - scrollLeft: element.pageXOffset, - scrollTop: element.pageYOffset - }; -} -function getParentNode(node) { - if (getNodeName(node) === 'html') { - return node; - } - const result = - // Step into the shadow DOM of the parent of a slotted node. - node.assignedSlot || - // DOM Element detected. - node.parentNode || - // ShadowRoot detected. - isShadowRoot(node) && node.host || - // Fallback. - getDocumentElement(node); - return isShadowRoot(result) ? result.host : result; -} -function getNearestOverflowAncestor(node) { - const parentNode = getParentNode(node); - if (isLastTraversableNode(parentNode)) { - return node.ownerDocument ? node.ownerDocument.body : node.body; - } - if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { - return parentNode; - } - return getNearestOverflowAncestor(parentNode); -} -function getOverflowAncestors(node, list, traverseIframes) { - var _node$ownerDocument2; - if (list === void 0) { - list = []; - } - if (traverseIframes === void 0) { - traverseIframes = true; - } - const scrollableAncestor = getNearestOverflowAncestor(node); - const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); - const win = getWindow(scrollableAncestor); - if (isBody) { - return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []); - } - return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); -} - -function getCssDimensions(element) { - const css = getComputedStyle(element); - // In testing environments, the `width` and `height` properties are empty - // strings for SVG elements, returning NaN. Fallback to `0` in this case. - let width = parseFloat(css.width) || 0; - let height = parseFloat(css.height) || 0; - const hasOffset = isHTMLElement(element); - const offsetWidth = hasOffset ? element.offsetWidth : width; - const offsetHeight = hasOffset ? element.offsetHeight : height; - const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; - if (shouldFallback) { - width = offsetWidth; - height = offsetHeight; - } - return { - width, - height, - $: shouldFallback - }; -} - -function unwrapElement(element) { - return !isElement(element) ? element.contextElement : element; -} - -function getScale(element) { - const domElement = unwrapElement(element); - if (!isHTMLElement(domElement)) { - return createCoords(1); - } - const rect = domElement.getBoundingClientRect(); - const { - width, - height, - $ - } = getCssDimensions(domElement); - let x = ($ ? round(rect.width) : rect.width) / width; - let y = ($ ? round(rect.height) : rect.height) / height; - - // 0, NaN, or Infinity should always fallback to 1. - - if (!x || !Number.isFinite(x)) { - x = 1; - } - if (!y || !Number.isFinite(y)) { - y = 1; - } - return { - x, - y - }; -} - -const noOffsets = /*#__PURE__*/createCoords(0); -function getVisualOffsets(element) { - const win = getWindow(element); - if (!isWebKit() || !win.visualViewport) { - return noOffsets; - } - return { - x: win.visualViewport.offsetLeft, - y: win.visualViewport.offsetTop - }; -} -function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { - if (isFixed === void 0) { - isFixed = false; - } - if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { - return false; - } - return isFixed; -} - -function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { - if (includeScale === void 0) { - includeScale = false; - } - if (isFixedStrategy === void 0) { - isFixedStrategy = false; - } - const clientRect = element.getBoundingClientRect(); - const domElement = unwrapElement(element); - let scale = createCoords(1); - if (includeScale) { - if (offsetParent) { - if (isElement(offsetParent)) { - scale = getScale(offsetParent); - } - } else { - scale = getScale(element); - } - } - const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); - let x = (clientRect.left + visualOffsets.x) / scale.x; - let y = (clientRect.top + visualOffsets.y) / scale.y; - let width = clientRect.width / scale.x; - let height = clientRect.height / scale.y; - if (domElement) { - const win = getWindow(domElement); - const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; - let currentWin = win; - let currentIFrame = currentWin.frameElement; - while (currentIFrame && offsetParent && offsetWin !== currentWin) { - const iframeScale = getScale(currentIFrame); - const iframeRect = currentIFrame.getBoundingClientRect(); - const css = getComputedStyle(currentIFrame); - const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; - const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; - x *= iframeScale.x; - y *= iframeScale.y; - width *= iframeScale.x; - height *= iframeScale.y; - x += left; - y += top; - currentWin = getWindow(currentIFrame); - currentIFrame = currentWin.frameElement; - } - } - return rectToClientRect({ - width, - height, - x, - y - }); -} - -const topLayerSelectors = [':popover-open', ':modal']; -function isTopLayer(element) { - return topLayerSelectors.some(selector => { - try { - return element.matches(selector); - } catch (e) { - return false; - } - }); -} - -function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { - let { - elements, - rect, - offsetParent, - strategy - } = _ref; - const isFixed = strategy === 'fixed'; - const documentElement = getDocumentElement(offsetParent); - const topLayer = elements ? isTopLayer(elements.floating) : false; - if (offsetParent === documentElement || topLayer && isFixed) { - return rect; - } - let scroll = { - scrollLeft: 0, - scrollTop: 0 - }; - let scale = createCoords(1); - const offsets = createCoords(0); - const isOffsetParentAnElement = isHTMLElement(offsetParent); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { - scroll = getNodeScroll(offsetParent); - } - if (isHTMLElement(offsetParent)) { - const offsetRect = getBoundingClientRect(offsetParent); - scale = getScale(offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; - } - } - return { - width: rect.width * scale.x, - height: rect.height * scale.y, - x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x, - y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y - }; -} - -function getClientRects(element) { - return Array.from(element.getClientRects()); -} - -function getWindowScrollBarX(element) { - // If has a CSS width greater than the viewport, then this will be - // incorrect for RTL. - return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; -} - -// Gets the entire size of the scrollable document area, even extending outside -// of the `` and `` rect bounds if horizontally scrollable. -function getDocumentRect(element) { - const html = getDocumentElement(element); - const scroll = getNodeScroll(element); - const body = element.ownerDocument.body; - const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); - const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); - let x = -scroll.scrollLeft + getWindowScrollBarX(element); - const y = -scroll.scrollTop; - if (getComputedStyle(body).direction === 'rtl') { - x += max(html.clientWidth, body.clientWidth) - width; - } - return { - width, - height, - x, - y - }; -} - -function getViewportRect(element, strategy) { - const win = getWindow(element); - const html = getDocumentElement(element); - const visualViewport = win.visualViewport; - let width = html.clientWidth; - let height = html.clientHeight; - let x = 0; - let y = 0; - if (visualViewport) { - width = visualViewport.width; - height = visualViewport.height; - const visualViewportBased = isWebKit(); - if (!visualViewportBased || visualViewportBased && strategy === 'fixed') { - x = visualViewport.offsetLeft; - y = visualViewport.offsetTop; - } - } - return { - width, - height, - x, - y - }; -} - -// Returns the inner client rect, subtracting scrollbars if present. -function getInnerBoundingClientRect(element, strategy) { - const clientRect = getBoundingClientRect(element, true, strategy === 'fixed'); - const top = clientRect.top + element.clientTop; - const left = clientRect.left + element.clientLeft; - const scale = isHTMLElement(element) ? getScale(element) : createCoords(1); - const width = element.clientWidth * scale.x; - const height = element.clientHeight * scale.y; - const x = left * scale.x; - const y = top * scale.y; - return { - width, - height, - x, - y - }; -} -function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { - let rect; - if (clippingAncestor === 'viewport') { - rect = getViewportRect(element, strategy); - } else if (clippingAncestor === 'document') { - rect = getDocumentRect(getDocumentElement(element)); - } else if (isElement(clippingAncestor)) { - rect = getInnerBoundingClientRect(clippingAncestor, strategy); - } else { - const visualOffsets = getVisualOffsets(element); - rect = { - ...clippingAncestor, - x: clippingAncestor.x - visualOffsets.x, - y: clippingAncestor.y - visualOffsets.y - }; - } - return rectToClientRect(rect); -} -function hasFixedPositionAncestor(element, stopNode) { - const parentNode = getParentNode(element); - if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { - return false; - } - return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode); -} - -// A "clipping ancestor" is an `overflow` element with the characteristic of -// clipping (or hiding) child elements. This returns all clipping ancestors -// of the given element up the tree. -function getClippingElementAncestors(element, cache) { - const cachedResult = cache.get(element); - if (cachedResult) { - return cachedResult; - } - let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body'); - let currentContainingBlockComputedStyle = null; - const elementIsFixed = getComputedStyle(element).position === 'fixed'; - let currentNode = elementIsFixed ? getParentNode(element) : element; - - // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block - while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { - const computedStyle = getComputedStyle(currentNode); - const currentNodeIsContaining = isContainingBlock(currentNode); - if (!currentNodeIsContaining && computedStyle.position === 'fixed') { - currentContainingBlockComputedStyle = null; - } - const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); - if (shouldDropCurrentNode) { - // Drop non-containing blocks. - result = result.filter(ancestor => ancestor !== currentNode); - } else { - // Record last containing block for next iteration. - currentContainingBlockComputedStyle = computedStyle; - } - currentNode = getParentNode(currentNode); - } - cache.set(element, result); - return result; -} - -// Gets the maximum area that the element is visible in due to any number of -// clipping ancestors. -function getClippingRect(_ref) { - let { - element, - boundary, - rootBoundary, - strategy - } = _ref; - const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); - const clippingAncestors = [...elementClippingAncestors, rootBoundary]; - const firstClippingAncestor = clippingAncestors[0]; - const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { - const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); - accRect.top = max(rect.top, accRect.top); - accRect.right = min(rect.right, accRect.right); - accRect.bottom = min(rect.bottom, accRect.bottom); - accRect.left = max(rect.left, accRect.left); - return accRect; - }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); - return { - width: clippingRect.right - clippingRect.left, - height: clippingRect.bottom - clippingRect.top, - x: clippingRect.left, - y: clippingRect.top - }; -} - -function getDimensions(element) { - const { - width, - height - } = getCssDimensions(element); - return { - width, - height - }; -} - -function getRectRelativeToOffsetParent(element, offsetParent, strategy) { - const isOffsetParentAnElement = isHTMLElement(offsetParent); - const documentElement = getDocumentElement(offsetParent); - const isFixed = strategy === 'fixed'; - const rect = getBoundingClientRect(element, true, isFixed, offsetParent); - let scroll = { - scrollLeft: 0, - scrollTop: 0 - }; - const offsets = createCoords(0); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) { - scroll = getNodeScroll(offsetParent); - } - if (isOffsetParentAnElement) { - const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; - } else if (documentElement) { - offsets.x = getWindowScrollBarX(documentElement); - } - } - const x = rect.left + scroll.scrollLeft - offsets.x; - const y = rect.top + scroll.scrollTop - offsets.y; - return { - x, - y, - width: rect.width, - height: rect.height - }; -} - -function isStaticPositioned(element) { - return getComputedStyle(element).position === 'static'; -} - -function getTrueOffsetParent(element, polyfill) { - if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') { - return null; - } - if (polyfill) { - return polyfill(element); - } - return element.offsetParent; -} - -// Gets the closest ancestor positioned element. Handles some edge cases, -// such as table ancestors and cross browser bugs. -function getOffsetParent(element, polyfill) { - const win = getWindow(element); - if (isTopLayer(element)) { - return win; - } - if (!isHTMLElement(element)) { - let svgOffsetParent = getParentNode(element); - while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { - if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { - return svgOffsetParent; - } - svgOffsetParent = getParentNode(svgOffsetParent); - } - return win; - } - let offsetParent = getTrueOffsetParent(element, polyfill); - while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { - offsetParent = getTrueOffsetParent(offsetParent, polyfill); - } - if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { - return win; - } - return offsetParent || getContainingBlock(element) || win; -} - -const getElementRects = async function (data) { - const getOffsetParentFn = this.getOffsetParent || getOffsetParent; - const getDimensionsFn = this.getDimensions; - const floatingDimensions = await getDimensionsFn(data.floating); - return { - reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), - floating: { - x: 0, - y: 0, - width: floatingDimensions.width, - height: floatingDimensions.height - } - }; -}; - -function isRTL(element) { - return getComputedStyle(element).direction === 'rtl'; -} - -const platform = { - convertOffsetParentRelativeRectToViewportRelativeRect, - getDocumentElement, - getClippingRect, - getOffsetParent, - getElementRects, - getClientRects, - getDimensions, - getScale, - isElement, - isRTL -}; - -// https://samthor.au/2021/observing-dom/ -function observeMove(element, onMove) { - let io = null; - let timeoutId; - const root = getDocumentElement(element); - function cleanup() { - var _io; - clearTimeout(timeoutId); - (_io = io) == null || _io.disconnect(); - io = null; - } - function refresh(skip, threshold) { - if (skip === void 0) { - skip = false; - } - if (threshold === void 0) { - threshold = 1; - } - cleanup(); - const { - left, - top, - width, - height - } = element.getBoundingClientRect(); - if (!skip) { - onMove(); - } - if (!width || !height) { - return; - } - const insetTop = floor(top); - const insetRight = floor(root.clientWidth - (left + width)); - const insetBottom = floor(root.clientHeight - (top + height)); - const insetLeft = floor(left); - const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; - const options = { - rootMargin, - threshold: max(0, min(1, threshold)) || 1 - }; - let isFirstUpdate = true; - function handleObserve(entries) { - const ratio = entries[0].intersectionRatio; - if (ratio !== threshold) { - if (!isFirstUpdate) { - return refresh(); - } - if (!ratio) { - // If the reference is clipped, the ratio is 0. Throttle the refresh - // to prevent an infinite loop of updates. - timeoutId = setTimeout(() => { - refresh(false, 1e-7); - }, 1000); - } else { - refresh(false, ratio); - } - } - isFirstUpdate = false; - } - - // Older browsers don't support a `document` as the root and will throw an - // error. - try { - io = new IntersectionObserver(handleObserve, { - ...options, - // Handle