@fluentui/react-positioning 9.5.14 → 9.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +77 -1
- package/CHANGELOG.md +33 -2
- package/dist/index.d.ts +14 -2
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js +47 -55
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js +95 -108
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createSlideStyles.js +59 -0
- package/lib/createSlideStyles.js.map +1 -0
- package/lib/createVirtualElementFromClick.js +18 -19
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/middleware/coverTarget.js +26 -32
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js +22 -32
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/index.js +0 -1
- package/lib/middleware/index.js.map +1 -1
- package/lib/middleware/intersecting.js +16 -17
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +25 -34
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +3 -5
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +21 -30
- package/lib/middleware/shift.js.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js +188 -154
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js +24 -23
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +13 -14
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +23 -28
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +14 -16
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js +16 -27
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +36 -37
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +35 -42
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +9 -11
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +24 -25
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +6 -7
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js +55 -56
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPadding.js +16 -21
- package/lib/utils/toFloatingUIPadding.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +25 -27
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js +12 -14
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js +30 -32
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +10 -17
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +39 -39
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js +1 -3
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +1 -3
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +4 -5
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createSlideStyles.js +63 -0
- package/lib-commonjs/createSlideStyles.js.map +1 -0
- package/lib-commonjs/createVirtualElementFromClick.js +1 -3
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +2 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +1 -3
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +1 -3
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +0 -3
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +1 -3
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +1 -3
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +1 -3
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +1 -3
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js +0 -3
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +6 -6
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +1 -3
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +1 -3
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +1 -3
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +1 -3
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +1 -3
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +1 -3
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +1 -3
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +1 -3
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +1 -3
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPadding.js +1 -3
- package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +1 -3
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +1 -3
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +1 -3
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +12 -5
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +5 -5
package/lib/utils/getBoundary.js
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
import { getScrollParent } from './getScrollParent';
|
2
2
|
/**
|
3
3
|
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
4
|
-
*/
|
5
|
-
|
6
|
-
|
7
|
-
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
8
|
-
}
|
9
|
-
if (boundary === 'clippingParents') {
|
10
|
-
return 'clippingAncestors';
|
11
|
-
}
|
12
|
-
if (boundary === 'scrollParent') {
|
13
|
-
let boundariesNode = getScrollParent(element);
|
14
|
-
if (boundariesNode.nodeName === 'BODY') {
|
15
|
-
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
4
|
+
*/ export function getBoundary(element, boundary) {
|
5
|
+
if (boundary === 'window') {
|
6
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
16
7
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
if (boundary === 'clippingParents') {
|
9
|
+
return 'clippingAncestors';
|
10
|
+
}
|
11
|
+
if (boundary === 'scrollParent') {
|
12
|
+
let boundariesNode = getScrollParent(element);
|
13
|
+
if (boundariesNode.nodeName === 'BODY') {
|
14
|
+
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
15
|
+
}
|
16
|
+
return boundariesNode;
|
17
|
+
}
|
18
|
+
return boundary;
|
20
19
|
}
|
21
|
-
//# sourceMappingURL=getBoundary.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["getScrollParent","getBoundary","element","boundary","ownerDocument","documentElement","boundariesNode","nodeName"],"mappings":"AAEA,SAASA,eAAe,QAAQ,oBAAoB;AAGpD;;CAEC,GACD,OAAO,SAASC,YAAYC,OAA2B,EAAEC,QAAmB,EAAkC;IAC5G,IAAIA,aAAa,UAAU;QACzB,OAAOD,oBAAAA,qBAAAA,KAAAA,IAAAA,QAASE,aAAa,CAAEC,eAAe;IAChD,CAAC;IAED,IAAIF,aAAa,mBAAmB;QAClC,OAAO;IACT,CAAC;IAED,IAAIA,aAAa,gBAAgB;QAC/B,IAAIG,iBAA0CN,gBAAgBE;QAE9D,IAAII,eAAeC,QAAQ,KAAK,QAAQ;YACtCD,iBAAiBJ,oBAAAA,qBAAAA,KAAAA,IAAAA,QAASE,aAAa,CAAEC,eAAe;QAC1D,CAAC;QAED,OAAOC;IACT,CAAC;IAED,OAAOH;AACT,CAAC"}
|
@@ -3,31 +3,20 @@ import { fromFloatingUIPlacement } from './fromFloatingUIPlacement';
|
|
3
3
|
* Shim to transform offset values from this library to Floating UI
|
4
4
|
* @param rawOffset Offset from this library
|
5
5
|
* @returns An offset value compatible with Floating UI
|
6
|
-
*/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
position,
|
23
|
-
alignment
|
24
|
-
} = fromFloatingUIPlacement(placement);
|
25
|
-
return rawOffset({
|
26
|
-
positionedRect: floating,
|
27
|
-
targetRect: reference,
|
28
|
-
position,
|
29
|
-
alignment
|
30
|
-
});
|
31
|
-
};
|
6
|
+
*/ export function getFloatingUIOffset(rawOffset) {
|
7
|
+
if (!rawOffset) {
|
8
|
+
return rawOffset;
|
9
|
+
}
|
10
|
+
if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
|
11
|
+
return rawOffset;
|
12
|
+
}
|
13
|
+
return ({ rects: { floating , reference } , placement })=>{
|
14
|
+
const { position , alignment } = fromFloatingUIPlacement(placement);
|
15
|
+
return rawOffset({
|
16
|
+
positionedRect: floating,
|
17
|
+
targetRect: reference,
|
18
|
+
position,
|
19
|
+
alignment
|
20
|
+
});
|
21
|
+
};
|
32
22
|
}
|
33
|
-
//# sourceMappingURL=getFloatingUIOffset.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["fromFloatingUIPlacement","getFloatingUIOffset","rawOffset","rects","floating","reference","placement","position","alignment","positionedRect","targetRect"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,4BAA4B;AAgCpE;;;;CAIC,GACD,OAAO,SAASC,oBACdC,SAA6B,EACiC;IAC9D,IAAI,CAACA,WAAW;QACd,OAAOA;IACT,CAAC;IAED,IAAI,OAAOA,cAAc,YAAY,OAAOA,cAAc,UAAU;QAClE,OAAOA;IACT,CAAC;IAED,OAAO,CAAC,EAAEC,OAAO,EAAEC,SAAQ,EAAEC,UAAS,EAAE,CAAA,EAAEC,UAAS,EAAE,GAAK;QACxD,MAAM,EAAEC,SAAQ,EAAEC,UAAS,EAAE,GAAGR,wBAAwBM;QACxD,OAAOJ,UAAU;YAAEO,gBAAgBL;YAAUM,YAAYL;YAAWE;YAAUC;QAAU;IAC1F;AACF,CAAC"}
|
@@ -1,43 +1,42 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
var WorkTag;
|
3
|
-
(function
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
26
|
})(WorkTag || (WorkTag = {}));
|
27
27
|
export function getReactFiberFromNode(elm) {
|
28
|
-
|
29
|
-
|
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];
|
28
|
+
if (!elm) {
|
29
|
+
return null;
|
39
30
|
}
|
40
|
-
|
41
|
-
|
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
42
|
}
|
43
|
-
//# sourceMappingURL=getReactFiberFromNode.js.map
|
@@ -1 +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"}
|
1
|
+
{"version":3,"sources":["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"],"names":["React","WorkTag","FunctionComponent","ClassComponent","IndeterminateComponent","HostRoot","HostPortal","HostComponent","HostText","Fragment","Mode","ContextConsumer","ContextProvider","ForwardRef","Profiler","SuspenseComponent","MemoComponent","SimpleMemoComponent","LazyComponent","IncompleteClassComponent","DehydratedFragment","SuspenseListComponent","FundamentalComponent","ScopeComponent","getReactFiberFromNode","elm","k","indexOf","Error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;IAuE/B;UAAKC,OAAO;IAAPA,QAAAA,QACHC,uBAAoB,KAApBA;IADGD,QAAAA,QAEHE,oBAAiB,KAAjBA;IAFGF,QAAAA,QAGHG,4BAAyB,KAAzBA;IAHGH,QAAAA,QAIHI,cAAW,KAAXA;IAJGJ,QAAAA,QAKHK,gBAAa,KAAbA;IALGL,QAAAA,QAMHM,mBAAgB,KAAhBA;IANGN,QAAAA,QAOHO,cAAW,KAAXA;IAPGP,QAAAA,QAQHQ,cAAW,KAAXA;IARGR,QAAAA,QASHS,UAAO,KAAPA;IATGT,QAAAA,QAUHU,qBAAkB,KAAlBA;IAVGV,QAAAA,QAWHW,qBAAkB,MAAlBA;IAXGX,QAAAA,QAYHY,gBAAa,MAAbA;IAZGZ,QAAAA,QAaHa,cAAW,MAAXA;IAbGb,QAAAA,QAcHc,uBAAoB,MAApBA;IAdGd,QAAAA,QAeHe,mBAAgB,MAAhBA;IAfGf,QAAAA,QAgBHgB,yBAAsB,MAAtBA;IAhBGhB,QAAAA,QAiBHiB,mBAAgB,MAAhBA;IAjBGjB,QAAAA,QAkBHkB,8BAA2B,MAA3BA;IAlBGlB,QAAAA,QAmBHmB,wBAAqB,MAArBA;IAnBGnB,QAAAA,QAoBHoB,2BAAwB,MAAxBA;IApBGpB,QAAAA,QAqBHqB,0BAAuB,MAAvBA;IArBGrB,QAAAA,QAsBHsB,oBAAiB,MAAjBA;GAtBGtB,YAAAA;AAsLL,OAAO,SAASuB,sBAAsBC,GAAqB,EAAgB;IACzE,IAAI,CAACA,KAAK;QACR,OAAO,IAAI;IACb,CAAC;IAED,IAAK,MAAMC,KAAKD,IAAK;QACnB,kDAAkD;QAClD,uCAAuC;QACvC,+CAA+C;QAC/C,IAAIC,EAAEC,OAAO,CAAC,gCAAgC,KAAKD,EAAEC,OAAO,CAAC,qBAAqB,GAAG;YACnF,6DAA6D;YAC7D,aAAa;YACb,OAAOF,GAAG,CAACC,EAAE;QACf,CAAC;IACH;IAEA,MAAM,IAAIE,MAAM,2DAA2D;AAC7E,CAAC"}
|
@@ -2,57 +2,50 @@
|
|
2
2
|
* Returns the parent node or the host of the node argument.
|
3
3
|
* @param node - DOM node.
|
4
4
|
* @returns - parent DOM node.
|
5
|
-
*/export const getParentNode = node
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
11
|
};
|
12
12
|
/**
|
13
13
|
* Returns CSS styles of the given node.
|
14
14
|
* @param node - DOM node.
|
15
15
|
* @returns - CSS styles.
|
16
|
-
*/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
return window.getComputedStyle(node, null);
|
16
|
+
*/ const getStyleComputedProperty = (node)=>{
|
17
|
+
var _node_ownerDocument;
|
18
|
+
if (node.nodeType !== 1) {
|
19
|
+
return {};
|
20
|
+
}
|
21
|
+
const window = (_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.defaultView;
|
22
|
+
return window.getComputedStyle(node, null);
|
24
23
|
};
|
25
24
|
/**
|
26
25
|
* Returns the first scrollable parent of the given element.
|
27
26
|
* @param node - DOM node.
|
28
27
|
* @returns - the first scrollable parent.
|
29
|
-
*/
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
} = getStyleComputedProperty(parentNode);
|
48
|
-
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
49
|
-
return parentNode;
|
50
|
-
}
|
51
|
-
return getScrollParent(parentNode);
|
28
|
+
*/ export const getScrollParent = (node)=>{
|
29
|
+
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
30
|
+
const parentNode = node && getParentNode(node);
|
31
|
+
// eslint-disable-next-line
|
32
|
+
if (!parentNode) return document.body;
|
33
|
+
switch(parentNode.nodeName){
|
34
|
+
case 'HTML':
|
35
|
+
case 'BODY':
|
36
|
+
return parentNode.ownerDocument.body;
|
37
|
+
case '#document':
|
38
|
+
return parentNode.body;
|
39
|
+
}
|
40
|
+
// If any of the overflow props is defined for the node then we return it as the parent
|
41
|
+
const { overflow , overflowX , overflowY } = getStyleComputedProperty(parentNode);
|
42
|
+
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
43
|
+
return parentNode;
|
44
|
+
}
|
45
|
+
return getScrollParent(parentNode);
|
52
46
|
};
|
53
|
-
export const hasScrollParent = node
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
export const hasScrollParent = (node)=>{
|
48
|
+
var _scrollParentElement_ownerDocument;
|
49
|
+
const scrollParentElement = getScrollParent(node);
|
50
|
+
return scrollParentElement ? scrollParentElement !== ((_scrollParentElement_ownerDocument = scrollParentElement.ownerDocument) === null || _scrollParentElement_ownerDocument === void 0 ? void 0 : _scrollParentElement_ownerDocument.body) : false;
|
57
51
|
};
|
58
|
-
//# sourceMappingURL=getScrollParent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["getParentNode","node","nodeName","parentNode","host","getStyleComputedProperty","nodeType","window","ownerDocument","defaultView","getComputedStyle","getScrollParent","document","body","overflow","overflowX","overflowY","test","hasScrollParent","scrollParentElement"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,MAAMA,gBAAgB,CAACC,OAAmC;IAC/D,IAAIA,KAAKC,QAAQ,KAAK,QAAQ;QAC5B,OAAOD;IACT,CAAC;IACD,8DAA8D;IAC9D,OAAOA,KAAKE,UAAU,IAAI,AAACF,KAAaG,IAAI;AAC9C,EAAE;AAEF;;;;CAIC,GACD,MAAMC,2BAA2B,CAACJ,OAAoD;QAKrEA;IAJf,IAAIA,KAAKK,QAAQ,KAAK,GAAG;QACvB,OAAO,CAAC;IACV,CAAC;IAED,MAAMC,SAASN,CAAAA,sBAAAA,KAAKO,aAAa,cAAlBP,iCAAAA,KAAAA,IAAAA,oBAAoBQ,WAAW;IAC9C,OAAOF,OAAQG,gBAAgB,CAACT,MAAM,IAAI;AAC5C;AAEA;;;;CAIC,GACD,OAAO,MAAMU,kBAAkB,CAACV,OAAqD;IACnF,iFAAiF;IACjF,MAAME,aAAaF,QAAQD,cAAcC;IACzC,2BAA2B;IAC3B,IAAI,CAACE,YAAY,OAAOS,SAASC,IAAI;IAErC,OAAQV,WAAWD,QAAQ;QACzB,KAAK;QACL,KAAK;YACH,OAAOC,WAAWK,aAAa,CAAEK,IAAI;QACvC,KAAK;YACH,OAAO,AAACV,WAAmCU,IAAI;IACnD;IAEA,uFAAuF;IACvF,MAAM,EAAEC,SAAQ,EAAEC,UAAS,EAAEC,UAAS,EAAE,GAAGX,yBAAyBF;IACpE,IAAI,wBAAwBc,IAAI,CAACH,WAAYE,YAAaD,YAAY;QACpE,OAAOZ;IACT,CAAC;IAED,OAAOQ,gBAAgBR;AACzB,EAAE;AAEF,OAAO,MAAMe,kBAAkB,CAACjB,OAAiD;QAE1BkB;IADrD,MAAMA,sBAAmCR,gBAAgBV;IACzD,OAAOkB,sBAAsBA,wBAAwBA,CAAAA,CAAAA,qCAAAA,oBAAoBX,aAAa,cAAjCW,gDAAAA,KAAAA,IAAAA,mCAAmCN,IAAI,AAAD,IAAI,KAAK;AACtG,EAAE"}
|
@@ -7,17 +7,15 @@ import { getReactFiberFromNode } from './getReactFiberFromNode';
|
|
7
7
|
* in React DOM and will not pass "autoFocus" to an actual HTML.
|
8
8
|
*
|
9
9
|
* @param node
|
10
|
-
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
return false;
|
10
|
+
*/ function hasAutofocusProp(node) {
|
11
|
+
// https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
|
12
|
+
const isAutoFocusableElement = node.nodeName === 'BUTTON' || node.nodeName === 'INPUT' || node.nodeName === 'SELECT' || node.nodeName === 'TEXTAREA';
|
13
|
+
if (isAutoFocusableElement) {
|
14
|
+
var _getReactFiberFromNode;
|
15
|
+
return !!((_getReactFiberFromNode = getReactFiberFromNode(node)) === null || _getReactFiberFromNode === void 0 ? void 0 : _getReactFiberFromNode.pendingProps.autoFocus);
|
16
|
+
}
|
17
|
+
return false;
|
19
18
|
}
|
20
19
|
export function hasAutofocusFilter(node) {
|
21
|
-
|
20
|
+
return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
22
21
|
}
|
23
|
-
//# sourceMappingURL=hasAutoFocusFilter.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["getReactFiberFromNode","hasAutofocusProp","node","isAutoFocusableElement","nodeName","pendingProps","autoFocus","hasAutofocusFilter","NodeFilter","FILTER_ACCEPT","FILTER_SKIP"],"mappings":"AAAA,EAAE;AACF,uDAAuD;AACvD,EAAE;AAEF,SAASA,qBAAqB,QAAQ,0BAA0B;AAEhE;;;;;CAKC,GACD,SAASC,iBAAiBC,IAAU,EAAW;IAC7C,gJAAgJ;IAChJ,MAAMC,yBACJD,KAAKE,QAAQ,KAAK,YAClBF,KAAKE,QAAQ,KAAK,WAClBF,KAAKE,QAAQ,KAAK,YAClBF,KAAKE,QAAQ,KAAK;IAEpB,IAAID,wBAAwB;YACjBH;QAAT,OAAO,CAAC,EAACA,CAAAA,yBAAAA,sBAAsBE,mBAAtBF,oCAAAA,KAAAA,IAAAA,uBAA6BK,aAAaC,SAAS;IAC9D,CAAC;IAED,OAAO,KAAK;AACd;AAEA,OAAO,SAASC,mBAAmBL,IAAU,EAAE;IAC7C,OAAOD,iBAAiBC,QAAQM,WAAWC,aAAa,GAAGD,WAAWE,WAAW;AACnF,CAAC"}
|
package/lib/utils/index.js
CHANGED
package/lib/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":[],"mappings":"AAAA,cAAc,6BAA6B;AAC3C,cAAc,gBAAgB;AAC9B,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,0BAA0B"}
|
@@ -6,33 +6,32 @@
|
|
6
6
|
* @param userOffset - The offset provided by the user
|
7
7
|
* @param arrowHeight - The height of the arrow in px
|
8
8
|
* @returns User offset augmented with arrow height
|
9
|
-
*/export function mergeArrowOffset(userOffset, arrowHeight) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
20
24
|
};
|
21
|
-
}
|
22
|
-
return {
|
23
|
-
mainAxis: arrowHeight
|
24
|
-
};
|
25
25
|
}
|
26
|
-
const addArrowOffset = (offset, arrowHeight)
|
27
|
-
|
26
|
+
const addArrowOffset = (offset, arrowHeight)=>{
|
27
|
+
if (typeof offset === 'number') {
|
28
|
+
return {
|
29
|
+
mainAxis: offset + arrowHeight
|
30
|
+
};
|
31
|
+
}
|
32
|
+
var _offset_mainAxis;
|
28
33
|
return {
|
29
|
-
|
34
|
+
...offset,
|
35
|
+
mainAxis: ((_offset_mainAxis = offset.mainAxis) !== null && _offset_mainAxis !== void 0 ? _offset_mainAxis : 0) + arrowHeight
|
30
36
|
};
|
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
37
|
};
|
38
|
-
//# sourceMappingURL=mergeArrowOffset.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["mergeArrowOffset","userOffset","arrowHeight","addArrowOffset","offsetParams","offset","mainAxis"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,iBAAiBC,UAAqC,EAAEC,WAAmB,EAAU;IACnG,IAAI,OAAOD,eAAe,UAAU;QAClC,OAAOE,eAAeF,YAAYC;IACpC,CAAC;IAED,IAAI,OAAOD,eAAe,YAAYA,eAAe,IAAI,EAAE;QACzD,OAAOE,eAAeF,YAAYC;IACpC,CAAC;IAED,IAAI,OAAOD,eAAe,YAAY;QACpC,OAAOG,CAAAA,eAAgB;YACrB,MAAMC,SAASJ,WAAWG;YAC1B,OAAOD,eAAeE,QAAQH;QAChC;IACF,CAAC;IAED,OAAO;QAAEI,UAAUJ;IAAY;AACjC,CAAC;AAED,MAAMC,iBAAiB,CAACE,QAA+BH,cAAsC;IAC3F,IAAI,OAAOG,WAAW,UAAU;QAC9B,OAAO;YAAEC,UAAUD,SAASH;QAAY;IAC1C,CAAC;QAE8BG;IAA/B,OAAO;QAAE,GAAGA,MAAM;QAAEC,UAAU,AAACD,CAAAA,CAAAA,mBAAAA,OAAOC,QAAQ,cAAfD,8BAAAA,mBAAmB,CAAC,AAAD,IAAKH;IAAY;AACrE"}
|
@@ -3,11 +3,10 @@
|
|
3
3
|
* @param placement - the floating ui placement (i.e. bottom-start)
|
4
4
|
*
|
5
5
|
* @returns side and alignment components of the placement
|
6
|
-
*/export function parseFloatingUIPlacement(placement) {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
*/ export function parseFloatingUIPlacement(placement) {
|
7
|
+
const tokens = placement.split('-');
|
8
|
+
return {
|
9
|
+
side: tokens[0],
|
10
|
+
alignment: tokens[1]
|
11
|
+
};
|
12
12
|
}
|
13
|
-
//# sourceMappingURL=parseFloatingUIPlacement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["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"],"names":["parseFloatingUIPlacement","placement","tokens","split","side","alignment"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,yBAAyBC,SAAoB,EAAwC;IACnG,MAAMC,SAASD,UAAUE,KAAK,CAAC;IAC/B,OAAO;QACLC,MAAMF,MAAM,CAAC,EAAE;QACfG,WAAWH,MAAM,CAAC,EAAE;IACtB;AACF,CAAC"}
|