@fluentui/react-positioning 0.0.0-nightly-20230501-0418.1 → 0.0.0-nightly-20230503-0419.1

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.
Files changed (68) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/dist/index.d.ts +267 -0
  4. package/lib/constants.js +5 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/createArrowStyles.js +87 -0
  7. package/lib/createArrowStyles.js.map +1 -0
  8. package/lib/createPositionManager.js +120 -0
  9. package/lib/createPositionManager.js.map +1 -0
  10. package/lib/createVirtualElementFromClick.js +25 -0
  11. package/lib/createVirtualElementFromClick.js.map +1 -0
  12. package/lib/index.js +6 -0
  13. package/lib/index.js.map +1 -0
  14. package/lib/middleware/coverTarget.js +35 -0
  15. package/lib/middleware/coverTarget.js.map +1 -0
  16. package/lib/middleware/flip.js +36 -0
  17. package/lib/middleware/flip.js.map +1 -0
  18. package/lib/middleware/index.js +7 -0
  19. package/lib/middleware/index.js.map +1 -0
  20. package/lib/middleware/intersecting.js +21 -0
  21. package/lib/middleware/intersecting.js.map +1 -0
  22. package/lib/middleware/maxSize.js +38 -0
  23. package/lib/middleware/maxSize.js.map +1 -0
  24. package/lib/middleware/offset.js +10 -0
  25. package/lib/middleware/offset.js.map +1 -0
  26. package/lib/middleware/shift.js +35 -0
  27. package/lib/middleware/shift.js.map +1 -0
  28. package/lib/types.js +2 -0
  29. package/lib/types.js.map +1 -0
  30. package/lib/usePositioning.js +169 -0
  31. package/lib/usePositioning.js.map +1 -0
  32. package/lib/usePositioningMouseTarget.js +34 -0
  33. package/lib/usePositioningMouseTarget.js.map +1 -0
  34. package/lib/utils/debounce.js +20 -0
  35. package/lib/utils/debounce.js.map +1 -0
  36. package/lib/utils/fromFloatingUIPlacement.js +38 -0
  37. package/lib/utils/fromFloatingUIPlacement.js.map +1 -0
  38. package/lib/utils/getBoundary.js +21 -0
  39. package/lib/utils/getBoundary.js.map +1 -0
  40. package/lib/utils/getFloatingUIOffset.js +33 -0
  41. package/lib/utils/getFloatingUIOffset.js.map +1 -0
  42. package/lib/utils/getReactFiberFromNode.js +43 -0
  43. package/lib/utils/getReactFiberFromNode.js.map +1 -0
  44. package/lib/utils/getScrollParent.js +58 -0
  45. package/lib/utils/getScrollParent.js.map +1 -0
  46. package/lib/utils/hasAutoFocusFilter.js +23 -0
  47. package/lib/utils/hasAutoFocusFilter.js.map +1 -0
  48. package/lib/utils/index.js +16 -0
  49. package/lib/utils/index.js.map +1 -0
  50. package/lib/utils/mergeArrowOffset.js +38 -0
  51. package/lib/utils/mergeArrowOffset.js.map +1 -0
  52. package/lib/utils/parseFloatingUIPlacement.js +13 -0
  53. package/lib/utils/parseFloatingUIPlacement.js.map +1 -0
  54. package/lib/utils/resolvePositioningShorthand.js +61 -0
  55. package/lib/utils/resolvePositioningShorthand.js.map +1 -0
  56. package/lib/utils/toFloatingUIPadding.js +23 -0
  57. package/lib/utils/toFloatingUIPadding.js.map +1 -0
  58. package/lib/utils/toFloatingUIPlacement.js +34 -0
  59. package/lib/utils/toFloatingUIPlacement.js.map +1 -0
  60. package/lib/utils/toggleScrollListener.js +22 -0
  61. package/lib/utils/toggleScrollListener.js.map +1 -0
  62. package/lib/utils/useCallbackRef.js +51 -0
  63. package/lib/utils/useCallbackRef.js.map +1 -0
  64. package/lib/utils/writeArrowUpdates.js +20 -0
  65. package/lib/utils/writeArrowUpdates.js.map +1 -0
  66. package/lib/utils/writeContainerupdates.js +43 -0
  67. package/lib/utils/writeContainerupdates.js.map +1 -0
  68. package/package.json +4 -4
@@ -0,0 +1,33 @@
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
+ export function getFloatingUIOffset(rawOffset) {
8
+ if (!rawOffset) {
9
+ return rawOffset;
10
+ }
11
+ if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
12
+ return rawOffset;
13
+ }
14
+ return ({
15
+ rects: {
16
+ floating,
17
+ reference
18
+ },
19
+ placement
20
+ }) => {
21
+ const {
22
+ position,
23
+ alignment
24
+ } = fromFloatingUIPlacement(placement);
25
+ return rawOffset({
26
+ positionedRect: floating,
27
+ targetRect: reference,
28
+ position,
29
+ alignment
30
+ });
31
+ };
32
+ }
33
+ //# sourceMappingURL=getFloatingUIOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fromFloatingUIPlacement","getFloatingUIOffset","rawOffset","rects","floating","reference","placement","position","alignment","positionedRect","targetRect"],"sources":["../../src/utils/getFloatingUIOffset.ts"],"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"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAgCxC;;;;;AAKA,OAAO,SAASC,oBACdC,SAA6B,EACiC;EAC9D,IAAI,CAACA,SAAA,EAAW;IACd,OAAOA,SAAA;EACT;EAEA,IAAI,OAAOA,SAAA,KAAc,YAAY,OAAOA,SAAA,KAAc,UAAU;IAClE,OAAOA,SAAA;EACT;EAEA,OAAO,CAAC;IAAEC,KAAA,EAAO;MAAEC,QAAA;MAAUC;IAAS,CAAE;IAAEC;EAAS,CAAE,KAAK;IACxD,MAAM;MAAEC,QAAA;MAAUC;IAAS,CAAE,GAAGR,uBAAA,CAAwBM,SAAA;IACxD,OAAOJ,SAAA,CAAU;MAAEO,cAAA,EAAgBL,QAAA;MAAUM,UAAA,EAAYL,SAAA;MAAWE,QAAA;MAAUC;IAAU;EAC1F;AACF"}
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+ var WorkTag;
3
+ (function (WorkTag) {
4
+ WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
5
+ WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
6
+ WorkTag[WorkTag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
7
+ WorkTag[WorkTag["HostRoot"] = 3] = "HostRoot";
8
+ WorkTag[WorkTag["HostPortal"] = 4] = "HostPortal";
9
+ WorkTag[WorkTag["HostComponent"] = 5] = "HostComponent";
10
+ WorkTag[WorkTag["HostText"] = 6] = "HostText";
11
+ WorkTag[WorkTag["Fragment"] = 7] = "Fragment";
12
+ WorkTag[WorkTag["Mode"] = 8] = "Mode";
13
+ WorkTag[WorkTag["ContextConsumer"] = 9] = "ContextConsumer";
14
+ WorkTag[WorkTag["ContextProvider"] = 10] = "ContextProvider";
15
+ WorkTag[WorkTag["ForwardRef"] = 11] = "ForwardRef";
16
+ WorkTag[WorkTag["Profiler"] = 12] = "Profiler";
17
+ WorkTag[WorkTag["SuspenseComponent"] = 13] = "SuspenseComponent";
18
+ WorkTag[WorkTag["MemoComponent"] = 14] = "MemoComponent";
19
+ WorkTag[WorkTag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
20
+ WorkTag[WorkTag["LazyComponent"] = 16] = "LazyComponent";
21
+ WorkTag[WorkTag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
22
+ WorkTag[WorkTag["DehydratedFragment"] = 18] = "DehydratedFragment";
23
+ WorkTag[WorkTag["SuspenseListComponent"] = 19] = "SuspenseListComponent";
24
+ WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
25
+ WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
26
+ })(WorkTag || (WorkTag = {}));
27
+ export function getReactFiberFromNode(elm) {
28
+ if (!elm) {
29
+ return null;
30
+ }
31
+ for (const k in elm) {
32
+ // React 16 uses "__reactInternalInstance$" prefix
33
+ // React 17 uses "__reactFiber$" prefix
34
+ // https://github.com/facebook/react/pull/18377
35
+ if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {
36
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
+ // @ts-ignore
38
+ return elm[k];
39
+ }
40
+ }
41
+ throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
42
+ }
43
+ //# sourceMappingURL=getReactFiberFromNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","WorkTag","getReactFiberFromNode","elm","k","indexOf","Error"],"sources":["../../src/utils/getReactFiberFromNode.ts"],"sourcesContent":["import * as React from 'react';\n\n// ========================================================\n// react/packages/shared/ReactTypes.js\n// ========================================================\n\ntype ReactEventResponder<E, C> = {\n $$typeof: Symbol | number;\n displayName: string;\n targetEventTypes: null | string[];\n rootEventTypes: null | string[];\n getInitialState: null | ((props: Object) => Object);\n onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onMount: null | ((context: C, props: Object, state: Object) => void);\n onUnmount: null | ((context: C, props: Object, state: Object) => void);\n};\n\ntype ReactEventResponderInstance<E, C> = {\n fiber: Object;\n props: Object;\n responder: ReactEventResponder<E, C>;\n rootEventTypes: null | Set<string>;\n state: Object;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiberHooks.js\n// ========================================================\n\nexport type HookType =\n | 'useState'\n | 'useReducer'\n | 'useContext'\n | 'useRef'\n | 'useEffect'\n | 'useLayoutEffect'\n | 'useCallback'\n | 'useMemo'\n | 'useImperativeHandle'\n | 'useDebugValue'\n | 'useResponder';\n\ntype ReactProviderType<T> = {\n $$typeof: Symbol | number;\n _context: ReactContext<T>;\n};\n\ntype ReactContext<T> = {\n $$typeof: Symbol | number;\n Consumer: ReactContext<T>;\n Provider: ReactProviderType<T>;\n\n _calculateChangedBits: ((a: T, b: T) => number) | null;\n\n _currentValue: T;\n _currentValue2: T;\n _threadCount: number;\n\n // DEV only\n _currentRenderer?: Object | null;\n _currentRenderer2?: Object | null;\n};\n\ntype ContextDependency<T> = {\n context: ReactContext<T>;\n observedBits: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n next: ContextDependency<any> | null;\n};\n\nenum WorkTag {\n FunctionComponent = 0,\n ClassComponent = 1,\n IndeterminateComponent = 2, // Before we know whether it is function or class\n HostRoot = 3, // Root of a host tree. Could be nested inside another node.\n HostPortal = 4, // A subtree. Could be an entry point to a different renderer.\n HostComponent = 5,\n HostText = 6,\n Fragment = 7,\n Mode = 8,\n ContextConsumer = 9,\n ContextProvider = 10,\n ForwardRef = 11,\n Profiler = 12,\n SuspenseComponent = 13,\n MemoComponent = 14,\n SimpleMemoComponent = 15,\n LazyComponent = 16,\n IncompleteClassComponent = 17,\n DehydratedFragment = 18,\n SuspenseListComponent = 19,\n FundamentalComponent = 20,\n ScopeComponent = 21,\n}\n\ntype Source = {\n fileName: string;\n lineNumber: number;\n};\n\ntype ExpirationTime = number;\n\ntype Dependencies = {\n expirationTime: ExpirationTime;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstContext: ContextDependency<any> | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiber.js\n// ========================================================\n\n// A Fiber is work on a Component that needs to be done or was done. There can\n// be more than one per component.\n\nexport type Fiber = {\n // These first fields are conceptually members of an Instance. This used to\n // be split into a separate type and intersected with the other Fiber fields,\n // but until Flow fixes its intersection bugs, we've merged them into a\n // single type.\n\n // An Instance is shared between all versions of a component. We can easily\n // break this out into a separate object to avoid copying so much to the\n // alternate versions of the tree. We put this on a single object for now to\n // minimize the number of objects created during the initial render.\n\n // Tag identifying the type of fiber.\n tag: WorkTag;\n\n // Unique identifier of this child.\n key: null | string;\n\n // The value of element.type which is used to preserve the identity during\n // reconciliation of this child.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementType: any;\n\n // The resolved function/class/ associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any;\n\n // The local state associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stateNode: any;\n\n // Conceptual aliases\n // parent : Instance -> return The parent happens to be the same as the\n // return fiber since we've merged the fiber and instance.\n\n // Remaining fields belong to Fiber\n\n // The Fiber to return to after finishing processing this one.\n // This is effectively the parent, but there can be multiple parents (two)\n // so this is only the parent of the thing we're currently processing.\n // It is conceptually the same as the return address of a stack frame.\n return: Fiber | null;\n\n // Singly Linked List Tree Structure.\n child: Fiber | null;\n sibling: Fiber | null;\n index: number;\n\n // The ref last used to attach this node.\n // I'll avoid adding an owner field for prod and model that as functions.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: React.Ref<any>;\n\n // Input is the data coming into process this fiber. Arguments. Props.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pendingProps: any; // This type will be more specific once we overload the tag.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedProps: any; // The props used to create the output.\n\n // A queue of state updates and callbacks.\n // updateQueue: UpdateQueue<any> | null,\n\n // The state used to create the output\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedState: any;\n\n // Dependencies (contexts, events) for this fiber, if it has any\n dependencies: Dependencies | null;\n\n // // Bitfield that describes properties about the fiber and its subtree. E.g.\n // // the ConcurrentMode flag indicates whether the subtree should be async-by-\n // // default. When a fiber is created, it inherits the mode of its\n // // parent. Additional flags can be set at creation time, but after that the\n // // value should remain unchanged throughout the fiber's lifetime, particularly\n // // before its child fibers are created.\n // mode: TypeOfMode\n //\n // // Effect\n // effectTag: SideEffectTag\n\n // Singly linked list fast path to the next fiber with side-effects.\n nextEffect: Fiber | null;\n\n // The first and last fiber with side-effect within this subtree. This allows\n // us to reuse a slice of the linked list when we reuse the work done within\n // this fiber.\n firstEffect: Fiber | null;\n lastEffect: Fiber | null;\n\n // Represents a time in the future by which this work should be completed.\n // Does not include work found in its subtree.\n expirationTime: ExpirationTime;\n\n // This is used to quickly determine if a subtree has no pending changes.\n childExpirationTime: ExpirationTime;\n\n // This is a pooled version of a Fiber. Every fiber that gets updated will\n // eventually have a pair. There are cases when we can clean up pairs to save\n // memory if we need to.\n alternate: Fiber | null;\n\n // Time spent rendering this Fiber and its descendants for the current update.\n // This tells us how well the tree makes use of sCU for memoization.\n // It is reset to 0 each time we render and only updated when we don't bailout.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualDuration?: number;\n\n // If the Fiber is currently active in the \"render\" phase,\n // This marks the time at which the work began.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualStartTime?: number;\n\n // Duration of the most recent render time for this Fiber.\n // This value is not updated when we bailout for memoization purposes.\n // This field is only set when the enableProfilerTimer flag is enabled.\n selfBaseDuration?: number;\n\n // Sum of base times for all descendants of this Fiber.\n // This value bubbles up during the \"complete\" phase.\n // This field is only set when the enableProfilerTimer flag is enabled.\n treeBaseDuration?: number;\n\n // Conceptual aliases\n // workInProgress : Fiber -> alternate The alternate used for reuse happens\n // to be the same as work in progress.\n // __DEV__ only\n _debugID?: number;\n _debugSource?: Source | null;\n _debugOwner?: Fiber | null;\n _debugIsCurrentlyTiming?: boolean;\n _debugNeedsRemount?: boolean;\n\n // Used to verify that the order of hooks does not change between renders.\n _debugHookTypes?: HookType[] | null;\n};\n\nexport function getReactFiberFromNode(elm: Node | undefined): Fiber | null {\n if (!elm) {\n return null;\n }\n\n for (const k in elm) {\n // React 16 uses \"__reactInternalInstance$\" prefix\n // React 17 uses \"__reactFiber$\" prefix\n // https://github.com/facebook/react/pull/18377\n if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return elm[k];\n }\n }\n\n throw new Error('getReactFiber(): Failed to find a React Fiber on a node');\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;IAuEvBC,OAAA;WAAKA,OAAO;EAAPA,OAAA,CAAAA,OAAA,CACH,uBAAoB,KAApB;EADGA,OAAA,CAAAA,OAAA,CAEH,oBAAiB,KAAjB;EAFGA,OAAA,CAAAA,OAAA,CAGH,4BAAyB,KAAzB;EAHGA,OAAA,CAAAA,OAAA,CAIH,cAAW,KAAX;EAJGA,OAAA,CAAAA,OAAA,CAKH,gBAAa,KAAb;EALGA,OAAA,CAAAA,OAAA,CAMH,mBAAgB,KAAhB;EANGA,OAAA,CAAAA,OAAA,CAOH,cAAW,KAAX;EAPGA,OAAA,CAAAA,OAAA,CAQH,cAAW,KAAX;EARGA,OAAA,CAAAA,OAAA,CASH,UAAO,KAAP;EATGA,OAAA,CAAAA,OAAA,CAUH,qBAAkB,KAAlB;EAVGA,OAAA,CAAAA,OAAA,CAWH,qBAAkB,MAAlB;EAXGA,OAAA,CAAAA,OAAA,CAYH,gBAAa,MAAb;EAZGA,OAAA,CAAAA,OAAA,CAaH,cAAW,MAAX;EAbGA,OAAA,CAAAA,OAAA,CAcH,uBAAoB,MAApB;EAdGA,OAAA,CAAAA,OAAA,CAeH,mBAAgB,MAAhB;EAfGA,OAAA,CAAAA,OAAA,CAgBH,yBAAsB,MAAtB;EAhBGA,OAAA,CAAAA,OAAA,CAiBH,mBAAgB,MAAhB;EAjBGA,OAAA,CAAAA,OAAA,CAkBH,8BAA2B,MAA3B;EAlBGA,OAAA,CAAAA,OAAA,CAmBH,wBAAqB,MAArB;EAnBGA,OAAA,CAAAA,OAAA,CAoBH,2BAAwB,MAAxB;EApBGA,OAAA,CAAAA,OAAA,CAqBH,0BAAuB,MAAvB;EArBGA,OAAA,CAAAA,OAAA,CAsBH,oBAAiB,MAAjB;GAtBGA,OAAA,KAAAA,OAAA;AAsLL,OAAO,SAASC,sBAAsBC,GAAqB,EAAgB;EACzE,IAAI,CAACA,GAAA,EAAK;IACR,OAAO,IAAI;EACb;EAEA,KAAK,MAAMC,CAAA,IAAKD,GAAA,EAAK;IACnB;IACA;IACA;IACA,IAAIC,CAAA,CAAEC,OAAO,CAAC,gCAAgC,KAAKD,CAAA,CAAEC,OAAO,CAAC,qBAAqB,GAAG;MACnF;MACA;MACA,OAAOF,GAAG,CAACC,CAAA,CAAE;IACf;EACF;EAEA,MAAM,IAAIE,KAAA,CAAM;AAClB"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Returns the parent node or the host of the node argument.
3
+ * @param node - DOM node.
4
+ * @returns - parent DOM node.
5
+ */export const getParentNode = node => {
6
+ if (node.nodeName === 'HTML') {
7
+ return node;
8
+ }
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ return node.parentNode || node.host;
11
+ };
12
+ /**
13
+ * Returns CSS styles of the given node.
14
+ * @param node - DOM node.
15
+ * @returns - CSS styles.
16
+ */
17
+ const getStyleComputedProperty = node => {
18
+ var _node_ownerDocument;
19
+ if (node.nodeType !== 1) {
20
+ return {};
21
+ }
22
+ const window = (_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.defaultView;
23
+ return window.getComputedStyle(node, null);
24
+ };
25
+ /**
26
+ * Returns the first scrollable parent of the given element.
27
+ * @param node - DOM node.
28
+ * @returns - the first scrollable parent.
29
+ */
30
+ export const getScrollParent = node => {
31
+ // Return body, `getScroll` will take care to get the correct `scrollTop` from it
32
+ const parentNode = node && getParentNode(node);
33
+ // eslint-disable-next-line
34
+ if (!parentNode) return document.body;
35
+ switch (parentNode.nodeName) {
36
+ case 'HTML':
37
+ case 'BODY':
38
+ return parentNode.ownerDocument.body;
39
+ case '#document':
40
+ return parentNode.body;
41
+ }
42
+ // If any of the overflow props is defined for the node then we return it as the parent
43
+ const {
44
+ overflow,
45
+ overflowX,
46
+ overflowY
47
+ } = getStyleComputedProperty(parentNode);
48
+ if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
49
+ return parentNode;
50
+ }
51
+ return getScrollParent(parentNode);
52
+ };
53
+ export const hasScrollParent = node => {
54
+ var _scrollParentElement_ownerDocument;
55
+ const scrollParentElement = getScrollParent(node);
56
+ return scrollParentElement ? scrollParentElement !== ((_scrollParentElement_ownerDocument = scrollParentElement.ownerDocument) === null || _scrollParentElement_ownerDocument === void 0 ? void 0 : _scrollParentElement_ownerDocument.body) : false;
57
+ };
58
+ //# sourceMappingURL=getScrollParent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getParentNode","node","nodeName","parentNode","host","getStyleComputedProperty","_node_ownerDocument","nodeType","window","ownerDocument","defaultView","getComputedStyle","getScrollParent","document","body","overflow","overflowX","overflowY","test","hasScrollParent","_scrollParentElement_ownerDocument","scrollParentElement"],"sources":["../../src/utils/getScrollParent.ts"],"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"],"mappings":"AAAA;;;;GAKA,OAAO,MAAMA,aAAA,GAAiBC,IAAA,IAAmC;EAC/D,IAAIA,IAAA,CAAKC,QAAQ,KAAK,QAAQ;IAC5B,OAAOD,IAAA;EACT;EACA;EACA,OAAOA,IAAA,CAAKE,UAAU,IAAIF,IAAC,CAAaG,IAAI;AAC9C;AAEA;;;;;AAKA,MAAMC,wBAAA,GAA4BJ,IAAA,IAAoD;MAKrEK,mBAAA;EAJf,IAAIL,IAAA,CAAKM,QAAQ,KAAK,GAAG;IACvB,OAAO,CAAC;EACV;EAEA,MAAMC,MAAA,GAAS,CAAAF,mBAAA,GAAAL,IAAA,CAAKQ,aAAa,cAAlBH,mBAAA,uBAAAA,mBAAA,CAAoBI,WAAW;EAC9C,OAAOF,MAAA,CAAQG,gBAAgB,CAACV,IAAA,EAAM,IAAI;AAC5C;AAEA;;;;;AAKA,OAAO,MAAMW,eAAA,GAAmBX,IAAA,IAAqD;EACnF;EACA,MAAME,UAAA,GAAaF,IAAA,IAAQD,aAAA,CAAcC,IAAA;EACzC;EACA,IAAI,CAACE,UAAA,EAAY,OAAOU,QAAA,CAASC,IAAI;EAErC,QAAQX,UAAA,CAAWD,QAAQ;IACzB,KAAK;IACL,KAAK;MACH,OAAOC,UAAA,CAAWM,aAAa,CAAEK,IAAI;IACvC,KAAK;MACH,OAAOX,UAAC,CAAmCW,IAAI;EAAA;EAGnD;EACA,MAAM;IAAEC,QAAA;IAAUC,SAAA;IAAWC;EAAS,CAAE,GAAGZ,wBAAA,CAAyBF,UAAA;EACpE,IAAI,wBAAwBe,IAAI,CAACH,QAAA,GAAYE,SAAA,GAAaD,SAAA,GAAY;IACpE,OAAOb,UAAA;EACT;EAEA,OAAOS,eAAA,CAAgBT,UAAA;AACzB;AAEA,OAAO,MAAMgB,eAAA,GAAmBlB,IAAA,IAAiD;MAE1BmB,kCAAA;EADrD,MAAMC,mBAAA,GAAmCT,eAAA,CAAgBX,IAAA;EACzD,OAAOoB,mBAAA,GAAsBA,mBAAA,MAAwB,CAAAD,kCAAA,GAAAC,mBAAA,CAAoBZ,aAAa,cAAjCW,kCAAA,uBAAAA,kCAAA,CAAmCN,IAAI,CAAD,GAAI,KAAK;AACtG"}
@@ -0,0 +1,23 @@
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
+ function hasAutofocusProp(node) {
12
+ // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
13
+ const isAutoFocusableElement = node.nodeName === 'BUTTON' || node.nodeName === 'INPUT' || node.nodeName === 'SELECT' || node.nodeName === 'TEXTAREA';
14
+ if (isAutoFocusableElement) {
15
+ var _getReactFiberFromNode;
16
+ return !!((_getReactFiberFromNode = getReactFiberFromNode(node)) === null || _getReactFiberFromNode === void 0 ? void 0 : _getReactFiberFromNode.pendingProps.autoFocus);
17
+ }
18
+ return false;
19
+ }
20
+ export function hasAutofocusFilter(node) {
21
+ return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
22
+ }
23
+ //# sourceMappingURL=hasAutoFocusFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getReactFiberFromNode","hasAutofocusProp","node","isAutoFocusableElement","nodeName","_getReactFiberFromNode","pendingProps","autoFocus","hasAutofocusFilter","NodeFilter","FILTER_ACCEPT","FILTER_SKIP"],"sources":["../../src/utils/hasAutoFocusFilter.ts"],"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"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,qBAAqB,QAAQ;AAEtC;;;;;;AAMA,SAASC,iBAAiBC,IAAU,EAAW;EAC7C;EACA,MAAMC,sBAAA,GACJD,IAAA,CAAKE,QAAQ,KAAK,YAClBF,IAAA,CAAKE,QAAQ,KAAK,WAClBF,IAAA,CAAKE,QAAQ,KAAK,YAClBF,IAAA,CAAKE,QAAQ,KAAK;EAEpB,IAAID,sBAAA,EAAwB;QACjBE,sBAAA;IAAT,OAAO,CAAC,EAAC,CAAAA,sBAAA,GAAAL,qBAAA,CAAsBE,IAAA,eAAtBG,sBAAA,uBAAAA,sBAAA,CAA6BC,YAAA,CAAaC,SAAS;EAC9D;EAEA,OAAO,KAAK;AACd;AAEA,OAAO,SAASC,mBAAmBN,IAAU,EAAE;EAC7C,OAAOD,gBAAA,CAAiBC,IAAA,IAAQO,UAAA,CAAWC,aAAa,GAAGD,UAAA,CAAWE,WAAW;AACnF"}
@@ -0,0 +1,16 @@
1
+ export * from './parseFloatingUIPlacement';
2
+ export * from './getBoundary';
3
+ export * from './getReactFiberFromNode';
4
+ export * from './getScrollParent';
5
+ export * from './mergeArrowOffset';
6
+ export * from './toFloatingUIPadding';
7
+ export * from './toFloatingUIPlacement';
8
+ export * from './fromFloatingUIPlacement';
9
+ export * from './resolvePositioningShorthand';
10
+ export * from './useCallbackRef';
11
+ export * from './debounce';
12
+ export * from './toggleScrollListener';
13
+ export * from './hasAutoFocusFilter';
14
+ export * from './writeArrowUpdates';
15
+ export * from './writeContainerupdates';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
3
+ * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
4
+ *
5
+ * @internal
6
+ * @param userOffset - The offset provided by the user
7
+ * @param arrowHeight - The height of the arrow in px
8
+ * @returns User offset augmented with arrow height
9
+ */export function mergeArrowOffset(userOffset, arrowHeight) {
10
+ if (typeof userOffset === 'number') {
11
+ return addArrowOffset(userOffset, arrowHeight);
12
+ }
13
+ if (typeof userOffset === 'object' && userOffset !== null) {
14
+ return addArrowOffset(userOffset, arrowHeight);
15
+ }
16
+ if (typeof userOffset === 'function') {
17
+ return offsetParams => {
18
+ const offset = userOffset(offsetParams);
19
+ return addArrowOffset(offset, arrowHeight);
20
+ };
21
+ }
22
+ return {
23
+ mainAxis: arrowHeight
24
+ };
25
+ }
26
+ const addArrowOffset = (offset, arrowHeight) => {
27
+ if (typeof offset === 'number') {
28
+ return {
29
+ mainAxis: offset + arrowHeight
30
+ };
31
+ }
32
+ var _offset_mainAxis;
33
+ return {
34
+ ...offset,
35
+ mainAxis: ((_offset_mainAxis = offset.mainAxis) !== null && _offset_mainAxis !== void 0 ? _offset_mainAxis : 0) + arrowHeight
36
+ };
37
+ };
38
+ //# sourceMappingURL=mergeArrowOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mergeArrowOffset","userOffset","arrowHeight","addArrowOffset","offsetParams","offset","mainAxis","_offset_mainAxis"],"sources":["../../src/utils/mergeArrowOffset.ts"],"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"],"mappings":"AAEA;;;;;;;;GASA,OAAO,SAASA,iBAAiBC,UAAqC,EAAEC,WAAmB,EAAU;EACnG,IAAI,OAAOD,UAAA,KAAe,UAAU;IAClC,OAAOE,cAAA,CAAeF,UAAA,EAAYC,WAAA;EACpC;EAEA,IAAI,OAAOD,UAAA,KAAe,YAAYA,UAAA,KAAe,IAAI,EAAE;IACzD,OAAOE,cAAA,CAAeF,UAAA,EAAYC,WAAA;EACpC;EAEA,IAAI,OAAOD,UAAA,KAAe,YAAY;IACpC,OAAOG,YAAA,IAAgB;MACrB,MAAMC,MAAA,GAASJ,UAAA,CAAWG,YAAA;MAC1B,OAAOD,cAAA,CAAeE,MAAA,EAAQH,WAAA;IAChC;EACF;EAEA,OAAO;IAAEI,QAAA,EAAUJ;EAAY;AACjC;AAEA,MAAMC,cAAA,GAAiBA,CAACE,MAAA,EAA+BH,WAAA,KAAsC;EAC3F,IAAI,OAAOG,MAAA,KAAW,UAAU;IAC9B,OAAO;MAAEC,QAAA,EAAUD,MAAA,GAASH;IAAY;EAC1C;MAE+BK,gBAAA;EAA/B,OAAO;IAAE,GAAGF,MAAM;IAAEC,QAAA,EAAU,CAAC,CAAAC,gBAAA,GAAAF,MAAA,CAAOC,QAAQ,cAAfC,gBAAA,cAAAA,gBAAA,GAAmB,CAAC,IAAIL;EAAY;AACrE"}
@@ -0,0 +1,13 @@
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
+ */export function parseFloatingUIPlacement(placement) {
7
+ const tokens = placement.split('-');
8
+ return {
9
+ side: tokens[0],
10
+ alignment: tokens[1]
11
+ };
12
+ }
13
+ //# sourceMappingURL=parseFloatingUIPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["parseFloatingUIPlacement","placement","tokens","split","side","alignment"],"sources":["../../src/utils/parseFloatingUIPlacement.ts"],"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"],"mappings":"AAEA;;;;;GAMA,OAAO,SAASA,yBAAyBC,SAAoB,EAAwC;EACnG,MAAMC,MAAA,GAASD,SAAA,CAAUE,KAAK,CAAC;EAC/B,OAAO;IACLC,IAAA,EAAMF,MAAM,CAAC,EAAE;IACfG,SAAA,EAAWH,MAAM,CAAC;EACpB;AACF"}
@@ -0,0 +1,61 @@
1
+ // Look up table for shorthand to avoid parsing strings
2
+ const shorthandLookup = {
3
+ above: {
4
+ position: 'above',
5
+ align: 'center'
6
+ },
7
+ 'above-start': {
8
+ position: 'above',
9
+ align: 'start'
10
+ },
11
+ 'above-end': {
12
+ position: 'above',
13
+ align: 'end'
14
+ },
15
+ below: {
16
+ position: 'below',
17
+ align: 'center'
18
+ },
19
+ 'below-start': {
20
+ position: 'below',
21
+ align: 'start'
22
+ },
23
+ 'below-end': {
24
+ position: 'below',
25
+ align: 'end'
26
+ },
27
+ before: {
28
+ position: 'before',
29
+ align: 'center'
30
+ },
31
+ 'before-top': {
32
+ position: 'before',
33
+ align: 'top'
34
+ },
35
+ 'before-bottom': {
36
+ position: 'before',
37
+ align: 'bottom'
38
+ },
39
+ after: {
40
+ position: 'after',
41
+ align: 'center'
42
+ },
43
+ 'after-top': {
44
+ position: 'after',
45
+ align: 'top'
46
+ },
47
+ 'after-bottom': {
48
+ position: 'after',
49
+ align: 'bottom'
50
+ }
51
+ };
52
+ export function resolvePositioningShorthand(shorthand) {
53
+ if (shorthand === undefined || shorthand === null) {
54
+ return {};
55
+ }
56
+ if (typeof shorthand === 'string') {
57
+ return shorthandLookup[shorthand];
58
+ }
59
+ return shorthand;
60
+ }
61
+ //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["shorthandLookup","above","position","align","below","before","after","resolvePositioningShorthand","shorthand","undefined"],"sources":["../../src/utils/resolvePositioningShorthand.ts"],"sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"],"mappings":"AAEA;AACA,MAAMA,eAAA,GAAmG;EACvGC,KAAA,EAAO;IAAEC,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,eAAe;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAQ;EACnD,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/CC,KAAA,EAAO;IAAEF,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,eAAe;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAQ;EACnD,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/CE,MAAA,EAAQ;IAAEH,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAS;EAC9C,cAAc;IAAED,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAM;EACjD,iBAAiB;IAAED,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAS;EACvDG,KAAA,EAAO;IAAEJ,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/C,gBAAgB;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;AACvD;AAEA,OAAO,SAASI,4BACdC,SAAkD,EACtB;EAC5B,IAAIA,SAAA,KAAcC,SAAA,IAAaD,SAAA,KAAc,IAAI,EAAE;IACjD,OAAO,CAAC;EACV;EAEA,IAAI,OAAOA,SAAA,KAAc,UAAU;IACjC,OAAOR,eAAe,CAACQ,SAAA,CAAU;EACnC;EAEA,OAAOA,SAAA;AACT"}
@@ -0,0 +1,23 @@
1
+ export function toFloatingUIPadding(padding, isRtl) {
2
+ if (typeof padding === 'number') {
3
+ return padding;
4
+ }
5
+ const {
6
+ start,
7
+ end,
8
+ ...verticalPadding
9
+ } = padding;
10
+ const paddingObject = verticalPadding;
11
+ const left = isRtl ? 'end' : 'start';
12
+ const right = isRtl ? 'start' : 'end';
13
+ // assign properties explicitly since undefined values are actually handled by floating UI
14
+ // TODO create floating UI issue
15
+ if (padding[left]) {
16
+ paddingObject.left = padding[left];
17
+ }
18
+ if (padding[right]) {
19
+ paddingObject.right = padding[right];
20
+ }
21
+ return paddingObject;
22
+ }
23
+ //# sourceMappingURL=toFloatingUIPadding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toFloatingUIPadding","padding","isRtl","start","end","verticalPadding","paddingObject","left","right"],"sources":["../../src/utils/toFloatingUIPadding.ts"],"sourcesContent":["import type { SideObject } from '@floating-ui/dom';\nimport { PositioningOptions } from '../types';\n\nexport function toFloatingUIPadding(\n padding: NonNullable<PositioningOptions['overflowBoundaryPadding']>,\n isRtl: boolean,\n): number | Partial<SideObject> {\n if (typeof padding === 'number') {\n return padding;\n }\n\n const { start, end, ...verticalPadding } = padding;\n\n const paddingObject: Partial<SideObject> = verticalPadding;\n\n const left = isRtl ? 'end' : 'start';\n const right = isRtl ? 'start' : 'end';\n\n // assign properties explicitly since undefined values are actually handled by floating UI\n // TODO create floating UI issue\n if (padding[left]) {\n paddingObject.left = padding[left];\n }\n\n if (padding[right]) {\n paddingObject.right = padding[right];\n }\n\n return paddingObject;\n}\n"],"mappings":"AAGA,OAAO,SAASA,oBACdC,OAAmE,EACnEC,KAAc,EACgB;EAC9B,IAAI,OAAOD,OAAA,KAAY,UAAU;IAC/B,OAAOA,OAAA;EACT;EAEA,MAAM;IAAEE,KAAA;IAAOC,GAAA;IAAK,GAAGC;EAAA,CAAiB,GAAGJ,OAAA;EAE3C,MAAMK,aAAA,GAAqCD,eAAA;EAE3C,MAAME,IAAA,GAAOL,KAAA,GAAQ,QAAQ,OAAO;EACpC,MAAMM,KAAA,GAAQN,KAAA,GAAQ,UAAU,KAAK;EAErC;EACA;EACA,IAAID,OAAO,CAACM,IAAA,CAAK,EAAE;IACjBD,aAAA,CAAcC,IAAI,GAAGN,OAAO,CAACM,IAAA,CAAK;EACpC;EAEA,IAAIN,OAAO,CAACO,KAAA,CAAM,EAAE;IAClBF,aAAA,CAAcE,KAAK,GAAGP,OAAO,CAACO,KAAA,CAAM;EACtC;EAEA,OAAOF,aAAA;AACT"}
@@ -0,0 +1,34 @@
1
+ const getPositionMap = rtl => ({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ });
7
+ // Floating UI automatically flips alignment
8
+ // https://github.com/floating-ui/floating-ui/issues/1563
9
+ const getAlignmentMap = () => ({
10
+ start: 'start',
11
+ end: 'end',
12
+ top: 'start',
13
+ bottom: 'end',
14
+ center: undefined
15
+ });
16
+ const shouldAlignToCenter = (p, a) => {
17
+ const positionedVertically = p === 'above' || p === 'below';
18
+ const alignedVertically = a === 'top' || a === 'bottom';
19
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
20
+ };
21
+ /**
22
+ * Maps internal positioning values to Floating UI placement
23
+ * @see positioningHelper.test.ts for expected placement values
24
+ */
25
+ export const toFloatingUIPlacement = (align, position, rtl) => {
26
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
27
+ const computedPosition = position && getPositionMap(rtl)[position];
28
+ const computedAlignment = alignment && getAlignmentMap()[alignment];
29
+ if (computedPosition && computedAlignment) {
30
+ return `${computedPosition}-${computedAlignment}`;
31
+ }
32
+ return computedPosition;
33
+ };
34
+ //# sourceMappingURL=toFloatingUIPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPositionMap","rtl","above","below","before","after","getAlignmentMap","start","end","top","bottom","center","undefined","shouldAlignToCenter","p","a","positionedVertically","alignedVertically","toFloatingUIPlacement","align","position","alignment","computedPosition","computedAlignment"],"sources":["../../src/utils/toFloatingUIPlacement.ts"],"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"],"mappings":"AAMA,MAAMA,cAAA,GAAkBC,GAAA,KAAwD;EAC9EC,KAAA,EAAO;EACPC,KAAA,EAAO;EACPC,MAAA,EAAQH,GAAA,GAAM,UAAU,MAAM;EAC9BI,KAAA,EAAOJ,GAAA,GAAM,SAAS;AACxB;AAEA;AACA;AACA,MAAMK,eAAA,GAAkBA,CAAA,MAAsD;EAC5EC,KAAA,EAAO;EACPC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,MAAA,EAAQ;EACRC,MAAA,EAAQC;AACV;AAEA,MAAMC,mBAAA,GAAsBA,CAACC,CAAA,EAAcC,CAAA,KAA2B;EACpE,MAAMC,oBAAA,GAAuBF,CAAA,KAAM,WAAWA,CAAA,KAAM;EACpD,MAAMG,iBAAA,GAAoBF,CAAA,KAAM,SAASA,CAAA,KAAM;EAE/C,OAAOC,oBAAC,IAAwBC,iBAAA,IAAuB,CAACD,oBAAA,IAAwB,CAACC,iBAAA;AACnF;AAEA;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAACC,KAAA,EAAmBC,QAAA,EAAqBnB,GAAA,KAAyC;EACrH,MAAMoB,SAAA,GAAYR,mBAAA,CAAoBO,QAAA,EAAUD,KAAA,IAAS,WAAWA,KAAK;EAEzE,MAAMG,gBAAA,GAAmBF,QAAA,IAAYpB,cAAA,CAAeC,GAAA,CAAI,CAACmB,QAAA,CAAS;EAClE,MAAMG,iBAAA,GAAoBF,SAAA,IAAaf,eAAA,EAAiB,CAACe,SAAA,CAAU;EAEnE,IAAIC,gBAAA,IAAoBC,iBAAA,EAAmB;IACzC,OAAQ,GAAED,gBAAiB,IAAGC,iBAAkB,EAAC;EACnD;EAEA,OAAOD,gBAAA;AACT"}
@@ -0,0 +1,22 @@
1
+ import { isHTMLElement } from '@fluentui/react-utilities';
2
+ import { getScrollParent } from './getScrollParent';
3
+ /**
4
+ * Toggles event listeners for scroll parent.
5
+ * Cleans up the event listeners for the previous element and adds them for the new scroll parent.
6
+ * @param next Next element
7
+ * @param prev Previous element
8
+ */
9
+ export function toggleScrollListener(next, prev, handler) {
10
+ if (next === prev) {
11
+ return;
12
+ }
13
+ if (isHTMLElement(prev)) {
14
+ const prevScrollParent = getScrollParent(prev);
15
+ prevScrollParent.removeEventListener('scroll', handler);
16
+ }
17
+ if (isHTMLElement(next)) {
18
+ const scrollParent = getScrollParent(next);
19
+ scrollParent.addEventListener('scroll', handler);
20
+ }
21
+ }
22
+ //# sourceMappingURL=toggleScrollListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isHTMLElement","getScrollParent","toggleScrollListener","next","prev","handler","prevScrollParent","removeEventListener","scrollParent","addEventListener"],"sources":["../../src/utils/toggleScrollListener.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport 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 (isHTMLElement(prev)) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener('scroll', handler);\n }\n if (isHTMLElement(next)) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener('scroll', handler);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ;AAE9B,SAASC,eAAe,QAAQ;AAEhC;;;;;;AAMA,OAAO,SAASC,qBACdC,IAAoD,EACpDC,IAAoD,EACpDC,OAAsB,EACtB;EACA,IAAIF,IAAA,KAASC,IAAA,EAAM;IACjB;EACF;EAEA,IAAIJ,aAAA,CAAcI,IAAA,GAAO;IACvB,MAAME,gBAAA,GAAmBL,eAAA,CAAgBG,IAAA;IACzCE,gBAAA,CAAiBC,mBAAmB,CAAC,UAAUF,OAAA;EACjD;EACA,IAAIL,aAAA,CAAcG,IAAA,GAAO;IACvB,MAAMK,YAAA,GAAeP,eAAA,CAAgBE,IAAA;IACrCK,YAAA,CAAaC,gBAAgB,CAAC,UAAUJ,OAAA;EAC1C;AACF"}
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
3
+ /**
4
+ * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
5
+ * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
6
+ * React.useState(), but it will cause re-renders always.
7
+ *
8
+ * https://reactjs.org/docs/hooks-reference.html#useref
9
+ * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
10
+ *
11
+ * @param initialValue - initial ref value
12
+ * @param callback - a callback to run when value changes
13
+ * @param skipInitialResolve - a flag to skip an initial ref report
14
+ *
15
+ * @example
16
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
17
+ * ref.current = 1;
18
+ * // prints 0 -> 1
19
+ */
20
+ export function useCallbackRef(initialValue, callback, skipInitialResolve) {
21
+ const isFirst = React.useRef(true);
22
+ const [ref] = React.useState(() => ({
23
+ // value
24
+ value: initialValue,
25
+ // last callback
26
+ callback,
27
+ // "memoized" public interface
28
+ facade: {
29
+ get current() {
30
+ return ref.value;
31
+ },
32
+ set current(value) {
33
+ const last = ref.value;
34
+ if (last !== value) {
35
+ ref.value = value;
36
+ if (skipInitialResolve && isFirst.current) {
37
+ return;
38
+ }
39
+ ref.callback(value, last);
40
+ }
41
+ }
42
+ }
43
+ }));
44
+ useIsomorphicLayoutEffect(() => {
45
+ isFirst.current = false;
46
+ }, []);
47
+ // update callback
48
+ ref.callback = callback;
49
+ return ref.facade;
50
+ }
51
+ //# sourceMappingURL=useCallbackRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useIsomorphicLayoutEffect","useCallbackRef","initialValue","callback","skipInitialResolve","isFirst","useRef","ref","useState","value","facade","current","last"],"sources":["../../src/utils/useCallbackRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n * @param skipInitialResolve - a flag to skip an initial ref report\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n skipInitialResolve?: boolean,\n): React.MutableRefObject<T | null> {\n const isFirst = React.useRef(true);\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n\n ref.callback(value, last);\n }\n },\n },\n }));\n\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,yBAAyB,QAAQ;AAE1C;;;;;;;;;;;;;;;;;AAiBA,OAAO,SAASC,eACdC,YAAsB,EACtBC,QAA2D,EAC3DC,kBAA4B,EACM;EAClC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,MAAM,CAAC,IAAI;EACjC,MAAM,CAACC,GAAA,CAAI,GAAGR,KAAA,CAAMS,QAAQ,CAAC,OAAO;IAClC;IACAC,KAAA,EAAOP,YAAA;IACP;IACAC,QAAA;IACA;IACAO,MAAA,EAAQ;MACN,IAAIC,QAAA,EAAU;QACZ,OAAOJ,GAAA,CAAIE,KAAK;MAClB;MACA,IAAIE,QAAQF,KAAA,EAAO;QACjB,MAAMG,IAAA,GAAOL,GAAA,CAAIE,KAAK;QAEtB,IAAIG,IAAA,KAASH,KAAA,EAAO;UAClBF,GAAA,CAAIE,KAAK,GAAGA,KAAA;UAEZ,IAAIL,kBAAA,IAAsBC,OAAA,CAAQM,OAAO,EAAE;YACzC;UACF;UAEAJ,GAAA,CAAIJ,QAAQ,CAACM,KAAA,EAAOG,IAAA;QACtB;MACF;IACF;EACF;EAEAZ,yBAAA,CAA0B,MAAM;IAC9BK,OAAA,CAAQM,OAAO,GAAG,KAAK;EACzB,GAAG,EAAE;EAEL;EACAJ,GAAA,CAAIJ,QAAQ,GAAGA,QAAA;EAEf,OAAOI,GAAA,CAAIG,MAAM;AACnB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Writes all DOM element updates after position is computed
3
+ */export function writeArrowUpdates(options) {
4
+ const {
5
+ arrow,
6
+ middlewareData
7
+ } = options;
8
+ if (!middlewareData.arrow || !arrow) {
9
+ return;
10
+ }
11
+ const {
12
+ x: arrowX,
13
+ y: arrowY
14
+ } = middlewareData.arrow;
15
+ Object.assign(arrow.style, {
16
+ left: `${arrowX}px`,
17
+ top: `${arrowY}px`
18
+ });
19
+ }
20
+ //# sourceMappingURL=writeArrowUpdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","top"],"sources":["../../src/utils/writeArrowUpdates.ts"],"sourcesContent":["import { MiddlewareData } from '@floating-ui/dom';\n\n/**\n * Writes all DOM element updates after position is computed\n */\nexport function 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"],"mappings":"AAEA;;GAGA,OAAO,SAASA,kBAAkBC,OAAsE,EAAE;EACxG,MAAM;IAAEC,KAAA;IAAOC;EAAc,CAAE,GAAGF,OAAA;EAClC,IAAI,CAACE,cAAA,CAAeD,KAAK,IAAI,CAACA,KAAA,EAAO;IACnC;EACF;EAEA,MAAM;IAAEE,CAAA,EAAGC,MAAA;IAAQC,CAAA,EAAGC;EAAM,CAAE,GAAGJ,cAAA,CAAeD,KAAK;EAErDM,MAAA,CAAOC,MAAM,CAACP,KAAA,CAAMQ,KAAK,EAAE;IACzBC,IAAA,EAAO,GAAEN,MAAO,IAAG;IACnBO,GAAA,EAAM,GAAEL,MAAO;EACjB;AACF"}
@@ -0,0 +1,43 @@
1
+ import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INTERSECTING, DATA_POSITIONING_PLACEMENT } from '../constants';
2
+ /**
3
+ * Writes all container element position updates after the position is computed
4
+ */
5
+ export function writeContainerUpdates(options) {
6
+ var _middlewareData_hide, _middlewareData_hide1, _container_ownerDocument_defaultView;
7
+ const {
8
+ container,
9
+ placement,
10
+ middlewareData,
11
+ strategy,
12
+ lowPPI,
13
+ coordinates
14
+ } = options;
15
+ if (!container) {
16
+ return;
17
+ }
18
+ container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);
19
+ container.removeAttribute(DATA_POSITIONING_INTERSECTING);
20
+ if (middlewareData.intersectionObserver.intersecting) {
21
+ container.setAttribute(DATA_POSITIONING_INTERSECTING, '');
22
+ }
23
+ container.removeAttribute(DATA_POSITIONING_ESCAPED);
24
+ if ((_middlewareData_hide = middlewareData.hide) === null || _middlewareData_hide === void 0 ? void 0 : _middlewareData_hide.escaped) {
25
+ container.setAttribute(DATA_POSITIONING_ESCAPED, '');
26
+ }
27
+ container.removeAttribute(DATA_POSITIONING_HIDDEN);
28
+ if ((_middlewareData_hide1 = middlewareData.hide) === null || _middlewareData_hide1 === void 0 ? void 0 : _middlewareData_hide1.referenceHidden) {
29
+ container.setAttribute(DATA_POSITIONING_HIDDEN, '');
30
+ }
31
+ // Round so that the coordinates land on device pixels.
32
+ // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
33
+ // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
34
+ // See https://github.com/microsoft/fluentui/issues/26764 for more info.
35
+ const devicePixelRatio = ((_container_ownerDocument_defaultView = container.ownerDocument.defaultView) === null || _container_ownerDocument_defaultView === void 0 ? void 0 : _container_ownerDocument_defaultView.devicePixelRatio) || 1;
36
+ const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
37
+ const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
38
+ Object.assign(container.style, {
39
+ transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
40
+ position: strategy
41
+ });
42
+ }
43
+ //# sourceMappingURL=writeContainerupdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","_middlewareData_hide","_middlewareData_hide1","_container_ownerDocument_defaultView","container","placement","middlewareData","strategy","lowPPI","coordinates","setAttribute","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","transform","position"],"sources":["../../src/utils/writeContainerupdates.ts"],"sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function 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 { container, placement, middlewareData, strategy, lowPPI, coordinates } = 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 // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\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"],"mappings":"AACA,SACEA,wBAAwB,EACxBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,0BAA0B,QACrB;AAEP;;;AAGA,OAAO,SAASC,sBAAsBC,OAYrC,EAAE;MAYGC,oBAAA,EAKAC,qBAAA,EAQqBC,oCAAA;EAxBzB,MAAM;IAAEC,SAAA;IAAWC,SAAA;IAAWC,cAAA;IAAgBC,QAAA;IAAUC,MAAA;IAAQC;EAAW,CAAE,GAAGT,OAAA;EAChF,IAAI,CAACI,SAAA,EAAW;IACd;EACF;EACAA,SAAA,CAAUM,YAAY,CAACZ,0BAAA,EAA4BO,SAAA;EACnDD,SAAA,CAAUO,eAAe,CAACd,6BAAA;EAC1B,IAAIS,cAAA,CAAeM,oBAAoB,CAACC,YAAY,EAAE;IACpDT,SAAA,CAAUM,YAAY,CAACb,6BAAA,EAA+B;EACxD;EAEAO,SAAA,CAAUO,eAAe,CAAChB,wBAAA;EAC1B,IAAI,CAAAM,oBAAA,GAAAK,cAAA,CAAeQ,IAAI,cAAnBb,oBAAA,uBAAAA,oBAAA,CAAqBc,OAAO,EAAE;IAChCX,SAAA,CAAUM,YAAY,CAACf,wBAAA,EAA0B;EACnD;EAEAS,SAAA,CAAUO,eAAe,CAACf,uBAAA;EAC1B,IAAI,CAAAM,qBAAA,GAAAI,cAAA,CAAeQ,IAAI,cAAnBZ,qBAAA,uBAAAA,qBAAA,CAAqBc,eAAe,EAAE;IACxCZ,SAAA,CAAUM,YAAY,CAACd,uBAAA,EAAyB;EAClD;EAEA;EACA;EACA;EACA;EACA,MAAMqB,gBAAA,GAAmB,EAAAd,oCAAA,GAAAC,SAAA,CAAUc,aAAa,CAACC,WAAW,cAAnChB,oCAAA,uBAAAA,oCAAA,CAAqCc,gBAAgB,KAAI;EAClF,MAAMG,CAAA,GAAIC,IAAA,CAAKC,KAAK,CAACb,WAAA,CAAYW,CAAC,GAAGH,gBAAA,IAAoBA,gBAAA;EACzD,MAAMM,CAAA,GAAIF,IAAA,CAAKC,KAAK,CAACb,WAAA,CAAYc,CAAC,GAAGN,gBAAA,IAAoBA,gBAAA;EAEzDO,MAAA,CAAOC,MAAM,CAACrB,SAAA,CAAUsB,KAAK,EAAE;IAC7BC,SAAA,EAAWnB,MAAA,GAAU,aAAYY,CAAE,OAAMG,CAAE,KAAI,GAAI,eAAcH,CAAE,OAAMG,CAAE,QAAO;IAClFK,QAAA,EAAUrB;EACZ;AACF"}