@fluentui/react-positioning 0.0.0-nightly-20230316-0427.1 → 0.0.0-nightly-20230317-1454.1

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 (132) hide show
  1. package/.swcrc +39 -0
  2. package/CHANGELOG.json +24 -9
  3. package/CHANGELOG.md +16 -7
  4. package/lib/constants.js +4 -4
  5. package/lib/constants.js.map +1 -1
  6. package/lib/createArrowStyles.js +19 -19
  7. package/lib/createArrowStyles.js.map +1 -1
  8. package/lib/createPositionManager.js +13 -13
  9. package/lib/createPositionManager.js.map +1 -1
  10. package/lib/createVirtualElementFromClick.js +1 -2
  11. package/lib/createVirtualElementFromClick.js.map +1 -1
  12. package/lib/index.js +5 -5
  13. package/lib/index.js.map +1 -1
  14. package/lib/middleware/coverTarget.js +6 -6
  15. package/lib/middleware/coverTarget.js.map +1 -1
  16. package/lib/middleware/flip.js +4 -4
  17. package/lib/middleware/flip.js.map +1 -1
  18. package/lib/middleware/index.js +6 -6
  19. package/lib/middleware/index.js.map +1 -1
  20. package/lib/middleware/intersecting.js +2 -2
  21. package/lib/middleware/intersecting.js.map +1 -1
  22. package/lib/middleware/maxSize.js +8 -8
  23. package/lib/middleware/maxSize.js.map +1 -1
  24. package/lib/middleware/offset.js +2 -2
  25. package/lib/middleware/offset.js.map +1 -1
  26. package/lib/middleware/shift.js +5 -5
  27. package/lib/middleware/shift.js.map +1 -1
  28. package/lib/types.js +1 -1
  29. package/lib/types.js.map +1 -1
  30. package/lib/usePositioning.js +20 -26
  31. package/lib/usePositioning.js.map +1 -1
  32. package/lib/usePositioningMouseTarget.js +4 -4
  33. package/lib/usePositioningMouseTarget.js.map +1 -1
  34. package/lib/utils/debounce.js +1 -2
  35. package/lib/utils/debounce.js.map +1 -1
  36. package/lib/utils/fromFloatingUIPlacement.js +10 -10
  37. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  38. package/lib/utils/getBoundary.js +8 -8
  39. package/lib/utils/getBoundary.js.map +1 -1
  40. package/lib/utils/getFloatingUIOffset.js +2 -2
  41. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  42. package/lib/utils/getReactFiberFromNode.js +3 -2
  43. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  44. package/lib/utils/getScrollParent.js +7 -10
  45. package/lib/utils/getScrollParent.js.map +1 -1
  46. package/lib/utils/hasAutoFocusFilter.js +3 -4
  47. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  48. package/lib/utils/index.js +15 -15
  49. package/lib/utils/index.js.map +1 -1
  50. package/lib/utils/mergeArrowOffset.js +6 -8
  51. package/lib/utils/mergeArrowOffset.js.map +1 -1
  52. package/lib/utils/parseFloatingUIPlacement.js +2 -3
  53. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  54. package/lib/utils/resolvePositioningShorthand.js +33 -33
  55. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  56. package/lib/utils/toFloatingUIPadding.js +3 -3
  57. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  58. package/lib/utils/toFloatingUIPlacement.js +11 -11
  59. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  60. package/lib/utils/toggleScrollListener.js +4 -4
  61. package/lib/utils/toggleScrollListener.js.map +1 -1
  62. package/lib/utils/useCallbackRef.js +2 -2
  63. package/lib/utils/useCallbackRef.js.map +1 -1
  64. package/lib/utils/writeArrowUpdates.js +1 -2
  65. package/lib/utils/writeArrowUpdates.js.map +1 -1
  66. package/lib/utils/writeContainerupdates.js +7 -8
  67. package/lib/utils/writeContainerupdates.js.map +1 -1
  68. package/lib-commonjs/constants.js +18 -7
  69. package/lib-commonjs/constants.js.map +1 -1
  70. package/lib-commonjs/createArrowStyles.js +60 -88
  71. package/lib-commonjs/createArrowStyles.js.map +1 -1
  72. package/lib-commonjs/createPositionManager.js +103 -117
  73. package/lib-commonjs/createPositionManager.js.map +1 -1
  74. package/lib-commonjs/createVirtualElementFromClick.js +27 -26
  75. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  76. package/lib-commonjs/index.js +24 -51
  77. package/lib-commonjs/index.js.map +1 -1
  78. package/lib-commonjs/middleware/coverTarget.js +34 -37
  79. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  80. package/lib-commonjs/middleware/flip.js +31 -38
  81. package/lib-commonjs/middleware/flip.js.map +1 -1
  82. package/lib-commonjs/middleware/index.js +10 -9
  83. package/lib-commonjs/middleware/index.js.map +1 -1
  84. package/lib-commonjs/middleware/intersecting.js +24 -22
  85. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  86. package/lib-commonjs/middleware/maxSize.js +34 -40
  87. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  88. package/lib-commonjs/middleware/offset.js +11 -12
  89. package/lib-commonjs/middleware/offset.js.map +1 -1
  90. package/lib-commonjs/middleware/shift.js +29 -37
  91. package/lib-commonjs/middleware/shift.js.map +1 -1
  92. package/lib-commonjs/types.js +5 -2
  93. package/lib-commonjs/types.js.map +1 -1
  94. package/lib-commonjs/usePositioning.js +192 -164
  95. package/lib-commonjs/usePositioning.js.map +1 -1
  96. package/lib-commonjs/usePositioningMouseTarget.js +34 -37
  97. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  98. package/lib-commonjs/utils/debounce.js +22 -21
  99. package/lib-commonjs/utils/debounce.js.map +1 -1
  100. package/lib-commonjs/utils/fromFloatingUIPlacement.js +30 -35
  101. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  102. package/lib-commonjs/utils/getBoundary.js +21 -22
  103. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  104. package/lib-commonjs/utils/getFloatingUIOffset.js +23 -35
  105. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  106. package/lib-commonjs/utils/getReactFiberFromNode.js +45 -41
  107. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  108. package/lib-commonjs/utils/getScrollParent.js +50 -56
  109. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  110. package/lib-commonjs/utils/hasAutoFocusFilter.js +17 -17
  111. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  112. package/lib-commonjs/utils/index.js +19 -18
  113. package/lib-commonjs/utils/index.js.map +1 -1
  114. package/lib-commonjs/utils/mergeArrowOffset.js +32 -32
  115. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  116. package/lib-commonjs/utils/parseFloatingUIPlacement.js +15 -14
  117. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  118. package/lib-commonjs/utils/resolvePositioningShorthand.js +63 -61
  119. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  120. package/lib-commonjs/utils/toFloatingUIPadding.js +23 -25
  121. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  122. package/lib-commonjs/utils/toFloatingUIPlacement.js +31 -33
  123. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  124. package/lib-commonjs/utils/toggleScrollListener.js +20 -24
  125. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  126. package/lib-commonjs/utils/useCallbackRef.js +39 -53
  127. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  128. package/lib-commonjs/utils/writeArrowUpdates.js +19 -24
  129. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  130. package/lib-commonjs/utils/writeContainerupdates.js +36 -45
  131. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  132. package/package.json +6 -6
package/.swcrc ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/swcrc",
3
+ "env": {
4
+ "targets": {
5
+ "chrome": "84",
6
+ "edge": "84",
7
+ "firefox": "75",
8
+ "opera": "73",
9
+ "safari": "14.1"
10
+ },
11
+ "bugfixes": true
12
+ },
13
+ "exclude": [
14
+ "/testing",
15
+ "/**/*.cy.ts",
16
+ "/**/*.cy.tsx",
17
+ "/**/*.spec.ts",
18
+ "/**/*.spec.tsx",
19
+ "/**/*.test.ts",
20
+ "/**/*.test.tsx"
21
+ ],
22
+ "jsc": {
23
+ "parser": {
24
+ "syntax": "typescript",
25
+ "tsx": true,
26
+ "decorators": false,
27
+ "dynamicImport": false
28
+ },
29
+ "externalHelpers": true,
30
+ "transform": {
31
+ "react": {
32
+ "runtime": "classic",
33
+ "useSpread": true
34
+ }
35
+ }
36
+ },
37
+ "minify": false,
38
+ "sourceMaps": true
39
+ }
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-positioning",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 16 Mar 2023 04:34:04 GMT",
6
- "tag": "@fluentui/react-positioning_v0.0.0-nightly-20230316-0427.1",
7
- "version": "0.0.0-nightly-20230316-0427.1",
5
+ "date": "Fri, 17 Mar 2023 15:00:02 GMT",
6
+ "tag": "@fluentui/react-positioning_v0.0.0-nightly-20230317-1454.1",
7
+ "version": "0.0.0-nightly-20230317-1454.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,20 +16,35 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-positioning",
19
- "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230316-0427.1",
20
- "commit": "3738c812cde18d4b2446cb53b7f78fee5702707c"
19
+ "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230317-1454.1",
20
+ "commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
24
  "package": "@fluentui/react-positioning",
25
- "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230316-0427.1",
26
- "commit": "3738c812cde18d4b2446cb53b7f78fee5702707c"
25
+ "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230317-1454.1",
26
+ "commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
30
  "package": "@fluentui/react-positioning",
31
- "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230316-0427.1",
32
- "commit": "3738c812cde18d4b2446cb53b7f78fee5702707c"
31
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1",
32
+ "commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "date": "Thu, 16 Mar 2023 14:36:59 GMT",
39
+ "tag": "@fluentui/react-positioning_v9.5.5",
40
+ "version": "9.5.5",
41
+ "comments": {
42
+ "patch": [
43
+ {
44
+ "author": "beachball",
45
+ "package": "@fluentui/react-positioning",
46
+ "comment": "Bump @fluentui/react-utilities to v9.7.1",
47
+ "commit": "e7dcadf7cabae6bc6811ca04a630e7d850388f81"
33
48
  }
34
49
  ]
35
50
  }
package/CHANGELOG.md CHANGED
@@ -1,20 +1,29 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Thu, 16 Mar 2023 04:34:04 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 17 Mar 2023 15:00:02 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20230316-0427.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly-20230316-0427.1)
7
+ ## [0.0.0-nightly-20230317-1454.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly-20230317-1454.1)
8
8
 
9
- Thu, 16 Mar 2023 04:34:04 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.4..@fluentui/react-positioning_v0.0.0-nightly-20230316-0427.1)
9
+ Fri, 17 Mar 2023 15:00:02 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.5..@fluentui/react-positioning_v0.0.0-nightly-20230317-1454.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230316-0427.1 ([commit](https://github.com/microsoft/fluentui/commit/3738c812cde18d4b2446cb53b7f78fee5702707c) by beachball)
16
- - Bump @fluentui/react-theme to v0.0.0-nightly-20230316-0427.1 ([commit](https://github.com/microsoft/fluentui/commit/3738c812cde18d4b2446cb53b7f78fee5702707c) by beachball)
17
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20230316-0427.1 ([commit](https://github.com/microsoft/fluentui/commit/3738c812cde18d4b2446cb53b7f78fee5702707c) by beachball)
15
+ - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
16
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
17
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
18
+
19
+ ## [9.5.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.5.5)
20
+
21
+ Thu, 16 Mar 2023 14:36:59 GMT
22
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.4..@fluentui/react-positioning_v9.5.5)
23
+
24
+ ### Patches
25
+
26
+ - Bump @fluentui/react-utilities to v9.7.1 ([PR #27229](https://github.com/microsoft/fluentui/pull/27229) by beachball)
18
27
 
19
28
  ## [9.5.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.5.4)
20
29
 
package/lib/constants.js CHANGED
@@ -1,5 +1,5 @@
1
- export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';
2
- export const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
3
- export const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
4
- export const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
1
+ export const DATA_POSITIONING_INTERSECTING = "data-popper-is-intersecting";
2
+ export const DATA_POSITIONING_ESCAPED = "data-popper-escaped";
3
+ export const DATA_POSITIONING_HIDDEN = "data-popper-reference-hidden";
4
+ export const DATA_POSITIONING_PLACEMENT = "data-popper-placement";
5
5
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,6BAA6B,CAAC;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AACtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC","sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n"]}
1
+ {"version":3,"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT"],"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n"],"mappings":"AAAA,OAAO,MAAMA,6BAAA,GAAgC;AAC7C,OAAO,MAAMC,wBAAA,GAA2B;AACxC,OAAO,MAAMC,uBAAA,GAA0B;AACvC,OAAO,MAAMC,0BAAA,GAA6B"}
@@ -1,5 +1,5 @@
1
- import { shorthands } from '@griffel/react';
2
- import { tokens } from '@fluentui/react-theme';
1
+ import { shorthands } from "@griffel/react";
2
+ import { tokens } from "@fluentui/react-theme";
3
3
  /**
4
4
  * @internal
5
5
  * Helper that creates a makeStyles rule for an arrow element.
@@ -26,45 +26,45 @@ import { tokens } from '@fluentui/react-theme';
26
26
  export function createArrowStyles(options) {
27
27
  const {
28
28
  arrowHeight,
29
- borderWidth = '1px',
30
- borderStyle = 'solid',
29
+ borderWidth = "1px",
30
+ borderStyle = "solid",
31
31
  borderColor = tokens.colorTransparentStroke
32
32
  } = options;
33
33
  return {
34
- position: 'absolute',
35
- backgroundColor: 'inherit',
36
- visibility: 'hidden',
34
+ position: "absolute",
35
+ backgroundColor: "inherit",
36
+ visibility: "hidden",
37
37
  zIndex: -1,
38
38
  ...(arrowHeight && createArrowHeightStyles(arrowHeight)),
39
- '::before': {
39
+ "::before": {
40
40
  content: '""',
41
- visibility: 'visible',
42
- position: 'absolute',
43
- boxSizing: 'border-box',
44
- width: 'inherit',
45
- height: 'inherit',
46
- backgroundColor: 'inherit',
41
+ visibility: "visible",
42
+ position: "absolute",
43
+ boxSizing: "border-box",
44
+ width: "inherit",
45
+ height: "inherit",
46
+ backgroundColor: "inherit",
47
47
  ...shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),
48
48
  ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),
49
49
  borderBottomRightRadius: tokens.borderRadiusSmall,
50
- transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
50
+ transform: "rotate(var(--angle)) translate(0, 50%) rotate(45deg)"
51
51
  },
52
52
  // Popper sets data-popper-placement on the root element, which is used to align the arrow
53
53
  ':global([data-popper-placement^="top"])': {
54
54
  bottom: `-${borderWidth}`,
55
- '--angle': '0'
55
+ "--angle": "0"
56
56
  },
57
57
  ':global([data-popper-placement^="right"])': {
58
58
  left: `-${borderWidth} /* @noflip */`,
59
- '--angle': '90deg'
59
+ "--angle": "90deg"
60
60
  },
61
61
  ':global([data-popper-placement^="bottom"])': {
62
62
  top: `-${borderWidth}`,
63
- '--angle': '180deg'
63
+ "--angle": "180deg"
64
64
  },
65
65
  ':global([data-popper-placement^="left"])': {
66
66
  right: `-${borderWidth} /* @noflip */`,
67
- '--angle': '270deg'
67
+ "--angle": "270deg"
68
68
  }
69
69
  };
70
70
  }
@@ -1 +1 @@
1
- {"version":3,"names":["shorthands","tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"sources":["../../../../../../../packages/react-components/react-positioning/src/createArrowStyles.ts"],"sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * @internal\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAsC9C;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAM,SAAUC,iBAAiBA,CAACC,OAAiC;EACjE,MAAM;IACJC,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,WAAW,GAAG,OAAO;IACrBC,WAAW,GAAGN,MAAM,CAACO;EAAsB,CAC5C,GAAGL,OAAO;EAEX,OAAO;IACLM,QAAQ,EAAE,UAAU;IACpBC,eAAe,EAAE,SAAS;IAC1BC,UAAU,EAAE,QAAQ;IACpBC,MAAM,EAAE,CAAC,CAAC;IAEV,IAAIR,WAAW,IAAIS,uBAAuB,CAACT,WAAW,CAAC,CAAC;IAExD,UAAU,EAAE;MACVU,OAAO,EAAE,IAAI;MACbH,UAAU,EAAE,SAAS;MACrBF,QAAQ,EAAE,UAAU;MACpBM,SAAS,EAAE,YAAY;MACvBC,KAAK,EAAE,SAAS;MAChBC,MAAM,EAAE,SAAS;MACjBP,eAAe,EAAE,SAAS;MAC1B,GAAGV,UAAU,CAACkB,WAAW,CACvB,GAAGb,WAAW,gBAAgB,EAC9B,GAAGC,WAAW,gBAAgB,EAC9B,GAAGC,WAAW,gBAAgB,CAC/B;MACD,GAAGP,UAAU,CAACmB,YAAY,CAACd,WAAW,EAAEC,WAAW,EAAEC,WAAW,CAAC;MACjEa,uBAAuB,EAAEnB,MAAM,CAACoB,iBAAiB;MACjDC,SAAS,EAAE;KACZ;IAED;IACA,yCAAyC,EAAE;MACzCC,MAAM,EAAE,IAAIlB,WAAW,EAAE;MACzB,SAAS,EAAE;KACZ;IACD,2CAA2C,EAAE;MAC3CmB,IAAI,EAAE,IAAInB,WAAW,gBAAgB;MACrC,SAAS,EAAE;KACZ;IACD,4CAA4C,EAAE;MAC5CoB,GAAG,EAAE,IAAIpB,WAAW,EAAE;MACtB,SAAS,EAAE;KACZ;IACD,0CAA0C,EAAE;MAC1CqB,KAAK,EAAE,IAAIrB,WAAW,gBAAgB;MACtC,SAAS,EAAE;;GAEd;AACH;AAEA;;;;;;;AAOA,OAAM,SAAUQ,uBAAuBA,CAACT,WAAmB;EACzD;EACA;EACA,MAAMuB,UAAU,GAAG,GAAG,KAAK,GAAGvB,WAAW,IAAI;EAC7C,OAAO;IAAEY,KAAK,EAAEW,UAAU;IAAEV,MAAM,EAAEU;EAAU,CAAE;AAClD"}
1
+ {"version":3,"names":["shorthands","tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"sources":["../src/createArrowStyles.ts"],"sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * @internal\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAC3B,SAASC,MAAM,QAAQ;AAsCvB;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,SAASC,kBAAkBC,OAAiC,EAAgB;EACjF,MAAM;IACJC,WAAA;IACAC,WAAA,GAAc;IACdC,WAAA,GAAc;IACdC,WAAA,GAAcN,MAAA,CAAOO;EAAsB,CAC5C,GAAGL,OAAA;EAEJ,OAAO;IACLM,QAAA,EAAU;IACVC,eAAA,EAAiB;IACjBC,UAAA,EAAY;IACZC,MAAA,EAAQ,CAAC;IAET,IAAIR,WAAA,IAAeS,uBAAA,CAAwBT,WAAA,CAAY;IAEvD,YAAY;MACVU,OAAA,EAAS;MACTH,UAAA,EAAY;MACZF,QAAA,EAAU;MACVM,SAAA,EAAW;MACXC,KAAA,EAAO;MACPC,MAAA,EAAQ;MACRP,eAAA,EAAiB;MACjB,GAAGV,UAAA,CAAWkB,WAAW,CACtB,GAAEb,WAAY,gBAAe,EAC7B,GAAEC,WAAY,gBAAe,EAC7B,GAAEC,WAAY,gBAAe,CAC/B;MACD,GAAGP,UAAA,CAAWmB,YAAY,CAACd,WAAA,EAAaC,WAAA,EAAaC,WAAA,CAAY;MACjEa,uBAAA,EAAyBnB,MAAA,CAAOoB,iBAAiB;MACjDC,SAAA,EAAW;IACb;IAEA;IACA,2CAA2C;MACzCC,MAAA,EAAS,IAAGlB,WAAY,EAAC;MACzB,WAAW;IACb;IACA,6CAA6C;MAC3CmB,IAAA,EAAO,IAAGnB,WAAY,gBAAe;MACrC,WAAW;IACb;IACA,8CAA8C;MAC5CoB,GAAA,EAAM,IAAGpB,WAAY,EAAC;MACtB,WAAW;IACb;IACA,4CAA4C;MAC1CqB,KAAA,EAAQ,IAAGrB,WAAY,gBAAe;MACtC,WAAW;IACb;EACF;AACF;AAEA;;;;;;;AAOA,OAAO,SAASQ,wBAAwBT,WAAmB,EAAE;EAC3D;EACA;EACA,MAAMuB,UAAA,GAAc,GAAE,QAAQvB,WAAY,IAAG;EAC7C,OAAO;IAAEY,KAAA,EAAOW,UAAA;IAAYV,MAAA,EAAQU;EAAW;AACjD"}
@@ -1,6 +1,6 @@
1
- import { computePosition } from '@floating-ui/dom';
2
- import { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';
3
- import { isHTMLElement } from '@fluentui/react-utilities';
1
+ import { computePosition } from "@floating-ui/dom";
2
+ import { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from "./utils";
3
+ import { isHTMLElement } from "@fluentui/react-utilities";
4
4
  /**
5
5
  * @internal
6
6
  * @returns manager that handles positioning out of the react lifecycle
@@ -27,7 +27,7 @@ export function createPositionManager(options) {
27
27
  // When the container is first resolved, set position `fixed` to avoid scroll jumps.
28
28
  // Without this scroll jumps can occur when the element is rendered initially and receives focus
29
29
  Object.assign(container.style, {
30
- position: 'fixed',
30
+ position: "fixed",
31
31
  left: 0,
32
32
  top: 0,
33
33
  margin: 0
@@ -44,7 +44,7 @@ export function createPositionManager(options) {
44
44
  scrollParents.add(getScrollParent(target));
45
45
  }
46
46
  scrollParents.forEach(scrollParent => {
47
- scrollParent.addEventListener('scroll', updatePosition);
47
+ scrollParent.addEventListener("scroll", updatePosition);
48
48
  });
49
49
  isFirstUpdate = false;
50
50
  }
@@ -78,7 +78,7 @@ export function createPositionManager(options) {
78
78
  x,
79
79
  y
80
80
  },
81
- lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,
81
+ lowPPI: (targetWindow?.devicePixelRatio || 1) <= 1,
82
82
  strategy
83
83
  });
84
84
  }).catch(err => {
@@ -89,9 +89,9 @@ export function createPositionManager(options) {
89
89
  // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist
90
90
  // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing
91
91
  // will actually be counter productive
92
- if (process.env.NODE_ENV === 'development') {
92
+ if (process.env.NODE_ENV === "development") {
93
93
  // eslint-disable-next-line no-console
94
- console.error('[usePositioning]: Failed to calculate position', err);
94
+ console.error("[usePositioning]: Failed to calculate position", err);
95
95
  }
96
96
  });
97
97
  };
@@ -99,16 +99,16 @@ export function createPositionManager(options) {
99
99
  const dispose = () => {
100
100
  isDestroyed = true;
101
101
  if (targetWindow) {
102
- targetWindow.removeEventListener('scroll', updatePosition);
103
- targetWindow.removeEventListener('resize', updatePosition);
102
+ targetWindow.removeEventListener("scroll", updatePosition);
103
+ targetWindow.removeEventListener("resize", updatePosition);
104
104
  }
105
105
  scrollParents.forEach(scrollParent => {
106
- scrollParent.removeEventListener('scroll', updatePosition);
106
+ scrollParent.removeEventListener("scroll", updatePosition);
107
107
  });
108
108
  };
109
109
  if (targetWindow) {
110
- targetWindow.addEventListener('scroll', updatePosition);
111
- targetWindow.addEventListener('resize', updatePosition);
110
+ targetWindow.addEventListener("scroll", updatePosition);
111
+ targetWindow.addEventListener("resize", updatePosition);
112
112
  }
113
113
  // Update the position on initialization
114
114
  updatePosition();
@@ -1 +1 @@
1
- {"version":3,"names":["computePosition","debounce","writeArrowUpdates","writeContainerUpdates","getScrollParent","isHTMLElement","createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","forEach","scrollParent","addEventListener","then","x","y","middlewareData","computedPlacement","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","removeEventListener"],"sources":["../../../../../../../packages/react-components/react-positioning/src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';\nimport { isHTMLElement } from '@fluentui/react-utilities';\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\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n const { container, target, arrow, strategy, middleware, placement } = options;\n let isDestroyed = false;\n if (!target || !container) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\n const targetWindow = container.ownerDocument.defaultView;\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 scrollParents.add(getScrollParent(container));\n if (isHTMLElement(target)) {\n scrollParents.add(getScrollParent(target));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition);\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 });\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 };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition);\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"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kBAAkB;AAGlD,SAASC,QAAQ,EAAEC,iBAAiB,EAAEC,qBAAqB,EAAEC,eAAe,QAAQ,SAAS;AAC7F,SAASC,aAAa,QAAQ,2BAA2B;AA8BzD;;;;AAIA,OAAM,SAAUC,qBAAqBA,CAACC,OAA+B;EACnE,MAAM;IAAEC,SAAS;IAAE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AAEpB,cAAc,CAAC;;EAGzD;EACAA,cAAc,EAAE;EAEhB,OAAO;IACLA,cAAc;IACdE;GACD;AACH"}
1
+ {"version":3,"names":["computePosition","debounce","writeArrowUpdates","writeContainerUpdates","getScrollParent","isHTMLElement","createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","forEach","scrollParent","addEventListener","then","x","y","middlewareData","computedPlacement","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","removeEventListener"],"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';\nimport { isHTMLElement } from '@fluentui/react-utilities';\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\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n const { container, target, arrow, strategy, middleware, placement } = options;\n let isDestroyed = false;\n if (!target || !container) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\n const targetWindow = container.ownerDocument.defaultView;\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 scrollParents.add(getScrollParent(container));\n if (isHTMLElement(target)) {\n scrollParents.add(getScrollParent(target));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition);\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 });\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 };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition);\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"],"mappings":"AAA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;AACF"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Creates a virtual element based on the position of a click event
3
3
  * Can be used as a target for popper in scenarios such as context menus
4
- */
5
- export function createVirtualElementFromClick(nativeEvent) {
4
+ */export function createVirtualElementFromClick(nativeEvent) {
6
5
  const left = nativeEvent.clientX;
7
6
  const top = nativeEvent.clientY;
8
7
  const right = left + 1;
@@ -1 +1 @@
1
- {"version":3,"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"sources":["../../../../../../../packages/react-components/react-positioning/src/createVirtualElementFromClick.ts"],"sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"mappings":"AAEA;;;;AAIA,OAAM,SAAUA,6BAA6BA,CAACC,WAAuB;EACnE,MAAMC,IAAI,GAAGD,WAAW,CAACE,OAAO;EAChC,MAAMC,GAAG,GAAGH,WAAW,CAACI,OAAO;EAC/B,MAAMC,KAAK,GAAGJ,IAAI,GAAG,CAAC;EACtB,MAAMK,MAAM,GAAGH,GAAG,GAAG,CAAC;EAEtB,SAASI,qBAAqBA,CAAA;IAC5B,OAAO;MACLN,IAAI;MACJE,GAAG;MACHE,KAAK;MACLC,MAAM;MACNE,CAAC,EAAEP,IAAI;MACPQ,CAAC,EAAEN,GAAG;MACNO,MAAM,EAAE,CAAC;MACTC,KAAK,EAAE;KACR;EACH;EAEA,OAAO;IACLJ;GACD;AACH"}
1
+ {"version":3,"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"sources":["../src/createVirtualElementFromClick.ts"],"sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"mappings":"AAEA;;;GAIA,OAAO,SAASA,8BAA8BC,WAAuB,EAA6B;EAChG,MAAMC,IAAA,GAAOD,WAAA,CAAYE,OAAO;EAChC,MAAMC,GAAA,GAAMH,WAAA,CAAYI,OAAO;EAC/B,MAAMC,KAAA,GAAQJ,IAAA,GAAO;EACrB,MAAMK,MAAA,GAASH,GAAA,GAAM;EAErB,SAASI,sBAAA,EAAwB;IAC/B,OAAO;MACLN,IAAA;MACAE,GAAA;MACAE,KAAA;MACAC,MAAA;MACAE,CAAA,EAAGP,IAAA;MACHQ,CAAA,EAAGN,GAAA;MACHO,MAAA,EAAQ;MACRC,KAAA,EAAO;IACT;EACF;EAEA,OAAO;IACLJ;EACF;AACF"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { createVirtualElementFromClick } from './createVirtualElementFromClick';
2
- export { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';
3
- export { usePositioning } from './usePositioning';
4
- export { usePositioningMouseTarget } from './usePositioningMouseTarget';
5
- export { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';
1
+ export { createVirtualElementFromClick } from "./createVirtualElementFromClick";
2
+ export { createArrowHeightStyles, createArrowStyles } from "./createArrowStyles";
3
+ export { usePositioning } from "./usePositioning";
4
+ export { usePositioningMouseTarget } from "./usePositioningMouseTarget";
5
+ export { resolvePositioningShorthand, mergeArrowOffset } from "./utils/index";
6
6
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"]}
1
+ {"version":3,"names":["createVirtualElementFromClick","createArrowHeightStyles","createArrowStyles","usePositioning","usePositioningMouseTarget","resolvePositioningShorthand","mergeArrowOffset"],"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"],"mappings":"AAAA,SAASA,6BAA6B,QAAQ;AAC9C,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ;AAE3D,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ"}
@@ -1,7 +1,7 @@
1
- import { parseFloatingUIPlacement } from '../utils/index';
1
+ import { parseFloatingUIPlacement } from "../utils/index";
2
2
  export function coverTarget() {
3
3
  return {
4
- name: 'coverTarget',
4
+ name: "coverTarget",
5
5
  fn: middlewareArguments => {
6
6
  const {
7
7
  placement,
@@ -15,16 +15,16 @@ export function coverTarget() {
15
15
  y
16
16
  };
17
17
  switch (basePlacement) {
18
- case 'bottom':
18
+ case "bottom":
19
19
  newCoords.y -= rects.reference.height;
20
20
  break;
21
- case 'top':
21
+ case "top":
22
22
  newCoords.y += rects.reference.height;
23
23
  break;
24
- case 'left':
24
+ case "left":
25
25
  newCoords.x += rects.reference.width;
26
26
  break;
27
- case 'right':
27
+ case "right":
28
28
  newCoords.x -= rects.reference.width;
29
29
  break;
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"names":["parseFloatingUIPlacement","coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","side","newCoords","reference","height","width"],"sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/coverTarget.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,gBAAgB;AAEzD,OAAM,SAAUC,WAAWA,CAAA;EACzB,OAAO;IACLC,IAAI,EAAE,aAAa;IACnBC,EAAE,EAAEC,mBAAmB,IAAG;MACxB,MAAM;QAAEC,SAAS;QAAEC,KAAK;QAAEC,CAAC;QAAEC;MAAC,CAAE,GAAGJ,mBAAmB;MACtD,MAAMK,aAAa,GAAGT,wBAAwB,CAACK,SAAS,CAAC,CAACK,IAAI;MAC9D,MAAMC,SAAS,GAAG;QAAEJ,CAAC;QAAEC;MAAC,CAAE;MAE1B,QAAQC,aAAa;QACnB,KAAK,QAAQ;UACXE,SAAS,CAACH,CAAC,IAAIF,KAAK,CAACM,SAAS,CAACC,MAAM;UACrC;QACF,KAAK,KAAK;UACRF,SAAS,CAACH,CAAC,IAAIF,KAAK,CAACM,SAAS,CAACC,MAAM;UACrC;QACF,KAAK,MAAM;UACTF,SAAS,CAACJ,CAAC,IAAID,KAAK,CAACM,SAAS,CAACE,KAAK;UACpC;QACF,KAAK,OAAO;UACVH,SAAS,CAACJ,CAAC,IAAID,KAAK,CAACM,SAAS,CAACE,KAAK;UACpC;MAAM;MAGV,OAAOH,SAAS;IAClB;GACD;AACH"}
1
+ {"version":3,"names":["parseFloatingUIPlacement","coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","side","newCoords","reference","height","width"],"sources":["../../src/middleware/coverTarget.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ;AAEzC,OAAO,SAASC,YAAA,EAA0B;EACxC,OAAO;IACLC,IAAA,EAAM;IACNC,EAAA,EAAIC,mBAAA,IAAuB;MACzB,MAAM;QAAEC,SAAA;QAAWC,KAAA;QAAOC,CAAA;QAAGC;MAAC,CAAE,GAAGJ,mBAAA;MACnC,MAAMK,aAAA,GAAgBT,wBAAA,CAAyBK,SAAA,EAAWK,IAAI;MAC9D,MAAMC,SAAA,GAAY;QAAEJ,CAAA;QAAGC;MAAE;MAEzB,QAAQC,aAAA;QACN,KAAK;UACHE,SAAA,CAAUH,CAAC,IAAIF,KAAA,CAAMM,SAAS,CAACC,MAAM;UACrC;QACF,KAAK;UACHF,SAAA,CAAUH,CAAC,IAAIF,KAAA,CAAMM,SAAS,CAACC,MAAM;UACrC;QACF,KAAK;UACHF,SAAA,CAAUJ,CAAC,IAAID,KAAA,CAAMM,SAAS,CAACE,KAAK;UACpC;QACF,KAAK;UACHH,SAAA,CAAUJ,CAAC,IAAID,KAAA,CAAMM,SAAS,CAACE,KAAK;UACpC;MAAM;MAGV,OAAOH,SAAA;IACT;EACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { flip as baseFlip } from '@floating-ui/dom';
2
- import { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';
1
+ import { flip as baseFlip } from "@floating-ui/dom";
2
+ import { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from "../utils/index";
3
3
  export function flip(options) {
4
4
  const {
5
5
  hasScrollableElement,
@@ -21,13 +21,13 @@ export function flip(options) {
21
21
  }, []);
22
22
  return baseFlip({
23
23
  ...(hasScrollableElement && {
24
- boundary: 'clippingAncestors'
24
+ boundary: "clippingAncestors"
25
25
  }),
26
26
  ...(flipBoundary && {
27
27
  altBoundary: true,
28
28
  boundary: getBoundary(container, flipBoundary)
29
29
  }),
30
- fallbackStrategy: 'bestFit',
30
+ fallbackStrategy: "bestFit",
31
31
  ...(fallbackPlacements.length && {
32
32
  fallbackPlacements
33
33
  })
@@ -1 +1 @@
1
- {"version":3,"names":["flip","baseFlip","getBoundary","resolvePositioningShorthand","toFloatingUIPlacement","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","placement","push","boundary","altBoundary","fallbackStrategy","length"],"sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/flip.ts"],"sourcesContent":["import { flip as baseFlip, Placement } 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) {\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"],"mappings":"AAAA,SAASA,IAAI,IAAIC,QAAQ,QAAmB,kBAAkB;AAE9D,SAASC,WAAW,EAAEC,2BAA2B,EAAEC,qBAAqB,QAAQ,gBAAgB;AAQhG,OAAM,SAAUJ,IAAIA,CAACK,OAA8B;EACjD,MAAM;IAAEC,oBAAoB;IAAEC,YAAY;IAAEC,SAAS;IAAEC,iBAAiB,GAAG,EAAE;IAAEC;EAAK,CAAE,GAAGL,OAAO;EAEhG,MAAMM,kBAAkB,GAAGF,iBAAiB,CAACG,MAAM,CAAc,CAACC,GAAG,EAAEC,SAAS,KAAI;IAClF,MAAM;MAAEC,QAAQ;MAAEC;IAAK,CAAE,GAAGb,2BAA2B,CAACW,SAAS,CAAC;IAClE,MAAMG,SAAS,GAAGb,qBAAqB,CAACY,KAAK,EAAED,QAAQ,EAAEL,KAAK,CAAC;IAC/D,IAAIO,SAAS,EAAE;MACbJ,GAAG,CAACK,IAAI,CAACD,SAAS,CAAC;;IAErB,OAAOJ,GAAG;EACZ,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOZ,QAAQ,CAAC;IACd,IAAIK,oBAAoB,IAAI;MAAEa,QAAQ,EAAE;IAAmB,CAAE,CAAC;IAC9D,IAAIZ,YAAY,IAAI;MAAEa,WAAW,EAAE,IAAI;MAAED,QAAQ,EAAEjB,WAAW,CAACM,SAAS,EAAED,YAAY;IAAC,CAAE,CAAC;IAC1Fc,gBAAgB,EAAE,SAAS;IAC3B,IAAIV,kBAAkB,CAACW,MAAM,IAAI;MAAEX;IAAkB,CAAE;GACxD,CAAC;AACJ"}
1
+ {"version":3,"names":["flip","baseFlip","getBoundary","resolvePositioningShorthand","toFloatingUIPlacement","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","placement","push","boundary","altBoundary","fallbackStrategy","length"],"sources":["../../src/middleware/flip.ts"],"sourcesContent":["import { flip as baseFlip, Placement } 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) {\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"],"mappings":"AAAA,SAASA,IAAA,IAAQC,QAAQ,QAAmB;AAE5C,SAASC,WAAW,EAAEC,2BAA2B,EAAEC,qBAAqB,QAAQ;AAQhF,OAAO,SAASJ,KAAKK,OAA8B,EAAE;EACnD,MAAM;IAAEC,oBAAA;IAAsBC,YAAA;IAAcC,SAAA;IAAWC,iBAAA,GAAoB,EAAE;IAAEC;EAAK,CAAE,GAAGL,OAAA;EAEzF,MAAMM,kBAAA,GAAqBF,iBAAA,CAAkBG,MAAM,CAAc,CAACC,GAAA,EAAKC,SAAA,KAAc;IACnF,MAAM;MAAEC,QAAA;MAAUC;IAAK,CAAE,GAAGb,2BAAA,CAA4BW,SAAA;IACxD,MAAMG,SAAA,GAAYb,qBAAA,CAAsBY,KAAA,EAAOD,QAAA,EAAUL,KAAA;IACzD,IAAIO,SAAA,EAAW;MACbJ,GAAA,CAAIK,IAAI,CAACD,SAAA;IACX;IACA,OAAOJ,GAAA;EACT,GAAG,EAAE;EAEL,OAAOZ,QAAA,CAAS;IACd,IAAIK,oBAAA,IAAwB;MAAEa,QAAA,EAAU;IAAoB,CAAC;IAC7D,IAAIZ,YAAA,IAAgB;MAAEa,WAAA,EAAa,IAAI;MAAED,QAAA,EAAUjB,WAAA,CAAYM,SAAA,EAAWD,YAAA;IAAc,CAAC;IACzFc,gBAAA,EAAkB;IAClB,IAAIV,kBAAA,CAAmBW,MAAM,IAAI;MAAEX;IAAmB,CAAC;EACzD;AACF"}
@@ -1,7 +1,7 @@
1
- export * from './coverTarget';
2
- export * from './flip';
3
- export * from './intersecting';
4
- export * from './maxSize';
5
- export * from './offset';
6
- export * from './shift';
1
+ export * from "./coverTarget";
2
+ export * from "./flip";
3
+ export * from "./intersecting";
4
+ export * from "./maxSize";
5
+ export * from "./offset";
6
+ export * from "./shift";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC","sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"]}
1
+ {"version":3,"names":[],"sources":["../../src/middleware/index.ts"],"sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
@@ -1,7 +1,7 @@
1
- import { detectOverflow } from '@floating-ui/dom';
1
+ import { detectOverflow } from "@floating-ui/dom";
2
2
  export function intersecting() {
3
3
  return {
4
- name: 'intersectionObserver',
4
+ name: "intersectionObserver",
5
5
  fn: async middlewareArguments => {
6
6
  const floatingRect = middlewareArguments.rects.floating;
7
7
  const altOverflow = await detectOverflow(middlewareArguments, {
@@ -1 +1 @@
1
- {"version":3,"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"sources":["../../../../../../../../packages/react-components/react-positioning/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"],"mappings":"AACA,SAASA,cAAc,QAAQ,kBAAkB;AAEjD,OAAM,SAAUC,YAAYA,CAAA;EAC1B,OAAO;IACLC,IAAI,EAAE,sBAAsB;IAC5BC,EAAE,EAAE,MAAMC,mBAAmB,IAAG;MAC9B,MAAMC,YAAY,GAAGD,mBAAmB,CAACE,KAAK,CAACC,QAAQ;MACvD,MAAMC,WAAW,GAAG,MAAMR,cAAc,CAACI,mBAAmB,EAAE;QAAEK,WAAW,EAAE;MAAI,CAAE,CAAC;MAEpF,MAAMC,iBAAiB,GAAGF,WAAW,CAACG,GAAG,GAAGN,YAAY,CAACO,MAAM,IAAIJ,WAAW,CAACG,GAAG,GAAG,CAAC;MACtF,MAAME,oBAAoB,GAAGL,WAAW,CAACM,MAAM,GAAGT,YAAY,CAACO,MAAM,IAAIJ,WAAW,CAACM,MAAM,GAAG,CAAC;MAE/F,MAAMC,cAAc,GAAGL,iBAAiB,IAAIG,oBAAoB;MAEhE,OAAO;QACLG,IAAI,EAAE;UACJf,YAAY,EAAEc;;OAEjB;IACH;GACD;AACH"}
1
+ {"version":3,"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"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"],"mappings":"AACA,SAASA,cAAc,QAAQ;AAE/B,OAAO,SAASC,aAAA,EAA2B;EACzC,OAAO;IACLC,IAAA,EAAM;IACNC,EAAA,EAAI,MAAMC,mBAAA,IAAuB;MAC/B,MAAMC,YAAA,GAAeD,mBAAA,CAAoBE,KAAK,CAACC,QAAQ;MACvD,MAAMC,WAAA,GAAc,MAAMR,cAAA,CAAeI,mBAAA,EAAqB;QAAEK,WAAA,EAAa;MAAK;MAElF,MAAMC,iBAAA,GAAoBF,WAAA,CAAYG,GAAG,GAAGN,YAAA,CAAaO,MAAM,IAAIJ,WAAA,CAAYG,GAAG,GAAG;MACrF,MAAME,oBAAA,GAAuBL,WAAA,CAAYM,MAAM,GAAGT,YAAA,CAAaO,MAAM,IAAIJ,WAAA,CAAYM,MAAM,GAAG;MAE9F,MAAMC,cAAA,GAAiBL,iBAAA,IAAqBG,oBAAA;MAE5C,OAAO;QACLG,IAAA,EAAM;UACJf,YAAA,EAAcc;QAChB;MACF;IACF;EACF;AACF"}