@fluentui/react-positioning 0.0.0-nightly0e0cf06c3420211029.1 → 0.0.0-nightly554221a5aa20211202.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) 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 +363 -320
  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.d.ts +0 -1
  21. package/lib/utils/getReactFiberFromNode.js +39 -35
  22. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  23. package/lib/utils/getScrollParent.js +46 -32
  24. package/lib/utils/getScrollParent.js.map +1 -1
  25. package/lib/utils/mergeArrowOffset.js +30 -25
  26. package/lib/utils/mergeArrowOffset.js.map +1 -1
  27. package/lib/utils/positioningHelper.d.ts +1 -1
  28. package/lib/utils/positioningHelper.js +42 -34
  29. package/lib/utils/positioningHelper.js.map +1 -1
  30. package/lib/utils/resolvePositioningShorthand.js +58 -20
  31. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  32. package/lib/utils/useCallbackRef.js +35 -29
  33. package/lib/utils/useCallbackRef.js.map +1 -1
  34. package/lib-commonjs/createArrowStyles.d.ts +27 -0
  35. package/lib-commonjs/createArrowStyles.js +83 -0
  36. package/lib-commonjs/createArrowStyles.js.map +1 -0
  37. package/lib-commonjs/createVirtualElementFromClick.js +23 -16
  38. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  39. package/lib-commonjs/index.d.ts +2 -1
  40. package/lib-commonjs/index.js +28 -6
  41. package/lib-commonjs/index.js.map +1 -1
  42. package/lib-commonjs/types.js +4 -1
  43. package/lib-commonjs/types.js.map +1 -1
  44. package/lib-commonjs/usePopper.js +377 -324
  45. package/lib-commonjs/usePopper.js.map +1 -1
  46. package/lib-commonjs/usePopperMouseTarget.js +38 -25
  47. package/lib-commonjs/usePopperMouseTarget.js.map +1 -1
  48. package/lib-commonjs/utils/getBasePlacement.js +7 -2
  49. package/lib-commonjs/utils/getBasePlacement.js.map +1 -1
  50. package/lib-commonjs/utils/getBoundary.js +23 -12
  51. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  52. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -1
  53. package/lib-commonjs/utils/getReactFiberFromNode.js +44 -36
  54. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  55. package/lib-commonjs/utils/getScrollParent.js +53 -33
  56. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  57. package/lib-commonjs/utils/index.js +14 -2
  58. package/lib-commonjs/utils/index.js.map +1 -1
  59. package/lib-commonjs/utils/mergeArrowOffset.js +36 -26
  60. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  61. package/lib-commonjs/utils/positioningHelper.d.ts +1 -1
  62. package/lib-commonjs/utils/positioningHelper.js +50 -35
  63. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  64. package/lib-commonjs/utils/resolvePositioningShorthand.js +66 -23
  65. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  66. package/lib-commonjs/utils/useCallbackRef.js +45 -32
  67. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  68. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.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C,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;;;AACH,OAAO,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;AAaP,OAAO,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,gBAAgB,CAAC,MAAM,CAAC,KAAD,CAAP,CAAxD;AACD,CAZM","sourceRoot":""}
@@ -1,25 +1,63 @@
1
1
  // Look up table for shorthand to avoid parsing strings
2
- var shorthandLookup = {
3
- above: { position: 'above', align: 'center' },
4
- 'above-start': { position: 'above', align: 'start' },
5
- 'above-end': { position: 'above', align: 'end' },
6
- below: { position: 'below', align: 'center' },
7
- 'below-start': { position: 'below', align: 'start' },
8
- 'below-end': { position: 'below', align: 'end' },
9
- before: { position: 'before', align: 'center' },
10
- 'before-top': { position: 'before', align: 'top' },
11
- 'before-bottom': { position: 'before', align: 'bottom' },
12
- after: { position: 'after', align: 'center' },
13
- 'after-top': { position: 'after', align: 'top' },
14
- 'after-bottom': { position: 'after', align: 'bottom' },
2
+ const shorthandLookup = {
3
+ above: {
4
+ position: 'above',
5
+ align: 'center'
6
+ },
7
+ 'above-start': {
8
+ position: 'above',
9
+ align: 'start'
10
+ },
11
+ 'above-end': {
12
+ position: 'above',
13
+ align: 'end'
14
+ },
15
+ below: {
16
+ position: 'below',
17
+ align: 'center'
18
+ },
19
+ 'below-start': {
20
+ position: 'below',
21
+ align: 'start'
22
+ },
23
+ 'below-end': {
24
+ position: 'below',
25
+ align: 'end'
26
+ },
27
+ before: {
28
+ position: 'before',
29
+ align: 'center'
30
+ },
31
+ 'before-top': {
32
+ position: 'before',
33
+ align: 'top'
34
+ },
35
+ 'before-bottom': {
36
+ position: 'before',
37
+ align: 'bottom'
38
+ },
39
+ after: {
40
+ position: 'after',
41
+ align: 'center'
42
+ },
43
+ 'after-top': {
44
+ position: 'after',
45
+ align: 'top'
46
+ },
47
+ 'after-bottom': {
48
+ position: 'after',
49
+ align: 'bottom'
50
+ }
15
51
  };
16
52
  export function resolvePositioningShorthand(shorthand) {
17
- if (shorthand === undefined || shorthand === null) {
18
- return {};
19
- }
20
- if (typeof shorthand === 'string') {
21
- return shorthandLookup[shorthand];
22
- }
23
- return shorthand;
53
+ if (shorthand === undefined || shorthand === null) {
54
+ return {};
55
+ }
56
+
57
+ if (typeof shorthand === 'string') {
58
+ return shorthandLookup[shorthand];
59
+ }
60
+
61
+ return shorthand;
24
62
  }
25
63
  //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolvePositioningShorthand.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,SADI,EAC8C;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","sourceRoot":""}
@@ -17,35 +17,41 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
17
17
  * ref.current = 1;
18
18
  * // prints 0 -> 1
19
19
  */
20
+
20
21
  export function useCallbackRef(initialValue, callback, skipInitialResolve) {
21
- var isFirst = React.useRef(true);
22
- var ref = React.useState(function () { return ({
23
- // value
24
- value: initialValue,
25
- // last callback
26
- callback: callback,
27
- // "memoized" public interface
28
- facade: {
29
- get current() {
30
- return ref.value;
31
- },
32
- set current(value) {
33
- var last = ref.value;
34
- if (last !== value) {
35
- ref.value = value;
36
- if (skipInitialResolve && isFirst.current) {
37
- return;
38
- }
39
- ref.callback(value, last);
40
- }
41
- },
42
- },
43
- }); })[0];
44
- useIsomorphicLayoutEffect(function () {
45
- isFirst.current = false;
46
- }, []);
47
- // update callback
48
- ref.callback = callback;
49
- return ref.facade;
22
+ const isFirst = React.useRef(true);
23
+ const [ref] = React.useState(() => ({
24
+ // value
25
+ value: initialValue,
26
+ // last callback
27
+ callback,
28
+ // "memoized" public interface
29
+ facade: {
30
+ get current() {
31
+ return ref.value;
32
+ },
33
+
34
+ set current(value) {
35
+ const last = ref.value;
36
+
37
+ if (last !== value) {
38
+ ref.value = value;
39
+
40
+ if (skipInitialResolve && isFirst.current) {
41
+ return;
42
+ }
43
+
44
+ ref.callback(value, last);
45
+ }
46
+ }
47
+
48
+ }
49
+ }));
50
+ useIsomorphicLayoutEffect(() => {
51
+ isFirst.current = false;
52
+ }, []); // update callback
53
+
54
+ ref.callback = callback;
55
+ return ref.facade;
50
56
  }
51
57
  //# sourceMappingURL=useCallbackRef.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAA,GAAG,GAAI,KAAK,CAAC,QAAQ,CAAC,cAAM,OAAA,CAAC;QAClC,QAAQ;QACR,KAAK,EAAE,YAAY;QACnB,gBAAgB;QAChB,QAAQ,UAAA;QACR,8BAA8B;QAC9B,MAAM,EAAE;YACN,IAAI,OAAO;gBACT,OAAO,GAAG,CAAC,KAAK,CAAC;YACnB,CAAC;YACD,IAAI,OAAO,CAAC,KAAK;gBACf,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;gBAEvB,IAAI,IAAI,KAAK,KAAK,EAAE;oBAClB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;oBAElB,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE;wBACzC,OAAO;qBACR;oBAED,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBAC3B;YACH,CAAC;SACF;KACF,CAAC,EAxBiC,CAwBjC,CAAC,GAxBO,CAwBN;IAEJ,yBAAyB,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,kBAAkB;IAClB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAExB,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,yBAAT,QAA0C,2BAA1C;AAEA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,cAAV,CACJ,YADI,EAEJ,QAFI,EAGJ,kBAHI,EAGwB;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,yBAAyB,CAAC,MAAK;AAC7B,IAAA,OAAO,CAAC,OAAR,GAAkB,KAAlB;AACD,GAFwB,EAEtB,EAFsB,CAAzB,CA7B4B,CAiC5B;;AACA,EAAA,GAAG,CAAC,QAAJ,GAAe,QAAf;AAEA,SAAO,GAAG,CAAC,MAAX;AACD","sourceRoot":""}
@@ -0,0 +1,27 @@
1
+ import type { MakeStylesStyleRule } from '@fluentui/react-make-styles';
2
+ import type { Theme } from '@fluentui/react-theme';
3
+ /**
4
+ * Helper that creates a makeStyles rule for an arrow element.
5
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
6
+ *
7
+ * ```ts
8
+ * makeStyles({
9
+ * arrowWithSize: createArrowStyles(5),
10
+ *
11
+ * arrowWithoutSize: createArrowStyles(),
12
+ * mediumArrow: { aspectRatio: 1, width: '4px' }
13
+ * smallArrow: { aspectRatio: 1, width: '2px' }
14
+ * })
15
+ * ...
16
+ *
17
+ * state.arrowWithSize.className = styles.arrowWithSize
18
+ * state.arrowWithoutSize.className = mergeClasses(
19
+ * styles.arrowWithoutSize,
20
+ * state.smallArrow && styles.smallArrow,
21
+ * state.mediumArrow && styles.mediumArrow,
22
+ * )
23
+ * ```
24
+ *
25
+ * @param size - dimensions of the square arrow element in pixels.
26
+ */
27
+ export declare function createArrowStyles(size?: number): MakeStylesStyleRule<Theme>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createArrowStyles = void 0;
7
+
8
+ const react_make_styles_1 = /*#__PURE__*/require("@fluentui/react-make-styles");
9
+ /**
10
+ * Helper that creates a makeStyles rule for an arrow element.
11
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
12
+ *
13
+ * ```ts
14
+ * makeStyles({
15
+ * arrowWithSize: createArrowStyles(5),
16
+ *
17
+ * arrowWithoutSize: createArrowStyles(),
18
+ * mediumArrow: { aspectRatio: 1, width: '4px' }
19
+ * smallArrow: { aspectRatio: 1, width: '2px' }
20
+ * })
21
+ * ...
22
+ *
23
+ * state.arrowWithSize.className = styles.arrowWithSize
24
+ * state.arrowWithoutSize.className = mergeClasses(
25
+ * styles.arrowWithoutSize,
26
+ * state.smallArrow && styles.smallArrow,
27
+ * state.mediumArrow && styles.mediumArrow,
28
+ * )
29
+ * ```
30
+ *
31
+ * @param size - dimensions of the square arrow element in pixels.
32
+ */
33
+
34
+
35
+ function createArrowStyles(size) {
36
+ return theme => ({
37
+ position: 'absolute',
38
+ backgroundColor: 'inherit',
39
+ visibility: 'hidden',
40
+ zIndex: -1,
41
+ ...(size && {
42
+ aspectRatio: '1',
43
+ width: `${size}px`
44
+ }),
45
+ ':before': {
46
+ content: '""',
47
+ ...react_make_styles_1.shorthands.borderRadius('4px'),
48
+ position: 'absolute',
49
+ width: 'inherit',
50
+ height: 'inherit',
51
+ backgroundColor: 'inherit',
52
+ visibility: 'visible',
53
+ borderBottomRightRadius: theme.borderRadiusSmall,
54
+ transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
55
+ },
56
+ ':global([data-popper-placement])': {
57
+ ':before': { // Special border for High Contrast mode
58
+ ...react_make_styles_1.shorthands.borderRight('1px', 'solid', 'transparent'),
59
+ ...react_make_styles_1.shorthands.borderBottom('1px', 'solid', 'transparent')
60
+ }
61
+ },
62
+ // Popper sets data-popper-placement on the root element, which is used to align the arrow
63
+ ':global([data-popper-placement^="top"])': {
64
+ bottom: 0,
65
+ '--angle': '0'
66
+ },
67
+ ':global([data-popper-placement^="right"])': {
68
+ left: 0,
69
+ '--angle': '90deg'
70
+ },
71
+ ':global([data-popper-placement^="bottom"])': {
72
+ top: 0,
73
+ '--angle': '180deg'
74
+ },
75
+ ':global([data-popper-placement^="left"])': {
76
+ right: 0,
77
+ '--angle': '270deg'
78
+ }
79
+ });
80
+ }
81
+
82
+ exports.createArrowStyles = createArrowStyles;
83
+ //# sourceMappingURL=createArrowStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;AAIA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;;;AACH,SAAgB,iBAAhB,CAAkC,IAAlC,EAA+C;AAC7C,SAAO,KAAK,KAAK;AACf,IAAA,QAAQ,EAAE,UADK;AAEf,IAAA,eAAe,EAAE,SAFF;AAGf,IAAA,UAAU,EAAE,QAHG;AAIf,IAAA,MAAM,EAAE,CAAC,CAJM;AAMf,QAAI,IAAI,IAAI;AACV,MAAA,WAAW,EAAE,GADH;AAEV,MAAA,KAAK,EAAE,GAAG,IAAI;AAFJ,KAAZ,CANe;AAWf,eAAW;AACT,MAAA,OAAO,EAAE,IADA;AAET,SAAG,mBAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,KAAxB,CAFM;AAGT,MAAA,QAAQ,EAAE,UAHD;AAIT,MAAA,KAAK,EAAE,SAJE;AAKT,MAAA,MAAM,EAAE,SALC;AAMT,MAAA,eAAe,EAAE,SANR;AAOT,MAAA,UAAU,EAAE,SAPH;AAQT,MAAA,uBAAuB,EAAE,KAAK,CAAC,iBARtB;AAST,MAAA,SAAS,EAAE;AATF,KAXI;AAuBf,wCAAoC;AAClC,iBAAW,EACT;AACA,WAAG,mBAAA,CAAA,UAAA,CAAW,WAAX,CAAuB,KAAvB,EAA8B,OAA9B,EAAuC,aAAvC,CAFM;AAGT,WAAG,mBAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,KAAxB,EAA+B,OAA/B,EAAwC,aAAxC;AAHM;AADuB,KAvBrB;AA+Bf;AACA,+CAA2C;AACzC,MAAA,MAAM,EAAE,CADiC;AAEzC,iBAAW;AAF8B,KAhC5B;AAqCf,iDAA6C;AAC3C,MAAA,IAAI,EAAE,CADqC;AAE3C,iBAAW;AAFgC,KArC9B;AAyCf,kDAA8C;AAC5C,MAAA,GAAG,EAAE,CADuC;AAE5C,iBAAW;AAFiC,KAzC/B;AA6Cf,gDAA4C;AAC1C,MAAA,KAAK,EAAE,CADmC;AAE1C,iBAAW;AAF+B;AA7C7B,GAAL,CAAZ;AAkDD;;AAnDD,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourceRoot":""}
@@ -1,28 +1,35 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.createVirtualElementFromClick = void 0;
4
7
  /**
5
8
  * Creates a virtual element based on the position of a click event
6
9
  * Can be used as a target for popper in scenarios such as context menus
7
10
  */
11
+
8
12
  function createVirtualElementFromClick(nativeEvent) {
9
- var left = nativeEvent.clientX;
10
- var top = nativeEvent.clientY;
11
- var right = left + 1;
12
- var bottom = top + 1;
13
- function getBoundingClientRect() {
14
- return {
15
- left: left,
16
- top: top,
17
- right: right,
18
- bottom: bottom,
19
- height: 1,
20
- width: 1,
21
- };
22
- }
13
+ const left = nativeEvent.clientX;
14
+ const top = nativeEvent.clientY;
15
+ const right = left + 1;
16
+ const bottom = top + 1;
17
+
18
+ function getBoundingClientRect() {
23
19
  return {
24
- getBoundingClientRect: getBoundingClientRect,
20
+ left,
21
+ top,
22
+ right,
23
+ bottom,
24
+ height: 1,
25
+ width: 1
25
26
  };
27
+ }
28
+
29
+ return {
30
+ getBoundingClientRect
31
+ };
26
32
  }
33
+
27
34
  exports.createVirtualElementFromClick = createVirtualElementFromClick;
28
35
  //# sourceMappingURL=createVirtualElementFromClick.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createVirtualElementFromClick.js","sourceRoot":"","sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,WAAuB;IACnE,IAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC;IACjC,IAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC;IAChC,IAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC;IACvB,IAAM,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;IAEvB,SAAS,qBAAqB;QAC5B,OAAO;YACL,IAAI,MAAA;YACJ,GAAG,KAAA;YACH,KAAK,OAAA;YACL,MAAM,QAAA;YAEN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,qBAAqB,uBAAA;KACtB,CAAC;AACJ,CAAC;AArBD,sEAqBC"}
1
+ {"version":3,"sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;;;;AAEA;;;AAGG;;AACH,SAAgB,6BAAhB,CAA8C,WAA9C,EAAqE;AACnE,QAAM,IAAI,GAAG,WAAW,CAAC,OAAzB;AACA,QAAM,GAAG,GAAG,WAAW,CAAC,OAAxB;AACA,QAAM,KAAK,GAAG,IAAI,GAAG,CAArB;AACA,QAAM,MAAM,GAAG,GAAG,GAAG,CAArB;;AAEA,WAAS,qBAAT,GAA8B;AAC5B,WAAO;AACL,MAAA,IADK;AAEL,MAAA,GAFK;AAGL,MAAA,KAHK;AAIL,MAAA,MAJK;AAML,MAAA,MAAM,EAAE,CANH;AAOL,MAAA,KAAK,EAAE;AAPF,KAAP;AASD;;AAED,SAAO;AACL,IAAA;AADK,GAAP;AAGD;;AArBD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourceRoot":""}
@@ -1,5 +1,6 @@
1
- export * from './usePopper';
2
1
  export * from './createVirtualElementFromClick';
2
+ export * from './createArrowStyles';
3
+ export * from './usePopper';
3
4
  export * from './usePopperMouseTarget';
4
5
  export { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';
5
6
  export * from './types';
@@ -1,12 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.mergeArrowOffset = exports.resolvePositioningShorthand = void 0;
4
- var tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./usePopper"), exports);
7
+
8
+ const tslib_1 = /*#__PURE__*/require("tslib");
9
+
6
10
  tslib_1.__exportStar(require("./createVirtualElementFromClick"), exports);
11
+
12
+ tslib_1.__exportStar(require("./createArrowStyles"), exports);
13
+
14
+ tslib_1.__exportStar(require("./usePopper"), exports);
15
+
7
16
  tslib_1.__exportStar(require("./usePopperMouseTarget"), exports);
8
- var index_1 = require("./utils/index");
9
- Object.defineProperty(exports, "resolvePositioningShorthand", { enumerable: true, get: function () { return index_1.resolvePositioningShorthand; } });
10
- Object.defineProperty(exports, "mergeArrowOffset", { enumerable: true, get: function () { return index_1.mergeArrowOffset; } });
17
+
18
+ var index_1 = /*#__PURE__*/require("./utils/index");
19
+
20
+ Object.defineProperty(exports, "resolvePositioningShorthand", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return index_1.resolvePositioningShorthand;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "mergeArrowOffset", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return index_1.mergeArrowOffset;
30
+ }
31
+ });
32
+
11
33
  tslib_1.__exportStar(require("./types"), exports);
12
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,sDAA4B;AAC5B,0EAAgD;AAChD,iEAAuC;AACvC,uCAA8E;AAArE,oHAAA,2BAA2B,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AACtD,kDAAwB"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,2BAAA;AAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,OAAA,CAAA,gBAAA;AAAgB;AAAhB,CAAA;;AACtC,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}