@fluentui/react-positioning 9.75.0-experimental.css-modules.20261031-810ab07afb.0 → 9.75.1-experimental.positioning-engine.20261103-19efe125d1.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 +130 -7
  3. package/lib/PositioningConfigurationContext.js +1 -2
  4. package/lib/PositioningConfigurationContext.js.map +1 -1
  5. package/lib/createPositionManager.js +74 -82
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/engine/computePosition.js +258 -0
  8. package/lib/engine/computePosition.js.map +1 -0
  9. package/lib/engine/index.js +260 -0
  10. package/lib/engine/index.js.map +1 -0
  11. package/lib/engine/platform.js +209 -0
  12. package/lib/engine/platform.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 +38 -48
  24. package/lib/usePositioning.js.map +1 -1
  25. package/lib/usePositioning.raster.js +45 -0
  26. package/lib/usePositioning.raster.js.map +1 -0
  27. package/lib/usePositioningOptions.js +25 -117
  28. package/lib/usePositioningOptions.js.map +1 -1
  29. package/lib/utils/createResizeObserver.js +2 -2
  30. package/lib/utils/createResizeObserver.js.map +1 -1
  31. package/lib/utils/debounce.js +6 -13
  32. package/lib/utils/debounce.js.map +1 -1
  33. package/lib/utils/fromFloatingUIPlacement.js +10 -29
  34. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  35. package/lib/utils/getBoundary.js +8 -17
  36. package/lib/utils/getBoundary.js.map +1 -1
  37. package/lib/utils/index.js +0 -2
  38. package/lib/utils/index.js.map +1 -1
  39. package/lib/utils/listScrollParents.js +12 -20
  40. package/lib/utils/listScrollParents.js.map +1 -1
  41. package/lib/utils/normalizeAutoSize.js +15 -22
  42. package/lib/utils/normalizeAutoSize.js.map +1 -1
  43. package/lib/utils/toFloatingUIPlacement.js +9 -26
  44. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  45. package/lib/utils/useCallbackRef.js +1 -10
  46. package/lib/utils/useCallbackRef.js.map +1 -1
  47. package/lib-commonjs/PositioningConfigurationContext.cjs +1 -2
  48. package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
  49. package/lib-commonjs/createPositionManager.cjs +72 -80
  50. package/lib-commonjs/createPositionManager.cjs.map +1 -1
  51. package/lib-commonjs/engine/computePosition.cjs +265 -0
  52. package/lib-commonjs/engine/computePosition.cjs.map +1 -0
  53. package/lib-commonjs/engine/index.cjs +290 -0
  54. package/lib-commonjs/engine/index.cjs.map +1 -0
  55. package/lib-commonjs/engine/platform.cjs +264 -0
  56. package/lib-commonjs/engine/platform.cjs.map +1 -0
  57. package/lib-commonjs/middleware/flip.cjs +6 -6
  58. package/lib-commonjs/middleware/flip.cjs.map +1 -1
  59. package/lib-commonjs/middleware/intersecting.cjs +2 -2
  60. package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
  61. package/lib-commonjs/middleware/maxSize.cjs +4 -4
  62. package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
  63. package/lib-commonjs/middleware/offset.cjs +2 -2
  64. package/lib-commonjs/middleware/offset.cjs.map +1 -1
  65. package/lib-commonjs/middleware/shift.cjs +7 -7
  66. package/lib-commonjs/middleware/shift.cjs.map +1 -1
  67. package/lib-commonjs/usePositioning.cjs +37 -46
  68. package/lib-commonjs/usePositioning.cjs.map +1 -1
  69. package/lib-commonjs/usePositioning.raster.cjs +49 -0
  70. package/lib-commonjs/usePositioning.raster.cjs.map +1 -0
  71. package/lib-commonjs/usePositioningOptions.cjs +24 -112
  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 +6 -13
  76. package/lib-commonjs/utils/debounce.cjs.map +1 -1
  77. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs +21 -32
  78. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
  79. package/lib-commonjs/utils/getBoundary.cjs +8 -17
  80. package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
  81. package/lib-commonjs/utils/index.cjs +0 -8
  82. package/lib-commonjs/utils/index.cjs.map +1 -1
  83. package/lib-commonjs/utils/listScrollParents.cjs +12 -20
  84. package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
  85. package/lib-commonjs/utils/normalizeAutoSize.cjs +26 -25
  86. package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
  87. package/lib-commonjs/utils/toFloatingUIPlacement.cjs +13 -27
  88. package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
  89. package/lib-commonjs/utils/useCallbackRef.cjs +1 -9
  90. package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
  91. package/package.json +5 -9
  92. package/lib/Arrow.module.css +0 -45
  93. package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +0 -28
  94. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +0 -9
  95. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +0 -1
  96. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +0 -9
  97. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +0 -1
  98. package/lib/utils/writeArrowUpdates.js +0 -13
  99. package/lib/utils/writeArrowUpdates.js.map +0 -1
  100. package/lib/utils/writeContainerupdates.js +0 -43
  101. package/lib/utils/writeContainerupdates.js.map +0 -1
  102. package/lib-commonjs/Arrow.module.css +0 -45
  103. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +0 -28
  104. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +0 -20
  105. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +0 -1
  106. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +0 -20
  107. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +0 -1
  108. package/lib-commonjs/utils/writeArrowUpdates.cjs +0 -23
  109. package/lib-commonjs/utils/writeArrowUpdates.cjs.map +0 -1
  110. package/lib-commonjs/utils/writeContainerupdates.cjs +0 -51
  111. package/lib-commonjs/utils/writeContainerupdates.cjs.map +0 -1
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "useStyles", {
6
- enumerable: true,
7
- get: function() {
8
- return useStyles;
9
- }
10
- });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _SafeZoneAreamodulecss = /*#__PURE__*/ _interop_require_default._(require("./SafeZoneArea.module.css"));
13
- const useStyles = ()=>({
14
- wrapper: _SafeZoneAreamodulecss.default.wrapper,
15
- wrapperActive: _SafeZoneAreamodulecss.default.wrapperActive,
16
- svg: _SafeZoneAreamodulecss.default.svg,
17
- safeZone: _SafeZoneAreamodulecss.default.safeZone,
18
- safeZoneDebug: _SafeZoneAreamodulecss.default.safeZoneDebug,
19
- rectDebug: _SafeZoneAreamodulecss.default.rectDebug
20
- });
@@ -1 +0,0 @@
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":";;;;+BAEaC;;;;;;;gFAFM,4BAA4B;AAExC,kBAAkB,IAGnB,CAAA;QACJC,SAASF,8BAAAA,CAAOE,OAAO;QACvBC,eAAeH,8BAAAA,CAAOG,aAAa;QACnCC,KAAKJ,8BAAAA,CAAOI,GAAG;QACfC,UAAUL,8BAAAA,CAAOK,QAAQ;QACzBC,eAAeN,8BAAAA,CAAOM,aAAa;QACnCC,WAAWP,8BAAAA,CAAOO,SAAS;KAC7B,CAAA,EAAG"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Writes all DOM element updates after position is computed
3
- */ "use strict";
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "writeArrowUpdates", {
8
- enumerable: true,
9
- get: function() {
10
- return writeArrowUpdates;
11
- }
12
- });
13
- function writeArrowUpdates(options) {
14
- const { arrow, middlewareData } = options;
15
- if (!middlewareData.arrow || !arrow) {
16
- return;
17
- }
18
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
19
- Object.assign(arrow.style, {
20
- left: arrowX !== null && arrowX !== undefined ? `${arrowX}px` : '',
21
- top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : ''
22
- });
23
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/writeArrowUpdates.ts"],"sourcesContent":["import type { MiddlewareData } from '@floating-ui/dom';\n\n/**\n * Writes all DOM element updates after position is computed\n */\nexport function writeArrowUpdates(options: { arrow: HTMLElement | null; middlewareData: MiddlewareData }): void {\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 !== null && arrowX !== undefined ? `${arrowX}px` : '',\n top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : '',\n });\n}\n"],"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","undefined","top"],"mappings":"AAEA;;CAEC,GACD;;;;;;;;;;AAAO,SAASA,kBAAkBC,OAAsE;IACtG,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAE,GAAGF;IAClC,IAAI,CAACE,eAAeD,KAAK,IAAI,CAACA,OAAO;QACnC;IACF;IAEA,MAAM,EAAEE,GAAGC,MAAM,EAAEC,GAAGC,MAAM,EAAE,GAAGJ,eAAeD,KAAK;IAErDM,OAAOC,MAAM,CAACP,MAAMQ,KAAK,EAAE;QACzBC,MAAMN,WAAW,QAAQA,WAAWO,YAAY,GAAGP,OAAO,EAAE,CAAC,GAAG;QAChEQ,KAAKN,WAAW,QAAQA,WAAWK,YAAY,GAAGL,OAAO,EAAE,CAAC,GAAG;IACjE;AACF"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "writeContainerUpdates", {
6
- enumerable: true,
7
- get: function() {
8
- return writeContainerUpdates;
9
- }
10
- });
11
- const _constants = require("../constants.cjs");
12
- function writeContainerUpdates(options) {
13
- var _middlewareData_hide, _middlewareData_hide1, _container_ownerDocument_defaultView;
14
- const { container, placement, middlewareData, strategy, lowPPI, coordinates, useTransform = true } = options;
15
- if (!container) {
16
- return;
17
- }
18
- container.setAttribute(_constants.DATA_POSITIONING_PLACEMENT, placement);
19
- container.removeAttribute(_constants.DATA_POSITIONING_INTERSECTING);
20
- if (middlewareData.intersectionObserver.intersecting) {
21
- container.setAttribute(_constants.DATA_POSITIONING_INTERSECTING, '');
22
- }
23
- container.removeAttribute(_constants.DATA_POSITIONING_ESCAPED);
24
- if ((_middlewareData_hide = middlewareData.hide) === null || _middlewareData_hide === void 0 ? void 0 : _middlewareData_hide.escaped) {
25
- container.setAttribute(_constants.DATA_POSITIONING_ESCAPED, '');
26
- }
27
- container.removeAttribute(_constants.DATA_POSITIONING_HIDDEN);
28
- if ((_middlewareData_hide1 = middlewareData.hide) === null || _middlewareData_hide1 === void 0 ? void 0 : _middlewareData_hide1.referenceHidden) {
29
- container.setAttribute(_constants.DATA_POSITIONING_HIDDEN, '');
30
- }
31
- // Round so that the coordinates land on device pixels.
32
- // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
33
- // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
34
- // See https://github.com/microsoft/fluentui/issues/26764 for more info.
35
- const devicePixelRatio = ((_container_ownerDocument_defaultView = container.ownerDocument.defaultView) === null || _container_ownerDocument_defaultView === void 0 ? void 0 : _container_ownerDocument_defaultView.devicePixelRatio) || 1;
36
- const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
37
- const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
38
- Object.assign(container.style, {
39
- position: strategy
40
- });
41
- if (useTransform) {
42
- Object.assign(container.style, {
43
- transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`
44
- });
45
- return;
46
- }
47
- Object.assign(container.style, {
48
- left: `${x}px`,
49
- top: `${y}px`
50
- });
51
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/writeContainerupdates.ts"],"sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n useTransform?: boolean;\n}): void {\n const { container, placement, middlewareData, strategy, lowPPI, coordinates, useTransform = true } = 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 // 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 effects like\n // `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 = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n\n Object.assign(container.style, {\n position: strategy,\n });\n\n if (useTransform) {\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n });\n return;\n }\n\n Object.assign(container.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n}\n"],"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","middlewareData","container","placement","strategy","lowPPI","coordinates","useTransform","setAttribute","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","position","transform","left","top"],"mappings":";;;;+BAWgBI;;;;;;2BALT,kBAAe;AAK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