@fluentui/react-positioning 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230321-0440.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 (132) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/lib/constants.js +4 -4
  4. package/lib/constants.js.map +1 -1
  5. package/lib/createArrowStyles.js +19 -19
  6. package/lib/createArrowStyles.js.map +1 -1
  7. package/lib/createPositionManager.js +13 -13
  8. package/lib/createPositionManager.js.map +1 -1
  9. package/lib/createVirtualElementFromClick.js +2 -1
  10. package/lib/createVirtualElementFromClick.js.map +1 -1
  11. package/lib/index.js +5 -5
  12. package/lib/index.js.map +1 -1
  13. package/lib/middleware/coverTarget.js +6 -6
  14. package/lib/middleware/coverTarget.js.map +1 -1
  15. package/lib/middleware/flip.js +4 -4
  16. package/lib/middleware/flip.js.map +1 -1
  17. package/lib/middleware/index.js +6 -6
  18. package/lib/middleware/index.js.map +1 -1
  19. package/lib/middleware/intersecting.js +2 -2
  20. package/lib/middleware/intersecting.js.map +1 -1
  21. package/lib/middleware/maxSize.js +8 -8
  22. package/lib/middleware/maxSize.js.map +1 -1
  23. package/lib/middleware/offset.js +2 -2
  24. package/lib/middleware/offset.js.map +1 -1
  25. package/lib/middleware/shift.js +5 -5
  26. package/lib/middleware/shift.js.map +1 -1
  27. package/lib/types.js +1 -1
  28. package/lib/types.js.map +1 -1
  29. package/lib/usePositioning.js +26 -20
  30. package/lib/usePositioning.js.map +1 -1
  31. package/lib/usePositioningMouseTarget.js +4 -4
  32. package/lib/usePositioningMouseTarget.js.map +1 -1
  33. package/lib/utils/debounce.js +2 -1
  34. package/lib/utils/debounce.js.map +1 -1
  35. package/lib/utils/fromFloatingUIPlacement.js +10 -10
  36. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  37. package/lib/utils/getBoundary.js +8 -8
  38. package/lib/utils/getBoundary.js.map +1 -1
  39. package/lib/utils/getFloatingUIOffset.js +2 -2
  40. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  41. package/lib/utils/getReactFiberFromNode.js +2 -3
  42. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  43. package/lib/utils/getScrollParent.js +10 -7
  44. package/lib/utils/getScrollParent.js.map +1 -1
  45. package/lib/utils/hasAutoFocusFilter.js +4 -3
  46. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  47. package/lib/utils/index.js +15 -15
  48. package/lib/utils/index.js.map +1 -1
  49. package/lib/utils/mergeArrowOffset.js +8 -6
  50. package/lib/utils/mergeArrowOffset.js.map +1 -1
  51. package/lib/utils/parseFloatingUIPlacement.js +3 -2
  52. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  53. package/lib/utils/resolvePositioningShorthand.js +33 -33
  54. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  55. package/lib/utils/toFloatingUIPadding.js +3 -3
  56. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  57. package/lib/utils/toFloatingUIPlacement.js +11 -11
  58. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  59. package/lib/utils/toggleScrollListener.js +4 -4
  60. package/lib/utils/toggleScrollListener.js.map +1 -1
  61. package/lib/utils/useCallbackRef.js +2 -2
  62. package/lib/utils/useCallbackRef.js.map +1 -1
  63. package/lib/utils/writeArrowUpdates.js +2 -1
  64. package/lib/utils/writeArrowUpdates.js.map +1 -1
  65. package/lib/utils/writeContainerupdates.js +8 -7
  66. package/lib/utils/writeContainerupdates.js.map +1 -1
  67. package/lib-commonjs/constants.js +7 -18
  68. package/lib-commonjs/constants.js.map +1 -1
  69. package/lib-commonjs/createArrowStyles.js +88 -60
  70. package/lib-commonjs/createArrowStyles.js.map +1 -1
  71. package/lib-commonjs/createPositionManager.js +117 -103
  72. package/lib-commonjs/createPositionManager.js.map +1 -1
  73. package/lib-commonjs/createVirtualElementFromClick.js +26 -27
  74. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  75. package/lib-commonjs/index.js +51 -24
  76. package/lib-commonjs/index.js.map +1 -1
  77. package/lib-commonjs/middleware/coverTarget.js +37 -34
  78. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  79. package/lib-commonjs/middleware/flip.js +38 -31
  80. package/lib-commonjs/middleware/flip.js.map +1 -1
  81. package/lib-commonjs/middleware/index.js +9 -10
  82. package/lib-commonjs/middleware/index.js.map +1 -1
  83. package/lib-commonjs/middleware/intersecting.js +22 -24
  84. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  85. package/lib-commonjs/middleware/maxSize.js +40 -34
  86. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  87. package/lib-commonjs/middleware/offset.js +12 -11
  88. package/lib-commonjs/middleware/offset.js.map +1 -1
  89. package/lib-commonjs/middleware/shift.js +37 -29
  90. package/lib-commonjs/middleware/shift.js.map +1 -1
  91. package/lib-commonjs/types.js +2 -5
  92. package/lib-commonjs/types.js.map +1 -1
  93. package/lib-commonjs/usePositioning.js +164 -192
  94. package/lib-commonjs/usePositioning.js.map +1 -1
  95. package/lib-commonjs/usePositioningMouseTarget.js +37 -34
  96. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  97. package/lib-commonjs/utils/debounce.js +21 -22
  98. package/lib-commonjs/utils/debounce.js.map +1 -1
  99. package/lib-commonjs/utils/fromFloatingUIPlacement.js +35 -30
  100. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  101. package/lib-commonjs/utils/getBoundary.js +22 -21
  102. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  103. package/lib-commonjs/utils/getFloatingUIOffset.js +35 -23
  104. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  105. package/lib-commonjs/utils/getReactFiberFromNode.js +41 -45
  106. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  107. package/lib-commonjs/utils/getScrollParent.js +56 -50
  108. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  109. package/lib-commonjs/utils/hasAutoFocusFilter.js +17 -17
  110. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  111. package/lib-commonjs/utils/index.js +18 -19
  112. package/lib-commonjs/utils/index.js.map +1 -1
  113. package/lib-commonjs/utils/mergeArrowOffset.js +32 -32
  114. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  115. package/lib-commonjs/utils/parseFloatingUIPlacement.js +14 -15
  116. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  117. package/lib-commonjs/utils/resolvePositioningShorthand.js +61 -63
  118. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  119. package/lib-commonjs/utils/toFloatingUIPadding.js +25 -23
  120. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  121. package/lib-commonjs/utils/toFloatingUIPlacement.js +33 -31
  122. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  123. package/lib-commonjs/utils/toggleScrollListener.js +24 -20
  124. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  125. package/lib-commonjs/utils/useCallbackRef.js +53 -39
  126. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  127. package/lib-commonjs/utils/writeArrowUpdates.js +24 -19
  128. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  129. package/lib-commonjs/utils/writeContainerupdates.js +45 -36
  130. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  131. package/package.json +7 -6
  132. package/.swcrc +0 -39
@@ -1,202 +1,174 @@
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
- updatePosition: ()=>managerRef.current?.updatePosition(),
49
- setTarget: (target)=>{
50
- if (options.target && process.env.NODE_ENV !== "production") {
51
- const err = new Error();
52
- // eslint-disable-next-line no-console
53
- console.warn("Imperative setTarget should not be used at the same time as target option");
54
- // eslint-disable-next-line no-console
55
- console.warn(err.stack);
56
- }
57
- setOverrideTarget(target);
58
- }
59
- }), [
60
- options.target,
61
- setOverrideTarget
62
- ]);
63
- (0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
64
- setOverrideTarget(options.target ?? null);
65
- }, [
66
- options.target,
67
- setOverrideTarget
68
- ]);
69
- (0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
70
- updatePositionManager();
71
- }, [
72
- updatePositionManager
73
- ]);
74
- if (process.env.NODE_ENV !== "production") {
75
- // This checked should run only in development mode
76
- // eslint-disable-next-line react-hooks/rules-of-hooks
77
- _react.useEffect(()=>{
78
- if (containerRef.current) {
79
- const contentNode = containerRef.current;
80
- const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
81
- acceptNode: _utils.hasAutofocusFilter
82
- });
83
- while(treeWalker.nextNode()){
84
- const node = treeWalker.currentNode;
85
- // eslint-disable-next-line no-console
86
- console.warn("<Popper>:", node);
87
- // eslint-disable-next-line no-console
88
- console.warn([
89
- '<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
90
- "positioning of an element and cause a window jump effect. This issue occurs because React polyfills",
91
- '"autoFocus" behavior to solve inconsistencies between different browsers:',
92
- "https://github.com/facebook/react/issues/11851#issuecomment-351787078",
93
- "\n",
94
- 'However, ".focus()" in this case occurs before any other React effects will be executed',
95
- "(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really",
96
- 'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by',
97
- '"Popper".',
98
- `In general, it's not recommended to use "autoFocus" as it may break accessibility aspects:`,
99
- "https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md",
100
- "\n",
101
- 'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use',
102
- '"ref.current.focus" in React.useEffect():',
103
- "https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element"
104
- ].join(" "));
105
- }
106
- }
107
- // We run this check once, no need to add deps here
108
- // TODO: Should be rework to handle options.enabled and contentRef updates
109
- // eslint-disable-next-line react-hooks/exhaustive-deps
110
- }, []);
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();
111
31
  }
112
- const setTarget = (0, _utils.useCallbackRef)(null, (target)=>{
113
- if (targetRef.current !== target) {
114
- targetRef.current = target;
115
- updatePositionManager();
116
- }
117
- });
118
- const setContainer = (0, _utils.useCallbackRef)(null, (container)=>{
119
- if (containerRef.current !== container) {
120
- containerRef.current = container;
121
- updatePositionManager();
122
- }
123
- });
124
- const setArrow = (0, _utils.useCallbackRef)(null, (arrow)=>{
125
- if (arrowRef.current !== arrow) {
126
- arrowRef.current = arrow;
127
- 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(' '));
128
86
  }
129
- });
130
- // 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
+ fallbackPositions
134
+ } = options;
135
+ const {
136
+ dir
137
+ } = react_shared_contexts_1.useFluent_unstable();
138
+ const isRtl = dir === 'rtl';
139
+ const strategy = positionFixed ? 'fixed' : 'absolute';
140
+ return React.useCallback((container, arrow) => {
141
+ const hasScrollableElement = utils_1.hasScrollParent(container);
142
+ const middleware = [offset && middleware_1.offset(offset), coverTarget && middleware_1.coverTarget(), !pinned && middleware_1.flip({
143
+ container,
144
+ flipBoundary,
145
+ hasScrollableElement,
146
+ isRtl,
147
+ fallbackPositions
148
+ }), middleware_1.shift({
149
+ container,
150
+ hasScrollableElement,
151
+ overflowBoundary,
152
+ disableTether,
153
+ overflowBoundaryPadding,
154
+ isRtl
155
+ }), autoSize && middleware_1.maxSize(autoSize, {
156
+ container,
157
+ overflowBoundary
158
+ }), middleware_1.intersecting(), arrow && dom_1.arrow({
159
+ element: arrow,
160
+ padding: arrowPadding
161
+ }), dom_1.hide({
162
+ strategy: 'referenceHidden'
163
+ }), dom_1.hide({
164
+ strategy: 'escaped'
165
+ })].filter(Boolean);
166
+ const placement = utils_1.toFloatingUIPlacement(align, position, isRtl);
131
167
  return {
132
- targetRef: setTarget,
133
- containerRef: setContainer,
134
- arrowRef: setArrow
168
+ placement,
169
+ middleware,
170
+ strategy
135
171
  };
172
+ }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy, overflowBoundaryPadding, fallbackPositions]);
136
173
  }
137
- function usePositioningOptions(options) {
138
- const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , overflowBoundaryPadding , fallbackPositions } = options;
139
- const { dir } = (0, _reactSharedContexts.useFluent_unstable)();
140
- const isRtl = dir === "rtl";
141
- const strategy = positionFixed ? "fixed" : "absolute";
142
- return _react.useCallback((container, arrow)=>{
143
- const hasScrollableElement = (0, _utils.hasScrollParent)(container);
144
- const middleware = [
145
- offset && (0, _middleware.offset)(offset),
146
- coverTarget && (0, _middleware.coverTarget)(),
147
- !pinned && (0, _middleware.flip)({
148
- container,
149
- flipBoundary,
150
- hasScrollableElement,
151
- isRtl,
152
- fallbackPositions
153
- }),
154
- (0, _middleware.shift)({
155
- container,
156
- hasScrollableElement,
157
- overflowBoundary,
158
- disableTether,
159
- overflowBoundaryPadding,
160
- isRtl
161
- }),
162
- autoSize && (0, _middleware.maxSize)(autoSize, {
163
- container,
164
- overflowBoundary
165
- }),
166
- (0, _middleware.intersecting)(),
167
- arrow && (0, _dom.arrow)({
168
- element: arrow,
169
- padding: arrowPadding
170
- }),
171
- (0, _dom.hide)({
172
- strategy: "referenceHidden"
173
- }),
174
- (0, _dom.hide)({
175
- strategy: "escaped"
176
- })
177
- ].filter(Boolean);
178
- const placement = (0, _utils.toFloatingUIPlacement)(align, position, isRtl);
179
- return {
180
- placement,
181
- middleware,
182
- strategy
183
- };
184
- }, [
185
- align,
186
- arrowPadding,
187
- autoSize,
188
- coverTarget,
189
- disableTether,
190
- flipBoundary,
191
- isRtl,
192
- offset,
193
- overflowBoundary,
194
- pinned,
195
- position,
196
- strategy,
197
- overflowBoundaryPadding,
198
- fallbackPositions
199
- ]);
200
- } //# sourceMappingURL=usePositioning.js.map
201
-
202
174
  //# 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 updatePosition: () => managerRef.current?.updatePosition(),\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 }), [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 const contentNode = containerRef.current;\n const treeWalker = 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 fallbackPositions\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 isRtl,\n fallbackPositions\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, fallbackPositions]);\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","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","useEffect","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","fallbackPositions","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,CAA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b;YACAH;QACF;IACF,GAAG;QAACjB;QAAOC;QAAcC;QAAUC;QAAaO;QAAeN;QAAcY;QAAOX;QAAQC;QAAkBC;QAAQC;QAAUS;QAAUL;QAAyBC;KAAkB;AACvL,EACA,0CAA0C"}
1
+ {"version":3,"names":["dom_1","require","react_shared_contexts_1","react_utilities_1","React","utils_1","middleware_1","createPositionManager_1","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","_a","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","exports","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","fallbackPositions","dir","useFluent_unstable","isRtl","strategy","hasScrollableElement","hasScrollParent","middleware","flip","shift","maxSize","intersecting","element","padding","hide","filter","Boolean","placement","toFloatingUIPlacement"],"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, Pick<PositioningOptions, 'fallbackPositions' | 'pinned'> {\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 fallbackPositions,\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, isRtl, fallbackPositions }),\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 fallbackPositions,\n ],\n );\n}\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA,MAAAC,uBAAA,gBAAAD,OAAA;AACA,MAAAE,iBAAA,gBAAAF,OAAA;AACA,MAAAG,KAAA,gBAAAH,OAAA;AAQA,MAAAI,OAAA,gBAAAJ,OAAA;AACA,MAAAK,YAAA,g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xD,SAAS;MACToD,oBAAoB;MACpBZ,gBAAgB;MAChBI,aAAa;MACbE,uBAAuB;MACvBI;KACD,CAAC,EACFd,QAAQ,IAAIzD,YAAA,CAAA8E,OAAiB,CAACrB,QAAQ,EAAE;MAAEpC,SAAS;MAAEwC;IAAgB,CAAE,CAAC,EACxE7D,YAAA,CAAA+E,YAAsB,EAAE,EACxBzD,KAAK,IAAI5B,KAAA,CAAA4B,KAAe,CAAC;MAAE0D,OAAO,EAAE1D,KAAK;MAAE2D,OAAO,EAAEzB;IAAY,CAAE,CAAC,EACnE9D,KAAA,CAAAwF,IAAc,CAAC;MAAEV,QAAQ,EAAE;IAAiB,CAAE,CAAC,EAC/C9E,KAAA,CAAAwF,IAAc,CAAC;MAAEV,QAAQ,EAAE;IAAS,CAAE,CAAC,CACxC,CAACW,MAAM,CAACC,OAAO,CAAiB;IAEjC,MAAMC,SAAS,GAAGtF,OAAA,CAAAuF,qBAAqB,CAAC/B,KAAK,EAAEQ,QAAQ,EAAEQ,KAAK,CAAC;IAE/D,OAAO;MACLc,SAAS;MACTV,UAAU;MACVH;KACD;EACH,CAAC,EACD,CACEjB,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRC,WAAW,EACXO,aAAa,EACbN,YAAY,EACZY,KAAK,EACLX,MAAM,EACNC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRS,QAAQ,EACRL,uBAAuB,EACvBC,iBAAiB,CAClB,CACF;AACH"}
@@ -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;IAC3D,MAAMK,wBAAwBC,CAAAA,QAAS;QACrC,IAAIA,UAAUC,aAAaD,UAAU,IAAI,EAAE;YACzCJ,kBAAkBK;YAClB;QACF,CAAC;QACD,IAAIC;QACJ,IAAI,CAAEF,CAAAA,iBAAiBG,UAAS,GAAI;YAClCD,aAAaF,MAAMI,WAAW;QAChC,OAAO;YACLF,aAAaF;QACf,CAAC;QACD,IAAI,CAAEE,CAAAA,sBAAsBC,UAAS,KAAME,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YAChF,sCAAsC;YACtCC,QAAQC,KAAK,CAAC;QAChB,CAAC;QACD,MAAMC,gBAAgBC,IAAAA,4DAA6B,EAACT;QACpDN,kBAAkBc;IACpB;IACA,OAAO;QAACf;QAAgBI;KAAsB;AAChD,GACA,qDAAqD"}
1
+ {"version":3,"names":["React","require","createVirtualElementFromClick_1","usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget","createVirtualElementFromClick","exports"],"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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,+BAAA,gBAAAD,OAAA;AAGA;;;;;;;;;AASO,MAAME,yBAAyB,GACpCC,YAA4E,IAC1E;EACF,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGN,KAAK,CAACO,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,+BAAA,CAAAkB,6BAA6B,CAACT,UAAU,CAAC;IAC/DL,iBAAiB,CAACa,aAAa,CAAC;EAClC,CAAC;EAED,OAAO,CAACd,cAAc,EAAEG,qBAAqB,CAAU;AACzD,CAAC;AA5BYa,OAAA,CAAAlB,yBAAyB,GAAAA,yBAAA"}
@@ -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,"names":["debounce","fn","pending","Promise","resolve","then","undefined","exports"],"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"],"mappings":";;;;;;AAAA;;;;;;AAMA,SAAgBA,QAAQA,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,OAAA,CAAAP,QAAA,GAAAA,QAAA"}