@fluentui/react-positioning 0.0.0-nightly-20230223-2115.1 → 0.0.0-nightly-20230228-0425.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +9 -9
- package/CHANGELOG.md +7 -7
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js +6 -7
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createVirtualElementFromClick.js +2 -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 +6 -7
- 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 +1 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js +21 -21
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +2 -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 +7 -8
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +0 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +6 -5
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +2 -2
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +4 -2
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +2 -1
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPadding.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 +2 -1
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +4 -4
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js +7 -18
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +88 -60
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +116 -103
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js +26 -27
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +51 -24
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +37 -34
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +22 -20
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +9 -10
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +22 -24
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +40 -35
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +12 -11
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +37 -29
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js +2 -5
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +161 -195
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +37 -34
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +21 -22
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +35 -30
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +22 -21
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +35 -24
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +41 -45
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +56 -52
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +17 -18
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +18 -19
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +32 -32
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +14 -15
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +61 -63
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPadding.js +25 -23
- package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +33 -31
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +23 -19
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +53 -39
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +24 -19
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +45 -37
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +6 -6
- package/.swcrc +0 -33
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/index.ts"],"sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPadding';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"]}
|
@@ -1,3 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mergeArrowOffset = void 0;
|
1
7
|
/**
|
2
8
|
* Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
|
3
9
|
* height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
|
@@ -6,41 +12,35 @@
|
|
6
12
|
* @param userOffset - The offset provided by the user
|
7
13
|
* @param arrowHeight - The height of the arrow in px
|
8
14
|
* @returns User offset augmented with arrow height
|
9
|
-
*/
|
10
|
-
Object.defineProperty(exports, "__esModule", {
|
11
|
-
value: true
|
12
|
-
});
|
13
|
-
Object.defineProperty(exports, "mergeArrowOffset", {
|
14
|
-
enumerable: true,
|
15
|
-
get: ()=>mergeArrowOffset
|
16
|
-
});
|
15
|
+
*/
|
17
16
|
function mergeArrowOffset(userOffset, arrowHeight) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
};
|
29
|
-
}
|
30
|
-
return {
|
31
|
-
mainAxis: arrowHeight
|
17
|
+
if (typeof userOffset === 'number') {
|
18
|
+
return addArrowOffset(userOffset, arrowHeight);
|
19
|
+
}
|
20
|
+
if (typeof userOffset === 'object' && userOffset !== null) {
|
21
|
+
return addArrowOffset(userOffset, arrowHeight);
|
22
|
+
}
|
23
|
+
if (typeof userOffset === 'function') {
|
24
|
+
return offsetParams => {
|
25
|
+
const offset = userOffset(offsetParams);
|
26
|
+
return addArrowOffset(offset, arrowHeight);
|
32
27
|
};
|
28
|
+
}
|
29
|
+
return {
|
30
|
+
mainAxis: arrowHeight
|
31
|
+
};
|
33
32
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
};
|
39
|
-
}
|
33
|
+
exports.mergeArrowOffset = mergeArrowOffset;
|
34
|
+
const addArrowOffset = (offset, arrowHeight) => {
|
35
|
+
var _a;
|
36
|
+
if (typeof offset === 'number') {
|
40
37
|
return {
|
41
|
-
|
42
|
-
mainAxis: (offset.mainAxis ?? 0) + arrowHeight
|
38
|
+
mainAxis: offset + arrowHeight
|
43
39
|
};
|
44
|
-
}
|
45
|
-
|
40
|
+
}
|
41
|
+
return {
|
42
|
+
...offset,
|
43
|
+
mainAxis: ((_a = offset.mainAxis) !== null && _a !== void 0 ? _a : 0) + arrowHeight
|
44
|
+
};
|
45
|
+
};
|
46
46
|
//# sourceMappingURL=mergeArrowOffset.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;;;;AASA,SAAgBA,gBAAgB,CAACC,UAAqC,EAAEC,WAAmB;EACzF,IAAI,OAAOD,UAAU,KAAK,QAAQ,EAAE;IAClC,OAAOE,cAAc,CAACF,UAAU,EAAEC,WAAW,CAAC;;EAGhD,IAAI,OAAOD,UAAU,KAAK,QAAQ,IAAIA,UAAU,KAAK,IAAI,EAAE;IACzD,OAAOE,cAAc,CAACF,UAAU,EAAEC,WAAW,CAAC;;EAGhD,IAAI,OAAOD,UAAU,KAAK,UAAU,EAAE;IACpC,OAAOG,YAAY,IAAG;MACpB,MAAMC,MAAM,GAAGJ,UAAU,CAACG,YAAY,CAAC;MACvC,OAAOD,cAAc,CAACE,MAAM,EAAEH,WAAW,CAAC;IAC5C,CAAC;;EAGH,OAAO;IAAEI,QAAQ,EAAEJ;EAAW,CAAE;AAClC;AAjBAK;AAmBA,MAAMJ,cAAc,GAAG,CAACE,MAA6B,EAAEH,WAAmB,KAAkB;;EAC1F,IAAI,OAAOG,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAO;MAAEC,QAAQ,EAAED,MAAM,GAAGH;IAAW,CAAE;;EAG3C,OAAO;IAAE,GAAGG,MAAM;IAAEC,QAAQ,EAAE,CAAC,YAAM,CAACA,QAAQ,mCAAI,CAAC,IAAIJ;EAAW,CAAE;AACtE,CAAC","names":["mergeArrowOffset","userOffset","arrowHeight","addArrowOffset","offsetParams","offset","mainAxis","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/mergeArrowOffset.ts"],"sourcesContent":["import type { Offset, OffsetObject } from '../types';\n\n/**\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @internal\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n if (typeof userOffset === 'number') {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'object' && userOffset !== null) {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'function') {\n return offsetParams => {\n const offset = userOffset(offsetParams);\n return addArrowOffset(offset, arrowHeight);\n };\n }\n\n return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n if (typeof offset === 'number') {\n return { mainAxis: offset + arrowHeight };\n }\n\n return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"]}
|
@@ -1,22 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.parseFloatingUIPlacement = void 0;
|
1
7
|
/**
|
2
8
|
* Parses Floating UI placement and returns the different components
|
3
9
|
* @param placement - the floating ui placement (i.e. bottom-start)
|
4
10
|
*
|
5
11
|
* @returns side and alignment components of the placement
|
6
|
-
*/
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
8
|
-
value: true
|
9
|
-
});
|
10
|
-
Object.defineProperty(exports, "parseFloatingUIPlacement", {
|
11
|
-
enumerable: true,
|
12
|
-
get: ()=>parseFloatingUIPlacement
|
13
|
-
});
|
12
|
+
*/
|
14
13
|
function parseFloatingUIPlacement(placement) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
|
14
|
+
const tokens = placement.split('-');
|
15
|
+
return {
|
16
|
+
side: tokens[0],
|
17
|
+
alignment: tokens[1]
|
18
|
+
};
|
19
|
+
}
|
20
|
+
exports.parseFloatingUIPlacement = parseFloatingUIPlacement;
|
22
21
|
//# sourceMappingURL=parseFloatingUIPlacement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;;;;;;AAMA,SAAgBA,wBAAwB,CAACC,SAAoB;EAC3D,MAAMC,MAAM,GAAGD,SAAS,CAACE,KAAK,CAAC,GAAG,CAAC;EACnC,OAAO;IACLC,IAAI,EAAEF,MAAM,CAAC,CAAC,CAAS;IACvBG,SAAS,EAAEH,MAAM,CAAC,CAAC;GACpB;AACH;AANAI","names":["parseFloatingUIPlacement","placement","tokens","split","side","alignment","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/parseFloatingUIPlacement.ts"],"sourcesContent":["import type { Side, Placement, Alignment } from '@floating-ui/dom';\n\n/**\n * Parses Floating UI placement and returns the different components\n * @param placement - the floating ui placement (i.e. bottom-start)\n *\n * @returns side and alignment components of the placement\n */\nexport function parseFloatingUIPlacement(placement: Placement): { side: Side; alignment: Alignment } {\n const tokens = placement.split('-');\n return {\n side: tokens[0] as Side,\n alignment: tokens[1] as Alignment,\n };\n}\n"]}
|
@@ -1,70 +1,68 @@
|
|
1
|
-
// Look up table for shorthand to avoid parsing strings
|
2
1
|
"use strict";
|
2
|
+
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "resolvePositioningShorthand", {
|
7
|
-
enumerable: true,
|
8
|
-
get: ()=>resolvePositioningShorthand
|
4
|
+
value: true
|
9
5
|
});
|
6
|
+
exports.resolvePositioningShorthand = void 0;
|
7
|
+
// Look up table for shorthand to avoid parsing strings
|
10
8
|
const shorthandLookup = {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
9
|
+
above: {
|
10
|
+
position: 'above',
|
11
|
+
align: 'center'
|
12
|
+
},
|
13
|
+
'above-start': {
|
14
|
+
position: 'above',
|
15
|
+
align: 'start'
|
16
|
+
},
|
17
|
+
'above-end': {
|
18
|
+
position: 'above',
|
19
|
+
align: 'end'
|
20
|
+
},
|
21
|
+
below: {
|
22
|
+
position: 'below',
|
23
|
+
align: 'center'
|
24
|
+
},
|
25
|
+
'below-start': {
|
26
|
+
position: 'below',
|
27
|
+
align: 'start'
|
28
|
+
},
|
29
|
+
'below-end': {
|
30
|
+
position: 'below',
|
31
|
+
align: 'end'
|
32
|
+
},
|
33
|
+
before: {
|
34
|
+
position: 'before',
|
35
|
+
align: 'center'
|
36
|
+
},
|
37
|
+
'before-top': {
|
38
|
+
position: 'before',
|
39
|
+
align: 'top'
|
40
|
+
},
|
41
|
+
'before-bottom': {
|
42
|
+
position: 'before',
|
43
|
+
align: 'bottom'
|
44
|
+
},
|
45
|
+
after: {
|
46
|
+
position: 'after',
|
47
|
+
align: 'center'
|
48
|
+
},
|
49
|
+
'after-top': {
|
50
|
+
position: 'after',
|
51
|
+
align: 'top'
|
52
|
+
},
|
53
|
+
'after-bottom': {
|
54
|
+
position: 'after',
|
55
|
+
align: 'bottom'
|
56
|
+
}
|
59
57
|
};
|
60
58
|
function resolvePositioningShorthand(shorthand) {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
69
|
-
|
59
|
+
if (shorthand === undefined || shorthand === null) {
|
60
|
+
return {};
|
61
|
+
}
|
62
|
+
if (typeof shorthand === 'string') {
|
63
|
+
return shorthandLookup[shorthand];
|
64
|
+
}
|
65
|
+
return shorthand;
|
66
|
+
}
|
67
|
+
exports.resolvePositioningShorthand = resolvePositioningShorthand;
|
70
68
|
//# sourceMappingURL=resolvePositioningShorthand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA;AACA,MAAMA,eAAe,GAAoF;EACvGC,KAAK,EAAE;IAAEC,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,aAAa,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAO,CAAE;EACpD,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChDC,KAAK,EAAE;IAAEF,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,aAAa,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAO,CAAE;EACpD,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChDE,MAAM,EAAE;IAAEH,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC/C,YAAY,EAAE;IAAED,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAK,CAAE;EAClD,eAAe,EAAE;IAAED,QAAQ,EAAE,QAAQ;IAAEC,KAAK,EAAE;EAAQ,CAAE;EACxDG,KAAK,EAAE;IAAEJ,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ,CAAE;EAC7C,WAAW,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAK,CAAE;EAChD,cAAc,EAAE;IAAED,QAAQ,EAAE,OAAO;IAAEC,KAAK,EAAE;EAAQ;CACrD;AAED,SAAgBI,2BAA2B,CACzCC,SAAkD;EAElD,IAAIA,SAAS,KAAKC,SAAS,IAAID,SAAS,KAAK,IAAI,EAAE;IACjD,OAAO,EAAE;;EAGX,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IACjC,OAAOR,eAAe,CAACQ,SAAS,CAAC;;EAGnC,OAAOA,SAAuC;AAChD;AAZAE","names":["shorthandLookup","above","position","align","below","before","after","resolvePositioningShorthand","shorthand","undefined","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/resolvePositioningShorthand.ts"],"sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"]}
|
@@ -1,28 +1,30 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "toFloatingUIPadding", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>toFloatingUIPadding
|
4
|
+
value: true
|
8
5
|
});
|
6
|
+
exports.toFloatingUIPadding = void 0;
|
9
7
|
function toFloatingUIPadding(padding, isRtl) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
if (typeof padding === 'number') {
|
9
|
+
return padding;
|
10
|
+
}
|
11
|
+
const {
|
12
|
+
start,
|
13
|
+
end,
|
14
|
+
...verticalPadding
|
15
|
+
} = padding;
|
16
|
+
const paddingObject = verticalPadding;
|
17
|
+
const left = isRtl ? 'end' : 'start';
|
18
|
+
const right = isRtl ? 'start' : 'end';
|
19
|
+
// assign properties explicitly since undefined values are actually handled by floating UI
|
20
|
+
// TODO create floating UI issue
|
21
|
+
if (padding[left]) {
|
22
|
+
paddingObject.left = padding[left];
|
23
|
+
}
|
24
|
+
if (padding[right]) {
|
25
|
+
paddingObject.right = padding[right];
|
26
|
+
}
|
27
|
+
return paddingObject;
|
28
|
+
}
|
29
|
+
exports.toFloatingUIPadding = toFloatingUIPadding;
|
28
30
|
//# sourceMappingURL=toFloatingUIPadding.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAGA,SAAgBA,mBAAmB,CACjCC,OAAmE,EACnEC,KAAc;EAEd,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;;EAGhB,MAAM;IAAEE,KAAK;IAAEC,GAAG;IAAE,GAAGC;EAAe,CAAE,GAAGJ,OAAO;EAElD,MAAMK,aAAa,GAAwBD,eAAe;EAE1D,MAAME,IAAI,GAAGL,KAAK,GAAG,KAAK,GAAG,OAAO;EACpC,MAAMM,KAAK,GAAGN,KAAK,GAAG,OAAO,GAAG,KAAK;EAErC;EACA;EACA,IAAID,OAAO,CAACM,IAAI,CAAC,EAAE;IACjBD,aAAa,CAACC,IAAI,GAAGN,OAAO,CAACM,IAAI,CAAC;;EAGpC,IAAIN,OAAO,CAACO,KAAK,CAAC,EAAE;IAClBF,aAAa,CAACE,KAAK,GAAGP,OAAO,CAACO,KAAK,CAAC;;EAGtC,OAAOF,aAAa;AACtB;AA1BAG","names":["toFloatingUIPadding","padding","isRtl","start","end","verticalPadding","paddingObject","left","right","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/toFloatingUIPadding.ts"],"sourcesContent":["import type { SideObject } from '@floating-ui/dom';\nimport { PositioningOptions } from '../types';\n\nexport function toFloatingUIPadding(\n padding: NonNullable<PositioningOptions['overflowBoundaryPadding']>,\n isRtl: boolean,\n): number | Partial<SideObject> {\n if (typeof padding === 'number') {\n return padding;\n }\n\n const { start, end, ...verticalPadding } = padding;\n\n const paddingObject: Partial<SideObject> = verticalPadding;\n\n const left = isRtl ? 'end' : 'start';\n const right = isRtl ? 'start' : 'end';\n\n // assign properties explicitly since undefined values are actually handled by floating UI\n // TODO create floating UI issue\n if (padding[left]) {\n paddingObject.left = padding[left];\n }\n\n if (padding[right]) {\n paddingObject.right = padding[right];\n }\n\n return paddingObject;\n}\n"]}
|
@@ -1,39 +1,41 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
+
value: true
|
4
5
|
});
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
exports.toFloatingUIPlacement = void 0;
|
7
|
+
const getPositionMap = rtl => ({
|
8
|
+
above: 'top',
|
9
|
+
below: 'bottom',
|
10
|
+
before: rtl ? 'right' : 'left',
|
11
|
+
after: rtl ? 'left' : 'right'
|
8
12
|
});
|
9
|
-
const getPositionMap = (rtl)=>({
|
10
|
-
above: 'top',
|
11
|
-
below: 'bottom',
|
12
|
-
before: rtl ? 'right' : 'left',
|
13
|
-
after: rtl ? 'left' : 'right'
|
14
|
-
});
|
15
13
|
// Floating UI automatically flips alignment
|
16
14
|
// https://github.com/floating-ui/floating-ui/issues/1563
|
17
|
-
const getAlignmentMap = ()=>({
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const shouldAlignToCenter = (p, a)=>{
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
const getAlignmentMap = () => ({
|
16
|
+
start: 'start',
|
17
|
+
end: 'end',
|
18
|
+
top: 'start',
|
19
|
+
bottom: 'end',
|
20
|
+
center: undefined
|
21
|
+
});
|
22
|
+
const shouldAlignToCenter = (p, a) => {
|
23
|
+
const positionedVertically = p === 'above' || p === 'below';
|
24
|
+
const alignedVertically = a === 'top' || a === 'bottom';
|
25
|
+
return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
|
28
26
|
};
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
/**
|
28
|
+
* Maps internal positioning values to Floating UI placement
|
29
|
+
* @see positioningHelper.test.ts for expected placement values
|
30
|
+
*/
|
31
|
+
const toFloatingUIPlacement = (align, position, rtl) => {
|
32
|
+
const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
|
33
|
+
const computedPosition = position && getPositionMap(rtl)[position];
|
34
|
+
const computedAlignment = alignment && getAlignmentMap()[alignment];
|
35
|
+
if (computedPosition && computedAlignment) {
|
36
|
+
return `${computedPosition}-${computedAlignment}`;
|
37
|
+
}
|
38
|
+
return computedPosition;
|
39
|
+
};
|
40
|
+
exports.toFloatingUIPlacement = toFloatingUIPlacement;
|
39
41
|
//# sourceMappingURL=toFloatingUIPlacement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAMA,MAAMA,cAAc,GAAIC,GAAa,KAA2C;EAC9EC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,QAAQ;EACfC,MAAM,EAAEH,GAAG,GAAG,OAAO,GAAG,MAAM;EAC9BI,KAAK,EAAEJ,GAAG,GAAG,MAAM,GAAG;CACvB,CAAC;AAEF;AACA;AACA,MAAMK,eAAe,GAAG,OAAsD;EAC5EC,KAAK,EAAE,OAAO;EACdC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,OAAO;EACZC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAEC;CACT,CAAC;AAEF,MAAMC,mBAAmB,GAAG,CAACC,CAAY,EAAEC,CAAa,KAAa;EACnE,MAAMC,oBAAoB,GAAGF,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,OAAO;EAC3D,MAAMG,iBAAiB,GAAGF,CAAC,KAAK,KAAK,IAAIA,CAAC,KAAK,QAAQ;EAEvD,OAAQC,oBAAoB,IAAIC,iBAAiB,IAAM,CAACD,oBAAoB,IAAI,CAACC,iBAAkB;AACrG,CAAC;AAED;;;;AAIO,MAAMC,qBAAqB,GAAG,CAACC,KAAiB,EAAEC,QAAmB,EAAEnB,GAAa,KAA2B;EACpH,MAAMoB,SAAS,GAAGR,mBAAmB,CAACO,QAAQ,EAAED,KAAK,CAAC,GAAG,QAAQ,GAAGA,KAAK;EAEzE,MAAMG,gBAAgB,GAAGF,QAAQ,IAAIpB,cAAc,CAACC,GAAG,CAAC,CAACmB,QAAQ,CAAC;EAClE,MAAMG,iBAAiB,GAAGF,SAAS,IAAIf,eAAe,EAAE,CAACe,SAAS,CAAC;EAEnE,IAAIC,gBAAgB,IAAIC,iBAAiB,EAAE;IACzC,OAAO,GAAGD,gBAAgB,IAAIC,iBAAiB,EAAe;;EAGhE,OAAOD,gBAAgB;AACzB,CAAC;AAXYE,6BAAqB","names":["getPositionMap","rtl","above","below","before","after","getAlignmentMap","start","end","top","bottom","center","undefined","shouldAlignToCenter","p","a","positionedVertically","alignedVertically","toFloatingUIPlacement","align","position","alignment","computedPosition","computedAlignment","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/toFloatingUIPlacement.ts"],"sourcesContent":["import type { Placement, Side, Alignment as FloatingUIAlignment } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\n\ntype PlacementPosition = Side;\ntype PlacementAlign = FloatingUIAlignment;\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (): Record<Alignment, PlacementAlign | undefined> => ({\n start: 'start',\n end: 'end',\n top: 'start',\n bottom: 'end',\n center: undefined,\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * Maps internal positioning values to Floating UI placement\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const toFloatingUIPlacement = (align?: Alignment, position?: Position, rtl?: boolean): Placement | undefined => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignment = alignment && getAlignmentMap()[alignment];\n\n if (computedPosition && computedAlignment) {\n return `${computedPosition}-${computedAlignment}` as Placement;\n }\n\n return computedPosition;\n};\n"]}
|
@@ -1,24 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "toggleScrollListener", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>toggleScrollListener
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
6
|
+
exports.toggleScrollListener = void 0;
|
7
|
+
const getScrollParent_1 = /*#__PURE__*/require("./getScrollParent");
|
8
|
+
/**
|
9
|
+
* Toggles event listeners for scroll parent.
|
10
|
+
* Cleans up the event listeners for the previous element and adds them for the new scroll parent.
|
11
|
+
* @param next Next element
|
12
|
+
* @param prev Previous element
|
13
|
+
*/
|
10
14
|
function toggleScrollListener(next, prev, handler) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
|
15
|
+
if (next === prev) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
if (prev instanceof HTMLElement) {
|
19
|
+
const prevScrollParent = getScrollParent_1.getScrollParent(prev);
|
20
|
+
prevScrollParent.removeEventListener('scroll', handler);
|
21
|
+
}
|
22
|
+
if (next instanceof HTMLElement) {
|
23
|
+
const scrollParent = getScrollParent_1.getScrollParent(next);
|
24
|
+
scrollParent.addEventListener('scroll', handler);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.toggleScrollListener = toggleScrollListener;
|
24
28
|
//# sourceMappingURL=toggleScrollListener.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AACA;AAEA;;;;;;AAMA,SAAgBA,oBAAoB,CAClCC,IAAoD,EACpDC,IAAoD,EACpDC,OAAsB;EAEtB,IAAIF,IAAI,KAAKC,IAAI,EAAE;IACjB;;EAGF,IAAIA,IAAI,YAAYE,WAAW,EAAE;IAC/B,MAAMC,gBAAgB,GAAGC,iCAAe,CAACJ,IAAI,CAAC;IAC9CG,gBAAgB,CAACE,mBAAmB,CAAC,QAAQ,EAAEJ,OAAO,CAAC;;EAEzD,IAAIF,IAAI,YAAYG,WAAW,EAAE;IAC/B,MAAMI,YAAY,GAAGF,iCAAe,CAACL,IAAI,CAAC;IAC1CO,YAAY,CAACC,gBAAgB,CAAC,QAAQ,EAAEN,OAAO,CAAC;;AAEpD;AAjBAO","names":["toggleScrollListener","next","prev","handler","HTMLElement","prevScrollParent","getScrollParent_1","removeEventListener","scrollParent","addEventListener","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/toggleScrollListener.ts"],"sourcesContent":["import type { PositioningVirtualElement } from '../types';\nimport { getScrollParent } from './getScrollParent';\n\n/**\n * Toggles event listeners for scroll parent.\n * Cleans up the event listeners for the previous element and adds them for the new scroll parent.\n * @param next Next element\n * @param prev Previous element\n */\nexport function toggleScrollListener(\n next: HTMLElement | PositioningVirtualElement | null,\n prev: HTMLElement | PositioningVirtualElement | null,\n handler: EventListener,\n) {\n if (next === prev) {\n return;\n }\n\n if (prev instanceof HTMLElement) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener('scroll', handler);\n }\n if (next instanceof HTMLElement) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener('scroll', handler);\n }\n}\n"]}
|
@@ -1,44 +1,58 @@
|
|
1
1
|
"use strict";
|
2
|
+
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
3
|
-
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "useCallbackRef", {
|
6
|
-
enumerable: true,
|
7
|
-
get: ()=>useCallbackRef
|
4
|
+
value: true
|
8
5
|
});
|
9
|
-
|
10
|
-
const
|
11
|
-
const
|
6
|
+
exports.useCallbackRef = void 0;
|
7
|
+
const React = /*#__PURE__*/require("react");
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
9
|
+
/**
|
10
|
+
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
11
|
+
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
12
|
+
* React.useState(), but it will cause re-renders always.
|
13
|
+
*
|
14
|
+
* https://reactjs.org/docs/hooks-reference.html#useref
|
15
|
+
* https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
16
|
+
*
|
17
|
+
* @param initialValue - initial ref value
|
18
|
+
* @param callback - a callback to run when value changes
|
19
|
+
* @param skipInitialResolve - a flag to skip an initial ref report
|
20
|
+
*
|
21
|
+
* @example
|
22
|
+
* const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
|
23
|
+
* ref.current = 1;
|
24
|
+
* // prints 0 -> 1
|
25
|
+
*/
|
12
26
|
function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
|
27
|
+
const isFirst = React.useRef(true);
|
28
|
+
const [ref] = React.useState(() => ({
|
29
|
+
// value
|
30
|
+
value: initialValue,
|
31
|
+
// last callback
|
32
|
+
callback,
|
33
|
+
// "memoized" public interface
|
34
|
+
facade: {
|
35
|
+
get current() {
|
36
|
+
return ref.value;
|
37
|
+
},
|
38
|
+
set current(value) {
|
39
|
+
const last = ref.value;
|
40
|
+
if (last !== value) {
|
41
|
+
ref.value = value;
|
42
|
+
if (skipInitialResolve && isFirst.current) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
ref.callback(value, last);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}));
|
50
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
51
|
+
isFirst.current = false;
|
52
|
+
}, []);
|
53
|
+
// update callback
|
54
|
+
ref.callback = callback;
|
55
|
+
return ref.facade;
|
56
|
+
}
|
57
|
+
exports.useCallbackRef = useCallbackRef;
|
44
58
|
//# sourceMappingURL=useCallbackRef.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;;;;;;;;;;;;;;;;;AAiBA,SAAgBA,cAAc,CAC5BC,YAAsB,EACtBC,QAA2D,EAC3DC,kBAA4B;EAE5B,MAAMC,OAAO,GAAGC,KAAK,CAACC,MAAM,CAAC,IAAI,CAAC;EAClC,MAAM,CAACC,GAAG,CAAC,GAAGF,KAAK,CAACG,QAAQ,CAAC,OAAO;IAClC;IACAC,KAAK,EAAER,YAAY;IACnB;IACAC,QAAQ;IACR;IACAQ,MAAM,EAAE;MACN,IAAIC,OAAO;QACT,OAAOJ,GAAG,CAACE,KAAK;MAClB,CAAC;MACD,IAAIE,OAAO,CAACF,KAAK;QACf,MAAMG,IAAI,GAAGL,GAAG,CAACE,KAAK;QAEtB,IAAIG,IAAI,KAAKH,KAAK,EAAE;UAClBF,GAAG,CAACE,KAAK,GAAGA,KAAK;UAEjB,IAAIN,kBAAkB,IAAIC,OAAO,CAACO,OAAO,EAAE;YACzC;;UAGFJ,GAAG,CAACL,QAAQ,CAACO,KAAK,EAAEG,IAAI,CAAC;;MAE7B;;GAEH,CAAC,CAAC;EAEHC,2CAAyB,CAAC,MAAK;IAC7BT,OAAO,CAACO,OAAO,GAAG,KAAK;EACzB,CAAC,EAAE,EAAE,CAAC;EAEN;EACAJ,GAAG,CAACL,QAAQ,GAAGA,QAAQ;EAEvB,OAAOK,GAAG,CAACG,MAAM;AACnB;AAxCAI","names":["useCallbackRef","initialValue","callback","skipInitialResolve","isFirst","React","useRef","ref","useState","value","facade","current","last","react_utilities_1","exports"],"sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/useCallbackRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n * @param skipInitialResolve - a flag to skip an initial ref report\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n skipInitialResolve?: boolean,\n): React.MutableRefObject<T | null> {\n const isFirst = React.useRef(true);\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n\n ref.callback(value, last);\n }\n },\n },\n }));\n\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"]}
|