@fluentui/react-positioning 9.0.0-alpha.6 → 9.0.0-alpha.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/CHANGELOG.json +1116 -1
  2. package/CHANGELOG.md +520 -2
  3. package/dist/react-positioning.d.ts +72 -27
  4. package/lib/createVirtualElementFromClick.d.ts +6 -0
  5. package/lib/createVirtualElementFromClick.js +24 -0
  6. package/lib/createVirtualElementFromClick.js.map +1 -0
  7. package/lib/index.d.ts +3 -0
  8. package/lib/index.js +4 -0
  9. package/lib/index.js.map +1 -1
  10. package/lib/tsdoc-metadata.json +1 -1
  11. package/lib/types.d.ts +22 -27
  12. package/lib/types.js +1 -0
  13. package/lib/types.js.map +1 -1
  14. package/lib/usePopper.d.ts +21 -1
  15. package/lib/usePopper.js +67 -29
  16. package/lib/usePopper.js.map +1 -1
  17. package/lib/usePopperMouseTarget.d.ts +11 -0
  18. package/lib/usePopperMouseTarget.js +34 -0
  19. package/lib/usePopperMouseTarget.js.map +1 -0
  20. package/lib/utils/getBasePlacement.d.ts +8 -0
  21. package/lib/utils/getBasePlacement.js +10 -0
  22. package/lib/utils/getBasePlacement.js.map +1 -0
  23. package/lib/utils/getBoundary.d.ts +1 -1
  24. package/lib/utils/getBoundary.js +2 -3
  25. package/lib/utils/getBoundary.js.map +1 -1
  26. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  27. package/lib/utils/getScrollParent.js.map +1 -1
  28. package/lib/utils/index.d.ts +5 -3
  29. package/lib/utils/index.js +5 -3
  30. package/lib/utils/index.js.map +1 -1
  31. package/lib/utils/mergeArrowOffset.d.ts +10 -0
  32. package/lib/utils/mergeArrowOffset.js +37 -0
  33. package/lib/utils/mergeArrowOffset.js.map +1 -0
  34. package/lib/utils/positioningHelper.d.ts +2 -2
  35. package/lib/utils/positioningHelper.js.map +1 -1
  36. package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
  37. package/lib/utils/resolvePositioningShorthand.js +25 -0
  38. package/lib/utils/resolvePositioningShorthand.js.map +1 -0
  39. package/lib/utils/useCallbackRef.js.map +1 -1
  40. package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
  41. package/lib-commonjs/createVirtualElementFromClick.js +28 -0
  42. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
  43. package/lib-commonjs/index.d.ts +3 -0
  44. package/lib-commonjs/index.js +7 -0
  45. package/lib-commonjs/index.js.map +1 -1
  46. package/lib-commonjs/types.d.ts +22 -27
  47. package/lib-commonjs/types.js.map +1 -1
  48. package/lib-commonjs/usePopper.d.ts +21 -1
  49. package/lib-commonjs/usePopper.js +67 -28
  50. package/lib-commonjs/usePopper.js.map +1 -1
  51. package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
  52. package/lib-commonjs/usePopperMouseTarget.js +38 -0
  53. package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
  54. package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
  55. package/lib-commonjs/utils/getBasePlacement.js +14 -0
  56. package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
  57. package/lib-commonjs/utils/getBoundary.d.ts +1 -1
  58. package/lib-commonjs/utils/getBoundary.js +3 -3
  59. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  60. package/lib-commonjs/utils/getReactFiberFromNode.js +1 -0
  61. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  62. package/lib-commonjs/utils/getScrollParent.js +5 -2
  63. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  64. package/lib-commonjs/utils/index.d.ts +5 -3
  65. package/lib-commonjs/utils/index.js +5 -3
  66. package/lib-commonjs/utils/index.js.map +1 -1
  67. package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
  68. package/lib-commonjs/utils/mergeArrowOffset.js +41 -0
  69. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
  70. package/lib-commonjs/utils/positioningHelper.d.ts +2 -2
  71. package/lib-commonjs/utils/positioningHelper.js +5 -2
  72. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  73. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
  74. package/lib-commonjs/utils/resolvePositioningShorthand.js +29 -0
  75. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
  76. package/lib-commonjs/utils/useCallbackRef.js +1 -0
  77. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  78. package/package.json +11 -8
  79. package/NOTICE.txt +0 -0
  80. package/config/api-extractor.json +0 -3
  81. package/etc/react-positioning.api.md +0 -69
  82. package/just.config.ts +0 -3
  83. package/lib/utils/isBrowser.d.ts +0 -1
  84. package/lib/utils/isBrowser.js +0 -4
  85. package/lib/utils/isBrowser.js.map +0 -1
  86. package/lib-amd/index.d.ts +0 -2
  87. package/lib-amd/index.js +0 -6
  88. package/lib-amd/index.js.map +0 -1
  89. package/lib-amd/types.d.ts +0 -73
  90. package/lib-amd/types.js +0 -5
  91. package/lib-amd/types.js.map +0 -1
  92. package/lib-amd/usePopper.d.ts +0 -15
  93. package/lib-amd/usePopper.js +0 -280
  94. package/lib-amd/usePopper.js.map +0 -1
  95. package/lib-amd/utils/getBoundary.d.ts +0 -6
  96. package/lib-amd/utils/getBoundary.js +0 -23
  97. package/lib-amd/utils/getBoundary.js.map +0 -1
  98. package/lib-amd/utils/getReactFiberFromNode.d.ts +0 -109
  99. package/lib-amd/utils/getReactFiberFromNode.js +0 -47
  100. package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
  101. package/lib-amd/utils/getScrollParent.d.ts +0 -12
  102. package/lib-amd/utils/getScrollParent.js +0 -55
  103. package/lib-amd/utils/getScrollParent.js.map +0 -1
  104. package/lib-amd/utils/index.d.ts +0 -6
  105. package/lib-amd/utils/index.js +0 -11
  106. package/lib-amd/utils/index.js.map +0 -1
  107. package/lib-amd/utils/isBrowser.d.ts +0 -1
  108. package/lib-amd/utils/isBrowser.js +0 -8
  109. package/lib-amd/utils/isBrowser.js.map +0 -1
  110. package/lib-amd/utils/positioningHelper.d.ts +0 -7
  111. package/lib-amd/utils/positioningHelper.js +0 -45
  112. package/lib-amd/utils/positioningHelper.js.map +0 -1
  113. package/lib-amd/utils/useCallbackRef.d.ts +0 -19
  114. package/lib-amd/utils/useCallbackRef.js +0 -54
  115. package/lib-amd/utils/useCallbackRef.js.map +0 -1
  116. package/lib-commonjs/utils/isBrowser.d.ts +0 -1
  117. package/lib-commonjs/utils/isBrowser.js +0 -6
  118. package/lib-commonjs/utils/isBrowser.js.map +0 -1
@@ -1,5 +1,24 @@
1
+ import * as PopperJs from '@popperjs/core';
1
2
  import * as React from 'react';
2
- import { PopperOptions } from './types';
3
+ import type { PositioningProps } from './types';
4
+ interface PopperOptions extends PositioningProps {
5
+ /**
6
+ * If false, delays Popper's creation.
7
+ * @default true
8
+ */
9
+ enabled?: boolean;
10
+ onStateUpdate?: (state: Partial<PopperJs.State>) => void;
11
+ /**
12
+ * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
13
+ * @default false
14
+ */
15
+ positionFixed?: boolean;
16
+ /**
17
+ * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
18
+ * "all" enables this behavior for all axis.
19
+ */
20
+ unstable_disableTether?: boolean | 'all';
21
+ }
3
22
  /**
4
23
  * Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
5
24
  * package:
@@ -13,3 +32,4 @@ export declare function usePopper(options?: PopperOptions): {
13
32
  containerRef: React.MutableRefObject<any>;
14
33
  arrowRef: React.MutableRefObject<any>;
15
34
  };
35
+ export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePopper = void 0;
3
4
  var react_utilities_1 = require("@fluentui/react-utilities");
4
- var react_provider_1 = require("@fluentui/react-provider");
5
+ var react_shared_contexts_1 = require("@fluentui/react-shared-contexts");
5
6
  var index_1 = require("./utils/index");
6
7
  var PopperJs = require("@popperjs/core");
7
8
  var React = require("react");
@@ -35,12 +36,10 @@ function hasAutofocusFilter(node) {
35
36
  * that can't be resolved properly during an initial rendering.
36
37
  */
37
38
  function usePopperOptions(options, popperOriginalPositionRef) {
38
- var autoSize = options.autoSize, flipBoundary = options.flipBoundary, offset = options.offset, onStateUpdate = options.onStateUpdate, overflowBoundary = options.overflowBoundary,
39
+ var arrowPadding = options.arrowPadding, autoSize = options.autoSize, coverTarget = options.coverTarget, flipBoundary = options.flipBoundary, offset = options.offset, onStateUpdate = options.onStateUpdate, overflowBoundary = options.overflowBoundary,
39
40
  // eslint-disable-next-line @typescript-eslint/naming-convention
40
- unstable_disableTether = options.unstable_disableTether,
41
- // eslint-disable-next-line @typescript-eslint/naming-convention
42
- unstable_pinned = options.unstable_pinned;
43
- var isRtl = react_provider_1.useFluent().dir === 'rtl';
41
+ unstable_disableTether = options.unstable_disableTether, pinned = options.pinned;
42
+ var isRtl = react_shared_contexts_1.useFluent().dir === 'rtl';
44
43
  var placement = index_1.getPlacement(options.align, options.position, isRtl);
45
44
  var strategy = options.positionFixed ? 'fixed' : 'absolute';
46
45
  var handleStateUpdate = react_utilities_1.useEventCallback(function (_a) {
@@ -87,12 +86,12 @@ function usePopperOptions(options, popperOriginalPositionRef) {
87
86
  },
88
87
  { name: 'flip', options: { flipVariations: true } },
89
88
  /**
90
- * unstable_pinned disables the flip modifier by setting flip.enabled to false; this
89
+ * pinned disables the flip modifier by setting flip.enabled to false; this
91
90
  * disables automatic repositioning of the popper box; it will always be placed according to
92
91
  * the values of `align` and `position` props, regardless of the size of the component, the
93
92
  * reference element or the viewport.
94
93
  */
95
- unstable_pinned && { name: 'flip', enabled: false },
94
+ pinned && { name: 'flip', enabled: false },
96
95
  /**
97
96
  * When the popper box is placed in the context of a scrollable element, we need to set
98
97
  * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'
@@ -131,12 +130,12 @@ function usePopperOptions(options, popperOriginalPositionRef) {
131
130
  phase: 'afterWrite',
132
131
  fn: handleStateUpdate,
133
132
  },
134
- autoSize && {
133
+ {
135
134
  // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js
136
135
  // popper-maxsize-modifier only calculates the max sizes.
137
- // This modifier applies the max sizes when overflow is detected
136
+ // This modifier can apply max sizes always, or apply the max sizes only when overflow is detected
138
137
  name: 'applyMaxSize',
139
- enabled: true,
138
+ enabled: !!autoSize,
140
139
  phase: 'beforeWrite',
141
140
  requiresIfExists: ['offset', 'preventOverflow', 'flip'],
142
141
  options: {
@@ -148,13 +147,19 @@ function usePopperOptions(options, popperOriginalPositionRef) {
148
147
  var overflow = PopperJs.detectOverflow(state, modifierOptions);
149
148
  var _b = state.modifiersData.preventOverflow || { x: 0, y: 0 }, x = _b.x, y = _b.y;
150
149
  var _c = state.rects.popper, width = _c.width, height = _c.height;
151
- var basePlacement = state.placement.split('-')[0];
150
+ var basePlacement = index_1.getBasePlacement(state.placement);
152
151
  var widthProp = basePlacement === 'left' ? 'left' : 'right';
153
152
  var heightProp = basePlacement === 'top' ? 'top' : 'bottom';
154
- if (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width')) {
153
+ var applyMaxWidth = autoSize === 'always' ||
154
+ autoSize === 'width-always' ||
155
+ (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));
156
+ var applyMaxHeight = autoSize === 'always' ||
157
+ autoSize === 'height-always' ||
158
+ (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));
159
+ if (applyMaxWidth) {
155
160
  state.styles.popper.maxWidth = width - overflow[widthProp] - x + "px";
156
161
  }
157
- if (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height')) {
162
+ if (applyMaxHeight) {
158
163
  state.styles.popper.maxHeight = height - overflow[heightProp] - y + "px";
159
164
  }
160
165
  },
@@ -166,7 +171,34 @@ function usePopperOptions(options, popperOriginalPositionRef) {
166
171
  {
167
172
  name: 'arrow',
168
173
  enabled: !!arrow,
169
- options: { element: arrow },
174
+ options: { element: arrow, padding: arrowPadding },
175
+ },
176
+ /**
177
+ * Modifies popper offsets to cover the reference rect, but still keep edge alignment
178
+ */
179
+ {
180
+ name: 'coverTarget',
181
+ enabled: !!coverTarget,
182
+ phase: 'main',
183
+ requiresIfExists: ['offset', 'preventOverflow', 'flip'],
184
+ fn: function (_a) {
185
+ var state = _a.state;
186
+ var basePlacement = index_1.getBasePlacement(state.placement);
187
+ switch (basePlacement) {
188
+ case 'bottom':
189
+ state.modifiersData.popperOffsets.y -= state.rects.reference.height;
190
+ break;
191
+ case 'top':
192
+ state.modifiersData.popperOffsets.y += state.rects.reference.height;
193
+ break;
194
+ case 'left':
195
+ state.modifiersData.popperOffsets.x += state.rects.reference.width;
196
+ break;
197
+ case 'right':
198
+ state.modifiersData.popperOffsets.x -= state.rects.reference.width;
199
+ break;
200
+ }
201
+ },
170
202
  },
171
203
  ].filter(Boolean); // filter boolean conditional spreading values
172
204
  var popperOptions = {
@@ -177,14 +209,16 @@ function usePopperOptions(options, popperOriginalPositionRef) {
177
209
  };
178
210
  return popperOptions;
179
211
  }, [
212
+ arrowPadding,
180
213
  autoSize,
214
+ coverTarget,
181
215
  flipBoundary,
182
216
  offsetModifier,
183
217
  overflowBoundary,
184
218
  placement,
185
219
  strategy,
186
220
  unstable_disableTether,
187
- unstable_pinned,
221
+ pinned,
188
222
  // These can be skipped from deps as they will not ever change
189
223
  handleStateUpdate,
190
224
  popperOriginalPositionRef,
@@ -209,10 +243,11 @@ function usePopper(options) {
209
243
  var _a;
210
244
  (_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
211
245
  popperInstanceRef.current = null;
246
+ var _b = options.target, target = _b === void 0 ? targetRef.current : _b;
212
247
  var popperInstance = null;
213
- if (index_1.isBrowser() && enabled) {
214
- if (targetRef.current && containerRef.current) {
215
- popperInstance = PopperJs.createPopper(targetRef.current, containerRef.current, resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current));
248
+ if (react_utilities_1.canUseDOM() && enabled) {
249
+ if (target && containerRef.current) {
250
+ popperInstance = PopperJs.createPopper(target, containerRef.current, resolvePopperOptions(target, containerRef.current, arrowRef.current));
216
251
  }
217
252
  }
218
253
  if (popperInstance) {
@@ -223,8 +258,7 @@ function usePopper(options) {
223
258
  var originalForceUpdate_1 = popperInstance.forceUpdate;
224
259
  popperInstance.isFirstRun = true;
225
260
  popperInstance.forceUpdate = function () {
226
- var _a;
227
- if ((_a = popperInstance) === null || _a === void 0 ? void 0 : _a.isFirstRun) {
261
+ if (popperInstance === null || popperInstance === void 0 ? void 0 : popperInstance.isFirstRun) {
228
262
  popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;
229
263
  popperInstance.isFirstRun = false;
230
264
  }
@@ -256,7 +290,7 @@ function usePopper(options) {
256
290
  var targetRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
257
291
  var containerRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
258
292
  var arrowRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
259
- React.useImperativeHandle(options.containerRef, function () { return ({
293
+ React.useImperativeHandle(options.popperRef, function () { return ({
260
294
  updatePosition: function () {
261
295
  var _a;
262
296
  (_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.update();
@@ -269,25 +303,30 @@ function usePopper(options) {
269
303
  (_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
270
304
  popperInstanceRef.current = null;
271
305
  };
272
- }, [options.enabled]);
306
+ }, [handlePopperUpdate, options.enabled, options.target]);
273
307
  react_utilities_1.useIsomorphicLayoutEffect(function () {
274
308
  var _a;
275
309
  if (!isFirstMount) {
276
- (_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setOptions(resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current));
310
+ (_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setOptions(resolvePopperOptions(options.target || targetRef.current, containerRef.current, arrowRef.current));
277
311
  }
278
- }, [resolvePopperOptions]);
312
+ },
313
+ // Missing deps:
314
+ // options.target - The useIsomorphicLayoutEffect before this will create a new popper instance if target changes
315
+ // isFirstMount - Should never change after mount
316
+ // arrowRef, containerRef, targetRef - Stable between renders
317
+ // eslint-disable-next-line react-hooks/exhaustive-deps
318
+ [resolvePopperOptions]);
279
319
  if (process.env.NODE_ENV !== 'production') {
280
320
  // This checked should run only in development mode
281
321
  // eslint-disable-next-line react-hooks/rules-of-hooks
282
322
  React.useEffect(function () {
283
- var _a, _b;
323
+ var _a;
284
324
  if (containerRef.current) {
285
325
  var contentNode = containerRef.current;
286
- // eslint-disable-next-line deprecation/deprecation
287
326
  var treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
288
327
  acceptNode: hasAutofocusFilter,
289
328
  });
290
- while ((_b = treeWalker) === null || _b === void 0 ? void 0 : _b.nextNode()) {
329
+ while (treeWalker === null || treeWalker === void 0 ? void 0 : treeWalker.nextNode()) {
291
330
  var node = treeWalker.currentNode;
292
331
  // eslint-disable-next-line no-console
293
332
  console.warn('<Popper>:', node);
@@ -1 +1 @@
1
- {"version":3,"file":"usePopper.js","sourceRoot":"../src/","sources":["usePopper.ts"],"names":[],"mappings":";;AAAA,6DAAuG;AACvG,2DAAqD;AACrD,uCAQuB;AACvB,yCAA2C;AAC3C,6BAA+B;AAK/B,EAAE;AACF,uDAAuD;AACvD,EAAE;AAEF;;;GAGG;AACH,SAAS,gBAAgB,CAAC,IAAU;;IAClC,gJAAgJ;IAChJ,IAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAC1B,IAAI,CAAC,QAAQ,KAAK,OAAO;QACzB,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAC1B,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC;IAE/B,IAAI,sBAAsB,EAAE;QAC1B,OAAO,CAAC,QAAC,6BAAqB,CAAC,IAAI,CAAC,0CAAE,YAAY,CAAC,SAAS,CAAA,CAAC;KAC9D;IAED,OAAO,KAAK,C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,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,mDAAmD;QACnD,sDAAsD;QACtD,KAAK,CAAC,SAAS,CAAC;;YACd,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,IAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC;gBACzC,mDAAmD;gBACnD,IAAM,UAAU,SAAG,WAAW,CAAC,aAAa,0CAAE,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,YAAY,EAAE;oBACnG,UAAU,EAAE,kBAAkB;iBAC/B,CAAC,CAAC;gBAEH,aAAO,UAAU,0CAAE,QAAQ,IAAI;oBAC7B,IAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;oBACpC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAChC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CACV;wBACE,gGAAgG;wBAChG,qGAAqG;wBACrG,2EAA2E;wBAC3E,uEAAuE;wBACvE,IAAI;wBACJ,yFAAyF;wBACzF,oGAAoG;wBACpG,kGAAkG;wBAClG,WAAW;wBACX,8FAA4F;wBAC5F,6FAA6F;wBAC7F,IAAI;wBACJ,2FAA2F;wBAC3F,2CAA2C;wBAC3C,8EAA8E;qBAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;iBACH;aACF;YACD,mDAAmD;YACnD,0EAA0E;YAC1E,uDAAuD;QACzD,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,OAAO,EAAE,SAAS,WAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC/C,CAAC;AAzJD,8BAyJC","sourcesContent":["import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-provider';\nimport {\n isBrowser,\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n} from './utils/index';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { PopperOptions } from './types';\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\n//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nfunction hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n\n/**\n * Provides a callback to resolve Popper options, it's stable and should be used as a dependency to trigger updates\n * of Popper options.\n *\n * A callback is used there intentionally as some of Popper.js modifiers require DOM nodes (targer, container, arrow)\n * that can't be resolved properly during an initial rendering.\n */\nfunction usePopperOptions(options: PopperOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n autoSize,\n flipBoundary,\n offset,\n onStateUpdate,\n overflowBoundary,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_pinned,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(options.align, options.position, isRtl);\n const strategy = options.positionFixed ? 'fixed' : 'absolute';\n\n const handleStateUpdate = useEventCallback(({ state }: { state: Partial<PopperJs.State> }) => {\n if (onStateUpdate) {\n onStateUpdate(state);\n }\n });\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(offset) : offset },\n }\n : null,\n [offset, isRtl],\n );\n\n return React.useCallback(\n (\n target: HTMLElement | PopperJs.VirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ): PopperJs.Options => {\n const scrollParentElement: HTMLElement = getScrollParent(container);\n const hasScrollableElement = scrollParentElement\n ? scrollParentElement !== scrollParentElement.ownerDocument?.body\n : false;\n\n const modifiers: PopperJs.Options['modifiers'] = [\n /**\n * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content\n * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of\n * a patch modifies \".forceUpdate()\" directly after a Popper will be created.\n */\n {\n name: 'positionStyleFix',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n effect: ({ state, instance }: { state: PopperJs.State; instance: PopperInstance }) => {\n // \".isFirstRun\" is a part of our patch, on a first evaluation it will \"undefined\"\n // should be disabled for subsequent runs as it breaks positioning for them\n if (instance.isFirstRun !== false) {\n popperOriginalPositionRef.current = state.elements.popper.style.position;\n state.elements.popper.style.position = 'fixed';\n }\n\n return () => undefined;\n },\n requires: [],\n },\n\n { name: 'flip', options: { flipVariations: true } },\n\n /**\n * unstable_pinned disables the flip modifier by setting flip.enabled to false; this\n * disables automatic repositioning of the popper box; it will always be placed according to\n * the values of `align` and `position` props, regardless of the size of the component, the\n * reference element or the viewport.\n */\n unstable_pinned && { name: 'flip', enabled: false },\n\n /**\n * When the popper box is placed in the context of a scrollable element, we need to set\n * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'\n * (default is 'viewport') so that the popper box will stick with the targetRef when we\n * scroll targetRef out of the viewport.\n */\n hasScrollableElement && { name: 'flip', options: { boundary: 'clippingParents' } },\n hasScrollableElement && { name: 'preventOverflow', options: { boundary: 'clippingParents' } },\n\n offsetModifier,\n\n /**\n * This modifier is necessary to retain behaviour from popper v1 where untethered poppers are allowed by\n * default. i.e. popper is still rendered fully in the viewport even if anchor element is no longer in the\n * viewport.\n */\n unstable_disableTether && {\n name: 'preventOverflow',\n options: { altAxis: unstable_disableTether === 'all', tether: false },\n },\n\n flipBoundary && {\n name: 'flip',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary),\n },\n },\n overflowBoundary && {\n name: 'preventOverflow',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n },\n\n {\n name: 'onUpdate',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n fn: handleStateUpdate,\n },\n\n autoSize && {\n // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\n // popper-maxsize-modifier only calculates the max sizes.\n // This modifier applies the max sizes when overflow is detected\n name: 'applyMaxSize',\n enabled: true,\n phase: 'beforeWrite' as PopperJs.ModifierPhases,\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n fn({ state, options: modifierOptions }: PopperJs.ModifierArguments<{}>) {\n const overflow = PopperJs.detectOverflow(state, modifierOptions);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const [basePlacement] = state.placement.split('-');\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n if (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width')) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height')) {\n state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n },\n },\n\n /**\n * This modifier is necessary in order to render the pointer. Refs are resolved in effects, so it can't be\n * placed under computed modifiers. Deep merge is not required as this modifier has only these properties.\n */\n {\n name: 'arrow',\n enabled: !!arrow,\n options: { element: arrow },\n },\n ].filter(Boolean) as PopperJs.Options['modifiers']; // filter boolean conditional spreading values\n\n const popperOptions: PopperJs.Options = {\n modifiers,\n\n placement,\n strategy,\n onFirstUpdate: state => handleStateUpdate({ state }),\n };\n\n return popperOptions;\n },\n [\n autoSize,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n unstable_pinned,\n\n // These can be skipped from deps as they will not ever change\n handleStateUpdate,\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * Exposes Popper positioning API via React hook. Contains few important differences between an official \"react-popper\"\n * package:\n * - style attributes are applied directly on DOM to avoid re-renders\n * - refs changes and resolution is handled properly without re-renders\n * - contains a specific to React fix related to initial positioning when containers have components with managed focus\n * to avoid focus jumps\n */\nexport function usePopper(\n options: PopperOptions = {},\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { enabled = true } = options;\n const isFirstMount = useFirstMount();\n\n const popperOriginalPositionRef = React.useRef<string>('absolute');\n const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);\n\n const popperInstanceRef = React.useRef<PopperInstance | null>(null);\n\n const handlePopperUpdate = useEventCallback(() => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n\n let popperInstance: PopperInstance | null = null;\n\n if (isBrowser() && enabled) {\n if (targetRef.current && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n targetRef.current,\n containerRef.current,\n resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n }\n\n if (popperInstance) {\n /**\n * The patch updates `.forceUpdate()` Popper function which restores the original position before the first\n * forceUpdate() call. See also \"positionStyleFix\" modifier in usePopperOptions().\n */\n const originalForceUpdate = popperInstance.forceUpdate;\n\n popperInstance.isFirstRun = true;\n popperInstance.forceUpdate = () => {\n if (popperInstance?.isFirstRun) {\n popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;\n popperInstance.isFirstRun = false;\n }\n\n originalForceUpdate();\n };\n }\n\n popperInstanceRef.current = popperInstance;\n });\n\n // Refs are managed by useCallbackRef() to handle ref updates scenarios.\n //\n // The first scenario are updates for a targetRef, we can handle it properly only via callback refs, but it causes\n // re-renders (we would like to avoid them).\n //\n // The second problem is related to refs resolution on React's layer: refs are resolved in the same order as effects\n // that causes an issue when you have a container inside a target, for example: a menu in ChatMessage.\n //\n // function ChatMessage(props) {\n // <div className=\"message\" ref={targetRef}> // 3) ref will be resolved only now, but it's too late already\n // <Popper target={targetRef}> // 2) create a popper instance\n // <div className=\"menu\" /> // 1) capture ref from this element\n // </Popper>\n // </div>\n // }\n //\n // Check a demo on CodeSandbox: https://codesandbox.io/s/popper-refs-emy60.\n //\n // This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation\n // to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.\n const targetRef = useCallbackRef<HTMLElement | PopperJs.VirtualElement | null>(null, handlePopperUpdate, true);\n const containerRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n const arrowRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n\n React.useImperativeHandle(\n options.containerRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n }),\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [options.enabled]);\n useIsomorphicLayoutEffect(() => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n }, [resolvePopperOptions]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n // eslint-disable-next-line deprecation/deprecation\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker?.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n"]}
1
+ {"version":3,"file":"usePopper.js","sourceRoot":"","sources":["../src/usePopper.ts"],"names":[],"mappings":";;;AAAA,6DAAkH;AAClH,yEAA4D;AAC5D,uCAQuB;AACvB,yCAA2C;AAC3C,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AE;oBACnG,UAAU,EAAE,kBAAkB;iBAC/B,CAAC,CAAC;gBAEH,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,IAAI;oBAC7B,IAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;oBACpC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAChC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CACV;wBACE,gGAAgG;wBAChG,qGAAqG;wBACrG,2EAA2E;wBAC3E,uEAAuE;wBACvE,IAAI;wBACJ,yFAAyF;wBACzF,oGAAoG;wBACpG,kGAAkG;wBAClG,WAAW;wBACX,8FAA4F;wBAC5F,6FAA6F;wBAC7F,IAAI;wBACJ,2FAA2F;wBAC3F,2CAA2C;wBAC3C,8EAA8E;qBAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;iBACH;aACF;YACD,mDAAmD;YACnD,0EAA0E;YAC1E,uDAAuD;QACzD,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,OAAO,EAAE,SAAS,WAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC/C,CAAC;AAlKD,8BAkKC"}
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import * as PopperJs from '@popperjs/core';
3
+ /**
4
+ * A state hook that manages a popper virtual element from mouseevents.
5
+ * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
6
+ * React synthetic events are not persisted by this hook
7
+ *
8
+ * @param initialState - initializes a user provided state similare to useState
9
+ * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
10
+ */
11
+ export declare const usePopperMouseTarget: (initialState?: PopperJs.VirtualElement | (() => PopperJs.VirtualElement) | undefined) => readonly [PopperJs.VirtualElement | undefined, (event: React.MouseEvent | MouseEvent | undefined | null) => void];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePopperMouseTarget = void 0;
4
+ var React = require("react");
5
+ var createVirtualElementFromClick_1 = require("./createVirtualElementFromClick");
6
+ /**
7
+ * A state hook that manages a popper virtual element from mouseevents.
8
+ * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
9
+ * React synthetic events are not persisted by this hook
10
+ *
11
+ * @param initialState - initializes a user provided state similare to useState
12
+ * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
13
+ */
14
+ var usePopperMouseTarget = function (initialState) {
15
+ var _a = React.useState(initialState), virtualElement = _a[0], setVirtualElement = _a[1];
16
+ var setVirtualMouseTarget = function (event) {
17
+ if (event === undefined || event === null) {
18
+ setVirtualElement(undefined);
19
+ return;
20
+ }
21
+ var mouseevent;
22
+ if (!(event instanceof MouseEvent)) {
23
+ mouseevent = event.nativeEvent;
24
+ }
25
+ else {
26
+ mouseevent = event;
27
+ }
28
+ if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
29
+ // eslint-disable-next-line no-console
30
+ console.error('usePopperMouseTarget should only be used with MouseEvent');
31
+ }
32
+ var contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
33
+ setVirtualElement(contextTarget);
34
+ };
35
+ return [virtualElement, setVirtualMouseTarget];
36
+ };
37
+ exports.usePopperMouseTarget = usePopperMouseTarget;
38
+ //# sourceMappingURL=usePopperMouseTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePopperMouseTarget.js","sourceRoot":"","sources":["../src/usePopperMouseTarget.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,iFAAgF;AAGhF;;;;;;;GAOG;AACI,IAAM,oBAAoB,GAAG,UAAC,YAAwE;IACrG,IAAA,KAAsC,KAAK,CAAC,QAAQ,CAAsC,YAAY,CAAC,EAAtG,cAAc,QAAA,EAAE,iBAAiB,QAAqE,CAAC;IAE9G,IAAM,qBAAqB,GAAG,UAAC,KAAuD;QACpF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACzC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC7B,OAAO;SACR;QAED,IAAI,UAAsB,CAAC;QAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;SAChC;aAAM;YACL,UAAU,GAAG,KAAK,CAAC;SACpB;QAED,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YAChF,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;SAC3E;QAED,IAAM,aAAa,GAAG,6DAA6B,CAAC,UAAU,CAAC,CAAC;QAChE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAC;AAC1D,CAAC,CAAC;AA1BW,QAAA,oBAAoB,wBA0B/B"}
@@ -0,0 +1,8 @@
1
+ import * as PopperJs from '@popperjs/core';
2
+ /**
3
+ * Returns the base placement value
4
+ * @param placement - the popper placement (i.e. bottom-start)
5
+ *
6
+ * @returns bottom-start -> bottom
7
+ */
8
+ export declare function getBasePlacement(placement: PopperJs.Placement): PopperJs.BasePlacement;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBasePlacement = void 0;
4
+ /**
5
+ * Returns the base placement value
6
+ * @param placement - the popper placement (i.e. bottom-start)
7
+ *
8
+ * @returns bottom-start -> bottom
9
+ */
10
+ function getBasePlacement(placement) {
11
+ return placement.split('-')[0];
12
+ }
13
+ exports.getBasePlacement = getBasePlacement;
14
+ //# sourceMappingURL=getBasePlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBasePlacement.js","sourceRoot":"","sources":["../../src/utils/getBasePlacement.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,SAA6B;IAC5D,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAA2B,CAAC;AAC3D,CAAC;AAFD,4CAEC"}
@@ -1,5 +1,5 @@
1
1
  import * as PopperJs from '@popperjs/core';
2
- import { Boundary } from '../types';
2
+ import type { Boundary } from '../types';
3
3
  /**
4
4
  * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
5
5
  */
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBoundary = void 0;
3
4
  var getScrollParent_1 = require("./getScrollParent");
4
5
  /**
5
6
  * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
6
7
  */
7
8
  function getBoundary(element, boundary) {
8
- var _a, _b;
9
9
  if (boundary === 'window') {
10
- return ((_a = element) === null || _a === void 0 ? void 0 : _a.ownerDocument).documentElement;
10
+ return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
11
11
  }
12
12
  if (boundary === 'scrollParent') {
13
13
  var boundariesNode = getScrollParent_1.getScrollParent(element);
14
14
  if (boundariesNode.nodeName === 'BODY') {
15
- boundariesNode = ((_b = element) === null || _b === void 0 ? void 0 : _b.ownerDocument).documentElement;
15
+ boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
16
16
  }
17
17
  return boundariesNode;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getBoundary.js","sourceRoot":"../src/","sources":["utils/getBoundary.ts"],"names":[],"mappings":";;AAEA,qDAAoD;AAGpD;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,CAAA,MAAA,OAAO,0CAAE,aAAc,CAAA,CAAC,eAAe,CAAC;KAChD;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,cAAc,GAAG,iCAAe,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;YACtC,cAAc,GAAG,CAAA,MAAA,OAAO,0CAAE,aAAc,CAAA,CAAC,eAAe,CAAC;SAC1D;QAED,OAAO,cAA6B,CAAC;KACtC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhBD,kCAgBC","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\nimport { getScrollParent } from './getScrollParent';\nimport { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary): PopperJs.Boundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode as HTMLElement;\n }\n\n return boundary;\n}\n"]}
1
+ {"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../src/utils/getBoundary.ts"],"names":[],"mappings":";;;AAEA,qDAAoD;AAGpD;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;KAChD;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,cAAc,GAA4B,iCAAe,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;YACtC,cAAc,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;SAC1D;QAED,OAAO,cAAc,CAAC;KACvB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhBD,kCAgBC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReactFiberFromNode = void 0;
3
4
  var WorkTag;
4
5
  (function (WorkTag) {
5
6
  WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
@@ -1 +1 @@
1
- {"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"../src/","sources":["utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,SAAgB,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;QACnB,kDAAkD;QAClD,uCAAuC;QACvC,+CAA+C;QAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YACnF,6DAA6D;YAC7D,aAAa;YACb,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACf;KACF;IAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC7E,CAAC;AAjBD,sDAiBC","sourcesContent":["import * as React from 'react';\n\n// ========================================================\n// react/packages/shared/ReactTypes.js\n// ========================================================\n\ntype ReactEventResponder<E, C> = {\n $$typeof: Symbol | number;\n displayName: string;\n targetEventTypes: null | string[];\n rootEventTypes: null | string[];\n getInitialState: null | ((props: Object) => Object);\n onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onMount: null | ((context: C, props: Object, state: Object) => void);\n onUnmount: null | ((context: C, props: Object, state: Object) => void);\n};\n\ntype ReactEventResponderInstance<E, C> = {\n fiber: Object;\n props: Object;\n responder: ReactEventResponder<E, C>;\n rootEventTypes: null | Set<string>;\n state: Object;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiberHooks.js\n// ========================================================\n\nexport type HookType =\n | 'useState'\n | 'useReducer'\n | 'useContext'\n | 'useRef'\n | 'useEffect'\n | 'useLayoutEffect'\n | 'useCallback'\n | 'useMemo'\n | 'useImperativeHandle'\n | 'useDebugValue'\n | 'useResponder';\n\ntype ReactProviderType<T> = {\n $$typeof: Symbol | number;\n _context: ReactContext<T>;\n};\n\ntype ReactContext<T> = {\n $$typeof: Symbol | number;\n Consumer: ReactContext<T>;\n Provider: ReactProviderType<T>;\n\n _calculateChangedBits: ((a: T, b: T) => number) | null;\n\n _currentValue: T;\n _currentValue2: T;\n _threadCount: number;\n\n // DEV only\n _currentRenderer?: Object | null;\n _currentRenderer2?: Object | null;\n};\n\ntype ContextDependency<T> = {\n context: ReactContext<T>;\n observedBits: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n next: ContextDependency<any> | null;\n};\n\nenum WorkTag {\n FunctionComponent = 0,\n ClassComponent = 1,\n IndeterminateComponent = 2, // Before we know whether it is function or class\n HostRoot = 3, // Root of a host tree. Could be nested inside another node.\n HostPortal = 4, // A subtree. Could be an entry point to a different renderer.\n HostComponent = 5,\n HostText = 6,\n Fragment = 7,\n Mode = 8,\n ContextConsumer = 9,\n ContextProvider = 10,\n ForwardRef = 11,\n Profiler = 12,\n SuspenseComponent = 13,\n MemoComponent = 14,\n SimpleMemoComponent = 15,\n LazyComponent = 16,\n IncompleteClassComponent = 17,\n DehydratedFragment = 18,\n SuspenseListComponent = 19,\n FundamentalComponent = 20,\n ScopeComponent = 21,\n}\n\ntype Source = {\n fileName: string;\n lineNumber: number;\n};\n\ntype ExpirationTime = number;\n\ntype Dependencies = {\n expirationTime: ExpirationTime;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstContext: ContextDependency<any> | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiber.js\n// ========================================================\n\n// A Fiber is work on a Component that needs to be done or was done. There can\n// be more than one per component.\n\nexport type Fiber = {\n // These first fields are conceptually members of an Instance. This used to\n // be split into a separate type and intersected with the other Fiber fields,\n // but until Flow fixes its intersection bugs, we've merged them into a\n // single type.\n\n // An Instance is shared between all versions of a component. We can easily\n // break this out into a separate object to avoid copying so much to the\n // alternate versions of the tree. We put this on a single object for now to\n // minimize the number of objects created during the initial render.\n\n // Tag identifying the type of fiber.\n tag: WorkTag;\n\n // Unique identifier of this child.\n key: null | string;\n\n // The value of element.type which is used to preserve the identity during\n // reconciliation of this child.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementType: any;\n\n // The resolved function/class/ associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any;\n\n // The local state associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stateNode: any;\n\n // Conceptual aliases\n // parent : Instance -> return The parent happens to be the same as the\n // return fiber since we've merged the fiber and instance.\n\n // Remaining fields belong to Fiber\n\n // The Fiber to return to after finishing processing this one.\n // This is effectively the parent, but there can be multiple parents (two)\n // so this is only the parent of the thing we're currently processing.\n // It is conceptually the same as the return address of a stack frame.\n return: Fiber | null;\n\n // Singly Linked List Tree Structure.\n child: Fiber | null;\n sibling: Fiber | null;\n index: number;\n\n // The ref last used to attach this node.\n // I'll avoid adding an owner field for prod and model that as functions.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: React.Ref<any>;\n\n // Input is the data coming into process this fiber. Arguments. Props.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pendingProps: any; // This type will be more specific once we overload the tag.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedProps: any; // The props used to create the output.\n\n // A queue of state updates and callbacks.\n // updateQueue: UpdateQueue<any> | null,\n\n // The state used to create the output\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedState: any;\n\n // Dependencies (contexts, events) for this fiber, if it has any\n dependencies: Dependencies | null;\n\n // // Bitfield that describes properties about the fiber and its subtree. E.g.\n // // the ConcurrentMode flag indicates whether the subtree should be async-by-\n // // default. When a fiber is created, it inherits the mode of its\n // // parent. Additional flags can be set at creation time, but after that the\n // // value should remain unchanged throughout the fiber's lifetime, particularly\n // // before its child fibers are created.\n // mode: TypeOfMode\n //\n // // Effect\n // effectTag: SideEffectTag\n\n // Singly linked list fast path to the next fiber with side-effects.\n nextEffect: Fiber | null;\n\n // The first and last fiber with side-effect within this subtree. This allows\n // us to reuse a slice of the linked list when we reuse the work done within\n // this fiber.\n firstEffect: Fiber | null;\n lastEffect: Fiber | null;\n\n // Represents a time in the future by which this work should be completed.\n // Does not include work found in its subtree.\n expirationTime: ExpirationTime;\n\n // This is used to quickly determine if a subtree has no pending changes.\n childExpirationTime: ExpirationTime;\n\n // This is a pooled version of a Fiber. Every fiber that gets updated will\n // eventually have a pair. There are cases when we can clean up pairs to save\n // memory if we need to.\n alternate: Fiber | null;\n\n // Time spent rendering this Fiber and its descendants for the current update.\n // This tells us how well the tree makes use of sCU for memoization.\n // It is reset to 0 each time we render and only updated when we don't bailout.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualDuration?: number;\n\n // If the Fiber is currently active in the \"render\" phase,\n // This marks the time at which the work began.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualStartTime?: number;\n\n // Duration of the most recent render time for this Fiber.\n // This value is not updated when we bailout for memoization purposes.\n // This field is only set when the enableProfilerTimer flag is enabled.\n selfBaseDuration?: number;\n\n // Sum of base times for all descendants of this Fiber.\n // This value bubbles up during the \"complete\" phase.\n // This field is only set when the enableProfilerTimer flag is enabled.\n treeBaseDuration?: number;\n\n // Conceptual aliases\n // workInProgress : Fiber -> alternate The alternate used for reuse happens\n // to be the same as work in progress.\n // __DEV__ only\n _debugID?: number;\n _debugSource?: Source | null;\n _debugOwner?: Fiber | null;\n _debugIsCurrentlyTiming?: boolean;\n _debugNeedsRemount?: boolean;\n\n // Used to verify that the order of hooks does not change between renders.\n _debugHookTypes?: HookType[] | null;\n};\n\nexport function getReactFiberFromNode(elm: Node | undefined): Fiber | null {\n if (!elm) {\n return null;\n }\n\n for (const k in elm) {\n // React 16 uses \"__reactInternalInstance$\" prefix\n // React 17 uses \"__reactFiber$\" prefix\n // https://github.com/facebook/react/pull/18377\n if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return elm[k];\n }\n }\n\n throw new Error('getReactFiber(): Failed to find a React Fiber on a node');\n}\n"]}
1
+ {"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,SAAgB,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;QACnB,kDAAkD;QAClD,uCAAuC;QACvC,+CAA+C;QAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YACnF,6DAA6D;YAC7D,aAAa;YACb,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACf;KACF;IAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC7E,CAAC;AAjBD,sDAiBC"}
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getScrollParent = exports.getParentNode = void 0;
3
4
  /**
4
5
  * Returns the parent node or the host of the node argument.
5
6
  * @param node - DOM node.
6
7
  * @returns - parent DOM node.
7
8
  */
8
- exports.getParentNode = function (node) {
9
+ var getParentNode = function (node) {
9
10
  if (node.nodeName === 'HTML') {
10
11
  return node;
11
12
  }
12
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
14
  return node.parentNode || node.host;
14
15
  };
16
+ exports.getParentNode = getParentNode;
15
17
  /**
16
18
  * Returns CSS styles of the given node.
17
19
  * @param node - DOM node.
@@ -30,7 +32,7 @@ var getStyleComputedProperty = function (node) {
30
32
  * @param node - DOM node.
31
33
  * @returns - the first scrollable parent.
32
34
  */
33
- exports.getScrollParent = function (node) {
35
+ var getScrollParent = function (node) {
34
36
  // Return body, `getScroll` will take care to get the correct `scrollTop` from it
35
37
  var parentNode = node && exports.getParentNode(node);
36
38
  // eslint-disable-next-line
@@ -50,4 +52,5 @@ exports.getScrollParent = function (node) {
50
52
  }
51
53
  return exports.getScrollParent(parentNode);
52
54
  };
55
+ exports.getScrollParent = getScrollParent;
53
56
  //# sourceMappingURL=getScrollParent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getScrollParent.js","sourceRoot":"../src/","sources":["utils/getScrollParent.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACU,QAAA,aAAa,GAAG,UAAC,IAAiB;IAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,OAAO,IAAI,CAAC,UAAU,IAAK,IAAY,CAAC,IAAI,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;GAIG;AACH,IAAM,wBAAwB,GAAG,UAAC,IAAiB;;IACjD,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,IAAM,MAAM,SAAG,IAAI,CAAC,aAAa,0CAAE,WAAW,CAAC;IAC/C,OAAO,MAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACU,QAAA,eAAe,GAAG,UAAC,IAAmC;IACjE,iFAAiF;IACjF,IAAM,UAAU,GAAG,IAAI,IAAI,qBAAa,CAAC,IAAmB,CAAC,CAAC;IAC9D,2BAA2B;IAC3B,IAAI,CAAC,UAAU;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IAEtC,QAAQ,UAAU,CAAC,QAAQ,EAAE;QAC3B,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,UAAU,CAAC,aAAc,CAAC,IAAI,CAAC;QACxC,KAAK,WAAW;YACd,OAAS,UAAmC,CAAC,IAAI,CAAC;KACrD;IAED,uFAAuF;IACjF,IAAA,yCAAyE,EAAvE,sBAAQ,EAAE,wBAAS,EAAE,wBAAkD,CAAC;IAChF,IAAI,uBAAuB,CAAC,IAAI,CAAC,QAAS,GAAG,SAAU,GAAG,SAAS,CAAC,EAAE;QACpE,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,uBAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/**\n * Returns the parent node or the host of the node argument.\n * @param node - DOM node.\n * @returns - parent DOM node.\n */\nexport const getParentNode = (node: HTMLElement): HTMLElement => {\n if (node.nodeName === 'HTML') {\n return node;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return node.parentNode || (node as any).host;\n};\n\n/**\n * Returns CSS styles of the given node.\n * @param node - DOM node.\n * @returns - CSS styles.\n */\nconst getStyleComputedProperty = (node: HTMLElement): Partial<CSSStyleDeclaration> => {\n if (node.nodeType !== 1) {\n return {};\n }\n\n const window = node.ownerDocument?.defaultView;\n return window!.getComputedStyle(node, null);\n};\n\n/**\n * Returns the first scrollable parent of the given element.\n * @param node - DOM node.\n * @returns - the first scrollable parent.\n */\nexport const getScrollParent = (node: Document | HTMLElement | null): HTMLElement => {\n // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n const parentNode = node && getParentNode(node as HTMLElement);\n // eslint-disable-next-line\n if (!parentNode) return document.body;\n\n switch (parentNode.nodeName) {\n case 'HTML':\n case 'BODY':\n return parentNode.ownerDocument!.body;\n case '#document':\n return ((parentNode as unknown) as Document).body;\n }\n\n // If any of the overflow props is defined for the node then we return it as the parent\n const { overflow, overflowX, overflowY } = getStyleComputedProperty(parentNode);\n if (/(auto|scroll|overlay)/.test(overflow! + overflowY! + overflowX)) {\n return parentNode;\n }\n\n return getScrollParent(parentNode);\n};\n"]}
1
+ {"version":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../src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U,CAAC,CAAC;AACrC,CAAC,CAAC;AArBW,QAAA,eAAe,mBAqB1B"}
@@ -1,6 +1,8 @@
1
- export * from './isBrowser';
2
- export * from './positioningHelper';
1
+ export * from './getBasePlacement';
3
2
  export * from './getBoundary';
4
- export * from './getScrollParent';
5
3
  export * from './getReactFiberFromNode';
4
+ export * from './getScrollParent';
5
+ export * from './mergeArrowOffset';
6
+ export * from './positioningHelper';
7
+ export * from './resolvePositioningShorthand';
6
8
  export * from './useCallbackRef';
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./isBrowser"), exports);
5
- tslib_1.__exportStar(require("./positioningHelper"), exports);
4
+ tslib_1.__exportStar(require("./getBasePlacement"), exports);
6
5
  tslib_1.__exportStar(require("./getBoundary"), exports);
7
- tslib_1.__exportStar(require("./getScrollParent"), exports);
8
6
  tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
7
+ tslib_1.__exportStar(require("./getScrollParent"), exports);
8
+ tslib_1.__exportStar(require("./mergeArrowOffset"), exports);
9
+ tslib_1.__exportStar(require("./positioningHelper"), exports);
10
+ tslib_1.__exportStar(require("./resolvePositioningShorthand"), exports);
9
11
  tslib_1.__exportStar(require("./useCallbackRef"), exports);
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,8DAAoC;AACpC,wDAA8B;AAC9B,4DAAkC;AAClC,kEAAwC;AACxC,2DAAiC","sourcesContent":["export * from './isBrowser';\nexport * from './positioningHelper';\nexport * from './getBoundary';\nexport * from './getScrollParent';\nexport * from './getReactFiberFromNode';\nexport * from './useCallbackRef';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,kEAAwC;AACxC,4DAAkC;AAClC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAC9C,2DAAiC"}
@@ -0,0 +1,10 @@
1
+ import type { Offset } from '../types';
2
+ /**
3
+ * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
4
+ * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
5
+ *
6
+ * @param userOffset - The offset provided by the user
7
+ * @param arrowHeight - The height of the arrow in px
8
+ * @returns User offset augmented with arrow height
9
+ */
10
+ export declare function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeArrowOffset = void 0;
4
+ /**
5
+ * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
6
+ * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
7
+ *
8
+ * @param userOffset - The offset provided by the user
9
+ * @param arrowHeight - The height of the arrow in px
10
+ * @returns User offset augmented with arrow height
11
+ */
12
+ function mergeArrowOffset(userOffset, arrowHeight) {
13
+ var offsetWithArrow = userOffset;
14
+ if (!userOffset) {
15
+ return [0, arrowHeight];
16
+ }
17
+ if (Array.isArray(offsetWithArrow)) {
18
+ setArrowOffset(offsetWithArrow, arrowHeight);
19
+ return offsetWithArrow;
20
+ }
21
+ if (typeof offsetWithArrow === 'function') {
22
+ var userOffsetFn_1 = offsetWithArrow;
23
+ offsetWithArrow = function (offsetParams) {
24
+ var offset = userOffsetFn_1(offsetParams);
25
+ setArrowOffset(offset, arrowHeight);
26
+ return offset;
27
+ };
28
+ }
29
+ // This should never happen
30
+ return [0, 0];
31
+ }
32
+ exports.mergeArrowOffset = mergeArrowOffset;
33
+ var setArrowOffset = function (offset, arrowHeight) {
34
+ if (offset[1] !== null && offset[1] !== undefined) {
35
+ offset[1] += arrowHeight;
36
+ }
37
+ else {
38
+ offset[1] = arrowHeight;
39
+ }
40
+ };
41
+ //# sourceMappingURL=mergeArrowOffset.js.map