@fluentui/react-positioning 0.0.0-nightly-20221222-0421.1 → 0.0.0-nightly-20221226-0422.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-positioning",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 22 Dec 2022 04:27:54 GMT",
6
- "tag": "@fluentui/react-positioning_v0.0.0-nightly-20221222-0421.1",
7
- "version": "0.0.0-nightly-20221222-0421.1",
5
+ "date": "Mon, 26 Dec 2022 04:30:03 GMT",
6
+ "tag": "@fluentui/react-positioning_v0.0.0-nightly-20221226-0422.1",
7
+ "version": "0.0.0-nightly-20221226-0422.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,20 +16,20 @@
16
16
  {
17
17
  "author": "beachball",
18
18
  "package": "@fluentui/react-positioning",
19
- "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221222-0421.1",
20
- "commit": "c2e5889ef20f57472af7239d390d0b736d2dddcf"
19
+ "comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221226-0422.1",
20
+ "commit": "7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
24
  "package": "@fluentui/react-positioning",
25
- "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20221222-0421.1",
26
- "commit": "c2e5889ef20f57472af7239d390d0b736d2dddcf"
25
+ "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20221226-0422.1",
26
+ "commit": "7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
30
  "package": "@fluentui/react-positioning",
31
- "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221222-0421.1",
32
- "commit": "c2e5889ef20f57472af7239d390d0b736d2dddcf"
31
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221226-0422.1",
32
+ "commit": "7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a"
33
33
  }
34
34
  ]
35
35
  }
package/CHANGELOG.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Thu, 22 Dec 2022 04:27:54 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 26 Dec 2022 04:30:03 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20221222-0421.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly-20221222-0421.1)
7
+ ## [0.0.0-nightly-20221226-0422.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly-20221226-0422.1)
8
8
 
9
- Thu, 22 Dec 2022 04:27:54 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.3.5..@fluentui/react-positioning_v0.0.0-nightly-20221222-0421.1)
9
+ Mon, 26 Dec 2022 04:30:03 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.3.5..@fluentui/react-positioning_v0.0.0-nightly-20221226-0422.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221222-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/c2e5889ef20f57472af7239d390d0b736d2dddcf) by beachball)
16
- - Bump @fluentui/react-theme to v0.0.0-nightly-20221222-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/c2e5889ef20f57472af7239d390d0b736d2dddcf) by beachball)
17
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20221222-0421.1 ([commit](https://github.com/microsoft/fluentui/commit/c2e5889ef20f57472af7239d390d0b736d2dddcf) by beachball)
15
+ - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221226-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a) by beachball)
16
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20221226-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a) by beachball)
17
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20221226-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/7ce01d5ce4e4d25cc8b06eb9ca36ea42bde9664a) by beachball)
18
18
 
19
19
  ## [9.3.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.3.5)
20
20
 
@@ -34,7 +34,7 @@ export function createPositionManager(options) {
34
34
  margin: 0
35
35
  });
36
36
 
37
- const forceUpdate = () => {
37
+ let forceUpdate = () => {
38
38
  if (isFirstUpdate) {
39
39
  scrollParents.add(getScrollParent(container));
40
40
 
@@ -94,6 +94,10 @@ export function createPositionManager(options) {
94
94
  const updatePosition = debounce(() => forceUpdate());
95
95
 
96
96
  const dispose = () => {
97
+ // debounced update can still occur afterwards
98
+ // so destroy the reference to forceUpdate
99
+ forceUpdate = () => null;
100
+
97
101
  if (targetWindow) {
98
102
  targetWindow.removeEventListener('scroll', updatePosition);
99
103
  targetWindow.removeEventListener('resize', updatePosition);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/react-components/react-positioning/src/createPositionManager.ts"],"names":[],"mappings":"AAAA,SAAS,eAAT,QAAgC,kBAAhC;AAGA,SAAS,QAAT,EAAmB,iBAAnB,EAAsC,qBAAtC,EAA6D,eAA7D,QAAoF,SAApF;AA8BA;;;AAGG;;AACH,OAAM,SAAU,qBAAV,CAAgC,OAAhC,EAA+D;EACnE,MAAM;IAAE,SAAF;IAAa,MAAb;IAAqB,KAArB;IAA4B,QAA5B;IAAsC,UAAtC;IAAkD;EAAlD,IAAgE,OAAtE;;EACA,IAAI,CA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UAAK;QAAL,CAJO;QAKpB,MAAM,EAAE,CAAC,CAAA,YAAY,KAAA,IAAZ,IAAA,YAAY,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAA,YAAY,CAAE,gBAAd,KAAkC,CAAnC,KAAyC,CAL7B;QAMpB;MANoB,CAAD,CAArB;IAQD,CAXH,EAYG,KAZH,CAYS,GAAG,IAAG;MACX;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,aAA7B,EAA4C;QAC1C;QACA,OAAO,CAAC,KAAR,CAAc,gDAAd,EAAgE,GAAhE;MACD;IACF,CAxBH;EAyBD,CAxCD;;EA0CA,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,WAAW,EAAlB,CAA/B;;EAEA,MAAM,OAAO,GAAG,MAAK;IACnB,IAAI,YAAJ,EAAkB;MAChB,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;MACA,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD;;IAED,aAAa,CAAC,OAAd,CAAsB,YAAY,IAAG;MACnC,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD,CAFD;EAGD,CATD;;EAWA,IAAI,YAAJ,EAAkB;IAChB,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;IACA,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;EACD,CA3EkE,CA6EnE;;;EACA,cAAc;EAEd,OAAO;IACL,cADK;IAEL;EAFK,CAAP;AAID","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';\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 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 if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (target instanceof HTMLElement) {\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 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 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"],"sourceRoot":""}
1
+ {"version":3,"sources":["../../../../../../../packages/react-components/react-positioning/src/createPositionManager.ts"],"names":[],"mappings":"AAAA,SAAS,eAAT,QAAgC,kBAAhC;AAGA,SAAS,QAAT,EAAmB,iBAAnB,EAAsC,qBAAtC,EAA6D,eAA7D,QAAoF,SAApF;AA8BA;;;AAGG;;AACH,OAAM,SAAU,qBAAV,CAAgC,OAAhC,EAA+D;EACnE,MAAM;IAAE,SAAF;IAAa,MAAb;IAAqB,KAArB;IAA4B,QAA5B;IAAsC,UAAtC;IAAkD;EAAlD,IAAgE,OAAtE;;EACA,IAAI,CAAC,MAAD,IAAW,CAAC,SAAhB,EAA2B;IACzB,OAAO;MACL,cAAc,EAAE,MAAM,SADjB;MAEL,OAAO,EAAE,MAAM;IAFV,CAAP;EAID;;EAED,IAAI,aAAa,GAAG,IAApB;EACA,MAAM,aAAa,GAAqB,IAAI,GAAJ,EAAxC;EACA,MAAM,YAAY,GAAG,SAAS,CAAC,aAAV,CAAwB,WAA7C,CAXmE,CAanE;EACA;;EACA,MAAM,CAAC,MAAP,CAAc,SAAS,CAAC,KAAxB,EAA+B;IAAE,QAAQ,EAAE,OAAZ;IAAqB,IAAI,EAAE,CAA3B;IAA8B,GAAG,EAAE,CAAnC;IAAsC,MAAM,EAAE;EAA9C,CAA/B;;EAEA,IAAI,WAAW,GAAG,MAAK;I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AAM,WAAW,EAAlB,CAA/B;;EAEA,MAAM,OAAO,GAAG,MAAK;IACnB;IACA;IACA,WAAW,GAAG,MAAM,IAApB;;IAEA,IAAI,YAAJ,EAAkB;MAChB,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;MACA,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD;;IAED,aAAa,CAAC,OAAd,CAAsB,YAAY,IAAG;MACnC,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD,CAFD;EAGD,CAbD;;EAeA,IAAI,YAAJ,EAAkB;IAChB,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;IACA,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;EACD,CA/EkE,CAiFnE;;;EACA,cAAc;EAEd,OAAO;IACL,cADK;IAEL;EAFK,CAAP;AAID","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';\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 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 let forceUpdate = () => {\n if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (target instanceof HTMLElement) {\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 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 // debounced update can still occur afterwards\n // so destroy the reference to forceUpdate\n forceUpdate = () => null;\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"],"sourceRoot":""}
@@ -43,7 +43,7 @@ function createPositionManager(options) {
43
43
  margin: 0
44
44
  });
45
45
 
46
- const forceUpdate = () => {
46
+ let forceUpdate = () => {
47
47
  if (isFirstUpdate) {
48
48
  scrollParents.add(utils_1.getScrollParent(container));
49
49
 
@@ -103,6 +103,10 @@ function createPositionManager(options) {
103
103
  const updatePosition = utils_1.debounce(() => forceUpdate());
104
104
 
105
105
  const dispose = () => {
106
+ // debounced update can still occur afterwards
107
+ // so destroy the reference to forceUpdate
108
+ forceUpdate = () => null;
109
+
106
110
  if (targetWindow) {
107
111
  targetWindow.removeEventListener('scroll', updatePosition);
108
112
  targetWindow.removeEventListener('resize', updatePosition);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/react-components/react-positioning/src/createPositionManager.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAGA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;AA8BA;;;AAGG;;;AACH,SAAgB,qBAAhB,CAAsC,OAAtC,EAAqE;EACnE,MAAM;IAAE,SAAF;IAAa,MAAb;IAAqB,KAArB;IAA4B,QAA5B;IAAsC,UAAtC;IAAkD;EAAlD,IAAgE,OAAtE;;EACA,IAAI,CAAC,MAAD,IAAW,CAAC,SAAhB,EAA2B;IACzB,OAAO;MACL,cAAc,EAAE,MAAM,SADjB;MAEL,OAAO,EAAE,MAAM;IAFV,CAAP;EAID;;EAED,IAAI,aAAa,GAAG,IAApB;EACA,MAAM,aAAa,GAAqB,IAAI,GAAJ,EAAxC;EACA,MAAM,YAAY,GAAG,SAAS,CAAC,aAAV,CAAwB,WAA7C,CAXmE,CAanE;EACA;;EACA,MAAM,CAAC,MAAP,CAAc,SAAS,CAAC,KAAxB,EAA+B;IAAE,QAAQ,EAAE,OAAZ;IAAqB,IAAI,EAAE,CAA3B;IAA8B,GAAG,EAAE,CAAnC;IAAsC,MAAM,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,KAAR,CAAc,gDAAd,EAAgE,GAAhE;MACD;IACF,CAxBH;EAyBD,CAxCD;;EA0CA,MAAM,cAAc,GAAG,OAAA,CAAA,QAAA,CAAS,MAAM,WAAW,EAA1B,CAAvB;;EAEA,MAAM,OAAO,GAAG,MAAK;IACnB,IAAI,YAAJ,EAAkB;MAChB,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;MACA,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD;;IAED,aAAa,CAAC,OAAd,CAAsB,YAAY,IAAG;MACnC,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD,CAFD;EAGD,CATD;;EAWA,IAAI,YAAJ,EAAkB;IAChB,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;IACA,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;EACD,CA3EkE,CA6EnE;;;EACA,cAAc;EAEd,OAAO;IACL,cADK;IAEL;EAFK,CAAP;AAID;;AApFD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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';\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 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 if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (target instanceof HTMLElement) {\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 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 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"],"sourceRoot":""}
1
+ {"version":3,"sources":["../../../../../../../packages/react-components/react-positioning/src/createPositionManager.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAGA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;AA8BA;;;AAGG;;;AACH,SAAgB,qBAAhB,CAAsC,OAAtC,EAAqE;EACnE,MAAM;IAAE,SAAF;IAAa,MAAb;IAAqB,KAArB;IAA4B,QAA5B;IAAsC,UAAtC;IAAkD;EAAlD,IAAgE,OAAtE;;EACA,IAAI,CAAC,MAAD,IAAW,CAAC,SAAhB,EAA2B;IACzB,OAAO;MACL,cAAc,EAAE,MAAM,SADjB;MAEL,OAAO,EAAE,MAAM;IAFV,CAAP;EAID;;EAED,IAAI,aAAa,GAAG,IAApB;EACA,MAAM,aAAa,GAAqB,IAAI,GAAJ,EAAxC;EACA,MAAM,YAAY,GAAG,SAAS,CAAC,aAAV,CAAwB,WAA7C,CAXmE,CAanE;EACA;;EACA,MAAM,CAAC,MAAP,CAAc,SAAS,CAAC,KAAxB,EAA+B;IAAE,QAAQ,EAAE,OAAZ;IAAqB,IAAI,EAAE,CAA3B;IAA8B,GAAG,EAAE,CAAnC;IAAsC,MAAM,EAAE;EAA9C,CAA/B;;EAEA,IAAI,WAAW,GAAG,MAAK;IACrB,IAAI,aAAJ,EAAmB;MACjB,aAAa,CAAC,GAAd,CAAkB,OAAA,CAAA,eAAA,CAAgB,SAAhB,CAAlB;;MACA,IAAI,MAAM,YAAY,WAAtB,EAAmC;QACjC,aAAa,CAAC,GAAd,CAAkB,OAAA,CAAA,eAAA,CAAgB,MAAhB,CAAlB;MACD;;MAED,aAAa,CAAC,OAAd,CAAsB,YAAY,IAAG;QACnC,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;MACD,CA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AC,OAAd,CAAsB,YAAY,IAAG;MACnC,YAAY,CAAC,mBAAb,CAAiC,QAAjC,EAA2C,cAA3C;IACD,CAFD;EAGD,CAbD;;EAeA,IAAI,YAAJ,EAAkB;IAChB,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;IACA,YAAY,CAAC,gBAAb,CAA8B,QAA9B,EAAwC,cAAxC;EACD,CA/EkE,CAiFnE;;;EACA,cAAc;EAEd,OAAO;IACL,cADK;IAEL;EAFK,CAAP;AAID;;AAxFD,OAAA,CAAA,qBAAA,GAAA,qBAAA","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';\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 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 let forceUpdate = () => {\n if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (target instanceof HTMLElement) {\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 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 // debounced update can still occur afterwards\n // so destroy the reference to forceUpdate\n forceUpdate = () => null;\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"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-positioning",
3
- "version": "0.0.0-nightly-20221222-0421.1",
3
+ "version": "0.0.0-nightly-20221226-0422.1",
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",
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@floating-ui/dom": "^1.0.0",
31
- "@fluentui/react-shared-contexts": "0.0.0-nightly-20221222-0421.1",
32
- "@fluentui/react-theme": "0.0.0-nightly-20221222-0421.1",
33
- "@fluentui/react-utilities": "0.0.0-nightly-20221222-0421.1",
31
+ "@fluentui/react-shared-contexts": "0.0.0-nightly-20221226-0422.1",
32
+ "@fluentui/react-theme": "0.0.0-nightly-20221226-0422.1",
33
+ "@fluentui/react-utilities": "0.0.0-nightly-20221226-0422.1",
34
34
  "@griffel/react": "^1.4.2",
35
35
  "tslib": "^2.1.0"
36
36
  },