@fluentui/react-positioning 9.4.0 → 9.4.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +31 -1
- package/CHANGELOG.md +20 -2
- package/lib/utils/writeContainerupdates.js +8 -3
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-amd/utils/writeContainerupdates.js +8 -3
- package/lib-amd/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +8 -3
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,37 @@
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Mon, 13 Feb 2023 23:40:50 GMT",
|
6
|
+
"tag": "@fluentui/react-positioning_v9.4.2",
|
7
|
+
"version": "9.4.2",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "beachball",
|
12
|
+
"package": "@fluentui/react-positioning",
|
13
|
+
"comment": "Bump @fluentui/react-utilities to v9.5.3",
|
14
|
+
"commit": "29e62b13706c2845b21d665d43cdacf1ef1b1513"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Mon, 13 Feb 2023 09:35:47 GMT",
|
21
|
+
"tag": "@fluentui/react-positioning_v9.4.1",
|
22
|
+
"version": "9.4.1",
|
23
|
+
"comments": {
|
24
|
+
"patch": [
|
25
|
+
{
|
26
|
+
"author": "behowell@microsoft.com",
|
27
|
+
"package": "@fluentui/react-positioning",
|
28
|
+
"commit": "0565ec044c06af355f951e158c0e68611a1d8861",
|
29
|
+
"comment": "fix: Coordinates should be rounded to device pixels to prevent blurriness"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"date": "Fri, 10 Feb 2023 08:49:59 GMT",
|
6
36
|
"tag": "@fluentui/react-positioning_v9.4.0",
|
7
37
|
"version": "9.4.0",
|
8
38
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Mon, 13 Feb 2023 23:40:50 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.4.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.4.2)
|
8
|
+
|
9
|
+
Mon, 13 Feb 2023 23:40:50 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.4.1..@fluentui/react-positioning_v9.4.2)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- Bump @fluentui/react-utilities to v9.5.3 ([PR #26814](https://github.com/microsoft/fluentui/pull/26814) by beachball)
|
15
|
+
|
16
|
+
## [9.4.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.4.1)
|
17
|
+
|
18
|
+
Mon, 13 Feb 2023 09:35:47 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.4.0..@fluentui/react-positioning_v9.4.1)
|
20
|
+
|
21
|
+
### Patches
|
22
|
+
|
23
|
+
- fix: Coordinates should be rounded to device pixels to prevent blurriness ([PR #26766](https://github.com/microsoft/fluentui/pull/26766) by behowell@microsoft.com)
|
24
|
+
|
7
25
|
## [9.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.4.0)
|
8
26
|
|
9
|
-
Fri, 10 Feb 2023 08:
|
27
|
+
Fri, 10 Feb 2023 08:49:59 GMT
|
10
28
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.3.11..@fluentui/react-positioning_v9.4.0)
|
11
29
|
|
12
30
|
### Minor changes
|
@@ -3,7 +3,7 @@ import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INT
|
|
3
3
|
* Writes all container element position updates after the position is computed
|
4
4
|
*/
|
5
5
|
export function writeContainerUpdates(options) {
|
6
|
-
var _a, _b;
|
6
|
+
var _a, _b, _c;
|
7
7
|
const {
|
8
8
|
container,
|
9
9
|
placement,
|
@@ -28,8 +28,13 @@ export function writeContainerUpdates(options) {
|
|
28
28
|
if ((_b = middlewareData.hide) === null || _b === void 0 ? void 0 : _b.referenceHidden) {
|
29
29
|
container.setAttribute(DATA_POSITIONING_HIDDEN, '');
|
30
30
|
}
|
31
|
-
|
32
|
-
|
31
|
+
// Round so that the coordinates land on device pixels.
|
32
|
+
// This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
|
33
|
+
// `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
|
34
|
+
// See https://github.com/microsoft/fluentui/issues/26764 for more info.
|
35
|
+
const devicePixelRatio = ((_c = container.ownerDocument.defaultView) === null || _c === void 0 ? void 0 : _c.devicePixelRatio) || 1;
|
36
|
+
const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
|
37
|
+
const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
|
33
38
|
Object.assign(container.style, {
|
34
39
|
transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
|
35
40
|
position: strategy
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":"AACA,SACEA,wBAAwB,EACxBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,0BAA0B,QACrB,cAAc;AAErB;;;AAGA,OAAM,SAAUC,qBAAqB,CAACC,OAYrC;;EACC,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC,cAAc;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAW,CAAE,GAAGN,OAAO;EACvF,IAAI,CAACC,SAAS,EAAE;IACd;;EAEFA,SAAS,CAACM,YAAY,CAACT,0BAA0B,EAAEI,SAAS,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Ae,CAACZ,uBAAuB,CAAC;EAClD,IAAI,oBAAc,CAACe,IAAI,0CAAEE,eAAe,EAAE;IACxCZ,SAAS,CAACM,YAAY,CAACX,uBAAuB,EAAE,EAAE,CAAC;;EAGrD;EACA;EACA;EACA;EACA,MAAMkB,gBAAgB,GAAG,gBAAS,CAACC,aAAa,CAACC,WAAW,0CAAEF,gBAAgB,KAAI,CAAC;EACnF,MAAMG,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACb,WAAW,CAACW,CAAC,GAAGH,gBAAgB,CAAC,GAAGA,gBAAgB;EACzE,MAAMM,CAAC,GAAGF,IAAI,CAACC,KAAK,CAACb,WAAW,CAACc,CAAC,GAAGN,gBAAgB,CAAC,GAAGA,gBAAgB;EAEzEO,MAAM,CAACC,MAAM,CAACrB,SAAS,CAACsB,KAAK,EAAE;IAC7BC,SAAS,EAAEnB,MAAM,GAAG,aAAaY,CAAC,OAAOG,CAAC,KAAK,GAAG,eAAeH,CAAC,OAAOG,CAAC,QAAQ;IAClFK,QAAQ,EAAErB;GACX,CAAC;AACJ","names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","container","placement","middlewareData","strategy","lowPPI","coordinates","setAttribute","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","transform","position"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/writeContainerupdates.ts"],"sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const { container, placement, middlewareData, strategy, lowPPI, coordinates } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n"]}
|
@@ -6,7 +6,7 @@ define(["require", "exports", "../constants"], function (require, exports, const
|
|
6
6
|
* Writes all container element position updates after the position is computed
|
7
7
|
*/
|
8
8
|
function writeContainerUpdates(options) {
|
9
|
-
var _a, _b;
|
9
|
+
var _a, _b, _c;
|
10
10
|
var container = options.container, placement = options.placement, middlewareData = options.middlewareData, strategy = options.strategy, lowPPI = options.lowPPI, coordinates = options.coordinates;
|
11
11
|
if (!container) {
|
12
12
|
return;
|
@@ -24,8 +24,13 @@ define(["require", "exports", "../constants"], function (require, exports, const
|
|
24
24
|
if ((_b = middlewareData.hide) === null || _b === void 0 ? void 0 : _b.referenceHidden) {
|
25
25
|
container.setAttribute(constants_1.DATA_POSITIONING_HIDDEN, '');
|
26
26
|
}
|
27
|
-
|
28
|
-
|
27
|
+
// Round so that the coordinates land on device pixels.
|
28
|
+
// This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
|
29
|
+
// `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
|
30
|
+
// See https://github.com/microsoft/fluentui/issues/26764 for more info.
|
31
|
+
var devicePixelRatio = ((_c = container.ownerDocument.defaultView) === null || _c === void 0 ? void 0 : _c.devicePixelRatio) || 1;
|
32
|
+
var x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
|
33
|
+
var y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
|
29
34
|
Object.assign(container.style, {
|
30
35
|
transform: lowPPI ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)",
|
31
36
|
position: strategy,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"writeContainerupdates.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/writeContainerupdates.ts"],"names":[],"mappings":";;;;IAQA;;OAEG;IACH,SAAgB,qBAAqB,CAAC,OAYrC;;QACS,IAAA,SAAS,GAA+D,OAAO,UAAtE,EAAE,SAAS,GAAoD,OAAO,UAA3D,EAAE,cAAc,GAAoC,OAAO,eAA3C,EAAE,QAAQ,GAA0B,OAAO,SAAjC,EAAE,MAAM,GAAkB,OAAO,OAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;QACxF,IAAI,CAAC,SAAS,EAAE;YACd,OAAO;SACR;QACD,SAAS,CAAC,YAAY,CAAC,sCAA0B,EAAE,SAAS,CAAC,CAAC;QAC9D,SAAS,CAAC,eAAe,CAAC,yCAA6B,CAAC,CAAC;QACzD,IAAI,cAAc,CAAC,oBAAoB,CAAC,YAAY,EAAE;YACpD,SAAS,CAAC,YAAY,CAAC,yCAA6B,EAAE,EAAE,CAAC,CAAC;SAC3D;QAED,SAAS,CAAC,eAAe,CAAC,oCAAwB,CAAC,CAAC;QACpD,IAAI,MAAA,cAAc,CAAC,IAAI,0CAAE,OAAO,EAAE;YAChC,SAAS,CAAC,YAAY,CAAC,oCAAwB,EAAE,EAAE,CAAC,CAAC;SACtD;QAED,SAAS,CAAC,eAAe,CAAC,mCAAuB,CAAC,CAAC;QACnD,IAAI,MAAA,cAAc,CAAC,IAAI,0CAAE,eAAe,EAAE;YACxC,SAAS,CAAC,YAAY,CAAC,mCAAuB,EAAE,EAAE,CAAC,CAAC;SACrD;QAED,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"writeContainerupdates.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-positioning/src/utils/writeContainerupdates.ts"],"names":[],"mappings":";;;;IAQA;;OAEG;IACH,SAAgB,qBAAqB,CAAC,OAYrC;;QACS,IAAA,SAAS,GAA+D,OAAO,UAAtE,EAAE,SAAS,GAAoD,OAAO,UAA3D,EAAE,cAAc,GAAoC,OAAO,eAA3C,EAAE,QAAQ,GAA0B,OAAO,SAAjC,EAAE,MAAM,GAAkB,OAAO,OAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;QACxF,IAAI,CAAC,SAAS,EAAE;YACd,OAAO;SACR;QACD,SAAS,CAAC,YAAY,CAAC,sCAA0B,EAAE,SAAS,CAAC,CAAC;QAC9D,SAAS,CAAC,eAAe,CAAC,yCAA6B,CAAC,CAAC;QACzD,IAAI,cAAc,CAAC,oBAAoB,CAAC,YAAY,EAAE;YACpD,SAAS,CAAC,YAAY,CAAC,yCAA6B,EAAE,EAAE,CAAC,CAAC;SAC3D;QAED,SAAS,CAAC,eAAe,CAAC,oCAAwB,CAAC,CAAC;QACpD,IAAI,MAAA,cAAc,CAAC,IAAI,0CAAE,OAAO,EAAE;YAChC,SAAS,CAAC,YAAY,CAAC,oCAAwB,EAAE,EAAE,CAAC,CAAC;SACtD;QAED,SAAS,CAAC,eAAe,CAAC,mCAAuB,CAAC,CAAC;QACnD,IAAI,MAAA,cAAc,CAAC,IAAI,0CAAE,eAAe,EAAE;YACxC,SAAS,CAAC,YAAY,CAAC,mCAAuB,EAAE,EAAE,CAAC,CAAC;SACrD;QAED,uDAAuD;QACvD,oHAAoH;QACpH,wFAAwF;QACxF,wEAAwE;QACxE,IAAM,gBAAgB,GAAG,CAAA,MAAA,SAAS,CAAC,aAAa,CAAC,WAAW,0CAAE,gBAAgB,KAAI,CAAC,CAAC;QACpF,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;QAC1E,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;QAE1E,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE;YAC7B,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,eAAa,CAAC,YAAO,CAAC,QAAK,CAAC,CAAC,CAAC,iBAAe,CAAC,YAAO,CAAC,WAAQ;YAClF,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC;IACL,CAAC;IA7CD,sDA6CC","sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const { container, placement, middlewareData, strategy, lowPPI, coordinates } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n"]}
|
@@ -9,7 +9,7 @@ const constants_1 = /*#__PURE__*/require("../constants");
|
|
9
9
|
* Writes all container element position updates after the position is computed
|
10
10
|
*/
|
11
11
|
function writeContainerUpdates(options) {
|
12
|
-
var _a, _b;
|
12
|
+
var _a, _b, _c;
|
13
13
|
const {
|
14
14
|
container,
|
15
15
|
placement,
|
@@ -34,8 +34,13 @@ function writeContainerUpdates(options) {
|
|
34
34
|
if ((_b = middlewareData.hide) === null || _b === void 0 ? void 0 : _b.referenceHidden) {
|
35
35
|
container.setAttribute(constants_1.DATA_POSITIONING_HIDDEN, '');
|
36
36
|
}
|
37
|
-
|
38
|
-
|
37
|
+
// Round so that the coordinates land on device pixels.
|
38
|
+
// This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
|
39
|
+
// `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
|
40
|
+
// See https://github.com/microsoft/fluentui/issues/26764 for more info.
|
41
|
+
const devicePixelRatio = ((_c = container.ownerDocument.defaultView) === null || _c === void 0 ? void 0 : _c.devicePixelRatio) || 1;
|
42
|
+
const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
|
43
|
+
const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
|
39
44
|
Object.assign(container.style, {
|
40
45
|
transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,
|
41
46
|
position: strategy
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"mappings":";;;;;;AACA;AAOA;;;AAGA,SAAgBA,qBAAqB,CAACC,OAYrC;;EACC,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC,cAAc;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAW,CAAE,GAAGN,OAAO;EACvF,IAAI,CAACC,SAAS,EAAE;IACd;;EAEFA,SAAS,CAACM,YAAY,CAACC,sCAA0B,EAAEN,SAAS,CAAC;EAC7DD,SAAS,CAACQ,eAAe,CAACD,yCAA6B,CAAC;EACxD,IAAIL,cAAc,CAACO,oBAAoB,CAACC,YAAY,EAAE;IACpDV,SAAS,CAACM,YAAY,CAACC,yCAA6B,EAAE,EAAE,CAAC;;EAG3DP,SAAS,CAACQ,eAAe,CAACD,oCAAwB,CAAC;EACnD,IAAI,oBAAc,CAACI,IAAI,0CAAEC,OAAO,EAAE;IAChCZ,SAAS,CAACM,YAAY,CAACC,oCAAwB,EAAE,EAAE,CAAC;;EAGtDP,SAAS,CAACQ,eAAe,CAACD,mCAAuB,CAAC;EAClD,IAAI,oBAAc,CAACI,IAAI,0CAAEE,eAAe,EAAE;IACxCb,SAAS,CAACM,YA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BC,SAAS,EAAEpB,MAAM,GAAG,aAAaa,CAAC,OAAOG,CAAC,KAAK,GAAG,eAAeH,CAAC,OAAOG,CAAC,QAAQ;IAClFK,QAAQ,EAAEtB;GACX,CAAC;AACJ;AA7CAuB","names":["writeContainerUpdates","options","container","placement","middlewareData","strategy","lowPPI","coordinates","setAttribute","constants_1","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","transform","position","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-positioning/src/utils/writeContainerupdates.ts"],"sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n DATA_POSITIONING_ESCAPED,\n DATA_POSITIONING_HIDDEN,\n DATA_POSITIONING_INTERSECTING,\n DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n container: HTMLElement | null;\n placement: Placement;\n middlewareData: MiddlewareData;\n /**\n * Layer acceleration can disable subpixel rendering which causes slightly\n * blurry text on low PPI displays, so we want to use 2D transforms\n * instead\n */\n lowPPI: boolean;\n strategy: Strategy;\n coordinates: Coords;\n}) {\n const { container, placement, middlewareData, strategy, lowPPI, coordinates } = options;\n if (!container) {\n return;\n }\n container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n if (middlewareData.intersectionObserver.intersecting) {\n container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_ESCAPED);\n if (middlewareData.hide?.escaped) {\n container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n }\n\n container.removeAttribute(DATA_POSITIONING_HIDDEN);\n if (middlewareData.hide?.referenceHidden) {\n container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n }\n\n // Round so that the coordinates land on device pixels.\n // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n position: strategy,\n });\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
|
-
"version": "9.4.
|
3
|
+
"version": "9.4.2",
|
4
4
|
"description": "A react wrapper around Popper.js for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"@floating-ui/dom": "^1.2.0",
|
32
32
|
"@fluentui/react-shared-contexts": "^9.2.0",
|
33
33
|
"@fluentui/react-theme": "^9.1.5",
|
34
|
-
"@fluentui/react-utilities": "^9.5.
|
34
|
+
"@fluentui/react-utilities": "^9.5.3",
|
35
35
|
"@griffel/react": "^1.5.2",
|
36
36
|
"tslib": "^2.1.0"
|
37
37
|
},
|