@fluentui/react-positioning 9.0.0-rc.9 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +141 -1
- package/CHANGELOG.md +54 -2
- package/dist/index.d.ts +78 -46
- package/lib/createArrowStyles.js +3 -1
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createVirtualElementFromClick.js +2 -0
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/isIntersectingModifier.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/{usePopper.js → usePositioning.js} +10 -8
- package/lib/usePositioning.js.map +1 -0
- package/lib/{usePopperMouseTarget.js → usePositioningMouseTarget.js} +4 -3
- package/lib/usePositioningMouseTarget.js.map +1 -0
- package/lib/utils/fromPopperPlacement.js +40 -0
- package/lib/utils/fromPopperPlacement.js.map +1 -0
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getPopperOffset.js +44 -0
- package/lib/utils/getPopperOffset.js.map +1 -0
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +24 -22
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parsePopperPlacement.js +14 -0
- package/lib/utils/parsePopperPlacement.js.map +1 -0
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +3 -1
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js +2 -0
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +7 -7
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/isIntersectingModifier.js.map +1 -1
- package/lib-commonjs/{usePopper.js → usePositioning.js} +13 -10
- package/lib-commonjs/usePositioning.js.map +1 -0
- package/lib-commonjs/{usePopperMouseTarget.js → usePositioningMouseTarget.js} +6 -5
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -0
- package/lib-commonjs/utils/fromPopperPlacement.js +50 -0
- package/lib-commonjs/utils/fromPopperPlacement.js.map +1 -0
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getPopperOffset.js +54 -0
- package/lib-commonjs/utils/getPopperOffset.js.map +1 -0
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.js +2 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +24 -22
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parsePopperPlacement.js +23 -0
- package/lib-commonjs/utils/parsePopperPlacement.js.map +1 -0
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +6 -8
- package/lib/usePopper.js.map +0 -1
- package/lib/usePopperMouseTarget.js.map +0 -1
- package/lib/utils/getBasePlacement.js +0 -10
- package/lib/utils/getBasePlacement.js.map +0 -1
- package/lib-commonjs/usePopper.js.map +0 -1
- package/lib-commonjs/usePopperMouseTarget.js.map +0 -1
- package/lib-commonjs/utils/getBasePlacement.js +0 -19
- package/lib-commonjs/utils/getBasePlacement.js.map +0 -1
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.mergeArrowOffset = void 0;
|
7
7
|
/**
|
8
|
+
* @internal
|
8
9
|
* Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
|
9
10
|
* height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
|
10
11
|
*
|
@@ -14,38 +15,39 @@ exports.mergeArrowOffset = void 0;
|
|
14
15
|
*/
|
15
16
|
|
16
17
|
function mergeArrowOffset(userOffset, arrowHeight) {
|
17
|
-
|
18
|
-
|
19
|
-
if (!userOffset) {
|
20
|
-
return [0, arrowHeight];
|
18
|
+
if (typeof userOffset === 'number') {
|
19
|
+
return addArrowOffset(userOffset, arrowHeight);
|
21
20
|
}
|
22
21
|
|
23
|
-
if (
|
24
|
-
|
25
|
-
return offsetWithArrow;
|
22
|
+
if (typeof userOffset === 'object' && userOffset !== null) {
|
23
|
+
return addArrowOffset(userOffset, arrowHeight);
|
26
24
|
}
|
27
25
|
|
28
|
-
if (typeof
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
const offset = userOffsetFn(offsetParams);
|
33
|
-
setArrowOffset(offset, arrowHeight);
|
34
|
-
return offset;
|
26
|
+
if (typeof userOffset === 'function') {
|
27
|
+
return offsetParams => {
|
28
|
+
const offset = userOffset(offsetParams);
|
29
|
+
return addArrowOffset(offset, arrowHeight);
|
35
30
|
};
|
36
|
-
}
|
37
|
-
|
31
|
+
}
|
38
32
|
|
39
|
-
return
|
33
|
+
return {
|
34
|
+
mainAxis: arrowHeight
|
35
|
+
};
|
40
36
|
}
|
41
37
|
|
42
38
|
exports.mergeArrowOffset = mergeArrowOffset;
|
43
39
|
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
const addArrowOffset = (offset, arrowHeight) => {
|
41
|
+
var _a;
|
42
|
+
|
43
|
+
if (typeof offset === 'number') {
|
44
|
+
return {
|
45
|
+
mainAxis: offset + arrowHeight
|
46
|
+
};
|
49
47
|
}
|
48
|
+
|
49
|
+
return { ...offset,
|
50
|
+
mainAxis: ((_a = offset.mainAxis) !== null && _a !== void 0 ? _a : 0) + arrowHeight
|
51
|
+
};
|
50
52
|
};
|
51
53
|
//# sourceMappingURL=mergeArrowOffset.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA
|
1
|
+
{"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;;AAQG;;AACH,SAAgB,gBAAhB,CAAiC,UAAjC,EAAwE,WAAxE,EAA2F;EACzF,IAAI,OAAO,UAAP,KAAsB,QAA1B,EAAoC;IAClC,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,QAAtB,IAAkC,UAAU,KAAK,IAArD,EAA2D;IACzD,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,UAA1B,EAAsC;IACpC,OAAO,YAAY,IAAG;MACpB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAD,CAAzB;MACA,OAAO,cAAc,CAAC,MAAD,EAAS,WAAT,CAArB;IACD,CAHD;EAID;;EAED,OAAO;IAAE,QAAQ,EAAE;EAAZ,CAAP;AACD;;AAjBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAmBA,MAAM,cAAc,GAAG,CAAC,MAAD,EAAgC,WAAhC,KAAqE;;;EAC1F,IAAI,OAAO,MAAP,KAAkB,QAAtB,EAAgC;IAC9B,OAAO;MAAE,QAAQ,EAAE,MAAM,GAAG;IAArB,CAAP;EACD;;EAED,OAAO,EAAE,GAAG,MAAL;IAAa,QAAQ,EAAE,CAAC,CAAA,EAAA,GAAA,MAAM,CAAC,QAAP,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,EAAf,GAAmB,CAApB,IAAyB;EAAhD,CAAP;AACD,CAND","sourcesContent":["import type { Offset, OffsetObject } from '../types';\n\n/**\n * @internal\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 * @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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.parsePopperPlacement = void 0;
|
7
|
+
/**
|
8
|
+
* Parses Popper placement and returns the different components
|
9
|
+
* @param placement - the Popper.js placement (i.e. bottom-start)
|
10
|
+
*
|
11
|
+
* @returns side and alignment components of the placement
|
12
|
+
*/
|
13
|
+
|
14
|
+
function parsePopperPlacement(placement) {
|
15
|
+
const tokens = placement.split('-');
|
16
|
+
return {
|
17
|
+
basePlacement: tokens[0],
|
18
|
+
alignment: tokens[1]
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
exports.parsePopperPlacement = parsePopperPlacement;
|
23
|
+
//# sourceMappingURL=parsePopperPlacement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["utils/parsePopperPlacement.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,oBAAhB,CAAqC,SAArC,EAAyD;EACvD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,CAAf;EACA,OAAO;IACL,aAAa,EAAE,MAAM,CAAC,CAAD,CADhB;IAEL,SAAS,EAAE,MAAM,CAAC,CAAD;EAFZ,CAAP;AAID;;AAND,OAAA,CAAA,oBAAA,GAAA,oBAAA","sourcesContent":["import type { BasePlacement, Placement, Variation } from '@popperjs/core';\n\n/**\n * Parses Popper placement and returns the different components\n * @param placement - the Popper.js placement (i.e. bottom-start)\n *\n * @returns side and alignment components of the placement\n */\nexport function parsePopperPlacement(placement: Placement): { basePlacement: BasePlacement; alignment: Variation } {\n const tokens = placement.split('-');\n return {\n basePlacement: tokens[0] as BasePlacement,\n alignment: tokens[1] as Variation,\n };\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["utils/positioningHelper.ts"],"names":[],"mappings":";;;;;;;
|
1
|
+
{"version":3,"sources":["utils/positioningHelper.ts"],"names":[],"mappings":";;;;;;;AAOA,MAAM,cAAc,GAAI,GAAD,KAAyD;EAC9E,KAAK,EAAE,KADuE;EAE9E,KAAK,EAAE,QAFuE;EAG9E,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;EAI9E,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;EAC7E,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OADwD;EAE7E,GAAG,EAAE,GAAG,GAAG,OAAH,GAAa,KAFwD;EAG7E,GAAG,EAAE,OAHwE;EAI7E,MAAM,EAAE,KAJqE;EAK7E,MAAM,EAAE;AALqE,CAAvD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;EACnE,MAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;EACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;EAEA,OAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;AAEG;;;AACI,MAAM,YAAY,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAA8E;EACxG,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;EAEA,MAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;EACA,MAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAD,CAAf,CAAqB,SAArB,CAAxC;;EAEA,IAAI,gBAAgB,IAAI,kBAAxB,EAA4C;IAC1C,OAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;EACD;;EAED,OAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ;;AAaN,MAAM,gBAAgB,GAAI,MAAD,IAA+D;EAC7F,IAAI,OAAO,MAAP,KAAkB,WAAtB,EAAmC;IACjC,OAAO,SAAP;EACD;;EAED,IAAI,KAAK,CAAC,OAAN,CAAc,MAAd,CAAJ,EAA2B;IACzB,MAAM,CAAC,CAAD,CAAN,GAAY,MAAM,CAAC,CAAD,CAAN,GAAa,CAAC,CAA1B;IAEA,OAAO,MAAP;EACD;;EAED,OAAS,KAAD,IAAsC,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAA9C;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport type { Alignment, Position } from '../types';\nimport { PopperOffset, PopperOffsetFunction, PopperOffsetFunctionParam } from './getPopperOffset';\n\ntype PlacementPosition = 'top' | 'bottom' | 'left' | 'right';\ntype PlacementAlign = 'start' | 'end' | ''; // '' represents center\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\nconst getAlignmentMap = (rtl?: boolean): Record<Alignment, PlacementAlign> => ({\n start: rtl ? 'end' : 'start',\n end: rtl ? 'start' : 'end',\n top: 'start',\n bottom: 'end',\n center: '',\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 * @see positioninHelper.test.ts for expected placement values\n */\nexport const getPlacement = (align?: Alignment, position?: Position, rtl?: boolean): PopperJs.Placement => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];\n\n if (computedPosition && computedAlignmnent) {\n return `${computedPosition}-${computedAlignmnent}` as PopperJs.Placement;\n }\n\n return computedPosition || ('auto' as PopperJs.Placement);\n};\n\nexport const applyRtlToOffset = (offset: PopperOffset | undefined): PopperOffset | undefined => {\n if (typeof offset === 'undefined') {\n return undefined;\n }\n\n if (Array.isArray(offset)) {\n offset[0] = offset[0]! * -1;\n\n return offset;\n }\n\n return ((param: PopperOffsetFunctionParam) => applyRtlToOffset(offset(param))) as PopperOffsetFunction;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["utils/resolvePositioningShorthand.ts"],"names":[],"mappings":";;;;;8CAEA;;AACA,MAAM,eAAe,GAAoF;
|
1
|
+
{"version":3,"sources":["utils/resolvePositioningShorthand.ts"],"names":[],"mappings":";;;;;8CAEA;;AACA,MAAM,eAAe,GAAoF;EACvG,KAAK,EAAE;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CADgG;EAEvG,eAAe;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAFwF;EAGvG,aAAa;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAH0F;EAIvG,KAAK,EAAE;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAJgG;EAKvG,eAAe;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CALwF;EAMvG,aAAa;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAN0F;EAOvG,MAAM,EAAE;IAAE,QAAQ,EAAE,QAAZ;IAAsB,KAAK,EAAE;EAA7B,CAP+F;EAQvG,cAAc;IAAE,QAAQ,EAAE,QAAZ;IAAsB,KAAK,EAAE;EAA7B,CARyF;EASvG,iBAAiB;IAAE,QAAQ,EAAE,QAAZ;IAAsB,KAAK,EAAE;EAA7B,CATsF;EAUvG,KAAK,EAAE;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAVgG;EAWvG,aAAa;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B,CAX0F;EAYvG,gBAAgB;IAAE,QAAQ,EAAE,OAAZ;IAAqB,KAAK,EAAE;EAA5B;AAZuF,CAAzG;;AAeA,SAAgB,2BAAhB,CACE,SADF,EACoD;EAElD,IAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;IACjD,OAAO,EAAP;EACD;;EAED,IAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;IACjC,OAAO,eAAe,CAAC,SAAD,CAAtB;EACD;;EAED,OAAO,SAAP;AACD;;AAZD,OAAA,CAAA,2BAAA,GAAA,2BAAA","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"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["utils/useCallbackRef.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;;;AACH,SAAgB,cAAhB,CACE,YADF,EAEE,QAFF,EAGE,kBAHF,EAG8B;
|
1
|
+
{"version":3,"sources":["utils/useCallbackRef.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;;;AACH,SAAgB,cAAhB,CACE,YADF,EAEE,QAFF,EAGE,kBAHF,EAG8B;EAE5B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAAa,IAAb,CAAhB;EACA,MAAM,CAAC,GAAD,IAAQ,KAAK,CAAC,QAAN,CAAe,OAAO;IAClC;IACA,KAAK,EAAE,YAF2B;IAGlC;IACA,QAJkC;IAKlC;IACA,MAAM,EAAE;MACN,IAAI,OAAJ,GAAW;QACT,OAAO,GAAG,CAAC,KAAX;MACD,CAHK;;MAIN,IAAI,OAAJ,CAAY,KAAZ,EAAiB;QACf,MAAM,IAAI,GAAG,GAAG,CAAC,KAAjB;;QAEA,IAAI,IAAI,KAAK,KAAb,EAAoB;UAClB,GAAG,CAAC,KAAJ,GAAY,KAAZ;;UAEA,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAlC,EAA2C;YACzC;UACD;;UAED,GAAG,CAAC,QAAJ,CAAa,KAAb,EAAoB,IAApB;QACD;MACF;;IAhBK;EAN0B,CAAP,CAAf,CAAd;EA0BA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;IAC7B,OAAO,CAAC,OAAR,GAAkB,KAAlB;EACD,CAFD,EAEG,EAFH,EA7B4B,CAiC5B;;EACA,GAAG,CAAC,QAAJ,GAAe,QAAf;EAEA,OAAO,GAAG,CAAC,MAAX;AACD;;AAxCD,OAAA,CAAA,cAAA,GAAA,cAAA","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"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
|
-
"version": "9.0.0
|
3
|
+
"version": "9.0.0",
|
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",
|
@@ -28,10 +28,10 @@
|
|
28
28
|
"@fluentui/scripts": "^1.0.0"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
|
-
"@griffel/react": "1.0
|
32
|
-
"@fluentui/react-shared-contexts": "9.0.0
|
33
|
-
"@fluentui/react-theme": "9.0.0
|
34
|
-
"@fluentui/react-utilities": "9.0.0
|
31
|
+
"@griffel/react": "1.2.0",
|
32
|
+
"@fluentui/react-shared-contexts": "^9.0.0",
|
33
|
+
"@fluentui/react-theme": "^9.0.0",
|
34
|
+
"@fluentui/react-utilities": "^9.0.0",
|
35
35
|
"@popperjs/core": "~2.4.3",
|
36
36
|
"tslib": "^2.1.0"
|
37
37
|
},
|
@@ -43,9 +43,7 @@
|
|
43
43
|
},
|
44
44
|
"beachball": {
|
45
45
|
"disallowedChangeTypes": [
|
46
|
-
"major"
|
47
|
-
"minor",
|
48
|
-
"patch"
|
46
|
+
"major"
|
49
47
|
]
|
50
48
|
},
|
51
49
|
"exports": {
|
package/lib/usePopper.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["usePopper.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,EAA2B,yBAA3B,EAAsD,aAAtD,EAAqE,SAArE,QAAsF,2BAAtF;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,OAAO,KAAK,QAAZ,MAA0B,g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IAAR,CACE,CACE,gGADF,EAEE,qGAFF,EAGE,2EAHF,EAIE,uEAJF,EAKE,IALF,EAME,yFANF,EAOE,oGAPF,EAQE,kGARF,EASE,WATF,EAUE,4FAVF,EAWE,6FAXF,EAYE,IAZF,EAaE,2FAbF,EAcE,2CAdF,EAeE,8EAfF,EAgBE,IAhBF,CAgBO,GAhBP,CADF;AAmBD;AACF,OAhCkB,CAiCnB;AACA;AACA;;AACD,KApCD,EAoCG,EApCH;AAqCD;;AAED,SAAO;AAAE,IAAA,SAAF;AAAa,IAAA,YAAb;AAA2B,IAAA;AAA3B,GAAP;AACD","sourcesContent":["import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount, canUseDOM } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { isIntersectingModifier } from './isIntersectingModifier';\nimport {\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n getBasePlacement,\n} from './utils/index';\nimport type { PopperVirtualElement, PopperOptions, PositioningProps } from './types';\n\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\ninterface UsePopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n}\n\n//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nfunction hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n\n/**\n * Provides a callback to resolve Popper options, it's stable and should be used as a dependency to trigger updates\n * of Popper options.\n *\n * A callback is used there intentionally as some of Popper.js modifiers require DOM nodes (targer, container, arrow)\n * that can't be resolved properly during an initial rendering.\n */\nfunction usePopperOptions(options: PopperOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionFixed,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(align, position, isRtl);\n const strategy = positionFixed ? 'fixed' : 'absolute';\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(offset) : offset },\n }\n : null,\n [offset, isRtl],\n );\n\n return React.useCallback(\n (\n target: HTMLElement | PopperJs.VirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ): PopperJs.Options => {\n const scrollParentElement: HTMLElement = getScrollParent(container);\n const hasScrollableElement = scrollParentElement\n ? scrollParentElement !== scrollParentElement.ownerDocument?.body\n : false;\n\n const modifiers: PopperJs.Options['modifiers'] = [\n isIntersectingModifier,\n\n /**\n * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content\n * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of\n * a patch modifies \".forceUpdate()\" directly after a Popper will be created.\n */\n {\n name: 'positionStyleFix',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n effect: ({ state, instance }: { state: PopperJs.State; instance: PopperInstance }) => {\n // \".isFirstRun\" is a part of our patch, on a first evaluation it will \"undefined\"\n // should be disabled for subsequent runs as it breaks positioning for them\n if (instance.isFirstRun !== false) {\n popperOriginalPositionRef.current = state.elements.popper.style.position;\n state.elements.popper.style.position = 'fixed';\n }\n\n return () => undefined;\n },\n requires: [],\n },\n\n { name: 'flip', options: { flipVariations: true } },\n\n /**\n * pinned disables the flip modifier by setting flip.enabled to false; this\n * disables automatic repositioning of the popper box; it will always be placed according to\n * the values of `align` and `position` props, regardless of the size of the component, the\n * reference element or the viewport.\n */\n pinned && { name: 'flip', enabled: false },\n\n /**\n * When the popper box is placed in the context of a scrollable element, we need to set\n * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'\n * (default is 'viewport') so that the popper box will stick with the targetRef when we\n * scroll targetRef out of the viewport.\n */\n hasScrollableElement && { name: 'flip', options: { boundary: 'clippingParents' } },\n hasScrollableElement && { name: 'preventOverflow', options: { boundary: 'clippingParents' } },\n\n offsetModifier,\n\n /**\n * This modifier is necessary to retain behaviour from popper v1 where untethered poppers are allowed by\n * default. i.e. popper is still rendered fully in the viewport even if anchor element is no longer in the\n * viewport.\n */\n unstable_disableTether && {\n name: 'preventOverflow',\n options: { altAxis: unstable_disableTether === 'all', tether: false },\n },\n\n flipBoundary && {\n name: 'flip',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary),\n },\n },\n overflowBoundary && {\n name: 'preventOverflow',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n },\n\n {\n // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\n // popper-maxsize-modifier only calculates the max sizes.\n // This modifier can apply max sizes always, or apply the max sizes only when overflow is detected\n name: 'applyMaxSize',\n enabled: !!autoSize,\n phase: 'beforeWrite' as PopperJs.ModifierPhases,\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n fn({ state, options: modifierOptions }: PopperJs.ModifierArguments<{}>) {\n const overflow = PopperJs.detectOverflow(state, modifierOptions);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const basePlacement = getBasePlacement(state.placement);\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\n state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n },\n },\n\n /**\n * This modifier is necessary in order to render the pointer. Refs are resolved in effects, so it can't be\n * placed under computed modifiers. Deep merge is not required as this modifier has only these properties.\n */\n {\n name: 'arrow',\n enabled: !!arrow,\n options: { element: arrow, padding: arrowPadding },\n },\n\n /**\n * Modifies popper offsets to cover the reference rect, but still keep edge alignment\n */\n {\n name: 'coverTarget',\n enabled: !!coverTarget,\n phase: 'main',\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n fn({ state }: PopperJs.ModifierArguments<{}>) {\n const basePlacement = getBasePlacement(state.placement);\n switch (basePlacement) {\n case 'bottom':\n state.modifiersData.popperOffsets!.y -= state.rects.reference.height;\n break;\n case 'top':\n state.modifiersData.popperOffsets!.y += state.rects.reference.height;\n break;\n case 'left':\n state.modifiersData.popperOffsets!.x += state.rects.reference.width;\n break;\n case 'right':\n state.modifiersData.popperOffsets!.x -= state.rects.reference.width;\n break;\n }\n },\n },\n ].filter(Boolean) as PopperJs.Options['modifiers']; // filter boolean conditional spreading values\n\n const popperOptions: PopperJs.Options = {\n modifiers,\n\n placement,\n strategy,\n };\n\n return popperOptions;\n },\n [\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n pinned,\n\n // These can be skipped from deps as they will not ever change\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * Exposes Popper positioning API via React hook. Contains few important differences between an official \"react-popper\"\n * package:\n * - style attributes are applied directly on DOM to avoid re-renders\n * - refs changes and resolution is handled properly without re-renders\n * - contains a specific to React fix related to initial positioning when containers have components with managed focus\n * to avoid focus jumps\n */\nexport function usePopper(\n options: UsePopperOptions = {},\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { enabled = true } = options;\n const isFirstMount = useFirstMount();\n\n const popperOriginalPositionRef = React.useRef<string>('absolute');\n const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);\n\n const popperInstanceRef = React.useRef<PopperInstance | null>(null);\n\n const handlePopperUpdate = useEventCallback(() => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n let popperInstance: PopperInstance | null = null;\n\n if (canUseDOM() && enabled) {\n if (target && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n target,\n containerRef.current,\n resolvePopperOptions(target, containerRef.current, arrowRef.current),\n );\n }\n }\n\n if (popperInstance) {\n /**\n * The patch updates `.forceUpdate()` Popper function which restores the original position before the first\n * forceUpdate() call. See also \"positionStyleFix\" modifier in usePopperOptions().\n */\n const originalForceUpdate = popperInstance.forceUpdate;\n\n popperInstance.isFirstRun = true;\n popperInstance.forceUpdate = () => {\n if (popperInstance?.isFirstRun) {\n popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;\n popperInstance.isFirstRun = false;\n }\n\n originalForceUpdate();\n };\n }\n\n popperInstanceRef.current = popperInstance;\n });\n\n // Refs are managed by useCallbackRef() to handle ref updates scenarios.\n //\n // The first scenario are updates for a targetRef, we can handle it properly only via callback refs, but it causes\n // re-renders (we would like to avoid them).\n //\n // The second problem is related to refs resolution on React's layer: refs are resolved in the same order as effects\n // that causes an issue when you have a container inside a target, for example: a menu in ChatMessage.\n //\n // function ChatMessage(props) {\n // <div className=\"message\" ref={targetRef}> // 3) ref will be resolved only now, but it's too late already\n // <Popper target={targetRef}> // 2) create a popper instance\n // <div className=\"menu\" /> // 1) capture ref from this element\n // </Popper>\n // </div>\n // }\n //\n // Check a demo on CodeSandbox: https://codesandbox.io/s/popper-refs-emy60.\n //\n // This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation\n // to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.\n const targetRef = useCallbackRef<HTMLElement | PopperJs.VirtualElement | null>(null, handlePopperUpdate, true);\n const containerRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n const arrowRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n\n // Stores external target from options.target or setTarget\n const overrideTargetRef = useCallbackRef<HTMLElement | PopperVirtualElement | null>(null, handlePopperUpdate, true);\n\n React.useImperativeHandle(\n options.popperRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n setTarget: (target: HTMLElement | PopperVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (options.target) {\n overrideTargetRef.current = options.target;\n }\n }, [options.target, overrideTargetRef]);\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [handlePopperUpdate, options.enabled]);\n useIsomorphicLayoutEffect(\n () => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(overrideTargetRef.current ?? targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n },\n // Missing deps:\n // isFirstMount - Should never change after mount\n // arrowRef, containerRef, targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [resolvePopperOptions],\n );\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker?.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["usePopperMouseTarget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,6BAAT,QAA8C,iCAA9C;AAGA;;;;;;;AAOG;;AACH,OAAO,MAAM,oBAAoB,GAAI,YAAD,IAA6E;AAC/G,QAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAoD,YAApD,CAA5C;;AAEA,QAAM,qBAAqB,GAAI,KAAD,IAA4D;AACxF,QAAI,KAAK,KAAK,SAAV,IAAuB,KAAK,KAAK,IAArC,EAA2C;AACzC,MAAA,iBAAiB,CAAC,SAAD,CAAjB;AACA;AACD;;AAED,QAAI,UAAJ;;AACA,QAAI,EAAE,KAAK,YAAY,UAAnB,CAAJ,EAAoC;AAClC,MAAA,UAAU,GAAG,KAAK,CAAC,WAAnB;AACD,KAFD,MAEO;AACL,MAAA,UAAU,GAAG,KAAb;AACD;;AAED,QAAI,EAAE,UAAU,YAAY,UAAxB,KAAuC,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAApE,EAAkF;AAChF;AACA,MAAA,OAAO,CAAC,KAAR,CAAc,0DAAd;AACD;;AAED,UAAM,aAAa,GAAG,6BAA6B,CAAC,UAAD,CAAnD;AACA,IAAA,iBAAiB,CAAC,aAAD,CAAjB;AACD,GApBD;;AAsBA,SAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA1BM","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport * as PopperJs from '@popperjs/core';\n\n/**\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePopperMouseTarget = (initialState?: PopperJs.VirtualElement | (() => PopperJs.VirtualElement)) => {\n const [virtualElement, setVirtualElement] = React.useState<PopperJs.VirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePopperMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Returns the base placement value
|
3
|
-
* @param placement - the popper placement (i.e. bottom-start)
|
4
|
-
*
|
5
|
-
* @returns bottom-start -> bottom
|
6
|
-
*/
|
7
|
-
export function getBasePlacement(placement) {
|
8
|
-
return placement.split('-')[0];
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=getBasePlacement.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["utils/getBasePlacement.ts"],"names":[],"mappings":"AAEA;;;;;AAKG;AACH,OAAM,SAAU,gBAAV,CAA2B,SAA3B,EAAwD;AAC5D,SAAO,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CAAP;AACD","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\n/**\n * Returns the base placement value\n * @param placement - the popper placement (i.e. bottom-start)\n *\n * @returns bottom-start -> bottom\n */\nexport function getBasePlacement(placement: PopperJs.Placement): PopperJs.BasePlacement {\n return placement.split('-')[0] as PopperJs.BasePlacement;\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["usePopper.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,QAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,wBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA,C,CAqBA;AACA;AACA;;AAEA;;;AAGG;;;AACH,SAAS,gBAAT,CAA0B,IAA1B,EAAoC;SAAA,CAClC;;;AACA,QAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAL,KAAkB,QAAlB,IACA,IAAI,CAAC,QAAL,KAAkB,OADlB,IAEA,IAAI,CAAC,QAAL,KAAkB,QAFlB,IAGA,IAAI,CAAC,QAAL,KAAkB,UAJpB;;AAMA,MAAI,sBAAJ,EAA4B;AAC1B,WAAO,CAAC,EAAC,CAAA,EAAA,GAAA,OAAA,CAAA,qBAAA,CAAsB,IAAtB,CAAA,MAA2B,IAA3B,IAA2B,EAAA,KAAA,KAAA,CAA3B,GAA2B,KAAA,CAA3B,GAA2B,EAAA,CAAE,YAAF,CAAe,SAA3C,CAAR;AACD;;AAED,SAAO,KAAP;AACD;;AAED,SAAS,kBAAT,CAA4B,IAA5B,EAAsC;AACpC,SAAO,gBAAgB,CAAC,IAAD,CAAhB,GAAyB,UAAU,CAAC,aAApC,GAAoD,UAAU,CAAC,WAAtE;AACD;AAED;;;;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K,CAAC,SAAN,CAAgB,MAAK;;;AACnB,UAAI,YAAY,CAAC,OAAjB,EAA0B;AACxB,cAAM,WAAW,GAAG,YAAY,CAAC,OAAjC;AACA,cAAM,UAAU,GAAG,CAAA,EAAA,GAAA,WAAW,CAAC,aAAZ,MAAyB,IAAzB,IAAyB,EAAA,KAAA,KAAA,CAAzB,GAAyB,KAAA,CAAzB,GAAyB,EAAA,CAAE,gBAAF,CAAmB,WAAnB,EAAgC,UAAU,CAAC,YAA3C,EAAyD;AACnG,UAAA,UAAU,EAAE;AADuF,SAAzD,CAA5C;;AAIA,eAAO,UAAU,KAAA,IAAV,IAAA,UAAU,KAAA,KAAA,CAAV,GAAU,KAAA,CAAV,GAAA,UAAU,CAAE,QAAZ,EAAP,EAA+B;AAC7B,gBAAM,IAAI,GAAG,UAAU,CAAC,WAAxB,CAD6B,CAE7B;;AACA,UAAA,OAAO,CAAC,IAAR,CAAa,WAAb,EAA0B,IAA1B,EAH6B,CAI7B;;AACA,UAAA,OAAO,CAAC,IAAR,CACE,CACE,gGADF,EAEE,qGAFF,EAGE,2EAHF,EAIE,uEAJF,EAKE,IALF,EAME,yFANF,EAOE,oGAPF,EAQE,kGARF,EASE,WATF,EAUE,4FAVF,EAWE,6FAXF,EAYE,IAZF,EAaE,2FAbF,EAcE,2CAdF,EAeE,8EAfF,EAgBE,IAhBF,CAgBO,GAhBP,CADF;AAmBD;AACF,OAhCkB,CAiCnB;AACA;AACA;;AACD,KApCD,EAoCG,EApCH;AAqCD;;AAED,SAAO;AAAE,IAAA,SAAF;AAAa,IAAA,YAAb;AAA2B,IAAA;AAA3B,GAAP;AACD;;AAxLD,OAAA,CAAA,SAAA,GAAA,SAAA","sourcesContent":["import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount, canUseDOM } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { isIntersectingModifier } from './isIntersectingModifier';\nimport {\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n getBasePlacement,\n} from './utils/index';\nimport type { PopperVirtualElement, PopperOptions, PositioningProps } from './types';\n\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\ninterface UsePopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n}\n\n//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nfunction hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n\n/**\n * Provides a callback to resolve Popper options, it's stable and should be used as a dependency to trigger updates\n * of Popper options.\n *\n * A callback is used there intentionally as some of Popper.js modifiers require DOM nodes (targer, container, arrow)\n * that can't be resolved properly during an initial rendering.\n */\nfunction usePopperOptions(options: PopperOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionFixed,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(align, position, isRtl);\n const strategy = positionFixed ? 'fixed' : 'absolute';\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(offset) : offset },\n }\n : null,\n [offset, isRtl],\n );\n\n return React.useCallback(\n (\n target: HTMLElement | PopperJs.VirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ): PopperJs.Options => {\n const scrollParentElement: HTMLElement = getScrollParent(container);\n const hasScrollableElement = scrollParentElement\n ? scrollParentElement !== scrollParentElement.ownerDocument?.body\n : false;\n\n const modifiers: PopperJs.Options['modifiers'] = [\n isIntersectingModifier,\n\n /**\n * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content\n * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of\n * a patch modifies \".forceUpdate()\" directly after a Popper will be created.\n */\n {\n name: 'positionStyleFix',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n effect: ({ state, instance }: { state: PopperJs.State; instance: PopperInstance }) => {\n // \".isFirstRun\" is a part of our patch, on a first evaluation it will \"undefined\"\n // should be disabled for subsequent runs as it breaks positioning for them\n if (instance.isFirstRun !== false) {\n popperOriginalPositionRef.current = state.elements.popper.style.position;\n state.elements.popper.style.position = 'fixed';\n }\n\n return () => undefined;\n },\n requires: [],\n },\n\n { name: 'flip', options: { flipVariations: true } },\n\n /**\n * pinned disables the flip modifier by setting flip.enabled to false; this\n * disables automatic repositioning of the popper box; it will always be placed according to\n * the values of `align` and `position` props, regardless of the size of the component, the\n * reference element or the viewport.\n */\n pinned && { name: 'flip', enabled: false },\n\n /**\n * When the popper box is placed in the context of a scrollable element, we need to set\n * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'\n * (default is 'viewport') so that the popper box will stick with the targetRef when we\n * scroll targetRef out of the viewport.\n */\n hasScrollableElement && { name: 'flip', options: { boundary: 'clippingParents' } },\n hasScrollableElement && { name: 'preventOverflow', options: { boundary: 'clippingParents' } },\n\n offsetModifier,\n\n /**\n * This modifier is necessary to retain behaviour from popper v1 where untethered poppers are allowed by\n * default. i.e. popper is still rendered fully in the viewport even if anchor element is no longer in the\n * viewport.\n */\n unstable_disableTether && {\n name: 'preventOverflow',\n options: { altAxis: unstable_disableTether === 'all', tether: false },\n },\n\n flipBoundary && {\n name: 'flip',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary),\n },\n },\n overflowBoundary && {\n name: 'preventOverflow',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n },\n\n {\n // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\n // popper-maxsize-modifier only calculates the max sizes.\n // This modifier can apply max sizes always, or apply the max sizes only when overflow is detected\n name: 'applyMaxSize',\n enabled: !!autoSize,\n phase: 'beforeWrite' as PopperJs.ModifierPhases,\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n fn({ state, options: modifierOptions }: PopperJs.ModifierArguments<{}>) {\n const overflow = PopperJs.detectOverflow(state, modifierOptions);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const basePlacement = getBasePlacement(state.placement);\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\n state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n },\n },\n\n /**\n * This modifier is necessary in order to render the pointer. Refs are resolved in effects, so it can't be\n * placed under computed modifiers. Deep merge is not required as this modifier has only these properties.\n */\n {\n name: 'arrow',\n enabled: !!arrow,\n options: { element: arrow, padding: arrowPadding },\n },\n\n /**\n * Modifies popper offsets to cover the reference rect, but still keep edge alignment\n */\n {\n name: 'coverTarget',\n enabled: !!coverTarget,\n phase: 'main',\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n fn({ state }: PopperJs.ModifierArguments<{}>) {\n const basePlacement = getBasePlacement(state.placement);\n switch (basePlacement) {\n case 'bottom':\n state.modifiersData.popperOffsets!.y -= state.rects.reference.height;\n break;\n case 'top':\n state.modifiersData.popperOffsets!.y += state.rects.reference.height;\n break;\n case 'left':\n state.modifiersData.popperOffsets!.x += state.rects.reference.width;\n break;\n case 'right':\n state.modifiersData.popperOffsets!.x -= state.rects.reference.width;\n break;\n }\n },\n },\n ].filter(Boolean) as PopperJs.Options['modifiers']; // filter boolean conditional spreading values\n\n const popperOptions: PopperJs.Options = {\n modifiers,\n\n placement,\n strategy,\n };\n\n return popperOptions;\n },\n [\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n pinned,\n\n // These can be skipped from deps as they will not ever change\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * Exposes Popper positioning API via React hook. Contains few important differences between an official \"react-popper\"\n * package:\n * - style attributes are applied directly on DOM to avoid re-renders\n * - refs changes and resolution is handled properly without re-renders\n * - contains a specific to React fix related to initial positioning when containers have components with managed focus\n * to avoid focus jumps\n */\nexport function usePopper(\n options: UsePopperOptions = {},\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { enabled = true } = options;\n const isFirstMount = useFirstMount();\n\n const popperOriginalPositionRef = React.useRef<string>('absolute');\n const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);\n\n const popperInstanceRef = React.useRef<PopperInstance | null>(null);\n\n const handlePopperUpdate = useEventCallback(() => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n let popperInstance: PopperInstance | null = null;\n\n if (canUseDOM() && enabled) {\n if (target && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n target,\n containerRef.current,\n resolvePopperOptions(target, containerRef.current, arrowRef.current),\n );\n }\n }\n\n if (popperInstance) {\n /**\n * The patch updates `.forceUpdate()` Popper function which restores the original position before the first\n * forceUpdate() call. See also \"positionStyleFix\" modifier in usePopperOptions().\n */\n const originalForceUpdate = popperInstance.forceUpdate;\n\n popperInstance.isFirstRun = true;\n popperInstance.forceUpdate = () => {\n if (popperInstance?.isFirstRun) {\n popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;\n popperInstance.isFirstRun = false;\n }\n\n originalForceUpdate();\n };\n }\n\n popperInstanceRef.current = popperInstance;\n });\n\n // Refs are managed by useCallbackRef() to handle ref updates scenarios.\n //\n // The first scenario are updates for a targetRef, we can handle it properly only via callback refs, but it causes\n // re-renders (we would like to avoid them).\n //\n // The second problem is related to refs resolution on React's layer: refs are resolved in the same order as effects\n // that causes an issue when you have a container inside a target, for example: a menu in ChatMessage.\n //\n // function ChatMessage(props) {\n // <div className=\"message\" ref={targetRef}> // 3) ref will be resolved only now, but it's too late already\n // <Popper target={targetRef}> // 2) create a popper instance\n // <div className=\"menu\" /> // 1) capture ref from this element\n // </Popper>\n // </div>\n // }\n //\n // Check a demo on CodeSandbox: https://codesandbox.io/s/popper-refs-emy60.\n //\n // This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation\n // to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.\n const targetRef = useCallbackRef<HTMLElement | PopperJs.VirtualElement | null>(null, handlePopperUpdate, true);\n const containerRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n const arrowRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n\n // Stores external target from options.target or setTarget\n const overrideTargetRef = useCallbackRef<HTMLElement | PopperVirtualElement | null>(null, handlePopperUpdate, true);\n\n React.useImperativeHandle(\n options.popperRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n setTarget: (target: HTMLElement | PopperVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (options.target) {\n overrideTargetRef.current = options.target;\n }\n }, [options.target, overrideTargetRef]);\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [handlePopperUpdate, options.enabled]);\n useIsomorphicLayoutEffect(\n () => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(overrideTargetRef.current ?? targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n },\n // Missing deps:\n // isFirstMount - Should never change after mount\n // arrowRef, containerRef, targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [resolvePopperOptions],\n );\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker?.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["usePopperMouseTarget.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,MAAM,oBAAoB,GAAI,YAAD,IAA6E;AAC/G,QAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAoD,YAApD,CAA5C;;AAEA,QAAM,qBAAqB,GAAI,KAAD,IAA4D;AACxF,QAAI,KAAK,KAAK,SAAV,IAAuB,KAAK,KAAK,IAArC,EAA2C;AACzC,MAAA,iBAAiB,CAAC,SAAD,CAAjB;AACA;AACD;;AAED,QAAI,UAAJ;;AACA,QAAI,EAAE,KAAK,YAAY,UAAnB,CAAJ,EAAoC;AAClC,MAAA,UAAU,GAAG,KAAK,CAAC,WAAnB;AACD,KAFD,MAEO;AACL,MAAA,UAAU,GAAG,KAAb;AACD;;AAED,QAAI,EAAE,UAAU,YAAY,UAAxB,KAAuC,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAApE,EAAkF;AAChF;AACA,MAAA,OAAO,CAAC,KAAR,CAAc,0DAAd;AACD;;AAED,UAAM,aAAa,GAAG,+BAAA,CAAA,6BAAA,CAA8B,UAA9B,CAAtB;AACA,IAAA,iBAAiB,CAAC,aAAD,CAAjB;AACD,GApBD;;AAsBA,SAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA1BM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport * as PopperJs from '@popperjs/core';\n\n/**\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePopperMouseTarget = (initialState?: PopperJs.VirtualElement | (() => PopperJs.VirtualElement)) => {\n const [virtualElement, setVirtualElement] = React.useState<PopperJs.VirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePopperMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.getBasePlacement = void 0;
|
7
|
-
/**
|
8
|
-
* Returns the base placement value
|
9
|
-
* @param placement - the popper placement (i.e. bottom-start)
|
10
|
-
*
|
11
|
-
* @returns bottom-start -> bottom
|
12
|
-
*/
|
13
|
-
|
14
|
-
function getBasePlacement(placement) {
|
15
|
-
return placement.split('-')[0];
|
16
|
-
}
|
17
|
-
|
18
|
-
exports.getBasePlacement = getBasePlacement;
|
19
|
-
//# sourceMappingURL=getBasePlacement.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["utils/getBasePlacement.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,gBAAhB,CAAiC,SAAjC,EAA8D;AAC5D,SAAO,SAAS,CAAC,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CAAP;AACD;;AAFD,OAAA,CAAA,gBAAA,GAAA,gBAAA","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\n/**\n * Returns the base placement value\n * @param placement - the popper placement (i.e. bottom-start)\n *\n * @returns bottom-start -> bottom\n */\nexport function getBasePlacement(placement: PopperJs.Placement): PopperJs.BasePlacement {\n return placement.split('-')[0] as PopperJs.BasePlacement;\n}\n"],"sourceRoot":"../src/"}
|