@fluentui/react-positioning 9.1.2 → 9.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. package/CHANGELOG.json +83 -1
  2. package/CHANGELOG.md +29 -2
  3. package/dist/index.d.ts +9 -16
  4. package/lib/constants.js +5 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/middleware/coverTarget.js +40 -0
  7. package/lib/middleware/coverTarget.js.map +1 -0
  8. package/lib/middleware/flip.js +19 -0
  9. package/lib/middleware/flip.js.map +1 -0
  10. package/lib/middleware/index.js +7 -0
  11. package/lib/middleware/index.js.map +1 -0
  12. package/lib/middleware/intersecting.js +21 -0
  13. package/lib/middleware/intersecting.js.map +1 -0
  14. package/lib/middleware/maxSize.js +43 -0
  15. package/lib/middleware/maxSize.js.map +1 -0
  16. package/lib/middleware/offset.js +11 -0
  17. package/lib/middleware/offset.js.map +1 -0
  18. package/lib/middleware/shift.js +30 -0
  19. package/lib/middleware/shift.js.map +1 -0
  20. package/lib/usePositioning.js +237 -339
  21. package/lib/usePositioning.js.map +1 -1
  22. package/lib/utils/debounce.js +22 -0
  23. package/lib/utils/debounce.js.map +1 -0
  24. package/lib/utils/fromFloatingUIPlacement.js +43 -0
  25. package/lib/utils/fromFloatingUIPlacement.js.map +1 -0
  26. package/lib/utils/getBoundary.js +5 -1
  27. package/lib/utils/getBoundary.js.map +1 -1
  28. package/lib/utils/getFloatingUIOffset.js +36 -0
  29. package/lib/utils/getFloatingUIOffset.js.map +1 -0
  30. package/lib/utils/getScrollParent.js +6 -0
  31. package/lib/utils/getScrollParent.js.map +1 -1
  32. package/lib/utils/hasAutoFocusFilter.js +28 -0
  33. package/lib/utils/hasAutoFocusFilter.js.map +1 -0
  34. package/lib/utils/index.js +6 -2
  35. package/lib/utils/index.js.map +1 -1
  36. package/lib/utils/mergeArrowOffset.js +1 -1
  37. package/lib/utils/mergeArrowOffset.js.map +1 -1
  38. package/lib/utils/parseFloatingUIPlacement.js +14 -0
  39. package/lib/utils/parseFloatingUIPlacement.js.map +1 -0
  40. package/lib/utils/toFloatingUIPlacement.js +40 -0
  41. package/lib/utils/toFloatingUIPlacement.js.map +1 -0
  42. package/lib/utils/toggleScrollListener.js +24 -0
  43. package/lib/utils/toggleScrollListener.js.map +1 -0
  44. package/lib-commonjs/constants.js +11 -0
  45. package/lib-commonjs/constants.js.map +1 -0
  46. package/lib-commonjs/middleware/coverTarget.js +50 -0
  47. package/lib-commonjs/middleware/coverTarget.js.map +1 -0
  48. package/lib-commonjs/middleware/flip.js +30 -0
  49. package/lib-commonjs/middleware/flip.js.map +1 -0
  50. package/lib-commonjs/middleware/index.js +20 -0
  51. package/lib-commonjs/middleware/index.js.map +1 -0
  52. package/lib-commonjs/middleware/intersecting.js +31 -0
  53. package/lib-commonjs/middleware/intersecting.js.map +1 -0
  54. package/lib-commonjs/middleware/maxSize.js +54 -0
  55. package/lib-commonjs/middleware/maxSize.js.map +1 -0
  56. package/lib-commonjs/middleware/offset.js +22 -0
  57. package/lib-commonjs/middleware/offset.js.map +1 -0
  58. package/lib-commonjs/middleware/shift.js +41 -0
  59. package/lib-commonjs/middleware/shift.js.map +1 -0
  60. package/lib-commonjs/usePositioning.js +239 -340
  61. package/lib-commonjs/usePositioning.js.map +1 -1
  62. package/lib-commonjs/utils/debounce.js +31 -0
  63. package/lib-commonjs/utils/debounce.js.map +1 -0
  64. package/lib-commonjs/utils/fromFloatingUIPlacement.js +52 -0
  65. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -0
  66. package/lib-commonjs/utils/getBoundary.js +5 -1
  67. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  68. package/lib-commonjs/utils/getFloatingUIOffset.js +46 -0
  69. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -0
  70. package/lib-commonjs/utils/getScrollParent.js +10 -1
  71. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  72. package/lib-commonjs/utils/hasAutoFocusFilter.js +37 -0
  73. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -0
  74. package/lib-commonjs/utils/index.js +10 -2
  75. package/lib-commonjs/utils/index.js.map +1 -1
  76. package/lib-commonjs/utils/mergeArrowOffset.js +1 -1
  77. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  78. package/lib-commonjs/utils/parseFloatingUIPlacement.js +23 -0
  79. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -0
  80. package/lib-commonjs/utils/toFloatingUIPlacement.js +49 -0
  81. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -0
  82. package/lib-commonjs/utils/toggleScrollListener.js +34 -0
  83. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -0
  84. package/package.json +7 -7
  85. package/dist/tsdoc-metadata.json +0 -11
  86. package/lib/isIntersectingModifier.js +0 -26
  87. package/lib/isIntersectingModifier.js.map +0 -1
  88. package/lib/utils/fromPopperPlacement.js +0 -40
  89. package/lib/utils/fromPopperPlacement.js.map +0 -1
  90. package/lib/utils/getPopperOffset.js +0 -44
  91. package/lib/utils/getPopperOffset.js.map +0 -1
  92. package/lib/utils/parsePopperPlacement.js +0 -14
  93. package/lib/utils/parsePopperPlacement.js.map +0 -1
  94. package/lib/utils/positioningHelper.js +0 -49
  95. package/lib/utils/positioningHelper.js.map +0 -1
  96. package/lib-commonjs/isIntersectingModifier.js +0 -34
  97. package/lib-commonjs/isIntersectingModifier.js.map +0 -1
  98. package/lib-commonjs/utils/fromPopperPlacement.js +0 -50
  99. package/lib-commonjs/utils/fromPopperPlacement.js.map +0 -1
  100. package/lib-commonjs/utils/getPopperOffset.js +0 -54
  101. package/lib-commonjs/utils/getPopperOffset.js.map +0 -1
  102. package/lib-commonjs/utils/parsePopperPlacement.js +0 -23
  103. package/lib-commonjs/utils/parsePopperPlacement.js.map +0 -1
  104. package/lib-commonjs/utils/positioningHelper.js +0 -61
  105. package/lib-commonjs/utils/positioningHelper.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":"AAAA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'@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { isIntersectingModifier } from './isIntersectingModifier';\nimport {\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n parsePopperPlacement,\n} from './utils/index';\nimport type { PositioningVirtualElement, PositioningOptions, PositioningProps } from './types';\nimport { getPopperOffset } from './utils/getPopperOffset';\n\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\ninterface UsePopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n}\n\n//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nfunction hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n\n/**\n * Provides a callback to resolve Popper options, it's stable and should be used as a dependency to trigger updates\n * of Popper options.\n *\n * A callback is used there intentionally as some of Popper.js modifiers require DOM nodes (targer, container, arrow)\n * that can't be resolved properly during an initial rendering.\n */\nfunction usePopperOptions(options: PositioningOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionFixed,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(align, position, isRtl);\n const strategy = positionFixed ? 'fixed' : 'absolute';\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(getPopperOffset(offset)) : getPopperOffset(offset) },\n }\n : null,\n [offset, isRtl],\n );\n\n return React.useCallback(\n (\n target: HTMLElement | PopperJs.VirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ): PopperJs.Options => {\n const scrollParentElement: HTMLElement = getScrollParent(container);\n const hasScrollableElement = scrollParentElement\n ? scrollParentElement !== scrollParentElement.ownerDocument?.body\n : false;\n\n const modifiers: PopperJs.Options['modifiers'] = [\n isIntersectingModifier,\n\n /**\n * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content\n * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of\n * a patch modifies \".forceUpdate()\" directly after a Popper will be created.\n */\n {\n name: 'positionStyleFix',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n effect: ({ state, instance }: { state: PopperJs.State; instance: PopperInstance }) => {\n // \".isFirstRun\" is a part of our patch, on a first evaluation it will \"undefined\"\n // should be disabled for subsequent runs as it breaks positioning for them\n if (instance.isFirstRun !== false) {\n popperOriginalPositionRef.current = state.elements.popper.style.position;\n state.elements.popper.style.position = 'fixed';\n }\n\n return () => undefined;\n },\n requires: [],\n },\n\n { name: 'flip', options: { flipVariations: true } },\n\n /**\n * pinned disables the flip modifier by setting flip.enabled to false; this\n * disables automatic repositioning of the popper box; it will always be placed according to\n * the values of `align` and `position` props, regardless of the size of the component, the\n * reference element or the viewport.\n */\n pinned && { name: 'flip', enabled: false },\n\n /**\n * When the popper box is placed in the context of a scrollable element, we need to set\n * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'\n * (default is 'viewport') so that the popper box will stick with the targetRef when we\n * scroll targetRef out of the viewport.\n */\n hasScrollableElement && { name: 'flip', options: { boundary: 'clippingParents' } },\n hasScrollableElement && { name: 'preventOverflow', options: { boundary: 'clippingParents' } },\n\n offsetModifier,\n\n /**\n * This modifier is necessary to retain behaviour from popper v1 where untethered poppers are allowed by\n * default. i.e. popper is still rendered fully in the viewport even if anchor element is no longer in the\n * viewport.\n */\n unstable_disableTether && {\n name: 'preventOverflow',\n options: { altAxis: unstable_disableTether === 'all', tether: false },\n },\n\n flipBoundary && {\n name: 'flip',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary),\n },\n },\n overflowBoundary && {\n name: 'preventOverflow',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n },\n\n {\n // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\n // popper-maxsize-modifier only calculates the max sizes.\n // This modifier can apply max sizes always, or apply the max sizes only when overflow is detected\n name: 'applyMaxSize',\n enabled: !!autoSize,\n phase: 'beforeWrite' as PopperJs.ModifierPhases,\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n fn({ state, options: modifierOptions }: PopperJs.ModifierArguments<{}>) {\n const overflow = PopperJs.detectOverflow(state, modifierOptions);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const basePlacement = parsePopperPlacement(state.placement).basePlacement;\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\n state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n },\n },\n\n /**\n * This modifier is necessary in order to render the pointer. Refs are resolved in effects, so it can't be\n * placed under computed modifiers. Deep merge is not required as this modifier has only these properties.\n */\n {\n name: 'arrow',\n enabled: !!arrow,\n options: { element: arrow, padding: arrowPadding },\n },\n\n /**\n * Modifies popper offsets to cover the reference rect, but still keep edge alignment\n */\n {\n name: 'coverTarget',\n enabled: !!coverTarget,\n phase: 'main',\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n fn({ state }: PopperJs.ModifierArguments<{}>) {\n const basePlacement = parsePopperPlacement(state.placement).basePlacement;\n switch (basePlacement) {\n case 'bottom':\n state.modifiersData.popperOffsets!.y -= state.rects.reference.height;\n break;\n case 'top':\n state.modifiersData.popperOffsets!.y += state.rects.reference.height;\n break;\n case 'left':\n state.modifiersData.popperOffsets!.x += state.rects.reference.width;\n break;\n case 'right':\n state.modifiersData.popperOffsets!.x -= state.rects.reference.width;\n break;\n }\n },\n },\n ].filter(Boolean) as PopperJs.Options['modifiers']; // filter boolean conditional spreading values\n\n const popperOptions: PopperJs.Options = {\n modifiers,\n\n placement,\n strategy,\n };\n\n return popperOptions;\n },\n [\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n pinned,\n\n // These can be skipped from deps as they will not ever change\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * @internal\n * Exposes Popper positioning API via React hook. Contains few important differences between an official \"react-popper\"\n * package:\n * - style attributes are applied directly on DOM to avoid re-renders\n * - refs changes and resolution is handled properly without re-renders\n * - contains a specific to React fix related to initial positioning when containers have components with managed focus\n * to avoid focus jumps\n */\nexport function usePositioning(\n options: UsePopperOptions = {},\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { enabled = true } = options;\n const isFirstMount = useFirstMount();\n\n const popperOriginalPositionRef = React.useRef<string>('absolute');\n const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);\n\n const popperInstanceRef = React.useRef<PopperInstance | null>(null);\n\n const handlePopperUpdate = useEventCallback(() => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n let popperInstance: PopperInstance | null = null;\n\n if (canUseDOM() && enabled) {\n if (target && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n target,\n containerRef.current,\n resolvePopperOptions(target, containerRef.current, arrowRef.current),\n );\n }\n }\n\n if (popperInstance) {\n /**\n * The patch updates `.forceUpdate()` Popper function which restores the original position before the first\n * forceUpdate() call. See also \"positionStyleFix\" modifier in usePopperOptions().\n */\n const originalForceUpdate = popperInstance.forceUpdate;\n\n popperInstance.isFirstRun = true;\n popperInstance.forceUpdate = () => {\n if (popperInstance?.isFirstRun) {\n popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;\n popperInstance.isFirstRun = false;\n }\n\n originalForceUpdate();\n };\n }\n\n popperInstanceRef.current = popperInstance;\n });\n\n // Refs are managed by useCallbackRef() to handle ref updates scenarios.\n //\n // The first scenario are updates for a targetRef, we can handle it properly only via callback refs, but it causes\n // re-renders (we would like to avoid them).\n //\n // The second problem is related to refs resolution on React's layer: refs are resolved in the same order as effects\n // that causes an issue when you have a container inside a target, for example: a menu in ChatMessage.\n //\n // function ChatMessage(props) {\n // <div className=\"message\" ref={targetRef}> // 3) ref will be resolved only now, but it's too late already\n // <Popper target={targetRef}> // 2) create a popper instance\n // <div className=\"menu\" /> // 1) capture ref from this element\n // </Popper>\n // </div>\n // }\n //\n // Check a demo on CodeSandbox: https://codesandbox.io/s/popper-refs-emy60.\n //\n // This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation\n // to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.\n const targetRef = useCallbackRef<HTMLElement | PopperJs.VirtualElement | null>(null, handlePopperUpdate, true);\n const containerRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n const arrowRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n\n // Stores external target from options.target or setTarget\n const overrideTargetRef = useCallbackRef<HTMLElement | PositioningVirtualElement | null>(\n null,\n handlePopperUpdate,\n true,\n );\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n setTarget: (target: HTMLElement | PositioningVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (options.target) {\n overrideTargetRef.current = options.target;\n }\n }, [options.target, overrideTargetRef]);\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [handlePopperUpdate, options.enabled]);\n useIsomorphicLayoutEffect(\n () => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(overrideTargetRef.current ?? targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n },\n // Missing deps:\n // isFirstMount - Should never change after mount\n // arrowRef, containerRef, targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [resolvePopperOptions],\n );\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker?.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":"AAAA,SAAS,eAAT,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} from '@floating-ui/dom';\nimport type { Middleware, Strategy, Placement, Coords, MiddlewareData } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { PositioningOptions, PositioningProps, PositioningVirtualElement } from './types';\nimport {\n useCallbackRef,\n toFloatingUIPlacement,\n toggleScrollListener,\n hasAutofocusFilter,\n debounce,\n hasScrollParent,\n} from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_PLACEMENT,\n} from './constants';\n\n/**\n * @internal\n */\nexport function usePositioning(\n options: UsePositioningOptions,\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { targetDocument } = useFluent();\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n\n const forceUpdate = useEventCallback(() => {\n const target = overrideTargetRef.current ?? targetRef.current;\n if (!canUseDOM || !enabled || !target || !containerRef.current) {\n return;\n }\n\n const { placement, middleware, strategy } = resolvePositioningOptions(\n target,\n containerRef.current,\n arrowRef.current,\n );\n\n // Container is always initialized with `position: fixed` to avoid scroll jumps\n // Before computing the positioned coordinates, revert the container to the deisred positioning strategy\n Object.assign(containerRef.current.style, { position: strategy });\n computePosition(target, containerRef.current, { placement, middleware, strategy })\n .then(({ x, y, middlewareData, placement: computedPlacement }) => {\n writeArrowUpdates({ arrow: arrowRef.current, middlewareData });\n writeContainerUpdates({\n container: containerRef.current,\n middlewareData,\n placement: computedPlacement,\n coordinates: { x, y },\n lowPPI: (targetDocument?.defaultView?.devicePixelRatio || 1) <= 1,\n strategy,\n });\n })\n .catch(err => {\n // https://github.com/floating-ui/floating-ui/issues/1845\n // FIXME for node > 14\n // node 15 introduces promise rejection which means that any components\n // tests need to be `it('', async () => {})` otherwise there can be race conditions with\n // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist\n // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing\n // will actually be counter productive\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error('[usePositioning]: Failed to calculate position', err);\n }\n });\n });\n\n const updatePosition = React.useState(() => debounce(forceUpdate))[0];\n\n const targetRef = useTargetRef(updatePosition);\n const overrideTargetRef = useTargetRef(updatePosition);\n const containerRef = useContainerRef(updatePosition, enabled);\n const arrowRef = useArrowRef(updatePosition);\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition,\n setTarget: (target: HTMLElement | PositioningVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // overrideTargetRef - Stable between renders\n // updatePosition - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n overrideTargetRef.current = options.target ?? null;\n }, [options.target, overrideTargetRef, containerRef]);\n\n useIsomorphicLayoutEffect(() => {\n updatePosition();\n }, [enabled, resolvePositioningOptions, updatePosition]);\n\n // Add window resize and scroll listeners to update position\n useIsomorphicLayoutEffect(() => {\n const win = targetDocument?.defaultView;\n if (win) {\n win.addEventListener('resize', updatePosition);\n win.addEventListener('scroll', updatePosition);\n\n return () => {\n win.removeEventListener('resize', updatePosition);\n win.removeEventListener('scroll', updatePosition);\n };\n }\n }, [updatePosition, targetDocument]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (\n target: HTMLElement | PositioningVirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n\nfunction useContainerRef(updatePosition: () => void, enabled: boolean) {\n return useCallbackRef<HTMLElement | null>(null, (container, prevContainer) => {\n if (container && enabled) {\n // When the container is first resolved, set position `fixed` to avoid scroll jumps.\n // Without this scroll jumps can occur when the element is rendered initially and receives focus\n Object.assign(container.style, { position: 'fixed', left: 0, top: 0, margin: 0 });\n }\n\n toggleScrollListener(container, prevContainer, updatePosition);\n\n updatePosition();\n });\n}\n\nfunction useTargetRef(updatePosition: () => void) {\n return useCallbackRef<HTMLElement | PositioningVirtualElement | null>(null, (target, prevTarget) => {\n toggleScrollListener(target, prevTarget, updatePosition);\n\n updatePosition();\n });\n}\n\nfunction useArrowRef(updatePosition: () => void) {\n return useCallbackRef<HTMLElement | null>(null, updatePosition);\n}\n\n/**\n * Writes all DOM element updates after position is computed\n */\nfunction writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const {\n container,\n placement,\n middlewareData,\n strategy,\n lowPPI,\n coordinates: { x, y },\n } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n\n/**\n * Writes all DOM element updates after position is computed\n */\nfunction writeArrowUpdates(options: { arrow: HTMLElement | null; middlewareData: MiddlewareData }) {\n const { arrow, middlewareData } = options;\n if (!middlewareData.arrow || !arrow) {\n return;\n }\n\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(arrow.style, {\n left: `${arrowX}px`,\n top: `${arrowY}px`,\n });\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Promise microtask debouncer used by Popper.js v2
3
+ * This is no longer exported in Floating UI (Popper.js v3)
4
+ * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
5
+ * @param fn function that will be debounced
6
+ */
7
+ export function debounce(fn) {
8
+ let pending;
9
+ return () => {
10
+ if (!pending) {
11
+ pending = new Promise(resolve => {
12
+ Promise.resolve().then(() => {
13
+ pending = undefined;
14
+ resolve(fn());
15
+ });
16
+ });
17
+ }
18
+
19
+ return pending;
20
+ };
21
+ }
22
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/debounce.ts"],"names":[],"mappings":"AAAA;;;;;AAKG;AACH,OAAM,SAAU,QAAV,CAAsB,EAAtB,EAAkC;EACtC,IAAI,OAAJ;EACA,OAAO,MAAK;IACV,IAAI,CAAC,OAAL,EAAc;MACZ,OAAO,GAAG,IAAI,OAAJ,CAAe,OAAO,IAAG;QACjC,OAAO,CAAC,OAAR,GAAkB,IAAlB,CAAuB,MAAK;UAC1B,OAAO,GAAG,SAAV;UACA,OAAO,CAAC,EAAE,EAAH,CAAP;QACD,CAHD;MAID,CALS,CAAV;IAMD;;IAED,OAAO,OAAP;EACD,CAXD;AAYD","sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,43 @@
1
+ import { parseFloatingUIPlacement } from './parseFloatingUIPlacement';
2
+
3
+ const getPositionMap = () => ({
4
+ top: 'above',
5
+ bottom: 'below',
6
+ right: 'after',
7
+ left: 'before'
8
+ }); // Floating UI automatically flips alignment
9
+ // https://github.com/floating-ui/floating-ui/issues/1563
10
+
11
+
12
+ const getAlignmentMap = position => {
13
+ if (position === 'above' || position === 'below') {
14
+ return {
15
+ start: 'start',
16
+ end: 'end'
17
+ };
18
+ }
19
+
20
+ return {
21
+ start: 'top',
22
+ end: 'bottom'
23
+ };
24
+ };
25
+ /**
26
+ * Maps Floating UI placement to positioning values
27
+ * @see positioningHelper.test.ts for expected placement values
28
+ */
29
+
30
+
31
+ export const fromFloatingUIPlacement = placement => {
32
+ const {
33
+ side,
34
+ alignment: floatingUIAlignment
35
+ } = parseFloatingUIPlacement(placement);
36
+ const position = getPositionMap()[side];
37
+ const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];
38
+ return {
39
+ position,
40
+ alignment
41
+ };
42
+ };
43
+ //# sourceMappingURL=fromFloatingUIPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/fromFloatingUIPlacement.ts"],"names":[],"mappings":"AAEA,SAAS,wBAAT,QAAyC,4BAAzC;;AAEA,MAAM,cAAc,GAAG,OAA+B;EACpD,GAAG,EAAE,OAD+C;EAEpD,MAAM,EAAE,OAF4C;EAGpD,KAAK,EAAE,OAH6C;EAIpD,IAAI,EAAE;AAJ8C,CAA/B,CAAvB,C,CAOA;AACA;;;AACA,MAAM,eAAe,GAAI,QAAD,IAA+D;EACrF,IAAI,QAAQ,KAAK,OAAb,IAAwB,QAAQ,KAAK,OAAzC,EAAkD;IAChD,OAAO;MACL,KAAK,EAAE,OADF;MAEL,GAAG,EAAE;IAFA,CAAP;EAID;;EAED,OAAO;IACL,KAAK,EAAE,KADF;IAEL,GAAG,EAAE;EAFA,CAAP;AAID,CAZD;AAcA;;;AAGG;;;AACH,OAAO,MAAM,uBAAuB,GAAI,SAAD,IAAwE;EAC7G,MAAM;IAAE,IAAF;IAAQ,SAAS,EAAE;EAAnB,IAA2C,wBAAwB,CAAC,SAAD,CAAzE;EACA,MAAM,QAAQ,GAAG,cAAc,GAAG,IAAH,CAA/B;EACA,MAAM,SAAS,GAAG,mBAAmB,IAAI,eAAe,CAAC,QAAD,CAAf,CAA0B,mBAA1B,CAAzC;EAEA,OAAO;IAAE,QAAF;IAAY;EAAZ,CAAP;AACD,CANM","sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, Alignment> => {\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end',\n };\n }\n\n return {\n start: 'top',\n end: 'bottom',\n };\n};\n\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"],"sourceRoot":"../src/"}
@@ -8,6 +8,10 @@ export function getBoundary(element, boundary) {
8
8
  return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
9
9
  }
10
10
 
11
+ if (boundary === 'clippingParents') {
12
+ return 'clippingAncestors';
13
+ }
14
+
11
15
  if (boundary === 'scrollParent') {
12
16
  let boundariesNode = getScrollParent(element);
13
17
 
@@ -18,6 +22,6 @@ export function getBoundary(element, boundary) {
18
22
  return boundariesNode;
19
23
  }
20
24
 
21
- return boundary !== null && boundary !== void 0 ? boundary : undefined;
25
+ return boundary;
22
26
  }
23
27
  //# sourceMappingURL=getBoundary.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/getBoundary.ts"],"names":[],"mappings":"AAEA,SAAS,eAAT,QAAgC,mBAAhC;AAGA;;AAEG;;AACH,OAAM,SAAU,WAAV,CAAsB,OAAtB,EAAmD,QAAnD,EAA6E;EACjF,IAAI,QAAQ,KAAK,QAAjB,EAA2B;IACzB,OAAO,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAA/B;EACD;;EAED,IAAI,QAAQ,KAAK,cAAjB,EAAiC;IAC/B,IAAI,cAAc,GAA4B,eAAe,CAAC,OAAD,CAA7D;;IAEA,IAAI,cAAc,CAAC,QAAf,KAA4B,MAAhC,EAAwC;MACtC,cAAc,GAAG,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAAzC;IACD;;IAED,OAAO,cAAP;EACD;;EAED,OAAO,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAA,QAAA,GAAY,SAAnB;AACD","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary | null): PopperJs.Boundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary ?? undefined;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/getBoundary.ts"],"names":[],"mappings":"AAEA,SAAS,eAAT,QAAgC,mBAAhC;AAGA;;AAEG;;AACH,OAAM,SAAU,WAAV,CAAsB,OAAtB,EAAmD,QAAnD,EAAsE;EAC1E,IAAI,QAAQ,KAAK,QAAjB,EAA2B;IACzB,OAAO,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAA/B;EACD;;EAED,IAAI,QAAQ,KAAK,iBAAjB,EAAoC;IAClC,OAAO,mBAAP;EACD;;EAED,IAAI,QAAQ,KAAK,cAAjB,EAAiC;IAC/B,IAAI,cAAc,GAA4B,eAAe,CAAC,OAAD,CAA7D;;IAEA,IAAI,cAAc,CAAC,QAAf,KAA4B,MAAhC,EAAwC;MACtC,cAAc,GAAG,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAAzC;IACD;;IAED,OAAO,cAAP;EACD;;EAED,OAAO,QAAP;AACD","sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary): FloatingUIBoundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'clippingParents') {\n return 'clippingAncestors';\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,36 @@
1
+ import { fromFloatingUIPlacement } from './fromFloatingUIPlacement';
2
+ /**
3
+ * Shim to transform offset values from this library to Floating UI
4
+ * @param rawOffset Offset from this library
5
+ * @returns An offset value compatible with Floating UI
6
+ */
7
+
8
+ export function getFloatingUIOffset(rawOffset) {
9
+ if (!rawOffset) {
10
+ return rawOffset;
11
+ }
12
+
13
+ if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
14
+ return rawOffset;
15
+ }
16
+
17
+ return ({
18
+ rects: {
19
+ floating,
20
+ reference
21
+ },
22
+ placement
23
+ }) => {
24
+ const {
25
+ position,
26
+ alignment
27
+ } = fromFloatingUIPlacement(placement);
28
+ return rawOffset({
29
+ positionedRect: floating,
30
+ targetRect: reference,
31
+ position,
32
+ alignment
33
+ });
34
+ };
35
+ }
36
+ //# sourceMappingURL=getFloatingUIOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getFloatingUIOffset.ts"],"names":[],"mappings":"AAEA,SAAS,uBAAT,QAAwC,2BAAxC;AAgCA;;;;AAIG;;AACH,OAAM,SAAU,mBAAV,CACJ,SADI,EACyB;EAE7B,IAAI,CAAC,SAAL,EAAgB;IACd,OAAO,SAAP;EACD;;EAED,IAAI,OAAO,SAAP,KAAqB,QAArB,IAAiC,OAAO,SAAP,KAAqB,QAA1D,EAAoE;IAClE,OAAO,SAAP;EACD;;EAED,OAAO,CAAC;IAAE,KAAK,EAAE;MAAE,QAAF;MAAY;IAAZ,CAAT;IAAkC;EAAlC,CAAD,KAAkD;IACvD,MAAM;MAAE,QAAF;MAAY;IAAZ,IAA0B,uBAAuB,CAAC,SAAD,CAAvD;IACA,OAAO,SAAS,CAAC;MAAE,cAAc,EAAE,QAAlB;MAA4B,UAAU,EAAE,SAAxC;MAAmD,QAAnD;MAA6D;IAA7D,CAAD,CAAhB;EACD,CAHD;AAID","sourcesContent":["import type { Offset } from '../types';\nimport type { MiddlewareArguments } from '@floating-ui/dom';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetValue =\n | number\n | {\n /**\n * The axis that runs along the side of the floating element.\n * @default 0\n */\n mainAxis?: number;\n /**\n * The axis that runs along the alignment of the floating element.\n * @default 0\n */\n crossAxis?: number;\n /**\n * When set to a number, overrides the `crossAxis` value for aligned\n * (non-centered/base) placements and works logically. A positive number\n * will move the floating element in the direction of the opposite edge\n * to the one that is aligned, while a negative number the reverse.\n * @default null\n */\n alignmentAxis?: number | null;\n };\n\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetFunction = (args: MiddlewareArguments) => FloatingUIOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Floating UI\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Floating UI\n */\nexport function getFloatingUIOffset(\n rawOffset: Offset | undefined,\n): FloatingUIOffsetValue | FloatingUIOffsetFunction | undefined {\n if (!rawOffset) {\n return rawOffset;\n }\n\n if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {\n return rawOffset;\n }\n\n return ({ rects: { floating, reference }, placement }) => {\n const { position, alignment } = fromFloatingUIPlacement(placement);\n return rawOffset({ positionedRect: floating, targetRect: reference, position, alignment });\n };\n}\n"],"sourceRoot":"../src/"}
@@ -62,4 +62,10 @@ export const getScrollParent = node => {
62
62
 
63
63
  return getScrollParent(parentNode);
64
64
  };
65
+ export const hasScrollParent = node => {
66
+ var _a;
67
+
68
+ const scrollParentElement = getScrollParent(node);
69
+ return scrollParentElement ? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body) : false;
70
+ };
65
71
  //# sourceMappingURL=getScrollParent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,MAAM,aAAa,GAAI,IAAD,IAAmC;EAC9D,IAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;IAC5B,OAAO,IAAP;EACD,CAH6D,CAI9D;;;EACA,OAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;AAQP;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;EACnF,IAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;IACvB,OAAO,EAAP;EACD;;EAED,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;EACA,OAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACH,OAAO,MAAM,eAAe,GAAI,IAAD,IAAqD;EAClF;EACA,MAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAD,CAAxC,CAFkF,CAGlF;;EACA,IAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;EAEjB,QAAQ,UAAU,CAAC,QAAnB;IACE,KAAK,MAAL;IACA,KAAK,MAAL;MACE,OAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;IACF,KAAK,WAAL;MACE,OAAS,UAAmC,CAAC,IAA7C;EALJ,CANkF,CAclF;;;EACA,MAAM;IAAE,QAAF;IAAY,SAAZ;IAAuB;EAAvB,IAAqC,wBAAwB,CAAC,UAAD,CAAnE;;EACA,IAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;IACpE,OAAO,UAAP;EACD;;EAED,OAAO,eAAe,CAAC,UAAD,CAAtB;AACD,CArBM","sourcesContent":["/**\n * Returns the parent node or the host of the node argument.\n * @param node - DOM node.\n * @returns - parent DOM node.\n */\nexport const getParentNode = (node: HTMLElement): HTMLElement => {\n if (node.nodeName === 'HTML') {\n return node;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return node.parentNode || (node as any).host;\n};\n\n/**\n * Returns CSS styles of the given node.\n * @param node - DOM node.\n * @returns - CSS styles.\n */\nconst getStyleComputedProperty = (node: HTMLElement): Partial<CSSStyleDeclaration> => {\n if (node.nodeType !== 1) {\n return {};\n }\n\n const window = node.ownerDocument?.defaultView;\n return window!.getComputedStyle(node, null);\n};\n\n/**\n * Returns the first scrollable parent of the given element.\n * @param node - DOM node.\n * @returns - the first scrollable parent.\n */\nexport const getScrollParent = (node: Document | HTMLElement | null): HTMLElement => {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n const parentNode = node && getParentNode(node as HTMLElement);\n // eslint-disable-next-line\n if (!parentNode) return document.body;\n\n switch (parentNode.nodeName) {\n case 'HTML':\n case 'BODY':\n return parentNode.ownerDocument!.body;\n case '#document':\n return ((parentNode as unknown) as Document).body;\n }\n\n // If any of the overflow props is defined for the node then we return it as the parent\n const { overflow, overflowX, overflowY } = getStyleComputedProperty(parentNode);\n if (/(auto|scroll|overlay)/.test(overflow! + overflowY! + overflowX)) {\n return parentNode;\n }\n\n return getScrollParent(parentNode);\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,MAAM,aAAa,GAAI,IAAD,IAAmC;EAC9D,IAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;IAC5B,OAAO,IAAP;EACD,CAH6D,CAI9D;;;EACA,OAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;AAQP;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;EACnF,IAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;IACvB,OAAO,EAAP;EACD;;EAED,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;EACA,OAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACH,OAAO,MAAM,eAAe,GAAI,IAAD,IAAqD;EAClF;EACA,MAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAD,CAAxC,CAFkF,CAGlF;;EACA,IAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;EAEjB,QAAQ,UAAU,CAAC,QAAnB;IACE,KAAK,MAAL;IACA,KAAK,MAAL;MACE,OAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;IACF,KAAK,WAAL;MACE,OAAS,UAAmC,CAAC,IAA7C;EALJ,CANkF,CAclF;;;EACA,MAAM;IAAE,QAAF;IAAY,SAAZ;IAAuB;EAAvB,IAAqC,wBAAwB,CAAC,UAAD,CAAnE;;EACA,IAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;IACpE,OAAO,UAAP;EACD;;EAED,OAAO,eAAe,CAAC,UAAD,CAAtB;AACD,CArBM;AAuBP,OAAO,MAAM,eAAe,GAAI,IAAD,IAAiD;;;EAC9E,MAAM,mBAAmB,GAAgB,eAAe,CAAC,IAAD,CAAxD;EACA,OAAO,mBAAmB,GAAG,mBAAmB,MAAK,CAAA,EAAA,GAAA,mBAAmB,CAAC,aAApB,MAAiC,IAAjC,IAAiC,EAAA,KAAA,KAAA,CAAjC,GAAiC,KAAA,CAAjC,GAAiC,EAAA,CAAE,IAAxC,CAAtB,GAAqE,KAA/F;AACD,CAHM","sourcesContent":["/**\n * Returns the parent node or the host of the node argument.\n * @param node - DOM node.\n * @returns - parent DOM node.\n */\nexport const getParentNode = (node: HTMLElement): HTMLElement => {\n if (node.nodeName === 'HTML') {\n return node;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return node.parentNode || (node as any).host;\n};\n\n/**\n * Returns CSS styles of the given node.\n * @param node - DOM node.\n * @returns - CSS styles.\n */\nconst getStyleComputedProperty = (node: HTMLElement): Partial<CSSStyleDeclaration> => {\n if (node.nodeType !== 1) {\n return {};\n }\n\n const window = node.ownerDocument?.defaultView;\n return window!.getComputedStyle(node, null);\n};\n\n/**\n * Returns the first scrollable parent of the given element.\n * @param node - DOM node.\n * @returns - the first scrollable parent.\n */\nexport const getScrollParent = (node: Document | HTMLElement | null): HTMLElement => {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n const parentNode = node && getParentNode(node as HTMLElement);\n // eslint-disable-next-line\n if (!parentNode) return document.body;\n\n switch (parentNode.nodeName) {\n case 'HTML':\n case 'BODY':\n return parentNode.ownerDocument!.body;\n case '#document':\n return ((parentNode as unknown) as Document).body;\n }\n\n // If any of the overflow props is defined for the node then we return it as the parent\n const { overflow, overflowX, overflowY } = getStyleComputedProperty(parentNode);\n if (/(auto|scroll|overlay)/.test(overflow! + overflowY! + overflowX)) {\n return parentNode;\n }\n\n return getScrollParent(parentNode);\n};\n\nexport const hasScrollParent = (node: Document | HTMLElement | null): boolean => {\n const scrollParentElement: HTMLElement = getScrollParent(node);\n return scrollParentElement ? scrollParentElement !== scrollParentElement.ownerDocument?.body : false;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,28 @@
1
+ //
2
+ // Dev utils to detect if nodes have "autoFocus" props.
3
+ //
4
+ import { getReactFiberFromNode } from './getReactFiberFromNode';
5
+ /**
6
+ * Detects if a passed HTML node has "autoFocus" prop on a React's fiber. Is needed as React handles autofocus behavior
7
+ * in React DOM and will not pass "autoFocus" to an actual HTML.
8
+ *
9
+ * @param node
10
+ */
11
+
12
+ function hasAutofocusProp(node) {
13
+ var _a; // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
14
+
15
+
16
+ const isAutoFocusableElement = node.nodeName === 'BUTTON' || node.nodeName === 'INPUT' || node.nodeName === 'SELECT' || node.nodeName === 'TEXTAREA';
17
+
18
+ if (isAutoFocusableElement) {
19
+ return !!((_a = getReactFiberFromNode(node)) === null || _a === void 0 ? void 0 : _a.pendingProps.autoFocus);
20
+ }
21
+
22
+ return false;
23
+ }
24
+
25
+ export function hasAutofocusFilter(node) {
26
+ return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
27
+ }
28
+ //# sourceMappingURL=hasAutoFocusFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/hasAutoFocusFilter.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AAEA,SAAS,qBAAT,QAAsC,yBAAtC;AAEA;;;;;AAKG;;AACH,SAAS,gBAAT,CAA0B,IAA1B,EAAoC;SAAA,CAClC;;;EACA,MAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAL,KAAkB,QAAlB,IACA,IAAI,CAAC,QAAL,KAAkB,OADlB,IAEA,IAAI,CAAC,QAAL,KAAkB,QAFlB,IAGA,IAAI,CAAC,QAAL,KAAkB,UAJpB;;EAMA,IAAI,sBAAJ,EAA4B;IAC1B,OAAO,CAAC,EAAC,CAAA,EAAA,GAAA,qBAAqB,CAAC,IAAD,CAArB,MAA2B,IAA3B,IAA2B,EAAA,KAAA,KAAA,CAA3B,GAA2B,KAAA,CAA3B,GAA2B,EAAA,CAAE,YAAF,CAAe,SAA3C,CAAR;EACD;;EAED,OAAO,KAAP;AACD;;AAED,OAAM,SAAU,kBAAV,CAA6B,IAA7B,EAAuC;EAC3C,OAAO,gBAAgB,CAAC,IAAD,CAAhB,GAAyB,UAAU,CAAC,aAApC,GAAoD,UAAU,CAAC,WAAtE;AACD","sourcesContent":["//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\nimport { getReactFiberFromNode } from './getReactFiberFromNode';\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n *\n * @param node\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nexport function hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n"],"sourceRoot":"../src/"}
@@ -1,9 +1,13 @@
1
+ export * from './parseFloatingUIPlacement';
1
2
  export * from './getBoundary';
2
3
  export * from './getReactFiberFromNode';
3
4
  export * from './getScrollParent';
4
5
  export * from './mergeArrowOffset';
5
- export * from './positioningHelper';
6
+ export * from './toFloatingUIPlacement';
7
+ export * from './fromFloatingUIPlacement';
6
8
  export * from './resolvePositioningShorthand';
7
9
  export * from './useCallbackRef';
8
- export * from './parsePopperPlacement';
10
+ export * from './debounce';
11
+ export * from './toggleScrollListener';
12
+ export * from './hasAutoFocusFilter';
9
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './positioningHelper';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './parsePopperPlacement';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\n"]}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @internal
3
2
  * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
4
3
  * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
5
4
  *
5
+ * @internal
6
6
  * @param userOffset - The offset provided by the user
7
7
  * @param arrowHeight - The height of the arrow in px
8
8
  * @returns User offset augmented with arrow height
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":"AAEA;;;;;;;;AAQG;AACH,OAAM,SAAU,gBAAV,CAA2B,UAA3B,EAAkE,WAAlE,EAAqF;EACzF,IAAI,OAAO,UAAP,KAAsB,QAA1B,EAAoC;IAClC,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,QAAtB,IAAkC,UAAU,KAAK,IAArD,EAA2D;IACzD,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,UAA1B,EAAsC;IACpC,OAAO,YAAY,IAAG;MACpB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAD,CAAzB;MACA,OAAO,cAAc,CAAC,MAAD,EAAS,WAAT,CAArB;IACD,CAHD;EAID;;EAED,OAAO;IAAE,QAAQ,EAAE;EAAZ,CAAP;AACD;;AAED,MAAM,cAAc,GAAG,CAAC,MAAD,EAAgC,WAAhC,KAAqE;;;EAC1F,IAAI,OAAO,MAAP,KAAkB,QAAtB,EAAgC;IAC9B,OAAO;MAAE,QAAQ,EAAE,MAAM,GAAG;IAArB,CAAP;EACD;;EAED,OAAO,EAAE,GAAG,MAAL;IAAa,QAAQ,EAAE,CAAC,CAAA,EAAA,GAAA,MAAM,CAAC,QAAP,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,EAAf,GAAmB,CAApB,IAAyB;EAAhD,CAAP;AACD,CAND","sourcesContent":["import type { Offset, OffsetObject } from '../types';\n\n/**\n * @internal\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n if (typeof userOffset === 'number') {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'object' && userOffset !== null) {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'function') {\n return offsetParams => {\n const offset = userOffset(offsetParams);\n return addArrowOffset(offset, arrowHeight);\n };\n }\n\n return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n if (typeof offset === 'number') {\n return { mainAxis: offset + arrowHeight };\n }\n\n return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":"AAEA;;;;;;;;AAQG;AACH,OAAM,SAAU,gBAAV,CAA2B,UAA3B,EAAkE,WAAlE,EAAqF;EACzF,IAAI,OAAO,UAAP,KAAsB,QAA1B,EAAoC;IAClC,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,QAAtB,IAAkC,UAAU,KAAK,IAArD,EAA2D;IACzD,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,UAA1B,EAAsC;IACpC,OAAO,YAAY,IAAG;MACpB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAD,CAAzB;MACA,OAAO,cAAc,CAAC,MAAD,EAAS,WAAT,CAArB;IACD,CAHD;EAID;;EAED,OAAO;IAAE,QAAQ,EAAE;EAAZ,CAAP;AACD;;AAED,MAAM,cAAc,GAAG,CAAC,MAAD,EAAgC,WAAhC,KAAqE;;;EAC1F,IAAI,OAAO,MAAP,KAAkB,QAAtB,EAAgC;IAC9B,OAAO;MAAE,QAAQ,EAAE,MAAM,GAAG;IAArB,CAAP;EACD;;EAED,OAAO,EAAE,GAAG,MAAL;IAAa,QAAQ,EAAE,CAAC,CAAA,EAAA,GAAA,MAAM,CAAC,QAAP,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,EAAf,GAAmB,CAApB,IAAyB;EAAhD,CAAP;AACD,CAND","sourcesContent":["import type { Offset, OffsetObject } from '../types';\n\n/**\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @internal\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n if (typeof userOffset === 'number') {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'object' && userOffset !== null) {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'function') {\n return offsetParams => {\n const offset = userOffset(offsetParams);\n return addArrowOffset(offset, arrowHeight);\n };\n }\n\n return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n if (typeof offset === 'number') {\n return { mainAxis: offset + arrowHeight };\n }\n\n return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parses Floating UI placement and returns the different components
3
+ * @param placement - the floating ui placement (i.e. bottom-start)
4
+ *
5
+ * @returns side and alignment components of the placement
6
+ */
7
+ export function parseFloatingUIPlacement(placement) {
8
+ const tokens = placement.split('-');
9
+ return {
10
+ side: tokens[0],
11
+ alignment: tokens[1]
12
+ };
13
+ }
14
+ //# sourceMappingURL=parseFloatingUIPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/parseFloatingUIPlacement.ts"],"names":[],"mappings":"AAEA;;;;;AAKG;AACH,OAAM,SAAU,wBAAV,CAAmC,SAAnC,EAAuD;EAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,CAAf;EACA,OAAO;IACL,IAAI,EAAE,MAAM,CAAC,CAAD,CADP;IAEL,SAAS,EAAE,MAAM,CAAC,CAAD;EAFZ,CAAP;AAID","sourcesContent":["import type { Side, Placement, Alignment } from '@floating-ui/dom';\n\n/**\n * Parses Floating UI placement and returns the different components\n * @param placement - the floating ui placement (i.e. bottom-start)\n *\n * @returns side and alignment components of the placement\n */\nexport function parseFloatingUIPlacement(placement: Placement): { side: Side; alignment: Alignment } {\n const tokens = placement.split('-');\n return {\n side: tokens[0] as Side,\n alignment: tokens[1] as Alignment,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,40 @@
1
+ const getPositionMap = rtl => ({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ }); // Floating UI automatically flips alignment
7
+ // https://github.com/floating-ui/floating-ui/issues/1563
8
+
9
+
10
+ const getAlignmentMap = () => ({
11
+ start: 'start',
12
+ end: 'end',
13
+ top: 'start',
14
+ bottom: 'end',
15
+ center: undefined
16
+ });
17
+
18
+ const shouldAlignToCenter = (p, a) => {
19
+ const positionedVertically = p === 'above' || p === 'below';
20
+ const alignedVertically = a === 'top' || a === 'bottom';
21
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
22
+ };
23
+ /**
24
+ * Maps internal positioning values to Floating UI placement
25
+ * @see positioningHelper.test.ts for expected placement values
26
+ */
27
+
28
+
29
+ export const toFloatingUIPlacement = (align, position, rtl) => {
30
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
31
+ const computedPosition = position && getPositionMap(rtl)[position];
32
+ const computedAlignment = alignment && getAlignmentMap()[alignment];
33
+
34
+ if (computedPosition && computedAlignment) {
35
+ return `${computedPosition}-${computedAlignment}`;
36
+ }
37
+
38
+ return computedPosition;
39
+ };
40
+ //# sourceMappingURL=toFloatingUIPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/toFloatingUIPlacement.ts"],"names":[],"mappings":"AAMA,MAAM,cAAc,GAAI,GAAD,KAAyD;EAC9E,KAAK,EAAE,KADuE;EAE9E,KAAK,EAAE,QAFuE;EAG9E,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;EAI9E,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB,C,CAOA;AACA;;;AACA,MAAM,eAAe,GAAG,OAAsD;EAC5E,KAAK,EAAE,OADqE;EAE5E,GAAG,EAAE,KAFuE;EAG5E,GAAG,EAAE,OAHuE;EAI5E,MAAM,EAAE,KAJoE;EAK5E,MAAM,EAAE;AALoE,CAAtD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;EACnE,MAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;EACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;EAEA,OAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;;AAGG;;;AACH,OAAO,MAAM,qBAAqB,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAAiF;EACpH,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;EAEA,MAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;EACA,MAAM,iBAAiB,GAAG,SAAS,IAAI,eAAe,GAAG,SAAH,CAAtD;;EAEA,IAAI,gBAAgB,IAAI,iBAAxB,EAA2C;IACzC,OAAO,GAAG,gBAAgB,IAAI,iBAAiB,EAA/C;EACD;;EAED,OAAO,gBAAP;AACD,CAXM","sourcesContent":["import type { Placement, Side, Alignment as FloatingUIAlignment } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\n\ntype PlacementPosition = Side;\ntype PlacementAlign = FloatingUIAlignment;\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (): Record<Alignment, PlacementAlign | undefined> => ({\n start: 'start',\n end: 'end',\n top: 'start',\n bottom: 'end',\n center: undefined,\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * Maps internal positioning values to Floating UI placement\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const toFloatingUIPlacement = (align?: Alignment, position?: Position, rtl?: boolean): Placement | undefined => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignment = alignment && getAlignmentMap()[alignment];\n\n if (computedPosition && computedAlignment) {\n return `${computedPosition}-${computedAlignment}` as Placement;\n }\n\n return computedPosition;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,24 @@
1
+ import { getScrollParent } from './getScrollParent';
2
+ /**
3
+ * Toggles event listeners for scroll parent.
4
+ * Cleans up the event listeners for the previous element and adds them for the new scroll parent.
5
+ * @param next Next element
6
+ * @param prev Previous element
7
+ */
8
+
9
+ export function toggleScrollListener(next, prev, handler) {
10
+ if (next === prev) {
11
+ return;
12
+ }
13
+
14
+ if (prev instanceof HTMLElement) {
15
+ const prevScrollParent = getScrollParent(prev);
16
+ prevScrollParent.removeEventListener('scroll', handler);
17
+ }
18
+
19
+ if (next instanceof HTMLElement) {
20
+ const scrollParent = getScrollParent(next);
21
+ scrollParent.addEventListener('scroll', handler);
22
+ }
23
+ }
24
+ //# sourceMappingURL=toggleScrollListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/toggleScrollListener.ts"],"names":[],"mappings":"AACA,SAAS,eAAT,QAAgC,mBAAhC;AAEA;;;;;AAKG;;AACH,OAAM,SAAU,oBAAV,CACJ,IADI,EAEJ,IAFI,EAGJ,OAHI,EAGkB;EAEtB,IAAI,IAAI,KAAK,IAAb,EAAmB;IACjB;EACD;;EAED,IAAI,IAAI,YAAY,WAApB,EAAiC;IAC/B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAD,CAAxC;IACA,gBAAgB,CAAC,mBAAjB,CAAqC,QAArC,EAA+C,OAA/C;EACD;;EACD,IAAI,IAAI,YAAY,WAApB,EAAiC;IAC/B,MAAM,YAAY,GAAG,eAAe,CAAC,IAAD,CAApC;IACA,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,OAAxC;EACD;AACF","sourcesContent":["import type { PositioningVirtualElement } from '../types';\nimport { getScrollParent } from './getScrollParent';\n\n/**\n * Toggles event listeners for scroll parent.\n * Cleans up the event listeners for the previous element and adds them for the new scroll parent.\n * @param next Next element\n * @param prev Previous element\n */\nexport function toggleScrollListener(\n next: HTMLElement | PositioningVirtualElement | null,\n prev: HTMLElement | PositioningVirtualElement | null,\n handler: EventListener,\n) {\n if (next === prev) {\n return;\n }\n\n if (prev instanceof HTMLElement) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener('scroll', handler);\n }\n if (next instanceof HTMLElement) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener('scroll', handler);\n }\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DATA_POSITIONING_PLACEMENT = exports.DATA_POSITIONING_HIDDEN = exports.DATA_POSITIONING_ESCAPED = exports.DATA_POSITIONING_INTERSECTING = void 0;
7
+ exports.DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';
8
+ exports.DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
9
+ exports.DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
10
+ exports.DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,6BAAA,GAAgC,6BAAhC;AACA,OAAA,CAAA,wBAAA,GAA2B,qBAA3B;AACA,OAAA,CAAA,uBAAA,GAA0B,8BAA1B;AACA,OAAA,CAAA,0BAAA,GAA6B,uBAA7B","sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.coverTarget = void 0;
7
+
8
+ const index_1 = /*#__PURE__*/require("../utils/index");
9
+
10
+ function coverTarget() {
11
+ return {
12
+ name: 'coverTarget',
13
+ fn: middlewareArguments => {
14
+ const {
15
+ placement,
16
+ rects,
17
+ x,
18
+ y
19
+ } = middlewareArguments;
20
+ const basePlacement = index_1.parseFloatingUIPlacement(placement).side;
21
+ const newCoords = {
22
+ x,
23
+ y
24
+ };
25
+
26
+ switch (basePlacement) {
27
+ case 'bottom':
28
+ newCoords.y -= rects.reference.height;
29
+ break;
30
+
31
+ case 'top':
32
+ newCoords.y += rects.reference.height;
33
+ break;
34
+
35
+ case 'left':
36
+ newCoords.x += rects.reference.width;
37
+ break;
38
+
39
+ case 'right':
40
+ newCoords.x -= rects.reference.width;
41
+ break;
42
+ }
43
+
44
+ return newCoords;
45
+ }
46
+ };
47
+ }
48
+
49
+ exports.coverTarget = coverTarget;
50
+ //# sourceMappingURL=coverTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/coverTarget.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,SAAgB,WAAhB,GAA2B;EACzB,OAAO;IACL,IAAI,EAAE,aADD;IAEL,EAAE,EAAE,mBAAmB,IAAG;MACxB,MAAM;QAAE,SAAF;QAAa,KAAb;QAAoB,CAApB;QAAuB;MAAvB,IAA6B,mBAAnC;MACA,MAAM,aAAa,GAAG,OAAA,CAAA,wBAAA,CAAyB,SAAzB,EAAoC,IAA1D;MACA,MAAM,SAAS,GAAG;QAAE,CAAF;QAAK;MAAL,CAAlB;;MAEA,QAAQ,aAAR;QACE,KAAK,QAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,KAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,MAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;;QACF,KAAK,OAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;MAZJ;;MAeA,OAAO,SAAP;IACD;EAvBI,CAAP;AAyBD;;AA1BD,OAAA,CAAA,WAAA,GAAA,WAAA","sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flip = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ const index_1 = /*#__PURE__*/require("../utils/index");
11
+
12
+ function flip(options) {
13
+ const {
14
+ hasScrollableElement,
15
+ flipBoundary,
16
+ container
17
+ } = options;
18
+ return dom_1.flip({ ...(hasScrollableElement && {
19
+ boundary: 'clippingAncestors'
20
+ }),
21
+ ...(flipBoundary && {
22
+ altBoundary: true,
23
+ boundary: index_1.getBoundary(container, flipBoundary)
24
+ }),
25
+ fallbackStrategy: 'bestFit'
26
+ });
27
+ }
28
+
29
+ exports.flip = flip;
30
+ //# sourceMappingURL=flip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/flip.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAOA,SAAgB,IAAhB,CAAqB,OAArB,EAAmD;EACjD,MAAM;IAAE,oBAAF;IAAwB,YAAxB;IAAsC;EAAtC,IAAoD,OAA1D;EAEA,OAAO,KAAA,CAAA,IAAA,CAAS,EACd,IAAI,oBAAoB,IAAI;MAAE,QAAQ,EAAE;IAAZ,CAA5B,CADc;IAEd,IAAI,YAAY,IAAI;MAAE,WAAW,EAAE,IAAf;MAAqB,QAAQ,EAAE,OAAA,CAAA,WAAA,CAAY,SAAZ,EAAuB,YAAvB;IAA/B,CAApB,CAFc;IAGd,gBAAgB,EAAE;EAHJ,CAAT,CAAP;AAKD;;AARD,OAAA,CAAA,IAAA,GAAA,IAAA","sourcesContent":["import { flip as baseFlip } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/index';\n\nexport interface FlipMiddlewareOptions extends Pick<PositioningOptions, 'flipBoundary'> {\n hasScrollableElement?: boolean;\n container: HTMLElement | null;\n}\n\nexport function flip(options: FlipMiddlewareOptions) {\n const { hasScrollableElement, flipBoundary, container } = options;\n\n return baseFlip({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(flipBoundary && { altBoundary: true, boundary: getBoundary(container, flipBoundary) }),\n fallbackStrategy: 'bestFit',\n });\n}\n"],"sourceRoot":"../src/"}