@fluentui/react-positioning 0.0.0-nightlya372ad979820211103.1 → 0.0.0-nightlya54302c0b220211124.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +45 -10
- package/CHANGELOG.md +18 -7
- package/dist/react-positioning.d.ts +28 -0
- package/lib/createArrowStyles.d.ts +27 -0
- package/lib/createArrowStyles.js +75 -0
- package/lib/createArrowStyles.js.map +1 -0
- package/lib/createVirtualElementFromClick.js +9 -9
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/usePopper.js +64 -71
- package/lib/usePopper.js.map +1 -1
- package/lib/usePopperMouseTarget.js +5 -5
- package/lib/usePopperMouseTarget.js.map +1 -1
- package/lib/utils/getBoundary.js +1 -1
- package/lib/utils/getReactFiberFromNode.d.ts +0 -1
- package/lib/utils/getReactFiberFromNode.js +1 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +6 -6
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +5 -5
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/positioningHelper.d.ts +1 -1
- package/lib/utils/positioningHelper.js +14 -14
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/useCallbackRef.js +6 -6
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createArrowStyles.d.ts +27 -0
- package/lib-commonjs/createArrowStyles.js +79 -0
- package/lib-commonjs/createArrowStyles.js.map +1 -0
- package/lib-commonjs/createVirtualElementFromClick.js +9 -9
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.d.ts +2 -1
- package/lib-commonjs/index.js +3 -2
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/usePopper.js +69 -76
- package/lib-commonjs/usePopper.js.map +1 -1
- package/lib-commonjs/usePopperMouseTarget.js +7 -7
- package/lib-commonjs/usePopperMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +2 -2
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +6 -6
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.js +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +5 -5
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/positioningHelper.d.ts +1 -1
- package/lib-commonjs/utils/positioningHelper.js +14 -14
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +8 -8
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +4 -4
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.usePopper = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
const react_utilities_1 = require("@fluentui/react-utilities");
|
5
|
+
const react_shared_contexts_1 = require("@fluentui/react-shared-contexts");
|
6
|
+
const index_1 = require("./utils/index");
|
7
|
+
const PopperJs = require("@popperjs/core");
|
8
|
+
const React = require("react");
|
9
9
|
//
|
10
10
|
// Dev utils to detect if nodes have "autoFocus" props.
|
11
11
|
//
|
@@ -16,7 +16,7 @@ var React = require("react");
|
|
16
16
|
function hasAutofocusProp(node) {
|
17
17
|
var _a;
|
18
18
|
// https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
|
19
|
-
|
19
|
+
const isAutoFocusableElement = node.nodeName === 'BUTTON' ||
|
20
20
|
node.nodeName === 'INPUT' ||
|
21
21
|
node.nodeName === 'SELECT' ||
|
22
22
|
node.nodeName === 'TEXTAREA';
|
@@ -36,33 +36,30 @@ function hasAutofocusFilter(node) {
|
|
36
36
|
* that can't be resolved properly during an initial rendering.
|
37
37
|
*/
|
38
38
|
function usePopperOptions(options, popperOriginalPositionRef) {
|
39
|
-
|
39
|
+
const { arrowPadding, autoSize, coverTarget, flipBoundary, offset, onStateUpdate, overflowBoundary,
|
40
40
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
41
|
-
unstable_disableTether
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
var state = _a.state;
|
41
|
+
unstable_disableTether, pinned, } = options;
|
42
|
+
const isRtl = react_shared_contexts_1.useFluent().dir === 'rtl';
|
43
|
+
const placement = index_1.getPlacement(options.align, options.position, isRtl);
|
44
|
+
const strategy = options.positionFixed ? 'fixed' : 'absolute';
|
45
|
+
const handleStateUpdate = react_utilities_1.useEventCallback(({ state }) => {
|
47
46
|
if (onStateUpdate) {
|
48
47
|
onStateUpdate(state);
|
49
48
|
}
|
50
49
|
});
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
}, [offset, isRtl]);
|
59
|
-
return React.useCallback(function (target, container, arrow) {
|
50
|
+
const offsetModifier = React.useMemo(() => offset
|
51
|
+
? {
|
52
|
+
name: 'offset',
|
53
|
+
options: { offset: isRtl ? index_1.applyRtlToOffset(offset) : offset },
|
54
|
+
}
|
55
|
+
: null, [offset, isRtl]);
|
56
|
+
return React.useCallback((target, container, arrow) => {
|
60
57
|
var _a;
|
61
|
-
|
62
|
-
|
58
|
+
const scrollParentElement = index_1.getScrollParent(container);
|
59
|
+
const hasScrollableElement = scrollParentElement
|
63
60
|
? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body)
|
64
61
|
: false;
|
65
|
-
|
62
|
+
const modifiers = [
|
66
63
|
/**
|
67
64
|
* We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content
|
68
65
|
* with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of
|
@@ -72,15 +69,14 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
72
69
|
name: 'positionStyleFix',
|
73
70
|
enabled: true,
|
74
71
|
phase: 'afterWrite',
|
75
|
-
effect:
|
76
|
-
var state = _a.state, instance = _a.instance;
|
72
|
+
effect: ({ state, instance }) => {
|
77
73
|
// ".isFirstRun" is a part of our patch, on a first evaluation it will "undefined"
|
78
74
|
// should be disabled for subsequent runs as it breaks positioning for them
|
79
75
|
if (instance.isFirstRun !== false) {
|
80
76
|
popperOriginalPositionRef.current = state.elements.popper.style.position;
|
81
77
|
state.elements.popper.style.position = 'fixed';
|
82
78
|
}
|
83
|
-
return
|
79
|
+
return () => undefined;
|
84
80
|
},
|
85
81
|
requires: [],
|
86
82
|
},
|
@@ -142,25 +138,24 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
142
138
|
altBoundary: true,
|
143
139
|
boundary: index_1.getBoundary(container, overflowBoundary),
|
144
140
|
},
|
145
|
-
fn:
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
var applyMaxWidth = autoSize === 'always' ||
|
141
|
+
fn({ state, options: modifierOptions }) {
|
142
|
+
const overflow = PopperJs.detectOverflow(state, modifierOptions);
|
143
|
+
const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };
|
144
|
+
const { width, height } = state.rects.popper;
|
145
|
+
const basePlacement = index_1.getBasePlacement(state.placement);
|
146
|
+
const widthProp = basePlacement === 'left' ? 'left' : 'right';
|
147
|
+
const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
|
148
|
+
const applyMaxWidth = autoSize === 'always' ||
|
154
149
|
autoSize === 'width-always' ||
|
155
150
|
(overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));
|
156
|
-
|
151
|
+
const applyMaxHeight = autoSize === 'always' ||
|
157
152
|
autoSize === 'height-always' ||
|
158
153
|
(overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));
|
159
154
|
if (applyMaxWidth) {
|
160
|
-
state.styles.popper.maxWidth = width - overflow[widthProp] - x
|
155
|
+
state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;
|
161
156
|
}
|
162
157
|
if (applyMaxHeight) {
|
163
|
-
state.styles.popper.maxHeight = height - overflow[heightProp] - y
|
158
|
+
state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;
|
164
159
|
}
|
165
160
|
},
|
166
161
|
},
|
@@ -181,9 +176,8 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
181
176
|
enabled: !!coverTarget,
|
182
177
|
phase: 'main',
|
183
178
|
requiresIfExists: ['offset', 'preventOverflow', 'flip'],
|
184
|
-
fn
|
185
|
-
|
186
|
-
var basePlacement = index_1.getBasePlacement(state.placement);
|
179
|
+
fn({ state }) {
|
180
|
+
const basePlacement = index_1.getBasePlacement(state.placement);
|
187
181
|
switch (basePlacement) {
|
188
182
|
case 'bottom':
|
189
183
|
state.modifiersData.popperOffsets.y -= state.rects.reference.height;
|
@@ -201,11 +195,11 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
201
195
|
},
|
202
196
|
},
|
203
197
|
].filter(Boolean); // filter boolean conditional spreading values
|
204
|
-
|
205
|
-
modifiers
|
206
|
-
placement
|
207
|
-
strategy
|
208
|
-
onFirstUpdate:
|
198
|
+
const popperOptions = {
|
199
|
+
modifiers,
|
200
|
+
placement,
|
201
|
+
strategy,
|
202
|
+
onFirstUpdate: state => handleStateUpdate({ state }),
|
209
203
|
};
|
210
204
|
return popperOptions;
|
211
205
|
}, [
|
@@ -232,19 +226,18 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
232
226
|
* - contains a specific to React fix related to initial positioning when containers have components with managed focus
|
233
227
|
* to avoid focus jumps
|
234
228
|
*/
|
235
|
-
function usePopper(options) {
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
var handlePopperUpdate = react_utilities_1.useEventCallback(function () {
|
229
|
+
function usePopper(options = {}) {
|
230
|
+
const { enabled = true } = options;
|
231
|
+
const isFirstMount = react_utilities_1.useFirstMount();
|
232
|
+
const popperOriginalPositionRef = React.useRef('absolute');
|
233
|
+
const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);
|
234
|
+
const popperInstanceRef = React.useRef(null);
|
235
|
+
const handlePopperUpdate = react_utilities_1.useEventCallback(() => {
|
243
236
|
var _a;
|
244
237
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
245
238
|
popperInstanceRef.current = null;
|
246
|
-
|
247
|
-
|
239
|
+
const { target = targetRef.current } = options;
|
240
|
+
let popperInstance = null;
|
248
241
|
if (react_utilities_1.canUseDOM() && enabled) {
|
249
242
|
if (target && containerRef.current) {
|
250
243
|
popperInstance = PopperJs.createPopper(target, containerRef.current, resolvePopperOptions(target, containerRef.current, arrowRef.current));
|
@@ -255,14 +248,14 @@ function usePopper(options) {
|
|
255
248
|
* The patch updates `.forceUpdate()` Popper function which restores the original position before the first
|
256
249
|
* forceUpdate() call. See also "positionStyleFix" modifier in usePopperOptions().
|
257
250
|
*/
|
258
|
-
|
251
|
+
const originalForceUpdate = popperInstance.forceUpdate;
|
259
252
|
popperInstance.isFirstRun = true;
|
260
|
-
popperInstance.forceUpdate =
|
253
|
+
popperInstance.forceUpdate = () => {
|
261
254
|
if (popperInstance === null || popperInstance === void 0 ? void 0 : popperInstance.isFirstRun) {
|
262
255
|
popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;
|
263
256
|
popperInstance.isFirstRun = false;
|
264
257
|
}
|
265
|
-
|
258
|
+
originalForceUpdate();
|
266
259
|
};
|
267
260
|
}
|
268
261
|
popperInstanceRef.current = popperInstance;
|
@@ -287,24 +280,24 @@ function usePopper(options) {
|
|
287
280
|
//
|
288
281
|
// This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation
|
289
282
|
// to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
React.useImperativeHandle(options.popperRef,
|
294
|
-
updatePosition:
|
283
|
+
const targetRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
|
284
|
+
const containerRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
|
285
|
+
const arrowRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
|
286
|
+
React.useImperativeHandle(options.popperRef, () => ({
|
287
|
+
updatePosition: () => {
|
295
288
|
var _a;
|
296
289
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
297
290
|
},
|
298
|
-
})
|
299
|
-
react_utilities_1.useIsomorphicLayoutEffect(
|
291
|
+
}), []);
|
292
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
300
293
|
handlePopperUpdate();
|
301
|
-
return
|
294
|
+
return () => {
|
302
295
|
var _a;
|
303
296
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
304
297
|
popperInstanceRef.current = null;
|
305
298
|
};
|
306
299
|
}, [handlePopperUpdate, options.enabled, options.target]);
|
307
|
-
react_utilities_1.useIsomorphicLayoutEffect(
|
300
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
308
301
|
var _a;
|
309
302
|
if (!isFirstMount) {
|
310
303
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setOptions(resolvePopperOptions(options.target || targetRef.current, containerRef.current, arrowRef.current));
|
@@ -319,15 +312,15 @@ function usePopper(options) {
|
|
319
312
|
if (process.env.NODE_ENV !== 'production') {
|
320
313
|
// This checked should run only in development mode
|
321
314
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
322
|
-
React.useEffect(
|
315
|
+
React.useEffect(() => {
|
323
316
|
var _a;
|
324
317
|
if (containerRef.current) {
|
325
|
-
|
326
|
-
|
318
|
+
const contentNode = containerRef.current;
|
319
|
+
const treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
|
327
320
|
acceptNode: hasAutofocusFilter,
|
328
321
|
});
|
329
322
|
while (treeWalker === null || treeWalker === void 0 ? void 0 : treeWalker.nextNode()) {
|
330
|
-
|
323
|
+
const node = treeWalker.currentNode;
|
331
324
|
// eslint-disable-next-line no-console
|
332
325
|
console.warn('<Popper>:', node);
|
333
326
|
// eslint-disable-next-line no-console
|
@@ -341,7 +334,7 @@ function usePopper(options) {
|
|
341
334
|
'(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',
|
342
335
|
'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by',
|
343
336
|
'"Popper".',
|
344
|
-
|
337
|
+
`In general, it's not recommended to use "autoFocus" as it may break accessibility aspects:`,
|
345
338
|
'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',
|
346
339
|
'\n',
|
347
340
|
'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use',
|
@@ -355,7 +348,7 @@ function usePopper(options) {
|
|
355
348
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
356
349
|
}, []);
|
357
350
|
}
|
358
|
-
return { targetRef
|
351
|
+
return { targetRef, containerRef, arrowRef };
|
359
352
|
}
|
360
353
|
exports.usePopper = usePopper;
|
361
354
|
//# sourceMappingURL=usePopper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePopper.js","sourceRoot":"","sources":["../src/usePopper.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"usePopper.js","sourceRoot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OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,IAAI;oBAC7B,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;oBACpC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAChC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CACV;wBACE,gGAAgG;wBAChG,qGAAqG;wBACrG,2EAA2E;wBAC3E,uEAAuE;wBACvE,IAAI;wBACJ,yFAAyF;wBACzF,oGAAoG;wBACpG,kGAAkG;wBAClG,WAAW;wBACX,4FAA4F;wBAC5F,6FAA6F;wBAC7F,IAAI;wBACJ,2FAA2F;wBAC3F,2CAA2C;wBAC3C,8EAA8E;qBAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;iBACH;aACF;YACD,mDAAmD;YACnD,0EAA0E;YAC1E,uDAAuD;QACzD,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC;AAlKD,8BAkKC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.usePopperMouseTarget = void 0;
|
4
|
-
|
5
|
-
|
4
|
+
const React = require("react");
|
5
|
+
const createVirtualElementFromClick_1 = require("./createVirtualElementFromClick");
|
6
6
|
/**
|
7
7
|
* A state hook that manages a popper virtual element from mouseevents.
|
8
8
|
* Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
|
@@ -11,14 +11,14 @@ var createVirtualElementFromClick_1 = require("./createVirtualElementFromClick")
|
|
11
11
|
* @param initialState - initializes a user provided state similare to useState
|
12
12
|
* @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
|
13
13
|
*/
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
const usePopperMouseTarget = (initialState) => {
|
15
|
+
const [virtualElement, setVirtualElement] = React.useState(initialState);
|
16
|
+
const setVirtualMouseTarget = (event) => {
|
17
17
|
if (event === undefined || event === null) {
|
18
18
|
setVirtualElement(undefined);
|
19
19
|
return;
|
20
20
|
}
|
21
|
-
|
21
|
+
let mouseevent;
|
22
22
|
if (!(event instanceof MouseEvent)) {
|
23
23
|
mouseevent = event.nativeEvent;
|
24
24
|
}
|
@@ -29,7 +29,7 @@ var usePopperMouseTarget = function (initialState) {
|
|
29
29
|
// eslint-disable-next-line no-console
|
30
30
|
console.error('usePopperMouseTarget should only be used with MouseEvent');
|
31
31
|
}
|
32
|
-
|
32
|
+
const contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
|
33
33
|
setVirtualElement(contextTarget);
|
34
34
|
};
|
35
35
|
return [virtualElement, setVirtualMouseTarget];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePopperMouseTarget.js","sourceRoot":"","sources":["../src/usePopperMouseTarget.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"usePopperMouseTarget.js","sourceRoot":"","sources":["../src/usePopperMouseTarget.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,mFAAgF;AAGhF;;;;;;;GAOG;AACI,MAAM,oBAAoB,GAAG,CAAC,YAAwE,EAAE,EAAE;IAC/G,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAsC,YAAY,CAAC,CAAC;IAE9G,MAAM,qBAAqB,GAAG,CAAC,KAAuD,EAAE,EAAE;QACxF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACzC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC7B,OAAO;SACR;QAED,IAAI,UAAsB,CAAC;QAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;SAChC;aAAM;YACL,UAAU,GAAG,KAAK,CAAC;SACpB;QAED,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YAChF,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;SAC3E;QAED,MAAM,aAAa,GAAG,6DAA6B,CAAC,UAAU,CAAC,CAAC;QAChE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAC;AAC1D,CAAC,CAAC;AA1BW,QAAA,oBAAoB,wBA0B/B"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getBoundary = void 0;
|
4
|
-
|
4
|
+
const getScrollParent_1 = require("./getScrollParent");
|
5
5
|
/**
|
6
6
|
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
7
7
|
*/
|
@@ -10,7 +10,7 @@ function getBoundary(element, boundary) {
|
|
10
10
|
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
11
11
|
}
|
12
12
|
if (boundary === 'scrollParent') {
|
13
|
-
|
13
|
+
let boundariesNode = getScrollParent_1.getScrollParent(element);
|
14
14
|
if (boundariesNode.nodeName === 'BODY') {
|
15
15
|
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
16
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../src/utils/getBoundary.ts"],"names":[],"mappings":";;;AAEA,
|
1
|
+
{"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../src/utils/getBoundary.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AAGpD;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;KAChD;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,cAAc,GAA4B,iCAAe,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;YACtC,cAAc,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;SAC1D;QAED,OAAO,cAAc,CAAC;KACvB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhBD,kCAgBC"}
|
@@ -30,7 +30,7 @@ function getReactFiberFromNode(elm) {
|
|
30
30
|
if (!elm) {
|
31
31
|
return null;
|
32
32
|
}
|
33
|
-
for (
|
33
|
+
for (const k in elm) {
|
34
34
|
// React 16 uses "__reactInternalInstance$" prefix
|
35
35
|
// React 17 uses "__reactFiber$" prefix
|
36
36
|
// https://github.com/facebook/react/pull/18377
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,SAAgB,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,
|
1
|
+
{"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,SAAgB,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE;QACnB,kDAAkD;QAClD,uCAAuC;QACvC,+CAA+C;QAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YACnF,6DAA6D;YAC7D,aAAa;YACb,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACf;KACF;IAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC7E,CAAC;AAjBD,sDAiBC"}
|
@@ -6,7 +6,7 @@ exports.getScrollParent = exports.getParentNode = void 0;
|
|
6
6
|
* @param node - DOM node.
|
7
7
|
* @returns - parent DOM node.
|
8
8
|
*/
|
9
|
-
|
9
|
+
const getParentNode = (node) => {
|
10
10
|
if (node.nodeName === 'HTML') {
|
11
11
|
return node;
|
12
12
|
}
|
@@ -19,12 +19,12 @@ exports.getParentNode = getParentNode;
|
|
19
19
|
* @param node - DOM node.
|
20
20
|
* @returns - CSS styles.
|
21
21
|
*/
|
22
|
-
|
22
|
+
const getStyleComputedProperty = (node) => {
|
23
23
|
var _a;
|
24
24
|
if (node.nodeType !== 1) {
|
25
25
|
return {};
|
26
26
|
}
|
27
|
-
|
27
|
+
const window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
28
28
|
return window.getComputedStyle(node, null);
|
29
29
|
};
|
30
30
|
/**
|
@@ -32,9 +32,9 @@ var getStyleComputedProperty = function (node) {
|
|
32
32
|
* @param node - DOM node.
|
33
33
|
* @returns - the first scrollable parent.
|
34
34
|
*/
|
35
|
-
|
35
|
+
const getScrollParent = (node) => {
|
36
36
|
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
37
|
-
|
37
|
+
const parentNode = node && exports.getParentNode(node);
|
38
38
|
// eslint-disable-next-line
|
39
39
|
if (!parentNode)
|
40
40
|
return document.body;
|
@@ -46,7 +46,7 @@ var getScrollParent = function (node) {
|
|
46
46
|
return parentNode.body;
|
47
47
|
}
|
48
48
|
// If any of the overflow props is defined for the node then we return it as the parent
|
49
|
-
|
49
|
+
const { overflow, overflowX, overflowY } = getStyleComputedProperty(parentNode);
|
50
50
|
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
51
51
|
return parentNode;
|
52
52
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,
|
1
|
+
{"version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E;QACpE,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,uBAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC;AArBW,QAAA,eAAe,mBAqB1B"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
3
|
+
const tslib_1 = require("tslib");
|
4
4
|
tslib_1.__exportStar(require("./getBasePlacement"), exports);
|
5
5
|
tslib_1.__exportStar(require("./getBoundary"), exports);
|
6
6
|
tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
|
@@ -10,7 +10,7 @@ exports.mergeArrowOffset = void 0;
|
|
10
10
|
* @returns User offset augmented with arrow height
|
11
11
|
*/
|
12
12
|
function mergeArrowOffset(userOffset, arrowHeight) {
|
13
|
-
|
13
|
+
let offsetWithArrow = userOffset;
|
14
14
|
if (!userOffset) {
|
15
15
|
return [0, arrowHeight];
|
16
16
|
}
|
@@ -19,9 +19,9 @@ function mergeArrowOffset(userOffset, arrowHeight) {
|
|
19
19
|
return offsetWithArrow;
|
20
20
|
}
|
21
21
|
if (typeof offsetWithArrow === 'function') {
|
22
|
-
|
23
|
-
offsetWithArrow =
|
24
|
-
|
22
|
+
const userOffsetFn = offsetWithArrow;
|
23
|
+
offsetWithArrow = offsetParams => {
|
24
|
+
const offset = userOffsetFn(offsetParams);
|
25
25
|
setArrowOffset(offset, arrowHeight);
|
26
26
|
return offset;
|
27
27
|
};
|
@@ -30,7 +30,7 @@ function mergeArrowOffset(userOffset, arrowHeight) {
|
|
30
30
|
return [0, 0];
|
31
31
|
}
|
32
32
|
exports.mergeArrowOffset = mergeArrowOffset;
|
33
|
-
|
33
|
+
const setArrowOffset = (offset, arrowHeight) => {
|
34
34
|
if (offset[1] !== null && offset[1] !== undefined) {
|
35
35
|
offset[1] += arrowHeight;
|
36
36
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mergeArrowOffset.js","sourceRoot":"","sources":["../../src/utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,UAAqC,EAAE,WAAmB;IACzF,IAAI,eAAe,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;KACzB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAClC,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAC7C,OAAO,eAAe,CAAC;KACxB;IAED,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;QACzC,
|
1
|
+
{"version":3,"file":"mergeArrowOffset.js","sourceRoot":"","sources":["../../src/utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,UAAqC,EAAE,WAAmB;IACzF,IAAI,eAAe,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;KACzB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAClC,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAC7C,OAAO,eAAe,CAAC;KACxB;IAED,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;QACzC,MAAM,YAAY,GAAG,eAAe,CAAC;QACrC,eAAe,GAAG,YAAY,CAAC,EAAE;YAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;YAC1C,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACpC,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAU,CAAC;AACzB,CAAC;AAtBD,4CAsBC;AAED,MAAM,cAAc,GAAG,CAAC,MAA8D,EAAE,WAAmB,EAAE,EAAE;IAC7G,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACjD,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;KAC1B;SAAM;QACL,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;KACzB;AACH,CAAC,CAAC"}
|
@@ -3,5 +3,5 @@ import type { Offset } from '../types';
|
|
3
3
|
/**
|
4
4
|
* @see positioninHelper.test.ts for expected placement values
|
5
5
|
*/
|
6
|
-
export declare const getPlacement: (align?: "
|
6
|
+
export declare const getPlacement: (align?: "bottom" | "top" | "center" | "start" | "end" | undefined, position?: "above" | "below" | "before" | "after" | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
|
7
7
|
export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
|
@@ -1,38 +1,38 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.applyRtlToOffset = exports.getPlacement = void 0;
|
4
|
-
|
4
|
+
const getPositionMap = (rtl) => ({
|
5
5
|
above: 'top',
|
6
6
|
below: 'bottom',
|
7
7
|
before: rtl ? 'right' : 'left',
|
8
8
|
after: rtl ? 'left' : 'right',
|
9
|
-
});
|
10
|
-
|
9
|
+
});
|
10
|
+
const getAlignmentMap = (rtl) => ({
|
11
11
|
start: rtl ? 'end' : 'start',
|
12
12
|
end: rtl ? 'start' : 'end',
|
13
13
|
top: 'start',
|
14
14
|
bottom: 'end',
|
15
15
|
center: '',
|
16
|
-
});
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
});
|
17
|
+
const shouldAlignToCenter = (p, a) => {
|
18
|
+
const positionedVertically = p === 'above' || p === 'below';
|
19
|
+
const alignedVertically = a === 'top' || a === 'bottom';
|
20
20
|
return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);
|
21
21
|
};
|
22
22
|
/**
|
23
23
|
* @see positioninHelper.test.ts for expected placement values
|
24
24
|
*/
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
const getPlacement = (align, position, rtl) => {
|
26
|
+
const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
|
27
|
+
const computedPosition = position && getPositionMap(rtl)[position];
|
28
|
+
const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
|
29
29
|
if (computedPosition && computedAlignmnent) {
|
30
|
-
return computedPosition
|
30
|
+
return `${computedPosition}-${computedAlignmnent}`;
|
31
31
|
}
|
32
32
|
return computedPosition || 'auto';
|
33
33
|
};
|
34
34
|
exports.getPlacement = getPlacement;
|
35
|
-
|
35
|
+
const applyRtlToOffset = (offset) => {
|
36
36
|
if (typeof offset === 'undefined') {
|
37
37
|
return undefined;
|
38
38
|
}
|
@@ -40,7 +40,7 @@ var applyRtlToOffset = function (offset) {
|
|
40
40
|
offset[0] = offset[0] * -1;
|
41
41
|
return offset;
|
42
42
|
}
|
43
|
-
return (
|
43
|
+
return ((param) => exports.applyRtlToOffset(offset(param)));
|
44
44
|
};
|
45
45
|
exports.applyRtlToOffset = applyRtlToOffset;
|
46
46
|
//# sourceMappingURL=positioningHelper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":";;;AAMA,
|
1
|
+
{"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":";;;AAMA,MAAM,cAAc,GAAG,CAAC,GAAa,EAAuC,EAAE,CAAC,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;IAC9B,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;CAC9B,CAAC,CAAC;AAEH,MAAM,eAAe,GAA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