@fluentui/react-positioning 9.3.5 → 9.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/CHANGELOG.json +69 -1
  2. package/CHANGELOG.md +24 -2
  3. package/lib/createArrowStyles.js +0 -2
  4. package/lib/createArrowStyles.js.map +1 -1
  5. package/lib/createPositionManager.js +8 -17
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js +0 -2
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/middleware/coverTarget.js +0 -5
  10. package/lib/middleware/coverTarget.js.map +1 -1
  11. package/lib/middleware/flip.js +2 -1
  12. package/lib/middleware/flip.js.map +1 -1
  13. package/lib/middleware/intersecting.js.map +1 -1
  14. package/lib/middleware/maxSize.js +31 -38
  15. package/lib/middleware/maxSize.js.map +1 -1
  16. package/lib/middleware/offset.js +0 -1
  17. package/lib/middleware/offset.js.map +1 -1
  18. package/lib/middleware/shift.js +2 -2
  19. package/lib/middleware/shift.js.map +1 -1
  20. package/lib/usePositioning.js +19 -28
  21. package/lib/usePositioning.js.map +1 -1
  22. package/lib/usePositioningMouseTarget.js +0 -7
  23. package/lib/usePositioningMouseTarget.js.map +1 -1
  24. package/lib/utils/debounce.js +0 -1
  25. package/lib/utils/debounce.js.map +1 -1
  26. package/lib/utils/fromFloatingUIPlacement.js +2 -7
  27. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  28. package/lib/utils/getBoundary.js +0 -6
  29. package/lib/utils/getBoundary.js.map +1 -1
  30. package/lib/utils/getFloatingUIOffset.js +0 -3
  31. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  32. package/lib/utils/getReactFiberFromNode.js +0 -4
  33. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  34. package/lib/utils/getScrollParent.js +6 -18
  35. package/lib/utils/getScrollParent.js.map +1 -1
  36. package/lib/utils/hasAutoFocusFilter.js +2 -7
  37. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  38. package/lib/utils/mergeArrowOffset.js +2 -7
  39. package/lib/utils/mergeArrowOffset.js.map +1 -1
  40. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  41. package/lib/utils/resolvePositioningShorthand.js +0 -2
  42. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  43. package/lib/utils/toFloatingUIPlacement.js +2 -8
  44. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  45. package/lib/utils/toggleScrollListener.js +0 -3
  46. package/lib/utils/toggleScrollListener.js.map +1 -1
  47. package/lib/utils/useCallbackRef.js +2 -8
  48. package/lib/utils/useCallbackRef.js.map +1 -1
  49. package/lib/utils/writeArrowUpdates.js +0 -2
  50. package/lib/utils/writeArrowUpdates.js.map +1 -1
  51. package/lib/utils/writeContainerupdates.js +0 -10
  52. package/lib/utils/writeContainerupdates.js.map +1 -1
  53. package/lib-amd/createPositionManager.js +3 -0
  54. package/lib-amd/createPositionManager.js.map +1 -1
  55. package/lib-amd/middleware/maxSize.js +24 -36
  56. package/lib-amd/middleware/maxSize.js.map +1 -1
  57. package/lib-amd/usePositioning.js +3 -3
  58. package/lib-amd/usePositioning.js.map +1 -1
  59. package/lib-commonjs/constants.js.map +1 -1
  60. package/lib-commonjs/createArrowStyles.js +0 -7
  61. package/lib-commonjs/createArrowStyles.js.map +1 -1
  62. package/lib-commonjs/createPositionManager.js +8 -21
  63. package/lib-commonjs/createPositionManager.js.map +1 -1
  64. package/lib-commonjs/createVirtualElementFromClick.js +0 -4
  65. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  66. package/lib-commonjs/index.js +0 -10
  67. package/lib-commonjs/index.js.map +1 -1
  68. package/lib-commonjs/middleware/coverTarget.js +0 -8
  69. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  70. package/lib-commonjs/middleware/flip.js +2 -5
  71. package/lib-commonjs/middleware/flip.js.map +1 -1
  72. package/lib-commonjs/middleware/index.js +0 -7
  73. package/lib-commonjs/middleware/index.js.map +1 -1
  74. package/lib-commonjs/middleware/intersecting.js +0 -3
  75. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  76. package/lib-commonjs/middleware/maxSize.js +30 -41
  77. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  78. package/lib-commonjs/middleware/offset.js +0 -5
  79. package/lib-commonjs/middleware/offset.js.map +1 -1
  80. package/lib-commonjs/middleware/shift.js +2 -6
  81. package/lib-commonjs/middleware/shift.js.map +1 -1
  82. package/lib-commonjs/types.js.map +1 -1
  83. package/lib-commonjs/usePositioning.js +18 -36
  84. package/lib-commonjs/usePositioning.js.map +1 -1
  85. package/lib-commonjs/usePositioningMouseTarget.js +0 -11
  86. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  87. package/lib-commonjs/utils/debounce.js +0 -3
  88. package/lib-commonjs/utils/debounce.js.map +1 -1
  89. package/lib-commonjs/utils/fromFloatingUIPlacement.js +2 -9
  90. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  91. package/lib-commonjs/utils/getBoundary.js +0 -9
  92. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  93. package/lib-commonjs/utils/getFloatingUIOffset.js +0 -6
  94. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  95. package/lib-commonjs/utils/getReactFiberFromNode.js +0 -5
  96. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  97. package/lib-commonjs/utils/getScrollParent.js +6 -23
  98. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  99. package/lib-commonjs/utils/hasAutoFocusFilter.js +5 -12
  100. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  101. package/lib-commonjs/utils/index.js +0 -15
  102. package/lib-commonjs/utils/index.js.map +1 -1
  103. package/lib-commonjs/utils/mergeArrowOffset.js +2 -9
  104. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  105. package/lib-commonjs/utils/parseFloatingUIPlacement.js +0 -2
  106. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  107. package/lib-commonjs/utils/resolvePositioningShorthand.js +2 -6
  108. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  109. package/lib-commonjs/utils/toFloatingUIPlacement.js +2 -10
  110. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  111. package/lib-commonjs/utils/toggleScrollListener.js +0 -6
  112. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  113. package/lib-commonjs/utils/useCallbackRef.js +2 -12
  114. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  115. package/lib-commonjs/utils/writeArrowUpdates.js +0 -4
  116. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  117. package/lib-commonjs/utils/writeContainerupdates.js +0 -13
  118. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  119. package/package.json +4 -4
@@ -1,6 +1,6 @@
1
1
  import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';
2
2
  import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
- import { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
3
+ import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
4
4
  import * as React from 'react';
5
5
  import { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';
6
6
  import { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';
@@ -8,7 +8,6 @@ import { createPositionManager } from './createPositionManager';
8
8
  /**
9
9
  * @internal
10
10
  */
11
-
12
11
  export function usePositioning(options) {
13
12
  const managerRef = React.useRef(null);
14
13
  const targetRef = React.useRef(null);
@@ -21,14 +20,11 @@ export function usePositioning(options) {
21
20
  const resolvePositioningOptions = usePositioningOptions(options);
22
21
  const updatePositionManager = React.useCallback(() => {
23
22
  var _a;
24
-
25
23
  if (managerRef.current) {
26
24
  managerRef.current.dispose();
27
25
  }
28
-
29
26
  managerRef.current = null;
30
27
  const target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
31
-
32
28
  if (enabled && canUseDOM() && target && containerRef.current) {
33
29
  managerRef.current = createPositionManager({
34
30
  container: containerRef.current,
@@ -38,63 +34,56 @@ export function usePositioning(options) {
38
34
  });
39
35
  }
40
36
  }, [enabled, resolvePositioningOptions]);
41
- const setOverrideTarget = React.useCallback(target => {
37
+ const setOverrideTarget = useEventCallback(target => {
42
38
  overrideTargetRef.current = target;
43
39
  updatePositionManager();
44
- }, [updatePositionManager]);
40
+ });
45
41
  React.useImperativeHandle(options.positioningRef, () => ({
46
42
  updatePosition: () => {
47
43
  var _a;
48
-
49
44
  return (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
50
45
  },
51
46
  setTarget: target => {
52
47
  if (options.target && process.env.NODE_ENV !== 'production') {
53
- const err = new Error(); // eslint-disable-next-line no-console
54
-
55
- console.warn('Imperative setTarget should not be used at the same time as target option'); // eslint-disable-next-line no-console
56
-
48
+ const err = new Error();
49
+ // eslint-disable-next-line no-console
50
+ console.warn('Imperative setTarget should not be used at the same time as target option');
51
+ // eslint-disable-next-line no-console
57
52
  console.warn(err.stack);
58
53
  }
59
-
60
54
  setOverrideTarget(target);
61
55
  }
62
56
  }), [options.target, setOverrideTarget]);
63
57
  useIsomorphicLayoutEffect(() => {
64
58
  var _a;
65
-
66
59
  setOverrideTarget((_a = options.target) !== null && _a !== void 0 ? _a : null);
67
60
  }, [options.target, setOverrideTarget]);
68
61
  useIsomorphicLayoutEffect(() => {
69
62
  updatePositionManager();
70
63
  }, [updatePositionManager]);
71
-
72
64
  if (process.env.NODE_ENV !== 'production') {
73
65
  // This checked should run only in development mode
74
66
  // eslint-disable-next-line react-hooks/rules-of-hooks
75
67
  React.useEffect(() => {
76
68
  var _a;
77
-
78
69
  if (containerRef.current) {
79
70
  const contentNode = containerRef.current;
80
71
  const treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
81
72
  acceptNode: hasAutofocusFilter
82
73
  });
83
-
84
74
  while (treeWalker.nextNode()) {
85
- const node = treeWalker.currentNode; // eslint-disable-next-line no-console
86
-
87
- console.warn('<Popper>:', node); // eslint-disable-next-line no-console
88
-
75
+ const node = treeWalker.currentNode;
76
+ // eslint-disable-next-line no-console
77
+ console.warn('<Popper>:', node);
78
+ // eslint-disable-next-line no-console
89
79
  console.warn(['<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial', 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills', '"autoFocus" behavior to solve inconsistencies between different browsers:', 'https://github.com/facebook/react/issues/11851#issuecomment-351787078', '\n', 'However, ".focus()" in this case occurs before any other React effects will be executed', '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really', 'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by', '"Popper".', `In general, it's not recommended to use "autoFocus" as it may break accessibility aspects:`, 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md', '\n', 'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use', '"ref.current.focus" in React.useEffect():', 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'].join(' '));
90
80
  }
91
- } // We run this check once, no need to add deps here
81
+ }
82
+ // We run this check once, no need to add deps here
92
83
  // TODO: Should be rework to handle options.enabled and contentRef updates
93
84
  // eslint-disable-next-line react-hooks/exhaustive-deps
94
-
95
85
  }, []);
96
86
  }
97
-
98
87
  const setTarget = useCallbackRef(null, target => {
99
88
  if (targetRef.current !== target) {
100
89
  targetRef.current = target;
@@ -112,15 +101,14 @@ export function usePositioning(options) {
112
101
  arrowRef.current = arrow;
113
102
  updatePositionManager();
114
103
  }
115
- }); // Let users use callback refs so they feel like 'normal' DOM refs
116
-
104
+ });
105
+ // Let users use callback refs so they feel like 'normal' DOM refs
117
106
  return {
118
107
  targetRef: setTarget,
119
108
  containerRef: setContainer,
120
109
  arrowRef: setArrow
121
110
  };
122
111
  }
123
-
124
112
  function usePositioningOptions(options) {
125
113
  const {
126
114
  align,
@@ -152,7 +140,10 @@ function usePositioningOptions(options) {
152
140
  hasScrollableElement,
153
141
  overflowBoundary,
154
142
  disableTether
155
- }), autoSize && maxSizeMiddleware(autoSize), intersectingMiddleware(), arrow && arrowMiddleware({
143
+ }), autoSize && maxSizeMiddleware(autoSize, {
144
+ container,
145
+ overflowBoundary
146
+ }), intersectingMiddleware(), arrow && arrowMiddleware({
156
147
  element: arrow,
157
148
  padding: arrowPadding
158
149
  }), hideMiddleware({
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/usePositioning.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,IAAI,cAAjB,EAAiC,KAAK,IAAI,eAA1C,QAAiE,kBAAjE;AAEA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,SAAT,EAAoB,yBAApB,QAAqD,2BAArD;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAQA,SAAS,cAAT,EAAyB,qBAAzB,EAAgD,kBAAhD,EAAoE,eAApE,QAA2F,SAA3F;AACA,SACE,KAAK,IAAI,eADX,EAEE,IAAI,IAAI,cAFV,EAGE,WAAW,IAAI,qBAHjB,EAIE,OAAO,IAAI,iBAJb,EAKE,MAAM,IAAI,gBALZ,EAME,YAAY,IAAI,sBANlB,QAOO,cAPP;AAQA,SAAS,qBAAT,QAAsC,yBAAtC;AAEA;;AAEG;;AACH,OAAM,SAAU,cAAV,CAAyB,OAAzB,EAAuD;EAC3D,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAqC,IAArC,CAAnB;EACA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAAlB;EACA,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAA1B;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BL,CACE,KADF,EAEE,YAFF,EAGE,QAHF,EAIE,WAJF,EAKE,aALF,EAME,YANF,EAOE,KAPF,EAQE,MARF,EASE,gBATF,EAUE,MAVF,EAWE,QAXF,EAYE,QAZF,CAvBK,CAAP;AAsCD","sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = React.useCallback(\n (target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n },\n [updatePositionManager],\n );\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\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 setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\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 const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAAA,SAASA,IAAI,IAAIC,cAAc,EAAEC,KAAK,IAAIC,eAAe,QAAQ,kBAAkB;AAEnF,SAASC,kBAAkB,IAAIC,SAAS,QAAQ,iCAAiC;AACjF,SAASC,SAAS,EAAEC,gBAAgB,EAAEC,yBAAyB,QAAQ,2BAA2B;AAClG,OAAO,KAAKC,KAAK,MAAM,OAAO;AAQ9B,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ,SAAS;AACpG,SACEC,KAAK,IAAIC,eAAe,EACxBC,IAAI,IAAIC,cAAc,EACtBC,WAAW,IAAIC,qBAAqB,EACpCC,OAAO,IAAIC,iBAAiB,EAC5BC,MAAM,IAAIC,gBAAgB,EAC1BC,YAAY,IAAIC,sBAAsB,QACjC,cAAc;AACrB,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;;AAGA,OAAM,SAAUC,cAAc,CAACC,OAA8B;EAC3D,MAAMC,UAAU,GAAGpB,KAAK,CAACqB,MAAM,CAAyB,IAAI,CAAC;EAC7D,MAAMC,SAAS,GAAGtB,KAAK,CAACqB,MAAM,CAAuB,IAAI,CAAC;EAC1D,MAAME,iBAAiB,GAAGvB,KAAK,CAACqB,MAAM,CAAuB,IAAI,CAAC;EAClE,MAAMG,YAAY,GAAGxB,KAAK,CAACqB,MAAM,CAAqB,IAAI,CAAC;EAC3D,MAAMI,QAAQ,GAAGzB,KAAK,CAACqB,MAAM,CAAqB,IAAI,CAAC;EAEvD,MAAM;IAAEK,OAAO,GAAG;EAAI,CAAE,GAAGP,OAAO;EAClC,MAAMQ,yBAAyB,GA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vD,MAAM0C,SAAS,GAAG1E,qBAAqB,CAAC4D,KAAK,EAAEM,QAAQ,EAAEK,KAAK,CAAC;IAC/D,MAAMI,UAAU,GAAG,CACjBhE,MAAM,IAAIC,gBAAgB,CAACD,MAAM,CAAC,EAClCJ,WAAW,IAAIC,qBAAqB,EAAE,EACtC,CAACyD,MAAM,IAAI3D,cAAc,CAAC;MAAE0B,SAAS;MAAE+B,YAAY;MAAEU;IAAoB,CAAE,CAAC,EAC5ErE,eAAe,CAAC;MAAE4B,SAAS;MAAEyC,oBAAoB;MAAET,gBAAgB;MAAEI;IAAa,CAAE,CAAC,EACrFN,QAAQ,IAAIpD,iBAAiB,CAACoD,QAAQ,EAAE;MAAE9B,SAAS;MAAEgC;IAAgB,CAAE,CAAC,EACxElD,sBAAsB,EAAE,EACxBvB,KAAK,IAAIC,eAAe,CAAC;MAAEoF,OAAO,EAAErF,KAAK;MAAEsF,OAAO,EAAEhB;IAAY,CAAE,CAAC,EACnEvE,cAAc,CAAC;MAAEkF,QAAQ,EAAE;IAAiB,CAAE,CAAC,EAC/ClF,cAAc,CAAC;MAAEkF,QAAQ,EAAE;IAAS,CAAE,CAAC,CACxC,CAACM,MAAM,CAACC,OAAO,CAAiB;IAEjC,OAAO;MACLL,SAAS;MACTC,UAAU;MACVH;KACD;EACH,CAAC,EACD,CACEZ,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRvD,WAAW,EACX6D,aAAa,EACbL,YAAY,EACZQ,KAAK,EACL5D,MAAM,EACNqD,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRM,QAAQ,CACT,CACF;AACH","names":["hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","useCallbackRef","toFloatingUIPlacement","hasAutofocusFilter","hasScrollParent","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","createPositionManager","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","container","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","nextNode","node","currentNode","join","setContainer","setArrow","align","arrowPadding","autoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","dir","isRtl","strategy","hasScrollableElement","placement","middleware","element","padding","filter","Boolean"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/usePositioning.ts"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\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 setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\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 const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n"]}
@@ -9,33 +9,26 @@ import { createVirtualElementFromClick } from './createVirtualElementFromClick';
9
9
  * @param initialState - initializes a user provided state similare to useState
10
10
  * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
11
11
  */
12
-
13
12
  export const usePositioningMouseTarget = initialState => {
14
13
  const [virtualElement, setVirtualElement] = React.useState(initialState);
15
-
16
14
  const setVirtualMouseTarget = event => {
17
15
  if (event === undefined || event === null) {
18
16
  setVirtualElement(undefined);
19
17
  return;
20
18
  }
21
-
22
19
  let mouseevent;
23
-
24
20
  if (!(event instanceof MouseEvent)) {
25
21
  mouseevent = event.nativeEvent;
26
22
  } else {
27
23
  mouseevent = event;
28
24
  }
29
-
30
25
  if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
31
26
  // eslint-disable-next-line no-console
32
27
  console.error('usePositioningMouseTarget should only be used with MouseEvent');
33
28
  }
34
-
35
29
  const contextTarget = createVirtualElementFromClick(mouseevent);
36
30
  setVirtualElement(contextTarget);
37
31
  };
38
-
39
32
  return [virtualElement, setVirtualMouseTarget];
40
33
  };
41
34
  //# sourceMappingURL=usePositioningMouseTarget.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/usePositioningMouseTarget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,6BAAT,QAA8C,iCAA9C;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,yBAAyB,GACpC,YADuC,IAErC;EACF,MAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAsD,YAAtD,CAA5C;;EAEA,MAAM,qBAAqB,GAA0B,KAAK,IAAG;IAC3D,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,6BAA6B,CAAC,UAAD,CAAnD;IACA,iBAAiB,CAAC,aAAD,CAAjB;EACD,CApBD;;EAsBA,OAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA5BM","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } 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: SetVirtualMouseTarget = event => {\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/"}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,6BAA6B,QAAQ,iCAAiC;AAG/E;;;;;;;;;AASA,OAAO,MAAMC,yBAAyB,GACpCC,YAA4E,IAC1E;EACF,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGL,KAAK,CAACM,QAAQ,CAAwCH,YAAY,CAAC;EAE/G,MAAMI,qBAAqB,GAA0BC,KAAK,IAAG;IAC3D,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;MACzCH,iBAAiB,CAACI,SAAS,CAAC;MAC5B;;IAGF,IAAIC,UAAsB;IAC1B,IAAI,EAAEF,KAAK,YAAYG,UAAU,CAAC,EAAE;MAClCD,UAAU,GAAGF,KAAK,CAACI,WAAW;KAC/B,MAAM;MACLF,UAAU,GAAGF,KAAK;;IAGpB,IAAI,EAAEE,UAAU,YAAYC,UAAU,CAAC,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MAChF;MACAC,OAAO,CAACC,KAAK,CAAC,+DAA+D,CAAC;;IAGhF,MAAMC,aAAa,GAAGjB,6BAA6B,CAACS,UAAU,CAAC;IAC/DL,iBAAiB,CAACa,aAAa,CAAC;EAClC,CAAC;EAED,OAAO,CAACd,cAAc,EAAEG,qBAAqB,CAAU;AACzD,CAAC","names":["React","createVirtualElementFromClick","usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/usePositioningMouseTarget.ts"],"sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } 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: SetVirtualMouseTarget = event => {\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"]}
@@ -15,7 +15,6 @@ export function debounce(fn) {
15
15
  });
16
16
  });
17
17
  }
18
-
19
18
  return pending;
20
19
  };
21
20
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/utils/debounce.ts"],"names":[],"mappings":"AAAA;;;;;AAKG;AACH,OAAM,SAAU,QAAV,CAAsB,EAAtB,EAAkC;EACtC,IAAI,OAAJ;EACA,OAAO,MAAK;IACV,IAAI,CAAC,OAAL,EAAc;MACZ,OAAO,GAAG,IAAI,OAAJ,CAAe,OAAO,IAAG;QACjC,OAAO,CAAC,OAAR,GAAkB,IAAlB,CAAuB,MAAK;UAC1B,OAAO,GAAG,SAAV;UACA,OAAO,CAAC,EAAE,EAAH,CAAP;QACD,CAHD;MAID,CALS,CAAV;IAMD;;IAED,OAAO,OAAP;EACD,CAXD;AAYD","sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAAA;;;;;;AAMA,OAAM,SAAUA,QAAQ,CAAIC,EAAY;EACtC,IAAIC,OAA+B;EACnC,OAAO,MAAK;IACV,IAAI,CAACA,OAAO,EAAE;MACZA,OAAO,GAAG,IAAIC,OAAO,CAAIC,OAAO,IAAG;QACjCD,OAAO,CAACC,OAAO,EAAE,CAACC,IAAI,CAAC,MAAK;UAC1BH,OAAO,GAAGI,SAAS;UACnBF,OAAO,CAACH,EAAE,EAAE,CAAC;QACf,CAAC,CAAC;MACJ,CAAC,CAAC;;IAGJ,OAAOC,OAAO;EAChB,CAAC;AACH","names":["debounce","fn","pending","Promise","resolve","then","undefined"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/debounce.ts"],"sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"]}
@@ -1,14 +1,12 @@
1
1
  import { parseFloatingUIPlacement } from './parseFloatingUIPlacement';
2
-
3
2
  const getPositionMap = () => ({
4
3
  top: 'above',
5
4
  bottom: 'below',
6
5
  right: 'after',
7
6
  left: 'before'
8
- }); // Floating UI automatically flips alignment
7
+ });
8
+ // Floating UI automatically flips alignment
9
9
  // https://github.com/floating-ui/floating-ui/issues/1563
10
-
11
-
12
10
  const getAlignmentMap = position => {
13
11
  if (position === 'above' || position === 'below') {
14
12
  return {
@@ -16,7 +14,6 @@ const getAlignmentMap = position => {
16
14
  end: 'end'
17
15
  };
18
16
  }
19
-
20
17
  return {
21
18
  start: 'top',
22
19
  end: 'bottom'
@@ -26,8 +23,6 @@ const getAlignmentMap = position => {
26
23
  * Maps Floating UI placement to positioning values
27
24
  * @see positioningHelper.test.ts for expected placement values
28
25
  */
29
-
30
-
31
26
  export const fromFloatingUIPlacement = placement => {
32
27
  const {
33
28
  side,
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/utils/fromFloatingUIPlacement.ts"],"names":[],"mappings":"AAEA,SAAS,wBAAT,QAAyC,4BAAzC;;AAEA,MAAM,cAAc,GAAG,OAA+B;EACpD,GAAG,EAAE,OAD+C;EAEpD,MAAM,EAAE,OAF4C;EAGpD,KAAK,EAAE,OAH6C;EAIpD,IAAI,EAAE;AAJ8C,CAA/B,CAAvB,C,CAOA;AACA;;;AACA,MAAM,eAAe,GAAI,QAAD,IAA+D;EACrF,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;;;AACH,OAAO,MAAM,uBAAuB,GAAI,SAAD,IAAwE;EAC7G,MAAM;IAAE,IAAF;IAAQ,SAAS,EAAE;EAAnB,IAA2C,wBAAwB,CAAC,SAAD,CAAzE;EACA,MAAM,QAAQ,GAAG,cAAc,GAAG,IAAH,CAA/B;EACA,MAAM,SAAS,GAAG,mBAAmB,IAAI,eAAe,CAAC,QAAD,CAAf,CAA0B,mBAA1B,CAAzC;EAEA,OAAO;IAAE,QAAF;IAAY;EAAZ,CAAP;AACD,CANM","sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, 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 Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAEA,SAASA,wBAAwB,QAAQ,4BAA4B;AAErE,MAAMC,cAAc,GAAG,OAA+B;EACpDC,GAAG,EAAE,OAAO;EACZC,MAAM,EAAE,OAAO;EACfC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE;CACP,CAAC;AAEF;AACA;AACA,MAAMC,eAAe,GAAIC,QAAkB,IAA4C;EACrF,IAAIA,QAAQ,KAAK,OAAO,IAAIA,QAAQ,KAAK,OAAO,EAAE;IAChD,OAAO;MACLC,KAAK,EAAE,OAAO;MACdC,GAAG,EAAE;KACN;;EAGH,OAAO;IACLD,KAAK,EAAE,KAAK;IACZC,GAAG,EAAE;GACN;AACH,CAAC;AAED;;;;AAIA,OAAO,MAAMC,uBAAuB,GAAIC,SAAoB,IAAmD;EAC7G,MAAM;IAAEC,IAAI;IAAEC,SAAS,EAAEC;EAAmB,CAAE,GAAGd,wBAAwB,CAACW,SAAS,CAAC;EACpF,MAAMJ,QAAQ,GAAGN,cAAc,EAAE,CAACW,IAAI,CAAC;EACvC,MAAMC,SAAS,GAAGC,mBAAmB,IAAIR,eAAe,CAACC,QAAQ,CAAC,CAACO,mBAAmB,CAAC;EAEvF,OAAO;IAAEP,QAAQ;IAAEM;EAAS,CAAE;AAChC,CAAC","names":["parseFloatingUIPlacement","getPositionMap","top","bottom","right","left","getAlignmentMap","position","start","end","fromFloatingUIPlacement","placement","side","alignment","floatingUIAlignment"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/fromFloatingUIPlacement.ts"],"sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, 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 Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"]}
@@ -2,26 +2,20 @@ import { getScrollParent } from './getScrollParent';
2
2
  /**
3
3
  * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
4
4
  */
5
-
6
5
  export function getBoundary(element, boundary) {
7
6
  if (boundary === 'window') {
8
7
  return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
9
8
  }
10
-
11
9
  if (boundary === 'clippingParents') {
12
10
  return 'clippingAncestors';
13
11
  }
14
-
15
12
  if (boundary === 'scrollParent') {
16
13
  let boundariesNode = getScrollParent(element);
17
-
18
14
  if (boundariesNode.nodeName === 'BODY') {
19
15
  boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
20
16
  }
21
-
22
17
  return boundariesNode;
23
18
  }
24
-
25
19
  return boundary;
26
20
  }
27
21
  //# sourceMappingURL=getBoundary.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/utils/getBoundary.ts"],"names":[],"mappings":"AAEA,SAAS,eAAT,QAAgC,mBAAhC;AAGA;;AAEG;;AACH,OAAM,SAAU,WAAV,CAAsB,OAAtB,EAAmD,QAAnD,EAAsE;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,iBAAjB,EAAoC;IAClC,OAAO,mBAAP;EACD;;EAED,IAAI,QAAQ,KAAK,cAAjB,EAAiC;IAC/B,IAAI,cAAc,GAA4B,eAAe,CAAC,OAAD,CAA7D;;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","sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\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): FloatingUIBoundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'clippingParents') {\n return 'clippingAncestors';\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,"mappings":"AAEA,SAASA,eAAe,QAAQ,mBAAmB;AAGnD;;;AAGA,OAAM,SAAUC,WAAW,CAACC,OAA2B,EAAEC,QAAmB;EAC1E,IAAIA,QAAQ,KAAK,QAAQ,EAAE;IACzB,OAAOD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,aAAa,CAAEC,eAAe;;EAGhD,IAAIF,QAAQ,KAAK,iBAAiB,EAAE;IAClC,OAAO,mBAAmB;;EAG5B,IAAIA,QAAQ,KAAK,cAAc,EAAE;IAC/B,IAAIG,cAAc,GAA4BN,eAAe,CAACE,OAAO,CAAC;IAEtE,IAAII,cAAc,CAACC,QAAQ,KAAK,MAAM,EAAE;MACtCD,cAAc,GAAGJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,aAAa,CAAEC,eAAe;;IAG1D,OAAOC,cAAc;;EAGvB,OAAOH,QAAQ;AACjB","names":["getScrollParent","getBoundary","element","boundary","ownerDocument","documentElement","boundariesNode","nodeName"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\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): FloatingUIBoundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'clippingParents') {\n return 'clippingAncestors';\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"]}
@@ -4,16 +4,13 @@ import { fromFloatingUIPlacement } from './fromFloatingUIPlacement';
4
4
  * @param rawOffset Offset from this library
5
5
  * @returns An offset value compatible with Floating UI
6
6
  */
7
-
8
7
  export function getFloatingUIOffset(rawOffset) {
9
8
  if (!rawOffset) {
10
9
  return rawOffset;
11
10
  }
12
-
13
11
  if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {
14
12
  return rawOffset;
15
13
  }
16
-
17
14
  return ({
18
15
  rects: {
19
16
  floating,
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/utils/getFloatingUIOffset.ts"],"names":[],"mappings":"AAEA,SAAS,uBAAT,QAAwC,2BAAxC;AAgCA;;;;AAIG;;AACH,OAAM,SAAU,mBAAV,CACJ,SADI,EACyB;EAE7B,IAAI,CAAC,SAAL,EAAgB;IACd,OAAO,SAAP;EACD;;EAED,IAAI,OAAO,SAAP,KAAqB,QAArB,IAAiC,OAAO,SAAP,KAAqB,QAA1D,EAAoE;IAClE,OAAO,SAAP;EACD;;EAED,OAAO,CAAC;IAAE,KAAK,EAAE;MAAE,QAAF;MAAY;IAAZ,CAAT;IAAkC;EAAlC,CAAD,KAAkD;IACvD,MAAM;MAAE,QAAF;MAAY;IAAZ,IAA0B,uBAAuB,CAAC,SAAD,CAAvD;IACA,OAAO,SAAS,CAAC;MAAE,cAAc,EAAE,QAAlB;MAA4B,UAAU,EAAE,SAAxC;MAAmD,QAAnD;MAA6D;IAA7D,CAAD,CAAhB;EACD,CAHD;AAID","sourcesContent":["import type { Offset } from '../types';\nimport type { MiddlewareArguments } from '@floating-ui/dom';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetValue =\n | number\n | {\n /**\n * The axis that runs along the side of the floating element.\n * @default 0\n */\n mainAxis?: number;\n /**\n * The axis that runs along the alignment of the floating element.\n * @default 0\n */\n crossAxis?: number;\n /**\n * When set to a number, overrides the `crossAxis` value for aligned\n * (non-centered/base) placements and works logically. A positive number\n * will move the floating element in the direction of the opposite edge\n * to the one that is aligned, while a negative number the reverse.\n * @default null\n */\n alignmentAxis?: number | null;\n };\n\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetFunction = (args: MiddlewareArguments) => FloatingUIOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Floating UI\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Floating UI\n */\nexport function getFloatingUIOffset(\n rawOffset: Offset | undefined,\n): FloatingUIOffsetValue | FloatingUIOffsetFunction | undefined {\n if (!rawOffset) {\n return rawOffset;\n }\n\n if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {\n return rawOffset;\n }\n\n return ({ rects: { floating, reference }, placement }) => {\n const { position, alignment } = fromFloatingUIPlacement(placement);\n return rawOffset({ positionedRect: floating, targetRect: reference, position, alignment });\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAEA,SAASA,uBAAuB,QAAQ,2BAA2B;AAgCnE;;;;;AAKA,OAAM,SAAUC,mBAAmB,CACjCC,SAA6B;EAE7B,IAAI,CAACA,SAAS,EAAE;IACd,OAAOA,SAAS;;EAGlB,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IAClE,OAAOA,SAAS;;EAGlB,OAAO,CAAC;IAAEC,KAAK,EAAE;MAAEC,QAAQ;MAAEC;IAAS,CAAE;IAAEC;EAAS,CAAE,KAAI;IACvD,MAAM;MAAEC,QAAQ;MAAEC;IAAS,CAAE,GAAGR,uBAAuB,CAACM,SAAS,CAAC;IAClE,OAAOJ,SAAS,CAAC;MAAEO,cAAc,EAAEL,QAAQ;MAAEM,UAAU,EAAEL,SAAS;MAAEE,QAAQ;MAAEC;IAAS,CAAE,CAAC;EAC5F,CAAC;AACH","names":["fromFloatingUIPlacement","getFloatingUIOffset","rawOffset","rects","floating","reference","placement","position","alignment","positionedRect","targetRect"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/getFloatingUIOffset.ts"],"sourcesContent":["import type { Offset } from '../types';\nimport type { MiddlewareArguments } from '@floating-ui/dom';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetValue =\n | number\n | {\n /**\n * The axis that runs along the side of the floating element.\n * @default 0\n */\n mainAxis?: number;\n /**\n * The axis that runs along the alignment of the floating element.\n * @default 0\n */\n crossAxis?: number;\n /**\n * When set to a number, overrides the `crossAxis` value for aligned\n * (non-centered/base) placements and works logically. A positive number\n * will move the floating element in the direction of the opposite edge\n * to the one that is aligned, while a negative number the reverse.\n * @default null\n */\n alignmentAxis?: number | null;\n };\n\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetFunction = (args: MiddlewareArguments) => FloatingUIOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Floating UI\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Floating UI\n */\nexport function getFloatingUIOffset(\n rawOffset: Offset | undefined,\n): FloatingUIOffsetValue | FloatingUIOffsetFunction | undefined {\n if (!rawOffset) {\n return rawOffset;\n }\n\n if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {\n return rawOffset;\n }\n\n return ({ rects: { floating, reference }, placement }) => {\n const { position, alignment } = fromFloatingUIPlacement(placement);\n return rawOffset({ positionedRect: floating, targetRect: reference, position, alignment });\n };\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  var WorkTag;
2
-
3
2
  (function (WorkTag) {
4
3
  WorkTag[WorkTag["FunctionComponent"] = 0] = "FunctionComponent";
5
4
  WorkTag[WorkTag["ClassComponent"] = 1] = "ClassComponent";
@@ -24,12 +23,10 @@ var WorkTag;
24
23
  WorkTag[WorkTag["FundamentalComponent"] = 20] = "FundamentalComponent";
25
24
  WorkTag[WorkTag["ScopeComponent"] = 21] = "ScopeComponent";
26
25
  })(WorkTag || (WorkTag = {}));
27
-
28
26
  export function getReactFiberFromNode(elm) {
29
27
  if (!elm) {
30
28
  return null;
31
29
  }
32
-
33
30
  for (const k in elm) {
34
31
  // React 16 uses "__reactInternalInstance$" prefix
35
32
  // React 17 uses "__reactFiber$" prefix
@@ -40,7 +37,6 @@ export function getReactFiberFromNode(elm) {
40
37
  return elm[k];
41
38
  }
42
39
  }
43
-
44
40
  throw new Error('getReactFiber(): Failed to find a React Fiber on a node');
45
41
  }
46
42
  //# sourceMappingURL=getReactFiberFromNode.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/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,GA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,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,OAAM,SAAU,qBAAV,CAAgC,GAAhC,EAAqD;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","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,"mappings":"AAuEA,IAAKA,OAuBJ;AAvBD,WAAKA,OAAO;EACVA,+DAAqB;EACrBA,yDAAkB;EAClBA,yEAA0B;EAC1BA,6CAAY;EACZA,iDAAc;EACdA,uDAAiB;EACjBA,6CAAY;EACZA,6CAAY;EACZA,qCAAQ;EACRA,2DAAmB;EACnBA,4DAAoB;EACpBA,kDAAe;EACfA,8CAAa;EACbA,gEAAsB;EACtBA,wDAAkB;EAClBA,oEAAwB;EACxBA,wDAAkB;EAClBA,8EAA6B;EAC7BA,kEAAuB;EACvBA,wEAA0B;EAC1BA,sEAAyB;EACzBA,0DAAmB;AACrB,CAAC,EAvBIA,OAAO,KAAPA,OAAO;AAsLZ,OAAM,SAAUC,qBAAqB,CAACC,GAAqB;EACzD,IAAI,CAACA,GAAG,EAAE;IACR,OAAO,IAAI;;EAGb,KAAK,MAAMC,CAAC,IAAID,GAAG,EAAE;IACnB;IACA;IACA;IACA,IAAIC,CAAC,CAACC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAID,CAAC,CAACC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;MACnF;MACA;MACA,OAAOF,GAAG,CAACC,CAAC,CAAC;;;EAIjB,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;AAC5E","names":["WorkTag","getReactFiberFromNode","elm","k","indexOf","Error"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/getReactFiberFromNode.ts"],"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"]}
@@ -6,9 +6,8 @@
6
6
  export const getParentNode = node => {
7
7
  if (node.nodeName === 'HTML') {
8
8
  return node;
9
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
-
11
-
9
+ }
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
11
  return node.parentNode || node.host;
13
12
  };
14
13
  /**
@@ -16,14 +15,11 @@ export const getParentNode = node => {
16
15
  * @param node - DOM node.
17
16
  * @returns - CSS styles.
18
17
  */
19
-
20
18
  const getStyleComputedProperty = node => {
21
19
  var _a;
22
-
23
20
  if (node.nodeType !== 1) {
24
21
  return {};
25
22
  }
26
-
27
23
  const window = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
28
24
  return window.getComputedStyle(node, null);
29
25
  };
@@ -32,39 +28,31 @@ const getStyleComputedProperty = node => {
32
28
  * @param node - DOM node.
33
29
  * @returns - the first scrollable parent.
34
30
  */
35
-
36
-
37
31
  export const getScrollParent = node => {
38
32
  // Return body, `getScroll` will take care to get the correct `scrollTop` from it
39
- const parentNode = node && getParentNode(node); // eslint-disable-next-line
40
-
33
+ const parentNode = node && getParentNode(node);
34
+ // eslint-disable-next-line
41
35
  if (!parentNode) return document.body;
42
-
43
36
  switch (parentNode.nodeName) {
44
37
  case 'HTML':
45
38
  case 'BODY':
46
39
  return parentNode.ownerDocument.body;
47
-
48
40
  case '#document':
49
41
  return parentNode.body;
50
- } // If any of the overflow props is defined for the node then we return it as the parent
51
-
52
-
42
+ }
43
+ // If any of the overflow props is defined for the node then we return it as the parent
53
44
  const {
54
45
  overflow,
55
46
  overflowX,
56
47
  overflowY
57
48
  } = getStyleComputedProperty(parentNode);
58
-
59
49
  if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
60
50
  return parentNode;
61
51
  }
62
-
63
52
  return getScrollParent(parentNode);
64
53
  };
65
54
  export const hasScrollParent = node => {
66
55
  var _a;
67
-
68
56
  const scrollParentElement = getScrollParent(node);
69
57
  return scrollParentElement ? scrollParentElement !== ((_a = scrollParentElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.body) : false;
70
58
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-positioning/src/utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,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;AAQP;;;;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;;;AACH,OAAO,MAAM,eAAe,GAAI,IAAD,IAAqD;EAClF;EACA,MAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAD,CAAxC,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,eAAe,CAAC,UAAD,CAAtB;AACD,CArBM;AAuBP,OAAO,MAAM,eAAe,GAAI,IAAD,IAAiD;;;EAC9E,MAAM,mBAAmB,GAAgB,eAAe,CAAC,IAAD,CAAxD;EACA,OAAO,mBAAmB,GAAG,mBAAmB,MAAK,CAAA,EAAA,GAAA,mBAAmB,CAAC,aAApB,MAAiC,IAAjC,IAAiC,EAAA,KAAA,KAAA,CAAjC,GAAiC,KAAA,CAAjC,GAAiC,EAAA,CAAE,IAAxC,CAAtB,GAAqE,KAA/F;AACD,CAHM","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\nexport const hasScrollParent = (node: Document | HTMLElement | null): boolean => {\n const scrollParentElement: HTMLElement = getScrollParent(node);\n return scrollParentElement ? scrollParentElement !== scrollParentElement.ownerDocument?.body : false;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAAA;;;;;AAKA,OAAO,MAAMA,aAAa,GAAIC,IAAiB,IAAiB;EAC9D,IAAIA,IAAI,CAACC,QAAQ,KAAK,MAAM,EAAE;IAC5B,OAAOD,IAAI;;EAEb;EACA,OAAOA,IAAI,CAACE,UAAU,IAAKF,IAAY,CAACG,IAAI;AAC9C,CAAC;AAED;;;;;AAKA,MAAMC,wBAAwB,GAAIJ,IAAiB,IAAkC;;EACnF,IAAIA,IAAI,CAACK,QAAQ,KAAK,CAAC,EAAE;IACvB,OAAO,EAAE;;EAGX,MAAMC,MAAM,GAAG,UAAI,CAACC,aAAa,0CAAEC,WAAW;EAC9C,OAAOF,MAAO,CAACG,gBAAgB,CAACT,IAAI,EAAE,IAAI,CAAC;AAC7C,CAAC;AAED;;;;;AAKA,OAAO,MAAMU,eAAe,GAAIV,IAAmC,IAAiB;EAClF;EACA,MAAME,UAAU,GAAGF,IAAI,IAAID,aAAa,CAACC,IAAmB,CAAC;EAC7D;EACA,IAAI,CAACE,UAAU,EAAE,OAAOS,QAAQ,CAACC,IAAI;EAErC,QAAQV,UAAU,CAACD,QAAQ;IACzB,KAAK,MAAM;IACX,KAAK,MAAM;MACT,OAAOC,UAAU,CAACK,aAAc,CAACK,IAAI;IACvC,KAAK,WAAW;MACd,OAASV,UAAmC,CAACU,IAAI;EAAC;EAGtD;EACA,MAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAS,CAAE,GAAGX,wBAAwB,CAACF,UAAU,CAAC;EAC/E,IAAI,uBAAuB,CAACc,IAAI,CAACH,QAAS,GAAGE,SAAU,GAAGD,SAAS,CAAC,EAAE;IACpE,OAAOZ,UAAU;;EAGnB,OAAOQ,eAAe,CAACR,UAAU,CAAC;AACpC,CAAC;AAED,OAAO,MAAMe,eAAe,GAAIjB,IAAmC,IAAa;;EAC9E,MAAMkB,mBAAmB,GAAgBR,eAAe,CAACV,IAAI,CAAC;EAC9D,OAAOkB,mBAAmB,GAAGA,mBAAmB,MAAK,yBAAmB,CAACX,aAAa,0CAAEK,IAAI,IAAG,KAAK;AACtG,CAAC","names":["getParentNode","node","nodeName","parentNode","host","getStyleComputedProperty","nodeType","window","ownerDocument","defaultView","getComputedStyle","getScrollParent","document","body","overflow","overflowX","overflowY","test","hasScrollParent","scrollParentElement"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/getScrollParent.ts"],"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\nexport const hasScrollParent = (node: Document | HTMLElement | null): boolean => {\n const scrollParentElement: HTMLElement = getScrollParent(node);\n return scrollParentElement ? scrollParentElement !== scrollParentElement.ownerDocument?.body : false;\n};\n"]}
@@ -8,20 +8,15 @@ import { getReactFiberFromNode } from './getReactFiberFromNode';
8
8
  *
9
9
  * @param node
10
10
  */
11
-
12
11
  function hasAutofocusProp(node) {
13
- var _a; // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
14
-
15
-
12
+ var _a;
13
+ // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166
16
14
  const isAutoFocusableElement = node.nodeName === 'BUTTON' || node.nodeName === 'INPUT' || node.nodeName === 'SELECT' || node.nodeName === 'TEXTAREA';
17
-
18
15
  if (isAutoFocusableElement) {
19
16
  return !!((_a = getReactFiberFromNode(node)) === null || _a === void 0 ? void 0 : _a.pendingProps.autoFocus);
20
17
  }
21
-
22
18
  return false;
23
19
  }
24
-
25
20
  export function hasAutofocusFilter(node) {
26
21
  return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
27
22
  }