@fluentui/react-positioning 0.0.0-nightlyff78d1e27a20220217.1 → 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/CHANGELOG.json +376 -10
  2. package/CHANGELOG.md +200 -75
  3. package/dist/{react-positioning.d.ts → index.d.ts} +78 -46
  4. package/{lib → dist}/tsdoc-metadata.json +0 -0
  5. package/lib/createArrowStyles.js +3 -1
  6. package/lib/createArrowStyles.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js +2 -0
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js +4 -5
  10. package/lib/index.js.map +1 -1
  11. package/lib/isIntersectingModifier.js +26 -0
  12. package/lib/isIntersectingModifier.js.map +1 -0
  13. package/lib/types.js.map +1 -1
  14. package/lib/{usePopper.js → usePositioning.js} +12 -9
  15. package/lib/usePositioning.js.map +1 -0
  16. package/lib/{usePopperMouseTarget.js → usePositioningMouseTarget.js} +4 -3
  17. package/lib/usePositioningMouseTarget.js.map +1 -0
  18. package/lib/utils/fromPopperPlacement.js +40 -0
  19. package/lib/utils/fromPopperPlacement.js.map +1 -0
  20. package/lib/utils/getBoundary.js.map +1 -1
  21. package/lib/utils/getPopperOffset.js +44 -0
  22. package/lib/utils/getPopperOffset.js.map +1 -0
  23. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  24. package/lib/utils/getScrollParent.js.map +1 -1
  25. package/lib/utils/index.js +1 -1
  26. package/lib/utils/index.js.map +1 -1
  27. package/lib/utils/mergeArrowOffset.js +24 -22
  28. package/lib/utils/mergeArrowOffset.js.map +1 -1
  29. package/lib/utils/parsePopperPlacement.js +14 -0
  30. package/lib/utils/parsePopperPlacement.js.map +1 -0
  31. package/lib/utils/positioningHelper.js.map +1 -1
  32. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  33. package/lib/utils/useCallbackRef.js.map +1 -1
  34. package/lib-commonjs/createArrowStyles.js +3 -1
  35. package/lib-commonjs/createArrowStyles.js.map +1 -1
  36. package/lib-commonjs/createVirtualElementFromClick.js +2 -0
  37. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  38. package/lib-commonjs/index.js +38 -8
  39. package/lib-commonjs/index.js.map +1 -1
  40. package/lib-commonjs/isIntersectingModifier.js +34 -0
  41. package/lib-commonjs/isIntersectingModifier.js.map +1 -0
  42. package/lib-commonjs/{usePopper.js → usePositioning.js} +16 -11
  43. package/lib-commonjs/usePositioning.js.map +1 -0
  44. package/lib-commonjs/{usePopperMouseTarget.js → usePositioningMouseTarget.js} +6 -5
  45. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -0
  46. package/lib-commonjs/utils/fromPopperPlacement.js +50 -0
  47. package/lib-commonjs/utils/fromPopperPlacement.js.map +1 -0
  48. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  49. package/lib-commonjs/utils/getPopperOffset.js +54 -0
  50. package/lib-commonjs/utils/getPopperOffset.js.map +1 -0
  51. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  52. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  53. package/lib-commonjs/utils/index.js +2 -2
  54. package/lib-commonjs/utils/index.js.map +1 -1
  55. package/lib-commonjs/utils/mergeArrowOffset.js +24 -22
  56. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  57. package/lib-commonjs/utils/parsePopperPlacement.js +23 -0
  58. package/lib-commonjs/utils/parsePopperPlacement.js.map +1 -0
  59. package/lib-commonjs/utils/positioningHelper.js.map +1 -1
  60. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  61. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  62. package/package.json +16 -14
  63. package/lib/createArrowStyles.d.ts +0 -64
  64. package/lib/createVirtualElementFromClick.d.ts +0 -6
  65. package/lib/index.d.ts +0 -6
  66. package/lib/types.d.ts +0 -89
  67. package/lib/usePopper.d.ts +0 -23
  68. package/lib/usePopper.js.map +0 -1
  69. package/lib/usePopperMouseTarget.d.ts +0 -11
  70. package/lib/usePopperMouseTarget.js.map +0 -1
  71. package/lib/utils/getBasePlacement.d.ts +0 -8
  72. package/lib/utils/getBasePlacement.js +0 -10
  73. package/lib/utils/getBasePlacement.js.map +0 -1
  74. package/lib/utils/getBoundary.d.ts +0 -6
  75. package/lib/utils/getReactFiberFromNode.d.ts +0 -108
  76. package/lib/utils/getScrollParent.d.ts +0 -12
  77. package/lib/utils/index.d.ts +0 -8
  78. package/lib/utils/mergeArrowOffset.d.ts +0 -10
  79. package/lib/utils/positioningHelper.d.ts +0 -7
  80. package/lib/utils/resolvePositioningShorthand.d.ts +0 -2
  81. package/lib/utils/useCallbackRef.d.ts +0 -19
  82. package/lib-commonjs/createArrowStyles.d.ts +0 -64
  83. package/lib-commonjs/createVirtualElementFromClick.d.ts +0 -6
  84. package/lib-commonjs/index.d.ts +0 -6
  85. package/lib-commonjs/types.d.ts +0 -89
  86. package/lib-commonjs/usePopper.d.ts +0 -23
  87. package/lib-commonjs/usePopper.js.map +0 -1
  88. package/lib-commonjs/usePopperMouseTarget.d.ts +0 -11
  89. package/lib-commonjs/usePopperMouseTarget.js.map +0 -1
  90. package/lib-commonjs/utils/getBasePlacement.d.ts +0 -8
  91. package/lib-commonjs/utils/getBasePlacement.js +0 -19
  92. package/lib-commonjs/utils/getBasePlacement.js.map +0 -1
  93. package/lib-commonjs/utils/getBoundary.d.ts +0 -6
  94. package/lib-commonjs/utils/getReactFiberFromNode.d.ts +0 -108
  95. package/lib-commonjs/utils/getScrollParent.d.ts +0 -12
  96. package/lib-commonjs/utils/index.d.ts +0 -8
  97. package/lib-commonjs/utils/mergeArrowOffset.d.ts +0 -10
  98. package/lib-commonjs/utils/positioningHelper.d.ts +0 -7
  99. package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +0 -2
  100. package/lib-commonjs/utils/useCallbackRef.d.ts +0 -19
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.usePopper = void 0;
6
+ exports.usePositioning = void 0;
7
7
 
8
8
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
9
 
@@ -13,7 +13,11 @@ const PopperJs = /*#__PURE__*/require("@popperjs/core");
13
13
 
14
14
  const React = /*#__PURE__*/require("react");
15
15
 
16
- const index_1 = /*#__PURE__*/require("./utils/index"); //
16
+ const isIntersectingModifier_1 = /*#__PURE__*/require("./isIntersectingModifier");
17
+
18
+ const index_1 = /*#__PURE__*/require("./utils/index");
19
+
20
+ const getPopperOffset_1 = /*#__PURE__*/require("./utils/getPopperOffset"); //
17
21
  // Dev utils to detect if nodes have "autoFocus" props.
18
22
  //
19
23
 
@@ -63,13 +67,13 @@ function usePopperOptions(options, popperOriginalPositionRef) {
63
67
  // eslint-disable-next-line @typescript-eslint/naming-convention
64
68
  unstable_disableTether
65
69
  } = options;
66
- const isRtl = react_shared_contexts_1.useFluent().dir === 'rtl';
70
+ const isRtl = react_shared_contexts_1.useFluent_unstable().dir === 'rtl';
67
71
  const placement = index_1.getPlacement(align, position, isRtl);
68
72
  const strategy = positionFixed ? 'fixed' : 'absolute';
69
73
  const offsetModifier = React.useMemo(() => offset ? {
70
74
  name: 'offset',
71
75
  options: {
72
- offset: isRtl ? index_1.applyRtlToOffset(offset) : offset
76
+ offset: isRtl ? index_1.applyRtlToOffset(getPopperOffset_1.getPopperOffset(offset)) : getPopperOffset_1.getPopperOffset(offset)
73
77
  }
74
78
  } : null, [offset, isRtl]);
75
79
  return React.useCallback((target, container, arrow) => {
@@ -77,7 +81,7 @@ function usePopperOptions(options, popperOriginalPositionRef) {
77
81
 
78
82
  const scrollParentElement = index_1.getScrollParent(container);
79
83
  const hasScrollableElement = scrollParentElement ? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body) : false;
80
- const modifiers = [
84
+ const modifiers = [isIntersectingModifier_1.isIntersectingModifier,
81
85
  /**
82
86
  * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content
83
87
  * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of
@@ -186,7 +190,7 @@ function usePopperOptions(options, popperOriginalPositionRef) {
186
190
  width,
187
191
  height
188
192
  } = state.rects.popper;
189
- const basePlacement = index_1.getBasePlacement(state.placement);
193
+ const basePlacement = index_1.parsePopperPlacement(state.placement).basePlacement;
190
194
  const widthProp = basePlacement === 'left' ? 'left' : 'right';
191
195
  const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
192
196
  const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width');
@@ -226,7 +230,7 @@ function usePopperOptions(options, popperOriginalPositionRef) {
226
230
  fn({
227
231
  state
228
232
  }) {
229
- const basePlacement = index_1.getBasePlacement(state.placement);
233
+ const basePlacement = index_1.parsePopperPlacement(state.placement).basePlacement;
230
234
 
231
235
  switch (basePlacement) {
232
236
  case 'bottom':
@@ -259,6 +263,7 @@ function usePopperOptions(options, popperOriginalPositionRef) {
259
263
  popperOriginalPositionRef]);
260
264
  }
261
265
  /**
266
+ * @internal
262
267
  * Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
263
268
  * package:
264
269
  * - style attributes are applied directly on DOM to avoid re-renders
@@ -268,7 +273,7 @@ function usePopperOptions(options, popperOriginalPositionRef) {
268
273
  */
269
274
 
270
275
 
271
- function usePopper(options = {}) {
276
+ function usePositioning(options = {}) {
272
277
  const {
273
278
  enabled = true
274
279
  } = options;
@@ -335,7 +340,7 @@ function usePopper(options = {}) {
335
340
  const arrowRef = index_1.useCallbackRef(null, handlePopperUpdate, true); // Stores external target from options.target or setTarget
336
341
 
337
342
  const overrideTargetRef = index_1.useCallbackRef(null, handlePopperUpdate, true);
338
- React.useImperativeHandle(options.popperRef, () => ({
343
+ React.useImperativeHandle(options.positioningRef, () => ({
339
344
  updatePosition: () => {
340
345
  var _a;
341
346
 
@@ -416,5 +421,5 @@ function usePopper(options = {}) {
416
421
  };
417
422
  }
418
423
 
419
- exports.usePopper = usePopper;
420
- //# sourceMappingURL=usePopper.js.map
424
+ exports.usePositioning = usePositioning;
425
+ //# sourceMappingURL=usePositioning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,QAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,wBAAA,gBAAA,OAAA,CAAA,0BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAUA,MAAA,iBAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA,C,CAYA;AACA;AACA;;AAEA;;;AAGG;;;AACH,SAAS,gBAAT,CAA0B,IAA1B,EAAoC;SAAA,CAClC;;;EACA,MAAM,sBAAsB,GAC1B,IAAI,CAAC,QAAL,KAAkB,QAAlB,IACA,IAAI,CAAC,QAAL,KAAkB,OADlB,IAEA,IAAI,CAAC,QAAL,KAAkB,QAFlB,IAGA,IAAI,CAAC,QAAL,KAAkB,UAJpB;;EAMA,IAAI,sBAAJ,EAA4B;IAC1B,OAAO,CAAC,EAAC,CAAA,EAAA,GAAA,OAAA,CAAA,qBAAA,CAAsB,IAAtB,CAAA,MAA2B,IAA3B,IAA2B,EAAA,KAAA,KAAA,CAA3B,GAA2B,KAAA,CAA3B,GAA2B,EAAA,CAAE,YAAF,CAAe,SAA3C,CAAR;EACD;;EAED,OAAO,KAAP;AACD;;AAED,SAAS,kBAAT,CAA4B,IAA5B,EAAsC;EACpC,OAAO,gBAAgB,CAAC,IAAD,CAAhB,GAAyB,UAAU,CAAC,aAApC,GAAoD,UAAU,CAAC,WAAtE;AACD;AAED;;;;;;AAMG;;;AACH,SAAS,gBAAT,CAA0B,OAA1B,EAAuD,y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CACE,CACE,gGADF,EAEE,qGAFF,EAGE,2EAHF,EAIE,uEAJF,EAKE,IALF,EAME,yFANF,EAOE,oGAPF,EAQE,kGARF,EASE,WATF,EAUE,4FAVF,EAWE,6FAXF,EAYE,IAZF,EAaE,2FAbF,EAcE,2CAdF,EAeE,8EAfF,EAgBE,IAhBF,CAgBO,GAhBP,CADF;QAmBD;MACF,CAhCkB,CAiCnB;MACA;MACA;;IACD,CApCD,EAoCG,EApCH;EAqCD;;EAED,OAAO;IAAE,SAAF;IAAa,YAAb;IAA2B;EAA3B,CAAP;AACD;;AA5LD,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount, canUseDOM } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { isIntersectingModifier } from './isIntersectingModifier';\nimport {\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n parsePopperPlacement,\n} from './utils/index';\nimport type { PositioningVirtualElement, PositioningOptions, PositioningProps } from './types';\nimport { getPopperOffset } from './utils/getPopperOffset';\n\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\ninterface UsePopperOptions extends PositioningProps {\n /**\n * If false, delays Popper's creation.\n * @default true\n */\n enabled?: boolean;\n}\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: PositioningOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n positionFixed,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(align, position, isRtl);\n const strategy = positionFixed ? 'fixed' : 'absolute';\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(getPopperOffset(offset)) : getPopperOffset(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 isIntersectingModifier,\n\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 * 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 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 // 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 can apply max sizes always, or apply the max sizes only when overflow is detected\n name: 'applyMaxSize',\n enabled: !!autoSize,\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 = parsePopperPlacement(state.placement).basePlacement;\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\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, padding: arrowPadding },\n },\n\n /**\n * Modifies popper offsets to cover the reference rect, but still keep edge alignment\n */\n {\n name: 'coverTarget',\n enabled: !!coverTarget,\n phase: 'main',\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n fn({ state }: PopperJs.ModifierArguments<{}>) {\n const basePlacement = parsePopperPlacement(state.placement).basePlacement;\n switch (basePlacement) {\n case 'bottom':\n state.modifiersData.popperOffsets!.y -= state.rects.reference.height;\n break;\n case 'top':\n state.modifiersData.popperOffsets!.y += state.rects.reference.height;\n break;\n case 'left':\n state.modifiersData.popperOffsets!.x += state.rects.reference.width;\n break;\n case 'right':\n state.modifiersData.popperOffsets!.x -= state.rects.reference.width;\n break;\n }\n },\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 };\n\n return popperOptions;\n },\n [\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n pinned,\n\n // These can be skipped from deps as they will not ever change\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * @internal\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 usePositioning(\n options: UsePopperOptions = {},\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 const target = overrideTargetRef.current ?? targetRef.current;\n\n let popperInstance: PopperInstance | null = null;\n\n if (canUseDOM() && enabled) {\n if (target && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n target,\n containerRef.current,\n resolvePopperOptions(target, 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 // Stores external target from options.target or setTarget\n const overrideTargetRef = useCallbackRef<HTMLElement | PositioningVirtualElement | null>(\n null,\n handlePopperUpdate,\n true,\n );\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n setTarget: (target: HTMLElement | PositioningVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (options.target) {\n overrideTargetRef.current = options.target;\n }\n }, [options.target, overrideTargetRef]);\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [handlePopperUpdate, options.enabled]);\n useIsomorphicLayoutEffect(\n () => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(overrideTargetRef.current ?? targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n },\n // Missing deps:\n // isFirstMount - Should never change after mount\n // arrowRef, containerRef, targetRef - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [resolvePopperOptions],\n );\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 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"],"sourceRoot":"../src/"}
@@ -3,12 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.usePopperMouseTarget = void 0;
6
+ exports.usePositioningMouseTarget = void 0;
7
7
 
8
8
  const React = /*#__PURE__*/require("react");
9
9
 
10
10
  const createVirtualElementFromClick_1 = /*#__PURE__*/require("./createVirtualElementFromClick");
11
11
  /**
12
+ * @internal
12
13
  * A state hook that manages a popper virtual element from mouseevents.
13
14
  * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
14
15
  * React synthetic events are not persisted by this hook
@@ -18,7 +19,7 @@ const createVirtualElementFromClick_1 = /*#__PURE__*/require("./createVirtualEle
18
19
  */
19
20
 
20
21
 
21
- const usePopperMouseTarget = initialState => {
22
+ const usePositioningMouseTarget = initialState => {
22
23
  const [virtualElement, setVirtualElement] = React.useState(initialState);
23
24
 
24
25
  const setVirtualMouseTarget = event => {
@@ -37,7 +38,7 @@ const usePopperMouseTarget = initialState => {
37
38
 
38
39
  if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
39
40
  // eslint-disable-next-line no-console
40
- console.error('usePopperMouseTarget should only be used with MouseEvent');
41
+ console.error('usePositioningMouseTarget should only be used with MouseEvent');
41
42
  }
42
43
 
43
44
  const contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
@@ -47,5 +48,5 @@ const usePopperMouseTarget = initialState => {
47
48
  return [virtualElement, setVirtualMouseTarget];
48
49
  };
49
50
 
50
- exports.usePopperMouseTarget = usePopperMouseTarget;
51
- //# sourceMappingURL=usePopperMouseTarget.js.map
51
+ exports.usePositioningMouseTarget = usePositioningMouseTarget;
52
+ //# sourceMappingURL=usePositioningMouseTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePositioningMouseTarget.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,MAAM,yBAAyB,GACpC,YADuC,IAErC;EACF,MAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAsD,YAAtD,CAA5C;;EAEA,MAAM,qBAAqB,GAAI,KAAD,IAA4D;IACxF,IAAI,KAAK,KAAK,SAAV,IAAuB,KAAK,KAAK,IAArC,EAA2C;MACzC,iBAAiB,CAAC,SAAD,CAAjB;MACA;IACD;;IAED,IAAI,UAAJ;;IACA,IAAI,EAAE,KAAK,YAAY,UAAnB,CAAJ,EAAoC;MAClC,UAAU,GAAG,KAAK,CAAC,WAAnB;IACD,CAFD,MAEO;MACL,UAAU,GAAG,KAAb;IACD;;IAED,IAAI,EAAE,UAAU,YAAY,UAAxB,KAAuC,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAApE,EAAkF;MAChF;MACA,OAAO,CAAC,KAAR,CAAc,+DAAd;IACD;;IAED,MAAM,aAAa,GAAG,+BAAA,CAAA,6BAAA,CAA8B,UAA9B,CAAtB;IACA,iBAAiB,CAAC,aAAD,CAAjB;EACD,CApBD;;EAsBA,OAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA5BM;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fromPopperPlacement = void 0;
7
+
8
+ const parsePopperPlacement_1 = /*#__PURE__*/require("./parsePopperPlacement");
9
+
10
+ const positionMap = {
11
+ top: 'above',
12
+ bottom: 'below',
13
+ right: 'after',
14
+ left: 'before'
15
+ };
16
+
17
+ const getAlignmentMap = position => {
18
+ if (position === 'above' || position === 'below') {
19
+ return {
20
+ start: 'start',
21
+ end: 'end'
22
+ };
23
+ }
24
+
25
+ return {
26
+ start: 'top',
27
+ end: 'bottom'
28
+ };
29
+ };
30
+ /**
31
+ * Maps Popper.js placement to positioning values
32
+ * @see positioningHelper.test.ts for expected placement values
33
+ */
34
+
35
+
36
+ const fromPopperPlacement = placement => {
37
+ const {
38
+ basePlacement,
39
+ alignment: popperAlignment
40
+ } = parsePopperPlacement_1.parsePopperPlacement(placement);
41
+ const position = positionMap[basePlacement];
42
+ const alignment = popperAlignment && getAlignmentMap(position)[popperAlignment];
43
+ return {
44
+ position,
45
+ alignment
46
+ };
47
+ };
48
+
49
+ exports.fromPopperPlacement = fromPopperPlacement;
50
+ //# sourceMappingURL=fromPopperPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/fromPopperPlacement.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AAEA,MAAM,WAAW,GAAG;EAClB,GAAG,EAAE,OADa;EAElB,MAAM,EAAE,OAFU;EAGlB,KAAK,EAAE,OAHW;EAIlB,IAAI,EAAE;AAJY,CAApB;;AAOA,MAAM,eAAe,GAAI,QAAD,IAA2D;EACjF,IAAI,QAAQ,KAAK,OAAb,IAAwB,QAAQ,KAAK,OAAzC,EAAkD;IAChD,OAAO;MACL,KAAK,EAAE,OADF;MAEL,GAAG,EAAE;IAFA,CAAP;EAID;;EAED,OAAO;IACL,KAAK,EAAE,KADF;IAEL,GAAG,EAAE;EAFA,CAAP;AAID,CAZD;AAcA;;;AAGG;;;AACI,MAAM,mBAAmB,GAAI,SAAD,IAAwE;EACzG,MAAM;IAAE,aAAF;IAAiB,SAAS,EAAE;EAA5B,IAAgD,sBAAA,CAAA,oBAAA,CAAqB,SAArB,CAAtD;EACA,MAAM,QAAQ,GAAG,WAAW,CAAC,aAAD,CAA5B;EACA,MAAM,SAAS,GAAG,eAAe,IAAI,eAAe,CAAC,QAAD,CAAf,CAA0B,eAA1B,CAArC;EAEA,OAAO;IAAE,QAAF;IAAY;EAAZ,CAAP;AACD,CANM;;AAAM,OAAA,CAAA,mBAAA,GAAmB,mBAAnB","sourcesContent":["import type { Variation as PopperAlignment, Placement } from '@popperjs/core';\nimport type { Alignment, Position } from '../types';\nimport { parsePopperPlacement } from './parsePopperPlacement';\n\nconst positionMap = {\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n} as const;\n\nconst getAlignmentMap = (position: Position): Record<PopperAlignment, Alignment> => {\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end',\n };\n }\n\n return {\n start: 'top',\n end: 'bottom',\n };\n};\n\n/**\n * Maps Popper.js placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromPopperPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { basePlacement, alignment: popperAlignment } = parsePopperPlacement(placement);\n const position = positionMap[basePlacement];\n const alignment = popperAlignment && getAlignmentMap(position)[popperAlignment];\n\n return { position, alignment };\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/getBoundary.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAGA;;AAEG;;;AACH,SAAgB,WAAhB,CAA4B,OAA5B,EAAyD,QAAzD,EAA4E;AAC1E,MAAI,QAAQ,KAAK,QAAjB,EAA2B;AACzB,WAAO,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAA/B;AACD;;AAED,MAAI,QAAQ,KAAK,cAAjB,EAAiC;AAC/B,QAAI,cAAc,GAA4B,iBAAA,CAAA,eAAA,CAAgB,OAAhB,CAA9C;;AAEA,QAAI,cAAc,CAAC,QAAf,KAA4B,MAAhC,EAAwC;AACtC,MAAA,cAAc,GAAG,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAAzC;AACD;;AAED,WAAO,cAAP;AACD;;AAED,SAAO,QAAP;AACD;;AAhBD,OAAA,CAAA,WAAA,GAAA,WAAA","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { 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: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/getBoundary.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAGA;;AAEG;;;AACH,SAAgB,WAAhB,CAA4B,OAA5B,EAAyD,QAAzD,EAA4E;EAC1E,IAAI,QAAQ,KAAK,QAAjB,EAA2B;IACzB,OAAO,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAA/B;EACD;;EAED,IAAI,QAAQ,KAAK,cAAjB,EAAiC;IAC/B,IAAI,cAAc,GAA4B,iBAAA,CAAA,eAAA,CAAgB,OAAhB,CAA9C;;IAEA,IAAI,cAAc,CAAC,QAAf,KAA4B,MAAhC,EAAwC;MACtC,cAAc,GAAG,OAAO,KAAA,IAAP,IAAA,OAAO,KAAA,KAAA,CAAP,GAAO,KAAA,CAAP,GAAA,OAAO,CAAE,aAAT,CAAwB,eAAzC;IACD;;IAED,OAAO,cAAP;EACD;;EAED,OAAO,QAAP;AACD;;AAhBD,OAAA,CAAA,WAAA,GAAA,WAAA","sourcesContent":["import * as PopperJs from '@popperjs/core';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { 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: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopperOffset = void 0;
7
+
8
+ const fromPopperPlacement_1 = /*#__PURE__*/require("./fromPopperPlacement");
9
+ /**
10
+ * Shim to transform offset values from this library to Popper.js
11
+ * @param rawOffset Offset from this library
12
+ * @returns An offset value compatible with Popper.js
13
+ */
14
+
15
+
16
+ function getPopperOffset(rawOffset) {
17
+ if (rawOffset === undefined || rawOffset === null) {
18
+ return rawOffset;
19
+ }
20
+
21
+ if (typeof rawOffset === 'number') {
22
+ return [0, rawOffset];
23
+ }
24
+
25
+ if (typeof rawOffset === 'object') {
26
+ return [rawOffset.crossAxis, rawOffset.mainAxis];
27
+ }
28
+
29
+ return ({
30
+ popper,
31
+ reference,
32
+ placement
33
+ }) => {
34
+ const {
35
+ position,
36
+ alignment
37
+ } = fromPopperPlacement_1.fromPopperPlacement(placement);
38
+ const computedOffset = rawOffset({
39
+ positionedRect: popper,
40
+ targetRect: reference,
41
+ position,
42
+ alignment
43
+ });
44
+
45
+ if (typeof computedOffset === 'number') {
46
+ return [0, computedOffset];
47
+ }
48
+
49
+ return [computedOffset.crossAxis, computedOffset.mainAxis];
50
+ };
51
+ }
52
+
53
+ exports.getPopperOffset = getPopperOffset;
54
+ //# sourceMappingURL=getPopperOffset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/getPopperOffset.ts"],"names":[],"mappings":";;;;;;;AAEA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAyBA;;;;AAIG;;;AACH,SAAgB,eAAhB,CAAgC,SAAhC,EAA6D;EAC3D,IAAI,SAAS,KAAK,SAAd,IAA2B,SAAS,KAAK,IAA7C,EAAmD;IACjD,OAAO,SAAP;EACD;;EAED,IAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;IACjC,OAAO,CAAC,CAAD,EAAI,SAAJ,CAAP;EACD;;EAED,IAAI,OAAO,SAAP,KAAqB,QAAzB,EAAmC;IACjC,OAAO,CAAC,SAAS,CAAC,SAAX,EAAsB,SAAS,CAAC,QAAhC,CAAP;EACD;;EAED,OAAO,CAAC;IAAE,MAAF;IAAU,SAAV;IAAqB;EAArB,CAAD,KAAqC;IAC1C,MAAM;MAAE,QAAF;MAAY;IAAZ,IAA0B,qBAAA,CAAA,mBAAA,CAAoB,SAApB,CAAhC;IACA,MAAM,cAAc,GAAG,SAAS,CAAC;MAAE,cAAc,EAAE,MAAlB;MAA0B,UAAU,EAAE,SAAtC;MAAiD,QAAjD;MAA2D;IAA3D,CAAD,CAAhC;;IACA,IAAI,OAAO,cAAP,KAA0B,QAA9B,EAAwC;MACtC,OAAO,CAAC,CAAD,EAAI,cAAJ,CAAP;IACD;;IAED,OAAO,CAAC,cAAc,CAAC,SAAhB,EAA2B,cAAc,CAAC,QAA1C,CAAP;EACD,CARD;AASD;;AAtBD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["import type { Offset } from '../types';\nimport type { Rect, Placement } from '@popperjs/core';\nimport { fromPopperPlacement } from './fromPopperPlacement';\n/**\n * Type taken from Popper since it is not exported\n */\nexport type PopperOffsetValue = [number | null | undefined, number | null | undefined];\n\n/**\n * Type taken from Popper since it is not exported\n */\nexport type PopperOffset = PopperOffsetValue | PopperOffsetFunction;\n\n/**\n * Type taken from Popper.js since it is not exported\n */\nexport type PopperOffsetFunctionParam = {\n popper: Rect;\n reference: Rect;\n placement: Placement;\n};\n\n/**\n * Type taken from Popper.js since it is not exported\n */\nexport type PopperOffsetFunction = (args: { popper: Rect; reference: Rect; placement: Placement }) => PopperOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Popper.js\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Popper.js\n */\nexport function getPopperOffset(rawOffset: Offset | undefined): PopperOffsetValue | PopperOffsetFunction | undefined {\n if (rawOffset === undefined || rawOffset === null) {\n return rawOffset;\n }\n\n if (typeof rawOffset === 'number') {\n return [0, rawOffset];\n }\n\n if (typeof rawOffset === 'object') {\n return [rawOffset.crossAxis, rawOffset.mainAxis];\n }\n\n return ({ popper, reference, placement }) => {\n const { position, alignment } = fromPopperPlacement(placement);\n const computedOffset = rawOffset({ positionedRect: popper, targetRect: reference, position, alignment });\n if (typeof computedOffset === 'number') {\n return [0, computedOffset];\n }\n\n return [computedOffset.crossAxis, computedOffset.mainAxis];\n };\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;;;;AAuEA,IAAK,OAAL;;AAAA,CAAA,UAAK,OAAL,EAAY;AACV,EAAA,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,mBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,gBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,wBAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,CAAA,CAAA,GAAA,eAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA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GAAA,EAAA,CAAZ;;AAsLA,SAAgB,qBAAhB,CAAsC,GAAtC,EAA2D;AACzD,MAAI,CAAC,GAAL,EAAU;AACR,WAAO,IAAP;AACD;;AAED,OAAK,MAAM,CAAX,IAAgB,GAAhB,EAAqB;AACnB;AACA;AACA;AACA,QAAI,CAAC,CAAC,OAAF,CAAU,0BAAV,MAA0C,CAA1C,IAA+C,CAAC,CAAC,OAAF,CAAU,eAAV,MAA+B,CAAlF,EAAqF;AACnF;AACA;AACA,aAAO,GAAG,CAAC,CAAD,CAAV;AACD;AACF;;AAED,QAAM,IAAI,KAAJ,CAAU,yDAAV,CAAN;AACD;;AAjBD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/getReactFiberFromNode.ts"],"names":[],"mappings":";;;;;;AAuEA,IAAK,OAAL;;AAAA,CAAA,UAAK,OAAL,EAAY;EACV,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,mBAAA;EACA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,gBAAA;EACA,OAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,wBAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,CAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;EACA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,iBAAA;EACA,OAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,iBAAA;EACA,OAAA,CAAA,OAAA,CAAA,YAAA,CAAA,GAAA,EAAA,CAAA,GAAA,YAAA;EACA,OAAA,CAAA,OAAA,CAAA,UAAA,CAAA,GAAA,EAAA,CAAA,GAAA,UAAA;EACA,OAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,mBAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,qBAAA;EACA,OAAA,CAAA,OAAA,CAAA,eAAA,CAAA,GAAA,EAAA,CAAA,GAAA,eAAA;EACA,OAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,GAAA,EAAA,CAAA,GAAA,0BAAA;EACA,OAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,oBAAA;EACA,OAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,uBAAA;EACA,OAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,sBAAA;EACA,OAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,gBAAA;AACD,CAvBD,EAAK,OAAO,KAAP,OAAO,GAAA,EAAA,CAAZ;;AAsLA,SAAgB,qBAAhB,CAAsC,GAAtC,EAA2D;EACzD,IAAI,CAAC,GAAL,EAAU;IACR,OAAO,IAAP;EACD;;EAED,KAAK,MAAM,CAAX,IAAgB,GAAhB,EAAqB;IACnB;IACA;IACA;IACA,IAAI,CAAC,CAAC,OAAF,CAAU,0BAAV,MAA0C,CAA1C,IAA+C,CAAC,CAAC,OAAF,CAAU,eAAV,MAA+B,CAAlF,EAAqF;MACnF;MACA;MACA,OAAO,GAAG,CAAC,CAAD,CAAV;IACD;EACF;;EAED,MAAM,IAAI,KAAJ,CAAU,yDAAV,CAAN;AACD;;AAjBD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":";;;;;;AAAA;;;;AAIG;;AACI,MAAM,aAAa,GAAI,IAAD,IAAmC;AAC9D,MAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;AAC5B,WAAO,IAAP;AACD,GAH6D,CAI9D;;;AACA,SAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb;AAQb;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;AACnF,MAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;AACvB,WAAO,EAAP;AACD;;AAED,QAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;AACA,SAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACI,MAAM,eAAe,GAAI,IAAD,IAAqD;AAClF;AACA,QAAM,UAAU,GAAG,IAAI,IAAI,OAAA,CAAA,aAAA,CAAc,IAAd,CAA3B,CAFkF,CAGlF;;AACA,MAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;AAEjB,UAAQ,UAAU,CAAC,QAAnB;AACE,SAAK,MAAL;AACA,SAAK,MAAL;AACE,aAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;AACF,SAAK,WAAL;AACE,aAAS,UAAmC,CAAC,IAA7C;AALJ,GANkF,CAclF;;;AACA,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,SAAZ;AAAuB,IAAA;AAAvB,MAAqC,wBAAwB,CAAC,UAAD,CAAnE;;AACA,MAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;AACpE,WAAO,UAAP;AACD;;AAED,SAAO,OAAA,CAAA,eAAA,CAAgB,UAAhB,CAAP;AACD,CArBM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","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"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/getScrollParent.ts"],"names":[],"mappings":";;;;;;AAAA;;;;AAIG;;AACI,MAAM,aAAa,GAAI,IAAD,IAAmC;EAC9D,IAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;IAC5B,OAAO,IAAP;EACD,CAH6D,CAI9D;;;EACA,OAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb;AAQb;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;EACnF,IAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;IACvB,OAAO,EAAP;EACD;;EAED,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;EACA,OAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACI,MAAM,eAAe,GAAI,IAAD,IAAqD;EAClF;EACA,MAAM,UAAU,GAAG,IAAI,IAAI,OAAA,CAAA,aAAA,CAAc,IAAd,CAA3B,CAFkF,CAGlF;;EACA,IAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;EAEjB,QAAQ,UAAU,CAAC,QAAnB;IACE,KAAK,MAAL;IACA,KAAK,MAAL;MACE,OAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;IACF,KAAK,WAAL;MACE,OAAS,UAAmC,CAAC,IAA7C;EALJ,CANkF,CAclF;;;EACA,MAAM;IAAE,QAAF;IAAY,SAAZ;IAAuB;EAAvB,IAAqC,wBAAwB,CAAC,UAAD,CAAnE;;EACA,IAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;IACpE,OAAO,UAAP;EACD;;EAED,OAAO,OAAA,CAAA,eAAA,CAAgB,UAAhB,CAAP;AACD,CArBM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","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"],"sourceRoot":"../src/"}
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const tslib_1 = /*#__PURE__*/require("tslib");
8
8
 
9
- tslib_1.__exportStar(require("./getBasePlacement"), exports);
10
-
11
9
  tslib_1.__exportStar(require("./getBoundary"), exports);
12
10
 
13
11
  tslib_1.__exportStar(require("./getReactFiberFromNode"), exports);
@@ -21,4 +19,6 @@ tslib_1.__exportStar(require("./positioningHelper"), exports);
21
19
  tslib_1.__exportStar(require("./resolvePositioningShorthand"), exports);
22
20
 
23
21
  tslib_1.__exportStar(require("./useCallbackRef"), exports);
22
+
23
+ tslib_1.__exportStar(require("./parsePopperPlacement"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './getBasePlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './positioningHelper';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './positioningHelper';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './parsePopperPlacement';\n"],"sourceRoot":"../src/"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.mergeArrowOffset = void 0;
7
7
  /**
8
+ * @internal
8
9
  * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
9
10
  * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
10
11
  *
@@ -14,38 +15,39 @@ exports.mergeArrowOffset = void 0;
14
15
  */
15
16
 
16
17
  function mergeArrowOffset(userOffset, arrowHeight) {
17
- let offsetWithArrow = userOffset;
18
-
19
- if (!userOffset) {
20
- return [0, arrowHeight];
18
+ if (typeof userOffset === 'number') {
19
+ return addArrowOffset(userOffset, arrowHeight);
21
20
  }
22
21
 
23
- if (Array.isArray(offsetWithArrow)) {
24
- setArrowOffset(offsetWithArrow, arrowHeight);
25
- return offsetWithArrow;
22
+ if (typeof userOffset === 'object' && userOffset !== null) {
23
+ return addArrowOffset(userOffset, arrowHeight);
26
24
  }
27
25
 
28
- if (typeof offsetWithArrow === 'function') {
29
- const userOffsetFn = offsetWithArrow;
30
-
31
- offsetWithArrow = offsetParams => {
32
- const offset = userOffsetFn(offsetParams);
33
- setArrowOffset(offset, arrowHeight);
34
- return offset;
26
+ if (typeof userOffset === 'function') {
27
+ return offsetParams => {
28
+ const offset = userOffset(offsetParams);
29
+ return addArrowOffset(offset, arrowHeight);
35
30
  };
36
- } // This should never happen
37
-
31
+ }
38
32
 
39
- return [0, 0];
33
+ return {
34
+ mainAxis: arrowHeight
35
+ };
40
36
  }
41
37
 
42
38
  exports.mergeArrowOffset = mergeArrowOffset;
43
39
 
44
- const setArrowOffset = (offset, arrowHeight) => {
45
- if (offset[1] !== null && offset[1] !== undefined) {
46
- offset[1] += arrowHeight;
47
- } else {
48
- offset[1] = arrowHeight;
40
+ const addArrowOffset = (offset, arrowHeight) => {
41
+ var _a;
42
+
43
+ if (typeof offset === 'number') {
44
+ return {
45
+ mainAxis: offset + arrowHeight
46
+ };
49
47
  }
48
+
49
+ return { ...offset,
50
+ mainAxis: ((_a = offset.mainAxis) !== null && _a !== void 0 ? _a : 0) + arrowHeight
51
+ };
50
52
  };
51
53
  //# sourceMappingURL=mergeArrowOffset.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;AAOG;;AACH,SAAgB,gBAAhB,CAAiC,UAAjC,EAAwE,WAAxE,EAA2F;AACzF,MAAI,eAAe,GAAG,UAAtB;;AACA,MAAI,CAAC,UAAL,EAAiB;AACf,WAAO,CAAC,CAAD,EAAI,WAAJ,CAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,eAAd,CAAJ,EAAoC;AAClC,IAAA,cAAc,CAAC,eAAD,EAAkB,WAAlB,CAAd;AACA,WAAO,eAAP;AACD;;AAED,MAAI,OAAO,eAAP,KAA2B,UAA/B,EAA2C;AACzC,UAAM,YAAY,GAAG,eAArB;;AACA,IAAA,eAAe,GAAG,YAAY,IAAG;AAC/B,YAAM,MAAM,GAAG,YAAY,CAAC,YAAD,CAA3B;AACA,MAAA,cAAc,CAAC,MAAD,EAAS,WAAT,CAAd;AACA,aAAO,MAAP;AACD,KAJD;AAKD,GAlBwF,CAoBzF;;;AACA,SAAO,CAAC,CAAD,EAAI,CAAJ,CAAP;AACD;;AAtBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAwBA,MAAM,cAAc,GAAG,CAAC,MAAD,EAAiE,WAAjE,KAAwF;AAC7G,MAAI,MAAM,CAAC,CAAD,CAAN,KAAc,IAAd,IAAsB,MAAM,CAAC,CAAD,CAAN,KAAc,SAAxC,EAAmD;AACjD,IAAA,MAAM,CAAC,CAAD,CAAN,IAAa,WAAb;AACD,GAFD,MAEO;AACL,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,WAAZ;AACD;AACF,CAND","sourcesContent":["import type { Offset } from '../types';\n\n/**\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n let offsetWithArrow = userOffset;\n if (!userOffset) {\n return [0, arrowHeight];\n }\n\n if (Array.isArray(offsetWithArrow)) {\n setArrowOffset(offsetWithArrow, arrowHeight);\n return offsetWithArrow;\n }\n\n if (typeof offsetWithArrow === 'function') {\n const userOffsetFn = offsetWithArrow;\n offsetWithArrow = offsetParams => {\n const offset = userOffsetFn(offsetParams);\n setArrowOffset(offset, arrowHeight);\n return offset;\n };\n }\n\n // This should never happen\n return [0, 0] as never;\n}\n\nconst setArrowOffset = (offset: [number | null | undefined, number | null | undefined], arrowHeight: number) => {\n if (offset[1] !== null && offset[1] !== undefined) {\n offset[1] += arrowHeight;\n } else {\n offset[1] = arrowHeight;\n }\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/mergeArrowOffset.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;;AAQG;;AACH,SAAgB,gBAAhB,CAAiC,UAAjC,EAAwE,WAAxE,EAA2F;EACzF,IAAI,OAAO,UAAP,KAAsB,QAA1B,EAAoC;IAClC,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,QAAtB,IAAkC,UAAU,KAAK,IAArD,EAA2D;IACzD,OAAO,cAAc,CAAC,UAAD,EAAa,WAAb,CAArB;EACD;;EAED,IAAI,OAAO,UAAP,KAAsB,UAA1B,EAAsC;IACpC,OAAO,YAAY,IAAG;MACpB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAD,CAAzB;MACA,OAAO,cAAc,CAAC,MAAD,EAAS,WAAT,CAArB;IACD,CAHD;EAID;;EAED,OAAO;IAAE,QAAQ,EAAE;EAAZ,CAAP;AACD;;AAjBD,OAAA,CAAA,gBAAA,GAAA,gBAAA;;AAmBA,MAAM,cAAc,GAAG,CAAC,MAAD,EAAgC,WAAhC,KAAqE;;;EAC1F,IAAI,OAAO,MAAP,KAAkB,QAAtB,EAAgC;IAC9B,OAAO;MAAE,QAAQ,EAAE,MAAM,GAAG;IAArB,CAAP;EACD;;EAED,OAAO,EAAE,GAAG,MAAL;IAAa,QAAQ,EAAE,CAAC,CAAA,EAAA,GAAA,MAAM,CAAC,QAAP,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,EAAf,GAAmB,CAApB,IAAyB;EAAhD,CAAP;AACD,CAND","sourcesContent":["import type { Offset, OffsetObject } from '../types';\n\n/**\n * @internal\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n if (typeof userOffset === 'number') {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'object' && userOffset !== null) {\n return addArrowOffset(userOffset, arrowHeight);\n }\n\n if (typeof userOffset === 'function') {\n return offsetParams => {\n const offset = userOffset(offsetParams);\n return addArrowOffset(offset, arrowHeight);\n };\n }\n\n return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n if (typeof offset === 'number') {\n return { mainAxis: offset + arrowHeight };\n }\n\n return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parsePopperPlacement = void 0;
7
+ /**
8
+ * Parses Popper placement and returns the different components
9
+ * @param placement - the Popper.js placement (i.e. bottom-start)
10
+ *
11
+ * @returns side and alignment components of the placement
12
+ */
13
+
14
+ function parsePopperPlacement(placement) {
15
+ const tokens = placement.split('-');
16
+ return {
17
+ basePlacement: tokens[0],
18
+ alignment: tokens[1]
19
+ };
20
+ }
21
+
22
+ exports.parsePopperPlacement = parsePopperPlacement;
23
+ //# sourceMappingURL=parsePopperPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/parsePopperPlacement.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;AAKG;;AACH,SAAgB,oBAAhB,CAAqC,SAArC,EAAyD;EACvD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAV,CAAgB,GAAhB,CAAf;EACA,OAAO;IACL,aAAa,EAAE,MAAM,CAAC,CAAD,CADhB;IAEL,SAAS,EAAE,MAAM,CAAC,CAAD;EAFZ,CAAP;AAID;;AAND,OAAA,CAAA,oBAAA,GAAA,oBAAA","sourcesContent":["import type { BasePlacement, Placement, Variation } from '@popperjs/core';\n\n/**\n * Parses Popper placement and returns the different components\n * @param placement - the Popper.js placement (i.e. bottom-start)\n *\n * @returns side and alignment components of the placement\n */\nexport function parsePopperPlacement(placement: Placement): { basePlacement: BasePlacement; alignment: Variation } {\n const tokens = placement.split('-');\n return {\n basePlacement: tokens[0] as BasePlacement,\n alignment: tokens[1] as Variation,\n };\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/positioningHelper.ts"],"names":[],"mappings":";;;;;;;AAMA,MAAM,cAAc,GAAI,GAAD,KAAyD;AAC9E,EAAA,KAAK,EAAE,KADuE;AAE9E,EAAA,KAAK,EAAE,QAFuE;AAG9E,EAAA,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;AAI9E,EAAA,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;AAC7E,EAAA,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OADwD;AAE7E,EAAA,GAAG,EAAE,GAAG,GAAG,OAAH,GAAa,KAFwD;AAG7E,EAAA,GAAG,EAAE,OAHwE;AAI7E,EAAA,MAAM,EAAE,KAJqE;AAK7E,EAAA,MAAM,EAAE;AALqE,CAAvD,CAAxB;;AAQA,MAAM,mBAAmB,GAAG,CAAC,CAAD,EAAe,CAAf,KAAyC;AACnE,QAAM,oBAAoB,GAAG,CAAC,KAAK,OAAN,IAAiB,CAAC,KAAK,OAApD;AACA,QAAM,iBAAiB,GAAG,CAAC,KAAK,KAAN,IAAe,CAAC,KAAK,QAA/C;AAEA,SAAQ,oBAAoB,IAAI,iBAAzB,IAAgD,CAAC,oBAAD,IAAyB,CAAC,iBAAjF;AACD,CALD;AAOA;;AAEG;;;AACI,MAAM,YAAY,GAAG,CAAC,KAAD,EAAoB,QAApB,EAAyC,GAAzC,KAA8E;AACxG,QAAM,SAAS,GAAG,mBAAmB,CAAC,QAAD,EAAW,KAAX,CAAnB,GAAuC,QAAvC,GAAkD,KAApE;AAEA,QAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,GAAD,CAAd,CAAoB,QAApB,CAArC;AACA,QAAM,kBAAkB,GAAG,SAAS,IAAI,eAAe,CAAC,GAAD,CAAf,CAAqB,SAArB,CAAxC;;AAEA,MAAI,gBAAgB,IAAI,kBAAxB,EAA4C;AAC1C,WAAO,GAAG,gBAAgB,IAAI,kBAAkB,EAAhD;AACD;;AAED,SAAO,gBAAgB,IAAK,MAA5B;AACD,CAXM;;AAAM,OAAA,CAAA,YAAA,GAAY,YAAZ;;AAaN,MAAM,gBAAgB,GAAI,MAAD,IAAmD;AACjF,MAAI,OAAO,MAAP,KAAkB,WAAtB,EAAmC;AACjC,WAAO,SAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzB,IAAA,MAAM,CAAC,CAAD,CAAN,GAAY,MAAM,CAAC,CAAD,CAAN,GAAa,CAAC,CAA1B;AAEA,WAAO,MAAP;AACD;;AAED,SAAS,KAAD,IAAgC,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAAxC;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport type { Alignment, Offset, OffsetFunction, OffsetFunctionParam, Position } from '../types';\n\ntype PlacementPosition = 'top' | 'bottom' | 'left' | 'right';\ntype PlacementAlign = 'start' | 'end' | ''; // '' represents center\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\nconst getAlignmentMap = (rtl?: boolean): Record<Alignment, PlacementAlign> => ({\n start: rtl ? 'end' : 'start',\n end: rtl ? 'start' : 'end',\n top: 'start',\n bottom: 'end',\n center: '',\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * @see positioninHelper.test.ts for expected placement values\n */\nexport const getPlacement = (align?: Alignment, position?: Position, rtl?: boolean): PopperJs.Placement => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];\n\n if (computedPosition && computedAlignmnent) {\n return `${computedPosition}-${computedAlignmnent}` as PopperJs.Placement;\n }\n\n return computedPosition || ('auto' as PopperJs.Placement);\n};\n\nexport const applyRtlToOffset = (offset: Offset | undefined): Offset | undefined => {\n if (typeof offset === 'undefined') {\n return undefined;\n }\n\n if (Array.isArray(offset)) {\n offset[0] = offset[0]! * -1;\n\n return offset;\n }\n\n return ((param: OffsetFunctionParam) => applyRtlToOffset(offset(param))) as OffsetFunction;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/positioningHelper.ts"],"names":[],"mappings":";;;;;;;AAOA,MAAM,cAAc,GAAI,GAAD,KAAyD;EAC9E,KAAK,EAAE,KADuE;EAE9E,KAAK,EAAE,QAFuE;EAG9E,MAAM,EAAE,GAAG,GAAG,OAAH,GAAa,MAHsD;EAI9E,KAAK,EAAE,GAAG,GAAG,MAAH,GAAY;AAJwD,CAAzD,CAAvB;;AAOA,MAAM,eAAe,GAAI,GAAD,KAAuD;EAC7E,KAAK,EAAE,GAAG,GAAG,KAAH,GAAW,OAD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AS,KAAD,IAAsC,OAAA,CAAA,gBAAA,CAAiB,MAAM,CAAC,KAAD,CAAvB,CAA9C;AACD,CAZM;;AAAM,OAAA,CAAA,gBAAA,GAAgB,gBAAhB","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport type { Alignment, Position } from '../types';\nimport { PopperOffset, PopperOffsetFunction, PopperOffsetFunctionParam } from './getPopperOffset';\n\ntype PlacementPosition = 'top' | 'bottom' | 'left' | 'right';\ntype PlacementAlign = 'start' | 'end' | ''; // '' represents center\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\nconst getAlignmentMap = (rtl?: boolean): Record<Alignment, PlacementAlign> => ({\n start: rtl ? 'end' : 'start',\n end: rtl ? 'start' : 'end',\n top: 'start',\n bottom: 'end',\n center: '',\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * @see positioninHelper.test.ts for expected placement values\n */\nexport const getPlacement = (align?: Alignment, position?: Position, rtl?: boolean): PopperJs.Placement => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignmnent = alignment && getAlignmentMap(rtl)[alignment];\n\n if (computedPosition && computedAlignmnent) {\n return `${computedPosition}-${computedAlignmnent}` as PopperJs.Placement;\n }\n\n return computedPosition || ('auto' as PopperJs.Placement);\n};\n\nexport const applyRtlToOffset = (offset: PopperOffset | undefined): PopperOffset | undefined => {\n if (typeof offset === 'undefined') {\n return undefined;\n }\n\n if (Array.isArray(offset)) {\n offset[0] = offset[0]! * -1;\n\n return offset;\n }\n\n return ((param: PopperOffsetFunctionParam) => applyRtlToOffset(offset(param))) as PopperOffsetFunction;\n};\n"],"sourceRoot":"../src/"}