@fluentui/react-positioning 0.0.0-nightly0e0cf06c3420211029.1 → 0.0.0-nightly627ad67f1120211109.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +14 -8
- package/CHANGELOG.md +8 -7
- package/lib/createVirtualElementFromClick.js +9 -9
- package/lib/createVirtualElementFromClick.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.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/createVirtualElementFromClick.js +9 -9
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +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.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 +3 -3
@@ -1,34 +1,34 @@
|
|
1
|
-
|
1
|
+
const getPositionMap = (rtl) => ({
|
2
2
|
above: 'top',
|
3
3
|
below: 'bottom',
|
4
4
|
before: rtl ? 'right' : 'left',
|
5
5
|
after: rtl ? 'left' : 'right',
|
6
|
-
});
|
7
|
-
|
6
|
+
});
|
7
|
+
const getAlignmentMap = (rtl) => ({
|
8
8
|
start: rtl ? 'end' : 'start',
|
9
9
|
end: rtl ? 'start' : 'end',
|
10
10
|
top: 'start',
|
11
11
|
bottom: 'end',
|
12
12
|
center: '',
|
13
|
-
});
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
});
|
14
|
+
const shouldAlignToCenter = (p, a) => {
|
15
|
+
const positionedVertically = p === 'above' || p === 'below';
|
16
|
+
const alignedVertically = a === 'top' || a === 'bottom';
|
17
17
|
return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);
|
18
18
|
};
|
19
19
|
/**
|
20
20
|
* @see positioninHelper.test.ts for expected placement values
|
21
21
|
*/
|
22
|
-
export
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
export const getPlacement = (align, position, rtl) => {
|
23
|
+
const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
|
24
|
+
const computedPosition = position && getPositionMap(rtl)[position];
|
25
|
+
const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
|
26
26
|
if (computedPosition && computedAlignmnent) {
|
27
|
-
return computedPosition
|
27
|
+
return `${computedPosition}-${computedAlignmnent}`;
|
28
28
|
}
|
29
29
|
return computedPosition || 'auto';
|
30
30
|
};
|
31
|
-
export
|
31
|
+
export const applyRtlToOffset = (offset) => {
|
32
32
|
if (typeof offset === 'undefined') {
|
33
33
|
return undefined;
|
34
34
|
}
|
@@ -36,6 +36,6 @@ export var applyRtlToOffset = function (offset) {
|
|
36
36
|
offset[0] = offset[0] * -1;
|
37
37
|
return offset;
|
38
38
|
}
|
39
|
-
return (
|
39
|
+
return ((param) => applyRtlToOffset(offset(param)));
|
40
40
|
};
|
41
41
|
//# 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,GAAG,CAAC,GAAa,EAAqC,EAAE,CAAC,CAAC;IAC7E,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;IAC1B,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,EAAE;CACX,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,CAAY,EAAE,CAAa,EAAW,EAAE;IACnE,MAAM,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AC7F,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolvePositioningShorthand.js","sourceRoot":"","sources":["../../src/utils/resolvePositioningShorthand.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,
|
1
|
+
{"version":3,"file":"resolvePositioningShorthand.js","sourceRoot":"","sources":["../../src/utils/resolvePositioningShorthand.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,MAAM,eAAe,GAAoF;IACvG,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC7C,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IACpD,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;IAChD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC7C,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IACpD,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;IAChD,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC/C,YAAY,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;IAClD,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACxD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC7C,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;IAChD,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;CACvD,CAAC;AAEF,MAAM,UAAU,2BAA2B,CACzC,SAAkD;IAElD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE;QACjD,OAAO,EAAE,CAAC;KACX;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;KACnC;IAED,OAAO,SAAuC,CAAC;AACjD,CAAC"}
|
@@ -18,19 +18,19 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
18
18
|
* // prints 0 -> 1
|
19
19
|
*/
|
20
20
|
export function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
21
|
-
|
22
|
-
|
21
|
+
const isFirst = React.useRef(true);
|
22
|
+
const [ref] = React.useState(() => ({
|
23
23
|
// value
|
24
24
|
value: initialValue,
|
25
25
|
// last callback
|
26
|
-
callback
|
26
|
+
callback,
|
27
27
|
// "memoized" public interface
|
28
28
|
facade: {
|
29
29
|
get current() {
|
30
30
|
return ref.value;
|
31
31
|
},
|
32
32
|
set current(value) {
|
33
|
-
|
33
|
+
const last = ref.value;
|
34
34
|
if (last !== value) {
|
35
35
|
ref.value = value;
|
36
36
|
if (skipInitialResolve && isFirst.current) {
|
@@ -40,8 +40,8 @@ export function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
|
40
40
|
}
|
41
41
|
},
|
42
42
|
},
|
43
|
-
})
|
44
|
-
useIsomorphicLayoutEffect(
|
43
|
+
}));
|
44
|
+
useIsomorphicLayoutEffect(() => {
|
45
45
|
isFirst.current = false;
|
46
46
|
}, []);
|
47
47
|
// update callback
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,
|
1
|
+
{"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;QAClC,QAAQ;QACR,KAAK,EAAE,YAAY;QACnB,gBAAgB;QAChB,QAAQ;QACR,8BAA8B;QAC9B,MAAM,EAAE;YACN,IAAI,OAAO;gBACT,OAAO,GAAG,CAAC,KAAK,CAAC;YACnB,CAAC;YACD,IAAI,OAAO,CAAC,KAAK;gBACf,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;gBAEvB,IAAI,IAAI,KAAK,KAAK,EAAE;oBAClB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;oBAElB,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE;wBACzC,OAAO;qBACR;oBAED,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBAC3B;YACH,CAAC;SACF;KACF,CAAC,CAAC,CAAC;IAEJ,yBAAyB,CAAC,GAAG,EAAE;QAC7B,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,kBAAkB;IAClB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAExB,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC"}
|
@@ -6,22 +6,22 @@ exports.createVirtualElementFromClick = void 0;
|
|
6
6
|
* Can be used as a target for popper in scenarios such as context menus
|
7
7
|
*/
|
8
8
|
function createVirtualElementFromClick(nativeEvent) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
const left = nativeEvent.clientX;
|
10
|
+
const top = nativeEvent.clientY;
|
11
|
+
const right = left + 1;
|
12
|
+
const bottom = top + 1;
|
13
13
|
function getBoundingClientRect() {
|
14
14
|
return {
|
15
|
-
left
|
16
|
-
top
|
17
|
-
right
|
18
|
-
bottom
|
15
|
+
left,
|
16
|
+
top,
|
17
|
+
right,
|
18
|
+
bottom,
|
19
19
|
height: 1,
|
20
20
|
width: 1,
|
21
21
|
};
|
22
22
|
}
|
23
23
|
return {
|
24
|
-
getBoundingClientRect
|
24
|
+
getBoundingClientRect,
|
25
25
|
};
|
26
26
|
}
|
27
27
|
exports.createVirtualElementFromClick = createVirtualElementFromClick;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createVirtualElementFromClick.js","sourceRoot":"","sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,WAAuB;IACnE,
|
1
|
+
{"version":3,"file":"createVirtualElementFromClick.js","sourceRoot":"","sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,WAAuB;IACnE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC;IACjC,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC;IACvB,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;IAEvB,SAAS,qBAAqB;QAC5B,OAAO;YACL,IAAI;YACJ,GAAG;YACH,KAAK;YACL,MAAM;YAEN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,qBAAqB;KACtB,CAAC;AACJ,CAAC;AArBD,sEAqBC"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.mergeArrowOffset = exports.resolvePositioningShorthand = void 0;
|
4
|
-
|
4
|
+
const tslib_1 = require("tslib");
|
5
5
|
tslib_1.__exportStar(require("./usePopper"), exports);
|
6
6
|
tslib_1.__exportStar(require("./createVirtualElementFromClick"), exports);
|
7
7
|
tslib_1.__exportStar(require("./usePopperMouseTarget"), exports);
|
@@ -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":"","sources":["../src/usePopper.ts"],"names":[],"mappings":";;;AAAA,+DAAkH;AAClH,2EAA4D;AAC5D,yCAQuB;AACvB,2CAA2C;AAC3C,+BAA+B;AA4B/B,EAAE;AACF,uDAAuD;AACvD,EAAE;AAEF;;;GAGG;AACH,SAAS,gBAAgB,CAAC,IAAU;;IAClC,gJAAgJ;IAChJ,MAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAC1B,IAAI,CAAC,QAAQ,KAAK,OAAO;QACzB,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAC1B,IAAI,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BACX,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"}
|