@fluentui/react-positioning 9.3.1 → 9.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +53 -1
- package/CHANGELOG.md +21 -2
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/index.js.map +1 -1
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-amd/constants.js +10 -0
- package/lib-amd/constants.js.map +1 -0
- package/lib-amd/createArrowStyles.js +62 -0
- package/lib-amd/createArrowStyles.js.map +1 -0
- package/lib-amd/createPositionManager.js +85 -0
- package/lib-amd/createPositionManager.js.map +1 -0
- package/lib-amd/createVirtualElementFromClick.js +32 -0
- package/lib-amd/createVirtualElementFromClick.js.map +1 -0
- package/lib-amd/index.js +13 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/middleware/coverTarget.js +32 -0
- package/lib-amd/middleware/coverTarget.js.map +1 -0
- package/lib-amd/middleware/flip.js +11 -0
- package/lib-amd/middleware/flip.js.map +1 -0
- package/lib-amd/middleware/index.js +11 -0
- package/lib-amd/middleware/index.js.map +1 -0
- package/lib-amd/middleware/intersecting.js +33 -0
- package/lib-amd/middleware/intersecting.js.map +1 -0
- package/lib-amd/middleware/maxSize.js +43 -0
- package/lib-amd/middleware/maxSize.js.map +1 -0
- package/lib-amd/middleware/offset.js +14 -0
- package/lib-amd/middleware/offset.js.map +1 -0
- package/lib-amd/middleware/shift.js +17 -0
- package/lib-amd/middleware/shift.js.map +1 -0
- package/lib-amd/types.js +5 -0
- package/lib-amd/types.js.map +1 -0
- package/lib-amd/usePositioning.js +152 -0
- package/lib-amd/usePositioning.js.map +1 -0
- package/lib-amd/usePositioningMouseTarget.js +39 -0
- package/lib-amd/usePositioningMouseTarget.js.map +1 -0
- package/lib-amd/utils/debounce.js +27 -0
- package/lib-amd/utils/debounce.js.map +1 -0
- package/lib-amd/utils/fromFloatingUIPlacement.js +37 -0
- package/lib-amd/utils/fromFloatingUIPlacement.js.map +1 -0
- package/lib-amd/utils/getBoundary.js +26 -0
- package/lib-amd/utils/getBoundary.js.map +1 -0
- package/lib-amd/utils/getFloatingUIOffset.js +25 -0
- package/lib-amd/utils/getFloatingUIOffset.js.map +1 -0
- package/lib-amd/utils/getReactFiberFromNode.js +48 -0
- package/lib-amd/utils/getReactFiberFromNode.js.map +1 -0
- package/lib-amd/utils/getScrollParent.js +64 -0
- package/lib-amd/utils/getScrollParent.js.map +1 -0
- package/lib-amd/utils/hasAutoFocusFilter.js +31 -0
- package/lib-amd/utils/hasAutoFocusFilter.js.map +1 -0
- package/lib-amd/utils/index.js +19 -0
- package/lib-amd/utils/index.js.map +1 -0
- package/lib-amd/utils/mergeArrowOffset.js +38 -0
- package/lib-amd/utils/mergeArrowOffset.js.map +1 -0
- package/lib-amd/utils/parseFloatingUIPlacement.js +20 -0
- package/lib-amd/utils/parseFloatingUIPlacement.js.map +1 -0
- package/lib-amd/utils/resolvePositioningShorthand.js +31 -0
- package/lib-amd/utils/resolvePositioningShorthand.js.map +1 -0
- package/lib-amd/utils/toFloatingUIPlacement.js +40 -0
- package/lib-amd/utils/toFloatingUIPlacement.js.map +1 -0
- package/lib-amd/utils/toggleScrollListener.js +26 -0
- package/lib-amd/utils/toggleScrollListener.js.map +1 -0
- package/lib-amd/utils/useCallbackRef.js +55 -0
- package/lib-amd/utils/useCallbackRef.js.map +1 -0
- package/lib-amd/utils/writeArrowUpdates.js +21 -0
- package/lib-amd/utils/writeArrowUpdates.js.map +1 -0
- package/lib-amd/utils/writeContainerupdates.js +34 -0
- package/lib-amd/utils/writeContainerupdates.js.map +1 -0
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +6 -7
@@ -0,0 +1,152 @@
|
|
1
|
+
define(["require", "exports", "tslib", "@floating-ui/dom", "@fluentui/react-shared-contexts", "@fluentui/react-utilities", "react", "./utils", "./middleware", "./createPositionManager"], function (require, exports, tslib_1, dom_1, react_shared_contexts_1, react_utilities_1, React, utils_1, middleware_1, createPositionManager_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.usePositioning = void 0;
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
*/
|
8
|
+
function usePositioning(options) {
|
9
|
+
var managerRef = React.useRef(null);
|
10
|
+
var targetRef = React.useRef(null);
|
11
|
+
var overrideTargetRef = React.useRef(null);
|
12
|
+
var containerRef = React.useRef(null);
|
13
|
+
var arrowRef = React.useRef(null);
|
14
|
+
var _a = options.enabled, enabled = _a === void 0 ? true : _a;
|
15
|
+
var resolvePositioningOptions = usePositioningOptions(options);
|
16
|
+
var updatePositionManager = React.useCallback(function () {
|
17
|
+
var _a;
|
18
|
+
if (managerRef.current) {
|
19
|
+
managerRef.current.dispose();
|
20
|
+
}
|
21
|
+
managerRef.current = null;
|
22
|
+
var target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
|
23
|
+
if (enabled && react_utilities_1.canUseDOM() && target && containerRef.current) {
|
24
|
+
managerRef.current = createPositionManager_1.createPositionManager(tslib_1.__assign({ container: containerRef.current, target: target, arrow: arrowRef.current }, resolvePositioningOptions(containerRef.current, arrowRef.current)));
|
25
|
+
}
|
26
|
+
}, [enabled, resolvePositioningOptions]);
|
27
|
+
var setOverrideTarget = React.useCallback(function (target) {
|
28
|
+
overrideTargetRef.current = target;
|
29
|
+
updatePositionManager();
|
30
|
+
}, [updatePositionManager]);
|
31
|
+
React.useImperativeHandle(options.positioningRef, function () { return ({
|
32
|
+
updatePosition: function () { var _a; return (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition(); },
|
33
|
+
setTarget: function (target) {
|
34
|
+
if (options.target && process.env.NODE_ENV !== 'production') {
|
35
|
+
var err = new Error();
|
36
|
+
// eslint-disable-next-line no-console
|
37
|
+
console.warn('Imperative setTarget should not be used at the same time as target option');
|
38
|
+
// eslint-disable-next-line no-console
|
39
|
+
console.warn(err.stack);
|
40
|
+
}
|
41
|
+
setOverrideTarget(target);
|
42
|
+
},
|
43
|
+
}); }, [options.target, setOverrideTarget]);
|
44
|
+
react_utilities_1.useIsomorphicLayoutEffect(function () {
|
45
|
+
var _a;
|
46
|
+
setOverrideTarget((_a = options.target) !== null && _a !== void 0 ? _a : null);
|
47
|
+
}, [options.target, setOverrideTarget]);
|
48
|
+
react_utilities_1.useIsomorphicLayoutEffect(function () {
|
49
|
+
updatePositionManager();
|
50
|
+
}, [updatePositionManager]);
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
52
|
+
// This checked should run only in development mode
|
53
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
54
|
+
React.useEffect(function () {
|
55
|
+
var _a;
|
56
|
+
if (containerRef.current) {
|
57
|
+
var contentNode = containerRef.current;
|
58
|
+
var treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
|
59
|
+
acceptNode: utils_1.hasAutofocusFilter,
|
60
|
+
});
|
61
|
+
while (treeWalker.nextNode()) {
|
62
|
+
var node = treeWalker.currentNode;
|
63
|
+
// eslint-disable-next-line no-console
|
64
|
+
console.warn('<Popper>:', node);
|
65
|
+
// eslint-disable-next-line no-console
|
66
|
+
console.warn([
|
67
|
+
'<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
|
68
|
+
'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',
|
69
|
+
'"autoFocus" behavior to solve inconsistencies between different browsers:',
|
70
|
+
'https://github.com/facebook/react/issues/11851#issuecomment-351787078',
|
71
|
+
'\n',
|
72
|
+
'However, ".focus()" in this case occurs before any other React effects will be executed',
|
73
|
+
'(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',
|
74
|
+
'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by',
|
75
|
+
'"Popper".',
|
76
|
+
"In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:",
|
77
|
+
'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',
|
78
|
+
'\n',
|
79
|
+
'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use',
|
80
|
+
'"ref.current.focus" in React.useEffect():',
|
81
|
+
'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',
|
82
|
+
].join(' '));
|
83
|
+
}
|
84
|
+
}
|
85
|
+
// We run this check once, no need to add deps here
|
86
|
+
// TODO: Should be rework to handle options.enabled and contentRef updates
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
88
|
+
}, []);
|
89
|
+
}
|
90
|
+
var setTarget = utils_1.useCallbackRef(null, function (target) {
|
91
|
+
if (targetRef.current !== target) {
|
92
|
+
targetRef.current = target;
|
93
|
+
updatePositionManager();
|
94
|
+
}
|
95
|
+
});
|
96
|
+
var setContainer = utils_1.useCallbackRef(null, function (container) {
|
97
|
+
if (containerRef.current !== container) {
|
98
|
+
containerRef.current = container;
|
99
|
+
updatePositionManager();
|
100
|
+
}
|
101
|
+
});
|
102
|
+
var setArrow = utils_1.useCallbackRef(null, function (arrow) {
|
103
|
+
if (arrowRef.current !== arrow) {
|
104
|
+
arrowRef.current = arrow;
|
105
|
+
updatePositionManager();
|
106
|
+
}
|
107
|
+
});
|
108
|
+
// Let users use callback refs so they feel like 'normal' DOM refs
|
109
|
+
return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };
|
110
|
+
}
|
111
|
+
exports.usePositioning = usePositioning;
|
112
|
+
function usePositioningOptions(options) {
|
113
|
+
var align = options.align, arrowPadding = options.arrowPadding, autoSize = options.autoSize, coverTarget = options.coverTarget, flipBoundary = options.flipBoundary, offset = options.offset, overflowBoundary = options.overflowBoundary, pinned = options.pinned, position = options.position, disableTether = options.unstable_disableTether, positionFixed = options.positionFixed;
|
114
|
+
var dir = react_shared_contexts_1.useFluent_unstable().dir;
|
115
|
+
var isRtl = dir === 'rtl';
|
116
|
+
var strategy = positionFixed ? 'fixed' : 'absolute';
|
117
|
+
return React.useCallback(function (container, arrow) {
|
118
|
+
var hasScrollableElement = utils_1.hasScrollParent(container);
|
119
|
+
var placement = utils_1.toFloatingUIPlacement(align, position, isRtl);
|
120
|
+
var middleware = [
|
121
|
+
offset && middleware_1.offset(offset),
|
122
|
+
coverTarget && middleware_1.coverTarget(),
|
123
|
+
!pinned && middleware_1.flip({ container: container, flipBoundary: flipBoundary, hasScrollableElement: hasScrollableElement }),
|
124
|
+
middleware_1.shift({ container: container, hasScrollableElement: hasScrollableElement, overflowBoundary: overflowBoundary, disableTether: disableTether }),
|
125
|
+
autoSize && middleware_1.maxSize(autoSize),
|
126
|
+
middleware_1.intersecting(),
|
127
|
+
arrow && dom_1.arrow({ element: arrow, padding: arrowPadding }),
|
128
|
+
dom_1.hide({ strategy: 'referenceHidden' }),
|
129
|
+
dom_1.hide({ strategy: 'escaped' }),
|
130
|
+
].filter(Boolean);
|
131
|
+
return {
|
132
|
+
placement: placement,
|
133
|
+
middleware: middleware,
|
134
|
+
strategy: strategy,
|
135
|
+
};
|
136
|
+
}, [
|
137
|
+
align,
|
138
|
+
arrowPadding,
|
139
|
+
autoSize,
|
140
|
+
coverTarget,
|
141
|
+
disableTether,
|
142
|
+
flipBoundary,
|
143
|
+
isRtl,
|
144
|
+
offset,
|
145
|
+
overflowBoundary,
|
146
|
+
pinned,
|
147
|
+
position,
|
148
|
+
strategy,
|
149
|
+
]);
|
150
|
+
}
|
151
|
+
});
|
152
|
+
//# sourceMappingURL=usePositioning.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePositioning.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/usePositioning.ts"],"names":[],"mappings":";;;;IAuBA;;OAEG;IACH,SAAgB,cAAc,CAAC,OAA8B;QAC3D,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAyB,IAAI,CAAC,CAAC;QAC9D,IAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAuB,IAAI,CAAC,CAAC;QAC3D,IAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAuB,IAAI,CAAC,CAAC;QACnE,IAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAqB,IAAI,CAAC,CAAC;QAC5D,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAqB,IAAI,CAAC,CAAC;QAEhD,IAAA,KAAmB,OAAO,QAAZ,EAAd,OAAO,mBAAG,IAAI,KAAA,CAAa;QACnC,IAAM,yBAAyB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACjE,IAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC;;YAC9C,IAAI,UAAU,CAAC,OAAO,EAAE;gBACtB,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;aAC9B;YACD,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAE1B,IAAM,MAAM,GAAG,MAAA,iBAAiB,CAAC,OAAO,mCAA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-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = React.useCallback(\n (target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n },\n [updatePositionManager],\n );\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n"]}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
define(["require", "exports", "react", "./createVirtualElementFromClick"], function (require, exports, React, createVirtualElementFromClick_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.usePositioningMouseTarget = void 0;
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
* A state hook that manages a popper virtual element from mouseevents.
|
8
|
+
* Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
|
9
|
+
* React synthetic events are not persisted by this hook
|
10
|
+
*
|
11
|
+
* @param initialState - initializes a user provided state similare to useState
|
12
|
+
* @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
|
13
|
+
*/
|
14
|
+
var usePositioningMouseTarget = function (initialState) {
|
15
|
+
var _a = React.useState(initialState), virtualElement = _a[0], setVirtualElement = _a[1];
|
16
|
+
var setVirtualMouseTarget = function (event) {
|
17
|
+
if (event === undefined || event === null) {
|
18
|
+
setVirtualElement(undefined);
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
var mouseevent;
|
22
|
+
if (!(event instanceof MouseEvent)) {
|
23
|
+
mouseevent = event.nativeEvent;
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
mouseevent = event;
|
27
|
+
}
|
28
|
+
if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
console.error('usePositioningMouseTarget should only be used with MouseEvent');
|
31
|
+
}
|
32
|
+
var contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
|
33
|
+
setVirtualElement(contextTarget);
|
34
|
+
};
|
35
|
+
return [virtualElement, setVirtualMouseTarget];
|
36
|
+
};
|
37
|
+
exports.usePositioningMouseTarget = usePositioningMouseTarget;
|
38
|
+
});
|
39
|
+
//# sourceMappingURL=usePositioningMouseTarget.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePositioningMouseTarget.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/usePositioningMouseTarget.ts"],"names":[],"mappings":";;;;IAIA;;;;;;;;OAQG;IACI,IAAM,yBAAyB,GAAG,UACvC,YAA4E;QAEtE,IAAA,KAAsC,KAAK,CAAC,QAAQ,CAAwC,YAAY,CAAC,EAAxG,cAAc,QAAA,EAAE,iBAAiB,QAAuE,CAAC;QAEhH,IAAM,qBAAqB,GAA0B,UAAA,KAAK;YACxD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;gBACzC,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAC7B,OAAO;aACR;YAED,IAAI,UAAsB,CAAC;YAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;gBAClC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;aAChC;iBAAM;gBACL,UAAU,GAAG,KAAK,CAAC;aACpB;YAED,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBAChF,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;aAChF;YAED,IAAM,aAAa,GAAG,6DAA6B,CAAC,UAAU,CAAC,CAAC;YAChE,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAC;IAC1D,CAAC,CAAC;IA5BW,QAAA,yBAAyB,6BA4BpC","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget: SetVirtualMouseTarget = event => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"]}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.debounce = void 0;
|
5
|
+
/**
|
6
|
+
* Promise microtask debouncer used by Popper.js v2
|
7
|
+
* This is no longer exported in Floating UI (Popper.js v3)
|
8
|
+
* https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
|
9
|
+
* @param fn function that will be debounced
|
10
|
+
*/
|
11
|
+
function debounce(fn) {
|
12
|
+
var pending;
|
13
|
+
return function () {
|
14
|
+
if (!pending) {
|
15
|
+
pending = new Promise(function (resolve) {
|
16
|
+
Promise.resolve().then(function () {
|
17
|
+
pending = undefined;
|
18
|
+
resolve(fn());
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
22
|
+
return pending;
|
23
|
+
};
|
24
|
+
}
|
25
|
+
exports.debounce = debounce;
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=debounce.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/debounce.ts"],"names":[],"mappings":";;;;IAAA;;;;;OAKG;IACH,SAAgB,QAAQ,CAAI,EAAY;QACtC,IAAI,OAA+B,CAAC;QACpC,OAAO;YACL,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,OAAO,CAAI,UAAA,OAAO;oBAC9B,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;wBACrB,OAAO,GAAG,SAAS,CAAC;wBACpB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;oBAChB,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;aACJ;YAED,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;IAdD,4BAcC","sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
define(["require", "exports", "./parseFloatingUIPlacement"], function (require, exports, parseFloatingUIPlacement_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.fromFloatingUIPlacement = void 0;
|
5
|
+
var getPositionMap = function () { return ({
|
6
|
+
top: 'above',
|
7
|
+
bottom: 'below',
|
8
|
+
right: 'after',
|
9
|
+
left: 'before',
|
10
|
+
}); };
|
11
|
+
// Floating UI automatically flips alignment
|
12
|
+
// https://github.com/floating-ui/floating-ui/issues/1563
|
13
|
+
var getAlignmentMap = function (position) {
|
14
|
+
if (position === 'above' || position === 'below') {
|
15
|
+
return {
|
16
|
+
start: 'start',
|
17
|
+
end: 'end',
|
18
|
+
};
|
19
|
+
}
|
20
|
+
return {
|
21
|
+
start: 'top',
|
22
|
+
end: 'bottom',
|
23
|
+
};
|
24
|
+
};
|
25
|
+
/**
|
26
|
+
* Maps Floating UI placement to positioning values
|
27
|
+
* @see positioningHelper.test.ts for expected placement values
|
28
|
+
*/
|
29
|
+
var fromFloatingUIPlacement = function (placement) {
|
30
|
+
var _a = parseFloatingUIPlacement_1.parseFloatingUIPlacement(placement), side = _a.side, floatingUIAlignment = _a.alignment;
|
31
|
+
var position = getPositionMap()[side];
|
32
|
+
var alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];
|
33
|
+
return { position: position, alignment: alignment };
|
34
|
+
};
|
35
|
+
exports.fromFloatingUIPlacement = fromFloatingUIPlacement;
|
36
|
+
});
|
37
|
+
//# sourceMappingURL=fromFloatingUIPlacement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fromFloatingUIPlacement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/fromFloatingUIPlacement.ts"],"names":[],"mappings":";;;;IAIA,IAAM,cAAc,GAAG,cAA8B,OAAA,CAAC;QACpD,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;KACf,CAAC,EALmD,CAKnD,CAAC;IAEH,4CAA4C;IAC5C,yDAAyD;IACzD,IAAM,eAAe,GAAG,UAAC,QAAkB;QACzC,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,OAAO,EAAE;YAChD,OAAO;gBACL,KAAK,EAAE,OAAO;gBACd,GAAG,EAAE,KAAK;aACX,CAAC;SACH;QAED,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC,CAAC;IAEF;;;OAGG;IACI,IAAM,uBAAuB,GAAG,UAAC,SAAoB;QACpD,IAAA,KAA2C,mDAAwB,CAAC,SAAS,CAAC,EAA5E,IAAI,UAAA,EAAa,mBAAmB,eAAwC,CAAC;QACrF,IAAM,QAAQ,GAAG,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QACxC,IAAM,SAAS,GAAG,mBAAmB,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAExF,OAAO,EAAE,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IACjC,CAAC,CAAC;IANW,QAAA,uBAAuB,2BAMlC","sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, Alignment> => {\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end',\n };\n }\n\n return {\n start: 'top',\n end: 'bottom',\n };\n};\n\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"]}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
define(["require", "exports", "./getScrollParent"], function (require, exports, getScrollParent_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.getBoundary = void 0;
|
5
|
+
/**
|
6
|
+
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
7
|
+
*/
|
8
|
+
function getBoundary(element, boundary) {
|
9
|
+
if (boundary === 'window') {
|
10
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
11
|
+
}
|
12
|
+
if (boundary === 'clippingParents') {
|
13
|
+
return 'clippingAncestors';
|
14
|
+
}
|
15
|
+
if (boundary === 'scrollParent') {
|
16
|
+
var boundariesNode = getScrollParent_1.getScrollParent(element);
|
17
|
+
if (boundariesNode.nodeName === 'BODY') {
|
18
|
+
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
19
|
+
}
|
20
|
+
return boundariesNode;
|
21
|
+
}
|
22
|
+
return boundary;
|
23
|
+
}
|
24
|
+
exports.getBoundary = getBoundary;
|
25
|
+
});
|
26
|
+
//# sourceMappingURL=getBoundary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getBoundary.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;QAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;YACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;SAChD;QAED,IAAI,QAAQ,KAAK,iBAAiB,EAAE;YAClC,OAAO,mBAAmB,CAAC;SAC5B;QAED,IAAI,QAAQ,KAAK,cAAc,EAAE;YAC/B,IAAI,cAAc,GAA4B,iCAAe,CAAC,OAAO,CAAC,CAAC;YAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;gBACtC,cAAc,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;aAC1D;YAED,OAAO,cAAc,CAAC;SACvB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IApBD,kCAoBC","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"]}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
define(["require", "exports", "./fromFloatingUIPlacement"], function (require, exports, fromFloatingUIPlacement_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.getFloatingUIOffset = void 0;
|
5
|
+
/**
|
6
|
+
* Shim to transform offset values from this library to Floating UI
|
7
|
+
* @param rawOffset Offset from this library
|
8
|
+
* @returns An offset value compatible with Floating UI
|
9
|
+
*/
|
10
|
+
function getFloatingUIOffset(rawOffset) {
|
11
|
+
if (!rawOffset) {
|
12
|
+
return rawOffset;
|
13
|
+
}
|
14
|
+
if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
|
15
|
+
return rawOffset;
|
16
|
+
}
|
17
|
+
return function (_a) {
|
18
|
+
var _b = _a.rects, floating = _b.floating, reference = _b.reference, placement = _a.placement;
|
19
|
+
var _c = fromFloatingUIPlacement_1.fromFloatingUIPlacement(placement), position = _c.position, alignment = _c.alignment;
|
20
|
+
return rawOffset({ positionedRect: floating, targetRect: reference, position: position, alignment: alignment });
|
21
|
+
};
|
22
|
+
}
|
23
|
+
exports.getFloatingUIOffset = getFloatingUIOffset;
|
24
|
+
});
|
25
|
+
//# sourceMappingURL=getFloatingUIOffset.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getFloatingUIOffset.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getFloatingUIOffset.ts"],"names":[],"mappings":";;;;IAkCA;;;;OAIG;IACH,SAAgB,mBAAmB,CACjC,SAA6B;QAE7B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YAClE,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,UAAC,EAA6C;gBAA3C,aAA8B,EAArB,QAAQ,cAAA,EAAE,SAAS,eAAA,EAAI,SAAS,eAAA;YAC3C,IAAA,KAA0B,iDAAuB,CAAC,SAAS,CAAC,EAA1D,QAAQ,cAAA,EAAE,SAAS,eAAuC,CAAC;YACnE,OAAO,SAAS,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC;QAC7F,CAAC,CAAC;IACJ,CAAC;IAfD,kDAeC","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"]}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.getReactFiberFromNode = void 0;
|
5
|
+
var WorkTag;
|
6
|
+
(function (WorkTag) {
|
7
|
+
WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
|
8
|
+
WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
|
9
|
+
WorkTag[WorkTag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
|
10
|
+
WorkTag[WorkTag["HostRoot"] = 3] = "HostRoot";
|
11
|
+
WorkTag[WorkTag["HostPortal"] = 4] = "HostPortal";
|
12
|
+
WorkTag[WorkTag["HostComponent"] = 5] = "HostComponent";
|
13
|
+
WorkTag[WorkTag["HostText"] = 6] = "HostText";
|
14
|
+
WorkTag[WorkTag["Fragment"] = 7] = "Fragment";
|
15
|
+
WorkTag[WorkTag["Mode"] = 8] = "Mode";
|
16
|
+
WorkTag[WorkTag["ContextConsumer"] = 9] = "ContextConsumer";
|
17
|
+
WorkTag[WorkTag["ContextProvider"] = 10] = "ContextProvider";
|
18
|
+
WorkTag[WorkTag["ForwardRef"] = 11] = "ForwardRef";
|
19
|
+
WorkTag[WorkTag["Profiler"] = 12] = "Profiler";
|
20
|
+
WorkTag[WorkTag["SuspenseComponent"] = 13] = "SuspenseComponent";
|
21
|
+
WorkTag[WorkTag["MemoComponent"] = 14] = "MemoComponent";
|
22
|
+
WorkTag[WorkTag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
|
23
|
+
WorkTag[WorkTag["LazyComponent"] = 16] = "LazyComponent";
|
24
|
+
WorkTag[WorkTag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
|
25
|
+
WorkTag[WorkTag["DehydratedFragment"] = 18] = "DehydratedFragment";
|
26
|
+
WorkTag[WorkTag["SuspenseListComponent"] = 19] = "SuspenseListComponent";
|
27
|
+
WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
|
28
|
+
WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
|
29
|
+
})(WorkTag || (WorkTag = {}));
|
30
|
+
function getReactFiberFromNode(elm) {
|
31
|
+
if (!elm) {
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
for (var k in elm) {
|
35
|
+
// React 16 uses "__reactInternalInstance$" prefix
|
36
|
+
// React 17 uses "__reactFiber$" prefix
|
37
|
+
// https://github.com/facebook/react/pull/18377
|
38
|
+
if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {
|
39
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
40
|
+
// @ts-ignore
|
41
|
+
return elm[k];
|
42
|
+
}
|
43
|
+
}
|
44
|
+
throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
|
45
|
+
}
|
46
|
+
exports.getReactFiberFromNode = getReactFiberFromNode;
|
47
|
+
});
|
48
|
+
//# sourceMappingURL=getReactFiberFromNode.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;;IAuEA,IAAK,OAuBJ;IAvBD,WAAK,OAAO;QACV,+DAAqB,CAAA;QACrB,yDAAkB,CAAA;QAClB,yEAA0B,CAAA;QAC1B,6CAAY,CAAA;QACZ,iDAAc,CAAA;QACd,uDAAiB,CAAA;QACjB,6CAAY,CAAA;QACZ,6CAAY,CAAA;QACZ,qCAAQ,CAAA;QACR,2DAAmB,CAAA;QACnB,4DAAoB,CAAA;QACpB,kDAAe,CAAA;QACf,8CAAa,CAAA;QACb,gEAAsB,CAAA;QACtB,wDAAkB,CAAA;QAClB,oEAAwB,CAAA;QACxB,wDAAkB,CAAA;QAClB,8EAA6B,CAAA;QAC7B,kEAAuB,CAAA;QACvB,wEAA0B,CAAA;QAC1B,sEAAyB,CAAA;QACzB,0DAAmB,CAAA;IACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;IA+JD,SAAgB,qBAAqB,CAAC,GAAqB;QACzD,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,IAAI,CAAC;SACb;QAED,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;YACnB,kDAAkD;YAClD,uCAAuC;YACvC,+CAA+C;YAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;gBACnF,6DAA6D;gBAC7D,aAAa;gBACb,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;aACf;SACF;QAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAjBD,sDAiBC","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"]}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.hasScrollParent = exports.getScrollParent = exports.getParentNode = void 0;
|
5
|
+
/**
|
6
|
+
* Returns the parent node or the host of the node argument.
|
7
|
+
* @param node - DOM node.
|
8
|
+
* @returns - parent DOM node.
|
9
|
+
*/
|
10
|
+
var getParentNode = function (node) {
|
11
|
+
if (node.nodeName === 'HTML') {
|
12
|
+
return node;
|
13
|
+
}
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
15
|
+
return node.parentNode || node.host;
|
16
|
+
};
|
17
|
+
exports.getParentNode = getParentNode;
|
18
|
+
/**
|
19
|
+
* Returns CSS styles of the given node.
|
20
|
+
* @param node - DOM node.
|
21
|
+
* @returns - CSS styles.
|
22
|
+
*/
|
23
|
+
var getStyleComputedProperty = function (node) {
|
24
|
+
var _a;
|
25
|
+
if (node.nodeType !== 1) {
|
26
|
+
return {};
|
27
|
+
}
|
28
|
+
var window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
29
|
+
return window.getComputedStyle(node, null);
|
30
|
+
};
|
31
|
+
/**
|
32
|
+
* Returns the first scrollable parent of the given element.
|
33
|
+
* @param node - DOM node.
|
34
|
+
* @returns - the first scrollable parent.
|
35
|
+
*/
|
36
|
+
var getScrollParent = function (node) {
|
37
|
+
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
38
|
+
var parentNode = node && exports.getParentNode(node);
|
39
|
+
// eslint-disable-next-line
|
40
|
+
if (!parentNode)
|
41
|
+
return document.body;
|
42
|
+
switch (parentNode.nodeName) {
|
43
|
+
case 'HTML':
|
44
|
+
case 'BODY':
|
45
|
+
return parentNode.ownerDocument.body;
|
46
|
+
case '#document':
|
47
|
+
return parentNode.body;
|
48
|
+
}
|
49
|
+
// If any of the overflow props is defined for the node then we return it as the parent
|
50
|
+
var _a = getStyleComputedProperty(parentNode), overflow = _a.overflow, overflowX = _a.overflowX, overflowY = _a.overflowY;
|
51
|
+
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
52
|
+
return parentNode;
|
53
|
+
}
|
54
|
+
return exports.getScrollParent(parentNode);
|
55
|
+
};
|
56
|
+
exports.getScrollParent = getScrollParent;
|
57
|
+
var hasScrollParent = function (node) {
|
58
|
+
var _a;
|
59
|
+
var scrollParentElement = exports.getScrollParent(node);
|
60
|
+
return scrollParentElement ? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body) : false;
|
61
|
+
};
|
62
|
+
exports.hasScrollParent = hasScrollParent;
|
63
|
+
});
|
64
|
+
//# sourceMappingURL=getScrollParent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getScrollParent.ts"],"names":[],"mappings":";;;;IAAA;;;;OAIG;IACI,IAAM,aAAa,GAAG,UAAC,IAAiB;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;YAC5B,OAAO,IAAI,CAAC;SACb;QACD,8DAA8D;QAC9D,OAAO,IAAI,CAAC,UAAU,IAAK,IAAY,CAAC,IAAI,CAAC;IAC/C,CAAC,CAAC;IANW,QAA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AC,CAAC,CAAC,KAAK,CAAC;IACvG,CAAC,CAAC;IAHW,QAAA,eAAe,mBAG1B","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"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
//
|
2
|
+
// Dev utils to detect if nodes have "autoFocus" props.
|
3
|
+
//
|
4
|
+
define(["require", "exports", "./getReactFiberFromNode"], function (require, exports, getReactFiberFromNode_1) {
|
5
|
+
"use strict";
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
exports.hasAutofocusFilter = void 0;
|
8
|
+
/**
|
9
|
+
* Detects if a passed HTML node has "autoFocus" prop on a React's fiber. Is needed as React handles autofocus behavior
|
10
|
+
* in React DOM and will not pass "autoFocus" to an actual HTML.
|
11
|
+
*
|
12
|
+
* @param node
|
13
|
+
*/
|
14
|
+
function hasAutofocusProp(node) {
|
15
|
+
var _a;
|
16
|
+
// https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
|
17
|
+
var isAutoFocusableElement = node.nodeName === 'BUTTON' ||
|
18
|
+
node.nodeName === 'INPUT' ||
|
19
|
+
node.nodeName === 'SELECT' ||
|
20
|
+
node.nodeName === 'TEXTAREA';
|
21
|
+
if (isAutoFocusableElement) {
|
22
|
+
return !!((_a = getReactFiberFromNode_1.getReactFiberFromNode(node)) === null || _a === void 0 ? void 0 : _a.pendingProps.autoFocus);
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
function hasAutofocusFilter(node) {
|
27
|
+
return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
28
|
+
}
|
29
|
+
exports.hasAutofocusFilter = hasAutofocusFilter;
|
30
|
+
});
|
31
|
+
//# sourceMappingURL=hasAutoFocusFilter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hasAutoFocusFilter.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/hasAutoFocusFilter.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,uDAAuD;AACvD,EAAE;;;;;IAIF;;;;;OAKG;IACH,SAAS,gBAAgB,CAAC,IAAU;;QAClC,gJAAgJ;QAChJ,IAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAC1B,IAAI,CAAC,QAAQ,KAAK,OAAO;YACzB,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAC1B,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC;QAE/B,IAAI,sBAAsB,EAAE;YAC1B,OAAO,CAAC,CAAC,CAAA,MAAA,6CAAqB,CAAC,IAAI,CAAC,0CAAE,YAAY,CAAC,SAAS,CAAA,CAAC;SAC9D;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAgB,kBAAkB,CAAC,IAAU;QAC3C,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;IACpF,CAAC;IAFD,gDAEC","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"]}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./parseFloatingUIPlacement", "./getBoundary", "./getReactFiberFromNode", "./getScrollParent", "./mergeArrowOffset", "./toFloatingUIPlacement", "./fromFloatingUIPlacement", "./resolvePositioningShorthand", "./useCallbackRef", "./debounce", "./toggleScrollListener", "./hasAutoFocusFilter", "./writeArrowUpdates", "./writeContainerupdates"], function (require, exports, tslib_1, parseFloatingUIPlacement_1, getBoundary_1, getReactFiberFromNode_1, getScrollParent_1, mergeArrowOffset_1, toFloatingUIPlacement_1, fromFloatingUIPlacement_1, resolvePositioningShorthand_1, useCallbackRef_1, debounce_1, toggleScrollListener_1, hasAutoFocusFilter_1, writeArrowUpdates_1, writeContainerupdates_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(parseFloatingUIPlacement_1, exports);
|
5
|
+
tslib_1.__exportStar(getBoundary_1, exports);
|
6
|
+
tslib_1.__exportStar(getReactFiberFromNode_1, exports);
|
7
|
+
tslib_1.__exportStar(getScrollParent_1, exports);
|
8
|
+
tslib_1.__exportStar(mergeArrowOffset_1, exports);
|
9
|
+
tslib_1.__exportStar(toFloatingUIPlacement_1, exports);
|
10
|
+
tslib_1.__exportStar(fromFloatingUIPlacement_1, exports);
|
11
|
+
tslib_1.__exportStar(resolvePositioningShorthand_1, exports);
|
12
|
+
tslib_1.__exportStar(useCallbackRef_1, exports);
|
13
|
+
tslib_1.__exportStar(debounce_1, exports);
|
14
|
+
tslib_1.__exportStar(toggleScrollListener_1, exports);
|
15
|
+
tslib_1.__exportStar(hasAutoFocusFilter_1, exports);
|
16
|
+
tslib_1.__exportStar(writeArrowUpdates_1, exports);
|
17
|
+
tslib_1.__exportStar(writeContainerupdates_1, exports);
|
18
|
+
});
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/index.ts"],"names":[],"mappings":";;;IAAA,0DAA2C;IAC3C,6CAA8B;IAC9B,uDAAwC;IACxC,iDAAkC;IAClC,kDAAmC;IACnC,uDAAwC;IACxC,yDAA0C;IAC1C,6DAA8C;IAC9C,gDAAiC;IACjC,0CAA2B;IAC3B,sDAAuC;IACvC,oDAAqC;IACrC,mDAAoC;IACpC,uDAAwC","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"]}
|