@fluentui/react-positioning 9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 → 9.75.2-experimental.css-modules.20261113-ba13c87438.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -7
- package/README.md +7 -130
- package/lib/Arrow.module.css +43 -0
- package/lib/PositioningConfigurationContext.js +2 -1
- package/lib/PositioningConfigurationContext.js.map +1 -1
- package/lib/createPositionManager.js +82 -74
- package/lib/createPositionManager.js.map +1 -1
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +9 -0
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +1 -0
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +9 -0
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +1 -0
- package/lib/middleware/flip.js +1 -1
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/intersecting.js +1 -1
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +1 -1
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +1 -1
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +1 -1
- package/lib/middleware/shift.js.map +1 -1
- package/lib/usePositioning.js +48 -38
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningOptions.js +117 -25
- package/lib/usePositioningOptions.js.map +1 -1
- package/lib/utils/createResizeObserver.js +2 -2
- package/lib/utils/createResizeObserver.js.map +1 -1
- package/lib/utils/debounce.js +13 -6
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +29 -10
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +17 -8
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/listScrollParents.js +20 -12
- package/lib/utils/listScrollParents.js.map +1 -1
- package/lib/utils/normalizeAutoSize.js +22 -15
- package/lib/utils/normalizeAutoSize.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +26 -9
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/useCallbackRef.js +10 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +13 -0
- package/lib/utils/writeArrowUpdates.js.map +1 -0
- package/lib/utils/writeContainerupdates.js +43 -0
- package/lib/utils/writeContainerupdates.js.map +1 -0
- package/lib-commonjs/Arrow.module.css +43 -0
- package/lib-commonjs/PositioningConfigurationContext.cjs +2 -1
- package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
- package/lib-commonjs/createPositionManager.cjs +80 -72
- package/lib-commonjs/createPositionManager.cjs.map +1 -1
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +20 -0
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +1 -0
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +20 -0
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +1 -0
- package/lib-commonjs/middleware/flip.cjs +6 -6
- package/lib-commonjs/middleware/flip.cjs.map +1 -1
- package/lib-commonjs/middleware/intersecting.cjs +2 -2
- package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
- package/lib-commonjs/middleware/maxSize.cjs +4 -4
- package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
- package/lib-commonjs/middleware/offset.cjs +2 -2
- package/lib-commonjs/middleware/offset.cjs.map +1 -1
- package/lib-commonjs/middleware/shift.cjs +7 -7
- package/lib-commonjs/middleware/shift.cjs.map +1 -1
- package/lib-commonjs/usePositioning.cjs +46 -37
- package/lib-commonjs/usePositioning.cjs.map +1 -1
- package/lib-commonjs/usePositioningOptions.cjs +112 -24
- package/lib-commonjs/usePositioningOptions.cjs.map +1 -1
- package/lib-commonjs/utils/createResizeObserver.cjs +2 -2
- package/lib-commonjs/utils/createResizeObserver.cjs.map +1 -1
- package/lib-commonjs/utils/debounce.cjs +13 -6
- package/lib-commonjs/utils/debounce.cjs.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.cjs +32 -21
- package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
- package/lib-commonjs/utils/getBoundary.cjs +17 -8
- package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
- package/lib-commonjs/utils/index.cjs +8 -0
- package/lib-commonjs/utils/index.cjs.map +1 -1
- package/lib-commonjs/utils/listScrollParents.cjs +20 -12
- package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
- package/lib-commonjs/utils/normalizeAutoSize.cjs +25 -26
- package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.cjs +27 -13
- package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.cjs +9 -1
- package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.cjs +23 -0
- package/lib-commonjs/utils/writeArrowUpdates.cjs.map +1 -0
- package/lib-commonjs/utils/writeContainerupdates.cjs +51 -0
- package/lib-commonjs/utils/writeContainerupdates.cjs.map +1 -0
- package/package.json +9 -5
- package/lib/engine/computePosition.js +0 -258
- package/lib/engine/computePosition.js.map +0 -1
- package/lib/engine/index.js +0 -260
- package/lib/engine/index.js.map +0 -1
- package/lib/engine/platform.js +0 -209
- package/lib/engine/platform.js.map +0 -1
- package/lib/usePositioning.raster.js +0 -45
- package/lib/usePositioning.raster.js.map +0 -1
- package/lib-commonjs/engine/computePosition.cjs +0 -265
- package/lib-commonjs/engine/computePosition.cjs.map +0 -1
- package/lib-commonjs/engine/index.cjs +0 -290
- package/lib-commonjs/engine/index.cjs.map +0 -1
- package/lib-commonjs/engine/platform.cjs +0 -264
- package/lib-commonjs/engine/platform.cjs.map +0 -1
- package/lib-commonjs/usePositioning.raster.cjs +0 -49
- package/lib-commonjs/usePositioning.raster.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/engine/computePosition.ts"],"sourcesContent":["import type { Placement, Rect, Side, SideObject, Strategy } from '@floating-ui/dom';\nimport type { Alignment, Position, PositioningBoundary, PositioningOptions, TargetElement } from '../types';\nimport { getBoundary, toFloatingUIPlacement } from '../utils';\nimport { toPositioningValues } from '../utils/fromFloatingUIPlacement';\nimport { getAutoSizeDimensions } from '../utils/normalizeAutoSize';\nimport {\n getClippingRect,\n getCoordinateSpace,\n getDimensions,\n getOffsetParent,\n getReferenceRect,\n getRoot,\n getStyle,\n getWindow,\n NO_OFFSET,\n px,\n rect,\n} from './platform';\n\ntype Options = {\n placement?: Placement;\n strategy: Strategy;\n options?: PositioningOptions;\n isRtl?: boolean;\n arrow?: HTMLElement | null;\n};\ntype Axis = 'x' | 'y';\ntype Coords = Record<Axis, number>;\nexport type ComputePositionResult = Coords & {\n placement: Placement;\n /** Arrow offset along the alignment axis, `undefined` without an arrow */\n arrow?: Partial<Coords>;\n /** The floating element is outside of the clipping boundary of the target, `false` without a layout viewport */\n escaped: boolean;\n /** The target is outside of its clipping boundary, `false` without a layout viewport */\n referenceHidden: boolean;\n /** The floating element crosses the top or bottom clipping edge */\n intersecting: boolean;\n};\n\nconst SIDES: Side[] = ['top', 'right', 'bottom', 'left'];\nconst lengthOf = (axis: Axis) => (axis === 'x' ? 'width' : 'height');\nconst startOf = (axis: Axis) => (axis === 'x' ? 'left' : 'top');\nconst endOf = (axis: Axis) => (axis === 'x' ? 'right' : 'bottom');\nconst sides = (top: number, right: number, bottom: number, left: number): SideObject => ({ top, right, bottom, left });\nconst clamp = (min: number, value: number, max: number) => Math.max(min, Math.min(value, max));\n/** Moves the coordinate on the axis by the least amount that removes the overflow */\nconst shiftOverflow = (coords: Coords, axis: Axis, overflow: SideObject) =>\n (coords[axis] = clamp(coords[axis] + overflow[startOf(axis)], coords[axis], coords[axis] - overflow[endOf(axis)]));\n\n/**\n * Fluent-specific pipeline. Measurements and all coordinates use the floating\n * containing block's CSS pixels; clipping rectangles use viewport pixels.\n */\nexport async function computePosition(\n target: TargetElement,\n container: HTMLElement,\n { placement: initial = 'bottom', strategy, options = {}, isRtl = false, arrow }: Options,\n): Promise<ComputePositionResult> {\n const {\n autoSize: rawAutoSize,\n offset,\n matchTargetSize,\n coverTarget,\n pinned,\n flipBoundary,\n overflowBoundary,\n overflowBoundaryPadding: rawPadding = 0,\n fallbackPositions = [],\n arrowPadding = 0,\n shiftToCoverTarget,\n unstable_disableTether: disableTether,\n } = options;\n const css = container.style;\n // An empty value removes the property\n const setStyle = (property: string, value = '') => css.setProperty(property, value);\n const autoSize = getAutoSizeDimensions(rawAutoSize);\n for (const dimension of autoSize) {\n setStyle('box-sizing');\n setStyle(`max-${dimension}`);\n setStyle(dimension);\n }\n const rtl = getStyle(container).direction === 'rtl';\n const referenceElement = 'nodeType' in target ? target : target.contextElement || getRoot(container);\n const clip = (element: Element, boundary?: PositioningBoundary) =>\n getClippingRect(element, getBoundary(container, boundary) || 'clippingAncestors', getWindow(container), strategy);\n // Without explicit boundaries flipping and shifting share the clipping ancestors of the container\n let containerClip: Rect | undefined;\n const boundaryClip = (boundary?: PositioningBoundary | null) =>\n boundary ? clip(referenceElement, boundary) : (containerClip ||= clip(container));\n const flipClip = boundaryClip(flipBoundary);\n const shiftClip = boundaryClip(overflowBoundary);\n const visibilityClip = clip(referenceElement);\n const padding =\n typeof rawPadding === 'number'\n ? sides(rawPadding, rawPadding, rawPadding, rawPadding)\n : sides(\n rawPadding.top || 0,\n rawPadding[isRtl ? 'start' : 'end'] || 0,\n rawPadding.bottom || 0,\n rawPadding[isRtl ? 'end' : 'start'] || 0,\n );\n /** How far the box (in container coordinates) overflows the bounds (in viewport coordinates) on each side */\n const overflow = (box: Rect, bounds: Rect, inset = sides(0, 0, 0, 0)) => {\n const result = { ...inset };\n for (const axis of ['x', 'y'] as const) {\n const length = lengthOf(axis);\n const axisScale = scale[axis];\n const origin = initialSpace[axis];\n result[startOf(axis)] = (bounds[axis] - (box[axis] * axisScale + origin) + inset[startOf(axis)]) / axisScale;\n result[endOf(axis)] =\n ((box[axis] + box[length]) * axisScale + origin - bounds[axis] - bounds[length] + inset[endOf(axis)]) /\n axisScale;\n }\n return result;\n };\n const [initialSide, initialAlign] = initial.split('-') as [Side, string?];\n // Without fallbacks: the initial placement, the opposite alignment, the opposite side and both opposites\n const candidates = fallbackPositions.length\n ? [\n initial,\n ...fallbackPositions.map(shorthand => {\n const [position, align] = shorthand.split('-') as [Position, Alignment?];\n return toFloatingUIPlacement(align, position, isRtl)!;\n }),\n ]\n : ([initialSide, SIDES[(SIDES.indexOf(initialSide) + 2) % 4]].flatMap(side =>\n initialAlign ? [`${side}-${initialAlign}`, `${side}-${initialAlign === 'start' ? 'end' : 'start'}`] : [side],\n ) as Placement[]);\n const attempts: [placement: Placement, overflows: number[]][] = [];\n let space: ReturnType<typeof getCoordinateSpace>;\n /** The reference and floating rects in the container's coordinate space */\n const measure = (): [Rect, Rect] => {\n space = getCoordinateSpace(container, strategy);\n const { width, height } = getDimensions(container);\n return [getReferenceRect(target, referenceElement, container, space, strategy), rect(0, 0, width, height)];\n };\n let rects = measure();\n // Overflow is always measured in the initial coordinate space\n const initialSpace = space!;\n const { scale } = initialSpace;\n let candidateIndex = 0;\n let placement = initial;\n let matchAttempt = false;\n let arrowAdjusted = false;\n let preserveCoordinates = false;\n let arrowData: Partial<Coords> | undefined;\n let coords!: Coords;\n let delta: Coords = NO_OFFSET;\n\n for (let attempt = 0; attempt <= 50; attempt++) {\n const [r, f] = rects;\n const [side, align] = placement.split('-') as [Side, string?];\n const isVertical = side === 'top' || side === 'bottom';\n const isStart = side === 'top' || side === 'left';\n // `main` is the alignment axis, `cross` is the axis that leads away from the target\n const main: Axis = isVertical ? 'x' : 'y';\n const cross: Axis = isVertical ? 'y' : 'x';\n const mainLength = lengthOf(main);\n const crossLength = lengthOf(cross);\n const floatingRect = () => ({ ...f, ...coords });\n if (!preserveCoordinates) {\n coords = { x: r.x + r.width / 2 - f.width / 2, y: r.y + r.height / 2 - f.height / 2 };\n coords[cross] = isStart ? r[cross] - f[crossLength] : r[cross] + r[crossLength];\n if (align) {\n coords[main] +=\n (r[mainLength] / 2 - f[mainLength] / 2) * (rtl && isVertical ? -1 : 1) * (align === 'start' ? -1 : 1);\n }\n }\n preserveCoordinates = false;\n if (matchTargetSize && r.width !== f.width && !matchAttempt) {\n const property = '--fui-match-target-size';\n setStyle(property, px(r.width));\n if (!css.width) {\n css.width = `var(${property})`;\n }\n matchAttempt = true;\n rects = measure();\n continue;\n }\n\n if (offset) {\n const raw =\n typeof offset === 'function'\n ? offset({ positionedRect: f, targetRect: r, ...toPositioningValues(side, align) })\n : offset;\n const value = typeof raw === 'number' ? { mainAxis: raw } : raw;\n if (!arrowAdjusted) {\n delta = {\n [cross]: (value.mainAxis || 0) * (isStart ? -1 : 1),\n [main]: (value.crossAxis || 0) * (rtl && isVertical ? -1 : 1),\n } as Coords;\n coords.x += delta.x;\n coords.y += delta.y;\n }\n }\n if (coverTarget) {\n coords[cross] += (isStart ? 1 : -1) * r[crossLength];\n }\n if (!pinned && !arrowAdjusted) {\n const values = overflow(floatingRect(), flipClip);\n // The edge on the alignment axis that overflows first: the end edge for start alignment (logical in RTL),\n // the opposite one when the target is larger than the floating element\n const alignEnd = (align === (rtl && isVertical ? 'end' : 'start')) !== r[mainLength] > f[mainLength];\n const overflows = [\n values[side],\n values[(alignEnd ? endOf : startOf)(main)],\n values[(alignEnd ? startOf : endOf)(main)],\n ];\n attempts.push([placement, overflows]);\n if (overflows.some(value => value > 0)) {\n const next = candidates[++candidateIndex];\n if (next) {\n placement = next;\n continue;\n }\n const score = (scores: number[]) => scores.reduce((sum, value) => sum + Math.max(0, value), 0);\n const best = (attempts.filter(item => item[1][0] <= 0).sort((a, b) => a[1][1] - b[1][1])[0] ||\n attempts.slice().sort((a, b) => score(a[1]) - score(b[1]))[0])[0];\n if (best !== placement) {\n placement = best;\n continue;\n }\n }\n }\n const shiftCross = disableTether ? disableTether === 'all' : !!shiftToCoverTarget;\n const values = overflow(floatingRect(), shiftClip, padding);\n shiftOverflow(coords, main, values);\n if (shiftCross) {\n shiftOverflow(coords, cross, values);\n }\n // Shifting on the cross axis, and disabling the tether on one axis, keep the floating element next to the target\n if (disableTether !== 'all' && (shiftCross || disableTether)) {\n coords[cross] = clamp(\n r[cross] - f[crossLength] + (isStart ? delta[cross] : 0),\n coords[cross],\n r[cross] + r[crossLength] + (isStart ? 0 : delta[cross]),\n );\n }\n if (autoSize.length) {\n const available = overflow(floatingRect(), shiftClip, padding);\n for (const dimension of autoSize) {\n const axis = dimension === 'width' ? 'x' : 'y';\n const max = f[dimension] - available[startOf(axis)] - available[endOf(axis)];\n // Shifting on an axis makes the whole boundary available, otherwise the side facing away from the target\n const size = axis === main || shiftCross ? max : Math.min(f[dimension] - available[side], max);\n setStyle('box-sizing', 'border-box');\n setStyle(`max-${dimension}`, px(size));\n if (f[dimension] > size) {\n setStyle(dimension, px(size));\n const property = `overflow-${axis}`;\n if (!css.getPropertyValue(property)) {\n setStyle(property, 'auto');\n }\n }\n }\n const dimensions = getDimensions(container);\n if (f.width !== dimensions.width || f.height !== dimensions.height) {\n rects = measure();\n continue;\n }\n }\n if (arrow) {\n const client = main === 'x' ? 'clientWidth' : 'clientHeight';\n const arrowLength = getDimensions(arrow)[mainLength];\n const parent = getOffsetParent(arrow);\n const clientSize = (parent && parent[client]) || container[client] || f[mainLength];\n const inset = Math.min(arrowPadding, clientSize / 2 - arrowLength / 2 - 1);\n const startDiff = coords[main] - r[main];\n const endDiff = r[mainLength] + r[main] - coords[main] - f[mainLength];\n const center = clientSize / 2 - arrowLength / 2 + endDiff / 2 - startDiff / 2;\n const arrowOffset = clamp(inset, center, clientSize - arrowLength - inset);\n arrowData = { [main]: arrowOffset };\n if (!arrowAdjusted && align && center !== arrowOffset && r[mainLength] / 2 - inset - arrowLength / 2 < 0) {\n coords[main] += center - arrowOffset;\n arrowAdjusted = preserveCoordinates = true;\n continue;\n }\n }\n break;\n }\n const [reference, floating] = rects;\n const floatingOverflow = overflow({ ...floating, ...coords }, visibilityClip);\n const { clientWidth, clientHeight } = getRoot(container);\n // Visibility can't be determined without a layout viewport (e.g. in jsdom)\n const isHidden = (values: SideObject, box: Rect) =>\n !!(clientWidth || clientHeight) && SIDES.some((side, index) => values[side] >= box[index % 2 ? 'width' : 'height']);\n return {\n ...coords,\n placement,\n arrow: arrowData,\n referenceHidden: isHidden(overflow(reference, visibilityClip), reference),\n escaped: isHidden(floatingOverflow, floating),\n intersecting: [floatingOverflow.top, floatingOverflow.bottom].some(value => value > 0 && value < floating.height),\n };\n}\n"],"names":["getBoundary","toFloatingUIPlacement","toPositioningValues","getAutoSizeDimensions","getClippingRect","getCoordinateSpace","getDimensions","getOffsetParent","getReferenceRect","getRoot","getStyle","getWindow","NO_OFFSET","px","rect","SIDES","lengthOf","axis","startOf","endOf","sides","top","right","bottom","left","clamp","min","value","max","Math","shiftOverflow","coords","overflow","computePosition","target","container","placement","initial","strategy","options","isRtl","arrow","autoSize","rawAutoSize","offset","matchTargetSize","coverTarget","pinned","flipBoundary","overflowBoundary","overflowBoundaryPadding","rawPadding","fallbackPositions","arrowPadding","shiftToCoverTarget","unstable_disableTether","disableTether","css","style","setStyle","property","setProperty","dimension","rtl","direction","referenceElement","contextElement","clip","element","boundary","containerClip","boundaryClip","flipClip","shiftClip","visibilityClip","padding","box","bounds","inset","result","length","axisScale","scale","origin","initialSpace","initialSide","initialAlign","split","candidates","map","shorthand","position","align","indexOf","flatMap","side","attempts","space","measure","width","height","rects","candidateIndex","matchAttempt","arrowAdjusted","preserveCoordinates","arrowData","delta","attempt","r","f","isVertical","isStart","main","cross","mainLength","crossLength","floatingRect","x","y","raw","positionedRect","targetRect","mainAxis","crossAxis","values","alignEnd","overflows","push","some","next","score","scores","reduce","sum","best","filter","item","sort","a","b","slice","shiftCross","available","size","getPropertyValue","dimensions","client","arrowLength","parent","clientSize","startDiff","endDiff","center","arrowOffset","reference","floating","floatingOverflow","clientWidth","clientHeight","isHidden","index","referenceHidden","escaped","intersecting"],"mappings":"AAEA,SAASA,WAAW,EAAEC,qBAAqB,QAAQ,oBAAW;AAC9D,SAASC,mBAAmB,QAAQ,sCAAmC;AACvE,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SACEC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,OAAO,EACPC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,EAAE,EACFC,IAAI,QACC,gBAAa;AAuBpB,MAAMC,QAAgB;IAAC;IAAO;IAAS;IAAU;CAAO;AACxD,MAAMC,WAAW,CAACC,OAAgBA,SAAS,MAAM,UAAU;AAC3D,MAAMC,UAAU,CAACD,OAAgBA,SAAS,MAAM,SAAS;AACzD,MAAME,QAAQ,CAACF,OAAgBA,SAAS,MAAM,UAAU;AACxD,MAAMG,QAAQ,CAACC,KAAaC,OAAeC,QAAgBC,OAA8B,CAAA;QAAEH;QAAKC;QAAOC;QAAQC;IAAK,CAAA;AACpH,MAAMC,QAAQ,CAACC,KAAaC,OAAeC,MAAgBC,KAAKD,GAAG,CAACF,KAAKG,KAAKH,GAAG,CAACC,OAAOC;AACzF,mFAAmF,GACnF,MAAME,gBAAgB,CAACC,QAAgBd,MAAYe,WAChDD,MAAM,CAACd,KAAK,GAAGQ,MAAMM,MAAM,CAACd,KAAK,GAAGe,QAAQ,CAACd,QAAQD,MAAM,EAAEc,MAAM,CAACd,KAAK,EAAEc,MAAM,CAACd,KAAK,GAAGe,QAAQ,CAACb,MAAMF,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SAAS6D,WAAWC,eAAe7C,CAAC,CAACM,WAAW,GAAG,IAAIrC,QAAQsE,cAAc,IAAI,GAAG;gBACxGrH,MAAM,CAACkF,KAAK,IAAIwC,SAASC;gBACzBlD,gBAAgBC,sBAAsB;gBACtC;YACF;QACF;QACA;IACF;IACA,MAAM,CAACkD,WAAWC,SAAS,GAAGvD;IAC9B,MAAMwD,mBAAmB7H,SAAS;QAAE,GAAG4H,QAAQ;QAAE,GAAG7H,MAAM;IAAC,GAAG2C;IAC9D,MAAM,EAAEoF,WAAW,EAAEC,YAAY,EAAE,GAAGtJ,QAAQ0B;IAC9C,2EAA2E;IAC3E,MAAM6H,WAAW,CAACnC,QAAoBjD,MACpC,CAAC,CAAEkF,CAAAA,eAAeC,YAAW,KAAMhJ,MAAMkH,IAAI,CAAC,CAAClC,MAAMkE,QAAUpC,MAAM,CAAC9B,KAAK,IAAInB,GAAG,CAACqF,QAAQ,IAAI,UAAU,SAAS;IACpH,OAAO;QACL,GAAGlI,MAAM;QACTK;QACAK,OAAOiE;QACPwD,iBAAiBF,SAAShI,SAAS2H,WAAWjF,iBAAiBiF;QAC/DQ,SAASH,SAASH,kBAAkBD;QACpCQ,cAAc;YAACP,iBAAiBxI,GAAG;YAAEwI,iBAAiBtI,MAAM;SAAC,CAAC0G,IAAI,CAACtG,CAAAA,QAASA,QAAQ,KAAKA,QAAQiI,SAASxD,MAAM;IAClH;AACF"}
|
package/lib/engine/index.js
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
const opposite = {
|
|
2
|
-
top: 'bottom',
|
|
3
|
-
bottom: 'top',
|
|
4
|
-
left: 'right',
|
|
5
|
-
right: 'left'
|
|
6
|
-
};
|
|
7
|
-
const sideOf = (placement)=>placement.split('-')[0];
|
|
8
|
-
const alignOf = (placement)=>placement.split('-')[1];
|
|
9
|
-
const vertical = (placement)=>/^(top|bottom)/.test(placement);
|
|
10
|
-
const clamp = (min, value, max)=>Math.max(min, Math.min(value, max));
|
|
11
|
-
const paddingOf = (padding = 0)=>typeof padding === 'number' ? {
|
|
12
|
-
top: padding,
|
|
13
|
-
right: padding,
|
|
14
|
-
bottom: padding,
|
|
15
|
-
left: padding
|
|
16
|
-
} : {
|
|
17
|
-
top: 0,
|
|
18
|
-
right: 0,
|
|
19
|
-
bottom: 0,
|
|
20
|
-
left: 0,
|
|
21
|
-
...padding
|
|
22
|
-
};
|
|
23
|
-
export async function detectOverflow(state, options = {}) {
|
|
24
|
-
var _element_contextElement;
|
|
25
|
-
var _platform_isElement, _platform_getOffsetParent, _platform_isElement1;
|
|
26
|
-
const { rects, elements, platform, strategy } = state;
|
|
27
|
-
const { elementContext = 'floating', altBoundary = false, boundary = 'clippingAncestors', rootBoundary = 'viewport' } = options;
|
|
28
|
-
const context = altBoundary ? elementContext === 'floating' ? 'reference' : 'floating' : elementContext;
|
|
29
|
-
const element = elements[context];
|
|
30
|
-
const clippingElement = await ((_platform_isElement = platform.isElement) === null || _platform_isElement === void 0 ? void 0 : _platform_isElement.call(platform, element)) ? element : (_element_contextElement = element.contextElement) !== null && _element_contextElement !== void 0 ? _element_contextElement : elements.floating.ownerDocument.documentElement;
|
|
31
|
-
const clip = await platform.getClippingRect({
|
|
32
|
-
element: clippingElement,
|
|
33
|
-
boundary,
|
|
34
|
-
rootBoundary,
|
|
35
|
-
strategy
|
|
36
|
-
});
|
|
37
|
-
const parent = await ((_platform_getOffsetParent = platform.getOffsetParent) === null || _platform_getOffsetParent === void 0 ? void 0 : _platform_getOffsetParent.call(platform, elements.floating));
|
|
38
|
-
const scale = parent && await ((_platform_isElement1 = platform.isElement) === null || _platform_isElement1 === void 0 ? void 0 : _platform_isElement1.call(platform, parent)) && platform.getScale ? await platform.getScale(parent) : {
|
|
39
|
-
x: 1,
|
|
40
|
-
y: 1
|
|
41
|
-
};
|
|
42
|
-
const local = elementContext === 'reference' ? rects.reference : {
|
|
43
|
-
x: state.x,
|
|
44
|
-
y: state.y,
|
|
45
|
-
width: rects.floating.width,
|
|
46
|
-
height: rects.floating.height
|
|
47
|
-
};
|
|
48
|
-
const rect = platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
49
|
-
elements,
|
|
50
|
-
rect: local,
|
|
51
|
-
offsetParent: parent,
|
|
52
|
-
strategy
|
|
53
|
-
}) : local;
|
|
54
|
-
const padding = paddingOf(options.padding);
|
|
55
|
-
return {
|
|
56
|
-
top: (clip.y - rect.y + padding.top) / scale.y,
|
|
57
|
-
bottom: (rect.y + rect.height - clip.y - clip.height + padding.bottom) / scale.y,
|
|
58
|
-
left: (clip.x - rect.x + padding.left) / scale.x,
|
|
59
|
-
right: (rect.x + rect.width - clip.x - clip.width + padding.right) / scale.x
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export function offset(options = 0) {
|
|
63
|
-
return {
|
|
64
|
-
name: 'offset',
|
|
65
|
-
async fn (state) {
|
|
66
|
-
var _state_platform_isRTL, _state_platform, _state_middlewareData_offset, _state_middlewareData_arrow;
|
|
67
|
-
const raw = typeof options === 'function' ? options(state) : options;
|
|
68
|
-
const value = typeof raw === 'number' ? {
|
|
69
|
-
mainAxis: raw
|
|
70
|
-
} : raw;
|
|
71
|
-
let cross = value.crossAxis || 0;
|
|
72
|
-
if (alignOf(state.placement) && typeof value.alignmentAxis === 'number') {
|
|
73
|
-
cross = value.alignmentAxis * (alignOf(state.placement) === 'end' ? -1 : 1);
|
|
74
|
-
}
|
|
75
|
-
const isVertical = vertical(state.placement);
|
|
76
|
-
const rtl = await ((_state_platform_isRTL = (_state_platform = state.platform).isRTL) === null || _state_platform_isRTL === void 0 ? void 0 : _state_platform_isRTL.call(_state_platform, state.elements.floating));
|
|
77
|
-
const main = (value.mainAxis || 0) * (/^(top|left)/.test(state.placement) ? -1 : 1);
|
|
78
|
-
cross *= rtl && isVertical ? -1 : 1;
|
|
79
|
-
if (((_state_middlewareData_offset = state.middlewareData.offset) === null || _state_middlewareData_offset === void 0 ? void 0 : _state_middlewareData_offset.placement) === state.placement && ((_state_middlewareData_arrow = state.middlewareData.arrow) === null || _state_middlewareData_arrow === void 0 ? void 0 : _state_middlewareData_arrow.alignmentOffset)) {
|
|
80
|
-
return {};
|
|
81
|
-
}
|
|
82
|
-
const delta = {
|
|
83
|
-
x: isVertical ? cross : main,
|
|
84
|
-
y: isVertical ? main : cross
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
x: state.x + delta.x,
|
|
88
|
-
y: state.y + delta.y,
|
|
89
|
-
data: {
|
|
90
|
-
...delta,
|
|
91
|
-
placement: state.placement
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export function flip(options = {}) {
|
|
98
|
-
return {
|
|
99
|
-
name: 'flip',
|
|
100
|
-
async fn (state) {
|
|
101
|
-
var _options_fallbackPlacements, _ref, _ref1, _fitting_;
|
|
102
|
-
var _state_middlewareData_arrow, _state_platform_isRTL, _state_platform, _state_middlewareData_flip, _state_middlewareData_flip1;
|
|
103
|
-
if ((_state_middlewareData_arrow = state.middlewareData.arrow) === null || _state_middlewareData_arrow === void 0 ? void 0 : _state_middlewareData_arrow.alignmentOffset) {
|
|
104
|
-
return {};
|
|
105
|
-
}
|
|
106
|
-
const initial = state.initialPlacement;
|
|
107
|
-
const align = alignOf(initial);
|
|
108
|
-
const oppositePlacement = (p)=>`${opposite[sideOf(p)]}${alignOf(p) ? `-${alignOf(p)}` : ''}`;
|
|
109
|
-
const oppositeAlignment = (p)=>p.replace(/start|end/, (match)=>match === 'start' ? 'end' : 'start');
|
|
110
|
-
const candidates = [
|
|
111
|
-
initial,
|
|
112
|
-
...(_options_fallbackPlacements = options.fallbackPlacements) !== null && _options_fallbackPlacements !== void 0 ? _options_fallbackPlacements : align ? [
|
|
113
|
-
oppositeAlignment(initial),
|
|
114
|
-
oppositePlacement(initial),
|
|
115
|
-
oppositeAlignment(oppositePlacement(initial))
|
|
116
|
-
] : [
|
|
117
|
-
oppositePlacement(initial)
|
|
118
|
-
]
|
|
119
|
-
];
|
|
120
|
-
const overflow = await detectOverflow(state, options);
|
|
121
|
-
const isVertical = vertical(state.placement);
|
|
122
|
-
const rtl = await ((_state_platform_isRTL = (_state_platform = state.platform).isRTL) === null || _state_platform_isRTL === void 0 ? void 0 : _state_platform_isRTL.call(_state_platform, state.elements.floating));
|
|
123
|
-
const length = isVertical ? 'width' : 'height';
|
|
124
|
-
let alignmentSide = isVertical ? alignOf(state.placement) === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignOf(state.placement) === 'start' ? 'bottom' : 'top';
|
|
125
|
-
if (state.rects.reference[length] > state.rects.floating[length]) {
|
|
126
|
-
alignmentSide = opposite[alignmentSide];
|
|
127
|
-
}
|
|
128
|
-
const overflows = [
|
|
129
|
-
overflow[sideOf(state.placement)],
|
|
130
|
-
overflow[alignmentSide],
|
|
131
|
-
overflow[opposite[alignmentSide]]
|
|
132
|
-
];
|
|
133
|
-
const attempts = [
|
|
134
|
-
...(_ref = (_state_middlewareData_flip = state.middlewareData.flip) === null || _state_middlewareData_flip === void 0 ? void 0 : _state_middlewareData_flip.overflows) !== null && _ref !== void 0 ? _ref : [],
|
|
135
|
-
{
|
|
136
|
-
placement: state.placement,
|
|
137
|
-
overflows
|
|
138
|
-
}
|
|
139
|
-
];
|
|
140
|
-
if (overflows.every((value)=>value <= 0)) {
|
|
141
|
-
return {};
|
|
142
|
-
}
|
|
143
|
-
const index = ((_ref1 = (_state_middlewareData_flip1 = state.middlewareData.flip) === null || _state_middlewareData_flip1 === void 0 ? void 0 : _state_middlewareData_flip1.index) !== null && _ref1 !== void 0 ? _ref1 : 0) + 1;
|
|
144
|
-
if (candidates[index]) {
|
|
145
|
-
return {
|
|
146
|
-
data: {
|
|
147
|
-
index,
|
|
148
|
-
overflows: attempts
|
|
149
|
-
},
|
|
150
|
-
reset: {
|
|
151
|
-
placement: candidates[index]
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
const fitting = attempts.filter((item)=>item.overflows[0] <= 0).sort((a, b)=>a.overflows[1] - b.overflows[1]);
|
|
156
|
-
const score = (values)=>values.reduce((sum, value)=>sum + Math.max(0, value), 0);
|
|
157
|
-
const best = (_fitting_ = fitting[0]) !== null && _fitting_ !== void 0 ? _fitting_ : attempts.sort((a, b)=>score(a.overflows) - score(b.overflows))[0];
|
|
158
|
-
return best.placement === state.placement ? {} : {
|
|
159
|
-
reset: {
|
|
160
|
-
placement: best.placement
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
export function limitShift(options = {}) {
|
|
167
|
-
return {
|
|
168
|
-
fn (state) {
|
|
169
|
-
const coords = {
|
|
170
|
-
x: state.x,
|
|
171
|
-
y: state.y
|
|
172
|
-
};
|
|
173
|
-
const main = vertical(state.placement) ? 'x' : 'y';
|
|
174
|
-
const cross = main === 'x' ? 'y' : 'x';
|
|
175
|
-
const { reference: r, floating: f } = state.rects;
|
|
176
|
-
if (options.mainAxis !== false) {
|
|
177
|
-
const length = main === 'x' ? 'width' : 'height';
|
|
178
|
-
coords[main] = clamp(r[main] - f[length], coords[main], r[main] + r[length]);
|
|
179
|
-
}
|
|
180
|
-
if (options.crossAxis !== false) {
|
|
181
|
-
var _state_middlewareData_offset;
|
|
182
|
-
const length = cross === 'x' ? 'width' : 'height';
|
|
183
|
-
const origin = /^(top|left)/.test(state.placement);
|
|
184
|
-
const delta = ((_state_middlewareData_offset = state.middlewareData.offset) === null || _state_middlewareData_offset === void 0 ? void 0 : _state_middlewareData_offset[cross]) || 0;
|
|
185
|
-
coords[cross] = clamp(r[cross] - f[length] + (origin ? delta : 0), coords[cross], r[cross] + r[length] + (origin ? 0 : delta));
|
|
186
|
-
}
|
|
187
|
-
return coords;
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
export function shift(options = {}) {
|
|
192
|
-
return {
|
|
193
|
-
name: 'shift',
|
|
194
|
-
async fn (state) {
|
|
195
|
-
var _ref;
|
|
196
|
-
var _options_limiter;
|
|
197
|
-
const overflow = await detectOverflow(state, options);
|
|
198
|
-
const coords = {
|
|
199
|
-
x: state.x,
|
|
200
|
-
y: state.y
|
|
201
|
-
};
|
|
202
|
-
const main = vertical(state.placement) ? 'x' : 'y';
|
|
203
|
-
const cross = main === 'x' ? 'y' : 'x';
|
|
204
|
-
const enabled = {
|
|
205
|
-
[main]: options.mainAxis !== false,
|
|
206
|
-
[cross]: !!options.crossAxis
|
|
207
|
-
};
|
|
208
|
-
for (const axis of [
|
|
209
|
-
'x',
|
|
210
|
-
'y'
|
|
211
|
-
]){
|
|
212
|
-
if (enabled[axis]) {
|
|
213
|
-
coords[axis] = clamp(coords[axis] + overflow[axis === 'x' ? 'left' : 'top'], coords[axis], coords[axis] - overflow[axis === 'x' ? 'right' : 'bottom']);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const limited = (_ref = (_options_limiter = options.limiter) === null || _options_limiter === void 0 ? void 0 : _options_limiter.fn({
|
|
217
|
-
...state,
|
|
218
|
-
...coords
|
|
219
|
-
})) !== null && _ref !== void 0 ? _ref : coords;
|
|
220
|
-
return {
|
|
221
|
-
...limited,
|
|
222
|
-
data: {
|
|
223
|
-
x: limited.x - state.x,
|
|
224
|
-
y: limited.y - state.y,
|
|
225
|
-
enabled
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
export function size(options) {
|
|
232
|
-
return {
|
|
233
|
-
name: 'size',
|
|
234
|
-
async fn (state) {
|
|
235
|
-
var _state_platform_isRTL, _state_platform, _state_middlewareData_shift, _state_middlewareData_shift1, _options_apply;
|
|
236
|
-
const overflow = await detectOverflow(state, options);
|
|
237
|
-
const side = sideOf(state.placement);
|
|
238
|
-
const align = alignOf(state.placement);
|
|
239
|
-
const rtl = await ((_state_platform_isRTL = (_state_platform = state.platform).isRTL) === null || _state_platform_isRTL === void 0 ? void 0 : _state_platform_isRTL.call(_state_platform, state.elements.floating));
|
|
240
|
-
const { width, height } = state.rects.floating;
|
|
241
|
-
const widthSide = vertical(state.placement) ? align === (rtl ? 'start' : 'end') ? 'left' : 'right' : side;
|
|
242
|
-
const heightSide = vertical(state.placement) ? side : align === 'end' ? 'top' : 'bottom';
|
|
243
|
-
const maxWidth = width - overflow.left - overflow.right;
|
|
244
|
-
const maxHeight = height - overflow.top - overflow.bottom;
|
|
245
|
-
const availableWidth = ((_state_middlewareData_shift = state.middlewareData.shift) === null || _state_middlewareData_shift === void 0 ? void 0 : _state_middlewareData_shift.enabled.x) ? maxWidth : Math.min(width - overflow[widthSide], maxWidth);
|
|
246
|
-
const availableHeight = ((_state_middlewareData_shift1 = state.middlewareData.shift) === null || _state_middlewareData_shift1 === void 0 ? void 0 : _state_middlewareData_shift1.enabled.y) ? maxHeight : Math.min(height - overflow[heightSide], maxHeight);
|
|
247
|
-
await ((_options_apply = options.apply) === null || _options_apply === void 0 ? void 0 : _options_apply.call(options, {
|
|
248
|
-
...state,
|
|
249
|
-
availableWidth,
|
|
250
|
-
availableHeight
|
|
251
|
-
}));
|
|
252
|
-
const dimensions = await state.platform.getDimensions(state.elements.floating);
|
|
253
|
-
return width !== dimensions.width || height !== dimensions.height ? {
|
|
254
|
-
reset: {
|
|
255
|
-
rects: true
|
|
256
|
-
}
|
|
257
|
-
} : {};
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
package/lib/engine/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/engine/index.ts"],"sourcesContent":["import type {\n DetectOverflowOptions,\n FlipOptions,\n LimitShiftOptions,\n Middleware,\n MiddlewareState,\n OffsetOptions,\n Padding,\n Placement,\n ReferenceElement,\n Side,\n ShiftOptions,\n SizeOptions,\n} from '@floating-ui/dom';\n\nconst opposite: Record<Side, Side> = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' };\nconst sideOf = (placement: Placement) => placement.split('-')[0] as Side;\nconst alignOf = (placement: Placement) => placement.split('-')[1];\nconst vertical = (placement: Placement) => /^(top|bottom)/.test(placement);\nconst clamp = (min: number, value: number, max: number) => Math.max(min, Math.min(value, max));\nconst paddingOf = (padding: Padding = 0) =>\n typeof padding === 'number'\n ? { top: padding, right: padding, bottom: padding, left: padding }\n : { top: 0, right: 0, bottom: 0, left: 0, ...padding };\n\nexport async function detectOverflow(\n state: MiddlewareState,\n options: DetectOverflowOptions = {},\n): Promise<Record<Side, number>> {\n const { rects, elements, platform, strategy } = state;\n const {\n elementContext = 'floating',\n altBoundary = false,\n boundary = 'clippingAncestors',\n rootBoundary = 'viewport',\n } = options;\n const context = altBoundary ? (elementContext === 'floating' ? 'reference' : 'floating') : elementContext;\n const element = elements[context];\n const clippingElement = (await platform.isElement?.(element))\n ? (element as Element)\n : (element as ReferenceElement & { contextElement?: Element }).contextElement ??\n elements.floating.ownerDocument.documentElement;\n const clip = await platform.getClippingRect({ element: clippingElement, boundary, rootBoundary, strategy });\n const parent = await platform.getOffsetParent?.(elements.floating);\n const scale =\n parent && (await platform.isElement?.(parent)) && platform.getScale\n ? await platform.getScale(parent)\n : { x: 1, y: 1 };\n const local =\n elementContext === 'reference'\n ? rects.reference\n : { x: state.x, y: state.y, width: rects.floating.width, height: rects.floating.height };\n const rect = platform.convertOffsetParentRelativeRectToViewportRelativeRect\n ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n elements,\n rect: local,\n offsetParent: parent,\n strategy,\n })\n : local;\n const padding = paddingOf(options.padding);\n return {\n top: (clip.y - rect.y + padding.top) / scale.y,\n bottom: (rect.y + rect.height - clip.y - clip.height + padding.bottom) / scale.y,\n left: (clip.x - rect.x + padding.left) / scale.x,\n right: (rect.x + rect.width - clip.x - clip.width + padding.right) / scale.x,\n };\n}\n\nexport function offset(options: OffsetOptions = 0): Middleware {\n return {\n name: 'offset',\n async fn(state) {\n const raw = typeof options === 'function' ? options(state) : options;\n const value = typeof raw === 'number' ? { mainAxis: raw } : raw;\n let cross = value.crossAxis || 0;\n if (alignOf(state.placement) && typeof value.alignmentAxis === 'number') {\n cross = value.alignmentAxis * (alignOf(state.placement) === 'end' ? -1 : 1);\n }\n const isVertical = vertical(state.placement);\n const rtl = await state.platform.isRTL?.(state.elements.floating);\n const main = (value.mainAxis || 0) * (/^(top|left)/.test(state.placement) ? -1 : 1);\n cross *= rtl && isVertical ? -1 : 1;\n if (state.middlewareData.offset?.placement === state.placement && state.middlewareData.arrow?.alignmentOffset) {\n return {};\n }\n const delta = { x: isVertical ? cross : main, y: isVertical ? main : cross };\n return { x: state.x + delta.x, y: state.y + delta.y, data: { ...delta, placement: state.placement } };\n },\n };\n}\n\nexport function flip(options: FlipOptions = {}): Middleware {\n return {\n name: 'flip',\n async fn(state) {\n if (state.middlewareData.arrow?.alignmentOffset) {\n return {};\n }\n const initial = state.initialPlacement;\n const align = alignOf(initial);\n const oppositePlacement = (p: Placement): Placement =>\n `${opposite[sideOf(p)]}${alignOf(p) ? `-${alignOf(p)}` : ''}` as Placement;\n const oppositeAlignment = (p: Placement): Placement =>\n p.replace(/start|end/, match => (match === 'start' ? 'end' : 'start')) as Placement;\n const candidates = [\n initial,\n ...(options.fallbackPlacements ??\n (align\n ? [oppositeAlignment(initial), oppositePlacement(initial), oppositeAlignment(oppositePlacement(initial))]\n : [oppositePlacement(initial)])),\n ];\n const overflow = await detectOverflow(state, options);\n const isVertical = vertical(state.placement);\n const rtl = await state.platform.isRTL?.(state.elements.floating);\n const length = isVertical ? 'width' : 'height';\n let alignmentSide: Side = isVertical\n ? alignOf(state.placement) === (rtl ? 'end' : 'start')\n ? 'right'\n : 'left'\n : alignOf(state.placement) === 'start'\n ? 'bottom'\n : 'top';\n if (state.rects.reference[length] > state.rects.floating[length]) {\n alignmentSide = opposite[alignmentSide];\n }\n const overflows = [overflow[sideOf(state.placement)], overflow[alignmentSide], overflow[opposite[alignmentSide]]];\n const attempts: { placement: Placement; overflows: number[] }[] = [\n ...(state.middlewareData.flip?.overflows ?? []),\n { placement: state.placement, overflows },\n ];\n if (overflows.every(value => value <= 0)) {\n return {};\n }\n const index = (state.middlewareData.flip?.index ?? 0) + 1;\n if (candidates[index]) {\n return { data: { index, overflows: attempts }, reset: { placement: candidates[index] } };\n }\n const fitting = attempts.filter(item => item.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1]);\n const score = (values: number[]) => values.reduce((sum, value) => sum + Math.max(0, value), 0);\n const best = fitting[0] ?? attempts.sort((a, b) => score(a.overflows) - score(b.overflows))[0];\n return best.placement === state.placement ? {} : { reset: { placement: best.placement } };\n },\n };\n}\n\nexport function limitShift(options: LimitShiftOptions = {}): NonNullable<ShiftOptions['limiter']> {\n return {\n fn(state) {\n const coords = { x: state.x, y: state.y };\n const main = vertical(state.placement) ? 'x' : 'y';\n const cross = main === 'x' ? 'y' : 'x';\n const { reference: r, floating: f } = state.rects;\n if (options.mainAxis !== false) {\n const length = main === 'x' ? 'width' : 'height';\n coords[main] = clamp(r[main] - f[length], coords[main], r[main] + r[length]);\n }\n if (options.crossAxis !== false) {\n const length = cross === 'x' ? 'width' : 'height';\n const origin = /^(top|left)/.test(state.placement);\n const delta = state.middlewareData.offset?.[cross] || 0;\n coords[cross] = clamp(\n r[cross] - f[length] + (origin ? delta : 0),\n coords[cross],\n r[cross] + r[length] + (origin ? 0 : delta),\n );\n }\n return coords;\n },\n };\n}\n\nexport function shift(options: ShiftOptions = {}): Middleware {\n return {\n name: 'shift',\n async fn(state) {\n const overflow = await detectOverflow(state, options);\n const coords = { x: state.x, y: state.y };\n const main = vertical(state.placement) ? 'x' : 'y';\n const cross = main === 'x' ? 'y' : 'x';\n const enabled = { [main]: options.mainAxis !== false, [cross]: !!options.crossAxis };\n for (const axis of ['x', 'y'] as const) {\n if (enabled[axis]) {\n coords[axis] = clamp(\n coords[axis] + overflow[axis === 'x' ? 'left' : 'top'],\n coords[axis],\n coords[axis] - overflow[axis === 'x' ? 'right' : 'bottom'],\n );\n }\n }\n const limited = options.limiter?.fn({ ...state, ...coords }) ?? coords;\n return { ...limited, data: { x: limited.x - state.x, y: limited.y - state.y, enabled } };\n },\n };\n}\n\nexport function size(options: SizeOptions): Middleware {\n return {\n name: 'size',\n async fn(state) {\n const overflow = await detectOverflow(state, options);\n const side = sideOf(state.placement);\n const align = alignOf(state.placement);\n const rtl = await state.platform.isRTL?.(state.elements.floating);\n const { width, height } = state.rects.floating;\n const widthSide = vertical(state.placement) ? (align === (rtl ? 'start' : 'end') ? 'left' : 'right') : side;\n const heightSide = vertical(state.placement) ? side : align === 'end' ? 'top' : 'bottom';\n const maxWidth = width - overflow.left - overflow.right;\n const maxHeight = height - overflow.top - overflow.bottom;\n const availableWidth = state.middlewareData.shift?.enabled.x\n ? maxWidth\n : Math.min(width - overflow[widthSide], maxWidth);\n const availableHeight = state.middlewareData.shift?.enabled.y\n ? maxHeight\n : Math.min(height - overflow[heightSide], maxHeight);\n await options.apply?.({ ...state, availableWidth, availableHeight });\n const dimensions = await state.platform.getDimensions(state.elements.floating);\n return width !== dimensions.width || height !== dimensions.height ? { reset: { rects: true } } : {};\n },\n };\n}\n"],"names":["opposite","top","bottom","left","right","sideOf","placement","split","alignOf","vertical","test","clamp","min","value","max","Math","paddingOf","padding","detectOverflow","state","options","platform","rects","elements","strategy","elementContext","altBoundary","boundary","rootBoundary","context","element","clippingElement","isElement","contextElement","floating","ownerDocument","documentElement","clip","getClippingRect","parent","getOffsetParent","scale","getScale","x","y","local","reference","width","height","rect","convertOffsetParentRelativeRectToViewportRelativeRect","offsetParent","offset","name","fn","raw","mainAxis","cross","crossAxis","alignmentAxis","isVertical","rtl","isRTL","main","middlewareData","arrow","alignmentOffset","delta","data","flip","fitting","initial","initialPlacement","align","oppositePlacement","p","oppositeAlignment","replace","match","candidates","fallbackPlacements","overflow","length","alignmentSide","overflows","attempts","every","index","reset","filter","item","sort","a","b","score","values","reduce","sum","best","limitShift","coords","r","f","origin","shift","enabled","axis","limited","limiter","size","side","widthSide","heightSide","maxWidth","maxHeight","availableWidth","availableHeight","apply","dimensions","getDimensions"],"mappings":"AAeA,MAAMA,WAA+B;IAAEC,KAAK;IAAUC,QAAQ;IAAOC,MAAM;IAASC,OAAO;AAAO;AAClG,MAAMC,SAAS,CAACC,YAAyBA,UAAUC,KAAK,CAAC,IAAI,CAAC,EAAE;AAChE,MAAMC,UAAU,CAACF,YAAyBA,UAAUC,KAAK,CAAC,IAAI,CAAC,EAAE;AACjE,MAAME,WAAW,CAACH,YAAyB,gBAAgBI,IAAI,CAACJ;AAChE,MAAMK,QAAQ,CAACC,KAAaC,OAAeC,MAAgBC,KAAKD,GAAG,CAACF,KAAKG,KAAKH,GAAG,CAACC,OAAOC;AACzF,MAAME,YAAY,CAACC,UAAmB,CAAC,GACrC,OAAOA,YAAY,WACf;QAAEhB,KAAKgB;QAASb,OAAOa;QAASf,QAAQe;QAASd,MAAMc;IAAQ,IAC/D;QAAEhB,KAAK;QAAGG,OAAO;QAAGF,QAAQ;QAAGC,MAAM;QAAG,GAAGc,OAAO;IAAC;AAEzD,OAAO,eAAeC,eACpBC,KAAsB,EACtBC,UAAiC,CAAC,CAAC;QAa/B;QAF2BC,qBAKVA,2BAEFA;IAhBnB,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEF,QAAQ,EAAEG,QAAQ,EAAE,GAAGL;IAChD,MAAM,EACJM,iBAAiB,UAAU,EAC3BC,cAAc,KAAK,EACnBC,WAAW,mBAAmB,EAC9BC,eAAe,UAAU,EAC1B,GAAGR;IACJ,MAAMS,UAAUH,cAAeD,mBAAmB,aAAa,cAAc,aAAcA;IAC3F,MAAMK,UAAUP,QAAQ,CAACM,QAAQ;IACjC,MAAME,kBAAkB,AAAC,QAAMV,sBAAAA,SAASW,SAAS,cAAlBX,0CAAAA,yBAAAA,UAAqBS,YAC/CA,WACD,0BAAA,AAACA,QAA4DG,cAAc,cAA3E,qCAAA,0BACAV,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,EAAEE;YAC1C,MAAMG,kBAAkBjG,EAAAA,+BAAAA,MAAM6C,cAAc,CAACwC,KAAK,cAA1BrF,mDAAAA,6BAA4BsF,OAAO,CAAC7D,CAAC,IACzDsE,YACAnG,KAAKH,GAAG,CAACoC,SAASiC,QAAQ,CAAC+B,WAAW,EAAEE;YAC5C,QAAM9F,iBAAAA,QAAQiG,KAAK,cAAbjG,qCAAAA,oBAAAA,SAAgB;gBAAE,GAAGD,KAAK;gBAAEgG;gBAAgBC;YAAgB;YAClE,MAAME,aAAa,MAAMnG,MAAME,QAAQ,CAACkG,aAAa,CAACpG,MAAMI,QAAQ,CAACW,QAAQ;YAC7E,OAAOa,UAAUuE,WAAWvE,KAAK,IAAIC,WAAWsE,WAAWtE,MAAM,GAAG;gBAAEwC,OAAO;oBAAElE,OAAO;gBAAK;YAAE,IAAI,CAAC;QACpG;IACF;AACF"}
|
package/lib/engine/platform.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { isHTMLElement } from "@fluentui/react-utilities";
|
|
2
|
-
// Expression-bodied helpers and plain property access keep the ES2019 output compact.
|
|
3
|
-
export const getWindow = (node)=>node.ownerDocument.defaultView;
|
|
4
|
-
export const getRoot = (node)=>node.ownerDocument.documentElement;
|
|
5
|
-
export const getStyle = (element)=>getWindow(element).getComputedStyle(element);
|
|
6
|
-
/** A CSS pixel value, an empty string removes the inline style */ export const px = (value)=>value === undefined ? '' : `${value}px`;
|
|
7
|
-
// Properties that are not supported are empty strings (i.e. in jsdom)
|
|
8
|
-
const isSet = (value)=>!!value && value !== 'none';
|
|
9
|
-
/** Uses `CSS.supports()` of the element's window, which is unavailable in some environments (e.g. jsdom) */ const isWebKit = (element)=>{
|
|
10
|
-
const css = getWindow(element).CSS;
|
|
11
|
-
return !!css && !!css.supports && css.supports('-webkit-backdrop-filter', 'none');
|
|
12
|
-
};
|
|
13
|
-
/** Shared and never mutated */ export const NO_OFFSET = {
|
|
14
|
-
x: 0,
|
|
15
|
-
y: 0
|
|
16
|
-
};
|
|
17
|
-
const getVisualOffsets = (element)=>{
|
|
18
|
-
const viewport = getWindow(element).visualViewport;
|
|
19
|
-
return isWebKit(element) && viewport ? {
|
|
20
|
-
x: viewport.offsetLeft,
|
|
21
|
-
y: viewport.offsetTop
|
|
22
|
-
} : NO_OFFSET;
|
|
23
|
-
};
|
|
24
|
-
const getBounds = (target)=>target.getBoundingClientRect();
|
|
25
|
-
export const rect = (x, y, width, height)=>({
|
|
26
|
-
x,
|
|
27
|
-
y,
|
|
28
|
-
width,
|
|
29
|
-
height
|
|
30
|
-
});
|
|
31
|
-
export const intersect = (a, b)=>{
|
|
32
|
-
const x = Math.max(a.x, b.x);
|
|
33
|
-
const y = Math.max(a.y, b.y);
|
|
34
|
-
return rect(x, y, Math.min(a.x + a.width, b.x + b.width) - x, Math.min(a.y + a.height, b.y + b.height) - y);
|
|
35
|
-
};
|
|
36
|
-
export const isContainingBlock = (element, style, strategy)=>// Boxless elements can't form containing blocks, and WebKit ignores filters
|
|
37
|
-
style.display !== 'contents' && (strategy === 'absolute' && !/^(static)?$/.test(style.position) || 'transform translate scale rotate perspective'.split(' ').some((property)=>isSet(style[property])) || (isSet(style.filter) || isSet(style.backdropFilter)) && !isWebKit(element) || /auto|hidden/.test(style.contentVisibility) || !!style.containerType && style.containerType !== 'normal' || /transform|perspective|filter/.test(style.willChange) || /paint|layout|strict|content/.test(style.contain));
|
|
38
|
-
/** The parent element, through slot assignments and shadow roots but not virtual parents */ export const getPhysicalParent = (element)=>{
|
|
39
|
-
if (isTopLayer(element)) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
let parent = element.assignedSlot || element.parentNode;
|
|
43
|
-
if (parent && parent.nodeType === 11) {
|
|
44
|
-
parent = parent.host;
|
|
45
|
-
}
|
|
46
|
-
return parent && parent.nodeType === 1 ? parent : null;
|
|
47
|
-
};
|
|
48
|
-
/** Open popovers and modal dialogs escape the clipping and containing blocks of their ancestors */ const isTopLayer = (element)=>{
|
|
49
|
-
try {
|
|
50
|
-
// A single forgiving `:is()` match per ancestor: unsupported pseudo-classes never match, and environments
|
|
51
|
-
// without `:is()` (e.g. jsdom) throw
|
|
52
|
-
return element.matches(':is(:popover-open, :modal)');
|
|
53
|
-
} catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Walks the physical ancestors (including SVG elements) of an element up to (excluding) the root element,
|
|
59
|
-
* stops when the callback returns true and returns that ancestor.
|
|
60
|
-
*/ export const findAncestor = (element, callback)=>{
|
|
61
|
-
const root = getRoot(element);
|
|
62
|
-
for(let node = getPhysicalParent(element); node && node !== root; node = getPhysicalParent(node)){
|
|
63
|
-
if (callback(node, getStyle(node))) {
|
|
64
|
-
return node;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
};
|
|
69
|
-
/** The ancestors that can clip the element, the closest first */ export const getScrollAncestors = (element)=>{
|
|
70
|
-
const ancestors = [];
|
|
71
|
-
const isPositioned = (position)=>position === 'fixed' || position === 'absolute';
|
|
72
|
-
const { position } = getStyle(element);
|
|
73
|
-
let strategy = isPositioned(position) ? position : '';
|
|
74
|
-
findAncestor(element, (node, style)=>{
|
|
75
|
-
// Positioned descendants escape overflow between themselves and their containing block.
|
|
76
|
-
if (strategy && isContainingBlock(node, style, strategy)) {
|
|
77
|
-
strategy = '';
|
|
78
|
-
}
|
|
79
|
-
// The overflow of the body propagates to the viewport, which is always part of the clipping rect
|
|
80
|
-
if (!strategy && node !== element.ownerDocument.body && isHTMLElement(node) && !/^(inline|contents)$/.test(style.display) && /auto|scroll|overlay|hidden|clip/.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
81
|
-
ancestors.push(node);
|
|
82
|
-
}
|
|
83
|
-
if (!strategy && isPositioned(style.position)) {
|
|
84
|
-
strategy = style.position;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
return ancestors;
|
|
88
|
-
};
|
|
89
|
-
/** CSS dimensions, or the rounded layout dimensions when they differ after rounding */ export const getDimensions = (element)=>{
|
|
90
|
-
const css = getStyle(element);
|
|
91
|
-
const width = parseFloat(css.width) || 0;
|
|
92
|
-
const height = parseFloat(css.height) || 0;
|
|
93
|
-
const rounded = isHTMLElement(element) && (Math.round(width) !== element.offsetWidth || Math.round(height) !== element.offsetHeight);
|
|
94
|
-
return {
|
|
95
|
-
width: rounded ? element.offsetWidth : width,
|
|
96
|
-
height: rounded ? element.offsetHeight : height,
|
|
97
|
-
rounded
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export const getScale = (element)=>{
|
|
101
|
-
const bounds = getBounds(element);
|
|
102
|
-
const { width, height, rounded } = getDimensions(element);
|
|
103
|
-
// Zero, infinite and NaN scales (e.g. of hidden elements) fall back to 1
|
|
104
|
-
const finite = (value)=>value && Number.isFinite(value) ? value : 1;
|
|
105
|
-
return {
|
|
106
|
-
x: finite((rounded ? Math.round(bounds.width) : bounds.width) / width),
|
|
107
|
-
y: finite((rounded ? Math.round(bounds.height) : bounds.height) / height)
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
/** The viewport rect of the element's padding box, in CSS pixels of its own window */ const getClientRect = (element)=>{
|
|
111
|
-
const bounds = getBounds(element);
|
|
112
|
-
const scale = getScale(element);
|
|
113
|
-
return {
|
|
114
|
-
...rect(bounds.left + element.clientLeft * scale.x, bounds.top + element.clientTop * scale.y, element.clientWidth * scale.x, element.clientHeight * scale.y),
|
|
115
|
-
scale
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
/** The offset and scale of a window's viewport within the top-most same-origin window */ const getWindowSpace = (win)=>{
|
|
119
|
-
const space = {
|
|
120
|
-
x: 0,
|
|
121
|
-
y: 0,
|
|
122
|
-
scale: {
|
|
123
|
-
x: 1,
|
|
124
|
-
y: 1
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
for(let frame = win.frameElement; isHTMLElement(frame); frame = getWindow(frame).frameElement){
|
|
128
|
-
const bounds = getBounds(frame);
|
|
129
|
-
const scale = getScale(frame);
|
|
130
|
-
const css = getStyle(frame);
|
|
131
|
-
space.x = bounds.left + (frame.clientLeft + (parseFloat(css.paddingLeft) || 0) + space.x) * scale.x;
|
|
132
|
-
space.y = bounds.top + (frame.clientTop + (parseFloat(css.paddingTop) || 0) + space.y) * scale.y;
|
|
133
|
-
space.scale.x *= scale.x;
|
|
134
|
-
space.scale.y *= scale.y;
|
|
135
|
-
}
|
|
136
|
-
return space;
|
|
137
|
-
};
|
|
138
|
-
/** Converts a viewport rect of one window to a viewport rect of another (same-origin) window */ const convertWindowRect = (value, from, to)=>{
|
|
139
|
-
if (from === to) {
|
|
140
|
-
return value;
|
|
141
|
-
}
|
|
142
|
-
const { x, y, scale } = getWindowSpace(from);
|
|
143
|
-
const target = getWindowSpace(to);
|
|
144
|
-
const targetScale = target.scale;
|
|
145
|
-
return rect((x + value.x * scale.x - target.x) / targetScale.x, (y + value.y * scale.y - target.y) / targetScale.y, value.width * scale.x / targetScale.x, value.height * scale.y / targetScale.y);
|
|
146
|
-
};
|
|
147
|
-
const isStatic = (element)=>getStyle(element).position === 'static';
|
|
148
|
-
export const getOffsetParent = (element)=>{
|
|
149
|
-
if (isTopLayer(element)) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
const strategy = getStyle(element).position === 'fixed' ? 'fixed' : 'absolute';
|
|
153
|
-
let parent = strategy === 'fixed' ? null : element.offsetParent;
|
|
154
|
-
while(isHTMLElement(parent) && /^(TABLE|TD|TH)$/.test(parent.tagName) && isStatic(parent)){
|
|
155
|
-
parent = parent.offsetParent;
|
|
156
|
-
}
|
|
157
|
-
return isHTMLElement(parent) && (!/^(HTML|BODY)$/.test(parent.tagName) || !isStatic(parent)) ? parent : findAncestor(element, (node, style)=>isHTMLElement(node) && isContainingBlock(node, style, strategy));
|
|
158
|
-
};
|
|
159
|
-
/** The viewport offset and scale of the coordinate space used to position the element */ export const getCoordinateSpace = (element, strategy)=>{
|
|
160
|
-
const parent = getOffsetParent(element);
|
|
161
|
-
if (parent) {
|
|
162
|
-
const { x, y, scale } = getClientRect(parent);
|
|
163
|
-
return {
|
|
164
|
-
parent,
|
|
165
|
-
scale,
|
|
166
|
-
x: x - parent.scrollLeft * scale.x,
|
|
167
|
-
y: y - parent.scrollTop * scale.y
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
const bounds = getBounds(getRoot(element));
|
|
171
|
-
return {
|
|
172
|
-
scale: {
|
|
173
|
-
x: 1,
|
|
174
|
-
y: 1
|
|
175
|
-
},
|
|
176
|
-
x: strategy === 'fixed' ? 0 : bounds.left,
|
|
177
|
-
y: strategy === 'fixed' ? 0 : bounds.top
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* The reference rect in the floating element's coordinate space, `context` is the reference element or the element
|
|
182
|
-
* that a virtual reference is relative to (the floating element's root element by default).
|
|
183
|
-
*/ export const getReferenceRect = (reference, context, floating, space, strategy)=>{
|
|
184
|
-
const floatingWindow = getWindow(floating);
|
|
185
|
-
const referenceWindow = getWindow(context);
|
|
186
|
-
const bounds = convertWindowRect(getBounds(reference), referenceWindow, floatingWindow);
|
|
187
|
-
const visual = strategy === 'fixed' && referenceWindow === floatingWindow && !space.parent ? getVisualOffsets(floating) : NO_OFFSET;
|
|
188
|
-
const { x, y, scale } = space;
|
|
189
|
-
return rect((bounds.x + visual.x - x) / scale.x, (bounds.y + visual.y - y) / scale.y, bounds.width / scale.x, bounds.height / scale.y);
|
|
190
|
-
};
|
|
191
|
-
/** The visible area of the element within the boundary, in viewport pixels of `floatingWindow` */ export const getClippingRect = (element, boundary, floatingWindow = getWindow(element), strategy = 'absolute')=>{
|
|
192
|
-
const win = getWindow(element);
|
|
193
|
-
const root = getRoot(element);
|
|
194
|
-
const viewport = win.visualViewport;
|
|
195
|
-
// WebKit lays out absolute elements relative to the layout viewport, rect boundaries are in its coordinates too
|
|
196
|
-
const visual = getVisualOffsets(element);
|
|
197
|
-
const layout = strategy === 'fixed' ? NO_OFFSET : visual;
|
|
198
|
-
const clippingAncestors = boundary === 'clippingAncestors';
|
|
199
|
-
let clip = viewport ? rect(viewport.offsetLeft - layout.x, viewport.offsetTop - layout.y, viewport.width, viewport.height) : rect(0, 0, root.clientWidth, root.clientHeight);
|
|
200
|
-
for (const item of clippingAncestors ? getScrollAncestors(element) : [].concat(boundary)){
|
|
201
|
-
if (item && typeof item === 'object') {
|
|
202
|
-
const { x, y, width, height } = item;
|
|
203
|
-
clip = intersect(clip, 'nodeType' in item ? convertWindowRect(getClientRect(item), getWindow(item), win) : rect(x - visual.x, y - visual.y, width, height));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const result = convertWindowRect(clip, win, floatingWindow);
|
|
207
|
-
const frame = win.frameElement;
|
|
208
|
-
return clippingAncestors && win !== floatingWindow && isHTMLElement(frame) ? intersect(result, getClippingRect(frame, boundary, floatingWindow, strategy)) : result;
|
|
209
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/engine/platform.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport type { Boundary, Rect, Strategy } from '@floating-ui/dom';\n\ntype Scale = { x: number; y: number };\ntype CoordinateSpace = Scale & { scale: Scale; parent?: HTMLElement | null };\n\n// Expression-bodied helpers and plain property access keep the ES2019 output compact.\n\nexport const getWindow = (node: Node): Window => node.ownerDocument!.defaultView!;\nexport const getRoot = (node: Node): HTMLElement => node.ownerDocument!.documentElement;\nexport const getStyle = (element: Element): CSSStyleDeclaration => getWindow(element).getComputedStyle(element);\n\n/** A CSS pixel value, an empty string removes the inline style */\nexport const px = (value: number | undefined): string => (value === undefined ? '' : `${value}px`);\n\n// Properties that are not supported are empty strings (i.e. in jsdom)\nconst isSet = (value: string | undefined): boolean => !!value && value !== 'none';\n\n/** Uses `CSS.supports()` of the element's window, which is unavailable in some environments (e.g. jsdom) */\nconst isWebKit = (element: Element): boolean => {\n const css = (getWindow(element) as Window & typeof globalThis).CSS;\n return !!css && !!css.supports && css.supports('-webkit-backdrop-filter', 'none');\n};\n\n/** Shared and never mutated */\nexport const NO_OFFSET: Scale = { x: 0, y: 0 };\n\nconst getVisualOffsets = (element: Element): Scale => {\n const viewport = getWindow(element).visualViewport;\n return isWebKit(element) && viewport ? { x: viewport.offsetLeft, y: viewport.offsetTop } : NO_OFFSET;\n};\n\nconst getBounds = (target: { getBoundingClientRect(): DOMRect | Rect }) => target.getBoundingClientRect() as DOMRect;\n\nexport const rect = (x: number, y: number, width: number, height: number): Rect => ({ x, y, width, height });\n\nexport const intersect = (a: Rect, b: Rect): Rect => {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n\n return rect(x, y, Math.min(a.x + a.width, b.x + b.width) - x, Math.min(a.y + a.height, b.y + b.height) - y);\n};\n\nexport const isContainingBlock = (\n element: Element,\n style: CSSStyleDeclaration,\n strategy: 'absolute' | 'fixed',\n): boolean =>\n // Boxless elements can't form containing blocks, and WebKit ignores filters\n style.display !== 'contents' &&\n ((strategy === 'absolute' && !/^(static)?$/.test(style.position)) ||\n ('transform translate scale rotate perspective'.split(' ') as 'scale'[]).some(property => isSet(style[property])) ||\n ((isSet(style.filter) || isSet(style.backdropFilter)) && !isWebKit(element)) ||\n /auto|hidden/.test(style.contentVisibility) ||\n (!!style.containerType && style.containerType !== 'normal') ||\n /transform|perspective|filter/.test(style.willChange) ||\n /paint|layout|strict|content/.test(style.contain));\n\n/** The parent element, through slot assignments and shadow roots but not virtual parents */\nexport const getPhysicalParent = (element: Element): Element | null => {\n if (isTopLayer(element)) {\n return null;\n }\n let parent: Node | null = element.assignedSlot || element.parentNode;\n if (parent && parent.nodeType === 11) {\n parent = (parent as ShadowRoot).host;\n }\n return parent && parent.nodeType === 1 ? (parent as Element) : null;\n};\n\n/** Open popovers and modal dialogs escape the clipping and containing blocks of their ancestors */\nconst isTopLayer = (element: Element): boolean => {\n try {\n // A single forgiving `:is()` match per ancestor: unsupported pseudo-classes never match, and environments\n // without `:is()` (e.g. jsdom) throw\n return element.matches(':is(:popover-open, :modal)');\n } catch {\n return false;\n }\n};\n\n/**\n * Walks the physical ancestors (including SVG elements) of an element up to (excluding) the root element,\n * stops when the callback returns true and returns that ancestor.\n */\nexport const findAncestor = (\n element: Element,\n callback: (node: Element, style: CSSStyleDeclaration) => unknown,\n): Element | null => {\n const root = getRoot(element);\n for (let node = getPhysicalParent(element); node && node !== root; node = getPhysicalParent(node)) {\n if (callback(node, getStyle(node))) {\n return node;\n }\n }\n return null;\n};\n\n/** The ancestors that can clip the element, the closest first */\nexport const getScrollAncestors = (element: Element): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n const isPositioned = (position: string) => position === 'fixed' || position === 'absolute';\n const { position } = getStyle(element);\n let strategy = isPositioned(position) ? position : '';\n\n findAncestor(element, (node, style) => {\n // Positioned descendants escape overflow between themselves and their containing block.\n if (strategy && isContainingBlock(node, style, strategy as 'absolute' | 'fixed')) {\n strategy = '';\n }\n // The overflow of the body propagates to the viewport, which is always part of the clipping rect\n if (\n !strategy &&\n node !== element.ownerDocument.body &&\n isHTMLElement(node) &&\n !/^(inline|contents)$/.test(style.display) &&\n /auto|scroll|overlay|hidden|clip/.test(style.overflow + style.overflowX + style.overflowY)\n ) {\n ancestors.push(node);\n }\n if (!strategy && isPositioned(style.position)) {\n strategy = style.position;\n }\n });\n\n return ancestors;\n};\n\n/** CSS dimensions, or the rounded layout dimensions when they differ after rounding */\nexport const getDimensions = (element: Element): { width: number; height: number; rounded: boolean } => {\n const css = getStyle(element);\n const width = parseFloat(css.width) || 0;\n const height = parseFloat(css.height) || 0;\n const rounded =\n isHTMLElement(element) &&\n (Math.round(width) !== element.offsetWidth || Math.round(height) !== element.offsetHeight);\n return {\n width: rounded ? (element as HTMLElement).offsetWidth : width,\n height: rounded ? (element as HTMLElement).offsetHeight : height,\n rounded,\n };\n};\n\nexport const getScale = (element: HTMLElement): Scale => {\n const bounds = getBounds(element);\n const { width, height, rounded } = getDimensions(element);\n // Zero, infinite and NaN scales (e.g. of hidden elements) fall back to 1\n const finite = (value: number) => (value && Number.isFinite(value) ? value : 1);\n return {\n x: finite((rounded ? Math.round(bounds.width) : bounds.width) / width),\n y: finite((rounded ? Math.round(bounds.height) : bounds.height) / height),\n };\n};\n\n/** The viewport rect of the element's padding box, in CSS pixels of its own window */\nconst getClientRect = (element: HTMLElement): Rect & { scale: Scale } => {\n const bounds = getBounds(element);\n const scale = getScale(element);\n return {\n ...rect(\n bounds.left + element.clientLeft * scale.x,\n bounds.top + element.clientTop * scale.y,\n element.clientWidth * scale.x,\n element.clientHeight * scale.y,\n ),\n scale,\n };\n};\n\n/** The offset and scale of a window's viewport within the top-most same-origin window */\nconst getWindowSpace = (win: Window): CoordinateSpace => {\n const space = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n for (let frame = win.frameElement; isHTMLElement(frame); frame = getWindow(frame).frameElement) {\n const bounds = getBounds(frame);\n const scale = getScale(frame);\n const css = getStyle(frame);\n space.x = bounds.left + (frame.clientLeft + (parseFloat(css.paddingLeft) || 0) + space.x) * scale.x;\n space.y = bounds.top + (frame.clientTop + (parseFloat(css.paddingTop) || 0) + space.y) * scale.y;\n space.scale.x *= scale.x;\n space.scale.y *= scale.y;\n }\n return space;\n};\n\n/** Converts a viewport rect of one window to a viewport rect of another (same-origin) window */\nconst convertWindowRect = (value: Rect, from: Window, to: Window): Rect => {\n if (from === to) {\n return value;\n }\n const { x, y, scale } = getWindowSpace(from);\n const target = getWindowSpace(to);\n const targetScale = target.scale;\n return rect(\n (x + value.x * scale.x - target.x) / targetScale.x,\n (y + value.y * scale.y - target.y) / targetScale.y,\n (value.width * scale.x) / targetScale.x,\n (value.height * scale.y) / targetScale.y,\n );\n};\n\nconst isStatic = (element: Element) => getStyle(element).position === 'static';\n\nexport const getOffsetParent = (element: HTMLElement): HTMLElement | null => {\n if (isTopLayer(element)) {\n return null;\n }\n const strategy = getStyle(element).position === 'fixed' ? 'fixed' : 'absolute';\n let parent = strategy === 'fixed' ? null : element.offsetParent;\n while (isHTMLElement(parent) && /^(TABLE|TD|TH)$/.test(parent.tagName) && isStatic(parent)) {\n parent = parent.offsetParent;\n }\n return isHTMLElement(parent) && (!/^(HTML|BODY)$/.test(parent.tagName) || !isStatic(parent))\n ? parent\n : // The element that forms the containing block, `null` is the viewport or the initial containing block\n (findAncestor(\n element,\n (node, style) => isHTMLElement(node) && isContainingBlock(node, style, strategy),\n ) as HTMLElement | null);\n};\n\n/** The viewport offset and scale of the coordinate space used to position the element */\nexport const getCoordinateSpace = (element: HTMLElement, strategy: Strategy): CoordinateSpace => {\n const parent = getOffsetParent(element);\n if (parent) {\n const { x, y, scale } = getClientRect(parent);\n return { parent, scale, x: x - parent.scrollLeft * scale.x, y: y - parent.scrollTop * scale.y };\n }\n const bounds = getBounds(getRoot(element));\n return {\n scale: { x: 1, y: 1 },\n x: strategy === 'fixed' ? 0 : bounds.left,\n y: strategy === 'fixed' ? 0 : bounds.top,\n };\n};\n\n/**\n * The reference rect in the floating element's coordinate space, `context` is the reference element or the element\n * that a virtual reference is relative to (the floating element's root element by default).\n */\nexport const getReferenceRect = (\n reference: { getBoundingClientRect(): DOMRect | Rect },\n context: Element,\n floating: HTMLElement,\n space: CoordinateSpace,\n strategy: Strategy,\n): Rect => {\n const floatingWindow = getWindow(floating);\n const referenceWindow = getWindow(context);\n const bounds = convertWindowRect(getBounds(reference), referenceWindow, floatingWindow);\n const visual =\n strategy === 'fixed' && referenceWindow === floatingWindow && !space.parent\n ? getVisualOffsets(floating)\n : NO_OFFSET;\n const { x, y, scale } = space;\n return rect(\n (bounds.x + visual.x - x) / scale.x,\n (bounds.y + visual.y - y) / scale.y,\n bounds.width / scale.x,\n bounds.height / scale.y,\n );\n};\n\n/** The visible area of the element within the boundary, in viewport pixels of `floatingWindow` */\nexport const getClippingRect = (\n element: Element,\n boundary: Boundary,\n floatingWindow = getWindow(element),\n strategy: Strategy = 'absolute',\n): Rect => {\n const win = getWindow(element);\n const root = getRoot(element);\n const viewport = win.visualViewport;\n // WebKit lays out absolute elements relative to the layout viewport, rect boundaries are in its coordinates too\n const visual = getVisualOffsets(element);\n const layout = strategy === 'fixed' ? NO_OFFSET : visual;\n const clippingAncestors = boundary === 'clippingAncestors';\n let clip = viewport\n ? rect(viewport.offsetLeft - layout.x, viewport.offsetTop - layout.y, viewport.width, viewport.height)\n : rect(0, 0, root.clientWidth, root.clientHeight);\n for (const item of clippingAncestors ? getScrollAncestors(element) : ([] as unknown[]).concat(boundary)) {\n if (item && typeof item === 'object') {\n const { x, y, width, height } = item as Rect;\n clip = intersect(\n clip,\n 'nodeType' in item\n ? convertWindowRect(getClientRect(item as HTMLElement), getWindow(item as Node), win)\n : rect(x - visual.x, y - visual.y, width, height),\n );\n }\n }\n const result = convertWindowRect(clip, win, floatingWindow);\n const frame = win.frameElement;\n return clippingAncestors && win !== floatingWindow && isHTMLElement(frame)\n ? intersect(result, getClippingRect(frame, boundary, floatingWindow, strategy))\n : result;\n};\n"],"names":["isHTMLElement","getWindow","node","ownerDocument","defaultView","getRoot","documentElement","getStyle","element","getComputedStyle","px","value","undefined","isSet","isWebKit","css","CSS","supports","NO_OFFSET","x","y","getVisualOffsets","viewport","visualViewport","offsetLeft","offsetTop","getBounds","target","getBoundingClientRect","rect","width","height","intersect","a","b","Math","max","min","isContainingBlock","style","strategy","display","test","position","split","some","property","filter","backdropFilter","contentVisibility","containerType","willChange","contain","getPhysicalParent","isTopLayer","parent","assignedSlot","parentNode","nodeType","host","matches","findAncestor","callback","root","getScrollAncestors","ancestors","isPositioned","body","overflow","overflowX","overflowY","push","getDimensions","parseFloat","rounded","round","offsetWidth","offsetHeight","getScale","bounds","finite","Number","isFinite","getClientRect","scale","left","clientLeft","top","clientTop","clientWidth","clientHeight","getWindowSpace","win","space","frame","frameElement","paddingLeft","paddingTop","convertWindowRect","from","to","targetScale","isStatic","getOffsetParent","offsetParent","tagName","getCoordinateSpace","scrollLeft","scrollTop","getReferenceRect","reference","context","floating","floatingWindow","referenceWindow","visual","getClippingRect","boundary","layout","clippingAncestors","clip","item","concat","result"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAM1D,sFAAsF;AAEtF,OAAO,MAAMC,YAAY,CAACC,OAAuBA,KAAKC,aAAa,CAAEC,WAAW,CAAE;AAClF,OAAO,MAAMC,UAAU,CAACH,OAA4BA,KAAKC,aAAa,CAAEG,eAAe,CAAC;AACxF,OAAO,MAAMC,WAAW,CAACC,UAA0CP,UAAUO,SAASC,gBAAgB,CAACD,SAAS;AAEhH,gEAAgE,GAChE,OAAO,MAAME,KAAK,CAACC,QAAuCA,UAAUC,YAAY,KAAK,GAAGD,MAAM,EAAE,CAAC,CAAE;AAEnG,sEAAsE;AACtE,MAAME,QAAQ,CAACF,QAAuC,CAAC,CAACA,SAASA,UAAU;AAE3E,0GAA0G,GAC1G,MAAMG,WAAW,CAACN;IAChB,MAAMO,MAAM,AAACd,UAAUO,SAAwCQ,GAAG;IAClE,OAAO,CAAC,CAACD,OAAO,CAAC,CAACA,IAAIE,QAAQ,IAAIF,IAAIE,QAAQ,CAAC,2BAA2B;AAC5E;AAEA,6BAA6B,GAC7B,OAAO,MAAMC,YAAmB;IAAEC,GAAG;IAAGC,GAAG;AAAE,EAAE;AAE/C,MAAMC,mBAAmB,CAACb;IACxB,MAAMc,WAAWrB,UAAUO,SAASe,cAAc;IAClD,OAAOT,SAASN,YAAYc,WAAW;QAAEH,GAAGG,SAASE,UAAU;QAAEJ,GAAGE,SAASG,SAAS;IAAC,IAAIP;AAC7F;AAEA,MAAMQ,YAAY,CAACC,SAAwDA,OAAOC,qBAAqB;AAEvG,OAAO,MAAMC,OAAO,CAACV,GAAWC,GAAWU,OAAeC,SAA0B,CAAA;QAAEZ;QAAGC;QAAGU;QAAOC;IAAO,CAAA,EAAG;AAE7G,OAAO,MAAMC,YAAY,CAACC,GAASC;IACjC,MAAMf,IAAIgB,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