@fluentui/react-positioning 0.0.0-nightly-20221227-0422.1 → 0.0.0-nightly-20221229-0425.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.
- package/CHANGELOG.json +9 -9
- package/CHANGELOG.md +7 -7
- package/lib/createArrowStyles.js +0 -2
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js +4 -17
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createVirtualElementFromClick.js +0 -2
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/middleware/coverTarget.js +0 -5
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js +2 -1
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +0 -3
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +0 -1
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +2 -2
- package/lib/middleware/shift.js.map +1 -1
- package/lib/usePositioning.js +12 -24
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js +0 -7
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +0 -1
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +2 -7
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +0 -6
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js +0 -3
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +0 -4
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +6 -18
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +2 -7
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +2 -7
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js +0 -2
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +2 -8
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js +0 -3
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js +2 -8
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +0 -2
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +0 -10
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +0 -7
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +4 -21
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js +0 -4
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +0 -10
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +0 -8
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +2 -5
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +0 -7
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +0 -3
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +0 -7
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +0 -5
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +2 -6
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +12 -33
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +0 -11
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +0 -3
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +2 -9
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +0 -9
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +0 -6
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +0 -5
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +6 -23
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +5 -12
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -15
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +2 -9
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +0 -2
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +2 -6
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +2 -10
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +0 -6
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +2 -12
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +0 -4
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +0 -13
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +4 -4
@@ -4,34 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getBoundary = void 0;
|
7
|
-
|
8
7
|
const getScrollParent_1 = /*#__PURE__*/require("./getScrollParent");
|
9
8
|
/**
|
10
9
|
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
11
10
|
*/
|
12
|
-
|
13
|
-
|
14
11
|
function getBoundary(element, boundary) {
|
15
12
|
if (boundary === 'window') {
|
16
13
|
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
17
14
|
}
|
18
|
-
|
19
15
|
if (boundary === 'clippingParents') {
|
20
16
|
return 'clippingAncestors';
|
21
17
|
}
|
22
|
-
|
23
18
|
if (boundary === 'scrollParent') {
|
24
19
|
let boundariesNode = getScrollParent_1.getScrollParent(element);
|
25
|
-
|
26
20
|
if (boundariesNode.nodeName === 'BODY') {
|
27
21
|
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
28
22
|
}
|
29
|
-
|
30
23
|
return boundariesNode;
|
31
24
|
}
|
32
|
-
|
33
25
|
return boundary;
|
34
26
|
}
|
35
|
-
|
36
27
|
exports.getBoundary = getBoundary;
|
37
28
|
//# sourceMappingURL=getBoundary.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AAGA;;;AAGA,SAAgBA,WAAW,CAACC,OAA2B,EAAEC,QAAmB;EAC1E,IAAIA,QAAQ,KAAK,QAAQ,EAAE;IACzB,OAAOD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,aAAa,CAAEC,eAAe;;EAGhD,IAAIF,QAAQ,KAAK,iBAAiB,EAAE;IAClC,OAAO,mBAAmB;;EAG5B,IAAIA,QAAQ,KAAK,cAAc,EAAE;IAC/B,IAAIG,cAAc,GAA4BC,iCAAe,CAACL,OAAO,CAAC;IAEtE,IAAII,cAAc,CAACE,QAAQ,KAAK,MAAM,EAAE;MACtCF,cAAc,GAAGJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,aAAa,CAAEC,eAAe;;IAG1D,OAAOC,cAAc;;EAGvB,OAAOH,QAAQ;AACjB;AApBAM","names":["getBoundary","element","boundary","ownerDocument","documentElement","boundariesNode","getScrollParent_1","nodeName","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getBoundary.ts"],"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"]}
|
@@ -4,24 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getFloatingUIOffset = void 0;
|
7
|
-
|
8
7
|
const fromFloatingUIPlacement_1 = /*#__PURE__*/require("./fromFloatingUIPlacement");
|
9
8
|
/**
|
10
9
|
* Shim to transform offset values from this library to Floating UI
|
11
10
|
* @param rawOffset Offset from this library
|
12
11
|
* @returns An offset value compatible with Floating UI
|
13
12
|
*/
|
14
|
-
|
15
|
-
|
16
13
|
function getFloatingUIOffset(rawOffset) {
|
17
14
|
if (!rawOffset) {
|
18
15
|
return rawOffset;
|
19
16
|
}
|
20
|
-
|
21
17
|
if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
|
22
18
|
return rawOffset;
|
23
19
|
}
|
24
|
-
|
25
20
|
return ({
|
26
21
|
rects: {
|
27
22
|
floating,
|
@@ -41,6 +36,5 @@ function getFloatingUIOffset(rawOffset) {
|
|
41
36
|
});
|
42
37
|
};
|
43
38
|
}
|
44
|
-
|
45
39
|
exports.getFloatingUIOffset = getFloatingUIOffset;
|
46
40
|
//# sourceMappingURL=getFloatingUIOffset.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AAgCA;;;;;AAKA,SAAgBA,mBAAmB,CACjCC,SAA6B;EAE7B,IAAI,CAACA,SAAS,EAAE;IACd,OAAOA,SAAS;;EAGlB,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IAClE,OAAOA,SAAS;;EAGlB,OAAO,CAAC;IAAEC,KAAK,EAAE;MAAEC,QAAQ;MAAEC;IAAS,CAAE;IAAEC;EAAS,CAAE,KAAI;IACvD,MAAM;MAAEC,QAAQ;MAAEC;IAAS,CAAE,GAAGC,iDAAuB,CAACH,SAAS,CAAC;IAClE,OAAOJ,SAAS,CAAC;MAAEQ,cAAc,EAAEN,QAAQ;MAAEO,UAAU,EAAEN,SAAS;MAAEE,QAAQ;MAAEC;IAAS,CAAE,CAAC;EAC5F,CAAC;AACH;AAfAI","names":["getFloatingUIOffset","rawOffset","rects","floating","reference","placement","position","alignment","fromFloatingUIPlacement_1","positionedRect","targetRect","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.getReactFiberFromNode = void 0;
|
7
7
|
var WorkTag;
|
8
|
-
|
9
8
|
(function (WorkTag) {
|
10
9
|
WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
|
11
10
|
WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
|
@@ -30,12 +29,10 @@ var WorkTag;
|
|
30
29
|
WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
|
31
30
|
WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
|
32
31
|
})(WorkTag || (WorkTag = {}));
|
33
|
-
|
34
32
|
function getReactFiberFromNode(elm) {
|
35
33
|
if (!elm) {
|
36
34
|
return null;
|
37
35
|
}
|
38
|
-
|
39
36
|
for (const k in elm) {
|
40
37
|
// React 16 uses "__reactInternalInstance$" prefix
|
41
38
|
// React 17 uses "__reactFiber$" prefix
|
@@ -46,9 +43,7 @@ function getReactFiberFromNode(elm) {
|
|
46
43
|
return elm[k];
|
47
44
|
}
|
48
45
|
}
|
49
|
-
|
50
46
|
throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
|
51
47
|
}
|
52
|
-
|
53
48
|
exports.getReactFiberFromNode = getReactFiberFromNode;
|
54
49
|
//# sourceMappingURL=getReactFiberFromNode.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;;;;AAuEA,IAAK,OAAL;;AAAA,CAAA,UAAK,OAAL,EAAY;EACV,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,mBAAA;EACA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,gBAAA;EACA,OAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,wBAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,CAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;EACA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,iBAAA;EACA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,iBAAA;EACA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,EAAA,CAAA,GAAA,YAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,EAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,mBAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,qBAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,GAAA,EAAA,CAAA,GAAA,0BAAA;EACA,OAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,oBAAA;EACA,OAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,uBAAA;EACA,OAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,sBAAA;EACA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,gBAAA;AACD,CAvBD,EAAK,OAAO,KAAP,OAAO,GAAA,EAAA,CAAZ;;AAsLA,SAAgB,qBAAhB,CAAsC,GAAtC,EAA2D;EACzD,IAAI,CAAC,GAAL,EAAU;IACR,OAAO,IAAP;EACD;;EAED,KAAK,MAAM,CAAX,IAAgB,GAAhB,EAAqB;IACnB;IACA;IACA;IACA,IAAI,CAAC,CAAC,OAAF,CAAU,0BAAV,MAA0C,CAA1C,IAA+C,CAAC,CAAC,OAAF,CAAU,eAAV,MAA+B,CAAlF,EAAqF;MACnF;MACA;MACA,OAAO,GAAG,CAAC,CAAD,CAAV;IACD;EACF;;EAED,MAAM,IAAI,KAAJ,CAAU,yDAAV,CAAN;AACD;;AAjBD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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"],"sourceRoot":""}
|
1
|
+
{"version":3,"mappings":";;;;;;AAuEA,IAAKA,OAuBJ;AAvBD,WAAKA,OAAO;EACVA,+DAAqB;EACrBA,yDAAkB;EAClBA,yEAA0B;EAC1BA,6CAAY;EACZA,iDAAc;EACdA,uDAAiB;EACjBA,6CAAY;EACZA,6CAAY;EACZA,qCAAQ;EACRA,2DAAmB;EACnBA,4DAAoB;EACpBA,kDAAe;EACfA,8CAAa;EACbA,gEAAsB;EACtBA,wDAAkB;EAClBA,oEAAwB;EACxBA,wDAAkB;EAClBA,8EAA6B;EAC7BA,kEAAuB;EACvBA,wEAA0B;EAC1BA,sEAAyB;EACzBA,0DAAmB;AACrB,CAAC,EAvBIA,OAAO,KAAPA,OAAO;AAsLZ,SAAgBC,qBAAqB,CAACC,GAAqB;EACzD,IAAI,CAACA,GAAG,EAAE;IACR,OAAO,IAAI;;EAGb,KAAK,MAAMC,CAAC,IAAID,GAAG,EAAE;IACnB;IACA;IACA;IACA,IAAIC,CAAC,CAACC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAID,CAAC,CAACC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;MACnF;MACA;MACA,OAAOF,GAAG,CAACC,CAAC,CAAC;;;EAIjB,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;AAC5E;AAjBAC","names":["WorkTag","getReactFiberFromNode","elm","k","indexOf","Error","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -9,30 +9,24 @@ exports.hasScrollParent = exports.getScrollParent = exports.getParentNode = void
|
|
9
9
|
* @param node - DOM node.
|
10
10
|
* @returns - parent DOM node.
|
11
11
|
*/
|
12
|
-
|
13
12
|
const getParentNode = node => {
|
14
13
|
if (node.nodeName === 'HTML') {
|
15
14
|
return node;
|
16
|
-
}
|
17
|
-
|
18
|
-
|
15
|
+
}
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
19
17
|
return node.parentNode || node.host;
|
20
18
|
};
|
21
|
-
|
22
19
|
exports.getParentNode = getParentNode;
|
23
20
|
/**
|
24
21
|
* Returns CSS styles of the given node.
|
25
22
|
* @param node - DOM node.
|
26
23
|
* @returns - CSS styles.
|
27
24
|
*/
|
28
|
-
|
29
25
|
const getStyleComputedProperty = node => {
|
30
26
|
var _a;
|
31
|
-
|
32
27
|
if (node.nodeType !== 1) {
|
33
28
|
return {};
|
34
29
|
}
|
35
|
-
|
36
30
|
const window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
37
31
|
return window.getComputedStyle(node, null);
|
38
32
|
};
|
@@ -41,45 +35,34 @@ const getStyleComputedProperty = node => {
|
|
41
35
|
* @param node - DOM node.
|
42
36
|
* @returns - the first scrollable parent.
|
43
37
|
*/
|
44
|
-
|
45
|
-
|
46
38
|
const getScrollParent = node => {
|
47
39
|
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
48
|
-
const parentNode = node && exports.getParentNode(node);
|
49
|
-
|
40
|
+
const parentNode = node && exports.getParentNode(node);
|
41
|
+
// eslint-disable-next-line
|
50
42
|
if (!parentNode) return document.body;
|
51
|
-
|
52
43
|
switch (parentNode.nodeName) {
|
53
44
|
case 'HTML':
|
54
45
|
case 'BODY':
|
55
46
|
return parentNode.ownerDocument.body;
|
56
|
-
|
57
47
|
case '#document':
|
58
48
|
return parentNode.body;
|
59
|
-
}
|
60
|
-
|
61
|
-
|
49
|
+
}
|
50
|
+
// If any of the overflow props is defined for the node then we return it as the parent
|
62
51
|
const {
|
63
52
|
overflow,
|
64
53
|
overflowX,
|
65
54
|
overflowY
|
66
55
|
} = getStyleComputedProperty(parentNode);
|
67
|
-
|
68
56
|
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
69
57
|
return parentNode;
|
70
58
|
}
|
71
|
-
|
72
59
|
return exports.getScrollParent(parentNode);
|
73
60
|
};
|
74
|
-
|
75
61
|
exports.getScrollParent = getScrollParent;
|
76
|
-
|
77
62
|
const hasScrollParent = node => {
|
78
63
|
var _a;
|
79
|
-
|
80
64
|
const scrollParentElement = exports.getScrollParent(node);
|
81
65
|
return scrollParentElement ? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body) : false;
|
82
66
|
};
|
83
|
-
|
84
67
|
exports.hasScrollParent = hasScrollParent;
|
85
68
|
//# sourceMappingURL=getScrollParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;AAKO,MAAMA,aAAa,GAAIC,IAAiB,IAAiB;EAC9D,IAAIA,IAAI,CAACC,QAAQ,KAAK,MAAM,EAAE;IAC5B,OAAOD,IAAI;;EAEb;EACA,OAAOA,IAAI,CAACE,UAAU,IAAKF,IAAY,CAACG,IAAI;AAC9C,CAAC;AANYC,qBAAa;AAQ1B;;;;;AAKA,MAAMC,wBAAwB,GAAIL,IAAiB,IAAkC;;EACnF,IAAIA,IAAI,CAACM,QAAQ,KAAK,CAAC,EAAE;IACvB,OAAO,EAAE;;EAGX,MAAMC,MAAM,GAAG,UAAI,CAACC,aAAa,0CAAEC,WAAW;EAC9C,OAAOF,MAAO,CAACG,gBAAgB,CAACV,IAAI,EAAE,IAAI,CAAC;AAC7C,CAAC;AAED;;;;;AAKO,MAAMW,eAAe,GAAIX,IAAmC,IAAiB;EAClF;EACA,MAAME,UAAU,GAAGF,IAAI,IAAII,qBAAa,CAACJ,IAAmB,CAAC;EAC7D;EACA,IAAI,CAACE,UAAU,EAAE,OAAOU,QAAQ,CAACC,IAAI;EAErC,QAAQX,UAAU,CAACD,QAAQ;IACzB,KAAK,MAAM;IACX,KAAK,MAAM;MACT,OAAOC,UAAU,CAACM,aAAc,CAACK,IAAI;IACvC,KAAK,WAAW;MACd,OAASX,UAAmC,CAACW,IAAI;EAAC;EAGtD;EACA,MAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAS,CAAE,GAAGX,wBAAwB,CAACH,UAAU,CAAC;EAC/E,IAAI,uBAAuB,CAACe,IAAI,CAACH,QAAS,GAAGE,SAAU,GAAGD,SAAS,CAAC,EAAE;IACpE,OAAOb,UAAU;;EAGnB,OAAOE,uBAAe,CAACF,UAAU,CAAC;AACpC,CAAC;AArBYE,uBAAe;AAuBrB,MAAMc,eAAe,GAAIlB,IAAmC,IAAa;;EAC9E,MAAMmB,mBAAmB,GAAgBf,uBAAe,CAACJ,IAAI,CAAC;EAC9D,OAAOmB,mBAAmB,GAAGA,mBAAmB,MAAK,yBAAmB,CAACX,aAAa,0CAAEK,IAAI,IAAG,KAAK;AACtG,CAAC;AAHYT,uBAAe","names":["getParentNode","node","nodeName","parentNode","host","exports","getStyleComputedProperty","nodeType","window","ownerDocument","defaultView","getComputedStyle","getScrollParent","document","body","overflow","overflowX","overflowY","test","hasScrollParent","scrollParentElement"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
"use strict";
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
//
|
2
4
|
// Dev utils to detect if nodes have "autoFocus" props.
|
3
5
|
//
|
4
|
-
|
5
6
|
Object.defineProperty(exports, "__esModule", {
|
6
7
|
value: true
|
7
8
|
});
|
8
9
|
exports.hasAutofocusFilter = void 0;
|
9
|
-
|
10
10
|
const getReactFiberFromNode_1 = /*#__PURE__*/require("./getReactFiberFromNode");
|
11
11
|
/**
|
12
12
|
* Detects if a passed HTML node has "autoFocus" prop on a React's fiber. Is needed as React handles autofocus behavior
|
@@ -14,24 +14,17 @@ const getReactFiberFromNode_1 = /*#__PURE__*/require("./getReactFiberFromNode");
|
|
14
14
|
*
|
15
15
|
* @param node
|
16
16
|
*/
|
17
|
-
|
18
|
-
|
19
17
|
function hasAutofocusProp(node) {
|
20
|
-
var _a;
|
21
|
-
|
22
|
-
|
18
|
+
var _a;
|
19
|
+
// https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
|
23
20
|
const isAutoFocusableElement = node.nodeName === 'BUTTON' || node.nodeName === 'INPUT' || node.nodeName === 'SELECT' || node.nodeName === 'TEXTAREA';
|
24
|
-
|
25
21
|
if (isAutoFocusableElement) {
|
26
22
|
return !!((_a = getReactFiberFromNode_1.getReactFiberFromNode(node)) === null || _a === void 0 ? void 0 : _a.pendingProps.autoFocus);
|
27
23
|
}
|
28
|
-
|
29
24
|
return false;
|
30
25
|
}
|
31
|
-
|
32
26
|
function hasAutofocusFilter(node) {
|
33
27
|
return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
34
28
|
}
|
35
|
-
|
36
29
|
exports.hasAutofocusFilter = hasAutofocusFilter;
|
37
30
|
//# sourceMappingURL=hasAutoFocusFilter.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;AAAA;AACA;AACA;;;;;AAEA;AAEA;;;;;;AAMA,SAASA,gBAAgB,CAACC,IAAU;;EAClC;EACA,MAAMC,sBAAsB,GAC1BD,IAAI,CAACE,QAAQ,KAAK,QAAQ,IAC1BF,IAAI,CAACE,QAAQ,KAAK,OAAO,IACzBF,IAAI,CAACE,QAAQ,KAAK,QAAQ,IAC1BF,IAAI,CAACE,QAAQ,KAAK,UAAU;EAE9B,IAAID,sBAAsB,EAAE;IAC1B,OAAO,CAAC,EAAC,mDAAqB,CAACD,IAAI,CAAC,0CAAEG,YAAY,CAACC,SAAS;;EAG9D,OAAO,KAAK;AACd;AAEA,SAAgBC,kBAAkB,CAACL,IAAU;EAC3C,OAAOD,gBAAgB,CAACC,IAAI,CAAC,GAAGM,UAAU,CAACC,aAAa,GAAGD,UAAU,CAACE,WAAW;AACnF;AAFAC","names":["hasAutofocusProp","node","isAutoFocusableElement","nodeName","pendingProps","autoFocus","hasAutofocusFilter","NodeFilter","FILTER_ACCEPT","FILTER_SKIP","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -3,34 +3,19 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./parseFloatingUIPlacement"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./getBoundary"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./getScrollParent"), exports);
|
16
|
-
|
17
11
|
tslib_1.__exportStar(require("./mergeArrowOffset"), exports);
|
18
|
-
|
19
12
|
tslib_1.__exportStar(require("./toFloatingUIPlacement"), exports);
|
20
|
-
|
21
13
|
tslib_1.__exportStar(require("./fromFloatingUIPlacement"), exports);
|
22
|
-
|
23
14
|
tslib_1.__exportStar(require("./resolvePositioningShorthand"), exports);
|
24
|
-
|
25
15
|
tslib_1.__exportStar(require("./useCallbackRef"), exports);
|
26
|
-
|
27
16
|
tslib_1.__exportStar(require("./debounce"), exports);
|
28
|
-
|
29
17
|
tslib_1.__exportStar(require("./toggleScrollListener"), exports);
|
30
|
-
|
31
18
|
tslib_1.__exportStar(require("./hasAutoFocusFilter"), exports);
|
32
|
-
|
33
19
|
tslib_1.__exportStar(require("./writeArrowUpdates"), exports);
|
34
|
-
|
35
20
|
tslib_1.__exportStar(require("./writeContainerupdates"), exports);
|
36
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/index.ts"],"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';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"]}
|
@@ -13,40 +13,33 @@ exports.mergeArrowOffset = void 0;
|
|
13
13
|
* @param arrowHeight - The height of the arrow in px
|
14
14
|
* @returns User offset augmented with arrow height
|
15
15
|
*/
|
16
|
-
|
17
16
|
function mergeArrowOffset(userOffset, arrowHeight) {
|
18
17
|
if (typeof userOffset === 'number') {
|
19
18
|
return addArrowOffset(userOffset, arrowHeight);
|
20
19
|
}
|
21
|
-
|
22
20
|
if (typeof userOffset === 'object' && userOffset !== null) {
|
23
21
|
return addArrowOffset(userOffset, arrowHeight);
|
24
22
|
}
|
25
|
-
|
26
23
|
if (typeof userOffset === 'function') {
|
27
24
|
return offsetParams => {
|
28
25
|
const offset = userOffset(offsetParams);
|
29
26
|
return addArrowOffset(offset, arrowHeight);
|
30
27
|
};
|
31
28
|
}
|
32
|
-
|
33
29
|
return {
|
34
30
|
mainAxis: arrowHeight
|
35
31
|
};
|
36
32
|
}
|
37
|
-
|
38
33
|
exports.mergeArrowOffset = mergeArrowOffset;
|
39
|
-
|
40
34
|
const addArrowOffset = (offset, arrowHeight) => {
|
41
35
|
var _a;
|
42
|
-
|
43
36
|
if (typeof offset === 'number') {
|
44
37
|
return {
|
45
38
|
mainAxis: offset + arrowHeight
|
46
39
|
};
|
47
40
|
}
|
48
|
-
|
49
|
-
|
41
|
+
return {
|
42
|
+
...offset,
|
50
43
|
mainAxis: ((_a = offset.mainAxis) !== null && _a !== void 0 ? _a : 0) + arrowHeight
|
51
44
|
};
|
52
45
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;;;;AASA,SAAgBA,gBAAgB,CAACC,UAAqC,EAAEC,WAAmB;EACzF,IAAI,OAAOD,UAAU,KAAK,QAAQ,EAAE;IAClC,OAAOE,cAAc,CAACF,UAAU,EAAEC,WAAW,CAAC;;EAGhD,IAAI,OAAOD,UAAU,KAAK,QAAQ,IAAIA,UAAU,KAAK,IAAI,EAAE;IACzD,OAAOE,cAAc,CAACF,UAAU,EAAEC,WAAW,CAAC;;EAGhD,IAAI,OAAOD,UAAU,KAAK,UAAU,EAAE;IACpC,OAAOG,YAAY,IAAG;MACpB,MAAMC,MAAM,GAAGJ,UAAU,CAACG,YAAY,CAAC;MACvC,OAAOD,cAAc,CAACE,MAAM,EAAEH,WAAW,CAAC;IAC5C,CAAC;;EAGH,OAAO;IAAEI,QAAQ,EAAEJ;EAAW,CAAE;AAClC;AAjBAK;AAmBA,MAAMJ,cAAc,GAAG,CAACE,MAA6B,EAAEH,WAAmB,KAAkB;;EAC1F,IAAI,OAAOG,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAO;MAAEC,QAAQ,EAAED,MAAM,GAAGH;IAAW,CAAE;;EAG3C,OAAO;IAAE,GAAGG,MAAM;IAAEC,QAAQ,EAAE,CAAC,YAAM,CAACA,QAAQ,mCAAI,CAAC,IAAIJ;EAAW,CAAE;AACtE,CAAC","names":["mergeArrowOffset","userOffset","arrowHeight","addArrowOffset","offsetParams","offset","mainAxis","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -10,7 +10,6 @@ exports.parseFloatingUIPlacement = void 0;
|
|
10
10
|
*
|
11
11
|
* @returns side and alignment components of the placement
|
12
12
|
*/
|
13
|
-
|
14
13
|
function parseFloatingUIPlacement(placement) {
|
15
14
|
const tokens = placement.split('-');
|
16
15
|
return {
|
@@ -18,6 +17,5 @@ function parseFloatingUIPlacement(placement) {
|
|
18
17
|
alignment: tokens[1]
|
19
18
|
};
|
20
19
|
}
|
21
|
-
|
22
20
|
exports.parseFloatingUIPlacement = parseFloatingUIPlacement;
|
23
21
|
//# sourceMappingURL=parseFloatingUIPlacement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,wBAAwB,CAACC,SAAoB;EAC3D,MAAMC,MAAM,GAAGD,SAAS,CAACE,KAAK,CAAC,GAAG,CAAC;EACnC,OAAO;IACLC,IAAI,EAAEF,MAAM,CAAC,CAAC,CAAS;IACvBG,SAAS,EAAEH,MAAM,CAAC,CAAC;GACpB;AACH;AANAI","names":["parseFloatingUIPlacement","placement","tokens","split","side","alignment","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.resolvePositioningShorthand = void 0;
|
7
|
-
|
6
|
+
exports.resolvePositioningShorthand = void 0;
|
7
|
+
// Look up table for shorthand to avoid parsing strings
|
8
8
|
const shorthandLookup = {
|
9
9
|
above: {
|
10
10
|
position: 'above',
|
@@ -55,18 +55,14 @@ const shorthandLookup = {
|
|
55
55
|
align: 'bottom'
|
56
56
|
}
|
57
57
|
};
|
58
|
-
|
59
58
|
function resolvePositioningShorthand(shorthand) {
|
60
59
|
if (shorthand === undefined || shorthand === null) {
|
61
60
|
return {};
|
62
61
|
}
|
63
|
-
|
64
62
|
if (typeof shorthand === 'string') {
|
65
63
|
return shorthandLookup[shorthand];
|
66
64
|
}
|
67
|
-
|
68
65
|
return shorthand;
|
69
66
|
}
|
70
|
-
|
71
67
|
exports.resolvePositioningShorthand = resolvePositioningShorthand;
|
72
68
|
//# sourceMappingURL=resolvePositioningShorthand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AACA,MAAMA,eAAe,GAAoF;EACvGC,KAAK,EAAE;IAAEC,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,aAAa,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAO,CAAE;EACpD,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChDC,KAAK,EAAE;IAAEF,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,aAAa,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAO,CAAE;EACpD,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChDE,MAAM,EAAE;IAAEH,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC/C,YAAY,EAAE;IAAED,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAK,CAAE;EAClD,eAAe,EAAE;IAAED,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAQ,CAAE;EACxDG,KAAK,EAAE;IAAEJ,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChD,cAAc,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ;CACrD;AAED,SAAgBI,2BAA2B,CACzCC,SAAkD;EAElD,IAAIA,SAAS,KAAKC,SAAS,IAAID,SAAS,KAAK,IAAI,EAAE;IACjD,OAAO,EAAE;;EAGX,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,OAAOR,eAAe,CAACQ,SAAS,CAAC;;EAGnC,OAAOA,SAAuC;AAChD;AAZAE","names":["shorthandLookup","above","position","align","below","before","after","resolvePositioningShorthand","shorthand","undefined","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.toFloatingUIPlacement = void 0;
|
7
|
-
|
8
7
|
const getPositionMap = rtl => ({
|
9
8
|
above: 'top',
|
10
9
|
below: 'bottom',
|
11
10
|
before: rtl ? 'right' : 'left',
|
12
11
|
after: rtl ? 'left' : 'right'
|
13
|
-
});
|
12
|
+
});
|
13
|
+
// Floating UI automatically flips alignment
|
14
14
|
// https://github.com/floating-ui/floating-ui/issues/1563
|
15
|
-
|
16
|
-
|
17
15
|
const getAlignmentMap = () => ({
|
18
16
|
start: 'start',
|
19
17
|
end: 'end',
|
@@ -21,7 +19,6 @@ const getAlignmentMap = () => ({
|
|
21
19
|
bottom: 'end',
|
22
20
|
center: undefined
|
23
21
|
});
|
24
|
-
|
25
22
|
const shouldAlignToCenter = (p, a) => {
|
26
23
|
const positionedVertically = p === 'above' || p === 'below';
|
27
24
|
const alignedVertically = a === 'top' || a === 'bottom';
|
@@ -31,19 +28,14 @@ const shouldAlignToCenter = (p, a) => {
|
|
31
28
|
* Maps internal positioning values to Floating UI placement
|
32
29
|
* @see positioningHelper.test.ts for expected placement values
|
33
30
|
*/
|
34
|
-
|
35
|
-
|
36
31
|
const toFloatingUIPlacement = (align, position, rtl) => {
|
37
32
|
const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
|
38
33
|
const computedPosition = position && getPositionMap(rtl)[position];
|
39
34
|
const computedAlignment = alignment && getAlignmentMap()[alignment];
|
40
|
-
|
41
35
|
if (computedPosition && computedAlignment) {
|
42
36
|
return `${computedPosition}-${computedAlignment}`;
|
43
37
|
}
|
44
|
-
|
45
38
|
return computedPosition;
|
46
39
|
};
|
47
|
-
|
48
40
|
exports.toFloatingUIPlacement = toFloatingUIPlacement;
|
49
41
|
//# sourceMappingURL=toFloatingUIPlacement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAMA,MAAMA,cAAc,GAAIC,GAAa,KAA2C;EAC9EC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,QAAQ;EACfC,MAAM,EAAEH,GAAG,GAAG,OAAO,GAAG,MAAM;EAC9BI,KAAK,EAAEJ,GAAG,GAAG,MAAM,GAAG;CACvB,CAAC;AAEF;AACA;AACA,MAAMK,eAAe,GAAG,OAAsD;EAC5EC,KAAK,EAAE,OAAO;EACdC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,OAAO;EACZC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAEC;CACT,CAAC;AAEF,MAAMC,mBAAmB,GAAG,CAACC,CAAY,EAAEC,CAAa,KAAa;EACnE,MAAMC,oBAAoB,GAAGF,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,OAAO;EAC3D,MAAMG,iBAAiB,GAAGF,CAAC,KAAK,KAAK,IAAIA,CAAC,KAAK,QAAQ;EAEvD,OAAQC,oBAAoB,IAAIC,iBAAiB,IAAM,CAACD,oBAAoB,IAAI,CAACC,iBAAkB;AACrG,CAAC;AAED;;;;AAIO,MAAMC,qBAAqB,GAAG,CAACC,KAAiB,EAAEC,QAAmB,EAAEnB,GAAa,KAA2B;EACpH,MAAMoB,SAAS,GAAGR,mBAAmB,CAACO,QAAQ,EAAED,KAAK,CAAC,GAAG,QAAQ,GAAGA,KAAK;EAEzE,MAAMG,gBAAgB,GAAGF,QAAQ,IAAIpB,cAAc,CAACC,GAAG,CAAC,CAACmB,QAAQ,CAAC;EAClE,MAAMG,iBAAiB,GAAGF,SAAS,IAAIf,eAAe,EAAE,CAACe,SAAS,CAAC;EAEnE,IAAIC,gBAAgB,IAAIC,iBAAiB,EAAE;IACzC,OAAO,GAAGD,gBAAgB,IAAIC,iBAAiB,EAAe;;EAGhE,OAAOD,gBAAgB;AACzB,CAAC;AAXYE,6BAAqB","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","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/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"]}
|