@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
@@ -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":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,IAAiB,EAAe,EAAE;IAC9D,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,OAAO,IAAI,CAAC,UAAU,IAAK,IAAY,CAAC,IAAI,CAAC;AAC/C,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB;AAEF;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,IAAiB,EAAgC,EAAE;;IACnF,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,MAAM,SAAG,IAAI,CAAC,aAAa,0CAAE,WAAW,CAAC;IAC/C,OAAO,MAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,IAAmC,EAAe,EAAE;IAClF,iFAAiF;IACjF,MAAM,UAAU,GAAG,IAAI,IAAI,qBAAa,CAAC,IAAmB,CAAC,CAAC;IAC9D,2BAA2B;IAC3B,IAAI,CAAC,UAAU;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IAEtC,QAAQ,UAAU,CAAC,QAAQ,EAAE;QAC3B,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,UAAU,CAAC,aAAc,CAAC,IAAI,CAAC;QACxC,KAAK,WAAW;YACd,OAAS,UAAmC,CAAC,IAAI,CAAC;KACrD;IAED,uFAAuF;IACvF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAChF,IAAI,uBAAuB,CAAC,IAAI,CAAC,QAAS,GAAG,SAAU,GAAG,SAAS,CAAC,EAAE;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"}
|
@@ -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,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,oBAAoB,GAAG,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO,CAAC;IAC5D,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,QAAQ,CAAC;IAExD,OAAO,CAAC,oBAAoB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,oBAAoB,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACtG,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,YAAY,GAAG,CAAC,KAAiB,EAAE,QAAmB,EAAE,GAAa,EAAsB,EAAE;IACxG,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAE1E,MAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACnE,MAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;IAExE,IAAI,gBAAgB,IAAI,kBAAkB,EAAE;QAC1C,OAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAwB,CAAC;KAC1E;IAED,OAAO,gBAAgB,IAAK,MAA6B,CAAC;AAC5D,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB;AAEK,MAAM,gBAAgB,GAAG,CAAC,MAA0B,EAAsB,EAAE;IACjF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;QAE5B,OAAO,MAAM,CAAC;KACf;IAED,OAAO,CAAC,CAAC,KAA0B,EAAE,EAAE,CAAC,wBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAmB,CAAC;AAC7F,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B"}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.resolvePositioningShorthand = void 0;
|
4
4
|
// Look up table for shorthand to avoid parsing strings
|
5
|
-
|
5
|
+
const shorthandLookup = {
|
6
6
|
above: { position: 'above', align: 'center' },
|
7
7
|
'above-start': { position: 'above', align: 'start' },
|
8
8
|
'above-end': { position: 'above', align: 'end' },
|
@@ -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,SAAgB,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;AAZD,kEAYC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.useCallbackRef = void 0;
|
4
|
-
|
5
|
-
|
4
|
+
const React = require("react");
|
5
|
+
const react_utilities_1 = require("@fluentui/react-utilities");
|
6
6
|
/**
|
7
7
|
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
8
8
|
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
@@ -21,19 +21,19 @@ var react_utilities_1 = require("@fluentui/react-utilities");
|
|
21
21
|
* // prints 0 -> 1
|
22
22
|
*/
|
23
23
|
function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
24
|
-
|
25
|
-
|
24
|
+
const isFirst = React.useRef(true);
|
25
|
+
const [ref] = React.useState(() => ({
|
26
26
|
// value
|
27
27
|
value: initialValue,
|
28
28
|
// last callback
|
29
|
-
callback
|
29
|
+
callback,
|
30
30
|
// "memoized" public interface
|
31
31
|
facade: {
|
32
32
|
get current() {
|
33
33
|
return ref.value;
|
34
34
|
},
|
35
35
|
set current(value) {
|
36
|
-
|
36
|
+
const last = ref.value;
|
37
37
|
if (last !== value) {
|
38
38
|
ref.value = value;
|
39
39
|
if (skipInitialResolve && isFirst.current) {
|
@@ -43,8 +43,8 @@ function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
|
43
43
|
}
|
44
44
|
},
|
45
45
|
},
|
46
|
-
})
|
47
|
-
react_utilities_1.useIsomorphicLayoutEffect(
|
46
|
+
}));
|
47
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
48
48
|
isFirst.current = false;
|
49
49
|
}, []);
|
50
50
|
// update callback
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+DAAsE;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,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,2CAAyB,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;AAxCD,wCAwCC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-nightly627ad67f1120211109.1",
|
4
4
|
"description": "A react wrapper around Popper.js for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -33,8 +33,8 @@
|
|
33
33
|
"react-dom": "16.8.6"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@fluentui/react-shared-contexts": "0.0.0-
|
37
|
-
"@fluentui/react-utilities": "0.0.0-
|
36
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly627ad67f1120211109.1",
|
37
|
+
"@fluentui/react-utilities": "0.0.0-nightly627ad67f1120211109.1",
|
38
38
|
"@popperjs/core": "~2.4.3",
|
39
39
|
"tslib": "^2.1.0"
|
40
40
|
},
|