@fluentui/react-positioning 9.1.1 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. package/CHANGELOG.json +72 -2
  2. package/CHANGELOG.md +28 -3
  3. package/dist/index.d.ts +9 -16
  4. package/lib/constants.js +5 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/middleware/coverTarget.js +40 -0
  7. package/lib/middleware/coverTarget.js.map +1 -0
  8. package/lib/middleware/flip.js +19 -0
  9. package/lib/middleware/flip.js.map +1 -0
  10. package/lib/middleware/index.js +7 -0
  11. package/lib/middleware/index.js.map +1 -0
  12. package/lib/middleware/intersecting.js +21 -0
  13. package/lib/middleware/intersecting.js.map +1 -0
  14. package/lib/middleware/maxSize.js +43 -0
  15. package/lib/middleware/maxSize.js.map +1 -0
  16. package/lib/middleware/offset.js +11 -0
  17. package/lib/middleware/offset.js.map +1 -0
  18. package/lib/middleware/shift.js +30 -0
  19. package/lib/middleware/shift.js.map +1 -0
  20. package/lib/usePositioning.js +234 -336
  21. package/lib/usePositioning.js.map +1 -1
  22. package/lib/utils/debounce.js +22 -0
  23. package/lib/utils/debounce.js.map +1 -0
  24. package/lib/utils/fromFloatingUIPlacement.js +43 -0
  25. package/lib/utils/fromFloatingUIPlacement.js.map +1 -0
  26. package/lib/utils/getBoundary.js +5 -1
  27. package/lib/utils/getBoundary.js.map +1 -1
  28. package/lib/utils/getFloatingUIOffset.js +36 -0
  29. package/lib/utils/getFloatingUIOffset.js.map +1 -0
  30. package/lib/utils/getScrollParent.js +6 -0
  31. package/lib/utils/getScrollParent.js.map +1 -1
  32. package/lib/utils/hasAutoFocusFilter.js +28 -0
  33. package/lib/utils/hasAutoFocusFilter.js.map +1 -0
  34. package/lib/utils/index.js +6 -2
  35. package/lib/utils/index.js.map +1 -1
  36. package/lib/utils/mergeArrowOffset.js +1 -1
  37. package/lib/utils/mergeArrowOffset.js.map +1 -1
  38. package/lib/utils/parseFloatingUIPlacement.js +14 -0
  39. package/lib/utils/parseFloatingUIPlacement.js.map +1 -0
  40. package/lib/utils/toFloatingUIPlacement.js +40 -0
  41. package/lib/utils/toFloatingUIPlacement.js.map +1 -0
  42. package/lib/utils/toggleScrollListener.js +24 -0
  43. package/lib/utils/toggleScrollListener.js.map +1 -0
  44. package/lib-commonjs/constants.js +11 -0
  45. package/lib-commonjs/constants.js.map +1 -0
  46. package/lib-commonjs/middleware/coverTarget.js +50 -0
  47. package/lib-commonjs/middleware/coverTarget.js.map +1 -0
  48. package/lib-commonjs/middleware/flip.js +30 -0
  49. package/lib-commonjs/middleware/flip.js.map +1 -0
  50. package/lib-commonjs/middleware/index.js +20 -0
  51. package/lib-commonjs/middleware/index.js.map +1 -0
  52. package/lib-commonjs/middleware/intersecting.js +31 -0
  53. package/lib-commonjs/middleware/intersecting.js.map +1 -0
  54. package/lib-commonjs/middleware/maxSize.js +54 -0
  55. package/lib-commonjs/middleware/maxSize.js.map +1 -0
  56. package/lib-commonjs/middleware/offset.js +22 -0
  57. package/lib-commonjs/middleware/offset.js.map +1 -0
  58. package/lib-commonjs/middleware/shift.js +41 -0
  59. package/lib-commonjs/middleware/shift.js.map +1 -0
  60. package/lib-commonjs/usePositioning.js +236 -337
  61. package/lib-commonjs/usePositioning.js.map +1 -1
  62. package/lib-commonjs/utils/debounce.js +31 -0
  63. package/lib-commonjs/utils/debounce.js.map +1 -0
  64. package/lib-commonjs/utils/fromFloatingUIPlacement.js +52 -0
  65. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -0
  66. package/lib-commonjs/utils/getBoundary.js +5 -1
  67. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  68. package/lib-commonjs/utils/getFloatingUIOffset.js +46 -0
  69. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -0
  70. package/lib-commonjs/utils/getScrollParent.js +10 -1
  71. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  72. package/lib-commonjs/utils/hasAutoFocusFilter.js +37 -0
  73. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -0
  74. package/lib-commonjs/utils/index.js +10 -2
  75. package/lib-commonjs/utils/index.js.map +1 -1
  76. package/lib-commonjs/utils/mergeArrowOffset.js +1 -1
  77. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  78. package/lib-commonjs/utils/parseFloatingUIPlacement.js +23 -0
  79. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -0
  80. package/lib-commonjs/utils/toFloatingUIPlacement.js +49 -0
  81. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -0
  82. package/lib-commonjs/utils/toggleScrollListener.js +34 -0
  83. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -0
  84. package/package.json +7 -7
  85. package/dist/tsdoc-metadata.json +0 -11
  86. package/lib/isIntersectingModifier.js +0 -26
  87. package/lib/isIntersectingModifier.js.map +0 -1
  88. package/lib/utils/fromPopperPlacement.js +0 -40
  89. package/lib/utils/fromPopperPlacement.js.map +0 -1
  90. package/lib/utils/getPopperOffset.js +0 -44
  91. package/lib/utils/getPopperOffset.js.map +0 -1
  92. package/lib/utils/parsePopperPlacement.js +0 -14
  93. package/lib/utils/parsePopperPlacement.js.map +0 -1
  94. package/lib/utils/positioningHelper.js +0 -49
  95. package/lib/utils/positioningHelper.js.map +0 -1
  96. package/lib-commonjs/isIntersectingModifier.js +0 -34
  97. package/lib-commonjs/isIntersectingModifier.js.map +0 -1
  98. package/lib-commonjs/utils/fromPopperPlacement.js +0 -50
  99. package/lib-commonjs/utils/fromPopperPlacement.js.map +0 -1
  100. package/lib-commonjs/utils/getPopperOffset.js +0 -54
  101. package/lib-commonjs/utils/getPopperOffset.js.map +0 -1
  102. package/lib-commonjs/utils/parsePopperPlacement.js +0 -23
  103. package/lib-commonjs/utils/parsePopperPlacement.js.map +0 -1
  104. package/lib-commonjs/utils/positioningHelper.js +0 -61
  105. package/lib-commonjs/utils/positioningHelper.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -2,7 +2,77 @@
2
2
  "name": "@fluentui/react-positioning",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 14 Jul 2022 21:18:37 GMT",
5
+ "date": "Thu, 15 Sep 2022 09:44:38 GMT",
6
+ "tag": "@fluentui/react-positioning_v9.2.0",
7
+ "version": "9.2.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "lingfangao@hotmail.com",
12
+ "package": "@fluentui/react-positioning",
13
+ "commit": "4ba03b2e704668cb253f8ad16e8995a8a44b3d22",
14
+ "comment": "feat: Upgrade to Floating UI v1"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-positioning",
19
+ "comment": "Bump @fluentui/react-shared-contexts to v9.0.1",
20
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-positioning",
25
+ "comment": "Bump @fluentui/react-theme to v9.1.0",
26
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-positioning",
31
+ "comment": "Bump @fluentui/react-utilities to v9.1.0",
32
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
33
+ }
34
+ ],
35
+ "none": [
36
+ {
37
+ "author": "martinhochel@microsoft.com",
38
+ "package": "@fluentui/react-positioning",
39
+ "commit": "16aa65dcae8f75c6a221225fd0eb43800650ac66",
40
+ "comment": "docs: re-generate api.md files"
41
+ },
42
+ {
43
+ "author": "martinhochel@microsoft.com",
44
+ "package": "@fluentui/react-positioning",
45
+ "commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
46
+ "comment": "chore: update package scaffold"
47
+ }
48
+ ],
49
+ "patch": [
50
+ {
51
+ "author": "olfedias@microsoft.com",
52
+ "package": "@fluentui/react-positioning",
53
+ "commit": "e610024474cfe5d45f61501a8b6a21daf4c794a2",
54
+ "comment": "chore: Update Griffel to latest version"
55
+ }
56
+ ]
57
+ }
58
+ },
59
+ {
60
+ "date": "Wed, 03 Aug 2022 16:03:56 GMT",
61
+ "tag": "@fluentui/react-positioning_v9.1.2",
62
+ "version": "9.1.2",
63
+ "comments": {
64
+ "patch": [
65
+ {
66
+ "author": "miroslav.stastny@microsoft.com",
67
+ "package": "@fluentui/react-positioning",
68
+ "commit": "08563664778fd80284561d3c9d254307a0a32362",
69
+ "comment": "chore: Bump Griffel dependencies"
70
+ }
71
+ ]
72
+ }
73
+ },
74
+ {
75
+ "date": "Thu, 14 Jul 2022 21:21:02 GMT",
6
76
  "tag": "@fluentui/react-positioning_v9.1.1",
7
77
  "version": "9.1.1",
8
78
  "comments": {
@@ -17,7 +87,7 @@
17
87
  "author": "beachball",
18
88
  "package": "@fluentui/react-positioning",
19
89
  "comment": "Bump @fluentui/react-utilities to v9.0.2",
20
- "commit": "802bc4e3730a88b0fc61b5bf42ef7fc6b6543fe2"
90
+ "commit": "79b513146194367544160f364b0a7dd749ed93e4"
21
91
  }
22
92
  ]
23
93
  }
package/CHANGELOG.md CHANGED
@@ -1,18 +1,43 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Thu, 14 Jul 2022 21:18:37 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 15 Sep 2022 09:44:38 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.2.0)
8
+
9
+ Thu, 15 Sep 2022 09:44:38 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.2..@fluentui/react-positioning_v9.2.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: Upgrade to Floating UI v1 ([PR #24254](https://github.com/microsoft/fluentui/pull/24254) by lingfangao@hotmail.com)
15
+ - Bump @fluentui/react-shared-contexts to v9.0.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
16
+ - Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
17
+ - Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
18
+
19
+ ### Patches
20
+
21
+ - chore: Update Griffel to latest version ([PR #24221](https://github.com/microsoft/fluentui/pull/24221) by olfedias@microsoft.com)
22
+
23
+ ## [9.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.1.2)
24
+
25
+ Wed, 03 Aug 2022 16:03:56 GMT
26
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.1..@fluentui/react-positioning_v9.1.2)
27
+
28
+ ### Patches
29
+
30
+ - chore: Bump Griffel dependencies ([PR #24114](https://github.com/microsoft/fluentui/pull/24114) by miroslav.stastny@microsoft.com)
31
+
7
32
  ## [9.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.1.1)
8
33
 
9
- Thu, 14 Jul 2022 21:18:37 GMT
34
+ Thu, 14 Jul 2022 21:21:02 GMT
10
35
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.0..@fluentui/react-positioning_v9.1.1)
11
36
 
12
37
  ### Patches
13
38
 
14
39
  - fix: Fixing bad version bump of @fluentui/react-utilities. ([PR #23920](https://github.com/microsoft/fluentui/pull/23920) by Humberto.Morimoto@microsoft.com)
15
- - Bump @fluentui/react-utilities to v9.0.2 ([PR #23920](https://github.com/microsoft/fluentui/pull/23920) by beachball)
40
+ - Bump @fluentui/react-utilities to v9.0.2 ([PR #23918](https://github.com/microsoft/fluentui/pull/23918) by beachball)
16
41
 
17
42
  ## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.1.0)
18
43
 
package/dist/index.d.ts CHANGED
@@ -83,10 +83,10 @@ export declare type CreateArrowStylesOptions = {
83
83
  export declare function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement;
84
84
 
85
85
  /**
86
- * @internal
87
86
  * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
88
87
  * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
89
88
  *
89
+ * @internal
90
90
  * @param userOffset - The offset provided by the user
91
91
  * @param arrowHeight - The height of the arrow in px
92
92
  * @returns User offset augmented with arrow height
@@ -216,24 +216,10 @@ declare type Rect = {
216
216
 
217
217
  export declare function resolvePositioningShorthand(shorthand: PositioningShorthand | undefined | null): Readonly<PositioningProps>;
218
218
 
219
- declare interface UsePopperOptions extends PositioningProps {
220
- /**
221
- * If false, delays Popper's creation.
222
- * @default true
223
- */
224
- enabled?: boolean;
225
- }
226
-
227
219
  /**
228
220
  * @internal
229
- * Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
230
- * package:
231
- * - style attributes are applied directly on DOM to avoid re-renders
232
- * - refs changes and resolution is handled properly without re-renders
233
- * - contains a specific to React fix related to initial positioning when containers have components with managed focus
234
- * to avoid focus jumps
235
221
  */
236
- export declare function usePositioning(options?: UsePopperOptions): {
222
+ export declare function usePositioning(options: UsePositioningOptions): {
237
223
  targetRef: React_2.MutableRefObject<any>;
238
224
  containerRef: React_2.MutableRefObject<any>;
239
225
  arrowRef: React_2.MutableRefObject<any>;
@@ -250,4 +236,11 @@ export declare function usePositioning(options?: UsePopperOptions): {
250
236
  */
251
237
  export declare const usePositioningMouseTarget: (initialState?: PositioningVirtualElement | (() => PositioningVirtualElement) | undefined) => readonly [PositioningVirtualElement | undefined, (event: React_2.MouseEvent | MouseEvent | undefined | null) => void];
252
238
 
239
+ declare interface UsePositioningOptions extends PositioningProps {
240
+ /**
241
+ * If false, does not position anything
242
+ */
243
+ enabled?: boolean;
244
+ }
245
+
253
246
  export { }
@@ -0,0 +1,5 @@
1
+ export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';
2
+ export const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
3
+ export const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
4
+ export const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"../src/","sources":["constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,6BAA6B,CAAC;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AACtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC","sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n"]}
@@ -0,0 +1,40 @@
1
+ import { parseFloatingUIPlacement } from '../utils/index';
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
+
18
+ switch (basePlacement) {
19
+ case 'bottom':
20
+ newCoords.y -= rects.reference.height;
21
+ break;
22
+
23
+ case 'top':
24
+ newCoords.y += rects.reference.height;
25
+ break;
26
+
27
+ case 'left':
28
+ newCoords.x += rects.reference.width;
29
+ break;
30
+
31
+ case 'right':
32
+ newCoords.x -= rects.reference.width;
33
+ break;
34
+ }
35
+
36
+ return newCoords;
37
+ }
38
+ };
39
+ }
40
+ //# sourceMappingURL=coverTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/coverTarget.ts"],"names":[],"mappings":"AACA,SAAS,wBAAT,QAAyC,gBAAzC;AAEA,OAAM,SAAU,WAAV,GAAqB;EACzB,OAAO;IACL,IAAI,EAAE,aADD;IAEL,EAAE,EAAE,mBAAmB,IAAG;MACxB,MAAM;QAAE,SAAF;QAAa,KAAb;QAAoB,CAApB;QAAuB;MAAvB,IAA6B,mBAAnC;MACA,MAAM,aAAa,GAAG,wBAAwB,CAAC,SAAD,CAAxB,CAAoC,IAA1D;MACA,MAAM,SAAS,GAAG;QAAE,CAAF;QAAK;MAAL,CAAlB;;MAEA,QAAQ,aAAR;QACE,KAAK,QAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,KAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,MAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;;QACF,KAAK,OAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;MAZJ;;MAeA,OAAO,SAAP;IACD;EAvBI,CAAP;AAyBD","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"],"sourceRoot":"../src/"}
@@ -0,0 +1,19 @@
1
+ import { flip as baseFlip } from '@floating-ui/dom';
2
+ import { getBoundary } from '../utils/index';
3
+ export function flip(options) {
4
+ const {
5
+ hasScrollableElement,
6
+ flipBoundary,
7
+ container
8
+ } = options;
9
+ return baseFlip({ ...(hasScrollableElement && {
10
+ boundary: 'clippingAncestors'
11
+ }),
12
+ ...(flipBoundary && {
13
+ altBoundary: true,
14
+ boundary: getBoundary(container, flipBoundary)
15
+ }),
16
+ fallbackStrategy: 'bestFit'
17
+ });
18
+ }
19
+ //# sourceMappingURL=flip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/flip.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,IAAI,QAAjB,QAAiC,kBAAjC;AAEA,SAAS,WAAT,QAA4B,gBAA5B;AAOA,OAAM,SAAU,IAAV,CAAe,OAAf,EAA6C;EACjD,MAAM;IAAE,oBAAF;IAAwB,YAAxB;IAAsC;EAAtC,IAAoD,OAA1D;EAEA,OAAO,QAAQ,CAAC,EACd,IAAI,oBAAoB,IAAI;MAAE,QAAQ,EAAE;IAAZ,CAA5B,CADc;IAEd,IAAI,YAAY,IAAI;MAAE,WAAW,EAAE,IAAf;MAAqB,QAAQ,EAAE,WAAW,CAAC,SAAD,EAAY,YAAZ;IAA1C,CAApB,CAFc;IAGd,gBAAgB,EAAE;EAHJ,CAAD,CAAf;AAKD","sourcesContent":["import { flip as baseFlip } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/index';\n\nexport interface FlipMiddlewareOptions extends Pick<PositioningOptions, 'flipBoundary'> {\n hasScrollableElement?: boolean;\n container: HTMLElement | null;\n}\n\nexport function flip(options: FlipMiddlewareOptions) {\n const { hasScrollableElement, flipBoundary, container } = options;\n\n return baseFlip({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(flipBoundary && { altBoundary: true, boundary: getBoundary(container, flipBoundary) }),\n fallbackStrategy: 'bestFit',\n });\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,7 @@
1
+ export * from './coverTarget';
2
+ export * from './flip';
3
+ export * from './intersecting';
4
+ export * from './maxSize';
5
+ export * from './offset';
6
+ export * from './shift';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC","sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"]}
@@ -0,0 +1,21 @@
1
+ import { detectOverflow } from '@floating-ui/dom';
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
16
+ }
17
+ };
18
+ }
19
+ };
20
+ }
21
+ //# sourceMappingURL=intersecting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/intersecting.ts"],"names":[],"mappings":"AACA,SAAS,cAAT,QAA+B,kBAA/B;AAEA,OAAM,SAAU,YAAV,GAAsB;EAC1B,OAAO;IACL,IAAI,EAAE,sBADD;IAEL,EAAE,EAAE,MAAM,mBAAN,IAA4B;MAC9B,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAApB,CAA0B,QAA/C;MACA,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,mBAAD,EAAsB;QAAE,WAAW,EAAE;MAAf,CAAtB,CAAxC;MAEA,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAZ,GAAkB,YAAY,CAAC,MAA/B,IAAyC,WAAW,CAAC,GAAZ,GAAkB,CAArF;MACA,MAAM,oBAAoB,GAAG,WAAW,CAAC,MAAZ,GAAqB,YAAY,CAAC,MAAlC,IAA4C,WAAW,CAAC,MAAZ,GAAqB,CAA9F;MAEA,MAAM,cAAc,GAAG,iBAAiB,IAAI,oBAA5C;MAEA,OAAO;QACL,IAAI,EAAE;UACJ,YAAY,EAAE;QADV;MADD,CAAP;IAKD;EAhBI,CAAP;AAkBD","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"],"sourceRoot":"../src/"}
@@ -0,0 +1,43 @@
1
+ import { detectOverflow } from '@floating-ui/dom';
2
+ import { parseFloatingUIPlacement } from '../utils/index';
3
+ export function maxSize(autoSize) {
4
+ return {
5
+ name: 'maxSize',
6
+ fn: async middlewareArguments => {
7
+ const {
8
+ placement,
9
+ rects,
10
+ elements,
11
+ middlewareData
12
+ } = middlewareArguments;
13
+ const basePlacement = parseFloatingUIPlacement(placement).side;
14
+ const overflow = await detectOverflow(middlewareArguments);
15
+ const {
16
+ x,
17
+ y
18
+ } = middlewareData.shift || {
19
+ x: 0,
20
+ y: 0
21
+ };
22
+ const {
23
+ width,
24
+ height
25
+ } = rects.floating;
26
+ const widthProp = basePlacement === 'left' ? 'left' : 'right';
27
+ const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
28
+ const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width');
29
+ const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height');
30
+
31
+ if (applyMaxWidth) {
32
+ elements.floating.style.maxWidth = `${width - overflow[widthProp] - x}px`;
33
+ }
34
+
35
+ if (applyMaxHeight) {
36
+ elements.floating.style.maxHeight = `${height - overflow[heightProp] - y}px`;
37
+ }
38
+
39
+ return {};
40
+ }
41
+ };
42
+ }
43
+ //# sourceMappingURL=maxSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/maxSize.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,kBAA/B;AAGA,SAAS,wBAAT,QAAyC,gBAAzC;AAEA,OAAM,SAAU,OAAV,CAAkB,QAAlB,EAA0D;EAC9D,OAAO;IACL,IAAI,EAAE,SADD;IAEL,EAAE,EAAE,MAAM,mBAAN,IAA4B;MAC9B,MAAM;QAAE,SAAF;QAAa,KAAb;QAAoB,QAApB;QAA8B;MAA9B,IAAiD,mBAAvD;MACA,MAAM,aAAa,GAAG,wBAAwB,CAAC,SAAD,CAAxB,CAAoC,IAA1D;MAEA,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,mBAAD,CAArC;MACA,MAAM;QAAE,CAAF;QAAK;MAAL,IAAW,cAAc,CAAC,KAAf,IAAwB;QAAE,CAAC,EAAE,CAAL;QAAQ,CAAC,EAAE;MAAX,CAAzC;MACA,MAAM;QAAE,KAAF;QAAS;MAAT,IAAoB,KAAK,CAAC,QAAhC;MAEA,MAAM,SAAS,GAAS,aAAa,KAAK,MAAlB,GAA2B,MAA3B,GAAoC,OAA5D;MACA,MAAM,UAAU,GAAS,aAAa,KAAK,KAAlB,GAA0B,KAA1B,GAAkC,QAA3D;MAEA,MAAM,aAAa,GACjB,QAAQ,KAAK,QAAb,IACA,QAAQ,KAAK,cADb,IAEC,QAAQ,CAAC,SAAD,CAAR,GAAsB,CAAtB,KAA4B,QAAQ,KAAK,IAAb,IAAqB,QAAQ,KAAK,OAA9D,CAHH;MAIA,MAAM,cAAc,GAClB,QAAQ,KAAK,QAAb,IACA,QAAQ,KAAK,eADb,IAEC,QAAQ,CAAC,UAAD,CAAR,GAAuB,CAAvB,KAA6B,QAAQ,KAAK,IAAb,IAAqB,QAAQ,KAAK,QAA/D,CAHH;;MAKA,IAAI,aAAJ,EAAmB;QACjB,QAAQ,CAAC,QAAT,CAAkB,KAAlB,CAAwB,QAAxB,GAAmC,GAAG,KAAK,GAAG,QAAQ,CAAC,SAAD,CAAhB,GAA8B,CAAC,IAArE;MACD;;MACD,IAAI,cAAJ,EAAoB;QAClB,QAAQ,CAAC,QAAT,CAAkB,KAAlB,CAAwB,SAAxB,GAAoC,GAAG,MAAM,GAAG,QAAQ,CAAC,UAAD,CAAjB,GAAgC,CAAC,IAAxE;MACD;;MAED,OAAO,EAAP;IACD;EA9BI,CAAP;AAgCD","sourcesContent":["import { detectOverflow } from '@floating-ui/dom';\nimport type { Middleware, Side } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function maxSize(autoSize: PositioningOptions['autoSize']): Middleware {\n return {\n name: 'maxSize',\n fn: async middlewareArguments => {\n const { placement, rects, elements, middlewareData } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n\n const overflow = await detectOverflow(middlewareArguments);\n const { x, y } = middlewareData.shift || { x: 0, y: 0 };\n const { width, height } = rects.floating;\n\n const widthProp: Side = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: Side = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n elements.floating.style.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\n elements.floating.style.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n\n return {};\n },\n };\n}\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,11 @@
1
+ import { offset as baseOffset } from '@floating-ui/dom';
2
+ import { getFloatingUIOffset } from '../utils/getFloatingUIOffset';
3
+ /**
4
+ * Wraps floating UI offset middleware to to transform offset value
5
+ */
6
+
7
+ export function offset(offsetValue) {
8
+ const floatingUIOffset = getFloatingUIOffset(offsetValue);
9
+ return baseOffset(floatingUIOffset);
10
+ }
11
+ //# sourceMappingURL=offset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/offset.ts"],"names":[],"mappings":"AAAA,SAAS,MAAM,IAAI,UAAnB,QAAqC,kBAArC;AAEA,SAAS,mBAAT,QAAoC,8BAApC;AAEA;;AAEG;;AACH,OAAM,SAAU,MAAV,CAAiB,WAAjB,EAA0D;EAC9D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAD,CAA5C;EACA,OAAO,UAAU,CAAC,gBAAD,CAAjB;AACD","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"],"sourceRoot":"../src/"}
@@ -0,0 +1,30 @@
1
+ import { shift as baseShift, limitShift } from '@floating-ui/dom';
2
+ import { getBoundary } from '../utils/index';
3
+ /**
4
+ * Wraps the floating UI shift middleware for easier usage of our options
5
+ */
6
+
7
+ export function shift(options) {
8
+ const {
9
+ hasScrollableElement,
10
+ disableTether,
11
+ overflowBoundary,
12
+ container
13
+ } = options;
14
+ return baseShift({ ...(hasScrollableElement && {
15
+ boundary: 'clippingAncestors'
16
+ }),
17
+ ...(disableTether && {
18
+ crossAxis: disableTether === 'all',
19
+ limiter: limitShift({
20
+ crossAxis: disableTether !== 'all',
21
+ mainAxis: false
22
+ })
23
+ }),
24
+ ...(overflowBoundary && {
25
+ altBoundary: true,
26
+ boundary: getBoundary(container, overflowBoundary)
27
+ })
28
+ });
29
+ }
30
+ //# sourceMappingURL=shift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["middleware/shift.ts"],"names":[],"mappings":"AAAA,SAAS,KAAK,IAAI,SAAlB,EAA6B,UAA7B,QAA+C,kBAA/C;AAEA,SAAS,WAAT,QAA4B,gBAA5B;AAQA;;AAEG;;AACH,OAAM,SAAU,KAAV,CAAgB,OAAhB,EAA+C;EACnD,MAAM;IAAE,oBAAF;IAAwB,aAAxB;IAAuC,gBAAvC;IAAyD;EAAzD,IAAuE,OAA7E;EAEA,OAAO,SAAS,CAAC,EACf,IAAI,oBAAoB,IAAI;MAAE,QAAQ,EAAE;IAAZ,CAA5B,CADe;IAEf,IAAI,aAAa,IAAI;MACnB,SAAS,EAAE,aAAa,KAAK,KADV;MAEnB,OAAO,EAAE,UAAU,CAAC;QAAE,SAAS,EAAE,aAAa,KAAK,KAA/B;QAAsC,QAAQ,EAAE;MAAhD,CAAD;IAFA,CAArB,CAFe;IAMf,IAAI,gBAAgB,IAAI;MAAE,WAAW,EAAE,IAAf;MAAqB,QAAQ,EAAE,WAAW,CAAC,SAAD,EAAY,gBAAZ;IAA1C,CAAxB;EANe,CAAD,CAAhB;AAQD","sourcesContent":["import { shift as baseShift, limitShift } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/index';\n\nexport interface ShiftMiddlewareOptions extends Pick<PositioningOptions, 'overflowBoundary'> {\n hasScrollableElement?: boolean;\n disableTether?: PositioningOptions['unstable_disableTether'];\n container: HTMLElement | null;\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 } = 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 ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n });\n}\n"],"sourceRoot":"../src/"}