@fluentui/react-positioning 0.0.0-nightly-20230426-0420.1 → 0.0.0-nightly-20230428-0419.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.
Files changed (68) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/package.json +4 -4
  4. package/dist/index.d.ts +0 -267
  5. package/lib/constants.js +0 -5
  6. package/lib/constants.js.map +0 -1
  7. package/lib/createArrowStyles.js +0 -87
  8. package/lib/createArrowStyles.js.map +0 -1
  9. package/lib/createPositionManager.js +0 -120
  10. package/lib/createPositionManager.js.map +0 -1
  11. package/lib/createVirtualElementFromClick.js +0 -25
  12. package/lib/createVirtualElementFromClick.js.map +0 -1
  13. package/lib/index.js +0 -6
  14. package/lib/index.js.map +0 -1
  15. package/lib/middleware/coverTarget.js +0 -35
  16. package/lib/middleware/coverTarget.js.map +0 -1
  17. package/lib/middleware/flip.js +0 -36
  18. package/lib/middleware/flip.js.map +0 -1
  19. package/lib/middleware/index.js +0 -7
  20. package/lib/middleware/index.js.map +0 -1
  21. package/lib/middleware/intersecting.js +0 -21
  22. package/lib/middleware/intersecting.js.map +0 -1
  23. package/lib/middleware/maxSize.js +0 -38
  24. package/lib/middleware/maxSize.js.map +0 -1
  25. package/lib/middleware/offset.js +0 -10
  26. package/lib/middleware/offset.js.map +0 -1
  27. package/lib/middleware/shift.js +0 -35
  28. package/lib/middleware/shift.js.map +0 -1
  29. package/lib/types.js +0 -2
  30. package/lib/types.js.map +0 -1
  31. package/lib/usePositioning.js +0 -169
  32. package/lib/usePositioning.js.map +0 -1
  33. package/lib/usePositioningMouseTarget.js +0 -34
  34. package/lib/usePositioningMouseTarget.js.map +0 -1
  35. package/lib/utils/debounce.js +0 -20
  36. package/lib/utils/debounce.js.map +0 -1
  37. package/lib/utils/fromFloatingUIPlacement.js +0 -38
  38. package/lib/utils/fromFloatingUIPlacement.js.map +0 -1
  39. package/lib/utils/getBoundary.js +0 -21
  40. package/lib/utils/getBoundary.js.map +0 -1
  41. package/lib/utils/getFloatingUIOffset.js +0 -33
  42. package/lib/utils/getFloatingUIOffset.js.map +0 -1
  43. package/lib/utils/getReactFiberFromNode.js +0 -43
  44. package/lib/utils/getReactFiberFromNode.js.map +0 -1
  45. package/lib/utils/getScrollParent.js +0 -58
  46. package/lib/utils/getScrollParent.js.map +0 -1
  47. package/lib/utils/hasAutoFocusFilter.js +0 -23
  48. package/lib/utils/hasAutoFocusFilter.js.map +0 -1
  49. package/lib/utils/index.js +0 -16
  50. package/lib/utils/index.js.map +0 -1
  51. package/lib/utils/mergeArrowOffset.js +0 -38
  52. package/lib/utils/mergeArrowOffset.js.map +0 -1
  53. package/lib/utils/parseFloatingUIPlacement.js +0 -13
  54. package/lib/utils/parseFloatingUIPlacement.js.map +0 -1
  55. package/lib/utils/resolvePositioningShorthand.js +0 -61
  56. package/lib/utils/resolvePositioningShorthand.js.map +0 -1
  57. package/lib/utils/toFloatingUIPadding.js +0 -23
  58. package/lib/utils/toFloatingUIPadding.js.map +0 -1
  59. package/lib/utils/toFloatingUIPlacement.js +0 -34
  60. package/lib/utils/toFloatingUIPlacement.js.map +0 -1
  61. package/lib/utils/toggleScrollListener.js +0 -22
  62. package/lib/utils/toggleScrollListener.js.map +0 -1
  63. package/lib/utils/useCallbackRef.js +0 -51
  64. package/lib/utils/useCallbackRef.js.map +0 -1
  65. package/lib/utils/writeArrowUpdates.js +0 -20
  66. package/lib/utils/writeArrowUpdates.js.map +0 -1
  67. package/lib/utils/writeContainerupdates.js +0 -43
  68. package/lib/utils/writeContainerupdates.js.map +0 -1
@@ -1,35 +0,0 @@
1
- import { parseFloatingUIPlacement } from '../utils/index';
2
- export function coverTarget() {
3
- return {
4
- name: 'coverTarget',
5
- fn: middlewareArguments => {
6
- const {
7
- placement,
8
- rects,
9
- x,
10
- y
11
- } = middlewareArguments;
12
- const basePlacement = parseFloatingUIPlacement(placement).side;
13
- const newCoords = {
14
- x,
15
- y
16
- };
17
- switch (basePlacement) {
18
- case 'bottom':
19
- newCoords.y -= rects.reference.height;
20
- break;
21
- case 'top':
22
- newCoords.y += rects.reference.height;
23
- break;
24
- case 'left':
25
- newCoords.x += rects.reference.width;
26
- break;
27
- case 'right':
28
- newCoords.x -= rects.reference.width;
29
- break;
30
- }
31
- return newCoords;
32
- }
33
- };
34
- }
35
- //# sourceMappingURL=coverTarget.js.map
@@ -1 +0,0 @@
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,36 +0,0 @@
1
- import { flip as baseFlip } from '@floating-ui/dom';
2
- import { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';
3
- export function flip(options) {
4
- const {
5
- hasScrollableElement,
6
- flipBoundary,
7
- container,
8
- fallbackPositions = [],
9
- isRtl
10
- } = options;
11
- const fallbackPlacements = fallbackPositions.reduce((acc, shorthand) => {
12
- const {
13
- position,
14
- align
15
- } = resolvePositioningShorthand(shorthand);
16
- const placement = toFloatingUIPlacement(align, position, isRtl);
17
- if (placement) {
18
- acc.push(placement);
19
- }
20
- return acc;
21
- }, []);
22
- return baseFlip({
23
- ...(hasScrollableElement && {
24
- boundary: 'clippingAncestors'
25
- }),
26
- ...(flipBoundary && {
27
- altBoundary: true,
28
- boundary: getBoundary(container, flipBoundary)
29
- }),
30
- fallbackStrategy: 'bestFit',
31
- ...(fallbackPlacements.length && {
32
- fallbackPlacements
33
- })
34
- });
35
- }
36
- //# sourceMappingURL=flip.js.map
@@ -1 +0,0 @@
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,7 +0,0 @@
1
- export * from './coverTarget';
2
- export * from './flip';
3
- export * from './intersecting';
4
- export * from './maxSize';
5
- export * from './offset';
6
- export * from './shift';
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,21 +0,0 @@
1
- import { detectOverflow } from '@floating-ui/dom';
2
- export function intersecting() {
3
- return {
4
- name: 'intersectionObserver',
5
- fn: async middlewareArguments => {
6
- const floatingRect = middlewareArguments.rects.floating;
7
- const altOverflow = await detectOverflow(middlewareArguments, {
8
- altBoundary: true
9
- });
10
- const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;
11
- const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;
12
- const isIntersecting = isIntersectingTop || isIntersectingBottom;
13
- return {
14
- data: {
15
- intersecting: isIntersecting
16
- }
17
- };
18
- }
19
- };
20
- }
21
- //# sourceMappingURL=intersecting.js.map
@@ -1 +0,0 @@
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,38 +0,0 @@
1
- import { size } from '@floating-ui/dom';
2
- import { getBoundary } from '../utils/getBoundary';
3
- export function maxSize(autoSize, options) {
4
- const {
5
- container,
6
- overflowBoundary
7
- } = options;
8
- return size({
9
- ...(overflowBoundary && {
10
- altBoundary: true,
11
- boundary: getBoundary(container, overflowBoundary)
12
- }),
13
- apply({
14
- availableHeight,
15
- availableWidth,
16
- elements,
17
- rects
18
- }) {
19
- const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');
20
- const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');
21
- if (applyMaxHeight) {
22
- Object.assign(elements.floating.style, {
23
- maxHeight: `${availableHeight}px`,
24
- boxSizing: 'border-box',
25
- overflowY: 'auto'
26
- });
27
- }
28
- if (applyMaxWidth) {
29
- Object.assign(elements.floating.style, {
30
- maxWidth: `${availableWidth}px`,
31
- boxSizing: 'border-box',
32
- overflowX: 'auto'
33
- });
34
- }
35
- }
36
- });
37
- }
38
- //# sourceMappingURL=maxSize.js.map
@@ -1 +0,0 @@
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,10 +0,0 @@
1
- import { offset as baseOffset } from '@floating-ui/dom';
2
- import { getFloatingUIOffset } from '../utils/getFloatingUIOffset';
3
- /**
4
- * Wraps floating UI offset middleware to to transform offset value
5
- */
6
- export function offset(offsetValue) {
7
- const floatingUIOffset = getFloatingUIOffset(offsetValue);
8
- return baseOffset(floatingUIOffset);
9
- }
10
- //# sourceMappingURL=offset.js.map
@@ -1 +0,0 @@
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,35 +0,0 @@
1
- import { shift as baseShift, limitShift } from '@floating-ui/dom';
2
- import { getBoundary, toFloatingUIPadding } from '../utils/index';
3
- /**
4
- * Wraps the floating UI shift middleware for easier usage of our options
5
- */
6
- export function shift(options) {
7
- const {
8
- hasScrollableElement,
9
- disableTether,
10
- overflowBoundary,
11
- container,
12
- overflowBoundaryPadding,
13
- isRtl
14
- } = options;
15
- return baseShift({
16
- ...(hasScrollableElement && {
17
- boundary: 'clippingAncestors'
18
- }),
19
- ...(disableTether && {
20
- crossAxis: disableTether === 'all',
21
- limiter: limitShift({
22
- crossAxis: disableTether !== 'all',
23
- mainAxis: false
24
- })
25
- }),
26
- ...(overflowBoundaryPadding && {
27
- padding: toFloatingUIPadding(overflowBoundaryPadding, isRtl)
28
- }),
29
- ...(overflowBoundary && {
30
- altBoundary: true,
31
- boundary: getBoundary(container, overflowBoundary)
32
- })
33
- });
34
- }
35
- //# sourceMappingURL=shift.js.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
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"}
@@ -1,169 +0,0 @@
1
- import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';
2
- import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
3
- import { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
4
- import * as React from 'react';
5
- import { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';
6
- import { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';
7
- import { createPositionManager } from './createPositionManager';
8
- /**
9
- * @internal
10
- */
11
- export function usePositioning(options) {
12
- const managerRef = React.useRef(null);
13
- const targetRef = React.useRef(null);
14
- const overrideTargetRef = React.useRef(null);
15
- const containerRef = React.useRef(null);
16
- const arrowRef = React.useRef(null);
17
- const {
18
- enabled = true
19
- } = options;
20
- const resolvePositioningOptions = usePositioningOptions(options);
21
- const updatePositionManager = React.useCallback(() => {
22
- if (managerRef.current) {
23
- managerRef.current.dispose();
24
- }
25
- managerRef.current = null;
26
- var _overrideTargetRef_current;
27
- const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;
28
- if (enabled && canUseDOM() && target && containerRef.current) {
29
- managerRef.current = createPositionManager({
30
- container: containerRef.current,
31
- target,
32
- arrow: arrowRef.current,
33
- ...resolvePositioningOptions(containerRef.current, arrowRef.current)
34
- });
35
- }
36
- }, [enabled, resolvePositioningOptions]);
37
- const setOverrideTarget = useEventCallback(target => {
38
- overrideTargetRef.current = target;
39
- updatePositionManager();
40
- });
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);
56
- }
57
- };
58
- }, [options.target, setOverrideTarget]);
59
- useIsomorphicLayoutEffect(() => {
60
- var _options_target;
61
- setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);
62
- }, [options.target, setOverrideTarget]);
63
- useIsomorphicLayoutEffect(() => {
64
- updatePositionManager();
65
- }, [updatePositionManager]);
66
- if (process.env.NODE_ENV !== 'production') {
67
- // This checked should run only in development mode
68
- // eslint-disable-next-line react-hooks/rules-of-hooks
69
- React.useEffect(() => {
70
- if (containerRef.current) {
71
- var _contentNode_ownerDocument;
72
- const contentNode = containerRef.current;
73
- const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {
74
- acceptNode: hasAutofocusFilter
75
- });
76
- while (treeWalker.nextNode()) {
77
- const node = treeWalker.currentNode;
78
- // eslint-disable-next-line no-console
79
- console.warn('<Popper>:', node);
80
- // eslint-disable-next-line no-console
81
- console.warn(['<Popper>: ^ this node contains "autoFocus" prop on a React element. This can break the initial', 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills', '"autoFocus" behavior to solve inconsistencies between different browsers:', 'https://github.com/facebook/react/issues/11851#issuecomment-351787078', '\n', 'However, ".focus()" in this case occurs before any other React effects will be executed', '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really', 'want to use "autoFocus" please add "position: fixed" to styles of the element that is wrapped by', '"Popper".', `In general, it's not recommended to use "autoFocus" as it may break accessibility aspects:`, 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md', '\n', 'We suggest to use the "trapFocus" prop on Fluent components or a catch "ref" and then use', '"ref.current.focus" in React.useEffect():', 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'].join(' '));
82
- }
83
- }
84
- // We run this check once, no need to add deps here
85
- // TODO: Should be rework to handle options.enabled and contentRef updates
86
- // eslint-disable-next-line react-hooks/exhaustive-deps
87
- }, []);
88
- }
89
- const setTarget = useCallbackRef(null, target => {
90
- if (targetRef.current !== target) {
91
- targetRef.current = target;
92
- updatePositionManager();
93
- }
94
- });
95
- const setContainer = useCallbackRef(null, container => {
96
- if (containerRef.current !== container) {
97
- containerRef.current = container;
98
- updatePositionManager();
99
- }
100
- });
101
- const setArrow = useCallbackRef(null, arrow => {
102
- if (arrowRef.current !== arrow) {
103
- arrowRef.current = arrow;
104
- updatePositionManager();
105
- }
106
- });
107
- // Let users use callback refs so they feel like 'normal' DOM refs
108
- return {
109
- targetRef: setTarget,
110
- containerRef: setContainer,
111
- arrowRef: setArrow
112
- };
113
- }
114
- function usePositioningOptions(options) {
115
- const {
116
- align,
117
- arrowPadding,
118
- autoSize,
119
- coverTarget,
120
- flipBoundary,
121
- offset,
122
- overflowBoundary,
123
- pinned,
124
- position,
125
- unstable_disableTether: disableTether,
126
- positionFixed,
127
- overflowBoundaryPadding,
128
- fallbackPositions
129
- } = options;
130
- const {
131
- dir
132
- } = useFluent();
133
- const isRtl = dir === 'rtl';
134
- const strategy = positionFixed ? 'fixed' : 'absolute';
135
- return React.useCallback((container, arrow) => {
136
- const hasScrollableElement = hasScrollParent(container);
137
- const middleware = [offset && offsetMiddleware(offset), coverTarget && coverTargetMiddleware(), !pinned && flipMiddleware({
138
- container,
139
- flipBoundary,
140
- hasScrollableElement,
141
- isRtl,
142
- fallbackPositions
143
- }), shiftMiddleware({
144
- container,
145
- hasScrollableElement,
146
- overflowBoundary,
147
- disableTether,
148
- overflowBoundaryPadding,
149
- isRtl
150
- }), autoSize && maxSizeMiddleware(autoSize, {
151
- container,
152
- overflowBoundary
153
- }), intersectingMiddleware(), arrow && arrowMiddleware({
154
- element: arrow,
155
- padding: arrowPadding
156
- }), hideMiddleware({
157
- strategy: 'referenceHidden'
158
- }), hideMiddleware({
159
- strategy: 'escaped'
160
- })].filter(Boolean);
161
- const placement = toFloatingUIPlacement(align, position, isRtl);
162
- return {
163
- placement,
164
- middleware,
165
- strategy
166
- };
167
- }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy, overflowBoundaryPadding, fallbackPositions]);
168
- }
169
- //# sourceMappingURL=usePositioning.js.map
@@ -1 +0,0 @@
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":"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"}
@@ -1,34 +0,0 @@
1
- import * as React from 'react';
2
- import { createVirtualElementFromClick } from './createVirtualElementFromClick';
3
- /**
4
- * @internal
5
- * A state hook that manages a popper virtual element from mouseevents.
6
- * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
7
- * React synthetic events are not persisted by this hook
8
- *
9
- * @param initialState - initializes a user provided state similare to useState
10
- * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
11
- */
12
- export const usePositioningMouseTarget = initialState => {
13
- const [virtualElement, setVirtualElement] = React.useState(initialState);
14
- const setVirtualMouseTarget = event => {
15
- if (event === undefined || event === null) {
16
- setVirtualElement(undefined);
17
- return;
18
- }
19
- let mouseevent;
20
- if (!(event instanceof MouseEvent)) {
21
- mouseevent = event.nativeEvent;
22
- } else {
23
- mouseevent = event;
24
- }
25
- if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
26
- // eslint-disable-next-line no-console
27
- console.error('usePositioningMouseTarget should only be used with MouseEvent');
28
- }
29
- const contextTarget = createVirtualElementFromClick(mouseevent);
30
- setVirtualElement(contextTarget);
31
- };
32
- return [virtualElement, setVirtualMouseTarget];
33
- };
34
- //# sourceMappingURL=usePositioningMouseTarget.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","createVirtualElementFromClick","usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget"],"sources":["../src/usePositioningMouseTarget.ts"],"sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\nimport { PositioningVirtualElement, SetVirtualMouseTarget } from './types';\n\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */\nexport const usePositioningMouseTarget = (\n initialState?: PositioningVirtualElement | (() => PositioningVirtualElement),\n) => {\n const [virtualElement, setVirtualElement] = React.useState<PositioningVirtualElement | undefined>(initialState);\n\n const setVirtualMouseTarget: SetVirtualMouseTarget = event => {\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n\n let mouseevent: MouseEvent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n\n return [virtualElement, setVirtualMouseTarget] as const;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,6BAA6B,QAAQ;AAG9C;;;;;;;;;AASA,OAAO,MAAMC,yBAAA,GACXC,YAAA,IACG;EACH,MAAM,CAACC,cAAA,EAAgBC,iBAAA,CAAkB,GAAGL,KAAA,CAAMM,QAAQ,CAAwCH,YAAA;EAElG,MAAMI,qBAAA,GAA+CC,KAAA,IAAS;IAC5D,IAAIA,KAAA,KAAUC,SAAA,IAAaD,KAAA,KAAU,IAAI,EAAE;MACzCH,iBAAA,CAAkBI,SAAA;MAClB;IACF;IAEA,IAAIC,UAAA;IACJ,IAAI,EAAEF,KAAA,YAAiBG,UAAS,GAAI;MAClCD,UAAA,GAAaF,KAAA,CAAMI,WAAW;IAChC,OAAO;MACLF,UAAA,GAAaF,KAAA;IACf;IAEA,IAAI,EAAEE,UAAA,YAAsBC,UAAS,KAAME,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;MAChF;MACAC,OAAA,CAAQC,KAAK,CAAC;IAChB;IAEA,MAAMC,aAAA,GAAgBjB,6BAAA,CAA8BS,UAAA;IACpDL,iBAAA,CAAkBa,aAAA;EACpB;EAEA,OAAO,CAACd,cAAA,EAAgBG,qBAAA,CAAsB;AAChD"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Promise microtask debouncer used by Popper.js v2
3
- * This is no longer exported in Floating UI (Popper.js v3)
4
- * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
5
- * @param fn function that will be debounced
6
- */export function debounce(fn) {
7
- let pending;
8
- return () => {
9
- if (!pending) {
10
- pending = new Promise(resolve => {
11
- Promise.resolve().then(() => {
12
- pending = undefined;
13
- resolve(fn());
14
- });
15
- });
16
- }
17
- return pending;
18
- };
19
- }
20
- //# sourceMappingURL=debounce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["debounce","fn","pending","Promise","resolve","then","undefined"],"sources":["../../src/utils/debounce.ts"],"sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */\nexport function debounce<T>(fn: Function): () => Promise<T> {\n let pending: Promise<T> | undefined;\n return () => {\n if (!pending) {\n pending = new Promise<T>(resolve => {\n Promise.resolve().then(() => {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}\n"],"mappings":"AAAA;;;;;GAMA,OAAO,SAASA,SAAYC,EAAY,EAAoB;EAC1D,IAAIC,OAAA;EACJ,OAAO,MAAM;IACX,IAAI,CAACA,OAAA,EAAS;MACZA,OAAA,GAAU,IAAIC,OAAA,CAAWC,OAAA,IAAW;QAClCD,OAAA,CAAQC,OAAO,GAAGC,IAAI,CAAC,MAAM;UAC3BH,OAAA,GAAUI,SAAA;UACVF,OAAA,CAAQH,EAAA;QACV;MACF;IACF;IAEA,OAAOC,OAAA;EACT;AACF"}
@@ -1,38 +0,0 @@
1
- import { parseFloatingUIPlacement } from './parseFloatingUIPlacement';
2
- const getPositionMap = () => ({
3
- top: 'above',
4
- bottom: 'below',
5
- right: 'after',
6
- left: 'before'
7
- });
8
- // Floating UI automatically flips alignment
9
- // https://github.com/floating-ui/floating-ui/issues/1563
10
- const getAlignmentMap = position => {
11
- if (position === 'above' || position === 'below') {
12
- return {
13
- start: 'start',
14
- end: 'end'
15
- };
16
- }
17
- return {
18
- start: 'top',
19
- end: 'bottom'
20
- };
21
- };
22
- /**
23
- * Maps Floating UI placement to positioning values
24
- * @see positioningHelper.test.ts for expected placement values
25
- */
26
- export const fromFloatingUIPlacement = placement => {
27
- const {
28
- side,
29
- alignment: floatingUIAlignment
30
- } = parseFloatingUIPlacement(placement);
31
- const position = getPositionMap()[side];
32
- const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];
33
- return {
34
- position,
35
- alignment
36
- };
37
- };
38
- //# sourceMappingURL=fromFloatingUIPlacement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["parseFloatingUIPlacement","getPositionMap","top","bottom","right","left","getAlignmentMap","position","start","end","fromFloatingUIPlacement","placement","side","alignment","floatingUIAlignment"],"sources":["../../src/utils/fromFloatingUIPlacement.ts"],"sourcesContent":["import type { Side, Alignment as FloatingUIAlignment, Placement } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\nimport { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\n\nconst getPositionMap = (): Record<Side, Position> => ({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position: Position): Record<FloatingUIAlignment, Alignment> => {\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end',\n };\n }\n\n return {\n start: 'top',\n end: 'bottom',\n };\n};\n\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } => {\n const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n\n return { position, alignment };\n};\n"],"mappings":"AAEA,SAASA,wBAAwB,QAAQ;AAEzC,MAAMC,cAAA,GAAiBA,CAAA,MAA+B;EACpDC,GAAA,EAAK;EACLC,MAAA,EAAQ;EACRC,KAAA,EAAO;EACPC,IAAA,EAAM;AACR;AAEA;AACA;AACA,MAAMC,eAAA,GAAmBC,QAAA,IAA+D;EACtF,IAAIA,QAAA,KAAa,WAAWA,QAAA,KAAa,SAAS;IAChD,OAAO;MACLC,KAAA,EAAO;MACPC,GAAA,EAAK;IACP;EACF;EAEA,OAAO;IACLD,KAAA,EAAO;IACPC,GAAA,EAAK;EACP;AACF;AAEA;;;;AAIA,OAAO,MAAMC,uBAAA,GAA2BC,SAAA,IAAwE;EAC9G,MAAM;IAAEC,IAAA;IAAMC,SAAA,EAAWC;EAAmB,CAAE,GAAGd,wBAAA,CAAyBW,SAAA;EAC1E,MAAMJ,QAAA,GAAWN,cAAA,EAAgB,CAACW,IAAA,CAAK;EACvC,MAAMC,SAAA,GAAYC,mBAAA,IAAuBR,eAAA,CAAgBC,QAAA,CAAS,CAACO,mBAAA,CAAoB;EAEvF,OAAO;IAAEP,QAAA;IAAUM;EAAU;AAC/B"}
@@ -1,21 +0,0 @@
1
- import { getScrollParent } from './getScrollParent';
2
- /**
3
- * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
4
- */
5
- export function getBoundary(element, boundary) {
6
- if (boundary === 'window') {
7
- return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
8
- }
9
- if (boundary === 'clippingParents') {
10
- return 'clippingAncestors';
11
- }
12
- if (boundary === 'scrollParent') {
13
- let boundariesNode = getScrollParent(element);
14
- if (boundariesNode.nodeName === 'BODY') {
15
- boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
16
- }
17
- return boundariesNode;
18
- }
19
- return boundary;
20
- }
21
- //# sourceMappingURL=getBoundary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getScrollParent","getBoundary","element","boundary","ownerDocument","documentElement","boundariesNode","nodeName"],"sources":["../../src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { Boundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport function getBoundary(element: HTMLElement | null, boundary?: Boundary): FloatingUIBoundary | undefined {\n if (boundary === 'window') {\n return element?.ownerDocument!.documentElement;\n }\n\n if (boundary === 'clippingParents') {\n return 'clippingAncestors';\n }\n\n if (boundary === 'scrollParent') {\n let boundariesNode: HTMLElement | undefined = getScrollParent(element);\n\n if (boundariesNode.nodeName === 'BODY') {\n boundariesNode = element?.ownerDocument!.documentElement;\n }\n\n return boundariesNode;\n }\n\n return boundary;\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ;AAGhC;;;AAGA,OAAO,SAASC,YAAYC,OAA2B,EAAEC,QAAmB,EAAkC;EAC5G,IAAIA,QAAA,KAAa,UAAU;IACzB,OAAOD,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASE,aAAa,CAAEC,eAAe;EAChD;EAEA,IAAIF,QAAA,KAAa,mBAAmB;IAClC,OAAO;EACT;EAEA,IAAIA,QAAA,KAAa,gBAAgB;IAC/B,IAAIG,cAAA,GAA0CN,eAAA,CAAgBE,OAAA;IAE9D,IAAII,cAAA,CAAeC,QAAQ,KAAK,QAAQ;MACtCD,cAAA,GAAiBJ,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASE,aAAa,CAAEC,eAAe;IAC1D;IAEA,OAAOC,cAAA;EACT;EAEA,OAAOH,QAAA;AACT"}