@fluentui/react-positioning 9.2.1 → 9.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,+BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,+BAAA,CAAA,6BAAA;EAA6B;AAA7B,CAAA;;AACT,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,yBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,uBAAA;EAAuB;AAAvB,CAAA;AAAyB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,iBAAA;EAAiB;AAAjB,CAAA;;AAElC,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,cAAA;EAAc;AAAd,CAAA;;AACT,IAAA,2BAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,2BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,2BAAA,CAAA,yBAAA;EAAyB;AAAzB,CAAA;;AACT,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n} from './types';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,+BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,+BAAA,CAAA,6BAAA;EAA6B;AAA7B,CAAA;;AACT,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,yBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,uBAAA;EAAuB;AAAvB,CAAA;AAAyB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,iBAAA;EAAiB;AAAjB,CAAA;;AAElC,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,cAAA;EAAc;AAAd,CAAA;;AACT,IAAA,2BAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,2BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,2BAAA,CAAA,yBAAA;EAAyB;AAAzB,CAAA;;AACT,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"],"sourceRoot":"../src/"}
@@ -11,95 +11,57 @@ const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-con
11
11
 
12
12
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
13
 
14
- const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
15
-
16
14
  const React = /*#__PURE__*/require("react");
17
15
 
18
16
  const utils_1 = /*#__PURE__*/require("./utils");
19
17
 
20
18
  const middleware_1 = /*#__PURE__*/require("./middleware");
21
19
 
22
- const constants_1 = /*#__PURE__*/require("./constants");
20
+ const createPositionManager_1 = /*#__PURE__*/require("./createPositionManager");
23
21
  /**
24
22
  * @internal
25
23
  */
26
24
 
27
25
 
28
26
  function usePositioning(options) {
29
- const {
30
- targetDocument
31
- } = react_shared_contexts_1.useFluent_unstable();
27
+ const managerRef = React.useRef(null);
28
+ const targetRef = React.useRef(null);
29
+ const overrideTargetRef = React.useRef(null);
30
+ const containerRef = React.useRef(null);
31
+ const arrowRef = React.useRef(null);
32
32
  const {
33
33
  enabled = true
34
34
  } = options;
35
35
  const resolvePositioningOptions = usePositioningOptions(options);
36
- const forceUpdate = react_utilities_2.useEventCallback(() => {
36
+ const updatePositionManager = React.useCallback(() => {
37
37
  var _a;
38
38
 
39
- const target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
40
-
41
- if (!react_utilities_1.canUseDOM || !enabled || !target || !containerRef.current) {
42
- return;
39
+ if (managerRef.current) {
40
+ managerRef.current.dispose();
43
41
  }
44
42
 
45
- const {
46
- placement,
47
- middleware,
48
- strategy
49
- } = resolvePositioningOptions(target, containerRef.current, arrowRef.current); // Container is always initialized with `position: fixed` to avoid scroll jumps
50
- // Before computing the positioned coordinates, revert the container to the deisred positioning strategy
51
-
52
- Object.assign(containerRef.current.style, {
53
- position: strategy
54
- });
55
- dom_1.computePosition(target, containerRef.current, {
56
- placement,
57
- middleware,
58
- strategy
59
- }).then(({
60
- x,
61
- y,
62
- middlewareData,
63
- placement: computedPlacement
64
- }) => {
65
- var _a;
43
+ managerRef.current = null;
44
+ const target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
66
45
 
67
- writeArrowUpdates({
68
- arrow: arrowRef.current,
69
- middlewareData
70
- });
71
- writeContainerUpdates({
46
+ if (enabled && react_utilities_1.canUseDOM() && target && containerRef.current) {
47
+ managerRef.current = createPositionManager_1.createPositionManager({
72
48
  container: containerRef.current,
73
- middlewareData,
74
- placement: computedPlacement,
75
- coordinates: {
76
- x,
77
- y
78
- },
79
- lowPPI: (((_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.devicePixelRatio) || 1) <= 1,
80
- strategy
49
+ target,
50
+ arrow: arrowRef.current,
51
+ ...resolvePositioningOptions(containerRef.current, arrowRef.current)
81
52
  });
82
- }).catch(err => {
83
- // https://github.com/floating-ui/floating-ui/issues/1845
84
- // FIXME for node > 14
85
- // node 15 introduces promise rejection which means that any components
86
- // tests need to be `it('', async () => {})` otherwise there can be race conditions with
87
- // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist
88
- // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing
89
- // will actually be counter productive
90
- if (process.env.NODE_ENV === 'development') {
91
- // eslint-disable-next-line no-console
92
- console.error('[usePositioning]: Failed to calculate position', err);
93
- }
94
- });
95
- });
96
- const updatePosition = React.useState(() => utils_1.debounce(forceUpdate))[0];
97
- const targetRef = useTargetRef(updatePosition);
98
- const overrideTargetRef = useTargetRef(updatePosition);
99
- const containerRef = useContainerRef(updatePosition, enabled);
100
- const arrowRef = useArrowRef(updatePosition);
53
+ }
54
+ }, [enabled, resolvePositioningOptions]);
55
+ const setOverrideTarget = React.useCallback(target => {
56
+ overrideTargetRef.current = target;
57
+ updatePositionManager();
58
+ }, [updatePositionManager]);
101
59
  React.useImperativeHandle(options.positioningRef, () => ({
102
- updatePosition,
60
+ updatePosition: () => {
61
+ var _a;
62
+
63
+ return (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition();
64
+ },
103
65
  setTarget: target => {
104
66
  if (options.target && process.env.NODE_ENV !== 'production') {
105
67
  const err = new Error(); // eslint-disable-next-line no-console
@@ -109,35 +71,17 @@ function usePositioning(options) {
109
71
  console.warn(err.stack);
110
72
  }
111
73
 
112
- overrideTargetRef.current = target;
74
+ setOverrideTarget(target);
113
75
  }
114
- }), // Missing deps:
115
- // options.target - only used for a runtime warning
116
- // overrideTargetRef - Stable between renders
117
- // updatePosition - Stable between renders
118
- // eslint-disable-next-line react-hooks/exhaustive-deps
119
- []);
76
+ }), [options.target, setOverrideTarget]);
120
77
  react_utilities_1.useIsomorphicLayoutEffect(() => {
121
78
  var _a;
122
79
 
123
- overrideTargetRef.current = (_a = options.target) !== null && _a !== void 0 ? _a : null;
124
- }, [options.target, overrideTargetRef, containerRef]);
80
+ setOverrideTarget((_a = options.target) !== null && _a !== void 0 ? _a : null);
81
+ }, [options.target, setOverrideTarget]);
125
82
  react_utilities_1.useIsomorphicLayoutEffect(() => {
126
- updatePosition();
127
- }, [enabled, resolvePositioningOptions, updatePosition]); // Add window resize and scroll listeners to update position
128
-
129
- react_utilities_1.useIsomorphicLayoutEffect(() => {
130
- const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
131
-
132
- if (win) {
133
- win.addEventListener('resize', updatePosition);
134
- win.addEventListener('scroll', updatePosition);
135
- return () => {
136
- win.removeEventListener('resize', updatePosition);
137
- win.removeEventListener('scroll', updatePosition);
138
- };
139
- }
140
- }, [updatePosition, targetDocument]);
83
+ updatePositionManager();
84
+ }, [updatePositionManager]);
141
85
 
142
86
  if (process.env.NODE_ENV !== 'production') {
143
87
  // This checked should run only in development mode
@@ -165,10 +109,29 @@ function usePositioning(options) {
165
109
  }, []);
166
110
  }
167
111
 
112
+ const setTarget = utils_1.useCallbackRef(null, target => {
113
+ if (targetRef.current !== target) {
114
+ targetRef.current = target;
115
+ updatePositionManager();
116
+ }
117
+ });
118
+ const setContainer = utils_1.useCallbackRef(null, container => {
119
+ if (containerRef.current !== container) {
120
+ containerRef.current = container;
121
+ updatePositionManager();
122
+ }
123
+ });
124
+ const setArrow = utils_1.useCallbackRef(null, arrow => {
125
+ if (arrowRef.current !== arrow) {
126
+ arrowRef.current = arrow;
127
+ updatePositionManager();
128
+ }
129
+ }); // Let users use callback refs so they feel like 'normal' DOM refs
130
+
168
131
  return {
169
- targetRef,
170
- containerRef,
171
- arrowRef
132
+ targetRef: setTarget,
133
+ containerRef: setContainer,
134
+ arrowRef: setArrow
172
135
  };
173
136
  }
174
137
 
@@ -193,7 +156,7 @@ function usePositioningOptions(options) {
193
156
  } = react_shared_contexts_1.useFluent_unstable();
194
157
  const isRtl = dir === 'rtl';
195
158
  const strategy = positionFixed ? 'fixed' : 'absolute';
196
- return React.useCallback((target, container, arrow) => {
159
+ return React.useCallback((container, arrow) => {
197
160
  const hasScrollableElement = utils_1.hasScrollParent(container);
198
161
  const placement = utils_1.toFloatingUIPlacement(align, position, isRtl);
199
162
  const middleware = [offset && middleware_1.offset(offset), coverTarget && middleware_1.coverTarget(), !pinned && middleware_1.flip({
@@ -220,105 +183,4 @@ function usePositioningOptions(options) {
220
183
  };
221
184
  }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy]);
222
185
  }
223
-
224
- function useContainerRef(updatePosition, enabled) {
225
- return utils_1.useCallbackRef(null, (container, prevContainer) => {
226
- if (container && enabled) {
227
- // When the container is first resolved, set position `fixed` to avoid scroll jumps.
228
- // Without this scroll jumps can occur when the element is rendered initially and receives focus
229
- Object.assign(container.style, {
230
- position: 'fixed',
231
- left: 0,
232
- top: 0,
233
- margin: 0
234
- });
235
- }
236
-
237
- utils_1.toggleScrollListener(container, prevContainer, updatePosition);
238
- updatePosition();
239
- });
240
- }
241
-
242
- function useTargetRef(updatePosition) {
243
- return utils_1.useCallbackRef(null, (target, prevTarget) => {
244
- utils_1.toggleScrollListener(target, prevTarget, updatePosition);
245
- updatePosition();
246
- });
247
- }
248
-
249
- function useArrowRef(updatePosition) {
250
- return utils_1.useCallbackRef(null, updatePosition);
251
- }
252
- /**
253
- * Writes all DOM element updates after position is computed
254
- */
255
-
256
-
257
- function writeContainerUpdates(options) {
258
- var _a, _b;
259
-
260
- const {
261
- container,
262
- placement,
263
- middlewareData,
264
- strategy,
265
- lowPPI,
266
- coordinates: {
267
- x,
268
- y
269
- }
270
- } = options;
271
-
272
- if (!container) {
273
- return;
274
- }
275
-
276
- container.setAttribute(constants_1.DATA_POSITIONING_PLACEMENT, placement);
277
- container.removeAttribute(constants_1.DATA_POSITIONING_INTERSECTING);
278
-
279
- if (middlewareData.intersectionObserver.intersecting) {
280
- container.setAttribute(constants_1.DATA_POSITIONING_INTERSECTING, '');
281
- }
282
-
283
- container.removeAttribute(constants_1.DATA_POSITIONING_ESCAPED);
284
-
285
- if ((_a = middlewareData.hide) === null || _a === void 0 ? void 0 : _a.escaped) {
286
- container.setAttribute(constants_1.DATA_POSITIONING_ESCAPED, '');
287
- }
288
-
289
- container.removeAttribute(constants_1.DATA_POSITIONING_HIDDEN);
290
-
291
- if ((_b = middlewareData.hide) === null || _b === void 0 ? void 0 : _b.referenceHidden) {
292
- container.setAttribute(constants_1.DATA_POSITIONING_HIDDEN, '');
293
- }
294
-
295
- Object.assign(container.style, {
296
- transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
297
- position: strategy
298
- });
299
- }
300
- /**
301
- * Writes all DOM element updates after position is computed
302
- */
303
-
304
-
305
- function writeArrowUpdates(options) {
306
- const {
307
- arrow,
308
- middlewareData
309
- } = options;
310
-
311
- if (!middlewareData.arrow || !arrow) {
312
- return;
313
- }
314
-
315
- const {
316
- x: arrowX,
317
- y: arrowY
318
- } = middlewareData.arrow;
319
- Object.assign(arrow.style, {
320
- left: `${arrowX}px`,
321
- top: `${ar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IAAS;EAAT,IAA4B,OAAlC;;EACA,IAAI,CAAC,cAAc,CAAC,KAAhB,IAAyB,CAAC,KAA9B,EAAqC;IACnC;EACD;;EAED,MAAM;IAAE,CAAC,EAAE,MAAL;IAAa,CAAC,EAAE;EAAhB,IAA2B,cAAc,CAAC,KAAhD;EAEA,MAAM,CAAC,MAAP,CAAc,KAAK,CAAC,KAApB,EAA2B;IACzB,IAAI,EAAE,GAAG,MAAM,IADU;IAEzB,GAAG,EAAE,GAAG,MAAM;EAFW,CAA3B;AAID","sourcesContent":["import { computePosition, hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy, Placement, Coords, MiddlewareData } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { PositioningOptions, PositioningProps, PositioningVirtualElement } from './types';\nimport {\n useCallbackRef,\n toFloatingUIPlacement,\n toggleScrollListener,\n hasAutofocusFilter,\n debounce,\n hasScrollParent,\n} 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 {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_PLACEMENT,\n} from './constants';\n\n/**\n * @internal\n */\nexport function usePositioning(\n options: UsePositioningOptions,\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { targetDocument } = useFluent();\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n\n const forceUpdate = useEventCallback(() => {\n const target = overrideTargetRef.current ?? targetRef.current;\n if (!canUseDOM || !enabled || !target || !containerRef.current) {\n return;\n }\n\n const { placement, middleware, strategy } = resolvePositioningOptions(\n target,\n containerRef.current,\n arrowRef.current,\n );\n\n // Container is always initialized with `position: fixed` to avoid scroll jumps\n // Before computing the positioned coordinates, revert the container to the deisred positioning strategy\n Object.assign(containerRef.current.style, { position: strategy });\n computePosition(target, containerRef.current, { placement, middleware, strategy })\n .then(({ x, y, middlewareData, placement: computedPlacement }) => {\n writeArrowUpdates({ arrow: arrowRef.current, middlewareData });\n writeContainerUpdates({\n container: containerRef.current,\n middlewareData,\n placement: computedPlacement,\n coordinates: { x, y },\n lowPPI: (targetDocument?.defaultView?.devicePixelRatio || 1) <= 1,\n strategy,\n });\n })\n .catch(err => {\n // https://github.com/floating-ui/floating-ui/issues/1845\n // FIXME for node > 14\n // node 15 introduces promise rejection which means that any components\n // tests need to be `it('', async () => {})` otherwise there can be race conditions with\n // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist\n // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing\n // will actually be counter productive\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error('[usePositioning]: Failed to calculate position', err);\n }\n });\n });\n\n const updatePosition = React.useState(() => debounce(forceUpdate))[0];\n\n const targetRef = useTargetRef(updatePosition);\n const overrideTargetRef = useTargetRef(updatePosition);\n const containerRef = useContainerRef(updatePosition, enabled);\n const arrowRef = useArrowRef(updatePosition);\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition,\n setTarget: (target: HTMLElement | PositioningVirtualElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n overrideTargetRef.current = target;\n },\n }),\n // Missing deps:\n // options.target - only used for a runtime warning\n // overrideTargetRef - Stable between renders\n // updatePosition - Stable between renders\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n overrideTargetRef.current = options.target ?? null;\n }, [options.target, overrideTargetRef, containerRef]);\n\n useIsomorphicLayoutEffect(() => {\n updatePosition();\n }, [enabled, resolvePositioningOptions, updatePosition]);\n\n // Add window resize and scroll listeners to update position\n useIsomorphicLayoutEffect(() => {\n const win = targetDocument?.defaultView;\n if (win) {\n win.addEventListener('resize', updatePosition);\n win.addEventListener('scroll', updatePosition);\n\n return () => {\n win.removeEventListener('resize', updatePosition);\n win.removeEventListener('scroll', updatePosition);\n };\n }\n }, [updatePosition, targetDocument]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (\n target: HTMLElement | PositioningVirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n\nfunction useContainerRef(updatePosition: () => void, enabled: boolean) {\n return useCallbackRef<HTMLElement | null>(null, (container, prevContainer) => {\n if (container && enabled) {\n // When the container is first resolved, set position `fixed` to avoid scroll jumps.\n // Without this scroll jumps can occur when the element is rendered initially and receives focus\n Object.assign(container.style, { position: 'fixed', left: 0, top: 0, margin: 0 });\n }\n\n toggleScrollListener(container, prevContainer, updatePosition);\n\n updatePosition();\n });\n}\n\nfunction useTargetRef(updatePosition: () => void) {\n return useCallbackRef<HTMLElement | PositioningVirtualElement | null>(null, (target, prevTarget) => {\n toggleScrollListener(target, prevTarget, updatePosition);\n\n updatePosition();\n });\n}\n\nfunction useArrowRef(updatePosition: () => void) {\n return useCallbackRef<HTMLElement | null>(null, updatePosition);\n}\n\n/**\n * Writes all DOM element updates after position is computed\n */\nfunction writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const {\n container,\n placement,\n middlewareData,\n strategy,\n lowPPI,\n coordinates: { x, y },\n } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n\n/**\n * Writes all DOM element updates after position is computed\n */\nfunction writeArrowUpdates(options: { arrow: HTMLElement | null; middlewareData: MiddlewareData }) {\n const { arrow, middlewareData } = options;\n if (!middlewareData.arrow || !arrow) {\n return;\n }\n\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(arrow.style, {\n left: `${arrowX}px`,\n top: `${arrowY}px`,\n });\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAQA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AAQA,MAAA,uBAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAEA;;AAEG;;;AACH,SAAgB,cAAhB,CAA+B,OAA/B,EAA6D;EAC3D,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAqC,IAArC,CAAnB;EACA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAAlB;EACA,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAN,CAAmC,IAAnC,CAA1B;EACA,MAAM,YAAY,GAAG,KAAK,CAAC,MAAN,CAAiC,IAAjC,CAArB;EACA,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAiC,IAAjC,CAAjB;EAEA,MAAM;IAAE,OAAO,GAAG;EAAZ,IAAqB,OAA3B;EACA,MAAM,yBAAyB,GAAG,qBAAqB,CAAC,OAAD,CAAvD;EACA,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAN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AuBL,CACE,KADF,EAEE,YAFF,EAGE,QAHF,EAIE,WAJF,EAKE,aALF,EAME,YANF,EAOE,KAPF,EAQE,MARF,EASE,gBATF,EAUE,MAVF,EAWE,QAXF,EAYE,QAZF,CAvBK,CAAP;AAsCD","sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = React.useCallback(\n (target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n },\n [updatePositionManager],\n );\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement }),\n shiftMiddleware({ container, hasScrollableElement, overflowBoundary, disableTether }),\n autoSize && maxSizeMiddleware(autoSize),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n ],\n );\n}\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioningMouseTarget.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,MAAM,yBAAyB,GACpC,YADuC,IAErC;EACF,MAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAsD,YAAtD,CAA5C;;EAEA,MAAM,qBAAqB,GAAI,KAAD,IAA4D;IACxF,IAAI,KAAK,KAAK,SAAV,IAAuB,KAAK,KAAK,IAArC,EAA2C;MACzC,iBAAiB,CAAC,SAAD,CAAjB;MACA;IACD;;IAED,IAAI,UAAJ;;IACA,IAAI,EAAE,KAAK,YAAY,UAAnB,CAAJ,EAAoC;MAClC,UAAU,GAAG,KAAK,CAAC,WAAnB;IACD,CAFD,MAEO;MACL,UAAU,GAAG,KAAb;IACD;;IAED,IAAI,EAAE,UAAU,YAAY,UAAxB,KAAuC,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAApE,EAAkF;MAChF;MACA,OAAO,CAAC,KAAR,CAAc,+DAAd;IACD;;IAED,MAAM,aAAa,GAAG,+BAAA,CAAA,6BAAA,CAA8B,UAA9B,CAAtB;IACA,iBAAiB,CAAC,aAAD,CAAjB;EACD,CApBD;;EAsBA,OAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA5BM;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["usePositioningMouseTarget.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;AAGA;;;;;;;;AAQG;;;AACI,MAAM,yBAAyB,GACpC,YADuC,IAErC;EACF,MAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAsD,YAAtD,CAA5C;;EAEA,MAAM,qBAAqB,GAA0B,KAAK,IAAG;IAC3D,IAAI,KAAK,KAAK,SAAV,IAAuB,KAAK,KAAK,IAArC,EAA2C;MACzC,iBAAiB,CAAC,SAAD,CAAjB;MACA;IACD;;IAED,IAAI,UAAJ;;IACA,IAAI,EAAE,KAAK,YAAY,UAAnB,CAAJ,EAAoC;MAClC,UAAU,GAAG,KAAK,CAAC,WAAnB;IACD,CAFD,MAEO;MACL,UAAU,GAAG,KAAb;IACD;;IAED,IAAI,EAAE,UAAU,YAAY,UAAxB,KAAuC,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAApE,EAAkF;MAChF;MACA,OAAO,CAAC,KAAR,CAAc,+DAAd;IACD;;IAED,MAAM,aAAa,GAAG,+BAAA,CAAA,6BAAA,CAA8B,UAA9B,CAAtB;IACA,iBAAiB,CAAC,aAAD,CAAjB;EACD,CApBD;;EAsBA,OAAO,CAAC,cAAD,EAAiB,qBAAjB,CAAP;AACD,CA5BM;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget: SetVirtualMouseTarget = event => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"sourceRoot":"../src/"}
@@ -29,4 +29,8 @@ tslib_1.__exportStar(require("./debounce"), exports);
29
29
  tslib_1.__exportStar(require("./toggleScrollListener"), exports);
30
30
 
31
31
  tslib_1.__exportStar(require("./hasAutoFocusFilter"), exports);
32
+
33
+ tslib_1.__exportStar(require("./writeArrowUpdates"), exports);
34
+
35
+ tslib_1.__exportStar(require("./writeContainerupdates"), exports);
32
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './parseFloatingUIPlacement';\nexport * from './getBoundary';\nexport * from './getReactFiberFromNode';\nexport * from './getScrollParent';\nexport * from './mergeArrowOffset';\nexport * from './toFloatingUIPlacement';\nexport * from './fromFloatingUIPlacement';\nexport * from './resolvePositioningShorthand';\nexport * from './useCallbackRef';\nexport * from './debounce';\nexport * from './toggleScrollListener';\nexport * from './hasAutoFocusFilter';\nexport * from './writeArrowUpdates';\nexport * from './writeContainerupdates';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.writeArrowUpdates = void 0;
7
+ /**
8
+ * Writes all DOM element updates after position is computed
9
+ */
10
+
11
+ function writeArrowUpdates(options) {
12
+ const {
13
+ arrow,
14
+ middlewareData
15
+ } = options;
16
+
17
+ if (!middlewareData.arrow || !arrow) {
18
+ return;
19
+ }
20
+
21
+ const {
22
+ x: arrowX,
23
+ y: arrowY
24
+ } = middlewareData.arrow;
25
+ Object.assign(arrow.style, {
26
+ left: `${arrowX}px`,
27
+ top: `${arrowY}px`
28
+ });
29
+ }
30
+
31
+ exports.writeArrowUpdates = writeArrowUpdates;
32
+ //# sourceMappingURL=writeArrowUpdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/writeArrowUpdates.ts"],"names":[],"mappings":";;;;;;AAEA;;AAEG;;AACH,SAAgB,iBAAhB,CAAkC,OAAlC,EAAwG;EACtG,MAAM;IAAE,KAAF;IAAS;EAAT,IAA4B,OAAlC;;EACA,IAAI,CAAC,cAAc,CAAC,KAAhB,IAAyB,CAAC,KAA9B,EAAqC;IACnC;EACD;;EAED,MAAM;IAAE,CAAC,EAAE,MAAL;IAAa,CAAC,EAAE;EAAhB,IAA2B,cAAc,CAAC,KAAhD;EAEA,MAAM,CAAC,MAAP,CAAc,KAAK,CAAC,KAApB,EAA2B;IACzB,IAAI,EAAE,GAAG,MAAM,IADU;IAEzB,GAAG,EAAE,GAAG,MAAM;EAFW,CAA3B;AAID;;AAZD,OAAA,CAAA,iBAAA,GAAA,iBAAA","sourcesContent":["import { MiddlewareData } from '@floating-ui/dom';\n\n/**\n * Writes all DOM element updates after position is computed\n */\nexport function writeArrowUpdates(options: { arrow: HTMLElement | null; middlewareData: MiddlewareData }) {\n const { arrow, middlewareData } = options;\n if (!middlewareData.arrow || !arrow) {\n return;\n }\n\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(arrow.style, {\n left: `${arrowX}px`,\n top: `${arrowY}px`,\n });\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.writeContainerUpdates = void 0;
7
+
8
+ const constants_1 = /*#__PURE__*/require("../constants");
9
+ /**
10
+ * Writes all container element position updates after the position is computed
11
+ */
12
+
13
+
14
+ function writeContainerUpdates(options) {
15
+ var _a, _b;
16
+
17
+ const {
18
+ container,
19
+ placement,
20
+ middlewareData,
21
+ strategy,
22
+ lowPPI,
23
+ coordinates: {
24
+ x,
25
+ y
26
+ }
27
+ } = options;
28
+
29
+ if (!container) {
30
+ return;
31
+ }
32
+
33
+ container.setAttribute(constants_1.DATA_POSITIONING_PLACEMENT, placement);
34
+ container.removeAttribute(constants_1.DATA_POSITIONING_INTERSECTING);
35
+
36
+ if (middlewareData.intersectionObserver.intersecting) {
37
+ container.setAttribute(constants_1.DATA_POSITIONING_INTERSECTING, '');
38
+ }
39
+
40
+ container.removeAttribute(constants_1.DATA_POSITIONING_ESCAPED);
41
+
42
+ if ((_a = middlewareData.hide) === null || _a === void 0 ? void 0 : _a.escaped) {
43
+ container.setAttribute(constants_1.DATA_POSITIONING_ESCAPED, '');
44
+ }
45
+
46
+ container.removeAttribute(constants_1.DATA_POSITIONING_HIDDEN);
47
+
48
+ if ((_b = middlewareData.hide) === null || _b === void 0 ? void 0 : _b.referenceHidden) {
49
+ container.setAttribute(constants_1.DATA_POSITIONING_HIDDEN, '');
50
+ }
51
+
52
+ Object.assign(container.style, {
53
+ transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
54
+ position: strategy
55
+ });
56
+ }
57
+
58
+ exports.writeContainerUpdates = writeContainerUpdates;
59
+ //# sourceMappingURL=writeContainerupdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/writeContainerupdates.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;AAOA;;AAEG;;;AACH,SAAgB,qBAAhB,CAAsC,OAAtC,EAYC;;;EACC,MAAM;IACJ,SADI;IAEJ,SAFI;IAGJ,cAHI;IAIJ,QAJI;IAKJ,MALI;IAMJ,WAAW,EAAE;MAAE,CAAF;MAAK;IAAL;EANT,IAOF,OAPJ;;EAQA,IAAI,CAAC,SAAL,EAAgB;IACd;EACD;;EACD,SAAS,CAAC,YAAV,CAAuB,WAAA,CAAA,0BAAvB,EAAmD,SAAnD;EACA,SAAS,CAAC,eAAV,CAA0B,WAAA,CAAA,6BAA1B;;EACA,IAAI,cAAc,CAAC,oBAAf,CAAoC,YAAxC,EAAsD;IACpD,SAAS,CAAC,YAAV,CAAuB,WAAA,CAAA,6BAAvB,EAAsD,EAAtD;EACD;;EAED,SAAS,CAAC,eAAV,CAA0B,WAAA,CAAA,wBAA1B;;EACA,IAAI,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,KAAA,CAAnB,GAAmB,EAAA,CAAE,OAAzB,EAAkC;IAChC,SAAS,CAAC,YAAV,CAAuB,WAAA,CAAA,wBAAvB,EAAiD,EAAjD;EACD;;EAED,SAAS,CAAC,eAAV,CAA0B,WAAA,CAAA,uBAA1B;;EACA,IAAI,CAAA,EAAA,GAAA,cAAc,CAAC,IAAf,MAAmB,IAAnB,IAAmB,EAAA,KAAA,KAAA,CAAnB,GAAmB,KAAA,CAAnB,GAAmB,EAAA,CAAE,eAAzB,EAA0C;IACxC,SAAS,CAAC,YAAV,CAAuB,WAAA,CAAA,uBAAvB,EAAgD,EAAhD;EACD;;EAED,MAAM,CAAC,MAAP,CAAc,SAAS,CAAC,KAAxB,EAA+B;IAC7B,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,KAAzB,GAAiC,eAAe,CAAC,OAAO,CAAC,QAD7C;IAE7B,QAAQ,EAAE;EAFmB,CAA/B;AAID;;AA5CD,OAAA,CAAA,qBAAA,GAAA,qBAAA","sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const {\n container,\n placement,\n middlewareData,\n strategy,\n lowPPI,\n coordinates: { x, y },\n } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "9.2.1",
3
+ "version": "9.3.0",
4
4
  "description": "A react wrapper around Popper.js for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -29,17 +29,17 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@floating-ui/dom": "^1.0.0",
32
- "@fluentui/react-shared-contexts": "^9.0.1",
33
- "@fluentui/react-theme": "^9.1.0",
34
- "@fluentui/react-utilities": "^9.1.1",
35
- "@griffel/react": "^1.4.0",
32
+ "@fluentui/react-shared-contexts": "^9.1.0",
33
+ "@fluentui/react-theme": "^9.1.1",
34
+ "@fluentui/react-utilities": "^9.2.0",
35
+ "@griffel/react": "^1.4.2",
36
36
  "tslib": "^2.1.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@types/react": ">=16.8.0 <18.0.0",
40
- "@types/react-dom": ">=16.8.0 <18.0.0",
41
- "react": ">=16.8.0 <18.0.0",
42
- "react-dom": ">=16.8.0 <18.0.0"
39
+ "@types/react": ">=16.8.0 <19.0.0",
40
+ "@types/react-dom": ">=16.8.0 <19.0.0",
41
+ "react": ">=16.8.0 <19.0.0",
42
+ "react-dom": ">=16.8.0 <19.0.0"
43
43
  },
44
44
  "beachball": {
45
45
  "disallowedChangeTypes": [