@fluentui/react-positioning 9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 → 9.75.2-experimental.css-modules.20261113-ba13c87438.0

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 (111) hide show
  1. package/CHANGELOG.md +7 -7
  2. package/README.md +7 -130
  3. package/lib/Arrow.module.css +43 -0
  4. package/lib/PositioningConfigurationContext.js +2 -1
  5. package/lib/PositioningConfigurationContext.js.map +1 -1
  6. package/lib/createPositionManager.js +82 -74
  7. package/lib/createPositionManager.js.map +1 -1
  8. package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
  9. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +9 -0
  10. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +1 -0
  11. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +9 -0
  12. package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +1 -0
  13. package/lib/middleware/flip.js +1 -1
  14. package/lib/middleware/flip.js.map +1 -1
  15. package/lib/middleware/intersecting.js +1 -1
  16. package/lib/middleware/intersecting.js.map +1 -1
  17. package/lib/middleware/maxSize.js +1 -1
  18. package/lib/middleware/maxSize.js.map +1 -1
  19. package/lib/middleware/offset.js +1 -1
  20. package/lib/middleware/offset.js.map +1 -1
  21. package/lib/middleware/shift.js +1 -1
  22. package/lib/middleware/shift.js.map +1 -1
  23. package/lib/usePositioning.js +48 -38
  24. package/lib/usePositioning.js.map +1 -1
  25. package/lib/usePositioningOptions.js +117 -25
  26. package/lib/usePositioningOptions.js.map +1 -1
  27. package/lib/utils/createResizeObserver.js +2 -2
  28. package/lib/utils/createResizeObserver.js.map +1 -1
  29. package/lib/utils/debounce.js +13 -6
  30. package/lib/utils/debounce.js.map +1 -1
  31. package/lib/utils/fromFloatingUIPlacement.js +29 -10
  32. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  33. package/lib/utils/getBoundary.js +17 -8
  34. package/lib/utils/getBoundary.js.map +1 -1
  35. package/lib/utils/index.js +2 -0
  36. package/lib/utils/index.js.map +1 -1
  37. package/lib/utils/listScrollParents.js +20 -12
  38. package/lib/utils/listScrollParents.js.map +1 -1
  39. package/lib/utils/normalizeAutoSize.js +22 -15
  40. package/lib/utils/normalizeAutoSize.js.map +1 -1
  41. package/lib/utils/toFloatingUIPlacement.js +26 -9
  42. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  43. package/lib/utils/useCallbackRef.js +10 -1
  44. package/lib/utils/useCallbackRef.js.map +1 -1
  45. package/lib/utils/writeArrowUpdates.js +13 -0
  46. package/lib/utils/writeArrowUpdates.js.map +1 -0
  47. package/lib/utils/writeContainerupdates.js +43 -0
  48. package/lib/utils/writeContainerupdates.js.map +1 -0
  49. package/lib-commonjs/Arrow.module.css +43 -0
  50. package/lib-commonjs/PositioningConfigurationContext.cjs +2 -1
  51. package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
  52. package/lib-commonjs/createPositionManager.cjs +80 -72
  53. package/lib-commonjs/createPositionManager.cjs.map +1 -1
  54. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +26 -0
  55. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +20 -0
  56. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +1 -0
  57. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +20 -0
  58. package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +1 -0
  59. package/lib-commonjs/middleware/flip.cjs +6 -6
  60. package/lib-commonjs/middleware/flip.cjs.map +1 -1
  61. package/lib-commonjs/middleware/intersecting.cjs +2 -2
  62. package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
  63. package/lib-commonjs/middleware/maxSize.cjs +4 -4
  64. package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
  65. package/lib-commonjs/middleware/offset.cjs +2 -2
  66. package/lib-commonjs/middleware/offset.cjs.map +1 -1
  67. package/lib-commonjs/middleware/shift.cjs +7 -7
  68. package/lib-commonjs/middleware/shift.cjs.map +1 -1
  69. package/lib-commonjs/usePositioning.cjs +46 -37
  70. package/lib-commonjs/usePositioning.cjs.map +1 -1
  71. package/lib-commonjs/usePositioningOptions.cjs +112 -24
  72. package/lib-commonjs/usePositioningOptions.cjs.map +1 -1
  73. package/lib-commonjs/utils/createResizeObserver.cjs +2 -2
  74. package/lib-commonjs/utils/createResizeObserver.cjs.map +1 -1
  75. package/lib-commonjs/utils/debounce.cjs +13 -6
  76. package/lib-commonjs/utils/debounce.cjs.map +1 -1
  77. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs +32 -21
  78. package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
  79. package/lib-commonjs/utils/getBoundary.cjs +17 -8
  80. package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
  81. package/lib-commonjs/utils/index.cjs +8 -0
  82. package/lib-commonjs/utils/index.cjs.map +1 -1
  83. package/lib-commonjs/utils/listScrollParents.cjs +20 -12
  84. package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
  85. package/lib-commonjs/utils/normalizeAutoSize.cjs +25 -26
  86. package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
  87. package/lib-commonjs/utils/toFloatingUIPlacement.cjs +27 -13
  88. package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
  89. package/lib-commonjs/utils/useCallbackRef.cjs +9 -1
  90. package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
  91. package/lib-commonjs/utils/writeArrowUpdates.cjs +23 -0
  92. package/lib-commonjs/utils/writeArrowUpdates.cjs.map +1 -0
  93. package/lib-commonjs/utils/writeContainerupdates.cjs +51 -0
  94. package/lib-commonjs/utils/writeContainerupdates.cjs.map +1 -0
  95. package/package.json +9 -5
  96. package/lib/engine/computePosition.js +0 -258
  97. package/lib/engine/computePosition.js.map +0 -1
  98. package/lib/engine/index.js +0 -260
  99. package/lib/engine/index.js.map +0 -1
  100. package/lib/engine/platform.js +0 -209
  101. package/lib/engine/platform.js.map +0 -1
  102. package/lib/usePositioning.raster.js +0 -45
  103. package/lib/usePositioning.raster.js.map +0 -1
  104. package/lib-commonjs/engine/computePosition.cjs +0 -265
  105. package/lib-commonjs/engine/computePosition.cjs.map +0 -1
  106. package/lib-commonjs/engine/index.cjs +0 -290
  107. package/lib-commonjs/engine/index.cjs.map +0 -1
  108. package/lib-commonjs/engine/platform.cjs +0 -264
  109. package/lib-commonjs/engine/platform.cjs.map +0 -1
  110. package/lib-commonjs/usePositioning.raster.cjs +0 -49
  111. package/lib-commonjs/usePositioning.raster.cjs.map +0 -1
@@ -1,10 +1,19 @@
1
- import { getRoot } from "../engine/platform.js";
2
- import { listScrollParents } from "./listScrollParents.js";
1
+ import { getScrollParent } from "./getScrollParent.js";
3
2
  /**
4
3
  * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
5
- */ export const getBoundary = (element, boundary)=>{
6
- const root = element ? getRoot(element) : undefined;
7
- // The closest scroll parent, the root when it's the body
8
- const scrollParent = boundary === 'scrollParent' && element && listScrollParents(element)[0];
9
- return boundary === 'clippingParents' ? 'clippingAncestors' : boundary === 'window' || boundary === 'scrollParent' ? scrollParent && scrollParent.nodeName !== 'BODY' && scrollParent || root : boundary;
10
- };
4
+ */ export function getBoundary(element, boundary) {
5
+ if (boundary === 'window') {
6
+ return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
7
+ }
8
+ if (boundary === 'clippingParents') {
9
+ return 'clippingAncestors';
10
+ }
11
+ if (boundary === 'scrollParent') {
12
+ let boundariesNode = getScrollParent(element);
13
+ if (boundariesNode.nodeName === 'BODY') {
14
+ boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
15
+ }
16
+ return boundariesNode;
17
+ }
18
+ return boundary;
19
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getRoot } from '../engine/platform';\nimport { listScrollParents } from './listScrollParents';\nimport type { PositioningBoundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport const getBoundary = (\n element: HTMLElement | null,\n boundary?: PositioningBoundary,\n): FloatingUIBoundary | undefined => {\n const root = element ? getRoot(element) : undefined;\n // The closest scroll parent, the root when it's the body\n const scrollParent = boundary === 'scrollParent' && element && listScrollParents(element)[0];\n\n return boundary === 'clippingParents'\n ? 'clippingAncestors'\n : boundary === 'window' || boundary === 'scrollParent'\n ? (scrollParent && scrollParent.nodeName !== 'BODY' && scrollParent) || root\n : boundary;\n};\n"],"names":["getRoot","listScrollParents","getBoundary","element","boundary","root","undefined","scrollParent","nodeName"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAqB;AAC7C,SAASC,iBAAiB,QAAQ,yBAAsB;AAGxD;;CAEC,GACD,OAAO,MAAMC,cAAc,CACzBC,SACAC;IAEA,MAAMC,OAAOF,UAAUH,QAAQG,WAAWG;IAC1C,yDAAyD;IACzD,MAAMC,eAAeH,aAAa,kBAAkBD,WAAWF,kBAAkBE,QAAQ,CAAC,EAAE;IAE5F,OAAOC,aAAa,oBAChB,sBACAA,aAAa,YAAYA,aAAa,iBACtC,AAACG,gBAAgBA,aAAaC,QAAQ,KAAK,UAAUD,gBAAiBF,OACtED;AACN,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getScrollParent } from './getScrollParent';\nimport type { PositioningBoundary } 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(\n element: HTMLElement | null,\n boundary?: PositioningBoundary,\n): 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"],"names":["getScrollParent","getBoundary","element","boundary","ownerDocument","documentElement","boundariesNode","nodeName"],"mappings":"AAEA,SAASA,eAAe,QAAQ,uBAAoB;AAGpD;;CAEC,GACD,OAAO,SAASC,YACdC,OAA2B,EAC3BC,QAA8B;IAE9B,IAAIA,aAAa,UAAU;QACzB,OAAOD,oBAAAA,8BAAAA,QAASE,aAAa,CAAEC,eAAe;IAChD;IAEA,IAAIF,aAAa,mBAAmB;QAClC,OAAO;IACT;IAEA,IAAIA,aAAa,gBAAgB;QAC/B,IAAIG,iBAA0CN,gBAAgBE;QAE9D,IAAII,eAAeC,QAAQ,KAAK,QAAQ;YACtCD,iBAAiBJ,oBAAAA,8BAAAA,QAASE,aAAa,CAAEC,eAAe;QAC1D;QAEA,OAAOC;IACT;IAEA,OAAOH;AACT"}
@@ -11,4 +11,6 @@ export { useCallbackRef } from "./useCallbackRef.js";
11
11
  export { debounce } from "./debounce.js";
12
12
  export { toggleScrollListener } from "./toggleScrollListener.js";
13
13
  export { hasAutofocusFilter } from "./hasAutoFocusFilter.js";
14
+ export { writeArrowUpdates } from "./writeArrowUpdates.js";
15
+ export { writeContainerUpdates } from "./writeContainerupdates.js";
14
16
  export { normalizeAutoSize } from "./normalizeAutoSize.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\nexport { getBoundary } from './getBoundary';\nexport type { Fiber, HookType } from './getReactFiberFromNode';\nexport { getReactFiberFromNode } from './getReactFiberFromNode';\nexport { getParentNode, getScrollParent, hasScrollParent } from './getScrollParent';\nexport { mergeArrowOffset } from './mergeArrowOffset';\nexport { toFloatingUIPadding } from './toFloatingUIPadding';\nexport { toFloatingUIPlacement } from './toFloatingUIPlacement';\nexport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\nexport { resolvePositioningShorthand } from './resolvePositioningShorthand';\nexport { useCallbackRef } from './useCallbackRef';\nexport { debounce } from './debounce';\nexport { toggleScrollListener } from './toggleScrollListener';\nexport { hasAutofocusFilter } from './hasAutoFocusFilter';\nexport { normalizeAutoSize } from './normalizeAutoSize';\n"],"names":["parseFloatingUIPlacement","getBoundary","getReactFiberFromNode","getParentNode","getScrollParent","hasScrollParent","mergeArrowOffset","toFloatingUIPadding","toFloatingUIPlacement","fromFloatingUIPlacement","resolvePositioningShorthand","useCallbackRef","debounce","toggleScrollListener","hasAutofocusFilter","normalizeAutoSize"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,gCAA6B;AACtE,SAASC,WAAW,QAAQ,mBAAgB;AAE5C,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,aAAa,EAAEC,eAAe,EAAEC,eAAe,QAAQ,uBAAoB;AACpF,SAASC,gBAAgB,QAAQ,wBAAqB;AACtD,SAASC,mBAAmB,QAAQ,2BAAwB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,uBAAuB,QAAQ,+BAA4B;AACpE,SAASC,2BAA2B,QAAQ,mCAAgC;AAC5E,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,QAAQ,QAAQ,gBAAa;AACtC,SAASC,oBAAoB,QAAQ,4BAAyB;AAC9D,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,iBAAiB,QAAQ,yBAAsB"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\nexport { getBoundary } from './getBoundary';\nexport type { Fiber, HookType } from './getReactFiberFromNode';\nexport { getReactFiberFromNode } from './getReactFiberFromNode';\nexport { getParentNode, getScrollParent, hasScrollParent } from './getScrollParent';\nexport { mergeArrowOffset } from './mergeArrowOffset';\nexport { toFloatingUIPadding } from './toFloatingUIPadding';\nexport { toFloatingUIPlacement } from './toFloatingUIPlacement';\nexport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\nexport { resolvePositioningShorthand } from './resolvePositioningShorthand';\nexport { useCallbackRef } from './useCallbackRef';\nexport { debounce } from './debounce';\nexport { toggleScrollListener } from './toggleScrollListener';\nexport { hasAutofocusFilter } from './hasAutoFocusFilter';\nexport { writeArrowUpdates } from './writeArrowUpdates';\nexport { writeContainerUpdates } from './writeContainerupdates';\nexport { normalizeAutoSize } from './normalizeAutoSize';\n"],"names":["parseFloatingUIPlacement","getBoundary","getReactFiberFromNode","getParentNode","getScrollParent","hasScrollParent","mergeArrowOffset","toFloatingUIPadding","toFloatingUIPlacement","fromFloatingUIPlacement","resolvePositioningShorthand","useCallbackRef","debounce","toggleScrollListener","hasAutofocusFilter","writeArrowUpdates","writeContainerUpdates","normalizeAutoSize"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,gCAA6B;AACtE,SAASC,WAAW,QAAQ,mBAAgB;AAE5C,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,aAAa,EAAEC,eAAe,EAAEC,eAAe,QAAQ,uBAAoB;AACpF,SAASC,gBAAgB,QAAQ,wBAAqB;AACtD,SAASC,mBAAmB,QAAQ,2BAAwB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,uBAAuB,QAAQ,+BAA4B;AACpE,SAASC,2BAA2B,QAAQ,mCAAgC;AAC5E,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,QAAQ,QAAQ,gBAAa;AACtC,SAASC,oBAAoB,QAAQ,4BAAyB;AAC9D,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,iBAAiB,QAAQ,yBAAsB;AACxD,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,iBAAiB,QAAQ,yBAAsB"}
@@ -1,14 +1,22 @@
1
- import { findAncestor } from "../engine/platform.js";
2
- /** Lists the scroll parents of the node, the closest first, up to and including the body of its document */ export const listScrollParents = (node)=>{
3
- const body = node.ownerDocument.body;
1
+ import { getScrollParent } from "./getScrollParent.js";
2
+ export function listScrollParents(node) {
4
3
  const scrollParents = [];
5
- findAncestor(node, (parent, { overflow, overflowX, overflowY })=>{
6
- if (parent !== body && /auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {
7
- scrollParents.push(parent);
4
+ let cur = node;
5
+ while(cur){
6
+ const scrollParent = getScrollParent(cur);
7
+ if (node.ownerDocument.body === scrollParent) {
8
+ scrollParents.push(scrollParent);
9
+ break;
8
10
  }
9
- });
10
- return [
11
- ...scrollParents,
12
- body
13
- ];
14
- };
11
+ if (scrollParent.nodeName === 'BODY' && scrollParent !== node.ownerDocument.body) {
12
+ if (process.env.NODE_ENV !== 'production') {
13
+ // eslint-disable-next-line no-console
14
+ console.error('@fluentui/react-positioning: You are comparing two different documents! This is an unexpected error, please report this as a bug to the Fluent UI team ');
15
+ }
16
+ break;
17
+ }
18
+ scrollParents.push(scrollParent);
19
+ cur = scrollParent;
20
+ }
21
+ return scrollParents;
22
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/listScrollParents.ts"],"sourcesContent":["import { findAncestor } from '../engine/platform';\n\n/** Lists the scroll parents of the node, the closest first, up to and including the body of its document */\nexport const listScrollParents = (node: HTMLElement): HTMLElement[] => {\n const body = node.ownerDocument.body;\n const scrollParents: HTMLElement[] = [];\n\n findAncestor(node, (parent, { overflow, overflowX, overflowY }) => {\n if (parent !== body && /auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {\n scrollParents.push(parent as HTMLElement);\n }\n });\n\n return [...scrollParents, body];\n};\n"],"names":["findAncestor","listScrollParents","node","body","ownerDocument","scrollParents","parent","overflow","overflowX","overflowY","test","push"],"mappings":"AAAA,SAASA,YAAY,QAAQ,wBAAqB;AAElD,0GAA0G,GAC1G,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAMC,OAAOD,KAAKE,aAAa,CAACD,IAAI;IACpC,MAAME,gBAA+B,EAAE;IAEvCL,aAAaE,MAAM,CAACI,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,SAAS,EAAE;QAC5D,IAAIH,WAAWH,QAAQ,sBAAsBO,IAAI,CAACH,WAAWE,YAAYD,YAAY;YACnFH,cAAcM,IAAI,CAACL;QACrB;IACF;IAEA,OAAO;WAAID;QAAeF;KAAK;AACjC,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/listScrollParents.ts"],"sourcesContent":["import { getScrollParent } from './getScrollParent';\n\nexport function listScrollParents(node: HTMLElement): HTMLElement[] {\n const scrollParents: HTMLElement[] = [];\n\n let cur: HTMLElement | null = node;\n while (cur) {\n const scrollParent = getScrollParent(cur);\n\n if (node.ownerDocument.body === scrollParent) {\n scrollParents.push(scrollParent);\n break;\n }\n\n if (scrollParent.nodeName === 'BODY' && scrollParent !== node.ownerDocument.body) {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(\n '@fluentui/react-positioning: You are comparing two different documents! This is an unexpected error, please report this as a bug to the Fluent UI team ',\n );\n }\n break;\n }\n\n scrollParents.push(scrollParent);\n cur = scrollParent;\n }\n\n return scrollParents;\n}\n"],"names":["getScrollParent","listScrollParents","node","scrollParents","cur","scrollParent","ownerDocument","body","push","nodeName","process","env","NODE_ENV","console","error"],"mappings":"AAAA,SAASA,eAAe,QAAQ,uBAAoB;AAEpD,OAAO,SAASC,kBAAkBC,IAAiB;IACjD,MAAMC,gBAA+B,EAAE;IAEvC,IAAIC,MAA0BF;IAC9B,MAAOE,IAAK;QACV,MAAMC,eAAeL,gBAAgBI;QAErC,IAAIF,KAAKI,aAAa,CAACC,IAAI,KAAKF,cAAc;YAC5CF,cAAcK,IAAI,CAACH;YACnB;QACF;QAEA,IAAIA,aAAaI,QAAQ,KAAK,UAAUJ,iBAAiBH,KAAKI,aAAa,CAACC,IAAI,EAAE;YAChF,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;gBACzC,sCAAsC;gBACtCC,QAAQC,KAAK,CACX;YAEJ;YACA;QACF;QAEAX,cAAcK,IAAI,CAACH;QACnBD,MAAMC;IACR;IAEA,OAAOF;AACT"}
@@ -3,19 +3,26 @@
3
3
  * Now options 'always'/'height-always'/'width-always' are obsolete.
4
4
  * This function maps them to true/'height'/'width'
5
5
  */ export const normalizeAutoSize = (autoSize)=>{
6
- const dimensions = getAutoSizeDimensions(autoSize);
7
- return dimensions.length ? {
8
- applyMaxWidth: dimensions.includes('width'),
9
- applyMaxHeight: dimensions.includes('height')
10
- } : false;
11
- };
12
- export const getAutoSizeDimensions = (autoSize)=>{
13
- // 'width-always' and 'height-always' are obsolete aliases of 'width' and 'height'
14
- const dimension = /^(width|height)(-always)?$/.exec(String(autoSize));
15
- return autoSize === true || autoSize === 'always' ? [
16
- 'width',
17
- 'height'
18
- ] : dimension ? [
19
- dimension[1]
20
- ] : [];
6
+ switch(autoSize){
7
+ case 'always':
8
+ case true:
9
+ return {
10
+ applyMaxWidth: true,
11
+ applyMaxHeight: true
12
+ };
13
+ case 'width-always':
14
+ case 'width':
15
+ return {
16
+ applyMaxWidth: true,
17
+ applyMaxHeight: false
18
+ };
19
+ case 'height-always':
20
+ case 'height':
21
+ return {
22
+ applyMaxWidth: false,
23
+ applyMaxHeight: true
24
+ };
25
+ default:
26
+ return false;
27
+ }
21
28
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/normalizeAutoSize.ts"],"sourcesContent":["import type { NormalizedAutoSize, PositioningOptions } from '../types';\n\n/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */\nexport const normalizeAutoSize = (autoSize?: PositioningOptions['autoSize']): NormalizedAutoSize | false => {\n const dimensions = getAutoSizeDimensions(autoSize);\n return dimensions.length\n ? {\n applyMaxWidth: dimensions.includes('width'),\n applyMaxHeight: dimensions.includes('height'),\n }\n : false;\n};\n\nexport const getAutoSizeDimensions = (autoSize?: PositioningOptions['autoSize']): ('width' | 'height')[] => {\n // 'width-always' and 'height-always' are obsolete aliases of 'width' and 'height'\n const dimension = /^(width|height)(-always)?$/.exec(String(autoSize));\n return autoSize === true || autoSize === 'always' ? ['width', 'height'] : dimension ? [dimension[1] as 'width'] : [];\n};\n"],"names":["normalizeAutoSize","autoSize","dimensions","getAutoSizeDimensions","length","applyMaxWidth","includes","applyMaxHeight","dimension","exec","String"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,oBAAoB,CAACC;IAChC,MAAMC,aAAaC,sBAAsBF;IACzC,OAAOC,WAAWE,MAAM,GACpB;QACEC,eAAeH,WAAWI,QAAQ,CAAC;QACnCC,gBAAgBL,WAAWI,QAAQ,CAAC;IACtC,IACA;AACN,EAAE;AAEF,OAAO,MAAMH,wBAAwB,CAACF;IACpC,kFAAkF;IAClF,MAAMO,YAAY,6BAA6BC,IAAI,CAACC,OAAOT;IAC3D,OAAOA,aAAa,QAAQA,aAAa,WAAW;QAAC;QAAS;KAAS,GAAGO,YAAY;QAACA,SAAS,CAAC,EAAE;KAAY,GAAG,EAAE;AACtH,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/normalizeAutoSize.ts"],"sourcesContent":["import type { NormalizedAutoSize, PositioningOptions } from '../types';\n\n/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */\nexport const normalizeAutoSize = (autoSize?: PositioningOptions['autoSize']): NormalizedAutoSize | false => {\n switch (autoSize) {\n case 'always':\n case true:\n return {\n applyMaxWidth: true,\n applyMaxHeight: true,\n };\n\n case 'width-always':\n case 'width':\n return {\n applyMaxWidth: true,\n applyMaxHeight: false,\n };\n\n case 'height-always':\n case 'height':\n return {\n applyMaxWidth: false,\n applyMaxHeight: true,\n };\n\n default:\n return false;\n }\n};\n"],"names":["normalizeAutoSize","autoSize","applyMaxWidth","applyMaxHeight"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,oBAAoB,CAACC;IAChC,OAAQA;QACN,KAAK;QACL,KAAK;YACH,OAAO;gBACLC,eAAe;gBACfC,gBAAgB;YAClB;QAEF,KAAK;QACL,KAAK;YACH,OAAO;gBACLD,eAAe;gBACfC,gBAAgB;YAClB;QAEF,KAAK;QACL,KAAK;YACH,OAAO;gBACLD,eAAe;gBACfC,gBAAgB;YAClB;QAEF;YACE,OAAO;IACX;AACF,EAAE"}
@@ -1,15 +1,32 @@
1
+ const getPositionMap = (rtl)=>({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ });
7
+ // Floating UI automatically flips alignment
8
+ // https://github.com/floating-ui/floating-ui/issues/1563
9
+ const getAlignmentMap = ()=>({
10
+ start: 'start',
11
+ end: 'end',
12
+ top: 'start',
13
+ bottom: 'end',
14
+ center: undefined
15
+ });
16
+ const shouldAlignToCenter = (p, a)=>{
17
+ const positionedVertically = p === 'above' || p === 'below';
18
+ const alignedVertically = a === 'top' || a === 'bottom';
19
+ return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
20
+ };
1
21
  /**
2
22
  * Maps internal positioning values to Floating UI placement
3
23
  * @see positioningHelper.test.ts for expected placement values
4
24
  */ export const toFloatingUIPlacement = (align, position, rtl)=>{
5
- if (!position) {
6
- return undefined;
7
- }
8
- const block = position === 'above' || position === 'below';
9
- const side = block ? position === 'above' ? 'top' : 'bottom' : position === 'before' !== !!rtl ? 'left' : 'right';
10
- const alignedVertically = align === 'top' || align === 'bottom';
11
- if (!align || align === 'center' || block === alignedVertically) {
12
- return side;
25
+ const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
26
+ const computedPosition = position && getPositionMap(rtl)[position];
27
+ const computedAlignment = alignment && getAlignmentMap()[alignment];
28
+ if (computedPosition && computedAlignment) {
29
+ return `${computedPosition}-${computedAlignment}`;
13
30
  }
14
- return `${side}-${align === 'start' || align === 'top' ? 'start' : 'end'}`;
31
+ return computedPosition;
15
32
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/toFloatingUIPlacement.ts"],"sourcesContent":["import type { Placement, Side } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\n\n/**\n * Maps internal positioning values to Floating UI placement\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const toFloatingUIPlacement = (align?: Alignment, position?: Position, rtl?: boolean): Placement | undefined => {\n if (!position) {\n return undefined;\n }\n const block = position === 'above' || position === 'below';\n const side: Side = block\n ? position === 'above'\n ? 'top'\n : 'bottom'\n : (position === 'before') !== !!rtl\n ? 'left'\n : 'right';\n const alignedVertically = align === 'top' || align === 'bottom';\n if (!align || align === 'center' || block === alignedVertically) {\n return side;\n }\n return `${side}-${align === 'start' || align === 'top' ? 'start' : 'end'}`;\n};\n"],"names":["toFloatingUIPlacement","align","position","rtl","undefined","block","side","alignedVertically"],"mappings":"AAGA;;;CAGC,GACD,OAAO,MAAMA,wBAAwB,CAACC,OAAmBC,UAAqBC;IAC5E,IAAI,CAACD,UAAU;QACb,OAAOE;IACT;IACA,MAAMC,QAAQH,aAAa,WAAWA,aAAa;IACnD,MAAMI,OAAaD,QACfH,aAAa,UACX,QACA,WACF,AAACA,aAAa,aAAc,CAAC,CAACC,MAC9B,SACA;IACJ,MAAMI,oBAAoBN,UAAU,SAASA,UAAU;IACvD,IAAI,CAACA,SAASA,UAAU,YAAYI,UAAUE,mBAAmB;QAC/D,OAAOD;IACT;IACA,OAAO,GAAGA,KAAK,CAAC,EAAEL,UAAU,WAAWA,UAAU,QAAQ,UAAU,OAAO;AAC5E,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/toFloatingUIPlacement.ts"],"sourcesContent":["import type { Placement, Side, Alignment as FloatingUIAlignment } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\n\ntype PlacementPosition = Side;\ntype PlacementAlign = FloatingUIAlignment;\n\nconst getPositionMap = (rtl?: boolean): Record<Position, PlacementPosition> => ({\n above: 'top',\n below: 'bottom',\n before: rtl ? 'right' : 'left',\n after: rtl ? 'left' : 'right',\n});\n\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (): Record<Alignment, PlacementAlign | undefined> => ({\n start: 'start',\n end: 'end',\n top: 'start',\n bottom: 'end',\n center: undefined,\n});\n\nconst shouldAlignToCenter = (p?: Position, a?: Alignment): boolean => {\n const positionedVertically = p === 'above' || p === 'below';\n const alignedVertically = a === 'top' || a === 'bottom';\n\n return (positionedVertically && alignedVertically) || (!positionedVertically && !alignedVertically);\n};\n\n/**\n * Maps internal positioning values to Floating UI placement\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const toFloatingUIPlacement = (align?: Alignment, position?: Position, rtl?: boolean): Placement | undefined => {\n const alignment = shouldAlignToCenter(position, align) ? 'center' : align;\n\n const computedPosition = position && getPositionMap(rtl)[position];\n const computedAlignment = alignment && getAlignmentMap()[alignment];\n\n if (computedPosition && computedAlignment) {\n return `${computedPosition}-${computedAlignment}` as Placement;\n }\n\n return computedPosition;\n};\n"],"names":["getPositionMap","rtl","above","below","before","after","getAlignmentMap","start","end","top","bottom","center","undefined","shouldAlignToCenter","p","a","positionedVertically","alignedVertically","toFloatingUIPlacement","align","position","alignment","computedPosition","computedAlignment"],"mappings":"AAMA,MAAMA,iBAAiB,CAACC,MAAwD,CAAA;QAC9EC,OAAO;QACPC,OAAO;QACPC,QAAQH,MAAM,UAAU;QACxBI,OAAOJ,MAAM,SAAS;IACxB,CAAA;AAEA,4CAA4C;AAC5C,yDAAyD;AACzD,MAAMK,kBAAkB,IAAsD,CAAA;QAC5EC,OAAO;QACPC,KAAK;QACLC,KAAK;QACLC,QAAQ;QACRC,QAAQC;IACV,CAAA;AAEA,MAAMC,sBAAsB,CAACC,GAAcC;IACzC,MAAMC,uBAAuBF,MAAM,WAAWA,MAAM;IACpD,MAAMG,oBAAoBF,MAAM,SAASA,MAAM;IAE/C,OAAO,AAACC,wBAAwBC,qBAAuB,CAACD,wBAAwB,CAACC;AACnF;AAEA;;;CAGC,GACD,OAAO,MAAMC,wBAAwB,CAACC,OAAmBC,UAAqBnB;IAC5E,MAAMoB,YAAYR,oBAAoBO,UAAUD,SAAS,WAAWA;IAEpE,MAAMG,mBAAmBF,YAAYpB,eAAeC,IAAI,CAACmB,SAAS;IAClE,MAAMG,oBAAoBF,aAAaf,iBAAiB,CAACe,UAAU;IAEnE,IAAIC,oBAAoBC,mBAAmB;QACzC,OAAO,GAAGD,iBAAiB,CAAC,EAAEC,mBAAmB;IACnD;IAEA,OAAOD;AACT,EAAE"}
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
+ import { useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
3
4
  /**
4
5
  * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content
5
6
  * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via
@@ -10,12 +11,14 @@ import * as React from "react";
10
11
  *
11
12
  * @param initialValue - initial ref value
12
13
  * @param callback - a callback to run when value changes
14
+ * @param skipInitialResolve - a flag to skip an initial ref report
13
15
  *
14
16
  * @example
15
17
  * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
16
18
  * ref.current = 1;
17
19
  * // prints 0 -> 1
18
- */ export function useCallbackRef(initialValue, callback) {
20
+ */ export function useCallbackRef(initialValue, callback, skipInitialResolve) {
21
+ const isFirst = React.useRef(true);
19
22
  const [ref] = React.useState(()=>({
20
23
  // value
21
24
  value: initialValue,
@@ -30,11 +33,17 @@ import * as React from "react";
30
33
  const last = ref.value;
31
34
  if (last !== value) {
32
35
  ref.value = value;
36
+ if (skipInitialResolve && isFirst.current) {
37
+ return;
38
+ }
33
39
  ref.callback(value, last);
34
40
  }
35
41
  }
36
42
  }
37
43
  }));
44
+ useIsomorphicLayoutEffect(()=>{
45
+ isFirst.current = false;
46
+ }, []);
38
47
  // update callback
39
48
  ref.callback = callback;
40
49
  return ref.facade;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/useCallbackRef.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n): React.MutableRefObject<T | null> {\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n ref.callback(value, last);\n }\n },\n },\n }));\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"],"names":["React","useCallbackRef","initialValue","callback","ref","useState","value","facade","current","last"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,eACdC,YAAsB,EACtBC,QAA2D;IAG3D,MAAM,CAACC,IAAI,GAAGJ,MAAMK,QAAQ,CAAC,IAAO,CAAA;YAClC,QAAQ;YACRC,OAAOJ;YACP,gBAAgB;YAChBC;YACA,8BAA8B;YAC9BI,QAAQ;gBACN,IAAIC,WAAU;oBACZ,OAAOJ,IAAIE,KAAK;gBAClB;gBACA,IAAIE,SAAQF,MAAO;oBACjB,MAAMG,OAAOL,IAAIE,KAAK;oBAEtB,IAAIG,SAASH,OAAO;wBAClBF,IAAIE,KAAK,GAAGA;wBACZF,IAAID,QAAQ,CAACG,OAAOG;oBACtB;gBACF;YACF;QACF,CAAA;IAEA,kBAAkB;IAClBL,IAAID,QAAQ,GAAGA;IAEf,OAAOC,IAAIG,MAAM;AACnB"}
1
+ {"version":3,"sources":["../../src/utils/useCallbackRef.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\n\n/**\n * Creates a MutableRef with ref change callback. Is useful as React.useRef() doesn't notify you when its content\n * changes and mutating the .current property doesn't cause a re-render. An opt-out will be use a callback ref via\n * React.useState(), but it will cause re-renders always.\n *\n * https://reactjs.org/docs/hooks-reference.html#useref\n * https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref\n *\n * @param initialValue - initial ref value\n * @param callback - a callback to run when value changes\n * @param skipInitialResolve - a flag to skip an initial ref report\n *\n * @example\n * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);\n * ref.current = 1;\n * // prints 0 -> 1\n */\nexport function useCallbackRef<T>(\n initialValue: T | null,\n callback: (newValue: T | null, lastValue: T | null) => void,\n skipInitialResolve?: boolean,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n): React.MutableRefObject<T | null> {\n const isFirst = React.useRef(true);\n const [ref] = React.useState(() => ({\n // value\n value: initialValue,\n // last callback\n callback,\n // \"memoized\" public interface\n facade: {\n get current() {\n return ref.value;\n },\n set current(value) {\n const last = ref.value;\n\n if (last !== value) {\n ref.value = value;\n\n if (skipInitialResolve && isFirst.current) {\n return;\n }\n\n ref.callback(value, last);\n }\n },\n },\n }));\n\n useIsomorphicLayoutEffect(() => {\n isFirst.current = false;\n }, []);\n\n // update callback\n ref.callback = callback;\n\n return ref.facade;\n}\n"],"names":["React","useIsomorphicLayoutEffect","useCallbackRef","initialValue","callback","skipInitialResolve","isFirst","useRef","ref","useState","value","facade","current","last"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,eACdC,YAAsB,EACtBC,QAA2D,EAC3DC,kBAA4B;IAG5B,MAAMC,UAAUN,MAAMO,MAAM,CAAC;IAC7B,MAAM,CAACC,IAAI,GAAGR,MAAMS,QAAQ,CAAC,IAAO,CAAA;YAClC,QAAQ;YACRC,OAAOP;YACP,gBAAgB;YAChBC;YACA,8BAA8B;YAC9BO,QAAQ;gBACN,IAAIC,WAAU;oBACZ,OAAOJ,IAAIE,KAAK;gBAClB;gBACA,IAAIE,SAAQF,MAAO;oBACjB,MAAMG,OAAOL,IAAIE,KAAK;oBAEtB,IAAIG,SAASH,OAAO;wBAClBF,IAAIE,KAAK,GAAGA;wBAEZ,IAAIL,sBAAsBC,QAAQM,OAAO,EAAE;4BACzC;wBACF;wBAEAJ,IAAIJ,QAAQ,CAACM,OAAOG;oBACtB;gBACF;YACF;QACF,CAAA;IAEAZ,0BAA0B;QACxBK,QAAQM,OAAO,GAAG;IACpB,GAAG,EAAE;IAEL,kBAAkB;IAClBJ,IAAIJ,QAAQ,GAAGA;IAEf,OAAOI,IAAIG,MAAM;AACnB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Writes all DOM element updates after position is computed
3
+ */ export function writeArrowUpdates(options) {
4
+ const { arrow, middlewareData } = options;
5
+ if (!middlewareData.arrow || !arrow) {
6
+ return;
7
+ }
8
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
9
+ Object.assign(arrow.style, {
10
+ left: arrowX !== null && arrowX !== undefined ? `${arrowX}px` : '',
11
+ top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : ''
12
+ });
13
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/writeArrowUpdates.ts"],"sourcesContent":["import type { MiddlewareData } from '@floating-ui/dom';\n\n/**\n * Writes all DOM element updates after position is computed\n */\nexport function writeArrowUpdates(options: { arrow: HTMLElement | null; middlewareData: MiddlewareData }): void {\n const { arrow, middlewareData } = options;\n if (!middlewareData.arrow || !arrow) {\n return;\n }\n\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n\n Object.assign(arrow.style, {\n left: arrowX !== null && arrowX !== undefined ? `${arrowX}px` : '',\n top: arrowY !== null && arrowY !== undefined ? `${arrowY}px` : '',\n });\n}\n"],"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","undefined","top"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,kBAAkBC,OAAsE;IACtG,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAE,GAAGF;IAClC,IAAI,CAACE,eAAeD,KAAK,IAAI,CAACA,OAAO;QACnC;IACF;IAEA,MAAM,EAAEE,GAAGC,MAAM,EAAEC,GAAGC,MAAM,EAAE,GAAGJ,eAAeD,KAAK;IAErDM,OAAOC,MAAM,CAACP,MAAMQ,KAAK,EAAE;QACzBC,MAAMN,WAAW,QAAQA,WAAWO,YAAY,GAAGP,OAAO,EAAE,CAAC,GAAG;QAChEQ,KAAKN,WAAW,QAAQA,WAAWK,YAAY,GAAGL,OAAO,EAAE,CAAC,GAAG;IACjE;AACF"}
@@ -0,0 +1,43 @@
1
+ import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INTERSECTING, DATA_POSITIONING_PLACEMENT } from "../constants.js";
2
+ /**
3
+ * Writes all container element position updates after the position is computed
4
+ */ export function writeContainerUpdates(options) {
5
+ var _middlewareData_hide, _middlewareData_hide1, _container_ownerDocument_defaultView;
6
+ const { container, placement, middlewareData, strategy, lowPPI, coordinates, useTransform = true } = options;
7
+ if (!container) {
8
+ return;
9
+ }
10
+ container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);
11
+ container.removeAttribute(DATA_POSITIONING_INTERSECTING);
12
+ if (middlewareData.intersectionObserver.intersecting) {
13
+ container.setAttribute(DATA_POSITIONING_INTERSECTING, '');
14
+ }
15
+ container.removeAttribute(DATA_POSITIONING_ESCAPED);
16
+ if ((_middlewareData_hide = middlewareData.hide) === null || _middlewareData_hide === void 0 ? void 0 : _middlewareData_hide.escaped) {
17
+ container.setAttribute(DATA_POSITIONING_ESCAPED, '');
18
+ }
19
+ container.removeAttribute(DATA_POSITIONING_HIDDEN);
20
+ if ((_middlewareData_hide1 = middlewareData.hide) === null || _middlewareData_hide1 === void 0 ? void 0 : _middlewareData_hide1.referenceHidden) {
21
+ container.setAttribute(DATA_POSITIONING_HIDDEN, '');
22
+ }
23
+ // Round so that the coordinates land on device pixels.
24
+ // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
25
+ // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
26
+ // See https://github.com/microsoft/fluentui/issues/26764 for more info.
27
+ const devicePixelRatio = ((_container_ownerDocument_defaultView = container.ownerDocument.defaultView) === null || _container_ownerDocument_defaultView === void 0 ? void 0 : _container_ownerDocument_defaultView.devicePixelRatio) || 1;
28
+ const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
29
+ const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
30
+ Object.assign(container.style, {
31
+ position: strategy
32
+ });
33
+ if (useTransform) {
34
+ Object.assign(container.style, {
35
+ transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`
36
+ });
37
+ return;
38
+ }
39
+ Object.assign(container.style, {
40
+ left: `${x}px`,
41
+ top: `${y}px`
42
+ });
43
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../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 useTransform?: boolean;\n}): void {\n const { container, placement, middlewareData, strategy, lowPPI, coordinates, useTransform = true } = 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 position: strategy,\n });\n\n if (useTransform) {\n Object.assign(container.style, {\n transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n });\n return;\n }\n\n Object.assign(container.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n}\n"],"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","middlewareData","container","placement","strategy","lowPPI","coordinates","useTransform","setAttribute","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","position","transform","left","top"],"mappings":"AACA,SACEA,wBAAwB,EACxBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,0BAA0B,QACrB,kBAAe;AAEtB;;CAEC,GACD,OAAO,SAASC,sBAAsBC,OAarC;QAYKC,sBAKAA,uBAQqBC;IAxBzB,MAAM,EAAEA,SAAS,EAAEC,SAAS,EAAEF,cAAc,EAAEG,QAAQ,EAAEC,MAAM,EAAEC,WAAW,EAAEC,eAAe,IAAI,EAAE,GAAGP;IACrG,IAAI,CAACE,WAAW;QACd;IACF;IACAA,UAAUM,YAAY,CAACV,4BAA4BK;IACnDD,UAAUO,eAAe,CAACZ;IAC1B,IAAII,eAAeS,oBAAoB,CAACC,YAAY,EAAE;QACpDT,UAAUM,YAAY,CAACX,+BAA+B;IACxD;IAEAK,UAAUO,eAAe,CAACd;IAC1B,KAAIM,uBAAAA,eAAeW,IAAI,cAAnBX,2CAAAA,qBAAqBY,OAAO,EAAE;QAChCX,UAAUM,YAAY,CAACb,0BAA0B;IACnD;IAEAO,UAAUO,eAAe,CAACb;IAC1B,KAAIK,wBAAAA,eAAeW,IAAI,cAAnBX,4CAAAA,sBAAqBa,eAAe,EAAE;QACxCZ,UAAUM,YAAY,CAACZ,yBAAyB;IAClD;IAEA,uDAAuD;IACvD,oHAAoH;IACpH,wFAAwF;IACxF,wEAAwE;IACxE,MAAMmB,mBAAmBb,EAAAA,uCAAAA,UAAUc,aAAa,CAACC,WAAW,cAAnCf,2DAAAA,qCAAqCa,gBAAgB,KAAI;IAClF,MAAMG,IAAIC,KAAKC,KAAK,CAACd,YAAYY,CAAC,GAAGH,oBAAoBA;IACzD,MAAMM,IAAIF,KAAKC,KAAK,CAACd,YAAYe,CAAC,GAAGN,oBAAoBA;IAEzDO,OAAOC,MAAM,CAACrB,UAAUsB,KAAK,EAAE;QAC7BC,UAAUrB;IACZ;IAEA,IAAIG,cAAc;QAChBe,OAAOC,MAAM,CAACrB,UAAUsB,KAAK,EAAE;YAC7BE,WAAWrB,SAAS,CAAC,UAAU,EAAEa,EAAE,IAAI,EAAEG,EAAE,GAAG,CAAC,GAAG,CAAC,YAAY,EAAEH,EAAE,IAAI,EAAEG,EAAE,MAAM,CAAC;QACpF;QACA;IACF;IAEAC,OAAOC,MAAM,CAACrB,UAAUsB,KAAK,EAAE;QAC7BG,MAAM,GAAGT,EAAE,EAAE,CAAC;QACdU,KAAK,GAAGP,EAAE,EAAE,CAAC;IACf;AACF"}
@@ -0,0 +1,43 @@
1
+ /* stylelint-disable fluentui/use-logical-properties -- Arrow rotation and Popper placement coordinates are physical in RTL, like createArrowStyles' @noflip values. */
2
+ .arrow {
3
+ box-sizing: border-box;
4
+ position: absolute;
5
+ z-index: -1;
6
+ background-color: inherit;
7
+ background-clip: content-box;
8
+ border-bottom-left-radius: var(--borderRadiusSmall);
9
+ transform: rotate(var(--fui-positioning-arrow-angle));
10
+ height: var(--fui-positioning-arrow-height);
11
+ width: var(--fui-positioning-arrow-height);
12
+
13
+ &::before {
14
+ content: '';
15
+ display: block;
16
+ background-color: inherit;
17
+ margin: calc(-1 * var(--fui-positioning-arrow-border-width, var(--strokeWidthThin)));
18
+ width: 100%;
19
+ height: 100%;
20
+ border: var(--fui-positioning-arrow-border-width, var(--strokeWidthThin))
21
+ var(--fui-positioning-arrow-border-style, solid)
22
+ var(--fui-positioning-arrow-border-color, var(--colorTransparentStroke));
23
+ border-bottom-left-radius: var(--borderRadiusSmall);
24
+ clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
25
+ }
26
+ }
27
+
28
+ :global([data-popper-placement^='top']) .arrow {
29
+ bottom: var(--fui-positioning-arrow-offset);
30
+ --fui-positioning-arrow-angle: -45deg;
31
+ }
32
+ :global([data-popper-placement^='right']) .arrow {
33
+ left: var(--fui-positioning-arrow-offset);
34
+ --fui-positioning-arrow-angle: 45deg;
35
+ }
36
+ :global([data-popper-placement^='bottom']) .arrow {
37
+ top: var(--fui-positioning-arrow-offset);
38
+ --fui-positioning-arrow-angle: 135deg;
39
+ }
40
+ :global([data-popper-placement^='left']) .arrow {
41
+ right: var(--fui-positioning-arrow-offset);
42
+ --fui-positioning-arrow-angle: 225deg;
43
+ }
@@ -27,5 +27,6 @@ const DEFAULT_CONFIGURATION = ({ options })=>{
27
27
  const PositioningConfigurationContext = /*#__PURE__*/ _react.createContext(undefined);
28
28
  const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;
29
29
  const usePositioningConfiguration = ()=>{
30
- return _react.useContext(PositioningConfigurationContext) || DEFAULT_CONFIGURATION;
30
+ var _React_useContext;
31
+ return (_React_useContext = _react.useContext(PositioningConfigurationContext)) !== null && _React_useContext !== void 0 ? _React_useContext : DEFAULT_CONFIGURATION;
31
32
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) || DEFAULT_CONFIGURATION;\n};\n"],"names":["React","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","createContext","undefined","PositioningConfigurationProvider","Provider","usePositioningConfiguration","useContext"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;iEAEuB,QAAQ;AAG/B,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,gDAAkCH,OAAMI,aAAa,CAAyCC;AAO7F,MAAMC,mCAAmCH,gCAAgCI,QAAQ,CAAC;AAElF,MAAMC,8BAA8B;IACzC,OAAOR,OAAMS,UAAU,CAACN,oCAAoCF;AAC9D,EAAE"}
1
+ {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["React","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","createContext","undefined","PositioningConfigurationProvider","Provider","usePositioningConfiguration","useContext"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;iEAEuB,QAAQ;AAG/B,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,gDAAkCH,OAAMI,aAAa,CAAyCC;AAO7F,MAAMC,mCAAmCH,gCAAgCI,QAAQ,CAAC;AAElF,MAAMC,8BAA8B;QAClCR;IAAP,OAAA,CAAOA,oBAAAA,OAAMS,UAAU,CAACN,gCAAAA,MAAAA,QAAjBH,sBAAAA,KAAAA,IAAAA,oBAAqDC;AAC9D,EAAE"}