@fluentui/react-positioning 9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 → 9.75.2-experimental.css-modules.20261113-ba13c87438.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +7 -7
  2. package/README.md +7 -130
  3. package/lib/Arrow.module.css +43 -0
  4. package/lib/PositioningConfigurationContext.js +2 -1
  5. package/lib/PositioningConfigurationContext.js.map +1 -1
  6. package/lib/createPositionManager.js +82 -74
  7. package/lib/createPositionManager.js.map +1 -1
  8. package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
  9. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +9 -0
  10. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +1 -0
  11. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +9 -0
  12. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +1 -0
  13. package/lib/middleware/flip.js +1 -1
  14. package/lib/middleware/flip.js.map +1 -1
  15. package/lib/middleware/intersecting.js +1 -1
  16. package/lib/middleware/intersecting.js.map +1 -1
  17. package/lib/middleware/maxSize.js +1 -1
  18. package/lib/middleware/maxSize.js.map +1 -1
  19. package/lib/middleware/offset.js +1 -1
  20. package/lib/middleware/offset.js.map +1 -1
  21. package/lib/middleware/shift.js +1 -1
  22. package/lib/middleware/shift.js.map +1 -1
  23. package/lib/usePositioning.js +48 -38
  24. package/lib/usePositioning.js.map +1 -1
  25. package/lib/usePositioningOptions.js +117 -25
  26. package/lib/usePositioningOptions.js.map +1 -1
  27. package/lib/utils/createResizeObserver.js +2 -2
  28. package/lib/utils/createResizeObserver.js.map +1 -1
  29. package/lib/utils/debounce.js +13 -6
  30. package/lib/utils/debounce.js.map +1 -1
  31. package/lib/utils/fromFloatingUIPlacement.js +29 -10
  32. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  33. package/lib/utils/getBoundary.js +17 -8
  34. package/lib/utils/getBoundary.js.map +1 -1
  35. package/lib/utils/index.js +2 -0
  36. package/lib/utils/index.js.map +1 -1
  37. package/lib/utils/listScrollParents.js +20 -12
  38. package/lib/utils/listScrollParents.js.map +1 -1
  39. package/lib/utils/normalizeAutoSize.js +22 -15
  40. package/lib/utils/normalizeAutoSize.js.map +1 -1
  41. package/lib/utils/toFloatingUIPlacement.js +26 -9
  42. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  43. package/lib/utils/useCallbackRef.js +10 -1
  44. package/lib/utils/useCallbackRef.js.map +1 -1
  45. package/lib/utils/writeArrowUpdates.js +13 -0
  46. package/lib/utils/writeArrowUpdates.js.map +1 -0
  47. package/lib/utils/writeContainerupdates.js +43 -0
  48. package/lib/utils/writeContainerupdates.js.map +1 -0
  49. package/lib-commonjs/Arrow.module.css +43 -0
  50. package/lib-commonjs/PositioningConfigurationContext.cjs +2 -1
  51. package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
  52. package/lib-commonjs/createPositionManager.cjs +80 -72
  53. package/lib-commonjs/createPositionManager.cjs.map +1 -1
  54. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
  55. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +20 -0
  56. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +1 -0
  57. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +20 -0
  58. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +1 -0
  59. package/lib-commonjs/middleware/flip.cjs +6 -6
  60. package/lib-commonjs/middleware/flip.cjs.map +1 -1
  61. package/lib-commonjs/middleware/intersecting.cjs +2 -2
  62. package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
  63. package/lib-commonjs/middleware/maxSize.cjs +4 -4
  64. package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
  65. package/lib-commonjs/middleware/offset.cjs +2 -2
  66. package/lib-commonjs/middleware/offset.cjs.map +1 -1
  67. package/lib-commonjs/middleware/shift.cjs +7 -7
  68. package/lib-commonjs/middleware/shift.cjs.map +1 -1
  69. package/lib-commonjs/usePositioning.cjs +46 -37
  70. package/lib-commonjs/usePositioning.cjs.map +1 -1
  71. package/lib-commonjs/usePositioningOptions.cjs +112 -24
  72. package/lib-commonjs/usePositioningOptions.cjs.map +1 -1
  73. package/lib-commonjs/utils/createResizeObserver.cjs +2 -2
  74. package/lib-commonjs/utils/createResizeObserver.cjs.map +1 -1
  75. package/lib-commonjs/utils/debounce.cjs +13 -6
  76. package/lib-commonjs/utils/debounce.cjs.map +1 -1
  77. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs +32 -21
  78. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
  79. package/lib-commonjs/utils/getBoundary.cjs +17 -8
  80. package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
  81. package/lib-commonjs/utils/index.cjs +8 -0
  82. package/lib-commonjs/utils/index.cjs.map +1 -1
  83. package/lib-commonjs/utils/listScrollParents.cjs +20 -12
  84. package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
  85. package/lib-commonjs/utils/normalizeAutoSize.cjs +25 -26
  86. package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
  87. package/lib-commonjs/utils/toFloatingUIPlacement.cjs +27 -13
  88. package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
  89. package/lib-commonjs/utils/useCallbackRef.cjs +9 -1
  90. package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
  91. package/lib-commonjs/utils/writeArrowUpdates.cjs +23 -0
  92. package/lib-commonjs/utils/writeArrowUpdates.cjs.map +1 -0
  93. package/lib-commonjs/utils/writeContainerupdates.cjs +51 -0
  94. package/lib-commonjs/utils/writeContainerupdates.cjs.map +1 -0
  95. package/package.json +9 -5
  96. package/lib/engine/computePosition.js +0 -258
  97. package/lib/engine/computePosition.js.map +0 -1
  98. package/lib/engine/index.js +0 -260
  99. package/lib/engine/index.js.map +0 -1
  100. package/lib/engine/platform.js +0 -209
  101. package/lib/engine/platform.js.map +0 -1
  102. package/lib/usePositioning.raster.js +0 -45
  103. package/lib/usePositioning.raster.js.map +0 -1
  104. package/lib-commonjs/engine/computePosition.cjs +0 -265
  105. package/lib-commonjs/engine/computePosition.cjs.map +0 -1
  106. package/lib-commonjs/engine/index.cjs +0 -290
  107. package/lib-commonjs/engine/index.cjs.map +0 -1
  108. package/lib-commonjs/engine/platform.cjs +0 -264
  109. package/lib-commonjs/engine/platform.cjs.map +0 -1
  110. package/lib-commonjs/usePositioning.raster.cjs +0 -49
  111. package/lib-commonjs/usePositioning.raster.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- <!-- This log was last generated on Tue, 03 Nov 2026 14:18:06 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Fri, 13 Nov 2026 20:36:55 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [9.75.1-experimental.positioning-engine.20261103-19efe125d1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0)
7
+ ## [9.75.2-experimental.css-modules.20261113-ba13c87438.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.75.2-experimental.css-modules.20261113-ba13c87438.0)
8
8
 
9
- Tue, 03 Nov 2026 14:18:06 GMT
9
+ Fri, 13 Nov 2026 20:36:55 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Release 9.75.1-experimental.positioning-engine.20261103-19efe125d1 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
- - Bump @fluentui/react-shared-contexts to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
- - Bump @fluentui/react-theme to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
- - Bump @fluentui/react-utilities to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
13
+ - Release 9.75.2-experimental.css-modules.20261113-ba13c87438 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
+ - Bump @fluentui/react-shared-contexts to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-theme to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+ - Bump @fluentui/react-utilities to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
17
 
18
18
  ## [9.23.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.23.4)
19
19
 
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # @fluentui/react-positioning
2
2
 
3
- React utilities for positioning elements in the DOM, using a standalone JavaScript engine.
4
- The fallback preserves the existing Floating UI-based hook's placement and configuration semantics
5
- without importing the Floating UI engine at runtime.
3
+ A React utilities built on top of [Floating UI](https://floating-ui.com/) for positioning elements in the DOM.
4
+
5
+ ## CSS arrow asset
6
+
7
+ The opt-in `@fluentui/react-positioning/arrow.module.css` export requires a CSS
8
+ Modules loader. It is excluded from Are the Types Wrong's JavaScript entry-point
9
+ checks in `.attw.json`; the package's JavaScript exports remain checked.
6
10
 
7
11
  ## Usage
8
12
 
@@ -25,130 +29,3 @@ const PopupExample: React.FC = ({ children }) => {
25
29
  );
26
30
  };
27
31
  ```
28
-
29
- ## Browser behavior contracts
30
-
31
- `src/usePositioning.geometry.cy.tsx` exercises the public hook with real DOM layout and the
32
- unmocked positioning engine. Run it through the existing component-test target:
33
-
34
- ```sh
35
- yarn nx run react-positioning:e2e --spec=src/usePositioning.geometry.cy.tsx --browser=electron --config=retries=0
36
- ```
37
-
38
- The committed expectations in `src/usePositioning.geometry-baseline.cy.ts` were captured from
39
- master baseline `f626209351609e43bc98eb8cc1296273faa679b7` using Cypress 14.4.1 / Electron 130
40
- at an 800-by-600 viewport. They pin exact CSS-pixel rectangles, placement, strategy, transform
41
- serialization, left/top, maximum sizes, arrow coordinates, visibility attributes, match-target
42
- CSS variable, and overflow styles. No tolerance or engine-derived expected coordinates are used.
43
- The baseline helper only expands literal expected values. Engine replacements must pass these
44
- expectations, not regenerate them.
45
-
46
- For fractional DPR cases with transforms disabled, only rectangle x/y are compared to an
47
- engine-free sibling positioned with the committed literal left/top values. Native layout
48
- quantization is host-dependent: Electron 130 lays out `280.667px` at `280.6640625` on the
49
- original macOS host but at `280.65625` on Linux CI. Both are distinct from device-pixel rounding
50
- performed by the engine. The sibling runs no positioning logic and never reads engine output;
51
- all inline styles, dimensions, placement, and other fields remain exact literal assertions.
52
- The original rectangle snapshots are retained as provenance, not regenerated for each host.
53
- Negative-control tests at DPR 1.5 and 3 reject a `0.001px` left/top change even when native
54
- layout produces the same rectangle, and reject displaced rectangles with unchanged left/top.
55
-
56
- Coverage includes the finite 4-position by 5-alignment by 2-direction matrix (including invalid
57
- axis combinations), edge flips, ordered fallbacks and best fit, pinned shifting, tether options,
58
- shift-to-cover limits, number/object/function offsets, arrows, rectangular/element/intersected
59
- element-array/window/scroll/clipping boundaries, independent flip/overflow boundaries, logical
60
- padding, auto-size aliases, target-width matching, target covering, containing-block scaling and
61
- transforms, virtual targets, and fractional rectangles at DPR 1, 1.25, 1.5, 2, and 3. DPR is
62
- controlled independently of the host display; geometry and the engine are never mocked.
63
- Scrollbars are hidden without disabling scrolling so native scrollbar widths do not alter the fixture.
64
- The fixture includes a scoped `::-webkit-scrollbar` rule for the older Chromium bundled with
65
- Cypress 13 in React 17 compatibility tests, which does not support `scrollbar-width`.
66
-
67
- Lifecycle cases cover imperative updates and retargeting, target prop removal, option removal,
68
- enable/disable, resize and scroll updates, visibility recovery, native end events, detached
69
- container cleanup, idle behavior, and inline end callbacks that update React state. A safety cap
70
- on the state-updating callback makes an update loop fail without hanging the browser.
71
-
72
- These are geometry contracts, not screenshot rasterization baselines or a claim of every
73
- possible combination. Font rasterization, browser zoom, native high-DPI capture, cross-browser
74
- layout differences and native visual-viewport/mobile behavior are not
75
- covered. The explicit `strategy: 'absolute'` case deliberately records the existing baseline's
76
- `fixed` result; changing that behavior requires a separate intentional compatibility decision.
77
-
78
- `src/usePositioning.regressions.cy.tsx` adds focused real-browser checks for individual CSS
79
- transforms, shadow-host containing blocks and clipping, boxless overflow ancestors, fixed
80
- surfaces inside absolute wrappers, and bordered/padded/scaled same-origin iframe references.
81
- It also covers boolean/all disabled-tether limiting, assigned-slot ancestry, SVG virtual-reference
82
- clipping, viewport-propagated body overflow, top-layer popovers and modal dialogs and their
83
- descendants, and positioned `display: contents` ancestors in scrolled documents.
84
- These cases compare against Floating UI where supported. Individual transform properties predate
85
- support in the pinned oracle, so those cases instead assert physical target/surface alignment.
86
-
87
- ## Engine parity, size and performance validation
88
-
89
- The engine measures in containing-block CSS pixels and resolves matching, offsets, covering,
90
- best-fit flipping, shifting/tethering, available-size constraints, arrows, and visibility in order.
91
- Positioning callbacks and imperative refs do not recreate the manager on callback-only rerenders.
92
-
93
- ```sh
94
- yarn nx run react-positioning:bundle-size --skip-nx-cache
95
- yarn nx run react-positioning:test-bundle-size
96
- yarn nx run react-positioning:test-raster
97
- yarn nx run react-positioning:benchmark
98
- yarn nx run react-positioning:test-webkit
99
- ```
100
-
101
- The bundle gate runs the repository's monosize/webpack measurement for the existing
102
- `bundle-size/usePopper.fixture.js` entry, labeled `usePositioning`, and rejects an actual
103
- minified output larger than **12,000 bytes**. This is an absolute, uncompressed limit; gzip
104
- is reported separately. Gate tests cover the inclusive limit and invalid or stale measurements.
105
-
106
- The WebKit target runs focused real-browser checks for filtered ancestors and nested
107
- top-layer surfaces. Filter cases preserve the pinned Floating UI WebKit exception; nested
108
- top-layer cases assert physical layout, including containment by the top-layer ancestor itself.
109
- It requires the workspace's Playwright WebKit browser installation.
110
- It also compares fixed/absolute positioning, containing blocks, and rectangular boundaries
111
- against Floating UI with controlled visual-viewport offsets. Element geometry remains real;
112
- the viewport metrics are emulated, so these checks do not replace native pinch-zoom/pan testing.
113
-
114
- The package is compiled to ES2019, so the engine avoids optional chaining and nullish coalescing
115
- in hot paths (they are lowered to verbose helpers), prefers expression-bodied helpers, and keeps
116
- DOM traversal in one place (`src/engine/platform.ts`) that the scroll-parent listing reuses.
117
-
118
- The raster target extracts the unchanged lower-PR source from
119
- `788e3b739fe79246a2f8850d1c575cf4018fd744` into a temporary directory, then runs the same
120
- contracts against that implementation and the replacement in Electron. A paint-only wrapper
121
- makes otherwise transparent fixtures visible without changing their layout. It compares every
122
- decoded RGBA pixel, including antialiasing, and writes its report to
123
- `dist/positioning-raster/comparison.json`. It does not update the pinned geometry expectations.
124
- This is bounded fixture coverage on the same browser and host display, not a guarantee of all
125
- option combinations, fonts, browsers, iframe/shadow-root targets, or mobile visual viewports.
126
-
127
- The performance target mounts 24 concurrent positioning instances per engine in the same Electron
128
- browser and compares against the unchanged Floating UI implementation from upstream lower PR
129
- `fca219991ed9e907b01274bd89ac1431e51c573a`.
130
- It mounts only one engine at a time, warms up both engines, randomizes workload order, and randomizes
131
- which engine runs first in every pair, including initialization. The inactive engine is unmounted
132
- and its listeners are disposed before timing, so global events cannot contaminate the other
133
- engine's samples. The mix includes flips/fallbacks, explicit boundaries, arrows, offsets, and
134
- autosizing. It measures completion through the actual `usePositioning` end-event path; setup is
135
- excluded from update timings, while initialization intentionally includes mount-to-all-positioned.
136
-
137
- Every workload runs in two layouts:
138
-
139
- - `flat`: targets are fixed children of the body, the cheapest case for ancestor traversal.
140
- - `nested`: targets are 12 levels deep inside a scroll container and surfaces are portaled to the
141
- end of the document, the common application shape. It exercises clipping, containing-block and
142
- scroll-parent traversal, and its `scroll` workload dispatches element scroll events that reach
143
- the managers through their scroll-parent listeners rather than the window listener.
144
-
145
- Each layout records paired initialization, imperative, scroll, and window-resize completion
146
- times. The script reports per-workload median, p95, p10/p90 and coefficient of variation for both
147
- engines, and the paired replacement/oracle ratios as a geometric mean with a seeded bootstrap 95%
148
- confidence interval (an interval entirely below 1 means the replacement is faster on that host).
149
- It enforces complete, finite, nonzero samples but intentionally has no machine-dependent
150
- performance pass/fail threshold. Run it on the same host/browser for meaningful comparisons.
151
- Set `POSITIONING_BENCH_SEED` to reproduce or vary the randomized order. The full samples,
152
- statistics and browser/machine metadata (including whether the engine had uncommitted changes)
153
- are written to `dist/positioning-perf/benchmark.json`, and a Markdown table for pull request
154
- descriptions to `dist/positioning-perf/summary.md`.
@@ -0,0 +1,43 @@
1
+ /* stylelint-disable fluentui/use-logical-properties -- Arrow rotation and Popper placement coordinates are physical in RTL, like createArrowStyles' @noflip values. */
2
+ .arrow {
3
+ box-sizing: border-box;
4
+ position: absolute;
5
+ z-index: -1;
6
+ background-color: inherit;
7
+ background-clip: content-box;
8
+ border-bottom-left-radius: var(--borderRadiusSmall);
9
+ transform: rotate(var(--fui-positioning-arrow-angle));
10
+ height: var(--fui-positioning-arrow-height);
11
+ width: var(--fui-positioning-arrow-height);
12
+
13
+ &::before {
14
+ content: '';
15
+ display: block;
16
+ background-color: inherit;
17
+ margin: calc(-1 * var(--fui-positioning-arrow-border-width, var(--strokeWidthThin)));
18
+ width: 100%;
19
+ height: 100%;
20
+ border: var(--fui-positioning-arrow-border-width, var(--strokeWidthThin))
21
+ var(--fui-positioning-arrow-border-style, solid)
22
+ var(--fui-positioning-arrow-border-color, var(--colorTransparentStroke));
23
+ border-bottom-left-radius: var(--borderRadiusSmall);
24
+ clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
25
+ }
26
+ }
27
+
28
+ :global([data-popper-placement^='top']) .arrow {
29
+ bottom: var(--fui-positioning-arrow-offset);
30
+ --fui-positioning-arrow-angle: -45deg;
31
+ }
32
+ :global([data-popper-placement^='right']) .arrow {
33
+ left: var(--fui-positioning-arrow-offset);
34
+ --fui-positioning-arrow-angle: 45deg;
35
+ }
36
+ :global([data-popper-placement^='bottom']) .arrow {
37
+ top: var(--fui-positioning-arrow-offset);
38
+ --fui-positioning-arrow-angle: 135deg;
39
+ }
40
+ :global([data-popper-placement^='left']) .arrow {
41
+ right: var(--fui-positioning-arrow-offset);
42
+ --fui-positioning-arrow-angle: 225deg;
43
+ }
@@ -12,5 +12,6 @@ const PositioningConfigurationContext = React.createContext(undefined);
12
12
  * Accepts a function that takes the positioning options and returns them modified.
13
13
  */ export const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;
14
14
  export const usePositioningConfiguration = ()=>{
15
- return React.useContext(PositioningConfigurationContext) || DEFAULT_CONFIGURATION;
15
+ var _React_useContext;
16
+ return (_React_useContext = React.useContext(PositioningConfigurationContext)) !== null && _React_useContext !== void 0 ? _React_useContext : DEFAULT_CONFIGURATION;
16
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) || DEFAULT_CONFIGURATION;\n};\n"],"names":["React","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","createContext","undefined","PositioningConfigurationProvider","Provider","usePositioningConfiguration","useContext"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAG/B,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,kCAAkCH,MAAMI,aAAa,CAAyCC;AAEpG;;;;CAIC,GACD,OAAO,MAAMC,mCAAmCH,gCAAgCI,QAAQ,CAAC;AAEzF,OAAO,MAAMC,8BAA8B;IACzC,OAAOR,MAAMS,UAAU,CAACN,oCAAoCF;AAC9D,EAAE"}
1
+ {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["React","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","createContext","undefined","PositioningConfigurationProvider","Provider","usePositioningConfiguration","useContext"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAG/B,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,kCAAkCH,MAAMI,aAAa,CAAyCC;AAEpG;;;;CAIC,GACD,OAAO,MAAMC,mCAAmCH,gCAAgCI,QAAQ,CAAC;AAEzF,OAAO,MAAMC,8BAA8B;QAClCR;IAAP,QAAOA,oBAAAA,MAAMS,UAAU,CAACN,8CAAjBH,+BAAAA,oBAAqDC;AAC9D,EAAE"}
@@ -1,54 +1,39 @@
1
- import { computePosition } from "./engine/computePosition.js";
2
- import { getWindow, px } from "./engine/platform.js";
1
+ import { computePosition } from "@floating-ui/dom";
3
2
  import { isHTMLElement } from "@fluentui/react-utilities";
4
- import { debounce } from "./utils/index.js";
3
+ import { debounce, writeArrowUpdates, writeContainerUpdates } from "./utils/index.js";
5
4
  import { listScrollParents } from "./utils/listScrollParents.js";
6
- import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INTERSECTING, DATA_POSITIONING_PLACEMENT, POSITIONING_END_EVENT } from "./constants.js";
5
+ import { POSITIONING_END_EVENT } from "./constants.js";
7
6
  import { createResizeObserver } from "./utils/createResizeObserver.js";
7
+ function isLayoutViewportUnavailable(container) {
8
+ const { clientWidth, clientHeight } = container.ownerDocument.documentElement;
9
+ return clientWidth === 0 && clientHeight === 0;
10
+ }
8
11
  /**
9
12
  * @internal
10
13
  * @returns manager that handles positioning out of the react lifecycle
11
- */ export function createPositionManager(managerOptions) {
14
+ */ export function createPositionManager(options) {
12
15
  let isDestroyed = false;
13
- const { container, target, arrow, strategy, options = {} } = managerOptions;
14
- // Modifies whether the container is positioned using transform
15
- const { useTransform = true, disableUpdateOnResize } = options;
16
- const targetWindow = getWindow(container);
17
- // Containers of documents without a window (e.g. `DOMParser`) can't be positioned
18
- if (!targetWindow) {
19
- const noop = ()=>undefined;
16
+ const { container, target, arrow, strategy, middleware, placement, useTransform = true, disableUpdateOnResize = false } = options;
17
+ const targetWindow = container.ownerDocument.defaultView;
18
+ if (!target || !container || !targetWindow) {
20
19
  return {
21
- updatePosition: noop,
22
- dispose: noop
20
+ updatePosition: ()=>undefined,
21
+ dispose: ()=>undefined
23
22
  };
24
23
  }
25
- // When the dimensions of the target or the container change - trigger a position update,
26
- // unless disabled by the `disableUpdateOnResize` option
24
+ // When the dimensions of the target or the container change - trigger a position update
27
25
  const resizeObserver = disableUpdateOnResize ? null : createResizeObserver(targetWindow, (entries)=>{
28
26
  // If content rect dimensions to go 0 -> very likely that `display: none` is being used to hide the element
29
27
  // In this case don't update and let users update imperatively
30
- if (entries.every((entry)=>entry.contentRect.width > 0 && entry.contentRect.height > 0)) {
28
+ const shouldUpdateOnResize = entries.every((entry)=>{
29
+ return entry.contentRect.width > 0 && entry.contentRect.height > 0;
30
+ });
31
+ if (shouldUpdateOnResize) {
31
32
  updatePosition();
32
33
  }
33
34
  });
34
35
  let isFirstUpdate = true;
35
- // The window and the scroll parents of the container and the target, the target is only observed
36
- // when it is an element as virtual elements are not part of the DOM
37
- const scrollTargets = new Set([
38
- targetWindow
39
- ]);
40
- const elements = isHTMLElement(target) ? [
41
- container,
42
- target
43
- ] : [
44
- container
45
- ];
46
- const listenToScroll = (scrollTarget)=>{
47
- scrollTargets.add(scrollTarget);
48
- scrollTarget.addEventListener('scroll', updatePosition, {
49
- passive: true
50
- });
51
- };
36
+ const scrollParents = new Set();
52
37
  // When the container is first resolved, set position `fixed` to avoid scroll jumps.
53
38
  // Without this scroll jumps can occur when the element is rendered initially and receives focus
54
39
  Object.assign(container.style, {
@@ -64,52 +49,68 @@ import { createResizeObserver } from "./utils/createResizeObserver.js";
64
49
  return;
65
50
  }
66
51
  if (isFirstUpdate) {
67
- elements.forEach((element)=>{
68
- listScrollParents(element).forEach(listenToScroll);
69
- resizeObserver && resizeObserver.observe(element);
52
+ listScrollParents(container).forEach((scrollParent)=>scrollParents.add(scrollParent));
53
+ if (isHTMLElement(target)) {
54
+ listScrollParents(target).forEach((scrollParent)=>scrollParents.add(scrollParent));
55
+ }
56
+ scrollParents.forEach((scrollParent)=>{
57
+ scrollParent.addEventListener('scroll', updatePosition, {
58
+ passive: true
59
+ });
70
60
  });
61
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container);
62
+ if (isHTMLElement(target)) {
63
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(target);
64
+ }
71
65
  isFirstUpdate = false;
72
66
  }
73
- container.style.position = strategy;
74
- computePosition(target, container, managerOptions).then(({ x, y, placement, arrow: arrowCoordinates, intersecting, escaped, referenceHidden })=>{
67
+ Object.assign(container.style, {
68
+ position: strategy
69
+ });
70
+ computePosition(target, container, {
71
+ placement,
72
+ middleware,
73
+ strategy
74
+ }).then(({ x, y, middlewareData, placement: computedPlacement })=>{
75
+ var _ref, _ref1;
76
+ var _positioningMiddlewareData_hide, _positioningMiddlewareData_hide1;
75
77
  // Promise can still resolve after destruction
76
78
  // early return to avoid applying outdated position
77
79
  if (isDestroyed) {
78
80
  return;
79
81
  }
80
- if (arrow && arrowCoordinates) {
81
- Object.assign(arrow.style, {
82
- left: px(arrowCoordinates.x),
83
- top: px(arrowCoordinates.y)
84
- });
85
- }
86
- container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);
87
- container.toggleAttribute(DATA_POSITIONING_INTERSECTING, intersecting);
88
- container.toggleAttribute(DATA_POSITIONING_ESCAPED, escaped);
89
- container.toggleAttribute(DATA_POSITIONING_HIDDEN, referenceHidden);
90
- // Round so that the coordinates land on device pixels.
91
- // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other
92
- // effects like `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
93
- // See https://github.com/microsoft/fluentui/issues/26764 for more info.
94
- const devicePixelRatio = targetWindow.devicePixelRatio || 1;
95
- const left = px(Math.round(x * devicePixelRatio) / devicePixelRatio);
96
- const top = px(Math.round(y * devicePixelRatio) / devicePixelRatio);
97
- Object.assign(container.style, useTransform ? {
98
- // Layer acceleration can disable subpixel rendering which causes slightly
99
- // blurry text on low PPI displays, so we want to use 2D transforms instead
100
- transform: devicePixelRatio <= 1 ? `translate(${left}, ${top})` : `translate3d(${left}, ${top}, 0)`
101
- } : {
102
- left,
103
- top
82
+ const positioningMiddlewareData = isLayoutViewportUnavailable(container) ? {
83
+ ...middlewareData,
84
+ hide: {
85
+ ...middlewareData.hide,
86
+ escaped: false,
87
+ referenceHidden: false
88
+ }
89
+ } : middlewareData;
90
+ writeArrowUpdates({
91
+ arrow,
92
+ middlewareData: positioningMiddlewareData
93
+ });
94
+ writeContainerUpdates({
95
+ container,
96
+ middlewareData: positioningMiddlewareData,
97
+ placement: computedPlacement,
98
+ coordinates: {
99
+ x,
100
+ y
101
+ },
102
+ lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,
103
+ strategy,
104
+ useTransform
104
105
  });
105
106
  container.dispatchEvent(new CustomEvent(POSITIONING_END_EVENT, {
106
107
  detail: {
107
108
  // Cast from Floating UI's Placement to the Fluent-owned PositioningPlacement.
108
109
  // These are equivalent string unions; the cast avoids leaking @floating-ui/dom
109
110
  // types into the public API surface.
110
- placement: placement,
111
- escaped,
112
- referenceHidden
111
+ placement: computedPlacement,
112
+ escaped: (_ref = (_positioningMiddlewareData_hide = positioningMiddlewareData.hide) === null || _positioningMiddlewareData_hide === void 0 ? void 0 : _positioningMiddlewareData_hide.escaped) !== null && _ref !== void 0 ? _ref : false,
113
+ referenceHidden: (_ref1 = (_positioningMiddlewareData_hide1 = positioningMiddlewareData.hide) === null || _positioningMiddlewareData_hide1 === void 0 ? void 0 : _positioningMiddlewareData_hide1.referenceHidden) !== null && _ref1 !== void 0 ? _ref1 : false
113
114
  }
114
115
  }));
115
116
  }).catch((err)=>{
@@ -126,18 +127,25 @@ import { createResizeObserver } from "./utils/createResizeObserver.js";
126
127
  }
127
128
  });
128
129
  };
129
- const updatePosition = debounce(forceUpdate);
130
+ const updatePosition = debounce(()=>forceUpdate());
130
131
  const dispose = ()=>{
131
132
  isDestroyed = true;
132
- targetWindow.removeEventListener('resize', updatePosition);
133
- scrollTargets.forEach((scrollTarget)=>{
134
- scrollTarget.removeEventListener('scroll', updatePosition);
133
+ if (targetWindow) {
134
+ targetWindow.removeEventListener('scroll', updatePosition);
135
+ targetWindow.removeEventListener('resize', updatePosition);
136
+ }
137
+ scrollParents.forEach((scrollParent)=>{
138
+ scrollParent.removeEventListener('scroll', updatePosition);
135
139
  });
136
- scrollTargets.clear();
137
- resizeObserver && resizeObserver.disconnect();
140
+ scrollParents.clear();
141
+ resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
138
142
  };
139
- listenToScroll(targetWindow);
140
- targetWindow.addEventListener('resize', updatePosition);
143
+ if (targetWindow) {
144
+ targetWindow.addEventListener('scroll', updatePosition, {
145
+ passive: true
146
+ });
147
+ targetWindow.addEventListener('resize', updatePosition);
148
+ }
141
149
  // Update the position on initialization
142
150
  updatePosition();
143
151
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from './engine/computePosition';\nimport { getWindow, px } from './engine/platform';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport type {\n OnPositioningEndEventDetail,\n PositionManager,\n PositioningOptions,\n PositioningPlacement,\n TargetElement,\n} from './types';\nimport { debounce } from './utils';\nimport { listScrollParents } from './utils/listScrollParents';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n POSITIONING_END_EVENT,\n} from './constants';\nimport { createResizeObserver } from './utils/createResizeObserver';\n\ninterface PositionManagerOptions {\n /**\n * The positioned element\n */\n container: HTMLElement;\n /**\n * Element that the container will be anchored to\n */\n target: TargetElement;\n /**\n * Arrow that points from the container to the target\n */\n arrow: HTMLElement | null;\n /**\n * The value of the css `position` property\n * @default absolute\n */\n strategy: Strategy;\n /**\n * [Floating UI middleware](https://floating-ui.com/docs/middleware)\n */\n middleware?: Middleware[];\n /** Positioning options resolved by the configuration context */\n options?: PositioningOptions;\n isRtl?: boolean;\n /**\n * [Floating UI placement](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: Placement;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(managerOptions: PositionManagerOptions): PositionManager {\n let isDestroyed = false;\n const { container, target, arrow, strategy, options = {} } = managerOptions;\n // Modifies whether the container is positioned using transform\n const { useTransform = true, disableUpdateOnResize } = options;\n const targetWindow = getWindow(container) as (Window & typeof globalThis) | null;\n // Containers of documents without a window (e.g. `DOMParser`) can't be positioned\n if (!targetWindow) {\n const noop = () => undefined;\n return { updatePosition: noop, dispose: noop };\n }\n\n // When the dimensions of the target or the container change - trigger a position update,\n // unless disabled by the `disableUpdateOnResize` option\n const resizeObserver = disableUpdateOnResize\n ? null\n : createResizeObserver(targetWindow, entries => {\n // If content rect dimensions to go 0 -> very likely that `display: none` is being used to hide the element\n // In this case don't update and let users update imperatively\n if (entries.every(entry => entry.contentRect.width > 0 && entry.contentRect.height > 0)) {\n updatePosition();\n }\n });\n\n let isFirstUpdate = true;\n // The window and the scroll parents of the container and the target, the target is only observed\n // when it is an element as virtual elements are not part of the DOM\n const scrollTargets = new Set<EventTarget>([targetWindow]);\n const elements = isHTMLElement(target) ? [container, target] : [container];\n const listenToScroll = (scrollTarget: EventTarget) => {\n scrollTargets.add(scrollTarget);\n scrollTarget.addEventListener('scroll', updatePosition, { passive: true });\n };\n\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 const forceUpdate = () => {\n // debounced update can still occur afterwards\n // early return to avoid memory leaks\n if (isDestroyed) {\n return;\n }\n\n if (isFirstUpdate) {\n elements.forEach(element => {\n listScrollParents(element).forEach(listenToScroll);\n resizeObserver && resizeObserver.observe(element);\n });\n\n isFirstUpdate = false;\n }\n\n container.style.position = strategy;\n computePosition(target, container, managerOptions)\n .then(({ x, y, placement, arrow: arrowCoordinates, intersecting, escaped, referenceHidden }) => {\n // Promise can still resolve after destruction\n // early return to avoid applying outdated position\n if (isDestroyed) {\n return;\n }\n\n if (arrow && arrowCoordinates) {\n Object.assign(arrow.style, { left: px(arrowCoordinates.x), top: px(arrowCoordinates.y) });\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.toggleAttribute(DATA_POSITIONING_INTERSECTING, intersecting);\n container.toggleAttribute(DATA_POSITIONING_ESCAPED, escaped);\n container.toggleAttribute(DATA_POSITIONING_HIDDEN, referenceHidden);\n\n // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other\n // effects like `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = targetWindow.devicePixelRatio || 1;\n const left = px(Math.round(x * devicePixelRatio) / devicePixelRatio);\n const top = px(Math.round(y * devicePixelRatio) / devicePixelRatio);\n Object.assign(\n container.style,\n useTransform\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 instead\n transform: devicePixelRatio <= 1 ? `translate(${left}, ${top})` : `translate3d(${left}, ${top}, 0)`,\n }\n : { left, top },\n );\n\n container.dispatchEvent(\n new CustomEvent<OnPositioningEndEventDetail>(POSITIONING_END_EVENT, {\n detail: {\n // Cast from Floating UI's Placement to the Fluent-owned PositioningPlacement.\n // These are equivalent string unions; the cast avoids leaking @floating-ui/dom\n // types into the public API surface.\n placement: placement satisfies PositioningPlacement,\n escaped,\n referenceHidden,\n },\n }),\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 = debounce(forceUpdate);\n\n const dispose = () => {\n isDestroyed = true;\n\n targetWindow.removeEventListener('resize', updatePosition);\n scrollTargets.forEach(scrollTarget => {\n scrollTarget.removeEventListener('scroll', updatePosition);\n });\n scrollTargets.clear();\n\n resizeObserver && resizeObserver.disconnect();\n };\n\n listenToScroll(targetWindow);\n targetWindow.addEventListener('resize', updatePosition);\n\n // Update the position on initialization\n updatePosition();\n\n return {\n updatePosition,\n dispose,\n };\n}\n"],"names":["computePosition","getWindow","px","isHTMLElement","debounce","listScrollParents","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT","createResizeObserver","createPositionManager","managerOptions","isDestroyed","container","target","arrow","strategy","options","useTransform","disableUpdateOnResize","targetWindow","noop","undefined","updatePosition","dispose","resizeObserver","entries","every","entry","contentRect","width","height","isFirstUpdate","scrollTargets","Set","elements","listenToScroll","scrollTarget","add","addEventListener","passive","Object","assign","style","position","left","top","margin","forceUpdate","forEach","element","observe","then","x","y","placement","arrowCoordinates","intersecting","escaped","referenceHidden","setAttribute","toggleAttribute","devicePixelRatio","Math","round","transform","dispatchEvent","CustomEvent","detail","catch","err","process","env","NODE_ENV","console","error","removeEventListener","clear","disconnect"],"mappings":"AAAA,SAASA,eAAe,QAAQ,8BAA2B;AAC3D,SAASC,SAAS,EAAEC,EAAE,QAAQ,uBAAoB;AAElD,SAASC,aAAa,QAAQ,4BAA4B;AAQ1D,SAASC,QAAQ,QAAQ,mBAAU;AACnC,SAASC,iBAAiB,QAAQ,+BAA4B;AAC9D,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,qBAAqB,QAChB,iBAAc;AACrB,SAASC,oBAAoB,QAAQ,kCAA+B;AAiCpE;;;CAGC,GACD,OAAO,SAASC,sBAAsBC,cAAsC;IAC1E,IAAIC,cAAc;IAClB,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC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BACXG;oBACAC;gBACF;YACF;QAEJ,GACCU,KAAK,CAACC,CAAAA;YACL,yDAAyD;YACzD,sBAAsB;YACtB,uEAAuE;YACvE,wFAAwF;YACxF,4GAA4G;YAC5G,0GAA0G;YAC1G,sCAAsC;YACtC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;gBAC1C,sCAAsC;gBACtCC,QAAQC,KAAK,CAAC,kDAAkDL;YAClE;QACF;IACJ;IAEA,MAAM/C,iBAAiBrB,SAAS8C;IAEhC,MAAMxB,UAAU;QACdZ,cAAc;QAEdQ,aAAawD,mBAAmB,CAAC,UAAUrD;QAC3CU,cAAcgB,OAAO,CAACZ,CAAAA;YACpBA,aAAauC,mBAAmB,CAAC,UAAUrD;QAC7C;QACAU,cAAc4C,KAAK;QAEnBpD,kBAAkBA,eAAeqD,UAAU;IAC7C;IAEA1C,eAAehB;IACfA,aAAamB,gBAAgB,CAAC,UAAUhB;IAExC,wCAAwC;IACxCA;IAEA,OAAO;QACLA;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport type { OnPositioningEndEventDetail, PositionManager, PositioningPlacement, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates } from './utils';\nimport { listScrollParents } from './utils/listScrollParents';\nimport { POSITIONING_END_EVENT } from './constants';\nimport { createResizeObserver } from './utils/createResizeObserver';\n\ninterface PositionManagerOptions {\n /**\n * The positioned element\n */\n container: HTMLElement;\n /**\n * Element that the container will be anchored to\n */\n target: TargetElement;\n /**\n * Arrow that points from the container to the target\n */\n arrow: HTMLElement | null;\n /**\n * The value of the css `position` property\n * @default absolute\n */\n strategy: Strategy;\n /**\n * [Floating UI middleware](https://floating-ui.com/docs/middleware)\n */\n middleware: Middleware[];\n /**\n * [Floating UI placement](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: Placement;\n /**\n * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n}\n\nfunction isLayoutViewportUnavailable(container: HTMLElement): boolean {\n const { clientWidth, clientHeight } = container.ownerDocument.documentElement;\n\n return clientWidth === 0 && clientHeight === 0;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n let isDestroyed = false;\n const {\n container,\n target,\n arrow,\n strategy,\n middleware,\n placement,\n useTransform = true,\n disableUpdateOnResize = false,\n } = options;\n const targetWindow = container.ownerDocument.defaultView;\n if (!target || !container || !targetWindow) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n // When the dimensions of the target or the container change - trigger a position update\n const resizeObserver = disableUpdateOnResize\n ? null\n : createResizeObserver(targetWindow, entries => {\n // If content rect dimensions to go 0 -> very likely that `display: none` is being used to hide the element\n // In this case don't update and let users update imperatively\n const shouldUpdateOnResize = entries.every(entry => {\n return entry.contentRect.width > 0 && entry.contentRect.height > 0;\n });\n\n if (shouldUpdateOnResize) {\n updatePosition();\n }\n });\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\n\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 const forceUpdate = () => {\n // debounced update can still occur afterwards\n // early return to avoid memory leaks\n if (isDestroyed) {\n return;\n }\n\n if (isFirstUpdate) {\n listScrollParents(container).forEach(scrollParent => scrollParents.add(scrollParent));\n if (isHTMLElement(target)) {\n listScrollParents(target).forEach(scrollParent => scrollParents.add(scrollParent));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition, { passive: true });\n });\n\n resizeObserver?.observe(container);\n if (isHTMLElement(target)) {\n resizeObserver?.observe(target);\n }\n\n isFirstUpdate = false;\n }\n\n Object.assign(container.style, { position: strategy });\n computePosition(target, container, { placement, middleware, strategy })\n .then(({ x, y, middlewareData, placement: computedPlacement }) => {\n // Promise can still resolve after destruction\n // early return to avoid applying outdated position\n if (isDestroyed) {\n return;\n }\n\n const positioningMiddlewareData = isLayoutViewportUnavailable(container)\n ? {\n ...middlewareData,\n hide: { ...middlewareData.hide, escaped: false, referenceHidden: false },\n }\n : middlewareData;\n\n writeArrowUpdates({ arrow, middlewareData: positioningMiddlewareData });\n writeContainerUpdates({\n container,\n middlewareData: positioningMiddlewareData,\n placement: computedPlacement,\n coordinates: { x, y },\n lowPPI: (targetWindow?.devicePixelRatio || 1) <= 1,\n strategy,\n useTransform,\n });\n\n container.dispatchEvent(\n new CustomEvent<OnPositioningEndEventDetail>(POSITIONING_END_EVENT, {\n detail: {\n // Cast from Floating UI's Placement to the Fluent-owned PositioningPlacement.\n // These are equivalent string unions; the cast avoids leaking @floating-ui/dom\n // types into the public API surface.\n placement: computedPlacement satisfies PositioningPlacement,\n escaped: positioningMiddlewareData.hide?.escaped ?? false,\n referenceHidden: positioningMiddlewareData.hide?.referenceHidden ?? false,\n },\n }),\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 = debounce(() => forceUpdate());\n\n const dispose = () => {\n isDestroyed = true;\n\n if (targetWindow) {\n targetWindow.removeEventListener('scroll', updatePosition);\n targetWindow.removeEventListener('resize', updatePosition);\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.removeEventListener('scroll', updatePosition);\n });\n scrollParents.clear();\n\n resizeObserver?.disconnect();\n };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition, { passive: true });\n targetWindow.addEventListener('resize', updatePosition);\n }\n\n // Update the position on initialization\n updatePosition();\n\n return {\n updatePosition,\n dispose,\n };\n}\n"],"names":["computePosition","isHTMLElement","debounce","writeArrowUpdates","writeContainerUpdates","listScrollParents","POSITIONING_END_EVENT","createResizeObserver","isLayoutViewportUnavailable","container","clientWidth","clientHeight","ownerDocument","documentElement","createPositionManager","options","isDestroyed","target","arrow","strategy","middleware","placement","useTransform","disableUpdateOnResize","targetWindow","defaultView","updatePosition","undefined","dispose","resizeObserver","entries","shouldUpdateOnResize","every","entry","contentRect","width","height","isFirstUpdate","scrollParents","Set","Object","assign","style","position","left","top","margin","forceUpdate","forEach","scrollParent","add","addEventListener","passive","observe","then","x","y","middlewareData","computedPlacement","positioningMiddlewareData","hide","escaped","referenceHidden","coordinates","lowPPI","devicePixelRatio","dispatchEvent","CustomEvent","detail","catch","err","process","env","NODE_ENV","console","error","removeEventListener","clear","disconnect"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,aAAa,QAAQ,4BAA4B;AAE1D,SAASC,QAAQ,EAAEC,iBAAiB,EAAEC,qBAAqB,QAAQ,mBAAU;AAC7E,SAASC,iBAAiB,QAAQ,+BAA4B;AAC9D,SAASC,qBAAqB,QAAQ,iBAAc;AACpD,SAASC,oBAAoB,QAAQ,kCAA+B;AAuCpE,SAASC,4BAA4BC,SAAsB;IACzD,MAAM,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGF,UAAUG,aAAa,CAACC,eAAe;IAE7E,OAAOH,gBAAgB,KAAKC,iBAAiB;AAC/C;AAEA;;;CAGC,GACD,OAAO,SAASG,sBAAsBC,OAA+B;IACnE,IAAIC,cAAc;IAClB,MAAM,EACJP,SAAS,EACTQ,MAAM,EACN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tC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;gBAC1C,sCAAsC;gBACtCC,QAAQC,KAAK,CAAC,kDAAkDL;YAClE;QACF;IACJ;IAEA,MAAM5C,iBAAiBxB,SAAS,IAAM6C;IAEtC,MAAMnB,UAAU;QACdZ,cAAc;QAEd,IAAIQ,cAAc;YAChBA,aAAaoD,mBAAmB,CAAC,UAAUlD;YAC3CF,aAAaoD,mBAAmB,CAAC,UAAUlD;QAC7C;QAEAY,cAAcU,OAAO,CAACC,CAAAA;YACpBA,aAAa2B,mBAAmB,CAAC,UAAUlD;QAC7C;QACAY,cAAcuC,KAAK;QAEnBhD,2BAAAA,qCAAAA,eAAgBiD,UAAU;IAC5B;IAEA,IAAItD,cAAc;QAChBA,aAAa2B,gBAAgB,CAAC,UAAUzB,gBAAgB;YAAE0B,SAAS;QAAK;QACxE5B,aAAa2B,gBAAgB,CAAC,UAAUzB;IAC1C;IAEA,wCAAwC;IACxCA;IAEA,OAAO;QACLA;QACAE;IACF;AACF"}
@@ -0,0 +1,26 @@
1
+ .wrapper {
2
+ display: none;
3
+ height: 0;
4
+ width: 0;
5
+ pointer-events: none;
6
+ }
7
+ .wrapperActive {
8
+ display: block;
9
+ }
10
+ .svg {
11
+ fill: transparent;
12
+ pointer-events: none;
13
+ position: fixed;
14
+ top: 0;
15
+ inset-inline-start: 0;
16
+ }
17
+ .safeZone {
18
+ pointer-events: auto;
19
+ }
20
+ .safeZoneDebug {
21
+ cursor: crosshair;
22
+ fill: color-mix(in srgb, var(--colorPaletteGreenBackground3) 20%, transparent);
23
+ }
24
+ .rectDebug {
25
+ fill: color-mix(in srgb, var(--colorPaletteRedBackground3) 20%, transparent);
26
+ }
@@ -0,0 +1,9 @@
1
+ import styles from "./SafeZoneArea.module.css";
2
+ export const useStyles = ()=>({
3
+ wrapper: styles.wrapper,
4
+ wrapperActive: styles.wrapperActive,
5
+ svg: styles.svg,
6
+ safeZone: styles.safeZone,
7
+ safeZoneDebug: styles.safeZoneDebug,
8
+ rectDebug: styles.rectDebug
9
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useSafeZoneArea/SafeZoneArea.styles.css.ts"],"sourcesContent":["import styles from './SafeZoneArea.module.css';\n\nexport const useStyles = (): Record<\n 'wrapper' | 'wrapperActive' | 'svg' | 'safeZone' | 'safeZoneDebug' | 'rectDebug',\n string\n> => ({\n wrapper: styles.wrapper,\n wrapperActive: styles.wrapperActive,\n svg: styles.svg,\n safeZone: styles.safeZone,\n safeZoneDebug: styles.safeZoneDebug,\n rectDebug: styles.rectDebug,\n});\n"],"names":["styles","useStyles","wrapper","wrapperActive","svg","safeZone","safeZoneDebug","rectDebug"],"mappings":"AAAA,OAAOA,YAAY,4BAA4B;AAE/C,OAAO,MAAMC,YAAY,IAGnB,CAAA;QACJC,SAASF,OAAOE,OAAO;QACvBC,eAAeH,OAAOG,aAAa;QACnCC,KAAKJ,OAAOI,GAAG;QACfC,UAAUL,OAAOK,QAAQ;QACzBC,eAAeN,OAAOM,aAAa;QACnCC,WAAWP,OAAOO,SAAS;IAC7B,CAAA,EAAG"}
@@ -0,0 +1,9 @@
1
+ import styles from "./SafeZoneArea.module.css";
2
+ export const useStyles = ()=>({
3
+ wrapper: styles.wrapper,
4
+ wrapperActive: styles.wrapperActive,
5
+ svg: styles.svg,
6
+ safeZone: styles.safeZone,
7
+ safeZoneDebug: styles.safeZoneDebug,
8
+ rectDebug: styles.rectDebug
9
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useSafeZoneArea/SafeZoneArea.styles.css.ts"],"sourcesContent":["import styles from './SafeZoneArea.module.css';\n\nexport const useStyles = (): Record<\n 'wrapper' | 'wrapperActive' | 'svg' | 'safeZone' | 'safeZoneDebug' | 'rectDebug',\n string\n> => ({\n wrapper: styles.wrapper,\n wrapperActive: styles.wrapperActive,\n svg: styles.svg,\n safeZone: styles.safeZone,\n safeZoneDebug: styles.safeZoneDebug,\n rectDebug: styles.rectDebug,\n});\n"],"names":["styles","useStyles","wrapper","wrapperActive","svg","safeZone","safeZoneDebug","rectDebug"],"mappings":"AAAA,OAAOA,YAAY,4BAA4B;AAE/C,OAAO,MAAMC,YAAY,IAGnB,CAAA;QACJC,SAASF,OAAOE,OAAO;QACvBC,eAAeH,OAAOG,aAAa;QACnCC,KAAKJ,OAAOI,GAAG;QACfC,UAAUL,OAAOK,QAAQ;QACzBC,eAAeN,OAAOM,aAAa;QACnCC,WAAWP,OAAOO,SAAS;IAC7B,CAAA,EAAG"}
@@ -1,4 +1,4 @@
1
- import { flip as baseFlip } from "../engine/index.js";
1
+ import { flip as baseFlip } from "@floating-ui/dom";
2
2
  import { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from "../utils/index.js";
3
3
  export function flip(options) {
4
4
  const { hasScrollableElement, flipBoundary, container, fallbackPositions = [], isRtl } = options;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/middleware/flip.ts"],"sourcesContent":["import type { Placement, Middleware } from '@floating-ui/dom';\nimport { flip as baseFlip } from '../engine';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';\n\nexport interface FlipMiddlewareOptions extends Pick<PositioningOptions, 'flipBoundary' | 'fallbackPositions'> {\n hasScrollableElement?: boolean;\n container: HTMLElement | null;\n isRtl?: boolean;\n}\n\nexport function flip(options: FlipMiddlewareOptions): Middleware {\n const { hasScrollableElement, flipBoundary, container, fallbackPositions = [], isRtl } = options;\n\n const fallbackPlacements = fallbackPositions.reduce<Placement[]>((acc, shorthand) => {\n const { position, align } = resolvePositioningShorthand(shorthand);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n if (placement) {\n acc.push(placement);\n }\n return acc;\n }, []);\n\n return baseFlip({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(flipBoundary && { altBoundary: true, boundary: getBoundary(container, flipBoundary) }),\n fallbackStrategy: 'bestFit',\n ...(fallbackPlacements.length && { fallbackPlacements }),\n });\n}\n"],"names":["flip","baseFlip","getBoundary","resolvePositioningShorthand","toFloatingUIPlacement","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","placement","push","boundary","altBoundary","fallbackStrategy","length"],"mappings":"AACA,SAASA,QAAQC,QAAQ,QAAQ,qBAAY;AAE7C,SAASC,WAAW,EAAEC,2BAA2B,EAAEC,qBAAqB,QAAQ,oBAAiB;AAQjG,OAAO,SAASJ,KAAKK,OAA8B;IACjD,MAAM,EAAEC,oBAAoB,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,EAAE,EAAEC,KAAK,EAAE,GAAGL;IAEzF,MAAMM,qBAAqBF,kBAAkBG,MAAM,CAAc,CAACC,KAAKC;QACrE,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGb,4BAA4BW;QACxD,MAAMG,YAAYb,sBAAsBY,OAAOD,UAAUL;QACzD,IAAIO,WAAW;YACbJ,IAAIK,IAAI,CAACD;QACX;QACA,OAAOJ;IACT,GAAG,EAAE;IAEL,OAAOZ,SAAS;QACd,GAAIK,wBAAwB;YAAEa,UAAU;QAAoB,CAAC;QAC7D,GAAIZ,gBAAgB;YAAEa,aAAa;YAAMD,UAAUjB,YAAYM,WAAWD;QAAc,CAAC;QACzFc,kBAAkB;QAClB,GAAIV,mBAAmBW,MAAM,IAAI;YAAEX;QAAmB,CAAC;IACzD;AACF"}
1
+ {"version":3,"sources":["../../src/middleware/flip.ts"],"sourcesContent":["import type { Placement, Middleware } from '@floating-ui/dom';\nimport { flip as baseFlip } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';\n\nexport interface FlipMiddlewareOptions extends Pick<PositioningOptions, 'flipBoundary' | 'fallbackPositions'> {\n hasScrollableElement?: boolean;\n container: HTMLElement | null;\n isRtl?: boolean;\n}\n\nexport function flip(options: FlipMiddlewareOptions): Middleware {\n const { hasScrollableElement, flipBoundary, container, fallbackPositions = [], isRtl } = options;\n\n const fallbackPlacements = fallbackPositions.reduce<Placement[]>((acc, shorthand) => {\n const { position, align } = resolvePositioningShorthand(shorthand);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n if (placement) {\n acc.push(placement);\n }\n return acc;\n }, []);\n\n return baseFlip({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(flipBoundary && { altBoundary: true, boundary: getBoundary(container, flipBoundary) }),\n fallbackStrategy: 'bestFit',\n ...(fallbackPlacements.length && { fallbackPlacements }),\n });\n}\n"],"names":["flip","baseFlip","getBoundary","resolvePositioningShorthand","toFloatingUIPlacement","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","placement","push","boundary","altBoundary","fallbackStrategy","length"],"mappings":"AACA,SAASA,QAAQC,QAAQ,QAAQ,mBAAmB;AAEpD,SAASC,WAAW,EAAEC,2BAA2B,EAAEC,qBAAqB,QAAQ,oBAAiB;AAQjG,OAAO,SAASJ,KAAKK,OAA8B;IACjD,MAAM,EAAEC,oBAAoB,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,EAAE,EAAEC,KAAK,EAAE,GAAGL;IAEzF,MAAMM,qBAAqBF,kBAAkBG,MAAM,CAAc,CAACC,KAAKC;QACrE,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGb,4BAA4BW;QACxD,MAAMG,YAAYb,sBAAsBY,OAAOD,UAAUL;QACzD,IAAIO,WAAW;YACbJ,IAAIK,IAAI,CAACD;QACX;QACA,OAAOJ;IACT,GAAG,EAAE;IAEL,OAAOZ,SAAS;QACd,GAAIK,wBAAwB;YAAEa,UAAU;QAAoB,CAAC;QAC7D,GAAIZ,gBAAgB;YAAEa,aAAa;YAAMD,UAAUjB,YAAYM,WAAWD;QAAc,CAAC;QACzFc,kBAAkB;QAClB,GAAIV,mBAAmBW,MAAM,IAAI;YAAEX;QAAmB,CAAC;IACzD;AACF"}
@@ -1,4 +1,4 @@
1
- import { detectOverflow } from "../engine/index.js";
1
+ import { detectOverflow } from "@floating-ui/dom";
2
2
  export function intersecting() {
3
3
  return {
4
4
  name: 'intersectionObserver',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/middleware/intersecting.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { detectOverflow } from '../engine';\n\nexport function intersecting(): Middleware {\n return {\n name: 'intersectionObserver',\n fn: async middlewareArguments => {\n const floatingRect = middlewareArguments.rects.floating;\n const altOverflow = await detectOverflow(middlewareArguments, { altBoundary: true });\n\n const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;\n const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;\n\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n\n return {\n data: {\n intersecting: isIntersecting,\n },\n };\n },\n };\n}\n"],"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"mappings":"AACA,SAASA,cAAc,QAAQ,qBAAY;AAE3C,OAAO,SAASC;IACd,OAAO;QACLC,MAAM;QACNC,IAAI,OAAMC;YACR,MAAMC,eAAeD,oBAAoBE,KAAK,CAACC,QAAQ;YACvD,MAAMC,cAAc,MAAMR,eAAeI,qBAAqB;gBAAEK,aAAa;YAAK;YAElF,MAAMC,oBAAoBF,YAAYG,GAAG,GAAGN,aAAaO,MAAM,IAAIJ,YAAYG,GAAG,GAAG;YACrF,MAAME,uBAAuBL,YAAYM,MAAM,GAAGT,aAAaO,MAAM,IAAIJ,YAAYM,MAAM,GAAG;YAE9F,MAAMC,iBAAiBL,qBAAqBG;YAE5C,OAAO;gBACLG,MAAM;oBACJf,cAAcc;gBAChB;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/middleware/intersecting.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { detectOverflow } from '@floating-ui/dom';\n\nexport function intersecting(): Middleware {\n return {\n name: 'intersectionObserver',\n fn: async middlewareArguments => {\n const floatingRect = middlewareArguments.rects.floating;\n const altOverflow = await detectOverflow(middlewareArguments, { altBoundary: true });\n\n const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;\n const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;\n\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n\n return {\n data: {\n intersecting: isIntersecting,\n },\n };\n },\n };\n}\n"],"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"mappings":"AACA,SAASA,cAAc,QAAQ,mBAAmB;AAElD,OAAO,SAASC;IACd,OAAO;QACLC,MAAM;QACNC,IAAI,OAAMC;YACR,MAAMC,eAAeD,oBAAoBE,KAAK,CAACC,QAAQ;YACvD,MAAMC,cAAc,MAAMR,eAAeI,qBAAqB;gBAAEK,aAAa;YAAK;YAElF,MAAMC,oBAAoBF,YAAYG,GAAG,GAAGN,aAAaO,MAAM,IAAIJ,YAAYG,GAAG,GAAG;YACrF,MAAME,uBAAuBL,YAAYM,MAAM,GAAGT,aAAaO,MAAM,IAAIJ,YAAYM,MAAM,GAAG;YAE9F,MAAMC,iBAAiBL,qBAAqBG;YAE5C,OAAO;gBACLG,MAAM;oBACJf,cAAcc;gBAChB;YACF;QACF;IACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { size } from "../engine/index.js";
1
+ import { size } from "@floating-ui/dom";
2
2
  import { getBoundary } from "../utils/getBoundary.js";
3
3
  import { toFloatingUIPadding } from "../utils/index.js";
4
4
  /**