@fluentui/react-positioning 9.0.0-alpha.9 → 9.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +1279 -1
- package/CHANGELOG.md +577 -2
- package/dist/react-positioning.d.ts +95 -27
- package/lib/createArrowStyles.d.ts +27 -0
- package/lib/createArrowStyles.js +75 -0
- package/lib/createArrowStyles.js.map +1 -0
- package/lib/createVirtualElementFromClick.d.ts +6 -0
- package/lib/createVirtualElementFromClick.js +26 -0
- package/lib/createVirtualElementFromClick.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +19 -29
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -1
- package/lib/usePopper.d.ts +21 -1
- package/lib/usePopper.js +364 -284
- package/lib/usePopper.js.map +1 -1
- package/lib/usePopperMouseTarget.d.ts +11 -0
- package/lib/usePopperMouseTarget.js +40 -0
- package/lib/usePopperMouseTarget.js.map +1 -0
- package/lib/utils/getBasePlacement.d.ts +8 -0
- package/lib/utils/getBasePlacement.js +10 -0
- package/lib/utils/getBasePlacement.js.map +1 -0
- package/lib/utils/getBoundary.d.ts +1 -1
- package/lib/utils/getBoundary.js +15 -11
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.d.ts +0 -1
- package/lib/utils/getReactFiberFromNode.js +39 -35
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +46 -32
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/index.d.ts +5 -3
- package/lib/utils/index.js +5 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.d.ts +10 -0
- package/lib/utils/mergeArrowOffset.js +42 -0
- package/lib/utils/mergeArrowOffset.js.map +1 -0
- package/lib/utils/positioningHelper.d.ts +3 -3
- package/lib/utils/positioningHelper.js +42 -34
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
- package/lib/utils/resolvePositioningShorthand.js +63 -0
- package/lib/utils/resolvePositioningShorthand.js.map +1 -0
- package/lib/utils/useCallbackRef.js +35 -29
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createArrowStyles.d.ts +27 -0
- package/lib-commonjs/createArrowStyles.js +84 -0
- package/lib-commonjs/createArrowStyles.js.map +1 -0
- package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
- package/lib-commonjs/createVirtualElementFromClick.js +35 -0
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
- package/lib-commonjs/index.d.ts +4 -0
- package/lib-commonjs/index.js +31 -2
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.d.ts +19 -29
- package/lib-commonjs/types.js +4 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePopper.d.ts +21 -1
- package/lib-commonjs/usePopper.js +378 -287
- package/lib-commonjs/usePopper.js.map +1 -1
- package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
- package/lib-commonjs/usePopperMouseTarget.js +51 -0
- package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
- package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
- package/lib-commonjs/utils/getBasePlacement.js +19 -0
- package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
- package/lib-commonjs/utils/getBoundary.d.ts +1 -1
- package/lib-commonjs/utils/getBoundary.js +24 -13
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +45 -36
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +56 -33
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.d.ts +5 -3
- package/lib-commonjs/utils/index.js +19 -5
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
- package/lib-commonjs/utils/mergeArrowOffset.js +51 -0
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
- package/lib-commonjs/utils/positioningHelper.d.ts +3 -3
- package/lib-commonjs/utils/positioningHelper.js +53 -35
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
- package/lib-commonjs/utils/resolvePositioningShorthand.js +72 -0
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
- package/lib-commonjs/utils/useCallbackRef.js +46 -32
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +13 -10
- package/config/api-extractor.json +0 -3
- package/etc/react-positioning.api.md +0 -70
- package/just.config.ts +0 -3
- package/lib/utils/isBrowser.d.ts +0 -1
- package/lib/utils/isBrowser.js +0 -4
- package/lib/utils/isBrowser.js.map +0 -1
- package/lib-amd/index.d.ts +0 -2
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/types.d.ts +0 -78
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
- package/lib-amd/usePopper.d.ts +0 -15
- package/lib-amd/usePopper.js +0 -281
- package/lib-amd/usePopper.js.map +0 -1
- package/lib-amd/utils/getBoundary.d.ts +0 -6
- package/lib-amd/utils/getBoundary.js +0 -23
- package/lib-amd/utils/getBoundary.js.map +0 -1
- package/lib-amd/utils/getReactFiberFromNode.d.ts +0 -109
- package/lib-amd/utils/getReactFiberFromNode.js +0 -47
- package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
- package/lib-amd/utils/getScrollParent.d.ts +0 -12
- package/lib-amd/utils/getScrollParent.js +0 -55
- package/lib-amd/utils/getScrollParent.js.map +0 -1
- package/lib-amd/utils/index.d.ts +0 -6
- package/lib-amd/utils/index.js +0 -11
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/isBrowser.d.ts +0 -1
- package/lib-amd/utils/isBrowser.js +0 -8
- package/lib-amd/utils/isBrowser.js.map +0 -1
- package/lib-amd/utils/positioningHelper.d.ts +0 -7
- package/lib-amd/utils/positioningHelper.js +0 -45
- package/lib-amd/utils/positioningHelper.js.map +0 -1
- package/lib-amd/utils/useCallbackRef.d.ts +0 -19
- package/lib-amd/utils/useCallbackRef.js +0 -54
- package/lib-amd/utils/useCallbackRef.js.map +0 -1
- package/lib-commonjs/utils/isBrowser.d.ts +0 -1
- package/lib-commonjs/utils/isBrowser.js +0 -6
- package/lib-commonjs/utils/isBrowser.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;AAOG;;AACH,SAAgB,gBAAhB,CAAiC,UAAjC,EAAwE,WAAxE,EAA2F;AACzF,MAAI,eAAe,GAAG,UAAtB;;AACA,MAAI,CAAC,UAAL,EAAiB;AACf,WAAO,CAAC,CAAD,EAAI,WAAJ,CAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,eAAd,CAAJ,EAAoC;AAClC,IAAA,cAAc,CAAC,eAAD,EAAkB,WAAlB,CAAd;AACA,WAAO,eAAP;AACD;;AAED,MAAI,OAAO,eAAP,KAA2B,UAA/B,EAA2C;AACzC,UAAM,YAAY,GAAG,eAArB;;AACA,IAAA,eAAe,GAAG,YAAY,IAAG;AAC/B,YAAM,MAAM,GAAG,YAAY,CAAC,YAAD,CAA3B;AACA,MAAA,cAAc,CAAC,MAAD,EAAS,WAAT,CAAd;AACA,aAAO,MAAP;AACD,KAJD;AAKD,GAlBwF,CAoBzF;;;AACA,SAAO,CAAC,CAAD,EAAI,CAAJ,CAAP;AACD;;AAtBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAwBA,MAAM,cAAc,GAAG,CAAC,MAAD,EAAiE,WAAjE,KAAwF;AAC7G,MAAI,MAAM,CAAC,CAAD,CAAN,KAAc,IAAd,IAAsB,MAAM,CAAC,CAAD,CAAN,KAAc,SAAxC,EAAmD;AACjD,IAAA,MAAM,CAAC,CAAD,CAAN,IAAa,WAAb;AACD,GAFD,MAEO;AACL,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,WAAZ;AACD;AACF,CAND","sourceRoot":""}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as PopperJs from '@popperjs/core';
|
2
|
-
import {
|
2
|
+
import type { Offset } from '../types';
|
3
3
|
/**
|
4
4
|
* @see positioninHelper.test.ts for expected placement values
|
5
5
|
*/
|
6
|
-
export declare const getPlacement: (align?: "
|
7
|
-
export declare const applyRtlToOffset: (offset:
|
6
|
+
export declare const getPlacement: (align?: "bottom" | "top" | "center" | "start" | "end" | undefined, position?: "above" | "below" | "before" | "after" | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
|
7
|
+
export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
|
@@ -1,43 +1,61 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.applyRtlToOffset = exports.getPlacement = void 0;
|
7
|
+
|
8
|
+
const getPositionMap = rtl => ({
|
9
|
+
above: 'top',
|
10
|
+
below: 'bottom',
|
11
|
+
before: rtl ? 'right' : 'left',
|
12
|
+
after: rtl ? 'left' : 'right'
|
13
|
+
});
|
14
|
+
|
15
|
+
const getAlignmentMap = rtl => ({
|
16
|
+
start: rtl ? 'end' : 'start',
|
17
|
+
end: rtl ? 'start' : 'end',
|
18
|
+
top: 'start',
|
19
|
+
bottom: 'end',
|
20
|
+
center: ''
|
21
|
+
});
|
22
|
+
|
23
|
+
const shouldAlignToCenter = (p, a) => {
|
24
|
+
const positionedVertically = p === 'above' || p === 'below';
|
25
|
+
const alignedVertically = a === 'top' || a === 'bottom';
|
26
|
+
return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
|
20
27
|
};
|
21
28
|
/**
|
22
29
|
* @see positioninHelper.test.ts for expected placement values
|
23
30
|
*/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
|
32
|
+
|
33
|
+
const getPlacement = (align, position, rtl) => {
|
34
|
+
const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
|
35
|
+
const computedPosition = position && getPositionMap(rtl)[position];
|
36
|
+
const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
|
37
|
+
|
38
|
+
if (computedPosition && computedAlignmnent) {
|
39
|
+
return `${computedPosition}-${computedAlignmnent}`;
|
40
|
+
}
|
41
|
+
|
42
|
+
return computedPosition || 'auto';
|
32
43
|
};
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
|
45
|
+
exports.getPlacement = getPlacement;
|
46
|
+
|
47
|
+
const applyRtlToOffset = offset => {
|
48
|
+
if (typeof offset === 'undefined') {
|
49
|
+
return undefined;
|
50
|
+
}
|
51
|
+
|
52
|
+
if (Array.isArray(offset)) {
|
53
|
+
offset[0] = offset[0] * -1;
|
54
|
+
return offset;
|
55
|
+
}
|
56
|
+
|
57
|
+
return param => exports.applyRtlToOffset(offset(param));
|
42
58
|
};
|
59
|
+
|
60
|
+
exports.applyRtlToOffset = applyRtlToOffset;
|
43
61
|
//# sourceMappingURL=positioningHelper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":";;;;;;;AAMA,MAAM,cAAc,GAAI,GAAD,KAAyD;AAC9E,EAAA,KAAK,EAAE,KADuE;AAE9E,EAAA,KAAK,EAAE,QAFuE;AAG9E,EAAA,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;AAI9E,EAAA,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;AAC7E,EAAA,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OADwD;AAE7E,EAAA,GAAG,EAAE,GAAG,GAAG,OAAH,GAAa,KAFwD;AAG7E,EAAA,GAAG,EAAE,OAHwE;AAI7E,EAAA,MAAM,EAAE,KAJqE;AAK7E,EAAA,MAAM,EAAE;AALqE,CAAvD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;AACnE,QAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;AACA,QAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;AAEA,SAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;AAEG;;;AACI,MAAM,YAAY,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAA8E;AACxG,QAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;AAEA,QAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;AACA,QAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAD,CAAf,CAAqB,SAArB,CAAxC;;AAEA,MAAI,gBAAgB,IAAI,kBAAxB,EAA4C;AAC1C,WAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;AACD;;AAED,SAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ;;AAaN,MAAM,gBAAgB,GAAI,MAAD,IAAmD;AACjF,MAAI,OAAO,MAAP,KAAkB,WAAtB,EAAmC;AACjC,WAAO,SAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzB,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,MAAM,CAAC,CAAD,CAAN,GAAa,CAAC,CAA1B;AAEA,WAAO,MAAP;AACD;;AAED,SAAS,KAAD,IAAgC,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAAxC;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourceRoot":""}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.resolvePositioningShorthand = void 0; // Look up table for shorthand to avoid parsing strings
|
7
|
+
|
8
|
+
const shorthandLookup = {
|
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
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
function resolvePositioningShorthand(shorthand) {
|
60
|
+
if (shorthand === undefined || shorthand === null) {
|
61
|
+
return {};
|
62
|
+
}
|
63
|
+
|
64
|
+
if (typeof shorthand === 'string') {
|
65
|
+
return shorthandLookup[shorthand];
|
66
|
+
}
|
67
|
+
|
68
|
+
return shorthand;
|
69
|
+
}
|
70
|
+
|
71
|
+
exports.resolvePositioningShorthand = resolvePositioningShorthand;
|
72
|
+
//# sourceMappingURL=resolvePositioningShorthand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/utils/resolvePositioningShorthand.ts"],"names":[],"mappings":";;;;;8CAEA;;AACA,MAAM,eAAe,GAAoF;AACvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GADgG;AAEvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAFwF;AAGvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAH0F;AAIvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAJgG;AAKvG,iBAAe;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GALwF;AAMvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAN0F;AAOvG,EAAA,MAAM,EAAE;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GAP+F;AAQvG,gBAAc;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GARyF;AASvG,mBAAiB;AAAE,IAAA,QAAQ,EAAE,QAAZ;AAAsB,IAAA,KAAK,EAAE;AAA7B,GATsF;AAUvG,EAAA,KAAK,EAAE;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAVgG;AAWvG,eAAa;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B,GAX0F;AAYvG,kBAAgB;AAAE,IAAA,QAAQ,EAAE,OAAZ;AAAqB,IAAA,KAAK,EAAE;AAA5B;AAZuF,CAAzG;;AAeA,SAAgB,2BAAhB,CACE,SADF,EACoD;AAElD,MAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;AACjD,WAAO,EAAP;AACD;;AAED,MAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;AACjC,WAAO,eAAe,CAAC,SAAD,CAAtB;AACD;;AAED,SAAO,SAAP;AACD;;AAZD,OAAA,CAAA,2BAAA,GAAA,2BAAA","sourceRoot":""}
|
@@ -1,7 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useCallbackRef = void 0;
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
5
11
|
/**
|
6
12
|
* Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
|
7
13
|
* changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
|
@@ -19,36 +25,44 @@ var react_utilities_1 = require("@fluentui/react-utilities");
|
|
19
25
|
* ref.current = 1;
|
20
26
|
* // prints 0 -> 1
|
21
27
|
*/
|
28
|
+
|
29
|
+
|
22
30
|
function useCallbackRef(initialValue, callback, skipInitialResolve) {
|
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
|
-
|
31
|
+
const isFirst = React.useRef(true);
|
32
|
+
const [ref] = React.useState(() => ({
|
33
|
+
// value
|
34
|
+
value: initialValue,
|
35
|
+
// last callback
|
36
|
+
callback,
|
37
|
+
// "memoized" public interface
|
38
|
+
facade: {
|
39
|
+
get current() {
|
40
|
+
return ref.value;
|
41
|
+
},
|
42
|
+
|
43
|
+
set current(value) {
|
44
|
+
const last = ref.value;
|
45
|
+
|
46
|
+
if (last !== value) {
|
47
|
+
ref.value = value;
|
48
|
+
|
49
|
+
if (skipInitialResolve && isFirst.current) {
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
|
53
|
+
ref.callback(value, last);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
}));
|
59
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
60
|
+
isFirst.current = false;
|
61
|
+
}, []); // update callback
|
62
|
+
|
63
|
+
ref.callback = callback;
|
64
|
+
return ref.facade;
|
52
65
|
}
|
66
|
+
|
53
67
|
exports.useCallbackRef = useCallbackRef;
|
54
68
|
//# sourceMappingURL=useCallbackRef.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["../../src/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;AAE5B,QAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAAa,IAAb,CAAhB;AACA,QAAM,CAAC,GAAD,IAAQ,KAAK,CAAC,QAAN,CAAe,OAAO;AAClC;AACA,IAAA,KAAK,EAAE,YAF2B;AAGlC;AACA,IAAA,QAJkC;AAKlC;AACA,IAAA,MAAM,EAAE;AACN,UAAI,OAAJ,GAAW;AACT,eAAO,GAAG,CAAC,KAAX;AACD,OAHK;;AAIN,UAAI,OAAJ,CAAY,KAAZ,EAAiB;AACf,cAAM,IAAI,GAAG,GAAG,CAAC,KAAjB;;AAEA,YAAI,IAAI,KAAK,KAAb,EAAoB;AAClB,UAAA,GAAG,CAAC,KAAJ,GAAY,KAAZ;;AAEA,cAAI,kBAAkB,IAAI,OAAO,CAAC,OAAlC,EAA2C;AACzC;AACD;;AAED,UAAA,GAAG,CAAC,QAAJ,CAAa,KAAb,EAAoB,IAApB;AACD;AACF;;AAhBK;AAN0B,GAAP,CAAf,CAAd;AA0BA,EAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,IAAA,OAAO,CAAC,OAAR,GAAkB,KAAlB;AACD,GAFD,EAEG,EAFH,EA7B4B,CAiC5B;;AACA,EAAA,GAAG,CAAC,QAAJ,GAAe,QAAf;AAEA,SAAO,GAAG,CAAC,MAAX;AACD;;AAxCD,OAAA,CAAA,cAAA,GAAA,cAAA","sourceRoot":""}
|
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-beta.4",
|
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",
|
@@ -13,27 +13,31 @@
|
|
13
13
|
"license": "MIT",
|
14
14
|
"scripts": {
|
15
15
|
"build": "just-scripts build",
|
16
|
+
"bundle-size": "bundle-size measure",
|
16
17
|
"clean": "just-scripts clean",
|
17
18
|
"code-style": "just-scripts code-style",
|
18
19
|
"just": "just-scripts",
|
19
20
|
"lint": "just-scripts lint",
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
21
|
+
"test": "jest",
|
22
|
+
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
23
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-positioning/src && yarn docs",
|
24
|
+
"type-check": "tsc -b tsconfig.json"
|
23
25
|
},
|
24
26
|
"devDependencies": {
|
25
|
-
"@fluentui/eslint-plugin": "
|
27
|
+
"@fluentui/eslint-plugin": "*",
|
26
28
|
"@fluentui/scripts": "^1.0.0",
|
27
29
|
"@types/react": "16.9.42",
|
28
30
|
"@types/react-dom": "16.9.10",
|
29
31
|
"react": "16.8.6",
|
30
|
-
"react-dom": "16.8.6"
|
32
|
+
"react-dom": "16.8.6",
|
33
|
+
"@fluentui/babel-make-styles": "9.0.0-beta.4"
|
31
34
|
},
|
32
35
|
"dependencies": {
|
33
|
-
"@fluentui/react-
|
34
|
-
"@fluentui/react-
|
36
|
+
"@fluentui/react-make-styles": "9.0.0-beta.4",
|
37
|
+
"@fluentui/react-shared-contexts": "9.0.0-beta.4",
|
38
|
+
"@fluentui/react-utilities": "9.0.0-beta.4",
|
35
39
|
"@popperjs/core": "~2.4.3",
|
36
|
-
"tslib": "^1.
|
40
|
+
"tslib": "^2.1.0"
|
37
41
|
},
|
38
42
|
"peerDependencies": {
|
39
43
|
"@types/react": ">=16.8.0 <18.0.0",
|
@@ -42,7 +46,6 @@
|
|
42
46
|
"react-dom": ">=16.8.0 <18.0.0"
|
43
47
|
},
|
44
48
|
"beachball": {
|
45
|
-
"tag": "alpha",
|
46
49
|
"disallowedChangeTypes": [
|
47
50
|
"major",
|
48
51
|
"minor",
|
@@ -1,70 +0,0 @@
|
|
1
|
-
## API Report File for "@fluentui/react-positioning"
|
2
|
-
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
4
|
-
|
5
|
-
```ts
|
6
|
-
|
7
|
-
import * as PopperJs from '@popperjs/core';
|
8
|
-
import * as React from 'react';
|
9
|
-
|
10
|
-
// @public (undocumented)
|
11
|
-
export type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
|
12
|
-
|
13
|
-
// @public (undocumented)
|
14
|
-
export type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
|
15
|
-
|
16
|
-
// @public (undocumented)
|
17
|
-
export type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];
|
18
|
-
|
19
|
-
// @public (undocumented)
|
20
|
-
export type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined];
|
21
|
-
|
22
|
-
// @public (undocumented)
|
23
|
-
export type OffsetFunctionParam = {
|
24
|
-
popper: PopperJs.Rect;
|
25
|
-
reference: PopperJs.Rect;
|
26
|
-
placement: PopperJs.Placement;
|
27
|
-
};
|
28
|
-
|
29
|
-
// @public (undocumented)
|
30
|
-
export interface PopperOptions extends PositioningProps {
|
31
|
-
enabled?: boolean;
|
32
|
-
// (undocumented)
|
33
|
-
onStateUpdate?: (state: Partial<PopperJs.State>) => void;
|
34
|
-
positioningDependencies?: React.DependencyList;
|
35
|
-
}
|
36
|
-
|
37
|
-
// @public (undocumented)
|
38
|
-
export type PopperRefHandle = {
|
39
|
-
updatePosition: () => void;
|
40
|
-
};
|
41
|
-
|
42
|
-
// @public (undocumented)
|
43
|
-
export type Position = 'above' | 'below' | 'before' | 'after';
|
44
|
-
|
45
|
-
// @public (undocumented)
|
46
|
-
export interface PositioningProps {
|
47
|
-
align?: Alignment;
|
48
|
-
arrowPadding?: number;
|
49
|
-
autoSize?: 'height' | 'width' | boolean;
|
50
|
-
containerRef?: React.Ref<PopperRefHandle>;
|
51
|
-
flipBoundary?: Boundary;
|
52
|
-
offset?: Offset;
|
53
|
-
overflowBoundary?: Boundary;
|
54
|
-
position?: Position;
|
55
|
-
positionFixed?: boolean;
|
56
|
-
unstable_disableTether?: boolean | 'all';
|
57
|
-
unstable_pinned?: boolean;
|
58
|
-
}
|
59
|
-
|
60
|
-
// @public
|
61
|
-
export function usePopper(options?: PopperOptions): {
|
62
|
-
targetRef: React.MutableRefObject<any>;
|
63
|
-
containerRef: React.MutableRefObject<any>;
|
64
|
-
arrowRef: React.MutableRefObject<any>;
|
65
|
-
};
|
66
|
-
|
67
|
-
|
68
|
-
// (No @packageDocumentation comment for this package)
|
69
|
-
|
70
|
-
```
|
package/just.config.ts
DELETED
package/lib/utils/isBrowser.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const isBrowser: () => boolean;
|
package/lib/utils/isBrowser.js
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
var hasDocument = typeof document === 'object' && document !== null;
|
2
|
-
var hasWindow = typeof window === 'object' && window !== null && window.self === window;
|
3
|
-
export var isBrowser = function () { return hasDocument && hasWindow; };
|
4
|
-
//# sourceMappingURL=isBrowser.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isBrowser.js","sourceRoot":"../src/","sources":["utils/isBrowser.tsx"],"names":[],"mappings":"AAAA,IAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC;AACtE,IAAM,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;AAE1F,MAAM,CAAC,IAAM,SAAS,GAAG,cAAM,OAAA,WAAW,IAAI,SAAS,EAAxB,CAAwB,CAAC","sourcesContent":["const hasDocument = typeof document === 'object' && document !== null;\nconst hasWindow = typeof window === 'object' && window !== null && window.self === window;\n\nexport const isBrowser = () => hasDocument && hasWindow;\n"]}
|
package/lib-amd/index.d.ts
DELETED
package/lib-amd/index.js
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "./usePopper"], function (require, exports, tslib_1, usePopper_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
tslib_1.__exportStar(usePopper_1, exports);
|
5
|
-
});
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;IAAA,2CAA4B","sourcesContent":["export * from './usePopper';\nexport * from './types';\n"]}
|
package/lib-amd/types.d.ts
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
import * as PopperJs from '@popperjs/core';
|
2
|
-
import * as React from 'react';
|
3
|
-
export declare type OffsetFunctionParam = {
|
4
|
-
popper: PopperJs.Rect;
|
5
|
-
reference: PopperJs.Rect;
|
6
|
-
placement: PopperJs.Placement;
|
7
|
-
};
|
8
|
-
export declare type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined];
|
9
|
-
export declare type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];
|
10
|
-
export declare type Position = 'above' | 'below' | 'before' | 'after';
|
11
|
-
export declare type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
|
12
|
-
export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
|
13
|
-
export declare type PopperRefHandle = {
|
14
|
-
updatePosition: () => void;
|
15
|
-
};
|
16
|
-
export interface PositioningProps {
|
17
|
-
/**
|
18
|
-
* Alignment for the component.
|
19
|
-
*/
|
20
|
-
align?: Alignment;
|
21
|
-
/** The element which will define the boundaries of the popper position for the flip behavior. */
|
22
|
-
flipBoundary?: Boundary;
|
23
|
-
/** The element which will define the boundaries of the popper position for the overflow behavior. */
|
24
|
-
overflowBoundary?: Boundary;
|
25
|
-
/** An imperative handle to Popper methods. */
|
26
|
-
containerRef?: React.Ref<PopperRefHandle>;
|
27
|
-
/**
|
28
|
-
* Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
|
29
|
-
* and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
|
30
|
-
* and 'start' | 'end' respectively),
|
31
|
-
* then provided value for 'align' will be ignored and 'center' will be used instead.
|
32
|
-
*/
|
33
|
-
position?: Position;
|
34
|
-
/**
|
35
|
-
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
36
|
-
* @default false
|
37
|
-
*/
|
38
|
-
positionFixed?: boolean;
|
39
|
-
/**
|
40
|
-
* Lets you displace a popper element from its reference element.
|
41
|
-
* This can be useful if you need to apply some margin between them or if you need to fine tune the
|
42
|
-
* position according to some custom logic.
|
43
|
-
*/
|
44
|
-
offset?: Offset;
|
45
|
-
/**
|
46
|
-
* Defines padding between the corner of the popup element and the arrow.
|
47
|
-
* Use to prevent the arrow from overlapping a rounded corner, for example.
|
48
|
-
*/
|
49
|
-
arrowPadding?: number;
|
50
|
-
/**
|
51
|
-
* When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
|
52
|
-
* "all" enables this behavior for all axis.
|
53
|
-
*/
|
54
|
-
unstable_disableTether?: boolean | 'all';
|
55
|
-
/**
|
56
|
-
* Disables automatic repositioning of the component; it will always be placed according to the values of `align` and
|
57
|
-
* `position` props, regardless of the size of the component, the reference element or the viewport.
|
58
|
-
*/
|
59
|
-
unstable_pinned?: boolean;
|
60
|
-
/**
|
61
|
-
* Applies max-height and max-width on popper to fit it within the available space in viewport.
|
62
|
-
* true enables this for both width and height.
|
63
|
-
* 'height' applies only `max-height` and 'width' for `max-width`
|
64
|
-
*/
|
65
|
-
autoSize?: 'height' | 'width' | boolean;
|
66
|
-
}
|
67
|
-
export interface PopperOptions extends PositioningProps {
|
68
|
-
/**
|
69
|
-
* If false, delays Popper's creation.
|
70
|
-
* @default true
|
71
|
-
*/
|
72
|
-
enabled?: boolean;
|
73
|
-
/**
|
74
|
-
* Array of conditions to be met in order to trigger a subsequent render to reposition the elements.
|
75
|
-
*/
|
76
|
-
positioningDependencies?: React.DependencyList;
|
77
|
-
onStateUpdate?: (state: Partial<PopperJs.State>) => void;
|
78
|
-
}
|
package/lib-amd/types.js
DELETED
package/lib-amd/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nexport type OffsetFunctionParam = {\n popper: PopperJs.Rect;\n reference: PopperJs.Rect;\n placement: PopperJs.Placement;\n};\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined];\n\nexport type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';\n\nexport type PopperRefHandle = { updatePosition: () => void };\n\nexport interface PositioningProps {\n /**\n * Alignment for the component.\n */\n align?: Alignment;\n\n /** The element which will define the boundaries of the popper position for the flip behavior. */\n flipBoundary?: Boundary;\n\n /** The element which will define the boundaries of the popper position for the overflow behavior. */\n overflowBoundary?: Boundary;\n\n /** An imperative handle to Popper methods. */\n containerRef?: React.Ref<PopperRefHandle>;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')\n * @default false\n */\n positionFixed?: boolean;\n\n /**\n * Lets you displace a popper element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_pinned?: boolean;\n\n /**\n * Applies max-height and max-width on popper to fit it within the available space in viewport.\n * true enables this for both width and height.\n * 'height' applies only `max-height` and 'width' for `max-width`\n */\n autoSize?: 'height' | 'width' | boolean;\n}\n\nexport interface PopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Array of conditions to be met in order to trigger a subsequent render to reposition the elements.\n */\n positioningDependencies?: React.DependencyList;\n\n onStateUpdate?: (state: Partial<PopperJs.State>) => void;\n}\n"]}
|
package/lib-amd/usePopper.d.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { PopperOptions } from './types';
|
3
|
-
/**
|
4
|
-
* Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
|
5
|
-
* package:
|
6
|
-
* - style attributes are applied directly on DOM to avoid re-renders
|
7
|
-
* - refs changes and resolution is handled properly without re-renders
|
8
|
-
* - contains a specific to React fix related to initial positioning when containers have components with managed focus
|
9
|
-
* to avoid focus jumps
|
10
|
-
*/
|
11
|
-
export declare function usePopper(options?: PopperOptions): {
|
12
|
-
targetRef: React.MutableRefObject<any>;
|
13
|
-
containerRef: React.MutableRefObject<any>;
|
14
|
-
arrowRef: React.MutableRefObject<any>;
|
15
|
-
};
|