@fluentui/react-positioning 9.74.7-experimental.cli-api.20261006-ccaa611d58.0 → 9.75.0-experimental.css-modules.20261031-810ab07afb.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 (139) hide show
  1. package/CHANGELOG.md +38 -8
  2. package/README.md +6 -0
  3. package/lib/Arrow.module.css +45 -0
  4. package/lib/PositioningConfigurationContext.js.map +1 -1
  5. package/lib/createPositionManager.js +18 -6
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/hooks/useSafeZoneArea/SafeZoneArea.js +51 -110
  8. package/lib/hooks/useSafeZoneArea/SafeZoneArea.js.map +1 -1
  9. package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +28 -0
  10. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +9 -0
  11. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +1 -0
  12. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.js +2 -2
  13. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.js.map +1 -1
  14. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +9 -0
  15. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +1 -0
  16. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.js +2 -2
  17. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.js.map +1 -1
  18. package/lib/hooks/useSafeZoneArea/computeOutsideClipPath.js +3 -6
  19. package/lib/hooks/useSafeZoneArea/computeOutsideClipPath.js.map +1 -1
  20. package/lib/hooks/useSafeZoneArea/createSafeZoneAreaStateStore.js.map +1 -1
  21. package/lib/hooks/useSafeZoneArea/getMouseAnchor.js.map +1 -1
  22. package/lib/hooks/useSafeZoneArea/getRectCorners.js.map +1 -1
  23. package/lib/hooks/useSafeZoneArea/getSafeZonePoints.js +72 -0
  24. package/lib/hooks/useSafeZoneArea/getSafeZonePoints.js.map +1 -0
  25. package/lib/hooks/useSafeZoneArea/pointsToSvgPath.js.map +1 -1
  26. package/lib/hooks/useSafeZoneArea/types.js.map +1 -1
  27. package/lib/hooks/useSafeZoneArea/useSafeZoneArea.js.map +1 -1
  28. package/lib/middleware/coverTarget.js.map +1 -1
  29. package/lib/middleware/flip.js.map +1 -1
  30. package/lib/middleware/index.js.map +1 -1
  31. package/lib/middleware/intersecting.js.map +1 -1
  32. package/lib/middleware/matchTargetSize.js.map +1 -1
  33. package/lib/middleware/maxSize.js.map +1 -1
  34. package/lib/middleware/offset.js.map +1 -1
  35. package/lib/middleware/shift.js.map +1 -1
  36. package/lib/usePositioning.js +1 -1
  37. package/lib/usePositioning.js.map +1 -1
  38. package/lib/usePositioningOptions.js.map +1 -1
  39. package/lib/usePositioningSlideDirection.js +32 -23
  40. package/lib/usePositioningSlideDirection.js.map +1 -1
  41. package/lib/utils/createResizeObserver.js.map +1 -1
  42. package/lib/utils/debounce.js.map +1 -1
  43. package/lib/utils/devtools.js.map +1 -1
  44. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  45. package/lib/utils/getBoundary.js.map +1 -1
  46. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  47. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  48. package/lib/utils/getScrollParent.js.map +1 -1
  49. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  50. package/lib/utils/index.js.map +1 -1
  51. package/lib/utils/listScrollParents.js.map +1 -1
  52. package/lib/utils/mergeArrowOffset.js +1 -1
  53. package/lib/utils/mergeArrowOffset.js.map +1 -1
  54. package/lib/utils/normalizeAutoSize.js.map +1 -1
  55. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  56. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  57. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  58. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  59. package/lib/utils/toggleScrollListener.js.map +1 -1
  60. package/lib/utils/useCallbackRef.js.map +1 -1
  61. package/lib/utils/writeArrowUpdates.js.map +1 -1
  62. package/lib/utils/writeContainerupdates.js.map +1 -1
  63. package/lib-commonjs/Arrow.module.css +45 -0
  64. package/lib-commonjs/PositioningConfigurationContext.cjs +3 -3
  65. package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
  66. package/lib-commonjs/constants.cjs +8 -8
  67. package/lib-commonjs/constants.cjs.map +1 -1
  68. package/lib-commonjs/createArrowStyles.cjs +3 -3
  69. package/lib-commonjs/createArrowStyles.cjs.map +1 -1
  70. package/lib-commonjs/createPositionManager.cjs +18 -6
  71. package/lib-commonjs/createPositionManager.cjs.map +1 -1
  72. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.cjs +53 -121
  73. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.cjs.map +1 -1
  74. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +28 -0
  75. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.cjs +2 -2
  76. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.cjs.map +1 -1
  77. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +20 -0
  78. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +1 -0
  79. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.cjs +2 -2
  80. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.cjs.map +1 -1
  81. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +20 -0
  82. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +1 -0
  83. package/lib-commonjs/hooks/useSafeZoneArea/computeOutsideClipPath.cjs +2 -5
  84. package/lib-commonjs/hooks/useSafeZoneArea/computeOutsideClipPath.cjs.map +1 -1
  85. package/lib-commonjs/hooks/useSafeZoneArea/createSafeZoneAreaStateStore.cjs.map +1 -1
  86. package/lib-commonjs/hooks/useSafeZoneArea/getMouseAnchor.cjs +4 -4
  87. package/lib-commonjs/hooks/useSafeZoneArea/getMouseAnchor.cjs.map +1 -1
  88. package/lib-commonjs/hooks/useSafeZoneArea/getRectCorners.cjs.map +1 -1
  89. package/lib-commonjs/hooks/useSafeZoneArea/getSafeZonePoints.cjs +82 -0
  90. package/lib-commonjs/hooks/useSafeZoneArea/getSafeZonePoints.cjs.map +1 -0
  91. package/lib-commonjs/hooks/useSafeZoneArea/pointsToSvgPath.cjs.map +1 -1
  92. package/lib-commonjs/hooks/useSafeZoneArea/types.cjs.map +1 -1
  93. package/lib-commonjs/hooks/useSafeZoneArea/useSafeZoneArea.cjs.map +1 -1
  94. package/lib-commonjs/index.cjs +14 -14
  95. package/lib-commonjs/index.cjs.map +1 -1
  96. package/lib-commonjs/middleware/coverTarget.cjs.map +1 -1
  97. package/lib-commonjs/middleware/flip.cjs.map +1 -1
  98. package/lib-commonjs/middleware/index.cjs +10 -10
  99. package/lib-commonjs/middleware/index.cjs.map +1 -1
  100. package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
  101. package/lib-commonjs/middleware/matchTargetSize.cjs +3 -3
  102. package/lib-commonjs/middleware/matchTargetSize.cjs.map +1 -1
  103. package/lib-commonjs/middleware/maxSize.cjs +3 -3
  104. package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
  105. package/lib-commonjs/middleware/offset.cjs.map +1 -1
  106. package/lib-commonjs/middleware/shift.cjs.map +1 -1
  107. package/lib-commonjs/usePositioning.cjs +1 -1
  108. package/lib-commonjs/usePositioning.cjs.map +1 -1
  109. package/lib-commonjs/usePositioningOptions.cjs.map +1 -1
  110. package/lib-commonjs/usePositioningSlideDirection.cjs +35 -26
  111. package/lib-commonjs/usePositioningSlideDirection.cjs.map +1 -1
  112. package/lib-commonjs/utils/createResizeObserver.cjs.map +1 -1
  113. package/lib-commonjs/utils/debounce.cjs.map +1 -1
  114. package/lib-commonjs/utils/devtools.cjs.map +1 -1
  115. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
  116. package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
  117. package/lib-commonjs/utils/getFloatingUIOffset.cjs.map +1 -1
  118. package/lib-commonjs/utils/getReactFiberFromNode.cjs.map +1 -1
  119. package/lib-commonjs/utils/getScrollParent.cjs +5 -5
  120. package/lib-commonjs/utils/getScrollParent.cjs.map +1 -1
  121. package/lib-commonjs/utils/hasAutoFocusFilter.cjs.map +1 -1
  122. package/lib-commonjs/utils/index.cjs +19 -19
  123. package/lib-commonjs/utils/index.cjs.map +1 -1
  124. package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
  125. package/lib-commonjs/utils/mergeArrowOffset.cjs +1 -1
  126. package/lib-commonjs/utils/mergeArrowOffset.cjs.map +1 -1
  127. package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
  128. package/lib-commonjs/utils/parseFloatingUIPlacement.cjs.map +1 -1
  129. package/lib-commonjs/utils/resolvePositioningShorthand.cjs +1 -1
  130. package/lib-commonjs/utils/resolvePositioningShorthand.cjs.map +1 -1
  131. package/lib-commonjs/utils/toFloatingUIPadding.cjs.map +1 -1
  132. package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
  133. package/lib-commonjs/utils/toggleScrollListener.cjs.map +1 -1
  134. package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
  135. package/lib-commonjs/utils/writeArrowUpdates.cjs.map +1 -1
  136. package/lib-commonjs/utils/writeContainerupdates.cjs.map +1 -1
  137. package/package.json +11 -10
  138. package/dist/metadata/api/api-root.json +0 -1
  139. package/dist/metadata/index.json +0 -1
package/CHANGELOG.md CHANGED
@@ -1,20 +1,50 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- <!-- This log was last generated on Tue, 06 Oct 2026 11:40:29 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Sat, 31 Oct 2026 11:08:52 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [9.74.7-experimental.cli-api.20261006-ccaa611d58.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.74.7-experimental.cli-api.20261006-ccaa611d58.0)
7
+ ## [9.75.0-experimental.css-modules.20261031-810ab07afb.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.75.0-experimental.css-modules.20261031-810ab07afb.0)
8
8
 
9
- Tue, 06 Oct 2026 11:40:29 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.23.1..@fluentui/react-positioning_v9.74.7-experimental.cli-api.20261006-ccaa611d58.0)
9
+ Sat, 31 Oct 2026 11:08:52 GMT
11
10
 
12
11
  ### Changes
13
12
 
14
- - Release 9.74.7-experimental.cli-api.20261006-ccaa611d58 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
15
- - Bump @fluentui/react-shared-contexts to v9.74.7-experimental.cli-api.20261006-ccaa611d58.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
- - Bump @fluentui/react-theme to v9.74.7-experimental.cli-api.20261006-ccaa611d58.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
- - Bump @fluentui/react-utilities to v9.74.7-experimental.cli-api.20261006-ccaa611d58.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
13
+ - Release 9.75.0-experimental.css-modules.20261031-810ab07afb ([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.0-experimental.css-modules.20261031-810ab07afb.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-theme to v9.75.0-experimental.css-modules.20261031-810ab07afb.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+ - Bump @fluentui/react-utilities to v9.75.0-experimental.css-modules.20261031-810ab07afb.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
+
18
+ ## [9.23.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.23.4)
19
+
20
+ Mon, 19 Oct 2026 16:49:01 GMT
21
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.23.3..@fluentui/react-positioning_v9.23.4)
22
+
23
+ ### Patches
24
+
25
+ - fix: register positioning slide-direction CSS properties once per document ([PR #36833](https://github.com/microsoft/fluentui/pull/36833) by bernardo.sunderhus@gmail.com)
26
+ - Bump @fluentui/react-utilities to v9.27.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
27
+
28
+ ## [9.23.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.23.3)
29
+
30
+ Wed, 23 Sep 2026 09:04:33 GMT
31
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.23.2..@fluentui/react-positioning_v9.23.3)
32
+
33
+ ### Patches
34
+
35
+ - fix: improve safe zone hit testing and avoid rerenders during pointer movement ([PR #36708](https://github.com/microsoft/fluentui/pull/36708) by jakubmiskech@microsoft.com)
36
+
37
+ ## [9.23.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.23.2)
38
+
39
+ Tue, 22 Sep 2026 11:25:39 GMT
40
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.23.1..@fluentui/react-positioning_v9.23.2)
41
+
42
+ ### Patches
43
+
44
+ - fix: remove unused react-dom and @types/react-dom peer dependencies, mark @types/react as optional, require use-sync-external-store ^1.4.0 for react 19 support ([PR #36559](https://github.com/microsoft/fluentui/pull/36559) by martinhochel@microsoft.com)
45
+ - Treat unavailable positioning geometry as indeterminate when reporting visibility flags. ([PR #36758](https://github.com/microsoft/fluentui/pull/36758) by bernardo.sunderhus@gmail.com)
46
+ - Bump @fluentui/react-shared-contexts to v9.26.4 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
47
+ - Bump @fluentui/react-utilities to v9.26.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
48
 
19
49
  ## [9.23.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.23.1)
20
50
 
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  A React utilities built on top of [Floating UI](https://floating-ui.com/) for positioning elements in the DOM.
4
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.
10
+
5
11
  ## Usage
6
12
 
7
13
  ```tsx
@@ -0,0 +1,45 @@
1
+ @layer fluentui {
2
+ .arrow {
3
+ box-sizing: border-box;
4
+ position: absolute;
5
+ z-index: -1;
6
+ background-color: inherit;
7
+ background-clip: content-box;
8
+ /* The rotated arrow and placement coordinates are intentionally physical in RTL. */
9
+ border-bottom-left-radius: var(--borderRadiusSmall);
10
+ transform: rotate(var(--fui-positioning-arrow-angle));
11
+ height: var(--fui-positioning-arrow-height);
12
+ width: var(--fui-positioning-arrow-height);
13
+
14
+ &::before {
15
+ content: '';
16
+ display: block;
17
+ background-color: inherit;
18
+ margin: calc(-1 * var(--fui-positioning-arrow-border-width, var(--strokeWidthThin)));
19
+ width: 100%;
20
+ height: 100%;
21
+ border: var(--fui-positioning-arrow-border-width, var(--strokeWidthThin))
22
+ var(--fui-positioning-arrow-border-style, solid)
23
+ var(--fui-positioning-arrow-border-color, var(--colorTransparentStroke));
24
+ border-bottom-left-radius: var(--borderRadiusSmall);
25
+ clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
26
+ }
27
+ }
28
+
29
+ :global([data-popper-placement^='top']) .arrow {
30
+ bottom: var(--fui-positioning-arrow-offset);
31
+ --fui-positioning-arrow-angle: -45deg;
32
+ }
33
+ :global([data-popper-placement^='right']) .arrow {
34
+ left: var(--fui-positioning-arrow-offset);
35
+ --fui-positioning-arrow-angle: 45deg;
36
+ }
37
+ :global([data-popper-placement^='bottom']) .arrow {
38
+ top: var(--fui-positioning-arrow-offset);
39
+ --fui-positioning-arrow-angle: 135deg;
40
+ }
41
+ :global([data-popper-placement^='left']) .arrow {
42
+ right: var(--fui-positioning-arrow-offset);
43
+ --fui-positioning-arrow-angle: 225deg;
44
+ }
45
+ }
@@ -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;QAClCR;IAAP,OAAOA,CAAAA,oBAAAA,MAAMS,UAAU,CAACN,8CAAjBH,+BAAAA,oBAAqDC;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"}
@@ -4,6 +4,10 @@ import { debounce, writeArrowUpdates, writeContainerUpdates } from "./utils/inde
4
4
  import { listScrollParents } from "./utils/listScrollParents.js";
5
5
  import { POSITIONING_END_EVENT } from "./constants.js";
6
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
+ }
7
11
  /**
8
12
  * @internal
9
13
  * @returns manager that handles positioning out of the react lifecycle
@@ -68,19 +72,28 @@ import { createResizeObserver } from "./utils/createResizeObserver.js";
68
72
  middleware,
69
73
  strategy
70
74
  }).then(({ x, y, middlewareData, placement: computedPlacement })=>{
71
- var _middlewareData_hide, _middlewareData_hide1;
75
+ var _ref, _ref1;
76
+ var _positioningMiddlewareData_hide, _positioningMiddlewareData_hide1;
72
77
  // Promise can still resolve after destruction
73
78
  // early return to avoid applying outdated position
74
79
  if (isDestroyed) {
75
80
  return;
76
81
  }
82
+ const positioningMiddlewareData = isLayoutViewportUnavailable(container) ? {
83
+ ...middlewareData,
84
+ hide: {
85
+ ...middlewareData.hide,
86
+ escaped: false,
87
+ referenceHidden: false
88
+ }
89
+ } : middlewareData;
77
90
  writeArrowUpdates({
78
91
  arrow,
79
- middlewareData
92
+ middlewareData: positioningMiddlewareData
80
93
  });
81
94
  writeContainerUpdates({
82
95
  container,
83
- middlewareData,
96
+ middlewareData: positioningMiddlewareData,
84
97
  placement: computedPlacement,
85
98
  coordinates: {
86
99
  x,
@@ -90,15 +103,14 @@ import { createResizeObserver } from "./utils/createResizeObserver.js";
90
103
  strategy,
91
104
  useTransform
92
105
  });
93
- var _middlewareData_hide_escaped, _middlewareData_hide_referenceHidden;
94
106
  container.dispatchEvent(new CustomEvent(POSITIONING_END_EVENT, {
95
107
  detail: {
96
108
  // Cast from Floating UI's Placement to the Fluent-owned PositioningPlacement.
97
109
  // These are equivalent string unions; the cast avoids leaking @floating-ui/dom
98
110
  // types into the public API surface.
99
111
  placement: computedPlacement,
100
- escaped: (_middlewareData_hide_escaped = (_middlewareData_hide = middlewareData.hide) === null || _middlewareData_hide === void 0 ? void 0 : _middlewareData_hide.escaped) !== null && _middlewareData_hide_escaped !== void 0 ? _middlewareData_hide_escaped : false,
101
- referenceHidden: (_middlewareData_hide_referenceHidden = (_middlewareData_hide1 = middlewareData.hide) === null || _middlewareData_hide1 === void 0 ? void 0 : _middlewareData_hide1.referenceHidden) !== null && _middlewareData_hide_referenceHidden !== void 0 ? _middlewareData_hide_referenceHidden : false
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
102
114
  }
103
115
  }));
104
116
  }).catch((err)=>{
@@ -1 +1 @@
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\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 writeArrowUpdates({ arrow, middlewareData });\n writeContainerUpdates({\n container,\n middlewareData,\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: middlewareData.hide?.escaped ?? false,\n referenceHidden: middlewareData.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","createPositionManager","options","isDestroyed","container","target","arrow","strategy","middleware","placement","useTransform","disableUpdateOnResize","targetWindow","ownerDocument","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","coordinates","lowPPI","devicePixelRatio","dispatchEvent","CustomEvent","detail","escaped","hide","referenceHidden","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;;;CAGC,GACD,OAAO,SAASC,sBAAsBC,OAA+B;IACnE,IAAIC,cAAc;IAClB,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,eAAe,IAAI,EACnBC,wBAAwB,KAAK,EAC9B,GAAGT;IACJ,MAAMU,eAAeR,UAAUS,aAAa,CAACC,WAAW;IACxD,IAAI,CAACT,UAAU,CAACD,aAAa,CAACQ,cAAc;QAC1C,OAAO;YACLG,gBAAgB,IAAMC;YACtBC,SAAS,IAAMD;QACjB;IACF;IAEA,wFAAwF;IACxF,MAAME,iBAAiBP,wBACnB,OACAX,qBAAqBY,cAAcO,CAAAA;QACjC,2GAA2G;QAC3G,8DAA8D;QAC9D,MAAMC,uBAAuBD,QAAQE,KAAK,CAACC,CAAAA;YACzC,OAAOA,MAAMC,WAAW,CAACC,KAAK,GAAG,KAAKF,MAAMC,WAAW,CAACE,MAAM,GAAG;QACnE;QAEA,IAAIL,sBAAsB;YACxBL;QACF;IACF;IAEJ,IAAIW,gBAAgB;IACpB,MAAMC,gBAAkC,IAAIC;IAE5C,oFAAoF;IACpF,gGAAgG;IAChGC,OAAOC,MAAM,CAAC1B,UAAU2B,KAAK,EAAE;QAAEC,UAAU;QAASC,MAAM;QAAGC,KAAK;QAAGC,QAAQ;IAAE;IAE/E,MAAMC,cAAc;QAClB,8CAA8C;QAC9C,qCAAqC;QACrC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,IAAI,cAAnBT,2CAAAA,qBAAqBQ,OAAO,cAA5BR,0CAAAA,+BAAgC;oBACzCU,iBAAiBV,CAAAA,wCAAAA,wBAAAA,eAAeS,IAAI,cAAnBT,4CAAAA,sBAAqBU,eAAe,cAApCV,kDAAAA,uCAAwC;gBAC3D;YACF;QAEJ,GACCW,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,MAAM3C,iBAAiBpB,SAAS,IAAMyC;IAEtC,MAAMnB,UAAU;QACdd,cAAc;QAEd,IAAIS,cAAc;YAChBA,aAAaoD,mBAAmB,CAAC,UAAUjD;YAC3CH,aAAaoD,mBAAmB,CAAC,UAAUjD;QAC7C;QAEAY,cAAcU,OAAO,CAACC,CAAAA;YACpBA,aAAa0B,mBAAmB,CAAC,UAAUjD;QAC7C;QACAY,cAAcsC,KAAK;QAEnB/C,2BAAAA,qCAAAA,eAAgBgD,UAAU;IAC5B;IAEA,IAAItD,cAAc;QAChBA,aAAa4B,gBAAgB,CAAC,UAAUzB,gBAAgB;YAAE0B,SAAS;QAAK;QACxE7B,aAAa4B,gBAAgB,CAAC,UAAUzB;IAC1C;IAEA,wCAAwC;IACxCA;IAEA,OAAO;QACLA;QACAE;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,S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AAWqC;oBACXG,OAAO,WAAEF,kCAAAA,0BAA0BC,IAAI,cAA9BD,sDAAAA,gCAAgCE,OAAO,uCAAI;oBACpDC,eAAe,YAAEH,mCAAAA,0BAA0BC,IAAI,cAA9BD,uDAAAA,iCAAgCG,eAAe,yCAAI;gBACtE;YACF;QAEJ,GACCO,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,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"}
@@ -8,34 +8,13 @@ import { getMouseAnchor } from "./getMouseAnchor.js";
8
8
  import { pointsToSvgPath } from "./pointsToSvgPath.js";
9
9
  import { useStyles } from "./SafeZoneArea.styles.js";
10
10
  import { computeOutsideClipPath } from "./computeOutsideClipPath.js";
11
- // ---
12
- const EMPTY_RECT = {
13
- top: 0,
14
- right: 0,
15
- bottom: 0,
16
- left: 0,
17
- width: 0,
18
- height: 0,
19
- x: 0,
20
- y: 0,
21
- toJSON () {
22
- return '';
23
- }
24
- };
25
- export function isSameRect(a, b) {
26
- return a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left && a.width === b.width && a.height === b.height;
27
- }
28
- export function isSameCoordinates(a, b) {
29
- return a[0] === b[0] && a[1] === b[1];
30
- }
11
+ import { getSafeZonePoints } from "./getSafeZonePoints.js";
31
12
  // ---
32
13
  /**
33
14
  * A component that renders a safe zone area with SVG shapes. Uses `useSyncExternalStore` to manage its active state
34
15
  * to avoid causing re-renders in `useSafeZoneArea()` as the hook might be used in host components like `Menu`.
35
16
  *
36
- * Draws two shapes:
37
- * - a triangle that points to the target element which is an actual safe zone
38
- * - a rectangle for a clip path that clips out the target element
17
+ * Draws a polygon from the mouse to the facing edges of the container and clips out the target element.
39
18
  *
40
19
  * @internal
41
20
  */ export const SafeZoneArea = /*#__PURE__*/ React.memo((props)=>{
@@ -44,114 +23,76 @@ export function isSameCoordinates(a, b) {
44
23
  const styles = useStyles();
45
24
  const active = useSyncExternalStore(stateStore.subscribe, stateStore.isActive);
46
25
  const svgRef = React.useRef(null);
47
- const [state, setState] = React.useState(()=>({
48
- containerRect: EMPTY_RECT,
49
- targetRect: EMPTY_RECT,
50
- mouseCoordinates: [
51
- 0,
52
- 0
53
- ]
54
- }));
26
+ const safeZoneRef = React.useRef(null);
27
+ const clipPathRef = React.useRef(null);
28
+ const rectDebugRef = React.useRef(null);
55
29
  React.useImperativeHandle(props.imperativeRef, ()=>({
56
- updateSVG (newState) {
57
- setState((prevState)=>{
58
- // Heads up!
59
- // A small optimization to avoid unnecessary re-renders
60
- if (isSameRect(prevState.containerRect, newState.containerRect) && isSameRect(prevState.targetRect, newState.targetRect) && isSameCoordinates(prevState.mouseCoordinates, newState.mouseCoordinates)) {
61
- return prevState;
62
- }
63
- return newState;
30
+ updateSVG ({ containerRect, targetRect, mouseCoordinates }) {
31
+ var _safeZoneRef_current, _clipPathRef_current, _rectDebugRef_current;
32
+ const topOffset = Math.min(targetRect.top, containerRect.top);
33
+ const leftOffset = Math.min(targetRect.left, containerRect.left);
34
+ const bottomOffset = Math.max(targetRect.bottom, containerRect.bottom);
35
+ const rightOffset = Math.max(targetRect.right, containerRect.right);
36
+ const containerCorners = getRectCorners(containerRect, [
37
+ leftOffset,
38
+ topOffset
39
+ ]);
40
+ const targetCorners = getRectCorners(targetRect, [
41
+ leftOffset,
42
+ topOffset
43
+ ]);
44
+ // SVG coordinates are relative to its top-left corner.
45
+ const relativeMouseCoordinates = [
46
+ mouseCoordinates[0] - leftOffset,
47
+ mouseCoordinates[1] - topOffset
48
+ ];
49
+ const mouseAnchor = getMouseAnchor(containerCorners.topLeft, containerCorners.bottomRight, relativeMouseCoordinates);
50
+ const svgWidth = rightOffset - leftOffset;
51
+ const svgHeight = bottomOffset - topOffset;
52
+ const clipPath = computeOutsideClipPath(svgWidth, svgHeight, {
53
+ x: targetCorners.topLeft[0],
54
+ y: targetCorners.topLeft[1],
55
+ width: targetRect.width,
56
+ height: targetRect.height
64
57
  });
58
+ if (svgRef.current) {
59
+ svgRef.current.style.width = `${svgWidth}px`;
60
+ svgRef.current.style.height = `${svgHeight}px`;
61
+ svgRef.current.style.transform = `translate(${leftOffset}px, ${topOffset}px)`;
62
+ }
63
+ const safeZonePoints = getSafeZonePoints(mouseAnchor, containerCorners);
64
+ (_safeZoneRef_current = safeZoneRef.current) === null || _safeZoneRef_current === void 0 ? void 0 : _safeZoneRef_current.setAttribute('d', safeZonePoints.length > 0 ? pointsToSvgPath(safeZonePoints) : '');
65
+ (_clipPathRef_current = clipPathRef.current) === null || _clipPathRef_current === void 0 ? void 0 : _clipPathRef_current.setAttribute('d', clipPath);
66
+ (_rectDebugRef_current = rectDebugRef.current) === null || _rectDebugRef_current === void 0 ? void 0 : _rectDebugRef_current.setAttribute('d', clipPath);
65
67
  }
66
68
  }), []);
67
- const { containerRect, targetRect, mouseCoordinates } = state;
68
- const topOffset = Math.min(targetRect.top, containerRect.top);
69
- const leftOffset = Math.min(targetRect.left, containerRect.left);
70
- const bottomOffset = Math.max(targetRect.bottom, containerRect.bottom);
71
- const rightOffset = Math.max(targetRect.right, containerRect.right);
72
- // ---
73
- const containerCorners = getRectCorners(containerRect, [
74
- leftOffset,
75
- topOffset
76
- ]);
77
- const targetCorners = getRectCorners(targetRect, [
78
- leftOffset,
79
- topOffset
80
- ]);
81
- // Heads up!
82
- // The SVG coordinate system starts at the top-left corner of the SVG element,
83
- // so we need to adjust the mouse coordinates relative to the SVG's top-left corner.
84
- const relativeMouseCoordinates = [
85
- mouseCoordinates[0] - leftOffset,
86
- mouseCoordinates[1] - topOffset
87
- ];
88
- const mouseAnchor = getMouseAnchor(containerCorners.topLeft, containerCorners.bottomRight, relativeMouseCoordinates);
89
- const triangleA = [
90
- mouseAnchor,
91
- containerCorners.topLeft,
92
- containerCorners.topRight
93
- ];
94
- const triangleB = [
95
- mouseAnchor,
96
- containerCorners.topRight,
97
- containerCorners.bottomRight
98
- ];
99
- const triangleC = [
100
- mouseAnchor,
101
- containerCorners.bottomRight,
102
- containerCorners.bottomLeft
103
- ];
104
- const triangleD = [
105
- mouseAnchor,
106
- containerCorners.bottomLeft,
107
- containerCorners.topLeft
108
- ];
109
- const svgWidth = rightOffset - leftOffset;
110
- const svgHeight = bottomOffset - topOffset;
111
- const clipPath = computeOutsideClipPath(svgWidth, svgHeight, {
112
- x: targetCorners.topLeft[0],
113
- y: targetCorners.topLeft[1],
114
- width: targetRect.width,
115
- height: targetRect.height
116
- }, {
117
- x: containerCorners.topLeft[0],
118
- y: containerCorners.topLeft[1],
119
- width: containerRect.width,
120
- height: containerRect.height
121
- });
122
69
  return /*#__PURE__*/ React.createElement("div", {
123
70
  className: mergeClasses(styles.wrapper, active && styles.wrapperActive),
124
71
  "data-safe-zone": ""
125
- }, active ? /*#__PURE__*/ React.createElement("svg", {
72
+ }, /*#__PURE__*/ React.createElement("svg", {
126
73
  "aria-hidden": true,
127
74
  className: styles.svg,
128
75
  xmlns: "http://www.w3.org/2000/svg",
129
76
  ref: svgRef,
130
77
  style: {
131
- width: `${svgWidth}px`,
132
- height: `${svgHeight}px`,
133
- transform: `translate(${leftOffset}px, ${topOffset}px)`
78
+ width: 0,
79
+ height: 0,
80
+ transform: 'translate(0px, 0px)'
134
81
  }
135
82
  }, /*#__PURE__*/ React.createElement("g", {
136
- className: mergeClasses(styles.triangle, debug && styles.triangleDebug),
83
+ className: mergeClasses(styles.safeZone, debug && styles.safeZoneDebug),
137
84
  clipPath: `url(#${clipPathId})`,
138
85
  onMouseEnter: onMouseEnter,
139
86
  onMouseMove: onMouseMove,
140
87
  onMouseLeave: onMouseLeave
141
88
  }, /*#__PURE__*/ React.createElement("path", {
142
- d: pointsToSvgPath(triangleA)
143
- }), /*#__PURE__*/ React.createElement("path", {
144
- d: pointsToSvgPath(triangleB)
145
- }), /*#__PURE__*/ React.createElement("path", {
146
- d: pointsToSvgPath(triangleC)
147
- }), /*#__PURE__*/ React.createElement("path", {
148
- d: pointsToSvgPath(triangleD)
89
+ ref: safeZoneRef
149
90
  })), /*#__PURE__*/ React.createElement("clipPath", {
150
91
  id: clipPathId
151
92
  }, /*#__PURE__*/ React.createElement("path", {
152
- d: clipPath
93
+ ref: clipPathRef
153
94
  })), debug && /*#__PURE__*/ React.createElement("path", {
154
- className: styles.rectDebug,
155
- d: clipPath
156
- })) : null);
95
+ ref: rectDebugRef,
96
+ className: styles.rectDebug
97
+ })));
157
98
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useSafeZoneArea/SafeZoneArea.tsx"],"sourcesContent":["'use client';\n\nimport { mergeClasses } from '@griffel/react';\nimport { useId } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nimport type { createSafeZoneAreaStateStore } from './createSafeZoneAreaStateStore';\nimport { getRectCorners } from './getRectCorners';\nimport { getMouseAnchor } from './getMouseAnchor';\nimport { pointsToSvgPath } from './pointsToSvgPath';\nimport { useStyles } from './SafeZoneArea.styles';\nimport type { Point } from './types';\nimport { computeOutsideClipPath } from './computeOutsideClipPath';\n\nexport type SafeZoneAreaImperativeHandle = {\n updateSVG: (options: { containerRect: DOMRect; targetRect: DOMRect; mouseCoordinates: Point }) => void;\n};\n\nexport type SafeZoneAreaProps = {\n /** Enables debug mode: makes drawn shapes visible. */\n debug: boolean;\n\n /** A reference to the SafeZoneArea imperative handle. */\n imperativeRef: React.Ref<SafeZoneAreaImperativeHandle>;\n\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseEnter: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseMove: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseLeave: (e: React.MouseEvent) => void;\n\n stateStore: ReturnType<typeof createSafeZoneAreaStateStore>;\n};\n\n/**\n * @internal\n */\ntype SafeZoneAreaState = {\n containerRect: DOMRect;\n targetRect: DOMRect;\n mouseCoordinates: Point;\n};\n\n// ---\n\nconst EMPTY_RECT: DOMRect = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n width: 0,\n height: 0,\n x: 0,\n y: 0,\n toJSON() {\n return '';\n },\n};\n\nexport function isSameRect(a: DOMRect, b: DOMRect): boolean {\n return (\n a.top === b.top &&\n a.right === b.right &&\n a.bottom === b.bottom &&\n a.left === b.left &&\n a.width === b.width &&\n a.height === b.height\n );\n}\n\nexport function isSameCoordinates(a: Point, b: Point): boolean {\n return a[0] === b[0] && a[1] === b[1];\n}\n\n// ---\n\n/**\n * A component that renders a safe zone area with SVG shapes. Uses `useSyncExternalStore` to manage its active state\n * to avoid causing re-renders in `useSafeZoneArea()` as the hook might be used in host components like `Menu`.\n *\n * Draws two shapes:\n * - a triangle that points to the target element which is an actual safe zone\n * - a rectangle for a clip path that clips out the target element\n *\n * @internal\n */\nexport const SafeZoneArea = React.memo((props: SafeZoneAreaProps): JSXElement => {\n const { debug, onMouseEnter, onMouseMove, onMouseLeave, stateStore } = props;\n\n const clipPathId = useId();\n const styles = useStyles();\n\n const active = useSyncExternalStore(stateStore.subscribe, stateStore.isActive);\n const svgRef = React.useRef<SVGSVGElement>(null);\n\n const [state, setState] = React.useState<SafeZoneAreaState>(() => ({\n containerRect: EMPTY_RECT,\n targetRect: EMPTY_RECT,\n mouseCoordinates: [0, 0],\n }));\n\n React.useImperativeHandle(\n props.imperativeRef,\n () => ({\n updateSVG(newState) {\n setState(prevState => {\n // Heads up!\n // A small optimization to avoid unnecessary re-renders\n if (\n isSameRect(prevState.containerRect, newState.containerRect) &&\n isSameRect(prevState.targetRect, newState.targetRect) &&\n isSameCoordinates(prevState.mouseCoordinates, newState.mouseCoordinates)\n ) {\n return prevState;\n }\n\n return newState;\n });\n },\n }),\n [],\n );\n\n const { containerRect, targetRect, mouseCoordinates } = state;\n\n const topOffset = Math.min(targetRect.top, containerRect.top);\n const leftOffset = Math.min(targetRect.left, containerRect.left);\n const bottomOffset = Math.max(targetRect.bottom, containerRect.bottom);\n const rightOffset = Math.max(targetRect.right, containerRect.right);\n\n // ---\n\n const containerCorners = getRectCorners(containerRect, [leftOffset, topOffset]);\n const targetCorners = getRectCorners(targetRect, [leftOffset, topOffset]);\n\n // Heads up!\n // The SVG coordinate system starts at the top-left corner of the SVG element,\n // so we need to adjust the mouse coordinates relative to the SVG's top-left corner.\n const relativeMouseCoordinates: Point = [mouseCoordinates[0] - leftOffset, mouseCoordinates[1] - topOffset];\n const mouseAnchor = getMouseAnchor(containerCorners.topLeft, containerCorners.bottomRight, relativeMouseCoordinates);\n\n const triangleA = [mouseAnchor, containerCorners.topLeft, containerCorners.topRight];\n const triangleB = [mouseAnchor, containerCorners.topRight, containerCorners.bottomRight];\n const triangleC = [mouseAnchor, containerCorners.bottomRight, containerCorners.bottomLeft];\n const triangleD = [mouseAnchor, containerCorners.bottomLeft, containerCorners.topLeft];\n\n const svgWidth = rightOffset - leftOffset;\n const svgHeight = bottomOffset - topOffset;\n\n const clipPath = computeOutsideClipPath(\n svgWidth,\n svgHeight,\n {\n x: targetCorners.topLeft[0],\n y: targetCorners.topLeft[1],\n width: targetRect.width,\n height: targetRect.height,\n },\n {\n x: containerCorners.topLeft[0],\n y: containerCorners.topLeft[1],\n width: containerRect.width,\n height: containerRect.height,\n },\n );\n\n return (\n <div className={mergeClasses(styles.wrapper, active && styles.wrapperActive)} data-safe-zone=\"\">\n {active ? (\n <svg\n aria-hidden\n className={styles.svg}\n xmlns=\"http://www.w3.org/2000/svg\"\n ref={svgRef}\n style={{\n width: `${svgWidth}px`,\n height: `${svgHeight}px`,\n transform: `translate(${leftOffset}px, ${topOffset}px)`,\n }}\n >\n <g\n className={mergeClasses(styles.triangle, debug && styles.triangleDebug)}\n clipPath={`url(#${clipPathId})`}\n onMouseEnter={onMouseEnter}\n onMouseMove={onMouseMove}\n onMouseLeave={onMouseLeave}\n >\n <path d={pointsToSvgPath(triangleA)} />\n <path d={pointsToSvgPath(triangleB)} />\n <path d={pointsToSvgPath(triangleC)} />\n <path d={pointsToSvgPath(triangleD)} />\n </g>\n\n <clipPath id={clipPathId}>\n <path d={clipPath} />\n </clipPath>\n\n {debug && <path className={styles.rectDebug} d={clipPath} />}\n </svg>\n ) : null}\n </div>\n );\n});\n"],"names":["mergeClasses","useId","React","useSyncExternalStore","getRectCorners","getMouseAnchor","pointsToSvgPath","useStyles","computeOutsideClipPath","EMPTY_RECT","top","right","bottom","left","width","height","x","y","toJSON","isSameRect","a","b","isSameCoordinates","SafeZoneArea","memo","props","debug","onMouseEnter","onMouseMove","onMouseLeave","stateStore","clipPathId","styles","active","subscribe","isActive","svgRef","useRef","state","setState","useState","containerRect","targetRect","mouseCoordinates","useImperativeHandle","imperativeRef","updateSVG","newState","prevState","topOffset","Math","min","leftOffset","bottomOffset","max","rightOffset","containerCorners","targetCorners","relativeMouseCoordinates","mouseAnchor","topLeft","bottomRight","triangleA","topRight","triangleB","triangleC","bottomLeft","triangleD","svgWidth","svgHeight","clipPath","div","className","wrapper","wrapperActive","data-safe-zone","svg","aria-hidden","xmlns","ref","style","transform","g","triangle","triangleDebug","path","d","id","rectDebug"],"mappings":"AAAA;AAEA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,KAAK,QAAQ,4BAA4B;AAElD,YAAYC,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,+BAA+B;AAGpE,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,SAAS,QAAQ,2BAAwB;AAElD,SAASC,sBAAsB,QAAQ,8BAA2B;AAgClE,MAAM;AAEN,MAAMC,aAAsB;IAC1BC,KAAK;IACLC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,GAAG;IACHC,GAAG;IACHC;QACE,OAAO;IACT;AACF;AAEA,OAAO,SAASC,WAAWC,CAAU,EAAEC,CAAU;IAC/C,OACED,EAAEV,GAAG,KAAKW,EAAEX,GAAG,IACfU,EAAET,KAAK,KAAKU,EAAEV,KAAK,IACnBS,EAAER,MAAM,KAAKS,EAAET,MAAM,IACrBQ,EAAEP,IAAI,KAAKQ,EAAER,IAAI,IACjBO,EAAEN,KAAK,KAAKO,EAAEP,KAAK,IACnBM,EAAEL,MAAM,KAAKM,EAAEN,MAAM;AAEzB;AAEA,OAAO,SAASO,kBAAkBF,CAAQ,EAAEC,CAAQ;IAClD,OAAOD,CAAC,CAAC,EAAE,KAAKC,CAAC,CAAC,EAAE,IAAID,CAAC,CAAC,EAAE,KAAKC,CAAC,CAAC,EAAE;AACvC;AAEA,MAAM;AAEN;;;;;;;;;CASC,GACD,OAAO,MAAME,6BAAerB,MAAMsB,IAAI,CAAC,CAACC;IACtC,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,WAAW,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGL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AAU,EAAE7B,WAAW,IAAI,EAAEH,UAAU,GAAG,CAAC;QACzD;qBAEA,oBAACiC;QACCV,WAAWxE,aAAagC,OAAOmD,QAAQ,EAAEzD,SAASM,OAAOoD,aAAa;QACtEd,UAAU,CAAC,KAAK,EAAEvC,WAAW,CAAC,CAAC;QAC/BJ,cAAcA;QACdC,aAAaA;QACbC,cAAcA;qBAEd,oBAACwD;QAAKC,GAAGhF,gBAAgBwD;sBACzB,oBAACuB;QAAKC,GAAGhF,gBAAgB0D;sBACzB,oBAACqB;QAAKC,GAAGhF,gBAAgB2D;sBACzB,oBAACoB;QAAKC,GAAGhF,gBAAgB6D;uBAG3B,oBAACG;QAASiB,IAAIxD;qBACZ,oBAACsD;QAAKC,GAAGhB;SAGV5C,uBAAS,oBAAC2D;QAAKb,WAAWxC,OAAOwD,SAAS;QAAEF,GAAGhB;UAEhD;AAGV,GAAG"}
1
+ {"version":3,"sources":["../../../src/hooks/useSafeZoneArea/SafeZoneArea.tsx"],"sourcesContent":["'use client';\n\nimport { mergeClasses } from '@griffel/react';\nimport { useId } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nimport type { createSafeZoneAreaStateStore } from './createSafeZoneAreaStateStore';\nimport { getRectCorners } from './getRectCorners';\nimport { getMouseAnchor } from './getMouseAnchor';\nimport { pointsToSvgPath } from './pointsToSvgPath';\nimport { useStyles } from './SafeZoneArea.styles';\nimport type { Point } from './types';\nimport { computeOutsideClipPath } from './computeOutsideClipPath';\nimport { getSafeZonePoints } from './getSafeZonePoints';\n\nexport type SafeZoneAreaImperativeHandle = {\n updateSVG: (options: { containerRect: DOMRect; targetRect: DOMRect; mouseCoordinates: Point }) => void;\n};\n\nexport type SafeZoneAreaProps = {\n /** Enables debug mode: makes drawn shapes visible. */\n debug: boolean;\n\n /** A reference to the SafeZoneArea imperative handle. */\n imperativeRef: React.Ref<SafeZoneAreaImperativeHandle>;\n\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseEnter: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseMove: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseLeave: (e: React.MouseEvent) => void;\n\n stateStore: ReturnType<typeof createSafeZoneAreaStateStore>;\n};\n\n// ---\n\n/**\n * A component that renders a safe zone area with SVG shapes. Uses `useSyncExternalStore` to manage its active state\n * to avoid causing re-renders in `useSafeZoneArea()` as the hook might be used in host components like `Menu`.\n *\n * Draws a polygon from the mouse to the facing edges of the container and clips out the target element.\n *\n * @internal\n */\nexport const SafeZoneArea = React.memo((props: SafeZoneAreaProps): JSXElement => {\n const { debug, onMouseEnter, onMouseMove, onMouseLeave, stateStore } = props;\n\n const clipPathId = useId();\n const styles = useStyles();\n\n const active = useSyncExternalStore(stateStore.subscribe, stateStore.isActive);\n const svgRef = React.useRef<SVGSVGElement>(null);\n const safeZoneRef = React.useRef<SVGPathElement>(null);\n const clipPathRef = React.useRef<SVGPathElement>(null);\n const rectDebugRef = React.useRef<SVGPathElement>(null);\n\n React.useImperativeHandle(\n props.imperativeRef,\n () => ({\n updateSVG({ containerRect, targetRect, mouseCoordinates }) {\n const topOffset = Math.min(targetRect.top, containerRect.top);\n const leftOffset = Math.min(targetRect.left, containerRect.left);\n const bottomOffset = Math.max(targetRect.bottom, containerRect.bottom);\n const rightOffset = Math.max(targetRect.right, containerRect.right);\n\n const containerCorners = getRectCorners(containerRect, [leftOffset, topOffset]);\n const targetCorners = getRectCorners(targetRect, [leftOffset, topOffset]);\n\n // SVG coordinates are relative to its top-left corner.\n const relativeMouseCoordinates: Point = [mouseCoordinates[0] - leftOffset, mouseCoordinates[1] - topOffset];\n const mouseAnchor = getMouseAnchor(\n containerCorners.topLeft,\n containerCorners.bottomRight,\n relativeMouseCoordinates,\n );\n\n const svgWidth = rightOffset - leftOffset;\n const svgHeight = bottomOffset - topOffset;\n const clipPath = computeOutsideClipPath(svgWidth, svgHeight, {\n x: targetCorners.topLeft[0],\n y: targetCorners.topLeft[1],\n width: targetRect.width,\n height: targetRect.height,\n });\n\n if (svgRef.current) {\n svgRef.current.style.width = `${svgWidth}px`;\n svgRef.current.style.height = `${svgHeight}px`;\n svgRef.current.style.transform = `translate(${leftOffset}px, ${topOffset}px)`;\n }\n\n const safeZonePoints = getSafeZonePoints(mouseAnchor, containerCorners);\n safeZoneRef.current?.setAttribute('d', safeZonePoints.length > 0 ? pointsToSvgPath(safeZonePoints) : '');\n clipPathRef.current?.setAttribute('d', clipPath);\n rectDebugRef.current?.setAttribute('d', clipPath);\n },\n }),\n [],\n );\n\n return (\n <div className={mergeClasses(styles.wrapper, active && styles.wrapperActive)} data-safe-zone=\"\">\n <svg\n aria-hidden\n className={styles.svg}\n xmlns=\"http://www.w3.org/2000/svg\"\n ref={svgRef}\n style={{ width: 0, height: 0, transform: 'translate(0px, 0px)' }}\n >\n <g\n className={mergeClasses(styles.safeZone, debug && styles.safeZoneDebug)}\n clipPath={`url(#${clipPathId})`}\n onMouseEnter={onMouseEnter}\n onMouseMove={onMouseMove}\n onMouseLeave={onMouseLeave}\n >\n <path ref={safeZoneRef} />\n </g>\n\n <clipPath id={clipPathId}>\n <path ref={clipPathRef} />\n </clipPath>\n\n {debug && <path ref={rectDebugRef} className={styles.rectDebug} />}\n </svg>\n </div>\n );\n});\n"],"names":["mergeClasses","useId","React","useSyncExternalStore","getRectCorners","getMouseAnchor","pointsToSvgPath","useStyles","computeOutsideClipPath","getSafeZonePoints","SafeZoneArea","memo","props","debug","onMouseEnter","onMouseMove","onMouseLeave","stateStore","clipPathId","styles","active","subscribe","isActive","svgRef","useRef","safeZoneRef","clipPathRef","rectDebugRef","useImperativeHandle","imperativeRef","updateSVG","containerRect","targetRect","mouseCoordinates","topOffset","Math","min","top","leftOffset","left","bottomOffset","max","bottom","rightOffset","right","containerCorners","targetCorners","relativeMouseCoordinates","mouseAnchor","topLeft","bottomRight","svgWidth","svgHeight","clipPath","x","y","width","height","current","style","transform","safeZonePoints","setAttribute","length","div","className","wrapper","wrapperActive","data-safe-zone","svg","aria-hidden","xmlns","ref","g","safeZone","safeZoneDebug","path","id","rectDebug"],"mappings":"AAAA;AAEA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,KAAK,QAAQ,4BAA4B;AAElD,YAAYC,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,+BAA+B;AAGpE,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,SAAS,QAAQ,2BAAwB;AAElD,SAASC,sBAAsB,QAAQ,8BAA2B;AAClE,SAASC,iBAAiB,QAAQ,yBAAsB;AAuBxD,MAAM;AAEN;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAAeR,MAAMS,IAAI,CAAC,CAACC;IACtC,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,WAAW,EAAEC,YAAY,EAAEC,UAAU,EAAE,GAAGL;IAEvE,MAAMM,aAAajB;IACnB,MAAMkB,SAASZ;IAEf,MAAMa,SAASjB,qBAAqBc,WAAWI,SAAS,EAAEJ,WAAWK,QAAQ;IAC7E,MAAMC,SAASrB,MAAMsB,MAAM,CAAgB;IAC3C,MAAMC,cAAcvB,MAAMsB,MAAM,CAAiB;IACjD,MAAME,cAAcxB,MAAMsB,MAAM,CAAiB;IACjD,MAAMG,eAAezB,MAAMsB,MAAM,CAAiB;IAElDtB,MAAM0B,mBAAmB,CACvBhB,MAAMiB,aAAa,EACnB,IAAO,CAAA;YACLC,WAAU,EAAEC,aAAa,EAAEC,UAAU,EAAEC,gBAAgB,EAAE;oBAiCvDR,sBACAC,sBACAC;gBAlCA,MAAMO,YAAYC,KAAKC,GAAG,CAACJ,WAAWK,GAAG,EAAEN,cAAcM,GAAG;gBAC5D,MAAMC,aAAaH,KAAKC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eAAeE,MAAM,GAAG,IAAIzD,gBAAgBuD,kBAAkB;iBACrGnC,uBAAAA,YAAYgC,OAAO,cAAnBhC,2CAAAA,qBAAqBoC,YAAY,CAAC,KAAKT;iBACvC1B,wBAAAA,aAAa+B,OAAO,cAApB/B,4CAAAA,sBAAsBmC,YAAY,CAAC,KAAKT;YAC1C;QACF,CAAA,GACA,EAAE;IAGJ,qBACE,oBAACW;QAAIC,WAAWjE,aAAamB,OAAO+C,OAAO,EAAE9C,UAAUD,OAAOgD,aAAa;QAAGC,kBAAe;qBAC3F,oBAACC;QACCC,eAAAA;QACAL,WAAW9C,OAAOkD,GAAG;QACrBE,OAAM;QACNC,KAAKjD;QACLoC,OAAO;YAAEH,OAAO;YAAGC,QAAQ;YAAGG,WAAW;QAAsB;qBAE/D,oBAACa;QACCR,WAAWjE,aAAamB,OAAOuD,QAAQ,EAAE7D,SAASM,OAAOwD,aAAa;QACtEtB,UAAU,CAAC,KAAK,EAAEnC,WAAW,CAAC,CAAC;QAC/BJ,cAAcA;QACdC,aAAaA;QACbC,cAAcA;qBAEd,oBAAC4D;QAAKJ,KAAK/C;uBAGb,oBAAC4B;QAASwB,IAAI3D;qBACZ,oBAAC0D;QAAKJ,KAAK9C;SAGZb,uBAAS,oBAAC+D;QAAKJ,KAAK7C;QAAcsC,WAAW9C,OAAO2D,SAAS;;AAItE,GAAG"}
@@ -0,0 +1,28 @@
1
+ @layer fluentui {
2
+ .wrapper {
3
+ display: none;
4
+ height: 0;
5
+ width: 0;
6
+ pointer-events: none;
7
+ }
8
+ .wrapperActive {
9
+ display: block;
10
+ }
11
+ .svg {
12
+ fill: transparent;
13
+ pointer-events: none;
14
+ position: fixed;
15
+ top: 0;
16
+ inset-inline-start: 0;
17
+ }
18
+ .safeZone {
19
+ pointer-events: auto;
20
+ }
21
+ .safeZoneDebug {
22
+ cursor: crosshair;
23
+ fill: color-mix(in srgb, var(--colorPaletteGreenBackground3) 20%, transparent);
24
+ }
25
+ .rectDebug {
26
+ fill: color-mix(in srgb, var(--colorPaletteRedBackground3) 20%, transparent);
27
+ }
28
+ }
@@ -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"}
@@ -19,10 +19,10 @@ export const useStyles = /*#__PURE__*/__styles({
19
19
  Bhzewxz: "f15twtuk",
20
20
  oyh7mz: ["f1vgc2s3", "f1e31b4d"]
21
21
  },
22
- triangle: {
22
+ safeZone: {
23
23
  Bkecrkj: "f1cguypg"
24
24
  },
25
- triangleDebug: {
25
+ safeZoneDebug: {
26
26
  Bceei9c: "f7116n6",
27
27
  Bkfmm31: "f1xab38x"
28
28
  },
@@ -1 +1 @@
1
- {"version":3,"names":["__styles","tokens","useStyles","wrapper","mc9l5x","Bqenvij","a9b677","Bkecrkj","wrapperActive","svg","Bkfmm31","qhf8xq","Bhzewxz","oyh7mz","triangle","triangleDebug","Bceei9c","rectDebug","d"],"sources":["SafeZoneArea.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles } from \"@griffel/react\";\nimport { tokens } from \"@fluentui/react-theme\";\nexport const useStyles = makeStyles({\n wrapper: {\n display: 'none',\n height: 0,\n width: 0,\n pointerEvents: 'none'\n },\n wrapperActive: {\n display: 'block'\n },\n svg: {\n fill: 'transparent',\n pointerEvents: 'none',\n position: 'fixed',\n top: 0,\n left: 0\n },\n triangle: {\n pointerEvents: 'auto'\n },\n triangleDebug: {\n cursor: 'crosshair',\n fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`\n },\n rectDebug: {\n fill: `color-mix(in srgb, ${tokens.colorPaletteRedBackground3} 20%, transparent)`\n }\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,QAA2B,gBAAgB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAO,MAAMC,SAAS,gBAAGF,QAAA;EAAAG,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,aAAA;IAAAJ,MAAA;EAAA;EAAAK,GAAA;IAAAC,OAAA;IAAAH,OAAA;IAAAI,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAP,OAAA;EAAA;EAAAQ,aAAA;IAAAC,OAAA;IAAAN,OAAA;EAAA;EAAAO,SAAA;IAAAP,OAAA;EAAA;AAAA;EAAAQ,CAAA;AAAA,CA2BxB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["__styles","tokens","useStyles","wrapper","mc9l5x","Bqenvij","a9b677","Bkecrkj","wrapperActive","svg","Bkfmm31","qhf8xq","Bhzewxz","oyh7mz","safeZone","safeZoneDebug","Bceei9c","rectDebug","d"],"sources":["SafeZoneArea.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles } from \"@griffel/react\";\nimport { tokens } from \"@fluentui/react-theme\";\nexport const useStyles = makeStyles({\n wrapper: {\n display: 'none',\n height: 0,\n width: 0,\n pointerEvents: 'none'\n },\n wrapperActive: {\n display: 'block'\n },\n svg: {\n fill: 'transparent',\n pointerEvents: 'none',\n position: 'fixed',\n top: 0,\n left: 0\n },\n safeZone: {\n pointerEvents: 'auto'\n },\n safeZoneDebug: {\n cursor: 'crosshair',\n fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`\n },\n rectDebug: {\n fill: `color-mix(in srgb, ${tokens.colorPaletteRedBackground3} 20%, transparent)`\n }\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,QAA2B,gBAAgB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAO,MAAMC,SAAS,gBAAGF,QAAA;EAAAG,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,aAAA;IAAAJ,MAAA;EAAA;EAAAK,GAAA;IAAAC,OAAA;IAAAH,OAAA;IAAAI,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAP,OAAA;EAAA;EAAAQ,aAAA;IAAAC,OAAA;IAAAN,OAAA;EAAA;EAAAO,SAAA;IAAAP,OAAA;EAAA;AAAA;EAAAQ,CAAA;AAAA,CA2BxB,CAAC","ignoreList":[]}
@@ -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"}
@@ -18,10 +18,10 @@ export const useStyles = makeStyles({
18
18
  top: 0,
19
19
  left: 0
20
20
  },
21
- triangle: {
21
+ safeZone: {
22
22
  pointerEvents: 'auto'
23
23
  },
24
- triangleDebug: {
24
+ safeZoneDebug: {
25
25
  cursor: 'crosshair',
26
26
  fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`
27
27
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useSafeZoneArea/SafeZoneArea.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\n\nexport const useStyles = makeStyles({\n wrapper: {\n display: 'none',\n height: 0,\n width: 0,\n pointerEvents: 'none',\n },\n wrapperActive: {\n display: 'block',\n },\n svg: {\n fill: 'transparent',\n pointerEvents: 'none',\n position: 'fixed',\n top: 0,\n left: 0,\n },\n triangle: {\n pointerEvents: 'auto',\n },\n triangleDebug: {\n cursor: 'crosshair',\n fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`,\n },\n rectDebug: {\n fill: `color-mix(in srgb, ${tokens.colorPaletteRedBackground3} 20%, transparent)`,\n },\n});\n"],"names":["makeStyles","tokens","useStyles","wrapper","display","height","width","pointerEvents","wrapperActive","svg","fill","position","top","left","triangle","triangleDebug","cursor","colorPaletteGreenBackground3","rectDebug","colorPaletteRedBackground3"],"mappings":"AAAA;AAEA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,MAAM,QAAQ,wBAAwB;AAE/C,OAAO,MAAMC,YAAYF,WAAW;IAClCG,SAAS;QACPC,SAAS;QACTC,QAAQ;QACRC,OAAO;QACPC,eAAe;IACjB;IACAC,eAAe;QACbJ,SAAS;IACX;IACAK,KAAK;QACHC,MAAM;QACNH,eAAe;QACfI,UAAU;QACVC,KAAK;QACLC,MAAM;IACR;IACAC,UAAU;QACRP,eAAe;IACjB;IACAQ,eAAe;QACbC,QAAQ;QACRN,MAAM,CAAC,mBAAmB,EAAET,OAAOgB,4BAA4B,CAAC,kBAAkB,CAAC;IACrF;IACAC,WAAW;QACTR,MAAM,CAAC,mBAAmB,EAAET,OAAOkB,0BAA0B,CAAC,kBAAkB,CAAC;IACnF;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/hooks/useSafeZoneArea/SafeZoneArea.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\n\nexport const useStyles = makeStyles({\n wrapper: {\n display: 'none',\n height: 0,\n width: 0,\n pointerEvents: 'none',\n },\n wrapperActive: {\n display: 'block',\n },\n svg: {\n fill: 'transparent',\n pointerEvents: 'none',\n position: 'fixed',\n top: 0,\n left: 0,\n },\n safeZone: {\n pointerEvents: 'auto',\n },\n safeZoneDebug: {\n cursor: 'crosshair',\n fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`,\n },\n rectDebug: {\n fill: `color-mix(in srgb, ${tokens.colorPaletteRedBackground3} 20%, transparent)`,\n },\n});\n"],"names":["makeStyles","tokens","useStyles","wrapper","display","height","width","pointerEvents","wrapperActive","svg","fill","position","top","left","safeZone","safeZoneDebug","cursor","colorPaletteGreenBackground3","rectDebug","colorPaletteRedBackground3"],"mappings":"AAAA;AAEA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,MAAM,QAAQ,wBAAwB;AAE/C,OAAO,MAAMC,YAAYF,WAAW;IAClCG,SAAS;QACPC,SAAS;QACTC,QAAQ;QACRC,OAAO;QACPC,eAAe;IACjB;IACAC,eAAe;QACbJ,SAAS;IACX;IACAK,KAAK;QACHC,MAAM;QACNH,eAAe;QACfI,UAAU;QACVC,KAAK;QACLC,MAAM;IACR;IACAC,UAAU;QACRP,eAAe;IACjB;IACAQ,eAAe;QACbC,QAAQ;QACRN,MAAM,CAAC,mBAAmB,EAAET,OAAOgB,4BAA4B,CAAC,kBAAkB,CAAC;IACrF;IACAC,WAAW;QACTR,MAAM,CAAC,mBAAmB,EAAET,OAAOkB,0BAA0B,CAAC,kBAAkB,CAAC;IACnF;AACF,GAAG"}