@fluentui/react-positioning 9.5.5 → 9.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +40 -1
  3. package/CHANGELOG.md +15 -2
  4. package/lib/constants.js.map +1 -1
  5. package/lib/createArrowStyles.js.map +1 -1
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js +1 -2
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js.map +1 -1
  10. package/lib/middleware/coverTarget.js.map +1 -1
  11. package/lib/middleware/flip.js.map +1 -1
  12. package/lib/middleware/index.js.map +1 -1
  13. package/lib/middleware/intersecting.js.map +1 -1
  14. package/lib/middleware/maxSize.js.map +1 -1
  15. package/lib/middleware/offset.js.map +1 -1
  16. package/lib/middleware/shift.js.map +1 -1
  17. package/lib/types.js +1 -1
  18. package/lib/types.js.map +1 -1
  19. package/lib/usePositioning.js +23 -21
  20. package/lib/usePositioning.js.map +1 -1
  21. package/lib/usePositioningMouseTarget.js.map +1 -1
  22. package/lib/utils/debounce.js +1 -2
  23. package/lib/utils/debounce.js.map +1 -1
  24. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  25. package/lib/utils/getBoundary.js.map +1 -1
  26. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  27. package/lib/utils/getReactFiberFromNode.js +1 -0
  28. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  29. package/lib/utils/getScrollParent.js +5 -6
  30. package/lib/utils/getScrollParent.js.map +1 -1
  31. package/lib/utils/hasAutoFocusFilter.js +2 -2
  32. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  33. package/lib/utils/index.js.map +1 -1
  34. package/lib/utils/mergeArrowOffset.js +3 -4
  35. package/lib/utils/mergeArrowOffset.js.map +1 -1
  36. package/lib/utils/parseFloatingUIPlacement.js +1 -2
  37. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  38. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  39. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  40. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  41. package/lib/utils/toggleScrollListener.js.map +1 -1
  42. package/lib/utils/useCallbackRef.js.map +1 -1
  43. package/lib/utils/writeArrowUpdates.js +1 -2
  44. package/lib/utils/writeArrowUpdates.js.map +1 -1
  45. package/lib/utils/writeContainerupdates.js +4 -4
  46. package/lib/utils/writeContainerupdates.js.map +1 -1
  47. package/lib-commonjs/constants.js +18 -7
  48. package/lib-commonjs/constants.js.map +1 -1
  49. package/lib-commonjs/createArrowStyles.js +60 -88
  50. package/lib-commonjs/createArrowStyles.js.map +1 -1
  51. package/lib-commonjs/createPositionManager.js +103 -117
  52. package/lib-commonjs/createPositionManager.js.map +1 -1
  53. package/lib-commonjs/createVirtualElementFromClick.js +27 -26
  54. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  55. package/lib-commonjs/index.js +24 -51
  56. package/lib-commonjs/index.js.map +1 -1
  57. package/lib-commonjs/middleware/coverTarget.js +34 -37
  58. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  59. package/lib-commonjs/middleware/flip.js +31 -38
  60. package/lib-commonjs/middleware/flip.js.map +1 -1
  61. package/lib-commonjs/middleware/index.js +10 -9
  62. package/lib-commonjs/middleware/index.js.map +1 -1
  63. package/lib-commonjs/middleware/intersecting.js +24 -22
  64. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  65. package/lib-commonjs/middleware/maxSize.js +34 -40
  66. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  67. package/lib-commonjs/middleware/offset.js +11 -12
  68. package/lib-commonjs/middleware/offset.js.map +1 -1
  69. package/lib-commonjs/middleware/shift.js +29 -37
  70. package/lib-commonjs/middleware/shift.js.map +1 -1
  71. package/lib-commonjs/types.js +5 -2
  72. package/lib-commonjs/types.js.map +1 -1
  73. package/lib-commonjs/usePositioning.js +200 -164
  74. package/lib-commonjs/usePositioning.js.map +1 -1
  75. package/lib-commonjs/usePositioningMouseTarget.js +34 -37
  76. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  77. package/lib-commonjs/utils/debounce.js +22 -21
  78. package/lib-commonjs/utils/debounce.js.map +1 -1
  79. package/lib-commonjs/utils/fromFloatingUIPlacement.js +30 -35
  80. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  81. package/lib-commonjs/utils/getBoundary.js +21 -22
  82. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  83. package/lib-commonjs/utils/getFloatingUIOffset.js +23 -35
  84. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  85. package/lib-commonjs/utils/getReactFiberFromNode.js +45 -41
  86. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  87. package/lib-commonjs/utils/getScrollParent.js +52 -56
  88. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  89. package/lib-commonjs/utils/hasAutoFocusFilter.js +18 -17
  90. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  91. package/lib-commonjs/utils/index.js +19 -18
  92. package/lib-commonjs/utils/index.js.map +1 -1
  93. package/lib-commonjs/utils/mergeArrowOffset.js +33 -32
  94. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  95. package/lib-commonjs/utils/parseFloatingUIPlacement.js +15 -14
  96. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  97. package/lib-commonjs/utils/resolvePositioningShorthand.js +63 -61
  98. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  99. package/lib-commonjs/utils/toFloatingUIPadding.js +23 -25
  100. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  101. package/lib-commonjs/utils/toFloatingUIPlacement.js +31 -33
  102. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  103. package/lib-commonjs/utils/toggleScrollListener.js +20 -24
  104. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  105. package/lib-commonjs/utils/useCallbackRef.js +39 -53
  106. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  107. package/lib-commonjs/utils/writeArrowUpdates.js +19 -24
  108. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  109. package/lib-commonjs/utils/writeContainerupdates.js +37 -45
  110. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  111. package/package.json +7 -6
  112. package/lib-amd/constants.js +0 -10
  113. package/lib-amd/constants.js.map +0 -1
  114. package/lib-amd/createArrowStyles.js +0 -62
  115. package/lib-amd/createArrowStyles.js.map +0 -1
  116. package/lib-amd/createPositionManager.js +0 -97
  117. package/lib-amd/createPositionManager.js.map +0 -1
  118. package/lib-amd/createVirtualElementFromClick.js +0 -32
  119. package/lib-amd/createVirtualElementFromClick.js.map +0 -1
  120. package/lib-amd/index.js +0 -13
  121. package/lib-amd/index.js.map +0 -1
  122. package/lib-amd/middleware/coverTarget.js +0 -32
  123. package/lib-amd/middleware/coverTarget.js.map +0 -1
  124. package/lib-amd/middleware/flip.js +0 -19
  125. package/lib-amd/middleware/flip.js.map +0 -1
  126. package/lib-amd/middleware/index.js +0 -11
  127. package/lib-amd/middleware/index.js.map +0 -1
  128. package/lib-amd/middleware/intersecting.js +0 -33
  129. package/lib-amd/middleware/intersecting.js.map +0 -1
  130. package/lib-amd/middleware/maxSize.js +0 -33
  131. package/lib-amd/middleware/maxSize.js.map +0 -1
  132. package/lib-amd/middleware/offset.js +0 -14
  133. package/lib-amd/middleware/offset.js.map +0 -1
  134. package/lib-amd/middleware/shift.js +0 -17
  135. package/lib-amd/middleware/shift.js.map +0 -1
  136. package/lib-amd/types.js +0 -5
  137. package/lib-amd/types.js.map +0 -1
  138. package/lib-amd/usePositioning.js +0 -161
  139. package/lib-amd/usePositioning.js.map +0 -1
  140. package/lib-amd/usePositioningMouseTarget.js +0 -39
  141. package/lib-amd/usePositioningMouseTarget.js.map +0 -1
  142. package/lib-amd/utils/debounce.js +0 -27
  143. package/lib-amd/utils/debounce.js.map +0 -1
  144. package/lib-amd/utils/fromFloatingUIPlacement.js +0 -37
  145. package/lib-amd/utils/fromFloatingUIPlacement.js.map +0 -1
  146. package/lib-amd/utils/getBoundary.js +0 -26
  147. package/lib-amd/utils/getBoundary.js.map +0 -1
  148. package/lib-amd/utils/getFloatingUIOffset.js +0 -25
  149. package/lib-amd/utils/getFloatingUIOffset.js.map +0 -1
  150. package/lib-amd/utils/getReactFiberFromNode.js +0 -48
  151. package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
  152. package/lib-amd/utils/getScrollParent.js +0 -64
  153. package/lib-amd/utils/getScrollParent.js.map +0 -1
  154. package/lib-amd/utils/hasAutoFocusFilter.js +0 -31
  155. package/lib-amd/utils/hasAutoFocusFilter.js.map +0 -1
  156. package/lib-amd/utils/index.js +0 -20
  157. package/lib-amd/utils/index.js.map +0 -1
  158. package/lib-amd/utils/mergeArrowOffset.js +0 -38
  159. package/lib-amd/utils/mergeArrowOffset.js.map +0 -1
  160. package/lib-amd/utils/parseFloatingUIPlacement.js +0 -20
  161. package/lib-amd/utils/parseFloatingUIPlacement.js.map +0 -1
  162. package/lib-amd/utils/resolvePositioningShorthand.js +0 -31
  163. package/lib-amd/utils/resolvePositioningShorthand.js.map +0 -1
  164. package/lib-amd/utils/toFloatingUIPadding.js +0 -25
  165. package/lib-amd/utils/toFloatingUIPadding.js.map +0 -1
  166. package/lib-amd/utils/toFloatingUIPlacement.js +0 -40
  167. package/lib-amd/utils/toFloatingUIPlacement.js.map +0 -1
  168. package/lib-amd/utils/toggleScrollListener.js +0 -26
  169. package/lib-amd/utils/toggleScrollListener.js.map +0 -1
  170. package/lib-amd/utils/useCallbackRef.js +0 -55
  171. package/lib-amd/utils/useCallbackRef.js.map +0 -1
  172. package/lib-amd/utils/writeArrowUpdates.js +0 -21
  173. package/lib-amd/utils/writeArrowUpdates.js.map +0 -1
  174. package/lib-amd/utils/writeContainerupdates.js +0 -41
  175. package/lib-amd/utils/writeContainerupdates.js.map +0 -1
@@ -1,32 +0,0 @@
1
- define(["require", "exports", "../utils/index"], function (require, exports, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.coverTarget = void 0;
5
- function coverTarget() {
6
- return {
7
- name: 'coverTarget',
8
- fn: function (middlewareArguments) {
9
- var placement = middlewareArguments.placement, rects = middlewareArguments.rects, x = middlewareArguments.x, y = middlewareArguments.y;
10
- var basePlacement = index_1.parseFloatingUIPlacement(placement).side;
11
- var newCoords = { x: x, y: y };
12
- switch (basePlacement) {
13
- case 'bottom':
14
- newCoords.y -= rects.reference.height;
15
- break;
16
- case 'top':
17
- newCoords.y += rects.reference.height;
18
- break;
19
- case 'left':
20
- newCoords.x += rects.reference.width;
21
- break;
22
- case 'right':
23
- newCoords.x -= rects.reference.width;
24
- break;
25
- }
26
- return newCoords;
27
- },
28
- };
29
- }
30
- exports.coverTarget = coverTarget;
31
- });
32
- //# sourceMappingURL=coverTarget.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coverTarget.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/coverTarget.ts"],"names":[],"mappings":";;;;IAGA,SAAgB,WAAW;QACzB,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,EAAE,EAAE,UAAA,mBAAmB;gBACb,IAAA,SAAS,GAAkB,mBAAmB,UAArC,EAAE,KAAK,GAAW,mBAAmB,MAA9B,EAAE,CAAC,GAAQ,mBAAmB,EAA3B,EAAE,CAAC,GAAK,mBAAmB,EAAxB,CAAyB;gBACvD,IAAM,aAAa,GAAG,gCAAwB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;gBAC/D,IAAM,SAAS,GAAG,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,CAAC;gBAE3B,QAAQ,aAAa,EAAE;oBACrB,KAAK,QAAQ;wBACX,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;wBACtC,MAAM;oBACR,KAAK,KAAK;wBACR,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;wBACtC,MAAM;oBACR,KAAK,MAAM;wBACT,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;wBACrC,MAAM;oBACR,KAAK,OAAO;wBACV,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;wBACrC,MAAM;iBACT;gBAED,OAAO,SAAS,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;IA1BD,kCA0BC","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"]}
@@ -1,19 +0,0 @@
1
- define(["require", "exports", "tslib", "@floating-ui/dom", "../utils/index"], function (require, exports, tslib_1, dom_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.flip = void 0;
5
- function flip(options) {
6
- var hasScrollableElement = options.hasScrollableElement, flipBoundary = options.flipBoundary, container = options.container, _a = options.fallbackPositions, fallbackPositions = _a === void 0 ? [] : _a, isRtl = options.isRtl;
7
- var fallbackPlacements = fallbackPositions.reduce(function (acc, shorthand) {
8
- var _a = index_1.resolvePositioningShorthand(shorthand), position = _a.position, align = _a.align;
9
- var placement = index_1.toFloatingUIPlacement(align, position, isRtl);
10
- if (placement) {
11
- acc.push(placement);
12
- }
13
- return acc;
14
- }, []);
15
- return dom_1.flip(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (hasScrollableElement && { boundary: 'clippingAncestors' })), (flipBoundary && { altBoundary: true, boundary: index_1.getBoundary(container, flipBoundary) })), { fallbackStrategy: 'bestFit' }), (fallbackPlacements.length && { fallbackPlacements: fallbackPlacements })));
16
- }
17
- exports.flip = flip;
18
- });
19
- //# sourceMappingURL=flip.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flip.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/flip.ts"],"names":[],"mappings":";;;;IAUA,SAAgB,IAAI,CAAC,OAA8B;QACzC,IAAA,oBAAoB,GAA6D,OAAO,qBAApE,EAAE,YAAY,GAA+C,OAAO,aAAtD,EAAE,SAAS,GAAoC,OAAO,UAA3C,EAAE,KAAkC,OAAO,kBAAnB,EAAtB,iBAAiB,mBAAG,EAAE,KAAA,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;QAEjG,IAAM,kBAAkB,GAAG,iBAAiB,CAAC,MAAM,CAAc,UAAC,GAAG,EAAE,SAAS;YACxE,IAAA,KAAsB,mCAA2B,CAAC,SAAS,CAAC,EAA1D,QAAQ,cAAA,EAAE,KAAK,WAA2C,CAAC;YACnE,IAAM,SAAS,GAAG,6BAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAChE,IAAI,SAAS,EAAE;gBACb,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACrB;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,UAAQ,yEACV,CAAC,oBAAoB,IAAI,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC,GAC3D,CAAC,YAAY,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAW,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,KAC1F,gBAAgB,EAAE,SAAS,KACxB,CAAC,kBAAkB,CAAC,MAAM,IAAI,EAAE,kBAAkB,oBAAA,EAAE,CAAC,EACxD,CAAC;IACL,CAAC;IAlBD,oBAkBC","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"]}
@@ -1,11 +0,0 @@
1
- define(["require", "exports", "tslib", "./coverTarget", "./flip", "./intersecting", "./maxSize", "./offset", "./shift"], function (require, exports, tslib_1, coverTarget_1, flip_1, intersecting_1, maxSize_1, offset_1, shift_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- tslib_1.__exportStar(coverTarget_1, exports);
5
- tslib_1.__exportStar(flip_1, exports);
6
- tslib_1.__exportStar(intersecting_1, exports);
7
- tslib_1.__exportStar(maxSize_1, exports);
8
- tslib_1.__exportStar(offset_1, exports);
9
- tslib_1.__exportStar(shift_1, exports);
10
- });
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/index.ts"],"names":[],"mappings":";;;IAAA,6CAA8B;IAC9B,sCAAuB;IACvB,8CAA+B;IAC/B,yCAA0B;IAC1B,wCAAyB;IACzB,uCAAwB","sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"]}
@@ -1,33 +0,0 @@
1
- define(["require", "exports", "tslib", "@floating-ui/dom"], function (require, exports, tslib_1, dom_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.intersecting = void 0;
5
- function intersecting() {
6
- var _this = this;
7
- return {
8
- name: 'intersectionObserver',
9
- fn: function (middlewareArguments) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
10
- var floatingRect, altOverflow, isIntersectingTop, isIntersectingBottom, isIntersecting;
11
- return tslib_1.__generator(this, function (_a) {
12
- switch (_a.label) {
13
- case 0:
14
- floatingRect = middlewareArguments.rects.floating;
15
- return [4 /*yield*/, dom_1.detectOverflow(middlewareArguments, { altBoundary: true })];
16
- case 1:
17
- altOverflow = _a.sent();
18
- isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;
19
- isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;
20
- isIntersecting = isIntersectingTop || isIntersectingBottom;
21
- return [2 /*return*/, {
22
- data: {
23
- intersecting: isIntersecting,
24
- },
25
- }];
26
- }
27
- });
28
- }); },
29
- };
30
- }
31
- exports.intersecting = intersecting;
32
- });
33
- //# sourceMappingURL=intersecting.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intersecting.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/intersecting.ts"],"names":[],"mappings":";;;;IAGA,SAAgB,YAAY;QAA5B,iBAmBC;QAlBC,OAAO;YACL,IAAI,EAAE,sBAAsB;YAC5B,EAAE,EAAE,UAAM,mBAAmB;;;;;4BACrB,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC;4BACpC,qBAAM,oBAAc,CAAC,mBAAmB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAA;;4BAA9E,WAAW,GAAG,SAAgE;4BAE9E,iBAAiB,GAAG,WAAW,CAAC,GAAG,GAAG,YAAY,CAAC,MAAM,IAAI,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC;4BACjF,oBAAoB,GAAG,WAAW,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;4BAE1F,cAAc,GAAG,iBAAiB,IAAI,oBAAoB,CAAC;4BAEjE,sBAAO;oCACL,IAAI,EAAE;wCACJ,YAAY,EAAE,cAAc;qCAC7B;iCACF,EAAC;;;iBACH;SACF,CAAC;IACJ,CAAC;IAnBD,oCAmBC","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"]}
@@ -1,33 +0,0 @@
1
- define(["require", "exports", "tslib", "@floating-ui/dom", "../utils/getBoundary"], function (require, exports, tslib_1, dom_1, getBoundary_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.maxSize = void 0;
5
- function maxSize(autoSize, options) {
6
- var container = options.container, overflowBoundary = options.overflowBoundary;
7
- return dom_1.size(tslib_1.__assign(tslib_1.__assign({}, (overflowBoundary && { altBoundary: true, boundary: getBoundary_1.getBoundary(container, overflowBoundary) })), { apply: function (_a) {
8
- var availableHeight = _a.availableHeight, availableWidth = _a.availableWidth, elements = _a.elements, rects = _a.rects;
9
- var applyMaxWidth = autoSize === 'always' ||
10
- autoSize === 'width-always' ||
11
- (rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width'));
12
- var applyMaxHeight = autoSize === 'always' ||
13
- autoSize === 'height-always' ||
14
- (rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height'));
15
- if (applyMaxHeight) {
16
- Object.assign(elements.floating.style, {
17
- maxHeight: availableHeight + "px",
18
- boxSizing: 'border-box',
19
- overflowY: 'auto',
20
- });
21
- }
22
- if (applyMaxWidth) {
23
- Object.assign(elements.floating.style, {
24
- maxWidth: availableWidth + "px",
25
- boxSizing: 'border-box',
26
- overflowX: 'auto',
27
- });
28
- }
29
- } }));
30
- }
31
- exports.maxSize = maxSize;
32
- });
33
- //# sourceMappingURL=maxSize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"maxSize.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/maxSize.ts"],"names":[],"mappings":";;;;IAQA,SAAgB,OAAO,CAAC,QAAwC,EAAE,OAAiC;QACzF,IAAA,SAAS,GAAuB,OAAO,UAA9B,EAAE,gBAAgB,GAAK,OAAO,iBAAZ,CAAa;QAChD,OAAO,UAAI,uCACN,CAAC,gBAAgB,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,yBAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,KAClG,KAAK,EAAL,UAAM,EAAoD;oBAAlD,eAAe,qBAAA,EAAE,cAAc,oBAAA,EAAE,QAAQ,cAAA,EAAE,KAAK,WAAA;gBACtD,IAAM,aAAa,GACjB,QAAQ,KAAK,QAAQ;oBACrB,QAAQ,KAAK,cAAc;oBAC3B,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,cAAc,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;gBAEzF,IAAM,cAAc,GAClB,QAAQ,KAAK,QAAQ;oBACrB,QAAQ,KAAK,eAAe;oBAC5B,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,eAAe,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC;gBAE5F,IAAI,cAAc,EAAE;oBAClB,MAAM,CAAC,MAAM,CAAoD,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE;wBACxF,SAAS,EAAK,eAAe,OAAI;wBACjC,SAAS,EAAE,YAAY;wBACvB,SAAS,EAAE,MAAM;qBAClB,CAAC,CAAC;iBACJ;gBAED,IAAI,aAAa,EAAE;oBACjB,MAAM,CAAC,MAAM,CAAoD,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE;wBACxF,QAAQ,EAAK,cAAc,OAAI;wBAC/B,SAAS,EAAE,YAAY;wBACvB,SAAS,EAAE,MAAM;qBAClB,CAAC,CAAC;iBACJ;YACH,CAAC,IACD,CAAC;IACL,CAAC;IAhCD,0BAgCC","sourcesContent":["import { size } from '@floating-ui/dom';\nimport type { Middleware } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/getBoundary';\nexport interface MaxSizeMiddlewareOptions extends Pick<PositioningOptions, 'overflowBoundary'> {\n container: HTMLElement | null;\n}\n\nexport function maxSize(autoSize: PositioningOptions['autoSize'], options: MaxSizeMiddlewareOptions): Middleware {\n const { container, overflowBoundary } = options;\n return size({\n ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n apply({ availableHeight, availableWidth, elements, rects }) {\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width'));\n\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxHeight) {\n Object.assign<CSSStyleDeclaration, Partial<CSSStyleDeclaration>>(elements.floating.style, {\n maxHeight: `${availableHeight}px`,\n boxSizing: 'border-box',\n overflowY: 'auto',\n });\n }\n\n if (applyMaxWidth) {\n Object.assign<CSSStyleDeclaration, Partial<CSSStyleDeclaration>>(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n boxSizing: 'border-box',\n overflowX: 'auto',\n });\n }\n },\n });\n}\n"]}
@@ -1,14 +0,0 @@
1
- define(["require", "exports", "@floating-ui/dom", "../utils/getFloatingUIOffset"], function (require, exports, dom_1, getFloatingUIOffset_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.offset = void 0;
5
- /**
6
- * Wraps floating UI offset middleware to to transform offset value
7
- */
8
- function offset(offsetValue) {
9
- var floatingUIOffset = getFloatingUIOffset_1.getFloatingUIOffset(offsetValue);
10
- return dom_1.offset(floatingUIOffset);
11
- }
12
- exports.offset = offset;
13
- });
14
- //# sourceMappingURL=offset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"offset.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/offset.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,MAAM,CAAC,WAAyC;QAC9D,IAAM,gBAAgB,GAAG,yCAAmB,CAAC,WAAW,CAAC,CAAC;QAC1D,OAAO,YAAU,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAHD,wBAGC","sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to to transform offset value\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"]}
@@ -1,17 +0,0 @@
1
- define(["require", "exports", "tslib", "@floating-ui/dom", "../utils/index"], function (require, exports, tslib_1, dom_1, index_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.shift = void 0;
5
- /**
6
- * Wraps the floating UI shift middleware for easier usage of our options
7
- */
8
- function shift(options) {
9
- var hasScrollableElement = options.hasScrollableElement, disableTether = options.disableTether, overflowBoundary = options.overflowBoundary, container = options.container, overflowBoundaryPadding = options.overflowBoundaryPadding, isRtl = options.isRtl;
10
- return dom_1.shift(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (hasScrollableElement && { boundary: 'clippingAncestors' })), (disableTether && {
11
- crossAxis: disableTether === 'all',
12
- limiter: dom_1.limitShift({ crossAxis: disableTether !== 'all', mainAxis: false }),
13
- })), (overflowBoundaryPadding && { padding: index_1.toFloatingUIPadding(overflowBoundaryPadding, isRtl) })), (overflowBoundary && { altBoundary: true, boundary: index_1.getBoundary(container, overflowBoundary) })));
14
- }
15
- exports.shift = shift;
16
- });
17
- //# sourceMappingURL=shift.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shift.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/middleware/shift.ts"],"names":[],"mappings":";;;;IAYA;;OAEG;IACH,SAAgB,KAAK,CAAC,OAA+B;QAC3C,IAAA,oBAAoB,GAAiF,OAAO,qBAAxF,EAAE,aAAa,GAAkE,OAAO,cAAzE,EAAE,gBAAgB,GAAgD,OAAO,iBAAvD,EAAE,SAAS,GAAqC,OAAO,UAA5C,EAAE,uBAAuB,GAAY,OAAO,wBAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;QAErH,OAAO,WAAS,yEACX,CAAC,oBAAoB,IAAI,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC,GAC3D,CAAC,aAAa,IAAI;YACnB,SAAS,EAAE,aAAa,KAAK,KAAK;YAClC,OAAO,EAAE,gBAAU,CAAC,EAAE,SAAS,EAAE,aAAa,KAAK,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;SAC7E,CAAC,GACC,CAAC,uBAAuB,IAAI,EAAE,OAAO,EAAE,2BAAmB,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,GAC7F,CAAC,gBAAgB,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,EAClG,CAAC;IACL,CAAC;IAZD,sBAYC","sourcesContent":["import { shift as baseShift, limitShift } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary, toFloatingUIPadding } from '../utils/index';\n\nexport interface ShiftMiddlewareOptions\n extends Pick<PositioningOptions, 'overflowBoundary' | 'overflowBoundaryPadding'> {\n hasScrollableElement?: boolean;\n disableTether?: PositioningOptions['unstable_disableTether'];\n container: HTMLElement | null;\n isRtl: boolean;\n}\n\n/**\n * Wraps the floating UI shift middleware for easier usage of our options\n */\nexport function shift(options: ShiftMiddlewareOptions) {\n const { hasScrollableElement, disableTether, overflowBoundary, container, overflowBoundaryPadding, isRtl } = options;\n\n return baseShift({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(disableTether && {\n crossAxis: disableTether === 'all',\n limiter: limitShift({ crossAxis: disableTether !== 'all', mainAxis: false }),\n }),\n ...(overflowBoundaryPadding && { padding: toFloatingUIPadding(overflowBoundaryPadding, isRtl) }),\n ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n });\n}\n"]}
package/lib-amd/types.js DELETED
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\ntype Rect = {\n width: number;\n height: number;\n x: number;\n y: number;\n};\n\nexport type OffsetFunctionParam = {\n positionedRect: Rect;\n targetRect: Rect;\n position: Position;\n alignment?: Alignment;\n};\n\nexport type TargetElement = HTMLElement | PositioningVirtualElement;\n\n/**\n * @internal\n */\nexport interface UsePositioningOptions extends PositioningProps {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface PositionManager {\n updatePosition: () => void;\n dispose: () => void;\n}\n\nexport interface UsePositioningReturn {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n}\n\nexport type OffsetObject = { crossAxis?: number; mainAxis: number };\n\nexport type OffsetShorthand = number;\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => OffsetObject | OffsetShorthand;\n\nexport type Offset = OffsetFunction | OffsetObject | OffsetShorthand;\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;\n\nexport type Boundary = HTMLElement | Array<HTMLElement> | 'clippingParents' | 'scrollParent' | 'window';\n\nexport type PositioningImperativeRef = {\n /**\n * Updates the position imperatively.\n * Useful when the position of the target changes from other factors than scrolling of window resize.\n */\n updatePosition: () => void;\n\n /**\n * Sets the target and updates positioning imperatively.\n * Useful for avoiding double renders with the target option.\n */\n setTarget: (target: TargetElement) => void;\n};\n\nexport type PositioningVirtualElement = {\n getBoundingClientRect: () => {\n x: number;\n y: number;\n top: number;\n left: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n };\n contextElement?: Element;\n};\n\nexport type SetVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => void;\n\nexport interface PositioningOptions {\n /** Alignment for the component. Only has an effect if used with the @see position option */\n align?: Alignment;\n\n /** The element which will define the boundaries of the positioned element for the flip behavior. */\n flipBoundary?: Boundary | null;\n\n /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n overflowBoundary?: Boundary | null;\n\n /**\n * Applies a padding to the overflow bounadry, so that overflow is detected earlier before the\n * positioned surface hits the overflow boundary.\n */\n overflowBoundaryPadding?: number | Partial<{ top: number; end: number; bottom: number; start: number }>;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the position element to be positioned with 'fixed' (default value is position: 'absolute')\n * @default false\n */\n positionFixed?: boolean;\n\n /**\n * Lets you displace a positioned element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * Applies max-height and max-width on the positioned element to fit it within the available space in viewport.\n * true enables this for both width and height when overflow happens.\n * 'always' applies `max-height`/`max-width` regardless of overflow.\n * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`\n * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`\n */\n autoSize?: AutoSize;\n\n /**\n * Modifies position and alignment to cover the target\n */\n coverTarget?: boolean;\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n pinned?: boolean;\n\n /**\n * When the reference element or the viewport is outside viewport allows a positioned element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n\n /**\n * If flip fails to stop the positioned element from overflowing\n * its boundaries, use a specified fallback positions.\n */\n fallbackPositions?: PositioningShorthandValue[];\n}\n\nexport interface PositioningProps\n extends Pick<\n PositioningOptions,\n | 'align'\n | 'flipBoundary'\n | 'overflowBoundary'\n | 'overflowBoundaryPadding'\n | 'position'\n | 'offset'\n | 'arrowPadding'\n | 'autoSize'\n | 'coverTarget'\n | 'pinned'\n > {\n /** An imperative handle to Popper methods. */\n positioningRef?: React.Ref<PositioningImperativeRef>;\n\n /**\n * Manual override for the target element. Useful for scenarios where a component accepts user prop to override target\n */\n target?: TargetElement | null;\n}\n\nexport type PositioningShorthandValue =\n | 'above'\n | 'above-start'\n | 'above-end'\n | 'below'\n | 'below-start'\n | 'below-end'\n | 'before'\n | 'before-top'\n | 'before-bottom'\n | 'after'\n | 'after-top'\n | 'after-bottom';\n\nexport type PositioningShorthand = PositioningProps | PositioningShorthandValue;\n"]}
@@ -1,161 +0,0 @@
1
- define(["require", "exports", "tslib", "@floating-ui/dom", "@fluentui/react-shared-contexts", "@fluentui/react-utilities", "react", "./utils", "./middleware", "./createPositionManager"], function (require, exports, tslib_1, dom_1, react_shared_contexts_1, react_utilities_1, React, utils_1, middleware_1, createPositionManager_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePositioning = void 0;
5
- /**
6
- * @internal
7
- */
8
- function usePositioning(options) {
9
- var managerRef = React.useRef(null);
10
- var targetRef = React.useRef(null);
11
- var overrideTargetRef = React.useRef(null);
12
- var containerRef = React.useRef(null);
13
- var arrowRef = React.useRef(null);
14
- var _a = options.enabled, enabled = _a === void 0 ? true : _a;
15
- var resolvePositioningOptions = usePositioningOptions(options);
16
- var updatePositionManager = React.useCallback(function () {
17
- var _a;
18
- if (managerRef.current) {
19
- managerRef.current.dispose();
20
- }
21
- managerRef.current = null;
22
- var target = (_a = overrideTargetRef.current) !== null && _a !== void 0 ? _a : targetRef.current;
23
- if (enabled && react_utilities_1.canUseDOM() && target && containerRef.current) {
24
- managerRef.current = createPositionManager_1.createPositionManager(tslib_1.__assign({ container: containerRef.current, target: target, arrow: arrowRef.current }, resolvePositioningOptions(containerRef.current, arrowRef.current)));
25
- }
26
- }, [enabled, resolvePositioningOptions]);
27
- var setOverrideTarget = react_utilities_1.useEventCallback(function (target) {
28
- overrideTargetRef.current = target;
29
- updatePositionManager();
30
- });
31
- React.useImperativeHandle(options.positioningRef, function () { return ({
32
- updatePosition: function () { var _a; return (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.updatePosition(); },
33
- setTarget: function (target) {
34
- if (options.target && process.env.NODE_ENV !== 'production') {
35
- var err = new Error();
36
- // eslint-disable-next-line no-console
37
- console.warn('Imperative setTarget should not be used at the same time as target option');
38
- // eslint-disable-next-line no-console
39
- console.warn(err.stack);
40
- }
41
- setOverrideTarget(target);
42
- },
43
- }); }, [options.target, setOverrideTarget]);
44
- react_utilities_1.useIsomorphicLayoutEffect(function () {
45
- var _a;
46
- setOverrideTarget((_a = options.target) !== null && _a !== void 0 ? _a : null);
47
- }, [options.target, setOverrideTarget]);
48
- react_utilities_1.useIsomorphicLayoutEffect(function () {
49
- updatePositionManager();
50
- }, [updatePositionManager]);
51
- if (process.env.NODE_ENV !== 'production') {
52
- // This checked should run only in development mode
53
- // eslint-disable-next-line react-hooks/rules-of-hooks
54
- React.useEffect(function () {
55
- var _a;
56
- if (containerRef.current) {
57
- var contentNode = containerRef.current;
58
- var treeWalker = (_a = contentNode.ownerDocument) === null || _a === void 0 ? void 0 : _a.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
59
- acceptNode: utils_1.hasAutofocusFilter,
60
- });
61
- while (treeWalker.nextNode()) {
62
- var node = treeWalker.currentNode;
63
- // eslint-disable-next-line no-console
64
- console.warn('<Popper>:', node);
65
- // eslint-disable-next-line no-console
66
- console.warn([
67
- '<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial',
68
- 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',
69
- '"autoFocus" behavior to solve inconsistencies between different browsers:',
70
- 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',
71
- '\n',
72
- 'However, ".focus()" in this case occurs before any other React effects will be executed',
73
- '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',
74
- 'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by',
75
- '"Popper".',
76
- "In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:",
77
- 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',
78
- '\n',
79
- 'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use',
80
- '"ref.current.focus" in React.useEffect():',
81
- 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',
82
- ].join(' '));
83
- }
84
- }
85
- // We run this check once, no need to add deps here
86
- // TODO: Should be rework to handle options.enabled and contentRef updates
87
- // eslint-disable-next-line react-hooks/exhaustive-deps
88
- }, []);
89
- }
90
- var setTarget = utils_1.useCallbackRef(null, function (target) {
91
- if (targetRef.current !== target) {
92
- targetRef.current = target;
93
- updatePositionManager();
94
- }
95
- });
96
- var setContainer = utils_1.useCallbackRef(null, function (container) {
97
- if (containerRef.current !== container) {
98
- containerRef.current = container;
99
- updatePositionManager();
100
- }
101
- });
102
- var setArrow = utils_1.useCallbackRef(null, function (arrow) {
103
- if (arrowRef.current !== arrow) {
104
- arrowRef.current = arrow;
105
- updatePositionManager();
106
- }
107
- });
108
- // Let users use callback refs so they feel like 'normal' DOM refs
109
- return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };
110
- }
111
- exports.usePositioning = usePositioning;
112
- function usePositioningOptions(options) {
113
- var align = options.align, arrowPadding = options.arrowPadding, autoSize = options.autoSize, coverTarget = options.coverTarget, flipBoundary = options.flipBoundary, offset = options.offset, overflowBoundary = options.overflowBoundary, pinned = options.pinned, position = options.position, disableTether = options.unstable_disableTether, positionFixed = options.positionFixed, overflowBoundaryPadding = options.overflowBoundaryPadding, fallbackPositions = options.fallbackPositions;
114
- var dir = react_shared_contexts_1.useFluent_unstable().dir;
115
- var isRtl = dir === 'rtl';
116
- var strategy = positionFixed ? 'fixed' : 'absolute';
117
- return React.useCallback(function (container, arrow) {
118
- var hasScrollableElement = utils_1.hasScrollParent(container);
119
- var middleware = [
120
- offset && middleware_1.offset(offset),
121
- coverTarget && middleware_1.coverTarget(),
122
- !pinned && middleware_1.flip({ container: container, flipBoundary: flipBoundary, hasScrollableElement: hasScrollableElement, isRtl: isRtl, fallbackPositions: fallbackPositions }),
123
- middleware_1.shift({
124
- container: container,
125
- hasScrollableElement: hasScrollableElement,
126
- overflowBoundary: overflowBoundary,
127
- disableTether: disableTether,
128
- overflowBoundaryPadding: overflowBoundaryPadding,
129
- isRtl: isRtl,
130
- }),
131
- autoSize && middleware_1.maxSize(autoSize, { container: container, overflowBoundary: overflowBoundary }),
132
- middleware_1.intersecting(),
133
- arrow && dom_1.arrow({ element: arrow, padding: arrowPadding }),
134
- dom_1.hide({ strategy: 'referenceHidden' }),
135
- dom_1.hide({ strategy: 'escaped' }),
136
- ].filter(Boolean);
137
- var placement = utils_1.toFloatingUIPlacement(align, position, isRtl);
138
- return {
139
- placement: placement,
140
- middleware: middleware,
141
- strategy: strategy,
142
- };
143
- }, [
144
- align,
145
- arrowPadding,
146
- autoSize,
147
- coverTarget,
148
- disableTether,
149
- flipBoundary,
150
- isRtl,
151
- offset,
152
- overflowBoundary,
153
- pinned,
154
- position,
155
- strategy,
156
- overflowBoundaryPadding,
157
- fallbackPositions,
158
- ]);
159
- }
160
- });
161
- //# sourceMappingURL=usePositioning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePositioning.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/usePositioning.ts"],"names":[],"mappings":";;;;IAuBA;;OAEG;IACH,SAAgB,cAAc,CAAC,OAA8B;QAC3D,IAAM,UAAU,GAAG,KAAK,C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BAAgB,kBAAA;oBAChB,aAAa,eAAA;oBACb,uBAAuB,yBAAA;oBACvB,KAAK,OAAA;iBACN,CAAC;gBACF,QAAQ,IAAI,oBAAiB,CAAC,QAAQ,EAAE,EAAE,SAAS,WAAA,EAAE,gBAAgB,kBAAA,EAAE,CAAC;gBACxE,yBAAsB,EAAE;gBACxB,KAAK,IAAI,WAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;gBACnE,UAAc,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAC/C,UAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;aACxC,CAAC,MAAM,CAAC,OAAO,CAAiB,CAAC;YAElC,IAAM,SAAS,GAAG,6BAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YAEhE,OAAO;gBACL,SAAS,WAAA;gBACT,UAAU,YAAA;gBACV,QAAQ,UAAA;aACT,CAAC;QACJ,CAAC,EACD;YACE,KAAK;YACL,YAAY;YACZ,QAAQ;YACR,WAAW;YACX,aAAa;YACb,YAAY;YACZ,KAAK;YACL,MAAM;YACN,gBAAgB;YAChB,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,uBAAuB;YACvB,iBAAiB;SAClB,CACF,CAAC;IACJ,CAAC","sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps, Pick<PositioningOptions, 'fallbackPositions' | 'pinned'> {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n overflowBoundaryPadding,\n fallbackPositions,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement, isRtl, fallbackPositions }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n ],\n );\n}\n"]}
@@ -1,39 +0,0 @@
1
- define(["require", "exports", "react", "./createVirtualElementFromClick"], function (require, exports, React, createVirtualElementFromClick_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.usePositioningMouseTarget = void 0;
5
- /**
6
- * @internal
7
- * A state hook that manages a popper virtual element from mouseevents.
8
- * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
9
- * React synthetic events are not persisted by this hook
10
- *
11
- * @param initialState - initializes a user provided state similare to useState
12
- * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
13
- */
14
- var usePositioningMouseTarget = function (initialState) {
15
- var _a = React.useState(initialState), virtualElement = _a[0], setVirtualElement = _a[1];
16
- var setVirtualMouseTarget = function (event) {
17
- if (event === undefined || event === null) {
18
- setVirtualElement(undefined);
19
- return;
20
- }
21
- var mouseevent;
22
- if (!(event instanceof MouseEvent)) {
23
- mouseevent = event.nativeEvent;
24
- }
25
- else {
26
- mouseevent = event;
27
- }
28
- if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
29
- // eslint-disable-next-line no-console
30
- console.error('usePositioningMouseTarget should only be used with MouseEvent');
31
- }
32
- var contextTarget = createVirtualElementFromClick_1.createVirtualElementFromClick(mouseevent);
33
- setVirtualElement(contextTarget);
34
- };
35
- return [virtualElement, setVirtualMouseTarget];
36
- };
37
- exports.usePositioningMouseTarget = usePositioningMouseTarget;
38
- });
39
- //# sourceMappingURL=usePositioningMouseTarget.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePositioningMouseTarget.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-positioning/src/usePositioningMouseTarget.ts"],"names":[],"mappings":";;;;IAIA;;;;;;;;OAQG;IACI,IAAM,yBAAyB,GAAG,UACvC,YAA4E;QAEtE,IAAA,KAAsC,KAAK,CAAC,QAAQ,CAAwC,YAAY,CAAC,EAAxG,cAAc,QAAA,EAAE,iBAAiB,QAAuE,CAAC;QAEhH,IAAM,qBAAqB,GAA0B,UAAA,KAAK;YACxD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;gBACzC,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAC7B,OAAO;aACR;YAED,IAAI,UAAsB,CAAC;YAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;gBAClC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;aAChC;iBAAM;gBACL,UAAU,GAAG,KAAK,CAAC;aACpB;YAED,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBAChF,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;aAChF;YAED,IAAM,aAAa,GAAG,6DAA6B,CAAC,UAAU,CAAC,CAAC;YAChE,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAC;IAC1D,CAAC,CAAC;IA5BW,QAAA,yBAAyB,6BA4BpC","sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget: SetVirtualMouseTarget = event => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"]}
@@ -1,27 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.debounce = void 0;
5
- /**
6
- * Promise microtask debouncer used by Popper.js v2
7
- * This is no longer exported in Floating UI (Popper.js v3)
8
- * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
9
- * @param fn function that will be debounced
10
- */
11
- function debounce(fn) {
12
- var pending;
13
- return function () {
14
- if (!pending) {
15
- pending = new Promise(function (resolve) {
16
- Promise.resolve().then(function () {
17
- pending = undefined;
18
- resolve(fn());
19
- });
20
- });
21
- }
22
- return pending;
23
- };
24
- }
25
- exports.debounce = debounce;
26
- });
27
- //# sourceMappingURL=debounce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/debounce.ts"],"names":[],"mappings":";;;;IAAA;;;;;OAKG;IACH,SAAgB,QAAQ,CAAI,EAAY;QACtC,IAAI,OAA+B,CAAC;QACpC,OAAO;YACL,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,OAAO,CAAI,UAAA,OAAO;oBAC9B,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;wBACrB,OAAO,GAAG,SAAS,CAAC;wBACpB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;oBAChB,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;aACJ;YAED,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;IAdD,4BAcC","sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"]}
@@ -1,37 +0,0 @@
1
- define(["require", "exports", "./parseFloatingUIPlacement"], function (require, exports, parseFloatingUIPlacement_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fromFloatingUIPlacement = void 0;
5
- var getPositionMap = function () { return ({
6
- top: 'above',
7
- bottom: 'below',
8
- right: 'after',
9
- left: 'before',
10
- }); };
11
- // Floating UI automatically flips alignment
12
- // https://github.com/floating-ui/floating-ui/issues/1563
13
- var getAlignmentMap = function (position) {
14
- if (position === 'above' || position === 'below') {
15
- return {
16
- start: 'start',
17
- end: 'end',
18
- };
19
- }
20
- return {
21
- start: 'top',
22
- end: 'bottom',
23
- };
24
- };
25
- /**
26
- * Maps Floating UI placement to positioning values
27
- * @see positioningHelper.test.ts for expected placement values
28
- */
29
- var fromFloatingUIPlacement = function (placement) {
30
- var _a = parseFloatingUIPlacement_1.parseFloatingUIPlacement(placement), side = _a.side, floatingUIAlignment = _a.alignment;
31
- var position = getPositionMap()[side];
32
- var alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];
33
- return { position: position, alignment: alignment };
34
- };
35
- exports.fromFloatingUIPlacement = fromFloatingUIPlacement;
36
- });
37
- //# sourceMappingURL=fromFloatingUIPlacement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromFloatingUIPlacement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/fromFloatingUIPlacement.ts"],"names":[],"mappings":";;;;IAIA,IAAM,cAAc,GAAG,cAA8B,OAAA,CAAC;QACpD,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;KACf,CAAC,EALmD,CAKnD,CAAC;IAEH,4CAA4C;IAC5C,yDAAyD;IACzD,IAAM,eAAe,GAAG,UAAC,QAAkB;QACzC,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,OAAO,EAAE;YAChD,OAAO;gBACL,KAAK,EAAE,OAAO;gBACd,GAAG,EAAE,KAAK;aACX,CAAC;SACH;QAED,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC,CAAC;IAEF;;;OAGG;IACI,IAAM,uBAAuB,GAAG,UAAC,SAAoB;QACpD,IAAA,KAA2C,mDAAwB,CAAC,SAAS,CAAC,EAA5E,IAAI,UAAA,EAAa,mBAAmB,eAAwC,CAAC;QACrF,IAAM,QAAQ,GAAG,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QACxC,IAAM,SAAS,GAAG,mBAAmB,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAExF,OAAO,EAAE,QAAQ,UAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IACjC,CAAC,CAAC;IANW,QAAA,uBAAuB,2BAMlC","sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, Alignment> => {\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end',\n };\n }\n\n return {\n start: 'top',\n end: 'bottom',\n };\n};\n\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"]}
@@ -1,26 +0,0 @@
1
- define(["require", "exports", "./getScrollParent"], function (require, exports, getScrollParent_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getBoundary = void 0;
5
- /**
6
- * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
7
- */
8
- function getBoundary(element, boundary) {
9
- if (boundary === 'window') {
10
- return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
11
- }
12
- if (boundary === 'clippingParents') {
13
- return 'clippingAncestors';
14
- }
15
- if (boundary === 'scrollParent') {
16
- var boundariesNode = getScrollParent_1.getScrollParent(element);
17
- if (boundariesNode.nodeName === 'BODY') {
18
- boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
19
- }
20
- return boundariesNode;
21
- }
22
- return boundary;
23
- }
24
- exports.getBoundary = getBoundary;
25
- });
26
- //# sourceMappingURL=getBoundary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/getBoundary.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,WAAW,CAAC,OAA2B,EAAE,QAAmB;QAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;YACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;SAChD;QAED,IAAI,QAAQ,KAAK,iBAAiB,EAAE;YAClC,OAAO,mBAAmB,CAAC;SAC5B;QAED,IAAI,QAAQ,KAAK,cAAc,EAAE;YAC/B,IAAI,cAAc,GAA4B,iCAAe,CAAC,OAAO,CAAC,CAAC;YAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;gBACtC,cAAc,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;aAC1D;YAED,OAAO,cAAc,CAAC;SACvB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IApBD,kCAoBC","sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary): FloatingUIBoundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'clippingParents') {\n return 'clippingAncestors';\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"]}