@fluentui/react-positioning 9.1.2 → 9.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +83 -1
- package/CHANGELOG.md +29 -2
- package/dist/index.d.ts +9 -16
- package/lib/constants.js +5 -0
- package/lib/constants.js.map +1 -0
- package/lib/middleware/coverTarget.js +40 -0
- package/lib/middleware/coverTarget.js.map +1 -0
- package/lib/middleware/flip.js +19 -0
- package/lib/middleware/flip.js.map +1 -0
- package/lib/middleware/index.js +7 -0
- package/lib/middleware/index.js.map +1 -0
- package/lib/middleware/intersecting.js +21 -0
- package/lib/middleware/intersecting.js.map +1 -0
- package/lib/middleware/maxSize.js +43 -0
- package/lib/middleware/maxSize.js.map +1 -0
- package/lib/middleware/offset.js +11 -0
- package/lib/middleware/offset.js.map +1 -0
- package/lib/middleware/shift.js +30 -0
- package/lib/middleware/shift.js.map +1 -0
- package/lib/usePositioning.js +237 -339
- package/lib/usePositioning.js.map +1 -1
- package/lib/utils/debounce.js +22 -0
- package/lib/utils/debounce.js.map +1 -0
- package/lib/utils/fromFloatingUIPlacement.js +43 -0
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -0
- package/lib/utils/getBoundary.js +5 -1
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js +36 -0
- package/lib/utils/getFloatingUIOffset.js.map +1 -0
- package/lib/utils/getScrollParent.js +6 -0
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +28 -0
- package/lib/utils/hasAutoFocusFilter.js.map +1 -0
- package/lib/utils/index.js +6 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +1 -1
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +14 -0
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -0
- package/lib/utils/toFloatingUIPlacement.js +40 -0
- package/lib/utils/toFloatingUIPlacement.js.map +1 -0
- package/lib/utils/toggleScrollListener.js +24 -0
- package/lib/utils/toggleScrollListener.js.map +1 -0
- package/lib-commonjs/constants.js +11 -0
- package/lib-commonjs/constants.js.map +1 -0
- package/lib-commonjs/middleware/coverTarget.js +50 -0
- package/lib-commonjs/middleware/coverTarget.js.map +1 -0
- package/lib-commonjs/middleware/flip.js +30 -0
- package/lib-commonjs/middleware/flip.js.map +1 -0
- package/lib-commonjs/middleware/index.js +20 -0
- package/lib-commonjs/middleware/index.js.map +1 -0
- package/lib-commonjs/middleware/intersecting.js +31 -0
- package/lib-commonjs/middleware/intersecting.js.map +1 -0
- package/lib-commonjs/middleware/maxSize.js +54 -0
- package/lib-commonjs/middleware/maxSize.js.map +1 -0
- package/lib-commonjs/middleware/offset.js +22 -0
- package/lib-commonjs/middleware/offset.js.map +1 -0
- package/lib-commonjs/middleware/shift.js +41 -0
- package/lib-commonjs/middleware/shift.js.map +1 -0
- package/lib-commonjs/usePositioning.js +239 -340
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +31 -0
- package/lib-commonjs/utils/debounce.js.map +1 -0
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +52 -0
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -0
- package/lib-commonjs/utils/getBoundary.js +5 -1
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +46 -0
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -0
- package/lib-commonjs/utils/getScrollParent.js +10 -1
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +37 -0
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -0
- package/lib-commonjs/utils/index.js +10 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +23 -0
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -0
- package/lib-commonjs/utils/toFloatingUIPlacement.js +49 -0
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -0
- package/lib-commonjs/utils/toggleScrollListener.js +34 -0
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -0
- package/package.json +7 -7
- package/dist/tsdoc-metadata.json +0 -11
- package/lib/isIntersectingModifier.js +0 -26
- package/lib/isIntersectingModifier.js.map +0 -1
- package/lib/utils/fromPopperPlacement.js +0 -40
- package/lib/utils/fromPopperPlacement.js.map +0 -1
- package/lib/utils/getPopperOffset.js +0 -44
- package/lib/utils/getPopperOffset.js.map +0 -1
- package/lib/utils/parsePopperPlacement.js +0 -14
- package/lib/utils/parsePopperPlacement.js.map +0 -1
- package/lib/utils/positioningHelper.js +0 -49
- package/lib/utils/positioningHelper.js.map +0 -1
- package/lib-commonjs/isIntersectingModifier.js +0 -34
- package/lib-commonjs/isIntersectingModifier.js.map +0 -1
- package/lib-commonjs/utils/fromPopperPlacement.js +0 -50
- package/lib-commonjs/utils/fromPopperPlacement.js.map +0 -1
- package/lib-commonjs/utils/getPopperOffset.js +0 -54
- package/lib-commonjs/utils/getPopperOffset.js.map +0 -1
- package/lib-commonjs/utils/parsePopperPlacement.js +0 -23
- package/lib-commonjs/utils/parsePopperPlacement.js.map +0 -1
- package/lib-commonjs/utils/positioningHelper.js +0 -61
- package/lib-commonjs/utils/positioningHelper.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,89 @@
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Thu, 13 Oct 2022 10:59:34 GMT",
|
6
|
+
"tag": "@fluentui/react-positioning_v9.2.1",
|
7
|
+
"version": "9.2.1",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "olfedias@microsoft.com",
|
12
|
+
"package": "@fluentui/react-positioning",
|
13
|
+
"commit": "1a527d440e0497ef8046b3ce240492241e7a04ac",
|
14
|
+
"comment": "chore: Update Griffel to latest version"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "yuanboxue@microsoft.com",
|
18
|
+
"package": "@fluentui/react-positioning",
|
19
|
+
"commit": "16c7bcadf6f5a1f66dd8224f014ceee4c4800be3",
|
20
|
+
"comment": "fix `usePositioning` to reset `overrideTargetRef` when target in hook options is undefined"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-positioning",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.1",
|
26
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Thu, 15 Sep 2022 09:49:16 GMT",
|
33
|
+
"tag": "@fluentui/react-positioning_v9.2.0",
|
34
|
+
"version": "9.2.0",
|
35
|
+
"comments": {
|
36
|
+
"minor": [
|
37
|
+
{
|
38
|
+
"author": "lingfangao@hotmail.com",
|
39
|
+
"package": "@fluentui/react-positioning",
|
40
|
+
"commit": "4ba03b2e704668cb253f8ad16e8995a8a44b3d22",
|
41
|
+
"comment": "feat: Upgrade to Floating UI v1"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "beachball",
|
45
|
+
"package": "@fluentui/react-positioning",
|
46
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.1",
|
47
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "beachball",
|
51
|
+
"package": "@fluentui/react-positioning",
|
52
|
+
"comment": "Bump @fluentui/react-theme to v9.1.0",
|
53
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"author": "beachball",
|
57
|
+
"package": "@fluentui/react-positioning",
|
58
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.0",
|
59
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"none": [
|
63
|
+
{
|
64
|
+
"author": "martinhochel@microsoft.com",
|
65
|
+
"package": "@fluentui/react-positioning",
|
66
|
+
"commit": "16aa65dcae8f75c6a221225fd0eb43800650ac66",
|
67
|
+
"comment": "docs: re-generate api.md files"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"author": "martinhochel@microsoft.com",
|
71
|
+
"package": "@fluentui/react-positioning",
|
72
|
+
"commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
|
73
|
+
"comment": "chore: update package scaffold"
|
74
|
+
}
|
75
|
+
],
|
76
|
+
"patch": [
|
77
|
+
{
|
78
|
+
"author": "olfedias@microsoft.com",
|
79
|
+
"package": "@fluentui/react-positioning",
|
80
|
+
"commit": "e610024474cfe5d45f61501a8b6a21daf4c794a2",
|
81
|
+
"comment": "chore: Update Griffel to latest version"
|
82
|
+
}
|
83
|
+
]
|
84
|
+
}
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"date": "Wed, 03 Aug 2022 16:03:56 GMT",
|
6
88
|
"tag": "@fluentui/react-positioning_v9.1.2",
|
7
89
|
"version": "9.1.2",
|
8
90
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,39 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 13 Oct 2022 10:59:34 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.2.1)
|
8
|
+
|
9
|
+
Thu, 13 Oct 2022 10:59:34 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.2.0..@fluentui/react-positioning_v9.2.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: Update Griffel to latest version ([PR #25075](https://github.com/microsoft/fluentui/pull/25075) by olfedias@microsoft.com)
|
15
|
+
- fix `usePositioning` to reset `overrideTargetRef` when target in hook options is undefined ([PR #25135](https://github.com/microsoft/fluentui/pull/25135) by yuanboxue@microsoft.com)
|
16
|
+
- Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
17
|
+
|
18
|
+
## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.2.0)
|
19
|
+
|
20
|
+
Thu, 15 Sep 2022 09:49:16 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.2..@fluentui/react-positioning_v9.2.0)
|
22
|
+
|
23
|
+
### Minor changes
|
24
|
+
|
25
|
+
- feat: Upgrade to Floating UI v1 ([PR #24254](https://github.com/microsoft/fluentui/pull/24254) by lingfangao@hotmail.com)
|
26
|
+
- Bump @fluentui/react-shared-contexts to v9.0.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
27
|
+
- Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
28
|
+
- Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
29
|
+
|
30
|
+
### Patches
|
31
|
+
|
32
|
+
- chore: Update Griffel to latest version ([PR #24221](https://github.com/microsoft/fluentui/pull/24221) by olfedias@microsoft.com)
|
33
|
+
|
7
34
|
## [9.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.1.2)
|
8
35
|
|
9
|
-
Wed, 03 Aug 2022 16:
|
36
|
+
Wed, 03 Aug 2022 16:03:56 GMT
|
10
37
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.1.1..@fluentui/react-positioning_v9.1.2)
|
11
38
|
|
12
39
|
### Patches
|
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
|
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 { }
|
package/lib/constants.js
ADDED
@@ -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 @@
|
|
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/"}
|