@fluentui/react-positioning 9.5.4 → 9.5.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +55 -1
- package/CHANGELOG.md +24 -2
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createVirtualElementFromClick.js +1 -2
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/index.js.map +1 -1
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js +23 -21
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +1 -2
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +1 -0
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +5 -6
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +2 -2
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +3 -4
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +1 -2
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPadding.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +1 -2
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +4 -4
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js +18 -7
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +60 -88
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +103 -117
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js +27 -26
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +24 -51
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +34 -37
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +31 -38
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +10 -9
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +24 -22
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +34 -40
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +11 -12
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +29 -37
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js +5 -2
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +200 -164
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +34 -37
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +22 -21
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +30 -35
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +21 -22
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +23 -35
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +45 -41
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +52 -56
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +18 -17
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +19 -18
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +33 -32
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +15 -14
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +63 -61
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPadding.js +23 -25
- package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +31 -33
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +20 -24
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +39 -53
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +19 -24
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +37 -45
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +7 -6
- package/lib-amd/constants.js +0 -10
- package/lib-amd/constants.js.map +0 -1
- package/lib-amd/createArrowStyles.js +0 -62
- package/lib-amd/createArrowStyles.js.map +0 -1
- package/lib-amd/createPositionManager.js +0 -97
- package/lib-amd/createPositionManager.js.map +0 -1
- package/lib-amd/createVirtualElementFromClick.js +0 -32
- package/lib-amd/createVirtualElementFromClick.js.map +0 -1
- package/lib-amd/index.js +0 -13
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/middleware/coverTarget.js +0 -32
- package/lib-amd/middleware/coverTarget.js.map +0 -1
- package/lib-amd/middleware/flip.js +0 -19
- package/lib-amd/middleware/flip.js.map +0 -1
- package/lib-amd/middleware/index.js +0 -11
- package/lib-amd/middleware/index.js.map +0 -1
- package/lib-amd/middleware/intersecting.js +0 -33
- package/lib-amd/middleware/intersecting.js.map +0 -1
- package/lib-amd/middleware/maxSize.js +0 -33
- package/lib-amd/middleware/maxSize.js.map +0 -1
- package/lib-amd/middleware/offset.js +0 -14
- package/lib-amd/middleware/offset.js.map +0 -1
- package/lib-amd/middleware/shift.js +0 -17
- package/lib-amd/middleware/shift.js.map +0 -1
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
- package/lib-amd/usePositioning.js +0 -161
- package/lib-amd/usePositioning.js.map +0 -1
- package/lib-amd/usePositioningMouseTarget.js +0 -39
- package/lib-amd/usePositioningMouseTarget.js.map +0 -1
- package/lib-amd/utils/debounce.js +0 -27
- package/lib-amd/utils/debounce.js.map +0 -1
- package/lib-amd/utils/fromFloatingUIPlacement.js +0 -37
- package/lib-amd/utils/fromFloatingUIPlacement.js.map +0 -1
- package/lib-amd/utils/getBoundary.js +0 -26
- package/lib-amd/utils/getBoundary.js.map +0 -1
- package/lib-amd/utils/getFloatingUIOffset.js +0 -25
- package/lib-amd/utils/getFloatingUIOffset.js.map +0 -1
- package/lib-amd/utils/getReactFiberFromNode.js +0 -48
- package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
- package/lib-amd/utils/getScrollParent.js +0 -64
- package/lib-amd/utils/getScrollParent.js.map +0 -1
- package/lib-amd/utils/hasAutoFocusFilter.js +0 -31
- package/lib-amd/utils/hasAutoFocusFilter.js.map +0 -1
- package/lib-amd/utils/index.js +0 -20
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/mergeArrowOffset.js +0 -38
- package/lib-amd/utils/mergeArrowOffset.js.map +0 -1
- package/lib-amd/utils/parseFloatingUIPlacement.js +0 -20
- package/lib-amd/utils/parseFloatingUIPlacement.js.map +0 -1
- package/lib-amd/utils/resolvePositioningShorthand.js +0 -31
- package/lib-amd/utils/resolvePositioningShorthand.js.map +0 -1
- package/lib-amd/utils/toFloatingUIPadding.js +0 -25
- package/lib-amd/utils/toFloatingUIPadding.js.map +0 -1
- package/lib-amd/utils/toFloatingUIPlacement.js +0 -40
- package/lib-amd/utils/toFloatingUIPlacement.js.map +0 -1
- package/lib-amd/utils/toggleScrollListener.js +0 -26
- package/lib-amd/utils/toggleScrollListener.js.map +0 -1
- package/lib-amd/utils/useCallbackRef.js +0 -55
- package/lib-amd/utils/useCallbackRef.js.map +0 -1
- package/lib-amd/utils/writeArrowUpdates.js +0 -21
- package/lib-amd/utils/writeArrowUpdates.js.map +0 -1
- package/lib-amd/utils/writeContainerupdates.js +0 -41
- package/lib-amd/utils/writeContainerupdates.js.map +0 -1
package/.swcrc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
+
"exclude": [
|
4
|
+
"/testing",
|
5
|
+
"/**/*.cy.ts",
|
6
|
+
"/**/*.cy.tsx",
|
7
|
+
"/**/*.spec.ts",
|
8
|
+
"/**/*.spec.tsx",
|
9
|
+
"/**/*.test.ts",
|
10
|
+
"/**/*.test.tsx"
|
11
|
+
],
|
12
|
+
"jsc": {
|
13
|
+
"parser": {
|
14
|
+
"syntax": "typescript",
|
15
|
+
"tsx": true,
|
16
|
+
"decorators": false,
|
17
|
+
"dynamicImport": false
|
18
|
+
},
|
19
|
+
"externalHelpers": true,
|
20
|
+
"transform": {
|
21
|
+
"react": {
|
22
|
+
"runtime": "classic",
|
23
|
+
"useSpread": true
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
27
|
+
},
|
28
|
+
"minify": false,
|
29
|
+
"sourceMaps": true
|
30
|
+
}
|
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,61 @@
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 21 Mar 2023 21:18:58 GMT",
|
6
|
+
"tag": "@fluentui/react-positioning_v9.5.6",
|
7
|
+
"version": "9.5.6",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "tristan.watanabe@gmail.com",
|
12
|
+
"package": "@fluentui/react-positioning",
|
13
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
14
|
+
"comment": "chore: migrate to swc transpilation approach."
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "tristan.watanabe@gmail.com",
|
18
|
+
"package": "@fluentui/react-positioning",
|
19
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
20
|
+
"comment": "fix: add node field to package.json exports map."
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-positioning",
|
25
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
26
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-positioning",
|
31
|
+
"comment": "Bump @fluentui/react-theme to v9.1.7",
|
32
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"author": "beachball",
|
36
|
+
"package": "@fluentui/react-positioning",
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
38
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"date": "Thu, 16 Mar 2023 14:36:59 GMT",
|
45
|
+
"tag": "@fluentui/react-positioning_v9.5.5",
|
46
|
+
"version": "9.5.5",
|
47
|
+
"comments": {
|
48
|
+
"patch": [
|
49
|
+
{
|
50
|
+
"author": "beachball",
|
51
|
+
"package": "@fluentui/react-positioning",
|
52
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.1",
|
53
|
+
"commit": "e7dcadf7cabae6bc6811ca04a630e7d850388f81"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"date": "Wed, 15 Mar 2023 10:19:53 GMT",
|
6
60
|
"tag": "@fluentui/react-positioning_v9.5.4",
|
7
61
|
"version": "9.5.4",
|
8
62
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 21 Mar 2023 21:18:58 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.5.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.5.6)
|
8
|
+
|
9
|
+
Tue, 21 Mar 2023 21:18:58 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.5..@fluentui/react-positioning_v9.5.6)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
15
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
16
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
17
|
+
- Bump @fluentui/react-theme to v9.1.7 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
19
|
+
|
20
|
+
## [9.5.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.5.5)
|
21
|
+
|
22
|
+
Thu, 16 Mar 2023 14:36:59 GMT
|
23
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.4..@fluentui/react-positioning_v9.5.5)
|
24
|
+
|
25
|
+
### Patches
|
26
|
+
|
27
|
+
- Bump @fluentui/react-utilities to v9.7.1 ([PR #27229](https://github.com/microsoft/fluentui/pull/27229) by beachball)
|
28
|
+
|
7
29
|
## [9.5.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.5.4)
|
8
30
|
|
9
|
-
Wed, 15 Mar 2023 10:
|
31
|
+
Wed, 15 Mar 2023 10:19:53 GMT
|
10
32
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.5.3..@fluentui/react-positioning_v9.5.4)
|
11
33
|
|
12
34
|
### Patches
|
package/lib/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT"],"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n"],"mappings":"AAAA,OAAO,MAAMA,6BAAA,GAAgC;AAC7C,OAAO,MAAMC,wBAAA,GAA2B;AACxC,OAAO,MAAMC,uBAAA,GAA0B;AACvC,OAAO,MAAMC,0BAAA,GAA6B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["shorthands","tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"sources":["../src/
|
1
|
+
{"version":3,"names":["shorthands","tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"sources":["../src/createArrowStyles.ts"],"sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * @internal\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAC3B,SAASC,MAAM,QAAQ;AAsCvB;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,SAASC,kBAAkBC,OAAiC,EAAgB;EACjF,MAAM;IACJC,WAAA;IACAC,WAAA,GAAc;IACdC,WAAA,GAAc;IACdC,WAAA,GAAcN,MAAA,CAAOO;EAAsB,CAC5C,GAAGL,OAAA;EAEJ,OAAO;IACLM,QAAA,EAAU;IACVC,eAAA,EAAiB;IACjBC,UAAA,EAAY;IACZC,MAAA,EAAQ,CAAC;IAET,IAAIR,WAAA,IAAeS,uBAAA,CAAwBT,WAAA,CAAY;IAEvD,YAAY;MACVU,OAAA,EAAS;MACTH,UAAA,EAAY;MACZF,QAAA,EAAU;MACVM,SAAA,EAAW;MACXC,KAAA,EAAO;MACPC,MAAA,EAAQ;MACRP,eAAA,EAAiB;MACjB,GAAGV,UAAA,CAAWkB,WAAW,CACtB,GAAEb,WAAY,gBAAe,EAC7B,GAAEC,WAAY,gBAAe,EAC7B,GAAEC,WAAY,gBAAe,CAC/B;MACD,GAAGP,UAAA,CAAWmB,YAAY,CAACd,WAAA,EAAaC,WAAA,EAAaC,WAAA,CAAY;MACjEa,uBAAA,EAAyBnB,MAAA,CAAOoB,iBAAiB;MACjDC,SAAA,EAAW;IACb;IAEA;IACA,2CAA2C;MACzCC,MAAA,EAAS,IAAGlB,WAAY,EAAC;MACzB,WAAW;IACb;IACA,6CAA6C;MAC3CmB,IAAA,EAAO,IAAGnB,WAAY,gBAAe;MACrC,WAAW;IACb;IACA,8CAA8C;MAC5CoB,GAAA,EAAM,IAAGpB,WAAY,EAAC;MACtB,WAAW;IACb;IACA,4CAA4C;MAC1CqB,KAAA,EAAQ,IAAGrB,WAAY,gBAAe;MACtC,WAAW;IACb;EACF;AACF;AAEA;;;;;;;AAOA,OAAO,SAASQ,wBAAwBT,WAAmB,EAAE;EAC3D;EACA;EACA,MAAMuB,UAAA,GAAc,GAAE,QAAQvB,WAAY,IAAG;EAC7C,OAAO;IAAEY,KAAA,EAAOW,UAAA;IAAYV,MAAA,EAAQU;EAAW;AACjD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["computePosition","debounce","writeArrowUpdates","writeContainerUpdates","getScrollParent","isHTMLElement","createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","forEach","scrollParent","addEventListener","then","x","y","middlewareData","computedPlacement","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","removeEventListener"],"sources":["../src/
|
1
|
+
{"version":3,"names":["computePosition","debounce","writeArrowUpdates","writeContainerUpdates","getScrollParent","isHTMLElement","createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","forEach","scrollParent","addEventListener","then","x","y","middlewareData","computedPlacement","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","removeEventListener"],"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';\nimport { isHTMLElement } from '@fluentui/react-utilities';\n\ninterface PositionManagerOptions {\n /**\n * The positioned element\n */\n container: HTMLElement;\n /**\n * Element that the container will be anchored to\n */\n target: TargetElement;\n /**\n * Arrow that points from the container to the target\n */\n arrow: HTMLElement | null;\n /**\n * The value of the css `position` property\n * @default absolute\n */\n strategy: Strategy;\n /**\n * [Floating UI middleware](https://floating-ui.com/docs/middleware)\n */\n middleware: Middleware[];\n /**\n * [Floating UI placement](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: Placement;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n const { container, target, arrow, strategy, middleware, placement } = options;\n let isDestroyed = false;\n if (!target || !container) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\n const targetWindow = container.ownerDocument.defaultView;\n\n // When the container is first resolved, set position `fixed` to avoid scroll jumps.\n // Without this scroll jumps can occur when the element is rendered initially and receives focus\n Object.assign(container.style, { position: 'fixed', left: 0, top: 0, margin: 0 });\n\n const forceUpdate = () => {\n // debounced update can still occur afterwards\n // early return to avoid memory leaks\n if (isDestroyed) {\n return;\n }\n\n if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (isHTMLElement(target)) {\n scrollParents.add(getScrollParent(target));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition);\n });\n\n isFirstUpdate = false;\n }\n\n Object.assign(container.style, { position: strategy });\n computePosition(target, container, { placement, middleware, strategy })\n .then(({ x, y, middlewareData, placement: computedPlacement }) => {\n // Promise can still resolve after destruction\n // early return to avoid applying outdated position\n if (isDestroyed) {\n return;\n }\n\n writeArrowUpdates({ arrow, middlewareData });\n writeContainerUpdates({\n container,\n middlewareData,\n placement: computedPlacement,\n coordinates: { x, y },\n lowPPI: (targetWindow?.devicePixelRatio || 1) <= 1,\n strategy,\n });\n })\n .catch(err => {\n // https://github.com/floating-ui/floating-ui/issues/1845\n // FIXME for node > 14\n // node 15 introduces promise rejection which means that any components\n // tests need to be `it('', async () => {})` otherwise there can be race conditions with\n // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist\n // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing\n // will actually be counter productive\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error('[usePositioning]: Failed to calculate position', err);\n }\n });\n };\n\n const updatePosition = debounce(() => forceUpdate());\n\n const dispose = () => {\n isDestroyed = true;\n\n if (targetWindow) {\n targetWindow.removeEventListener('scroll', updatePosition);\n targetWindow.removeEventListener('resize', updatePosition);\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.removeEventListener('scroll', updatePosition);\n });\n };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition);\n targetWindow.addEventListener('resize', updatePosition);\n }\n\n // Update the position on initialization\n updatePosition();\n\n return {\n updatePosition,\n dispose,\n };\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ;AAGhC,SAASC,QAAQ,EAAEC,iBAAiB,EAAEC,qBAAqB,EAAEC,eAAe,QAAQ;AACpF,SAASC,aAAa,QAAQ;AA8B9B;;;;AAIA,OAAO,SAASC,sBAAsBC,OAA+B,EAAmB;EACtF,MAAM;IAAEC,SAAA;IAAWC,MAAA;IAAQC,KAAA;IAAOC,QAAA;IAAUC,UAAA;IAAYC;EAAS,CAAE,GAAGN,OAAA;EACtE,IAAIO,WAAA,GAAc,KAAK;EACvB,IAAI,CAACL,MAAA,IAAU,CAACD,SAAA,EAAW;IACzB,OAAO;MACLO,cAAA,EAAgBA,CAAA,KAAMC,SAAA;MACtBC,OAAA,EAASA,CAAA,KAAMD;IACjB;EACF;EAEA,IAAIE,aAAA,GAAgB,IAAI;EACxB,MAAMC,aAAA,GAAkC,IAAIC,GAAA;EAC5C,MAAMC,YAAA,GAAeb,SAAA,CAAUc,aAAa,CAACC,WAAW;EAExD;EACA;EACAC,MAAA,CAAOC,MAAM,CA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ACC,QAAQ,KAAK,eAAe;QAC1C;QACAC,OAAA,CAAQC,KAAK,CAAC,kDAAkDL,GAAA;MAClE;IACF;EACJ;EAEA,MAAM9B,cAAA,GAAiBd,QAAA,CAAS,MAAM8B,WAAA;EAEtC,MAAMd,OAAA,GAAUA,CAAA,KAAM;IACpBH,WAAA,GAAc,IAAI;IAElB,IAAIO,YAAA,EAAc;MAChBA,YAAA,CAAa8B,mBAAmB,CAAC,UAAUpC,cAAA;MAC3CM,YAAA,CAAa8B,mBAAmB,CAAC,UAAUpC,cAAA;IAC7C;IAEAI,aAAA,CAAcc,OAAO,CAACC,YAAA,IAAgB;MACpCA,YAAA,CAAaiB,mBAAmB,CAAC,UAAUpC,cAAA;IAC7C;EACF;EAEA,IAAIM,YAAA,EAAc;IAChBA,YAAA,CAAac,gBAAgB,CAAC,UAAUpB,cAAA;IACxCM,YAAA,CAAac,gBAAgB,CAAC,UAAUpB,cAAA;EAC1C;EAEA;EACAA,cAAA;EAEA,OAAO;IACLA,cAAA;IACAE;EACF;AACF"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Creates a virtual element based on the position of a click event
|
3
3
|
* Can be used as a target for popper in scenarios such as context menus
|
4
|
-
*/
|
5
|
-
export function createVirtualElementFromClick(nativeEvent) {
|
4
|
+
*/export function createVirtualElementFromClick(nativeEvent) {
|
6
5
|
const left = nativeEvent.clientX;
|
7
6
|
const top = nativeEvent.clientY;
|
8
7
|
const right = left + 1;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"sources":["../src/
|
1
|
+
{"version":3,"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"sources":["../src/createVirtualElementFromClick.ts"],"sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"mappings":"AAEA;;;GAIA,OAAO,SAASA,8BAA8BC,WAAuB,EAA6B;EAChG,MAAMC,IAAA,GAAOD,WAAA,CAAYE,OAAO;EAChC,MAAMC,GAAA,GAAMH,WAAA,CAAYI,OAAO;EAC/B,MAAMC,KAAA,GAAQJ,IAAA,GAAO;EACrB,MAAMK,MAAA,GAASH,GAAA,GAAM;EAErB,SAASI,sBAAA,EAAwB;IAC/B,OAAO;MACLN,IAAA;MACAE,GAAA;MACAE,KAAA;MACAC,MAAA;MACAE,CAAA,EAAGP,IAAA;MACHQ,CAAA,EAAGN,GAAA;MACHO,MAAA,EAAQ;MACRC,KAAA,EAAO;IACT;EACF;EAEA,OAAO;IACLJ;EACF;AACF"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["createVirtualElementFromClick","createArrowHeightStyles","createArrowStyles","usePositioning","usePositioningMouseTarget","resolvePositioningShorthand","mergeArrowOffset"],"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n} from './types';\n"],"mappings":"AAAA,SAASA,6BAA6B,QAAQ;AAC9C,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ;AAE3D,SAASC,cAAc,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,2BAA2B,EAAEC,gBAAgB,QAAQ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["parseFloatingUIPlacement","coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","side","newCoords","reference","height","width"],"sources":["
|
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 +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":["
|
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 +1 @@
|
|
1
|
-
{"version":3,"
|
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 +1 @@
|
|
1
|
-
{"version":3,"names":["detectOverflow","intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"sources":["
|
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 +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":["
|
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 +1 @@
|
|
1
|
-
{"version":3,"names":["offset","baseOffset","getFloatingUIOffset","offsetValue","floatingUIOffset"],"sources":["
|
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 +1 @@
|
|
1
|
-
{"version":3,"names":["shift","baseShift","limitShift","getBoundary","toFloatingUIPadding","options","hasScrollableElement","disableTether","overflowBoundary","container","overflowBoundaryPadding","isRtl","boundary","crossAxis","limiter","mainAxis","padding","altBoundary"],"sources":["
|
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"}
|
package/lib/types.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
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"}
|
package/lib/usePositioning.js
CHANGED
@@ -19,12 +19,12 @@ export function usePositioning(options) {
|
|
19
19
|
} = options;
|
20
20
|
const resolvePositioningOptions = usePositioningOptions(options);
|
21
21
|
const updatePositionManager = React.useCallback(() => {
|
22
|
-
var _a;
|
23
22
|
if (managerRef.current) {
|
24
23
|
managerRef.current.dispose();
|
25
24
|
}
|
26
25
|
managerRef.current = null;
|
27
|
-
|
26
|
+
var _overrideTargetRef_current;
|
27
|
+
const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;
|
28
28
|
if (enabled && canUseDOM() && target && containerRef.current) {
|
29
29
|
managerRef.current = createPositionManager({
|
30
30
|
container: containerRef.current,
|
@@ -38,25 +38,27 @@ export function usePositioning(options) {
|
|
38
38
|
overrideTargetRef.current = target;
|
39
39
|
updatePositionManager();
|
40
40
|
});
|
41
|
-
React.useImperativeHandle(options.positioningRef, () =>
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
React.useImperativeHandle(options.positioningRef, () => {
|
42
|
+
return {
|
43
|
+
updatePosition: () => {
|
44
|
+
var _managerRef_current;
|
45
|
+
return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();
|
46
|
+
},
|
47
|
+
setTarget: target => {
|
48
|
+
if (options.target && process.env.NODE_ENV !== 'production') {
|
49
|
+
const err = new Error();
|
50
|
+
// eslint-disable-next-line no-console
|
51
|
+
console.warn('Imperative setTarget should not be used at the same time as target option');
|
52
|
+
// eslint-disable-next-line no-console
|
53
|
+
console.warn(err.stack);
|
54
|
+
}
|
55
|
+
setOverrideTarget(target);
|
53
56
|
}
|
54
|
-
|
55
|
-
|
56
|
-
}), [options.target, setOverrideTarget]);
|
57
|
+
};
|
58
|
+
}, [options.target, setOverrideTarget]);
|
57
59
|
useIsomorphicLayoutEffect(() => {
|
58
|
-
var
|
59
|
-
setOverrideTarget((
|
60
|
+
var _options_target;
|
61
|
+
setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);
|
60
62
|
}, [options.target, setOverrideTarget]);
|
61
63
|
useIsomorphicLayoutEffect(() => {
|
62
64
|
updatePositionManager();
|
@@ -65,10 +67,10 @@ export function usePositioning(options) {
|
|
65
67
|
// This checked should run only in development mode
|
66
68
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
67
69
|
React.useEffect(() => {
|
68
|
-
var _a;
|
69
70
|
if (containerRef.current) {
|
71
|
+
var _contentNode_ownerDocument;
|
70
72
|
const contentNode = containerRef.current;
|
71
|
-
const treeWalker = (
|
73
|
+
const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
|
72
74
|
acceptNode: hasAutofocusFilter
|
73
75
|
});
|
74
76
|
while (treeWalker.nextNode()) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","useCallbackRef","toFloatingUIPlacement","hasAutofocusFilter","hasScrollParent","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","createPositionManager","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","target","_a","container","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useEffect","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","nextNode","node","currentNode","join","setContainer","setArrow","align","arrowPadding","autoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","fallbackPositions","dir","isRtl","strategy","hasScrollableElement","middleware","element","padding","filter","Boolean","placement"],"sources":["../src/packages/react-components/react-positioning/src/usePositioning.ts"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps, Pick<PositioningOptions, 'fallbackPositions' | 'pinned'> {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n overflowBoundaryPadding,\n fallbackPositions,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement, isRtl, fallbackPositions }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n ],\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e,CAAC+B,SAAS,CAAC;IAEvD,MAAM4C,UAAU,GAAG,CACjBlE,MAAM,IAAIC,gBAAgB,CAACD,MAAM,CAAC,EAClCJ,WAAW,IAAIC,qBAAqB,EAAE,EACtC,CAAC0D,MAAM,IAAI5D,cAAc,CAAC;MAAE2B,SAAS;MAAE+B,YAAY;MAAEY,oBAAoB;MAAEF,KAAK;MAAEF;IAAiB,CAAE,CAAC,EACtGpE,eAAe,CAAC;MACd6B,SAAS;MACT2C,oBAAoB;MACpBX,gBAAgB;MAChBI,aAAa;MACbE,uBAAuB;MACvBG;KACD,CAAC,EACFX,QAAQ,IAAIrD,iBAAiB,CAACqD,QAAQ,EAAE;MAAE9B,SAAS;MAAEgC;IAAgB,CAAE,CAAC,EACxEnD,sBAAsB,EAAE,EACxBvB,KAAK,IAAIC,eAAe,CAAC;MAAEsF,OAAO,EAAEvF,KAAK;MAAEwF,OAAO,EAAEjB;IAAY,CAAE,CAAC,EACnExE,cAAc,CAAC;MAAEqF,QAAQ,EAAE;IAAiB,CAAE,CAAC,EAC/CrF,cAAc,CAAC;MAAEqF,QAAQ,EAAE;IAAS,CAAE,CAAC,CACxC,CAACK,MAAM,CAACC,OAAO,CAAiB;IAEjC,MAAMC,SAAS,GAAGlF,qBAAqB,CAAC6D,KAAK,EAAEM,QAAQ,EAAEO,KAAK,CAAC;IAE/D,OAAO;MACLQ,SAAS;MACTL,UAAU;MACVF;KACD;EACH,CAAC,EACD,CACEd,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRxD,WAAW,EACX8D,aAAa,EACbL,YAAY,EACZU,KAAK,EACL/D,MAAM,EACNsD,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRQ,QAAQ,EACRJ,uBAAuB,EACvBC,iBAAiB,CAClB,CACF;AACH"}
|
1
|
+
{"version":3,"names":["hide","hideMiddleware","arrow","arrowMiddleware","useFluent_unstable","useFluent","canUseDOM","useEventCallback","useIsomorphicLayoutEffect","React","useCallbackRef","toFloatingUIPlacement","hasAutofocusFilter","hasScrollParent","shift","shiftMiddleware","flip","flipMiddleware","coverTarget","coverTargetMiddleware","maxSize","maxSizeMiddleware","offset","offsetMiddleware","intersecting","intersectingMiddleware","createPositionManager","usePositioning","options","managerRef","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","_overrideTargetRef_current","target","container","setOverrideTarget","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","_options_target","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","nextNode","node","currentNode","join","setContainer","setArrow","align","arrowPadding","autoSize","flipBoundary","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","fallbackPositions","dir","isRtl","strategy","hasScrollableElement","middleware","element","padding","filter","Boolean","placement"],"sources":["../src/usePositioning.ts"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport type { Middleware, Strategy } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type {\n PositioningOptions,\n PositioningProps,\n PositionManager,\n TargetElement,\n UsePositioningReturn,\n} from './types';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport {\n shift as shiftMiddleware,\n flip as flipMiddleware,\n coverTarget as coverTargetMiddleware,\n maxSize as maxSizeMiddleware,\n offset as offsetMiddleware,\n intersecting as intersectingMiddleware,\n} from './middleware';\nimport { createPositionManager } from './createPositionManager';\n\n/**\n * @internal\n */\nexport function usePositioning(options: UsePositioningOptions): UsePositioningReturn {\n const managerRef = React.useRef<PositionManager | null>(null);\n const targetRef = React.useRef<TargetElement | null>(null);\n const overrideTargetRef = React.useRef<TargetElement | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLElement | null>(null);\n\n const { enabled = true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n\n const target = overrideTargetRef.current ?? targetRef.current;\n\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current),\n });\n }\n }, [enabled, resolvePositioningOptions]);\n\n const setOverrideTarget = useEventCallback((target: TargetElement | null) => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n\n React.useImperativeHandle(\n options.positioningRef,\n () => ({\n updatePosition: () => managerRef.current?.updatePosition(),\n setTarget: (target: TargetElement) => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n\n setOverrideTarget(target);\n },\n }),\n [options.target, setOverrideTarget],\n );\n\n useIsomorphicLayoutEffect(() => {\n setOverrideTarget(options.target ?? null);\n }, [options.target, setOverrideTarget]);\n\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n const setTarget = useCallbackRef<TargetElement>(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n\n const setContainer = useCallbackRef<HTMLElement | null>(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n\n const setArrow = useCallbackRef<HTMLElement | null>(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n\n // Let users use callback refs so they feel like 'normal' DOM refs\n return { targetRef: setTarget, containerRef: setContainer, arrowRef: setArrow };\n}\n\ninterface UsePositioningOptions extends PositioningProps, Pick<PositioningOptions, 'fallbackPositions' | 'pinned'> {\n /**\n * If false, does not position anything\n */\n enabled?: boolean;\n}\n\nfunction usePositioningOptions(options: PositioningOptions) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n overflowBoundaryPadding,\n fallbackPositions,\n } = options;\n\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy: Strategy = positionFixed ? 'fixed' : 'absolute';\n\n return React.useCallback(\n (container: HTMLElement | null, arrow: HTMLElement | null) => {\n const hasScrollableElement = hasScrollParent(container);\n\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({ container, flipBoundary, hasScrollableElement, isRtl, fallbackPositions }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl,\n }),\n autoSize && maxSizeMiddleware(autoSize, { container, overflowBoundary }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({ element: arrow, padding: arrowPadding }),\n hideMiddleware({ strategy: 'referenceHidden' }),\n hideMiddleware({ strategy: 'escaped' }),\n ].filter(Boolean) as Middleware[];\n\n const placement = toFloatingUIPlacement(align, position, isRtl);\n\n return {\n placement,\n middleware,\n strategy,\n };\n },\n [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n ],\n );\n}\n"],"mappings":"AAAA,SAASA,IAAA,IAAQC,cAAc,EAAEC,KAAA,IAASC,eAAe,QAAQ;AAEjE,SAASC,kBAAA,IAAsBC,SAAS,QAAQ;AAChD,SAASC,SAAS,EAAEC,gBAAgB,EAAEC,yBAAyB,QAAQ;AACvE,YAAYC,KAAA,MAAW;AAQvB,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ;AAC3F,SACEC,KAAA,IAASC,eAAe,EACxBC,IAAA,IAAQC,cAAc,EACtBC,WAAA,IAAeC,qBAAqB,EACpCC,OAAA,IAAWC,iBAAiB,EAC5BC,MAAA,IAAUC,gBAAgB,EAC1BC,YAA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