@fluentui/react-positioning 0.0.0-nightly-20230223-2115.1 → 0.0.0-nightly-20230228-0425.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/lib/constants.js.map +1 -1
  4. package/lib/createArrowStyles.js.map +1 -1
  5. package/lib/createPositionManager.js +6 -7
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js +2 -1
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js.map +1 -1
  10. package/lib/middleware/coverTarget.js.map +1 -1
  11. package/lib/middleware/flip.js.map +1 -1
  12. package/lib/middleware/index.js.map +1 -1
  13. package/lib/middleware/intersecting.js.map +1 -1
  14. package/lib/middleware/maxSize.js +6 -7
  15. package/lib/middleware/maxSize.js.map +1 -1
  16. package/lib/middleware/offset.js.map +1 -1
  17. package/lib/middleware/shift.js.map +1 -1
  18. package/lib/types.js +1 -1
  19. package/lib/types.js.map +1 -1
  20. package/lib/usePositioning.js +21 -21
  21. package/lib/usePositioning.js.map +1 -1
  22. package/lib/usePositioningMouseTarget.js.map +1 -1
  23. package/lib/utils/debounce.js +2 -1
  24. package/lib/utils/debounce.js.map +1 -1
  25. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  26. package/lib/utils/getBoundary.js.map +1 -1
  27. package/lib/utils/getFloatingUIOffset.js +7 -8
  28. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  29. package/lib/utils/getReactFiberFromNode.js +0 -1
  30. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  31. package/lib/utils/getScrollParent.js +6 -5
  32. package/lib/utils/getScrollParent.js.map +1 -1
  33. package/lib/utils/hasAutoFocusFilter.js +2 -2
  34. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  35. package/lib/utils/index.js.map +1 -1
  36. package/lib/utils/mergeArrowOffset.js +4 -2
  37. package/lib/utils/mergeArrowOffset.js.map +1 -1
  38. package/lib/utils/parseFloatingUIPlacement.js +2 -1
  39. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  40. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  41. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  42. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  43. package/lib/utils/toggleScrollListener.js.map +1 -1
  44. package/lib/utils/useCallbackRef.js.map +1 -1
  45. package/lib/utils/writeArrowUpdates.js +2 -1
  46. package/lib/utils/writeArrowUpdates.js.map +1 -1
  47. package/lib/utils/writeContainerupdates.js +4 -4
  48. package/lib/utils/writeContainerupdates.js.map +1 -1
  49. package/lib-commonjs/constants.js +7 -18
  50. package/lib-commonjs/constants.js.map +1 -1
  51. package/lib-commonjs/createArrowStyles.js +88 -60
  52. package/lib-commonjs/createArrowStyles.js.map +1 -1
  53. package/lib-commonjs/createPositionManager.js +116 -103
  54. package/lib-commonjs/createPositionManager.js.map +1 -1
  55. package/lib-commonjs/createVirtualElementFromClick.js +26 -27
  56. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  57. package/lib-commonjs/index.js +51 -24
  58. package/lib-commonjs/index.js.map +1 -1
  59. package/lib-commonjs/middleware/coverTarget.js +37 -34
  60. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  61. package/lib-commonjs/middleware/flip.js +22 -20
  62. package/lib-commonjs/middleware/flip.js.map +1 -1
  63. package/lib-commonjs/middleware/index.js +9 -10
  64. package/lib-commonjs/middleware/index.js.map +1 -1
  65. package/lib-commonjs/middleware/intersecting.js +22 -24
  66. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  67. package/lib-commonjs/middleware/maxSize.js +40 -35
  68. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  69. package/lib-commonjs/middleware/offset.js +12 -11
  70. package/lib-commonjs/middleware/offset.js.map +1 -1
  71. package/lib-commonjs/middleware/shift.js +37 -29
  72. package/lib-commonjs/middleware/shift.js.map +1 -1
  73. package/lib-commonjs/types.js +2 -5
  74. package/lib-commonjs/types.js.map +1 -1
  75. package/lib-commonjs/usePositioning.js +161 -195
  76. package/lib-commonjs/usePositioning.js.map +1 -1
  77. package/lib-commonjs/usePositioningMouseTarget.js +37 -34
  78. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  79. package/lib-commonjs/utils/debounce.js +21 -22
  80. package/lib-commonjs/utils/debounce.js.map +1 -1
  81. package/lib-commonjs/utils/fromFloatingUIPlacement.js +35 -30
  82. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  83. package/lib-commonjs/utils/getBoundary.js +22 -21
  84. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  85. package/lib-commonjs/utils/getFloatingUIOffset.js +35 -24
  86. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  87. package/lib-commonjs/utils/getReactFiberFromNode.js +41 -45
  88. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  89. package/lib-commonjs/utils/getScrollParent.js +56 -52
  90. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  91. package/lib-commonjs/utils/hasAutoFocusFilter.js +17 -18
  92. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  93. package/lib-commonjs/utils/index.js +18 -19
  94. package/lib-commonjs/utils/index.js.map +1 -1
  95. package/lib-commonjs/utils/mergeArrowOffset.js +32 -32
  96. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  97. package/lib-commonjs/utils/parseFloatingUIPlacement.js +14 -15
  98. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  99. package/lib-commonjs/utils/resolvePositioningShorthand.js +61 -63
  100. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  101. package/lib-commonjs/utils/toFloatingUIPadding.js +25 -23
  102. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  103. package/lib-commonjs/utils/toFloatingUIPlacement.js +33 -31
  104. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  105. package/lib-commonjs/utils/toggleScrollListener.js +23 -19
  106. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  107. package/lib-commonjs/utils/useCallbackRef.js +53 -39
  108. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  109. package/lib-commonjs/utils/writeArrowUpdates.js +24 -19
  110. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  111. package/lib-commonjs/utils/writeContainerupdates.js +45 -37
  112. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  113. package/package.json +6 -6
  114. package/.swcrc +0 -33
@@ -1,205 +1,171 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "usePositioning", {
6
- enumerable: true,
7
- get: ()=>usePositioning
4
+ value: true
8
5
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _dom = require("@floating-ui/dom");
11
- const _reactSharedContexts = require("@fluentui/react-shared-contexts");
12
- const _reactUtilities = require("@fluentui/react-utilities");
13
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
14
- const _utils = require("./utils");
15
- const _middleware = require("./middleware");
16
- const _createPositionManager = require("./createPositionManager");
6
+ exports.usePositioning = void 0;
7
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
8
+ const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
9
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
+ const React = /*#__PURE__*/require("react");
11
+ const utils_1 = /*#__PURE__*/require("./utils");
12
+ const middleware_1 = /*#__PURE__*/require("./middleware");
13
+ const createPositionManager_1 = /*#__PURE__*/require("./createPositionManager");
14
+ /**
15
+ * @internal
16
+ */
17
17
  function usePositioning(options) {
18
- const managerRef = _react.useRef(null);
19
- const targetRef = _react.useRef(null);
20
- const overrideTargetRef = _react.useRef(null);
21
- const containerRef = _react.useRef(null);
22
- const arrowRef = _react.useRef(null);
23
- const { enabled =true } = options;
24
- const resolvePositioningOptions = usePositioningOptions(options);
25
- const updatePositionManager = _react.useCallback(()=>{
26
- if (managerRef.current) {
27
- managerRef.current.dispose();
28
- }
29
- managerRef.current = null;
30
- const target = overrideTargetRef.current ?? targetRef.current;
31
- if (enabled && (0, _reactUtilities.canUseDOM)() && target && containerRef.current) {
32
- managerRef.current = (0, _createPositionManager.createPositionManager)({
33
- container: containerRef.current,
34
- target,
35
- arrow: arrowRef.current,
36
- ...resolvePositioningOptions(containerRef.current, arrowRef.current)
37
- });
38
- }
39
- }, [
40
- enabled,
41
- resolvePositioningOptions
42
- ]);
43
- const setOverrideTarget = (0, _reactUtilities.useEventCallback)((target)=>{
44
- overrideTargetRef.current = target;
45
- updatePositionManager();
46
- });
47
- _react.useImperativeHandle(options.positioningRef, ()=>{
48
- return {
49
- updatePosition: ()=>{
50
- var _managerRef_current;
51
- return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();
52
- },
53
- setTarget: (target)=>{
54
- if (options.target && process.env.NODE_ENV !== 'production') {
55
- const err = new Error();
56
- // eslint-disable-next-line no-console
57
- console.warn('Imperative setTarget should not be used at the same time as target option');
58
- // eslint-disable-next-line no-console
59
- console.warn(err.stack);
60
- }
61
- setOverrideTarget(target);
62
- }
63
- };
64
- }, [
65
- options.target,
66
- setOverrideTarget
67
- ]);
68
- (0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
69
- setOverrideTarget(options.target ?? null);
70
- }, [
71
- options.target,
72
- setOverrideTarget
73
- ]);
74
- (0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
75
- updatePositionManager();
76
- }, [
77
- updatePositionManager
78
- ]);
79
- if (process.env.NODE_ENV !== 'production') {
80
- // This checked should run only in development mode
81
- // eslint-disable-next-line react-hooks/rules-of-hooks
82
- _react.useEffect(()=>{
83
- if (containerRef.current) {
84
- var _contentNode_ownerDocument;
85
- const contentNode = containerRef.current;
86
- const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
87
- acceptNode: _utils.hasAutofocusFilter
88
- });
89
- while(treeWalker.nextNode()){
90
- const node = treeWalker.currentNode;
91
- // eslint-disable-next-line no-console
92
- console.warn('<Popper>:', node);
93
- // eslint-disable-next-line no-console
94
- console.warn([
95
- '<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
96
- 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',
97
- '"autoFocus" behavior to solve inconsistencies between different browsers:',
98
- 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',
99
- '\n',
100
- 'However, ".focus()" in this case occurs before any other React effects will be executed',
101
- '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',
102
- 'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by',
103
- '"Popper".',
104
- `In general, it's not recommended to use "autoFocus" as it may break accessibility aspects:`,
105
- 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',
106
- '\n',
107
- 'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use',
108
- '"ref.current.focus" in React.useEffect():',
109
- 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'
110
- ].join(' '));
111
- }
112
- }
113
- // We run this check once, no need to add deps here
114
- // TODO: Should be rework to handle options.enabled and contentRef updates
115
- // eslint-disable-next-line react-hooks/exhaustive-deps
116
- }, []);
18
+ const managerRef = React.useRef(null);
19
+ const targetRef = React.useRef(null);
20
+ const overrideTargetRef = React.useRef(null);
21
+ const containerRef = React.useRef(null);
22
+ const arrowRef = React.useRef(null);
23
+ const {
24
+ enabled = true
25
+ } = options;
26
+ const resolvePositioningOptions = usePositioningOptions(options);
27
+ const updatePositionManager = React.useCallback(() => {
28
+ var _a;
29
+ if (managerRef.current) {
30
+ managerRef.current.dispose();
117
31
  }
118
- const setTarget = (0, _utils.useCallbackRef)(null, (target)=>{
119
- if (targetRef.current !== target) {
120
- targetRef.current = target;
121
- updatePositionManager();
122
- }
123
- });
124
- const setContainer = (0, _utils.useCallbackRef)(null, (container)=>{
125
- if (containerRef.current !== container) {
126
- containerRef.current = container;
127
- updatePositionManager();
128
- }
129
- });
130
- const setArrow = (0, _utils.useCallbackRef)(null, (arrow)=>{
131
- if (arrowRef.current !== arrow) {
132
- arrowRef.current = arrow;
133
- updatePositionManager();
32
+ managerRef.current = null;
33
+ const target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
34
+ if (enabled && react_utilities_1.canUseDOM() && target && containerRef.current) {
35
+ managerRef.current = createPositionManager_1.createPositionManager({
36
+ container: containerRef.current,
37
+ target,
38
+ arrow: arrowRef.current,
39
+ ...resolvePositioningOptions(containerRef.current, arrowRef.current)
40
+ });
41
+ }
42
+ }, [enabled, resolvePositioningOptions]);
43
+ const setOverrideTarget = react_utilities_1.useEventCallback(target => {
44
+ overrideTargetRef.current = target;
45
+ updatePositionManager();
46
+ });
47
+ React.useImperativeHandle(options.positioningRef, () => ({
48
+ updatePosition: () => {
49
+ var _a;
50
+ return (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
51
+ },
52
+ setTarget: target => {
53
+ if (options.target && process.env.NODE_ENV !== 'production') {
54
+ const err = new Error();
55
+ // eslint-disable-next-line no-console
56
+ console.warn('Imperative setTarget should not be used at the same time as target option');
57
+ // eslint-disable-next-line no-console
58
+ console.warn(err.stack);
59
+ }
60
+ setOverrideTarget(target);
61
+ }
62
+ }), [options.target, setOverrideTarget]);
63
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
64
+ var _a;
65
+ setOverrideTarget((_a = options.target) !== null && _a !== void 0 ? _a : null);
66
+ }, [options.target, setOverrideTarget]);
67
+ react_utilities_1.useIsomorphicLayoutEffect(() => {
68
+ updatePositionManager();
69
+ }, [updatePositionManager]);
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ // This checked should run only in development mode
72
+ // eslint-disable-next-line react-hooks/rules-of-hooks
73
+ React.useEffect(() => {
74
+ var _a;
75
+ if (containerRef.current) {
76
+ const contentNode = containerRef.current;
77
+ const treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
78
+ acceptNode: utils_1.hasAutofocusFilter
79
+ });
80
+ while (treeWalker.nextNode()) {
81
+ const node = treeWalker.currentNode;
82
+ // eslint-disable-next-line no-console
83
+ console.warn('<Popper>:', node);
84
+ // eslint-disable-next-line no-console
85
+ 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(' '));
134
86
  }
135
- });
136
- // Let users use callback refs so they feel like 'normal' DOM refs
87
+ }
88
+ // We run this check once, no need to add deps here
89
+ // TODO: Should be rework to handle options.enabled and contentRef updates
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, []);
92
+ }
93
+ const setTarget = utils_1.useCallbackRef(null, target => {
94
+ if (targetRef.current !== target) {
95
+ targetRef.current = target;
96
+ updatePositionManager();
97
+ }
98
+ });
99
+ const setContainer = utils_1.useCallbackRef(null, container => {
100
+ if (containerRef.current !== container) {
101
+ containerRef.current = container;
102
+ updatePositionManager();
103
+ }
104
+ });
105
+ const setArrow = utils_1.useCallbackRef(null, arrow => {
106
+ if (arrowRef.current !== arrow) {
107
+ arrowRef.current = arrow;
108
+ updatePositionManager();
109
+ }
110
+ });
111
+ // Let users use callback refs so they feel like 'normal' DOM refs
112
+ return {
113
+ targetRef: setTarget,
114
+ containerRef: setContainer,
115
+ arrowRef: setArrow
116
+ };
117
+ }
118
+ exports.usePositioning = usePositioning;
119
+ function usePositioningOptions(options) {
120
+ const {
121
+ align,
122
+ arrowPadding,
123
+ autoSize,
124
+ coverTarget,
125
+ flipBoundary,
126
+ offset,
127
+ overflowBoundary,
128
+ pinned,
129
+ position,
130
+ unstable_disableTether: disableTether,
131
+ positionFixed,
132
+ overflowBoundaryPadding
133
+ } = options;
134
+ const {
135
+ dir
136
+ } = react_shared_contexts_1.useFluent_unstable();
137
+ const isRtl = dir === 'rtl';
138
+ const strategy = positionFixed ? 'fixed' : 'absolute';
139
+ return React.useCallback((container, arrow) => {
140
+ const hasScrollableElement = utils_1.hasScrollParent(container);
141
+ const middleware = [offset && middleware_1.offset(offset), coverTarget && middleware_1.coverTarget(), !pinned && middleware_1.flip({
142
+ container,
143
+ flipBoundary,
144
+ hasScrollableElement
145
+ }), middleware_1.shift({
146
+ container,
147
+ hasScrollableElement,
148
+ overflowBoundary,
149
+ disableTether,
150
+ overflowBoundaryPadding,
151
+ isRtl
152
+ }), autoSize && middleware_1.maxSize(autoSize, {
153
+ container,
154
+ overflowBoundary
155
+ }), middleware_1.intersecting(), arrow && dom_1.arrow({
156
+ element: arrow,
157
+ padding: arrowPadding
158
+ }), dom_1.hide({
159
+ strategy: 'referenceHidden'
160
+ }), dom_1.hide({
161
+ strategy: 'escaped'
162
+ })].filter(Boolean);
163
+ const placement = utils_1.toFloatingUIPlacement(align, position, isRtl);
137
164
  return {
138
- targetRef: setTarget,
139
- containerRef: setContainer,
140
- arrowRef: setArrow
165
+ placement,
166
+ middleware,
167
+ strategy
141
168
  };
169
+ }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy, overflowBoundaryPadding]);
142
170
  }
143
- function usePositioningOptions(options) {
144
- const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , overflowBoundaryPadding } = options;
145
- const { dir } = (0, _reactSharedContexts.useFluent_unstable)();
146
- const isRtl = dir === 'rtl';
147
- const strategy = positionFixed ? 'fixed' : 'absolute';
148
- return _react.useCallback((container, arrow)=>{
149
- const hasScrollableElement = (0, _utils.hasScrollParent)(container);
150
- const middleware = [
151
- offset && (0, _middleware.offset)(offset),
152
- coverTarget && (0, _middleware.coverTarget)(),
153
- !pinned && (0, _middleware.flip)({
154
- container,
155
- flipBoundary,
156
- hasScrollableElement
157
- }),
158
- (0, _middleware.shift)({
159
- container,
160
- hasScrollableElement,
161
- overflowBoundary,
162
- disableTether,
163
- overflowBoundaryPadding,
164
- isRtl
165
- }),
166
- autoSize && (0, _middleware.maxSize)(autoSize, {
167
- container,
168
- overflowBoundary
169
- }),
170
- (0, _middleware.intersecting)(),
171
- arrow && (0, _dom.arrow)({
172
- element: arrow,
173
- padding: arrowPadding
174
- }),
175
- (0, _dom.hide)({
176
- strategy: 'referenceHidden'
177
- }),
178
- (0, _dom.hide)({
179
- strategy: 'escaped'
180
- })
181
- ].filter(Boolean);
182
- const placement = (0, _utils.toFloatingUIPlacement)(align, position, isRtl);
183
- return {
184
- placement,
185
- middleware,
186
- strategy
187
- };
188
- }, [
189
- align,
190
- arrowPadding,
191
- autoSize,
192
- coverTarget,
193
- disableTether,
194
- flipBoundary,
195
- isRtl,
196
- offset,
197
- overflowBoundary,
198
- pinned,
199
- position,
200
- strategy,
201
- overflowBoundaryPadding
202
- ]);
203
- } //# sourceMappingURL=usePositioning.js.map
204
-
205
171
  //# sourceMappingURL=usePositioning.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/usePositioning.js"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } 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 { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';\nimport { createPositionManager } from './createPositionManager';\n/**\n * @internal\n */\nexport function usePositioning(options) {\n const managerRef = React.useRef(null);\n const targetRef = React.useRef(null);\n const overrideTargetRef = React.useRef(null);\n const containerRef = React.useRef(null);\n const arrowRef = React.useRef(null);\n const {\n enabled = true\n } = 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 const target = overrideTargetRef.current ?? targetRef.current;\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 const setOverrideTarget = useEventCallback(target => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n React.useImperativeHandle(options.positioningRef, () => {\n return {\n updatePosition: () => {\n var _managerRef_current;\n return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();\n },\n setTarget: target => {\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 setOverrideTarget(target);\n }\n };\n }, [options.target, setOverrideTarget]);\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\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 var _contentNode_ownerDocument;\n const contentNode = containerRef.current;\n const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter\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(['<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(' '));\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 const setTarget = useCallbackRef(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n const setContainer = useCallbackRef(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n const setArrow = useCallbackRef(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n // Let users use callback refs so they feel like 'normal' DOM refs\n return {\n targetRef: setTarget,\n containerRef: setContainer,\n arrowRef: setArrow\n };\n}\nfunction usePositioningOptions(options) {\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 overflowBoundaryPadding\n } = options;\n const {\n dir\n } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy = positionFixed ? 'fixed' : 'absolute';\n return React.useCallback((container, arrow) => {\n const hasScrollableElement = hasScrollParent(container);\n const middleware = [offset && offsetMiddleware(offset), coverTarget && coverTargetMiddleware(), !pinned && flipMiddleware({\n container,\n flipBoundary,\n hasScrollableElement\n }), shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl\n }), autoSize && maxSizeMiddleware(autoSize, {\n container,\n overflowBoundary\n }), intersectingMiddleware(), arrow && arrowMiddleware({\n element: arrow,\n padding: arrowPadding\n }), hideMiddleware({\n strategy: 'referenceHidden'\n }), hideMiddleware({\n strategy: 'escaped'\n })].filter(Boolean);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n return {\n placement,\n middleware,\n strategy\n };\n }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy, overflowBoundaryPadding]);\n}\n//# sourceMappingURL=usePositioning.js.map"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","dir","useFluent","isRtl","strategy","hasScrollableElement","hasScrollParent","middleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","filter","Boolean","placement","toFloatingUIPlacement"],"mappings":";;;;+BAUgBA;;aAAAA;;;qBAViD;qCACjB;gCACuB;6DAChD;uBACoE;4BAC8G;uCACnK;AAI/B,SAASA,eAAeC,OAAO,EAAE;IACtC,MAAMC,aAAaC,OAAMC,MAAM,CAAC,IAAI;IACpC,MAAMC,YAAYF,OAAMC,MAAM,CAAC,IAAI;IACnC,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3C,MAAMG,eAAeJ,OAAMC,MAAM,CAAC,IAAI;IACtC,MAAMI,WAAWL,OAAMC,MAAM,CAAC,IAAI;IAClC,MAAM,EACJK,SAAU,IAAI,CAAA,EACf,GAAGR;IACJ,MAAMS,4BAA4BC,sBAAsBV;IACxD,MAAMW,wBAAwBT,OAAMU,WAAW,CAAC,IAAM;QACpD,IAAIX,WAAWY,OAAO,EAAE;YACtBZ,WAAWY,OAAO,CAACC,OAAO;QAC5B,CAAC;QACDb,WAAWY,OAAO,GAAG,IAAI;QACzB,MAAME,SAASV,kBAAkBQ,OAAO,IAAIT,UAAUS,OAAO;QAC7D,IAAIL,WAAWQ,IAAAA,yBAAS,OAAMD,UAAUT,aAAaO,O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qB,CAACQ,KAAK,EAAEQ,QAAQ,EAAEO,KAAK,CAAC;IAE/D,OAAO;MACLU,SAAS;MACTP,UAAU;MACVF;KACD;EACH,CAAC,EACD,CACEhB,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRC,WAAW,EACXO,aAAa,EACbN,YAAY,EACZW,KAAK,EACLV,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRQ,QAAQ,EACRJ,uBAAuB,CACxB,CACF;AACH","names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","react_utilities_1","createPositionManager_1","container","arrow","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","utils_1","nextNode","node","currentNode","join","setContainer","setArrow","exports","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","dir","react_shared_contexts_1","isRtl","strategy","hasScrollableElement","middleware","middleware_1","dom_1","element","padding","filter","Boolean","placement"],"sourceRoot":"","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 overflowBoundaryPadding,\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 middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\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 const placement = toFloatingUIPlacement(align, position, isRtl);\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 overflowBoundaryPadding,\n ],\n );\n}\n"]}
@@ -1,38 +1,41 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "usePositioningMouseTarget", {
6
- enumerable: true,
7
- get: ()=>usePositioningMouseTarget
4
+ value: true
8
5
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
12
- const usePositioningMouseTarget = (initialState)=>{
13
- const [virtualElement, setVirtualElement] = _react.useState(initialState);
14
- const setVirtualMouseTarget = (event)=>{
15
- if (event === undefined || event === null) {
16
- setVirtualElement(undefined);
17
- return;
18
- }
19
- let mouseevent;
20
- if (!(event instanceof MouseEvent)) {
21
- mouseevent = event.nativeEvent;
22
- } else {
23
- mouseevent = event;
24
- }
25
- if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
26
- // eslint-disable-next-line no-console
27
- console.error('usePositioningMouseTarget should only be used with MouseEvent');
28
- }
29
- const contextTarget = (0, _createVirtualElementFromClick.createVirtualElementFromClick)(mouseevent);
30
- setVirtualElement(contextTarget);
31
- };
32
- return [
33
- virtualElement,
34
- setVirtualMouseTarget
35
- ];
36
- }; //# sourceMappingURL=usePositioningMouseTarget.js.map
37
-
6
+ exports.usePositioningMouseTarget = void 0;
7
+ const React = /*#__PURE__*/require("react");
8
+ const createVirtualElementFromClick_1 = /*#__PURE__*/require("./createVirtualElementFromClick");
9
+ /**
10
+ * @internal
11
+ * A state hook that manages a popper virtual element from mouseevents.
12
+ * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
13
+ * React synthetic events are not persisted by this hook
14
+ *
15
+ * @param initialState - initializes a user provided state similare to useState
16
+ * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
17
+ */
18
+ const usePositioningMouseTarget = initialState => {
19
+ const [virtualElement, setVirtualElement] = React.useState(initialState);
20
+ const setVirtualMouseTarget = event => {
21
+ if (event === undefined || event === null) {
22
+ setVirtualElement(undefined);
23
+ return;
24
+ }
25
+ let mouseevent;
26
+ if (!(event instanceof MouseEvent)) {
27
+ mouseevent = event.nativeEvent;
28
+ } else {
29
+ mouseevent = event;
30
+ }
31
+ if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
32
+ // eslint-disable-next-line no-console
33
+ console.error('usePositioningMouseTarget should only be used with MouseEvent');
34
+ }
35
+ const contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
36
+ setVirtualElement(contextTarget);
37
+ };
38
+ return [virtualElement, setVirtualMouseTarget];
39
+ };
40
+ exports.usePositioningMouseTarget = usePositioningMouseTarget;
38
41
  //# sourceMappingURL=usePositioningMouseTarget.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/usePositioningMouseTarget.js"],"sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\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 = initialState => {\n const [virtualElement, setVirtualElement] = React.useState(initialState);\n const setVirtualMouseTarget = event => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n let mouseevent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\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 const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n return [virtualElement, setVirtualMouseTarget];\n};\n//# sourceMappingURL=usePositioningMouseTarget.js.map"],"names":["usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","React","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget","createVirtualElementFromClick"],"mappings":";;;;+BAWaA;;aAAAA;;;6DAXU;+CACuB;AAUvC,MAAMA,4BAA4BC,CAAAA,eAAgB;IACvD,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGC,OAAMC,QAAQ,CAACJ;I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ClC,CAAC;EAED,OAAO,CAACf,cAAc,EAAEI,qBAAqB,CAAU;AACzD,CAAC;AA5BYa,iCAAyB","names":["usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","React","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget","createVirtualElementFromClick_1","exports"],"sourceRoot":"","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"]}
@@ -1,29 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.debounce = void 0;
1
7
  /**
2
8
  * Promise microtask debouncer used by Popper.js v2
3
9
  * This is no longer exported in Floating UI (Popper.js v3)
4
10
  * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
5
11
  * @param fn function that will be debounced
6
- */ "use strict";
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- Object.defineProperty(exports, "debounce", {
11
- enumerable: true,
12
- get: ()=>debounce
13
- });
12
+ */
14
13
  function debounce(fn) {
15
- let pending;
16
- return ()=>{
17
- if (!pending) {
18
- pending = new Promise((resolve)=>{
19
- Promise.resolve().then(()=>{
20
- pending = undefined;
21
- resolve(fn());
22
- });
23
- });
24
- }
25
- return pending;
26
- };
27
- } //# sourceMappingURL=debounce.js.map
28
-
14
+ let pending;
15
+ return () => {
16
+ if (!pending) {
17
+ pending = new Promise(resolve => {
18
+ Promise.resolve().then(() => {
19
+ pending = undefined;
20
+ resolve(fn());
21
+ });
22
+ });
23
+ }
24
+ return pending;
25
+ };
26
+ }
27
+ exports.debounce = debounce;
29
28
  //# sourceMappingURL=debounce.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/utils/debounce.js"],"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 */export function debounce(fn) {\n let pending;\n return () => {\n if (!pending) {\n pending = new Promise(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n return pending;\n };\n}\n//# sourceMappingURL=debounce.js.map"],"names":["debounce","fn","pending","Promise","resolve","then","undefined"],"mappings":"AAAA;;;;;CAKC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,SAASC,EAAE,EAAE;IAC9B,IAAIC;IACJ,OAAO,IAAM;QACX,IAAI,CAACA,SAAS;YACZA,UAAU,IAAIC,QAAQC,CAAAA,UAAW;gBAC/BD,QAAQC,OAAO,GAAGC,IAAI,CAAC,IAAM;oBAC3BH,UAAUI;oBACVF,QAAQH;gBACV;YACF;QACF,CAAC;QACD,OAAOC;IACT;AACF,EACA,oCAAoC"}
1
+ {"version":3,"mappings":";;;;;;AAAA;;;;;;AAMA,SAAgBA,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;AAdAK","names":["debounce","fn","pending","Promise","resolve","then","undefined","exports"],"sourceRoot":"","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"]}