@fluentui/react-positioning 9.2.0 → 9.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,34 @@
2
2
  "name": "@fluentui/react-positioning",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 15 Sep 2022 09:44:38 GMT",
5
+ "date": "Thu, 13 Oct 2022 10:59:34 GMT",
6
+ "tag": "@fluentui/react-positioning_v9.2.1",
7
+ "version": "9.2.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "olfedias@microsoft.com",
12
+ "package": "@fluentui/react-positioning",
13
+ "commit": "1a527d440e0497ef8046b3ce240492241e7a04ac",
14
+ "comment": "chore: Update Griffel to latest version"
15
+ },
16
+ {
17
+ "author": "yuanboxue@microsoft.com",
18
+ "package": "@fluentui/react-positioning",
19
+ "commit": "16c7bcadf6f5a1f66dd8224f014ceee4c4800be3",
20
+ "comment": "fix `usePositioning` to reset `overrideTargetRef` when target in hook options is undefined"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-positioning",
25
+ "comment": "Bump @fluentui/react-utilities to v9.1.1",
26
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Thu, 15 Sep 2022 09:49:16 GMT",
6
33
  "tag": "@fluentui/react-positioning_v9.2.0",
7
34
  "version": "9.2.0",
8
35
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,23 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Thu, 15 Sep 2022 09:44:38 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 13 Oct 2022 10:59:34 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.2.1)
8
+
9
+ Thu, 13 Oct 2022 10:59:34 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.2.0..@fluentui/react-positioning_v9.2.1)
11
+
12
+ ### Patches
13
+
14
+ - chore: Update Griffel to latest version ([PR #25075](https://github.com/microsoft/fluentui/pull/25075) by olfedias@microsoft.com)
15
+ - fix `usePositioning` to reset `overrideTargetRef` when target in hook options is undefined ([PR #25135](https://github.com/microsoft/fluentui/pull/25135) by yuanboxue@microsoft.com)
16
+ - Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
17
+
7
18
  ## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.2.0)
8
19
 
9
- Thu, 15 Sep 2022 09:44:38 GMT
20
+ Thu, 15 Sep 2022 09:49:16 GMT
10
21
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.2..@fluentui/react-positioning_v9.2.0)
11
22
 
12
23
  ### Minor changes
@@ -103,9 +103,9 @@ export function usePositioning(options) {
103
103
  // eslint-disable-next-line react-hooks/exhaustive-deps
104
104
  []);
105
105
  useIsomorphicLayoutEffect(() => {
106
- if (options.target) {
107
- overrideTargetRef.current = options.target;
108
- }
106
+ var _a;
107
+
108
+ overrideTargetRef.current = (_a = options.target) !== null && _a !== void 0 ? _a : null;
109
109
  }, [options.target, overrideTargetRef, containerRef]);
110
110
  useIsomorphicLayoutEffect(() => {
111
111
  updatePosition();
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":"AAAA,SAAS,eAAT,EAA0B,IAAI,IAAI,cAAlC,EAAkD,KAAK,IAAI,eAA3D,QAAkF,kBAAlF;AAEA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,SAAT,EAAoB,yBAApB,QAAqD,2BAArD;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SACE,cADF,EAEE,qBAFF,EAGE,oBAHF,EAIE,kBAJF,EAK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S,CAAC,eAAV,CAA0B,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,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;AAED;;AAEG;;;AACH,SAAS,iBAAT,CAA2B,OAA3B,EAAiG;EAC/F,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","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 if (options.target) {\n overrideTargetRef.current = options.target;\n }\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,SAAS,eAAT,EAA0B,IAAI,IAAI,cAAlC,EAAkD,KAAK,IAAI,eAA3D,QAAkF,kBAAlF;AAEA,SAAS,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SAAS,SAAT,EAAoB,yBAApB,QAAqD,2BAArD;AACA,SAAS,gBAAT,QAAiC,2BAAjC;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SACE,cADF,EAEE,qBAFF,EAGE,oBAHF,EAIE,kBAJF,EAKE,QALF,EAME,eANF,QAOO,SAPP;AAQA,SACE,KAAK,I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S,CAAC,eAAV,CAA0B,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,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;AAED;;AAEG;;;AACH,SAAS,iBAAT,CAA2B,OAA3B,EAAiG;EAC/F,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","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/"}
@@ -118,9 +118,9 @@ function usePositioning(options) {
118
118
  // eslint-disable-next-line react-hooks/exhaustive-deps
119
119
  []);
120
120
  react_utilities_1.useIsomorphicLayoutEffect(() => {
121
- if (options.target) {
122
- overrideTargetRef.current = options.target;
123
- }
121
+ var _a;
122
+
123
+ overrideTargetRef.current = (_a = options.target) !== null && _a !== void 0 ? _a : null;
124
124
  }, [options.target, overrideTargetRef, containerRef]);
125
125
  react_utilities_1.useIsomorphicLayoutEffect(() => {
126
126
  updatePosition();
@@ -1 +1 @@
1
- {"version":3,"sources":["usePositioning.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAA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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 if (options.target) {\n overrideTargetRef.current = options.target;\n }\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,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAQA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AAQA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAOA;;AAEG;;;AACH,SAAgB,cAAhB,CACE,OADF,EACgC;EAa9B,MAAM;IAAE;EAAF,IAAqB,uBAAA,CAAA,kBAAA,EAA3B;EACA,MAAM;IAAE,OAAO,GAAG;EAAZ,IAAqB,OAA3B;EACA,MAAM,yBAAyB,GAAG,qBAAqB,CAAC,OAAD,CAAvD;EAEA,MAAM,WAAW,GAAG,iBAAA,CAAA,gBAAA,CAAiB,MAAK;;;IACxC,MAAM,MAAM,GAAG,CAAA,EAAA,GAAA,iBAAiB,CAAC,OAAlB,MAAyB,IAAzB,IAAyB,EAAA,KAAA,KAAA,CAAzB,GAAyB,EAAzB,GAA6B,SAAS,CAAC,OAAtD;;IACA,IAAI,CAAC,iBAAA,CAAA,SAAD,IAAc,CAAC,OAAf,IAA0B,CAAC,MAA3B,IAAqC,CAAC,YAAY,CAAC,OAAvD,EAAgE;MAC9D;IACD;;IAED,MAAM;MAAE,SAAF;MAAa,UAAb;MAAyB;IAAzB,IAAsC,yBAAyB,CACnE,MADmE,EAEnE,YAAY,CAAC,OAFs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BAAT,CAA2B,OAA3B,EAAiG;EAC/F,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","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/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "9.2.0",
3
+ "version": "9.2.1",
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",
@@ -31,8 +31,8 @@
31
31
  "@floating-ui/dom": "^1.0.0",
32
32
  "@fluentui/react-shared-contexts": "^9.0.1",
33
33
  "@fluentui/react-theme": "^9.1.0",
34
- "@fluentui/react-utilities": "^9.1.0",
35
- "@griffel/react": "^1.3.0",
34
+ "@fluentui/react-utilities": "^9.1.1",
35
+ "@griffel/react": "^1.4.0",
36
36
  "tslib": "^2.1.0"
37
37
  },
38
38
  "peerDependencies": {