@fluentui/react-positioning 9.5.14 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. package/CHANGELOG.json +30 -1
  2. package/CHANGELOG.md +16 -2
  3. package/dist/index.d.ts +6 -1
  4. package/lib/constants.js +0 -1
  5. package/lib/constants.js.map +1 -1
  6. package/lib/createArrowStyles.js +47 -55
  7. package/lib/createArrowStyles.js.map +1 -1
  8. package/lib/createPositionManager.js +95 -108
  9. package/lib/createPositionManager.js.map +1 -1
  10. package/lib/createVirtualElementFromClick.js +18 -19
  11. package/lib/createVirtualElementFromClick.js.map +1 -1
  12. package/lib/index.js +0 -1
  13. package/lib/index.js.map +1 -1
  14. package/lib/middleware/coverTarget.js +26 -32
  15. package/lib/middleware/coverTarget.js.map +1 -1
  16. package/lib/middleware/flip.js +22 -32
  17. package/lib/middleware/flip.js.map +1 -1
  18. package/lib/middleware/index.js +0 -1
  19. package/lib/middleware/index.js.map +1 -1
  20. package/lib/middleware/intersecting.js +16 -17
  21. package/lib/middleware/intersecting.js.map +1 -1
  22. package/lib/middleware/maxSize.js +25 -34
  23. package/lib/middleware/maxSize.js.map +1 -1
  24. package/lib/middleware/offset.js +3 -5
  25. package/lib/middleware/offset.js.map +1 -1
  26. package/lib/middleware/shift.js +21 -30
  27. package/lib/middleware/shift.js.map +1 -1
  28. package/lib/types.js +0 -1
  29. package/lib/types.js.map +1 -1
  30. package/lib/usePositioning.js +188 -154
  31. package/lib/usePositioning.js.map +1 -1
  32. package/lib/usePositioningMouseTarget.js +24 -23
  33. package/lib/usePositioningMouseTarget.js.map +1 -1
  34. package/lib/utils/debounce.js +13 -14
  35. package/lib/utils/debounce.js.map +1 -1
  36. package/lib/utils/fromFloatingUIPlacement.js +23 -28
  37. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  38. package/lib/utils/getBoundary.js +14 -16
  39. package/lib/utils/getBoundary.js.map +1 -1
  40. package/lib/utils/getFloatingUIOffset.js +16 -27
  41. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  42. package/lib/utils/getReactFiberFromNode.js +36 -37
  43. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  44. package/lib/utils/getScrollParent.js +35 -42
  45. package/lib/utils/getScrollParent.js.map +1 -1
  46. package/lib/utils/hasAutoFocusFilter.js +9 -11
  47. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  48. package/lib/utils/index.js +0 -1
  49. package/lib/utils/index.js.map +1 -1
  50. package/lib/utils/mergeArrowOffset.js +24 -25
  51. package/lib/utils/mergeArrowOffset.js.map +1 -1
  52. package/lib/utils/parseFloatingUIPlacement.js +6 -7
  53. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  54. package/lib/utils/resolvePositioningShorthand.js +55 -56
  55. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  56. package/lib/utils/toFloatingUIPadding.js +16 -21
  57. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  58. package/lib/utils/toFloatingUIPlacement.js +25 -27
  59. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  60. package/lib/utils/toggleScrollListener.js +12 -14
  61. package/lib/utils/toggleScrollListener.js.map +1 -1
  62. package/lib/utils/useCallbackRef.js +30 -32
  63. package/lib/utils/useCallbackRef.js.map +1 -1
  64. package/lib/utils/writeArrowUpdates.js +10 -17
  65. package/lib/utils/writeArrowUpdates.js.map +1 -1
  66. package/lib/utils/writeContainerupdates.js +39 -39
  67. package/lib/utils/writeContainerupdates.js.map +1 -1
  68. package/lib-commonjs/constants.js +1 -3
  69. package/lib-commonjs/constants.js.map +1 -1
  70. package/lib-commonjs/createArrowStyles.js +1 -3
  71. package/lib-commonjs/createArrowStyles.js.map +1 -1
  72. package/lib-commonjs/createPositionManager.js +4 -5
  73. package/lib-commonjs/createPositionManager.js.map +1 -1
  74. package/lib-commonjs/createVirtualElementFromClick.js +1 -3
  75. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  76. package/lib-commonjs/index.js +0 -3
  77. package/lib-commonjs/index.js.map +1 -1
  78. package/lib-commonjs/middleware/coverTarget.js +1 -3
  79. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  80. package/lib-commonjs/middleware/flip.js +1 -3
  81. package/lib-commonjs/middleware/flip.js.map +1 -1
  82. package/lib-commonjs/middleware/index.js +0 -3
  83. package/lib-commonjs/middleware/index.js.map +1 -1
  84. package/lib-commonjs/middleware/intersecting.js +1 -3
  85. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  86. package/lib-commonjs/middleware/maxSize.js +1 -3
  87. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  88. package/lib-commonjs/middleware/offset.js +1 -3
  89. package/lib-commonjs/middleware/offset.js.map +1 -1
  90. package/lib-commonjs/middleware/shift.js +1 -3
  91. package/lib-commonjs/middleware/shift.js.map +1 -1
  92. package/lib-commonjs/types.js +0 -3
  93. package/lib-commonjs/types.js.map +1 -1
  94. package/lib-commonjs/usePositioning.js +6 -6
  95. package/lib-commonjs/usePositioning.js.map +1 -1
  96. package/lib-commonjs/usePositioningMouseTarget.js +1 -3
  97. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  98. package/lib-commonjs/utils/debounce.js +1 -3
  99. package/lib-commonjs/utils/debounce.js.map +1 -1
  100. package/lib-commonjs/utils/fromFloatingUIPlacement.js +1 -3
  101. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  102. package/lib-commonjs/utils/getBoundary.js +1 -3
  103. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  104. package/lib-commonjs/utils/getFloatingUIOffset.js +1 -3
  105. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  106. package/lib-commonjs/utils/getReactFiberFromNode.js +1 -3
  107. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  108. package/lib-commonjs/utils/getScrollParent.js +1 -3
  109. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  110. package/lib-commonjs/utils/hasAutoFocusFilter.js +1 -3
  111. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  112. package/lib-commonjs/utils/index.js +0 -3
  113. package/lib-commonjs/utils/index.js.map +1 -1
  114. package/lib-commonjs/utils/mergeArrowOffset.js +1 -3
  115. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  116. package/lib-commonjs/utils/parseFloatingUIPlacement.js +1 -3
  117. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  118. package/lib-commonjs/utils/resolvePositioningShorthand.js +1 -3
  119. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  120. package/lib-commonjs/utils/toFloatingUIPadding.js +1 -3
  121. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  122. package/lib-commonjs/utils/toFloatingUIPlacement.js +1 -3
  123. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  124. package/lib-commonjs/utils/toggleScrollListener.js +1 -3
  125. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  126. package/lib-commonjs/utils/useCallbackRef.js +1 -3
  127. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  128. package/lib-commonjs/utils/writeArrowUpdates.js +1 -3
  129. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  130. package/lib-commonjs/utils/writeContainerupdates.js +12 -5
  131. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  132. package/package.json +3 -3
@@ -1,35 +1,29 @@
1
1
  import { parseFloatingUIPlacement } from '../utils/index';
2
2
  export function coverTarget() {
3
- return {
4
- name: 'coverTarget',
5
- fn: middlewareArguments => {
6
- const {
7
- placement,
8
- rects,
9
- x,
10
- y
11
- } = middlewareArguments;
12
- const basePlacement = parseFloatingUIPlacement(placement).side;
13
- const newCoords = {
14
- x,
15
- y
16
- };
17
- switch (basePlacement) {
18
- case 'bottom':
19
- newCoords.y -= rects.reference.height;
20
- break;
21
- case 'top':
22
- newCoords.y += rects.reference.height;
23
- break;
24
- case 'left':
25
- newCoords.x += rects.reference.width;
26
- break;
27
- case 'right':
28
- newCoords.x -= rects.reference.width;
29
- break;
30
- }
31
- return newCoords;
32
- }
33
- };
3
+ return {
4
+ name: 'coverTarget',
5
+ fn: (middlewareArguments)=>{
6
+ const { placement , rects , x , y } = middlewareArguments;
7
+ const basePlacement = parseFloatingUIPlacement(placement).side;
8
+ const newCoords = {
9
+ x,
10
+ y
11
+ };
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
+ };
34
29
  }
35
- //# sourceMappingURL=coverTarget.js.map
@@ -1 +1 @@
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
+ {"version":3,"sources":["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"],"names":["parseFloatingUIPlacement","coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","side","newCoords","reference","height","width"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,iBAAiB;AAE1D,OAAO,SAASC,cAA0B;IACxC,OAAO;QACLC,MAAM;QACNC,IAAIC,CAAAA,sBAAuB;YACzB,MAAM,EAAEC,UAAS,EAAEC,MAAK,EAAEC,EAAC,EAAEC,EAAC,EAAE,GAAGJ;YACnC,MAAMK,gBAAgBT,yBAAyBK,WAAWK,IAAI;YAC9D,MAAMC,YAAY;gBAAEJ;gBAAGC;YAAE;YAEzB,OAAQC;gBACN,KAAK;oBACHE,UAAUH,CAAC,IAAIF,MAAMM,SAAS,CAACC,MAAM;oBACrC,KAAM;gBACR,KAAK;oBACHF,UAAUH,CAAC,IAAIF,MAAMM,SAAS,CAACC,MAAM;oBACrC,KAAM;gBACR,KAAK;oBACHF,UAAUJ,CAAC,IAAID,MAAMM,SAAS,CAACE,KAAK;oBACpC,KAAM;gBACR,KAAK;oBACHH,UAAUJ,CAAC,IAAID,MAAMM,SAAS,CAACE,KAAK;oBACpC,KAAM;YACV;YAEA,OAAOH;QACT;IACF;AACF,CAAC"}
@@ -1,36 +1,26 @@
1
1
  import { flip as baseFlip } from '@floating-ui/dom';
2
2
  import { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';
3
3
  export function flip(options) {
4
- const {
5
- hasScrollableElement,
6
- flipBoundary,
7
- container,
8
- fallbackPositions = [],
9
- isRtl
10
- } = options;
11
- const fallbackPlacements = fallbackPositions.reduce((acc, shorthand) => {
12
- const {
13
- position,
14
- align
15
- } = resolvePositioningShorthand(shorthand);
16
- const placement = toFloatingUIPlacement(align, position, isRtl);
17
- if (placement) {
18
- acc.push(placement);
19
- }
20
- return acc;
21
- }, []);
22
- return baseFlip({
23
- ...(hasScrollableElement && {
24
- boundary: 'clippingAncestors'
25
- }),
26
- ...(flipBoundary && {
27
- altBoundary: true,
28
- boundary: getBoundary(container, flipBoundary)
29
- }),
30
- fallbackStrategy: 'bestFit',
31
- ...(fallbackPlacements.length && {
32
- fallbackPlacements
33
- })
34
- });
4
+ const { hasScrollableElement , flipBoundary , container , fallbackPositions =[] , isRtl } = options;
5
+ const fallbackPlacements = fallbackPositions.reduce((acc, shorthand)=>{
6
+ const { position , align } = resolvePositioningShorthand(shorthand);
7
+ const placement = toFloatingUIPlacement(align, position, isRtl);
8
+ if (placement) {
9
+ acc.push(placement);
10
+ }
11
+ return acc;
12
+ }, []);
13
+ return baseFlip({
14
+ ...hasScrollableElement && {
15
+ boundary: 'clippingAncestors'
16
+ },
17
+ ...flipBoundary && {
18
+ altBoundary: true,
19
+ boundary: getBoundary(container, flipBoundary)
20
+ },
21
+ fallbackStrategy: 'bestFit',
22
+ ...fallbackPlacements.length && {
23
+ fallbackPlacements
24
+ }
25
+ });
35
26
  }
36
- //# sourceMappingURL=flip.js.map
@@ -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":["../../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
+ {"version":3,"sources":["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"],"names":["flip","baseFlip","getBoundary","resolvePositioningShorthand","toFloatingUIPlacement","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","placement","push","boundary","altBoundary","fallbackStrategy","length"],"mappings":"AAAA,SAASA,QAAQC,QAAQ,QAAmB,mBAAmB;AAE/D,SAASC,WAAW,EAAEC,2BAA2B,EAAEC,qBAAqB,QAAQ,iBAAiB;AAQjG,OAAO,SAASJ,KAAKK,OAA8B,EAAE;IACnD,MAAM,EAAEC,qBAAoB,EAAEC,aAAY,EAAEC,UAAS,EAAEC,mBAAoB,EAAE,CAAA,EAAEC,MAAK,EAAE,GAAGL;IAEzF,MAAMM,qBAAqBF,kBAAkBG,MAAM,CAAc,CAACC,KAAKC,YAAc;QACnF,MAAM,EAAEC,SAAQ,EAAEC,MAAK,EAAE,GAAGb,4BAA4BW;QACxD,MAAMG,YAAYb,sBAAsBY,OAAOD,UAAUL;QACzD,IAAIO,WAAW;YACbJ,IAAIK,IAAI,CAACD;QACX,CAAC;QACD,OAAOJ;IACT,GAAG,EAAE;IAEL,OAAOZ,SAAS;QACd,GAAIK,wBAAwB;YAAEa,UAAU;QAAoB,CAAC;QAC7D,GAAIZ,gBAAgB;YAAEa,aAAa,IAAI;YAAED,UAAUjB,YAAYM,WAAWD;QAAc,CAAC;QACzFc,kBAAkB;QAClB,GAAIV,mBAAmBW,MAAM,IAAI;YAAEX;QAAmB,CAAC;IACzD;AACF,CAAC"}
@@ -4,4 +4,3 @@ export * from './intersecting';
4
4
  export * from './maxSize';
5
5
  export * from './offset';
6
6
  export * from './shift';
7
- //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,UAAU"}
@@ -1,21 +1,20 @@
1
1
  import { detectOverflow } from '@floating-ui/dom';
2
2
  export function intersecting() {
3
- return {
4
- name: 'intersectionObserver',
5
- fn: async middlewareArguments => {
6
- const floatingRect = middlewareArguments.rects.floating;
7
- const altOverflow = await detectOverflow(middlewareArguments, {
8
- altBoundary: true
9
- });
10
- const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;
11
- const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;
12
- const isIntersecting = isIntersectingTop || isIntersectingBottom;
13
- return {
14
- data: {
15
- intersecting: isIntersecting
3
+ return {
4
+ name: 'intersectionObserver',
5
+ fn: async (middlewareArguments)=>{
6
+ const floatingRect = middlewareArguments.rects.floating;
7
+ const altOverflow = await detectOverflow(middlewareArguments, {
8
+ altBoundary: true
9
+ });
10
+ const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;
11
+ const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;
12
+ const isIntersecting = isIntersectingTop || isIntersectingBottom;
13
+ return {
14
+ data: {
15
+ intersecting: isIntersecting
16
+ }
17
+ };
16
18
  }
17
- };
18
- }
19
- };
19
+ };
20
20
  }
21
- //# sourceMappingURL=intersecting.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"sources":["intersecting.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { detectOverflow } from '@floating-ui/dom';\n\nexport function intersecting(): Middleware {\n return {\n name: 'intersectionObserver',\n fn: async middlewareArguments => {\n const floatingRect = middlewareArguments.rects.floating;\n const altOverflow = await detectOverflow(middlewareArguments, { altBoundary: true });\n\n const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;\n const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;\n\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n\n return {\n data: {\n intersecting: isIntersecting,\n },\n };\n },\n };\n}\n"],"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"mappings":"AACA,SAASA,cAAc,QAAQ,mBAAmB;AAElD,OAAO,SAASC,eAA2B;IACzC,OAAO;QACLC,MAAM;QACNC,IAAI,OAAMC,sBAAuB;YAC/B,MAAMC,eAAeD,oBAAoBE,KAAK,CAACC,QAAQ;YACvD,MAAMC,cAAc,MAAMR,eAAeI,qBAAqB;gBAAEK,aAAa,IAAI;YAAC;YAElF,MAAMC,oBAAoBF,YAAYG,GAAG,GAAGN,aAAaO,MAAM,IAAIJ,YAAYG,GAAG,GAAG;YACrF,MAAME,uBAAuBL,YAAYM,MAAM,GAAGT,aAAaO,MAAM,IAAIJ,YAAYM,MAAM,GAAG;YAE9F,MAAMC,iBAAiBL,qBAAqBG;YAE5C,OAAO;gBACLG,MAAM;oBACJf,cAAcc;gBAChB;YACF;QACF;IACF;AACF,CAAC"}
@@ -1,38 +1,29 @@
1
1
  import { size } from '@floating-ui/dom';
2
2
  import { getBoundary } from '../utils/getBoundary';
3
3
  export function maxSize(autoSize, options) {
4
- const {
5
- container,
6
- overflowBoundary
7
- } = options;
8
- return size({
9
- ...(overflowBoundary && {
10
- altBoundary: true,
11
- boundary: getBoundary(container, overflowBoundary)
12
- }),
13
- apply({
14
- availableHeight,
15
- availableWidth,
16
- elements,
17
- rects
18
- }) {
19
- const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');
20
- const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');
21
- if (applyMaxHeight) {
22
- Object.assign(elements.floating.style, {
23
- maxHeight: `${availableHeight}px`,
24
- boxSizing: 'border-box',
25
- overflowY: 'auto'
26
- });
27
- }
28
- if (applyMaxWidth) {
29
- Object.assign(elements.floating.style, {
30
- maxWidth: `${availableWidth}px`,
31
- boxSizing: 'border-box',
32
- overflowX: 'auto'
33
- });
34
- }
35
- }
36
- });
4
+ const { container , overflowBoundary } = options;
5
+ return size({
6
+ ...overflowBoundary && {
7
+ altBoundary: true,
8
+ boundary: getBoundary(container, overflowBoundary)
9
+ },
10
+ apply ({ availableHeight , availableWidth , elements , rects }) {
11
+ const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');
12
+ const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');
13
+ if (applyMaxHeight) {
14
+ Object.assign(elements.floating.style, {
15
+ maxHeight: `${availableHeight}px`,
16
+ boxSizing: 'border-box',
17
+ overflowY: 'auto'
18
+ });
19
+ }
20
+ if (applyMaxWidth) {
21
+ Object.assign(elements.floating.style, {
22
+ maxWidth: `${availableWidth}px`,
23
+ boxSizing: 'border-box',
24
+ overflowX: 'auto'
25
+ });
26
+ }
27
+ }
28
+ });
37
29
  }
38
- //# sourceMappingURL=maxSize.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["size","getBoundary","maxSize","autoSize","options","container","overflowBoundary","altBoundary","boundary","apply","availableHeight","availableWidth","elements","rects","applyMaxWidth","floating","width","applyMaxHeight","height","Object","assign","style","maxHeight","boxSizing","overflowY","maxWidth","overflowX"],"sources":["../../src/middleware/maxSize.ts"],"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"],"mappings":"AAAA,SAASA,IAAI,QAAQ;AAGrB,SAASC,WAAW,QAAQ;AAK5B,OAAO,SAASC,QAAQC,QAAwC,EAAEC,OAAiC,EAAc;EAC/G,MAAM;IAAEC,SAAA;IAAWC;EAAgB,CAAE,GAAGF,OAAA;EACxC,OAAOJ,IAAA,CAAK;IACV,IAAIM,gBAAA,IAAoB;MAAEC,WAAA,EAAa,IAAI;MAAEC,QAAA,EAAUP,WAAA,CAAYI,SAAA,EAAWC,gBAAA;IAAkB,CAAC;IACjGG,MAAM;MAAEC,eAAA;MAAiBC,cAAA;MAAgBC,QAAA;MAAUC;IAAK,CAAE,EAAE;MAC1D,MAAMC,aAAA,GACJX,QAAA,KAAa,YACbA,QAAA,KAAa,kBACZU,KAAA,CAAME,QAAQ,CAACC,KAAK,GAAGL,cAAA,KAAmBR,QAAA,KAAa,IAAI,IAAIA,QAAA,KAAa,OAAM;MAErF,MAAMc,cAAA,GACJd,QAAA,KAAa,YACbA,QAAA,KAAa,mBACZU,KAAA,CAAME,QAAQ,CAACG,MAAM,GAAGR,eAAA,KAAoBP,QAAA,KAAa,IAAI,IAAIA,QAAA,KAAa,QAAO;MAExF,IAAIc,cAAA,EAAgB;QAClBE,MAAA,CAAOC,MAAM,CAAoDR,QAAA,CAASG,QAAQ,CAACM,KAAK,EAAE;UACxFC,SAAA,EAAY,GAAEZ,eAAgB,IAAG;UACjCa,SAAA,EAAW;UACXC,SAAA,EAAW;QACb;MACF;MAEA,IAAIV,aAAA,EAAe;QACjBK,MAAA,CAAOC,MAAM,CAAoDR,QAAA,CAASG,QAAQ,CAACM,KAAK,EAAE;UACxFI,QAAA,EAAW,GAAEd,cAAe,IAAG;UAC/BY,SAAA,EAAW;UACXG,SAAA,EAAW;QACb;MACF;IACF;EACF;AACF"}
1
+ {"version":3,"sources":["maxSize.ts"],"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"],"names":["size","getBoundary","maxSize","autoSize","options","container","overflowBoundary","altBoundary","boundary","apply","availableHeight","availableWidth","elements","rects","applyMaxWidth","floating","width","applyMaxHeight","height","Object","assign","style","maxHeight","boxSizing","overflowY","maxWidth","overflowX"],"mappings":"AAAA,SAASA,IAAI,QAAQ,mBAAmB;AAGxC,SAASC,WAAW,QAAQ,uBAAuB;AAKnD,OAAO,SAASC,QAAQC,QAAwC,EAAEC,OAAiC,EAAc;IAC/G,MAAM,EAAEC,UAAS,EAAEC,iBAAgB,EAAE,GAAGF;IACxC,OAAOJ,KAAK;QACV,GAAIM,oBAAoB;YAAEC,aAAa,IAAI;YAAEC,UAAUP,YAAYI,WAAWC;QAAkB,CAAC;QACjGG,OAAM,EAAEC,gBAAe,EAAEC,eAAc,EAAEC,SAAQ,EAAEC,MAAK,EAAE,EAAE;YAC1D,MAAMC,gBACJX,aAAa,YACbA,aAAa,kBACZU,MAAME,QAAQ,CAACC,KAAK,GAAGL,kBAAmBR,CAAAA,aAAa,IAAI,IAAIA,aAAa,OAAM;YAErF,MAAMc,iBACJd,aAAa,YACbA,aAAa,mBACZU,MAAME,QAAQ,CAACG,MAAM,GAAGR,mBAAoBP,CAAAA,aAAa,IAAI,IAAIA,aAAa,QAAO;YAExF,IAAIc,gBAAgB;gBAClBE,OAAOC,MAAM,CAAoDR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACxFC,WAAW,CAAC,EAAEZ,gBAAgB,EAAE,CAAC;oBACjCa,WAAW;oBACXC,WAAW;gBACb;YACF,CAAC;YAED,IAAIV,eAAe;gBACjBK,OAAOC,MAAM,CAAoDR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACxFI,UAAU,CAAC,EAAEd,eAAe,EAAE,CAAC;oBAC/BY,WAAW;oBACXG,WAAW;gBACb;YACF,CAAC;QACH;IACF;AACF,CAAC"}
@@ -2,9 +2,7 @@ import { offset as baseOffset } from '@floating-ui/dom';
2
2
  import { getFloatingUIOffset } from '../utils/getFloatingUIOffset';
3
3
  /**
4
4
  * Wraps floating UI offset middleware to to transform offset value
5
- */
6
- export function offset(offsetValue) {
7
- const floatingUIOffset = getFloatingUIOffset(offsetValue);
8
- return baseOffset(floatingUIOffset);
5
+ */ export function offset(offsetValue) {
6
+ const floatingUIOffset = getFloatingUIOffset(offsetValue);
7
+ return baseOffset(floatingUIOffset);
9
8
  }
10
- //# sourceMappingURL=offset.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["offset","baseOffset","getFloatingUIOffset","offsetValue","floatingUIOffset"],"sources":["../../src/middleware/offset.ts"],"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"],"mappings":"AAAA,SAASA,MAAA,IAAUC,UAAU,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpC;;;AAGA,OAAO,SAASF,OAAOG,WAAyC,EAAE;EAChE,MAAMC,gBAAA,GAAmBF,mBAAA,CAAoBC,WAAA;EAC7C,OAAOF,UAAA,CAAWG,gBAAA;AACpB"}
1
+ {"version":3,"sources":["offset.ts"],"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"],"names":["offset","baseOffset","getFloatingUIOffset","offsetValue","floatingUIOffset"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,mBAAmB;AAExD,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE;;CAEC,GACD,OAAO,SAASF,OAAOG,WAAyC,EAAE;IAChE,MAAMC,mBAAmBF,oBAAoBC;IAC7C,OAAOF,WAAWG;AACpB,CAAC"}
@@ -2,34 +2,25 @@ import { shift as baseShift, limitShift } from '@floating-ui/dom';
2
2
  import { getBoundary, toFloatingUIPadding } from '../utils/index';
3
3
  /**
4
4
  * Wraps the floating UI shift middleware for easier usage of our options
5
- */
6
- export function shift(options) {
7
- const {
8
- hasScrollableElement,
9
- disableTether,
10
- overflowBoundary,
11
- container,
12
- overflowBoundaryPadding,
13
- isRtl
14
- } = options;
15
- return baseShift({
16
- ...(hasScrollableElement && {
17
- boundary: 'clippingAncestors'
18
- }),
19
- ...(disableTether && {
20
- crossAxis: disableTether === 'all',
21
- limiter: limitShift({
22
- crossAxis: disableTether !== 'all',
23
- mainAxis: false
24
- })
25
- }),
26
- ...(overflowBoundaryPadding && {
27
- padding: toFloatingUIPadding(overflowBoundaryPadding, isRtl)
28
- }),
29
- ...(overflowBoundary && {
30
- altBoundary: true,
31
- boundary: getBoundary(container, overflowBoundary)
32
- })
33
- });
5
+ */ export function shift(options) {
6
+ const { hasScrollableElement , disableTether , overflowBoundary , container , overflowBoundaryPadding , isRtl } = options;
7
+ return baseShift({
8
+ ...hasScrollableElement && {
9
+ boundary: 'clippingAncestors'
10
+ },
11
+ ...disableTether && {
12
+ crossAxis: disableTether === 'all',
13
+ limiter: limitShift({
14
+ crossAxis: disableTether !== 'all',
15
+ mainAxis: false
16
+ })
17
+ },
18
+ ...overflowBoundaryPadding && {
19
+ padding: toFloatingUIPadding(overflowBoundaryPadding, isRtl)
20
+ },
21
+ ...overflowBoundary && {
22
+ altBoundary: true,
23
+ boundary: getBoundary(container, overflowBoundary)
24
+ }
25
+ });
34
26
  }
35
- //# sourceMappingURL=shift.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["shift","baseShift","limitShift","getBoundary","toFloatingUIPadding","options","hasScrollableElement","disableTether","overflowBoundary","container","overflowBoundaryPadding","isRtl","boundary","crossAxis","limiter","mainAxis","padding","altBoundary"],"sources":["../../src/middleware/shift.ts"],"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"],"mappings":"AAAA,SAASA,KAAA,IAASC,SAAS,EAAEC,UAAU,QAAQ;AAE/C,SAASC,WAAW,EAAEC,mBAAmB,QAAQ;AAUjD;;;AAGA,OAAO,SAASJ,MAAMK,OAA+B,EAAE;EACrD,MAAM;IAAEC,oBAAA;IAAsBC,aAAA;IAAeC,gBAAA;IAAkBC,SAAA;IAAWC,uBAAA;IAAyBC;EAAK,CAAE,GAAGN,OAAA;EAE7G,OAAOJ,SAAA,CAAU;IACf,IAAIK,oBAAA,IAAwB;MAAEM,QAAA,EAAU;IAAoB,CAAC;IAC7D,IAAIL,aAAA,IAAiB;MACnBM,SAAA,EAAWN,aAAA,KAAkB;MAC7BO,OAAA,EAASZ,UAAA,CAAW;QAAEW,SAAA,EAAWN,aAAA,KAAkB;QAAOQ,QAAA,EAAU;MAAM;IAC5E,CAAC;IACD,IAAIL,uBAAA,IAA2B;MAAEM,OAAA,EAASZ,mBAAA,CAAoBM,uBAAA,EAAyBC,KAAA;IAAO,CAAC;IAC/F,IAAIH,gBAAA,IAAoB;MAAES,WAAA,EAAa,IAAI;MAAEL,QAAA,EAAUT,WAAA,CAAYM,SAAA,EAAWD,gBAAA;IAAkB,CAAC;EACnG;AACF"}
1
+ {"version":3,"sources":["shift.ts"],"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"],"names":["shift","baseShift","limitShift","getBoundary","toFloatingUIPadding","options","hasScrollableElement","disableTether","overflowBoundary","container","overflowBoundaryPadding","isRtl","boundary","crossAxis","limiter","mainAxis","padding","altBoundary"],"mappings":"AAAA,SAASA,SAASC,SAAS,EAAEC,UAAU,QAAQ,mBAAmB;AAElE,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,iBAAiB;AAUlE;;CAEC,GACD,OAAO,SAASJ,MAAMK,OAA+B,EAAE;IACrD,MAAM,EAAEC,qBAAoB,EAAEC,cAAa,EAAEC,iBAAgB,EAAEC,UAAS,EAAEC,wBAAuB,EAAEC,MAAK,EAAE,GAAGN;IAE7G,OAAOJ,UAAU;QACf,GAAIK,wBAAwB;YAAEM,UAAU;QAAoB,CAAC;QAC7D,GAAIL,iBAAiB;YACnBM,WAAWN,kBAAkB;YAC7BO,SAASZ,WAAW;gBAAEW,WAAWN,kBAAkB;gBAAOQ,UAAU,KAAK;YAAC;QAC5E,CAAC;QACD,GAAIL,2BAA2B;YAAEM,SAASZ,oBAAoBM,yBAAyBC;QAAO,CAAC;QAC/F,GAAIH,oBAAoB;YAAES,aAAa,IAAI;YAAEL,UAAUT,YAAYM,WAAWD;QAAkB,CAAC;IACnG;AACF,CAAC"}
package/lib/types.js CHANGED
@@ -1,2 +1 @@
1
1
  import * as React from 'react';
2
- //# sourceMappingURL=types.js.map
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["React"],"sources":["../src/types.ts"],"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"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
1
+ {"version":3,"sources":["types.ts"],"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 /**\n * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\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 | 'useTransform'\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"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}