@fluentui/react-positioning 0.0.0-nightlyf3ce1fbe1d20211110.1 → 0.0.0-nightlyf8be6a7c6520220106.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/CHANGELOG.json +114 -8
  2. package/CHANGELOG.md +35 -7
  3. package/dist/react-positioning.d.ts +28 -0
  4. package/lib/createArrowStyles.d.ts +27 -0
  5. package/lib/createArrowStyles.js +73 -0
  6. package/lib/createArrowStyles.js.map +1 -0
  7. package/lib/createVirtualElementFromClick.js +17 -15
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.d.ts +2 -1
  10. package/lib/index.js +2 -1
  11. package/lib/index.js.map +1 -1
  12. package/lib/usePopper.js +362 -312
  13. package/lib/usePopper.js.map +1 -1
  14. package/lib/usePopperMouseTarget.js +28 -22
  15. package/lib/usePopperMouseTarget.js.map +1 -1
  16. package/lib/utils/getBasePlacement.js +1 -1
  17. package/lib/utils/getBasePlacement.js.map +1 -1
  18. package/lib/utils/getBoundary.js +15 -10
  19. package/lib/utils/getBoundary.js.map +1 -1
  20. package/lib/utils/getReactFiberFromNode.js +39 -35
  21. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  22. package/lib/utils/getScrollParent.js +46 -32
  23. package/lib/utils/getScrollParent.js.map +1 -1
  24. package/lib/utils/mergeArrowOffset.js +29 -24
  25. package/lib/utils/mergeArrowOffset.js.map +1 -1
  26. package/lib/utils/positioningHelper.d.ts +2 -2
  27. package/lib/utils/positioningHelper.js +38 -30
  28. package/lib/utils/positioningHelper.js.map +1 -1
  29. package/lib/utils/resolvePositioningShorthand.js +57 -19
  30. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  31. package/lib/utils/useCallbackRef.js +35 -29
  32. package/lib/utils/useCallbackRef.js.map +1 -1
  33. package/lib-commonjs/createArrowStyles.d.ts +27 -0
  34. package/lib-commonjs/createArrowStyles.js +83 -0
  35. package/lib-commonjs/createArrowStyles.js.map +1 -0
  36. package/lib-commonjs/createVirtualElementFromClick.js +23 -16
  37. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  38. package/lib-commonjs/index.d.ts +2 -1
  39. package/lib-commonjs/index.js +28 -6
  40. package/lib-commonjs/index.js.map +1 -1
  41. package/lib-commonjs/types.js +4 -1
  42. package/lib-commonjs/types.js.map +1 -1
  43. package/lib-commonjs/usePopper.js +376 -316
  44. package/lib-commonjs/usePopper.js.map +1 -1
  45. package/lib-commonjs/usePopperMouseTarget.js +38 -25
  46. package/lib-commonjs/usePopperMouseTarget.js.map +1 -1
  47. package/lib-commonjs/utils/getBasePlacement.js +7 -2
  48. package/lib-commonjs/utils/getBasePlacement.js.map +1 -1
  49. package/lib-commonjs/utils/getBoundary.js +23 -12
  50. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  51. package/lib-commonjs/utils/getReactFiberFromNode.js +44 -36
  52. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  53. package/lib-commonjs/utils/getScrollParent.js +53 -33
  54. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  55. package/lib-commonjs/utils/index.js +14 -2
  56. package/lib-commonjs/utils/index.js.map +1 -1
  57. package/lib-commonjs/utils/mergeArrowOffset.js +35 -25
  58. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  59. package/lib-commonjs/utils/positioningHelper.d.ts +2 -2
  60. package/lib-commonjs/utils/positioningHelper.js +46 -31
  61. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  62. package/lib-commonjs/utils/resolvePositioningShorthand.js +65 -22
  63. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  64. package/lib-commonjs/utils/useCallbackRef.js +45 -32
  65. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  66. package/package.json +8 -8
@@ -1,7 +1,7 @@
1
1
  import * as PopperJs from '@popperjs/core';
2
- import type { Offset } from '../types';
2
+ import type { Alignment, Offset, Position } from '../types';
3
3
  /**
4
4
  * @see positioninHelper.test.ts for expected placement values
5
5
  */
6
- export declare const getPlacement: (align?: "top" | "bottom" | "start" | "end" | "center" | undefined, position?: "above" | "below" | "before" | "after" | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
6
+ export declare const getPlacement: (align?: Alignment | undefined, position?: Position | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
7
7
  export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
@@ -1,46 +1,61 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.applyRtlToOffset = exports.getPlacement = void 0;
4
- const getPositionMap = (rtl) => ({
5
- above: 'top',
6
- below: 'bottom',
7
- before: rtl ? 'right' : 'left',
8
- after: rtl ? 'left' : 'right',
7
+
8
+ const getPositionMap = rtl => ({
9
+ above: 'top',
10
+ below: 'bottom',
11
+ before: rtl ? 'right' : 'left',
12
+ after: rtl ? 'left' : 'right'
9
13
  });
10
- const getAlignmentMap = (rtl) => ({
11
- start: rtl ? 'end' : 'start',
12
- end: rtl ? 'start' : 'end',
13
- top: 'start',
14
- bottom: 'end',
15
- center: '',
14
+
15
+ const getAlignmentMap = rtl => ({
16
+ start: rtl ? 'end' : 'start',
17
+ end: rtl ? 'start' : 'end',
18
+ top: 'start',
19
+ bottom: 'end',
20
+ center: ''
16
21
  });
22
+
17
23
  const shouldAlignToCenter = (p, a) => {
18
- const positionedVertically = p === 'above' || p === 'below';
19
- const alignedVertically = a === 'top' || a === 'bottom';
20
- return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);
24
+ const positionedVertically = p === 'above' || p === 'below';
25
+ const alignedVertically = a === 'top' || a === 'bottom';
26
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
21
27
  };
22
28
  /**
23
29
  * @see positioninHelper.test.ts for expected placement values
24
30
  */
31
+
32
+
25
33
  const getPlacement = (align, position, rtl) => {
26
- const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
27
- const computedPosition = position && getPositionMap(rtl)[position];
28
- const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];
29
- if (computedPosition && computedAlignmnent) {
30
- return `${computedPosition}-${computedAlignmnent}`;
31
- }
32
- return computedPosition || 'auto';
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';
33
43
  };
44
+
34
45
  exports.getPlacement = getPlacement;
35
- const applyRtlToOffset = (offset) => {
36
- if (typeof offset === 'undefined') {
37
- return undefined;
38
- }
39
- if (Array.isArray(offset)) {
40
- offset[0] = offset[0] * -1;
41
- return offset;
42
- }
43
- return ((param) => exports.applyRtlToOffset(offset(param)));
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));
44
58
  };
59
+
45
60
  exports.applyRtlToOffset = applyRtlToOffset;
46
61
  //# sourceMappingURL=positioningHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":";;;AAMA,MAAM,cAAc,GAAG,CAAC,GAAa,EAAuC,EAAE,CAAC,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;IAC9B,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;CAC9B,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,GAAa,E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G;;;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":""}
@@ -1,29 +1,72 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePositioningShorthand = void 0;
4
- // Look up table for shorthand to avoid parsing strings
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
+
5
8
  const shorthandLookup = {
6
- above: { position: 'above', align: 'center' },
7
- 'above-start': { position: 'above', align: 'start' },
8
- 'above-end': { position: 'above', align: 'end' },
9
- below: { position: 'below', align: 'center' },
10
- 'below-start': { position: 'below', align: 'start' },
11
- 'below-end': { position: 'below', align: 'end' },
12
- before: { position: 'before', align: 'center' },
13
- 'before-top': { position: 'before', align: 'top' },
14
- 'before-bottom': { position: 'before', align: 'bottom' },
15
- after: { position: 'after', align: 'center' },
16
- 'after-top': { position: 'after', align: 'top' },
17
- 'after-bottom': { position: 'after', align: 'bottom' },
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
+ }
18
57
  };
58
+
19
59
  function resolvePositioningShorthand(shorthand) {
20
- if (shorthand === undefined || shorthand === null) {
21
- return {};
22
- }
23
- if (typeof shorthand === 'string') {
24
- return shorthandLookup[shorthand];
25
- }
26
- return 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;
27
69
  }
70
+
28
71
  exports.resolvePositioningShorthand = resolvePositioningShorthand;
29
72
  //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -1 +1 @@
1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5B;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,8 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.useCallbackRef = void 0;
4
- const React = require("react");
5
- const react_utilities_1 = require("@fluentui/react-utilities");
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
6
11
  /**
7
12
  * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
8
13
  * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
@@ -20,36 +25,44 @@ const react_utilities_1 = require("@fluentui/react-utilities");
20
25
  * ref.current = 1;
21
26
  * // prints 0 -> 1
22
27
  */
28
+
29
+
23
30
  function useCallbackRef(initialValue, callback, skipInitialResolve) {
24
- const isFirst = React.useRef(true);
25
- const [ref] = React.useState(() => ({
26
- // value
27
- value: initialValue,
28
- // last callback
29
- callback,
30
- // "memoized" public interface
31
- facade: {
32
- get current() {
33
- return ref.value;
34
- },
35
- set current(value) {
36
- const last = ref.value;
37
- if (last !== value) {
38
- ref.value = value;
39
- if (skipInitialResolve && isFirst.current) {
40
- return;
41
- }
42
- ref.callback(value, last);
43
- }
44
- },
45
- },
46
- }));
47
- react_utilities_1.useIsomorphicLayoutEffect(() => {
48
- isFirst.current = false;
49
- }, []);
50
- // update callback
51
- ref.callback = callback;
52
- return ref.facade;
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;
53
65
  }
66
+
54
67
  exports.useCallbackRef = useCallbackRef;
55
68
  //# sourceMappingURL=useCallbackRef.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+DAAsE;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;QAClC,QAAQ;QACR,KAAK,EAAE,YAAY;QACnB,gBAAgB;QAChB,QAAQ;QACR,8BAA8B;QAC9B,MAAM,EAAE;YACN,IAAI,OAAO;gBACT,OAAO,GAAG,CAAC,KAAK,CAAC;YACnB,CAAC;YACD,IAAI,OAAO,CAAC,KAAK;gBACf,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;gBAEvB,IAAI,IAAI,KAAK,KAAK,EAAE;oBAClB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;oBAElB,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE;wBAC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0BA,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": "0.0.0-nightlyf3ce1fbe1d20211110.1",
3
+ "version": "0.0.0-nightlyf8be6a7c6520220106.1",
4
4
  "description": "A react wrapper around Popper.js for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -20,9 +20,8 @@
20
20
  "lint": "just-scripts lint",
21
21
  "test": "jest",
22
22
  "docs": "api-extractor run --config=config/api-extractor.local.json --local",
23
- "build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-positioning/src && yarn docs",
24
- "storybook": "start-storybook",
25
- "start": "yarn storybook"
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"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@fluentui/eslint-plugin": "*",
@@ -30,11 +29,13 @@
30
29
  "@types/react": "16.9.42",
31
30
  "@types/react-dom": "16.9.10",
32
31
  "react": "16.8.6",
33
- "react-dom": "16.8.6"
32
+ "react-dom": "16.8.6",
33
+ "@fluentui/babel-make-styles": "0.0.0-nightlyf8be6a7c6520220106.1"
34
34
  },
35
35
  "dependencies": {
36
- "@fluentui/react-shared-contexts": "0.0.0-nightlyf3ce1fbe1d20211110.1",
37
- "@fluentui/react-utilities": "0.0.0-nightlyf3ce1fbe1d20211110.1",
36
+ "@fluentui/react-make-styles": "0.0.0-nightlyf8be6a7c6520220106.1",
37
+ "@fluentui/react-shared-contexts": "0.0.0-nightlyf8be6a7c6520220106.1",
38
+ "@fluentui/react-utilities": "0.0.0-nightlyf8be6a7c6520220106.1",
38
39
  "@popperjs/core": "~2.4.3",
39
40
  "tslib": "^2.1.0"
40
41
  },
@@ -45,7 +46,6 @@
45
46
  "react-dom": ">=16.8.0 <18.0.0"
46
47
  },
47
48
  "beachball": {
48
- "tag": "beta",
49
49
  "disallowedChangeTypes": [
50
50
  "major",
51
51
  "minor",