@fluentui/react-positioning 0.0.0-nightly-20220302-0405.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.json +1614 -0
  2. package/CHANGELOG.md +719 -0
  3. package/LICENSE +15 -0
  4. package/README.md +25 -0
  5. package/dist/react-positioning.d.ts +221 -0
  6. package/lib/createArrowStyles.d.ts +64 -0
  7. package/lib/createArrowStyles.js +87 -0
  8. package/lib/createArrowStyles.js.map +1 -0
  9. package/lib/createVirtualElementFromClick.d.ts +6 -0
  10. package/lib/createVirtualElementFromClick.js +26 -0
  11. package/lib/createVirtualElementFromClick.js.map +1 -0
  12. package/lib/index.d.ts +6 -0
  13. package/lib/index.js +7 -0
  14. package/lib/index.js.map +1 -0
  15. package/lib/isIntersectingModifier.d.ts +4 -0
  16. package/lib/isIntersectingModifier.js +26 -0
  17. package/lib/isIntersectingModifier.js.map +1 -0
  18. package/lib/tsdoc-metadata.json +11 -0
  19. package/lib/types.d.ts +89 -0
  20. package/lib/types.js +2 -0
  21. package/lib/types.js.map +1 -0
  22. package/lib/usePopper.d.ts +23 -0
  23. package/lib/usePopper.js +407 -0
  24. package/lib/usePopper.js.map +1 -0
  25. package/lib/usePopperMouseTarget.d.ts +11 -0
  26. package/lib/usePopperMouseTarget.js +40 -0
  27. package/lib/usePopperMouseTarget.js.map +1 -0
  28. package/lib/utils/getBasePlacement.d.ts +8 -0
  29. package/lib/utils/getBasePlacement.js +10 -0
  30. package/lib/utils/getBasePlacement.js.map +1 -0
  31. package/lib/utils/getBoundary.d.ts +6 -0
  32. package/lib/utils/getBoundary.js +23 -0
  33. package/lib/utils/getBoundary.js.map +1 -0
  34. package/lib/utils/getReactFiberFromNode.d.ts +108 -0
  35. package/lib/utils/getReactFiberFromNode.js +46 -0
  36. package/lib/utils/getReactFiberFromNode.js.map +1 -0
  37. package/lib/utils/getScrollParent.d.ts +12 -0
  38. package/lib/utils/getScrollParent.js +65 -0
  39. package/lib/utils/getScrollParent.js.map +1 -0
  40. package/lib/utils/index.d.ts +8 -0
  41. package/lib/utils/index.js +9 -0
  42. package/lib/utils/index.js.map +1 -0
  43. package/lib/utils/mergeArrowOffset.d.ts +10 -0
  44. package/lib/utils/mergeArrowOffset.js +42 -0
  45. package/lib/utils/mergeArrowOffset.js.map +1 -0
  46. package/lib/utils/positioningHelper.d.ts +7 -0
  47. package/lib/utils/positioningHelper.js +49 -0
  48. package/lib/utils/positioningHelper.js.map +1 -0
  49. package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
  50. package/lib/utils/resolvePositioningShorthand.js +63 -0
  51. package/lib/utils/resolvePositioningShorthand.js.map +1 -0
  52. package/lib/utils/useCallbackRef.d.ts +19 -0
  53. package/lib/utils/useCallbackRef.js +57 -0
  54. package/lib/utils/useCallbackRef.js.map +1 -0
  55. package/lib-commonjs/createArrowStyles.d.ts +64 -0
  56. package/lib-commonjs/createArrowStyles.js +100 -0
  57. package/lib-commonjs/createArrowStyles.js.map +1 -0
  58. package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
  59. package/lib-commonjs/createVirtualElementFromClick.js +35 -0
  60. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
  61. package/lib-commonjs/index.d.ts +6 -0
  62. package/lib-commonjs/index.js +34 -0
  63. package/lib-commonjs/index.js.map +1 -0
  64. package/lib-commonjs/isIntersectingModifier.d.ts +4 -0
  65. package/lib-commonjs/isIntersectingModifier.js +34 -0
  66. package/lib-commonjs/isIntersectingModifier.js.map +1 -0
  67. package/lib-commonjs/types.d.ts +89 -0
  68. package/lib-commonjs/types.js +6 -0
  69. package/lib-commonjs/types.js.map +1 -0
  70. package/lib-commonjs/usePopper.d.ts +23 -0
  71. package/lib-commonjs/usePopper.js +422 -0
  72. package/lib-commonjs/usePopper.js.map +1 -0
  73. package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
  74. package/lib-commonjs/usePopperMouseTarget.js +51 -0
  75. package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
  76. package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
  77. package/lib-commonjs/utils/getBasePlacement.js +19 -0
  78. package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
  79. package/lib-commonjs/utils/getBoundary.d.ts +6 -0
  80. package/lib-commonjs/utils/getBoundary.js +33 -0
  81. package/lib-commonjs/utils/getBoundary.js.map +1 -0
  82. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +108 -0
  83. package/lib-commonjs/utils/getReactFiberFromNode.js +54 -0
  84. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -0
  85. package/lib-commonjs/utils/getScrollParent.d.ts +12 -0
  86. package/lib-commonjs/utils/getScrollParent.js +76 -0
  87. package/lib-commonjs/utils/getScrollParent.js.map +1 -0
  88. package/lib-commonjs/utils/index.d.ts +8 -0
  89. package/lib-commonjs/utils/index.js +24 -0
  90. package/lib-commonjs/utils/index.js.map +1 -0
  91. package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
  92. package/lib-commonjs/utils/mergeArrowOffset.js +51 -0
  93. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
  94. package/lib-commonjs/utils/positioningHelper.d.ts +7 -0
  95. package/lib-commonjs/utils/positioningHelper.js +61 -0
  96. package/lib-commonjs/utils/positioningHelper.js.map +1 -0
  97. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
  98. package/lib-commonjs/utils/resolvePositioningShorthand.js +72 -0
  99. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
  100. package/lib-commonjs/utils/useCallbackRef.d.ts +19 -0
  101. package/lib-commonjs/utils/useCallbackRef.js +68 -0
  102. package/lib-commonjs/utils/useCallbackRef.js.map +1 -0
  103. package/package.json +55 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createArrowHeightStyles = exports.createArrowStyles = void 0;
7
+
8
+ const react_1 = /*#__PURE__*/require("@griffel/react");
9
+
10
+ const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
11
+ /**
12
+ * Helper that creates a makeStyles rule for an arrow element.
13
+ * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
14
+ *
15
+ * ```ts
16
+ * makeStyles({
17
+ * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
18
+ *
19
+ * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
20
+ * mediumArrow: createArrowHeightStyles(4),
21
+ * smallArrow: createArrowHeightStyles(2),
22
+ * })
23
+ * ...
24
+ *
25
+ * state.arrowWithSize.className = styles.arrowWithSize;
26
+ * state.arrowWithoutSize.className = mergeClasses(
27
+ * styles.arrowWithoutSize,
28
+ * state.smallArrow && styles.smallArrow,
29
+ * state.mediumArrow && styles.mediumArrow,
30
+ * )
31
+ * ```
32
+ */
33
+
34
+
35
+ function createArrowStyles(options) {
36
+ const {
37
+ arrowHeight,
38
+ borderWidth = '1px',
39
+ borderStyle = 'solid',
40
+ borderColor = react_theme_1.tokens.colorTransparentStroke
41
+ } = options;
42
+ return {
43
+ position: 'absolute',
44
+ backgroundColor: 'inherit',
45
+ visibility: 'hidden',
46
+ zIndex: -1,
47
+ ...(arrowHeight && createArrowHeightStyles(arrowHeight)),
48
+ ':before': {
49
+ content: '""',
50
+ visibility: 'visible',
51
+ position: 'absolute',
52
+ boxSizing: 'border-box',
53
+ width: 'inherit',
54
+ height: 'inherit',
55
+ backgroundColor: 'inherit',
56
+ ...react_1.shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),
57
+ ...react_1.shorthands.borderBottom(borderWidth, borderStyle, borderColor),
58
+ borderBottomRightRadius: react_theme_1.tokens.borderRadiusSmall,
59
+ transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
60
+ },
61
+ // Popper sets data-popper-placement on the root element, which is used to align the arrow
62
+ ':global([data-popper-placement^="top"])': {
63
+ bottom: `-${borderWidth}`,
64
+ '--angle': '0'
65
+ },
66
+ ':global([data-popper-placement^="right"])': {
67
+ left: `-${borderWidth} /* @noflip */`,
68
+ '--angle': '90deg'
69
+ },
70
+ ':global([data-popper-placement^="bottom"])': {
71
+ top: `-${borderWidth}`,
72
+ '--angle': '180deg'
73
+ },
74
+ ':global([data-popper-placement^="left"])': {
75
+ right: `-${borderWidth} /* @noflip */`,
76
+ '--angle': '270deg'
77
+ }
78
+ };
79
+ }
80
+
81
+ exports.createArrowStyles = createArrowStyles;
82
+ /**
83
+ * Creates CSS styles to size the arrow created by createArrowStyles to the given height.
84
+ *
85
+ * Use this when you need to create classes for several different arrow sizes. If you only need a
86
+ * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
87
+ */
88
+
89
+ function createArrowHeightStyles(arrowHeight) {
90
+ // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
91
+ // Multiply the triangle's height by sqrt(2) to get length of its edges.
92
+ const edgeLength = `${1.414 * arrowHeight}px`;
93
+ return {
94
+ width: edgeLength,
95
+ height: edgeLength
96
+ };
97
+ }
98
+
99
+ exports.createArrowHeightStyles = createArrowHeightStyles;
100
+ //# sourceMappingURL=createArrowStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAqCA;;;;;;;;;;;;;;;;;;;;;AAqBG;;;AACH,SAAgB,iBAAhB,CAAkC,OAAlC,EAAmE;AACjE,QAAM;AACJ,IAAA,WADI;AAEJ,IAAA,WAAW,GAAG,KAFV;AAGJ,IAAA,WAAW,GAAG,OAHV;AAIJ,IAAA,WAAW,GAAG,aAAA,CAAA,MAAA,CAAO;AAJjB,MAKF,OALJ;AAOA,SAAO;AACL,IAAA,QAAQ,EAAE,UADL;AAEL,IAAA,eAAe,EAAE,SAFZ;AAGL,IAAA,UAAU,EAAE,QAHP;AAIL,IAAA,MAAM,EAAE,CAAC,CAJJ;AAML,QAAI,WAAW,IAAI,uBAAuB,CAAC,WAAD,CAA1C,CANK;AAQL,eAAW;AACT,MAAA,OAAO,EAAE,IADA;AAET,MAAA,UAAU,EAAE,SAFH;AAGT,MAAA,QAAQ,EAAE,UAHD;AAIT,MAAA,SAAS,EAAE,YAJF;AAKT,MAAA,KAAK,EAAE,SALE;AAMT,MAAA,MAAM,EAAE,SANC;AAOT,MAAA,eAAe,EAAE,SAPR;AAQT,SAAG,OAAA,CAAA,UAAA,CAAW,WAAX,CACD,GAAG,WAAW,gBADb,EAED,GAAG,WAAW,gBAFb,EAGD,GAAG,WAAW,gBAHb,CARM;AAaT,SAAG,OAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CAbM;AAcT,MAAA,uBAAuB,EAAE,aAAA,CAAA,MAAA,CAAO,iBAdvB;AAeT,MAAA,SAAS,EAAE;AAfF,KARN;AA0BL;AACA,+CAA2C;AACzC,MAAA,MAAM,EAAE,IAAI,WAAW,EADkB;AAEzC,iBAAW;AAF8B,KA3BtC;AA+BL,iDAA6C;AAC3C,MAAA,IAAI,EAAE,IAAI,WAAW,gBADsB;AAE3C,iBAAW;AAFgC,KA/BxC;AAmCL,kDAA8C;AAC5C,MAAA,GAAG,EAAE,IAAI,WAAW,EADwB;AAE5C,iBAAW;AAFiC,KAnCzC;AAuCL,gDAA4C;AAC1C,MAAA,KAAK,EAAE,IAAI,WAAW,gBADoB;AAE1C,iBAAW;AAF+B;AAvCvC,GAAP;AA4CD;;AApDD,OAAA,CAAA,iBAAA,GAAA,iBAAA;AAsDA;;;;;AAKG;;AACH,SAAgB,uBAAhB,CAAwC,WAAxC,EAA2D;AACzD;AACA;AACA,QAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,IAAzC;AACA,SAAO;AAAE,IAAA,KAAK,EAAE,UAAT;AAAqB,IAAA,MAAM,EAAE;AAA7B,GAAP;AACD;;AALD,OAAA,CAAA,uBAAA,GAAA,uBAAA","sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n ':before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import type { PopperVirtualElement } from './types';
2
+ /**
3
+ * Creates a virtual element based on the position of a click event
4
+ * Can be used as a target for popper in scenarios such as context menus
5
+ */
6
+ export declare function createVirtualElementFromClick(nativeEvent: MouseEvent): PopperVirtualElement;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createVirtualElementFromClick = void 0;
7
+ /**
8
+ * Creates a virtual element based on the position of a click event
9
+ * Can be used as a target for popper in scenarios such as context menus
10
+ */
11
+
12
+ function createVirtualElementFromClick(nativeEvent) {
13
+ const left = nativeEvent.clientX;
14
+ const top = nativeEvent.clientY;
15
+ const right = left + 1;
16
+ const bottom = top + 1;
17
+
18
+ function getBoundingClientRect() {
19
+ return {
20
+ left,
21
+ top,
22
+ right,
23
+ bottom,
24
+ height: 1,
25
+ width: 1
26
+ };
27
+ }
28
+
29
+ return {
30
+ getBoundingClientRect
31
+ };
32
+ }
33
+
34
+ exports.createVirtualElementFromClick = createVirtualElementFromClick;
35
+ //# sourceMappingURL=createVirtualElementFromClick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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","sourcesContent":["import type { PopperVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PopperVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect(): ClientRect {\n return {\n left,\n top,\n right,\n bottom,\n\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ export * from './createVirtualElementFromClick';
2
+ export * from './createArrowStyles';
3
+ export * from './usePopper';
4
+ export * from './usePopperMouseTarget';
5
+ export { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';
6
+ export * from './types';
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeArrowOffset = exports.resolvePositioningShorthand = void 0;
7
+
8
+ const tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ tslib_1.__exportStar(require("./createVirtualElementFromClick"), exports);
11
+
12
+ tslib_1.__exportStar(require("./createArrowStyles"), exports);
13
+
14
+ tslib_1.__exportStar(require("./usePopper"), exports);
15
+
16
+ tslib_1.__exportStar(require("./usePopperMouseTarget"), exports);
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
+
33
+ tslib_1.__exportStar(require("./types"), exports);
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["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","sourcesContent":["export * from './createVirtualElementFromClick';\nexport * from './createArrowStyles';\nexport * from './usePopper';\nexport * from './usePopperMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport * from './types';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,4 @@
1
+ import { Modifier } from '@popperjs/core';
2
+ export declare const isIntersectingModifier: IsIntersectingModifier;
3
+ declare type IsIntersectingModifier = Modifier<'is-intersecting-modifier', never>;
4
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isIntersectingModifier = void 0;
7
+
8
+ const core_1 = /*#__PURE__*/require("@popperjs/core");
9
+
10
+ exports.isIntersectingModifier = {
11
+ name: 'is-intersecting-modifier',
12
+ enabled: true,
13
+ phase: 'main',
14
+ requires: ['preventOverflow'],
15
+ fn: ({
16
+ state,
17
+ name
18
+ }) => {
19
+ const popperRect = state.rects.popper;
20
+ const popperAltOverflow = core_1.detectOverflow(state, {
21
+ altBoundary: true
22
+ });
23
+ const isIntersectingTop = popperAltOverflow.top < popperRect.height && popperAltOverflow.top > 0;
24
+ const isIntersectingBottom = popperAltOverflow.bottom < popperRect.height && popperAltOverflow.bottom > 0;
25
+ const isIntersecting = isIntersectingTop || isIntersectingBottom;
26
+ state.modifiersData[name] = {
27
+ isIntersecting
28
+ };
29
+ state.attributes.popper = { ...state.attributes.popper,
30
+ 'data-popper-is-intersecting': isIntersecting
31
+ };
32
+ }
33
+ };
34
+ //# sourceMappingURL=isIntersectingModifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["isIntersectingModifier.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,MAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEa,OAAA,CAAA,sBAAA,GAAiD;AAC5D,EAAA,IAAI,EAAE,0BADsD;AAE5D,EAAA,OAAO,EAAE,IAFmD;AAG5D,EAAA,KAAK,EAAE,MAHqD;AAI5D,EAAA,QAAQ,EAAE,CAAC,iBAAD,CAJkD;AAK5D,EAAA,EAAE,EAAE,CAAC;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,GAAD,KAAoB;AACtB,UAAM,UAAU,GAAG,KAAK,CAAC,KAAN,CAAY,MAA/B;AACA,UAAM,iBAAiB,GAAG,MAAA,CAAA,cAAA,CAAe,KAAf,EAAsB;AAAE,MAAA,WAAW,EAAE;AAAf,KAAtB,CAA1B;AAEA,UAAM,iBAAiB,GAAG,iBAAiB,CAAC,GAAlB,GAAwB,UAAU,CAAC,MAAnC,IAA6C,iBAAiB,CAAC,GAAlB,GAAwB,CAA/F;AACA,UAAM,oBAAoB,GAAG,iBAAiB,CAAC,MAAlB,GAA2B,UAAU,CAAC,MAAtC,IAAgD,iBAAiB,CAAC,MAAlB,GAA2B,CAAxG;AAEA,UAAM,cAAc,GAAG,iBAAiB,IAAI,oBAA5C;AAEA,IAAA,KAAK,CAAC,aAAN,CAAoB,IAApB,IAA4B;AAC1B,MAAA;AAD0B,KAA5B;AAGA,IAAA,KAAK,CAAC,UAAN,CAAiB,MAAjB,GAA0B,EACxB,GAAG,KAAK,CAAC,UAAN,CAAiB,MADI;AAExB,qCAA+B;AAFP,KAA1B;AAID;AArB2D,CAAjD","sourcesContent":["import { detectOverflow, Modifier } from '@popperjs/core';\n\nexport const isIntersectingModifier: IsIntersectingModifier = {\n name: 'is-intersecting-modifier',\n enabled: true,\n phase: 'main',\n requires: ['preventOverflow'],\n fn: ({ state, name }) => {\n const popperRect = state.rects.popper;\n const popperAltOverflow = detectOverflow(state, { altBoundary: true });\n\n const isIntersectingTop = popperAltOverflow.top < popperRect.height && popperAltOverflow.top > 0;\n const isIntersectingBottom = popperAltOverflow.bottom < popperRect.height && popperAltOverflow.bottom > 0;\n\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n\n state.modifiersData[name] = {\n isIntersecting,\n };\n state.attributes.popper = {\n ...state.attributes.popper,\n 'data-popper-is-intersecting': isIntersecting,\n };\n },\n};\n\ntype IsIntersectingModifier = Modifier<'is-intersecting-modifier', never>;\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,89 @@
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 AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;
13
+ export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
14
+ export declare type PopperRefHandle = {
15
+ /**
16
+ * Updates the position of the popper imperatively.
17
+ * Useful when the position of the target changes from other factors than scrolling of window resize.
18
+ */
19
+ updatePosition: () => void;
20
+ /**
21
+ * Sets the target and updates positioning imperatively.
22
+ * Useful for avoiding double renders with the target option.
23
+ */
24
+ setTarget: (target: HTMLElement | PopperVirtualElement) => void;
25
+ };
26
+ export declare type PopperVirtualElement = PopperJs.VirtualElement;
27
+ export interface PopperOptions {
28
+ /** Alignment for the component. Only has an effect if used with the @see position option */
29
+ align?: Alignment;
30
+ /** The element which will define the boundaries of the popper position for the flip behavior. */
31
+ flipBoundary?: Boundary;
32
+ /** The element which will define the boundaries of the popper position for the overflow behavior. */
33
+ overflowBoundary?: Boundary;
34
+ /**
35
+ * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
36
+ * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
37
+ * and 'start' | 'end' respectively),
38
+ * then provided value for 'align' will be ignored and 'center' will be used instead.
39
+ */
40
+ position?: Position;
41
+ /**
42
+ * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
43
+ * @default false
44
+ */
45
+ positionFixed?: boolean;
46
+ /**
47
+ * Lets you displace a popper element from its reference element.
48
+ * This can be useful if you need to apply some margin between them or if you need to fine tune the
49
+ * position according to some custom logic.
50
+ */
51
+ offset?: Offset;
52
+ /**
53
+ * Defines padding between the corner of the popup element and the arrow.
54
+ * Use to prevent the arrow from overlapping a rounded corner, for example.
55
+ */
56
+ arrowPadding?: number;
57
+ /**
58
+ * Applies max-height and max-width on popper to fit it within the available space in viewport.
59
+ * true enables this for both width and height when overflow happens.
60
+ * 'always' applies `max-height`/`max-width` regardless of overflow.
61
+ * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`
62
+ * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
63
+ */
64
+ autoSize?: AutoSize;
65
+ /**
66
+ * Modifies position and alignment to cover the target
67
+ */
68
+ coverTarget?: boolean;
69
+ /**
70
+ * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and
71
+ * `position` props, regardless of the size of the component, the reference element or the viewport.
72
+ */
73
+ pinned?: boolean;
74
+ /**
75
+ * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
76
+ * "all" enables this behavior for all axis.
77
+ */
78
+ unstable_disableTether?: boolean | 'all';
79
+ }
80
+ export interface PositioningProps extends Omit<PopperOptions, 'positionFixed' | 'unstable_disableTether'> {
81
+ /** An imperative handle to Popper methods. */
82
+ popperRef?: React.Ref<PopperRefHandle>;
83
+ /**
84
+ * Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
85
+ */
86
+ target?: HTMLElement | PopperVirtualElement | null;
87
+ }
88
+ export declare type PositioningShorthandValue = 'above' | 'above-start' | 'above-end' | 'below' | 'below-start' | 'below-end' | 'before' | 'before-top' | 'before-bottom' | 'after' | 'after-top' | 'after-bottom';
89
+ export declare type PositioningShorthand = PositioningProps | PositioningShorthandValue;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import type { PositioningProps } from './types';
3
+ interface UsePopperOptions extends PositioningProps {
4
+ /**
5
+ * If false, delays Popper's creation.
6
+ * @default true
7
+ */
8
+ enabled?: boolean;
9
+ }
10
+ /**
11
+ * Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
12
+ * package:
13
+ * - style attributes are applied directly on DOM to avoid re-renders
14
+ * - refs changes and resolution is handled properly without re-renders
15
+ * - contains a specific to React fix related to initial positioning when containers have components with managed focus
16
+ * to avoid focus jumps
17
+ */
18
+ export declare function usePopper(options?: UsePopperOptions): {
19
+ targetRef: React.MutableRefObject<any>;
20
+ containerRef: React.MutableRefObject<any>;
21
+ arrowRef: React.MutableRefObject<any>;
22
+ };
23
+ export {};