@fluentui/react-positioning 0.0.0-nightly-20230529-0417.1 → 0.0.0-nightly-20230530-0415.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 (99) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/lib/constants.js +1 -0
  4. package/lib/constants.js.map +1 -1
  5. package/lib/createArrowStyles.js +48 -54
  6. package/lib/createArrowStyles.js.map +1 -1
  7. package/lib/createPositionManager.js +96 -109
  8. package/lib/createPositionManager.js.map +1 -1
  9. package/lib/createVirtualElementFromClick.js +19 -18
  10. package/lib/createVirtualElementFromClick.js.map +1 -1
  11. package/lib/index.js +1 -0
  12. package/lib/index.js.map +1 -1
  13. package/lib/middleware/coverTarget.js +27 -31
  14. package/lib/middleware/coverTarget.js.map +1 -1
  15. package/lib/middleware/flip.js +23 -31
  16. package/lib/middleware/flip.js.map +1 -1
  17. package/lib/middleware/index.js +1 -0
  18. package/lib/middleware/index.js.map +1 -1
  19. package/lib/middleware/intersecting.js +17 -16
  20. package/lib/middleware/intersecting.js.map +1 -1
  21. package/lib/middleware/maxSize.js +26 -33
  22. package/lib/middleware/maxSize.js.map +1 -1
  23. package/lib/middleware/offset.js +4 -4
  24. package/lib/middleware/offset.js.map +1 -1
  25. package/lib/middleware/shift.js +22 -29
  26. package/lib/middleware/shift.js.map +1 -1
  27. package/lib/types.js +1 -0
  28. package/lib/types.js.map +1 -1
  29. package/lib/usePositioning.js +189 -155
  30. package/lib/usePositioning.js.map +1 -1
  31. package/lib/usePositioningMouseTarget.js +25 -22
  32. package/lib/usePositioningMouseTarget.js.map +1 -1
  33. package/lib/utils/debounce.js +14 -13
  34. package/lib/utils/debounce.js.map +1 -1
  35. package/lib/utils/fromFloatingUIPlacement.js +24 -27
  36. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  37. package/lib/utils/getBoundary.js +15 -15
  38. package/lib/utils/getBoundary.js.map +1 -1
  39. package/lib/utils/getFloatingUIOffset.js +17 -26
  40. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  41. package/lib/utils/getReactFiberFromNode.js +37 -36
  42. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  43. package/lib/utils/getScrollParent.js +36 -41
  44. package/lib/utils/getScrollParent.js.map +1 -1
  45. package/lib/utils/hasAutoFocusFilter.js +10 -10
  46. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  47. package/lib/utils/index.js +1 -0
  48. package/lib/utils/index.js.map +1 -1
  49. package/lib/utils/mergeArrowOffset.js +25 -24
  50. package/lib/utils/mergeArrowOffset.js.map +1 -1
  51. package/lib/utils/parseFloatingUIPlacement.js +7 -6
  52. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  53. package/lib/utils/resolvePositioningShorthand.js +56 -55
  54. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  55. package/lib/utils/toFloatingUIPadding.js +17 -20
  56. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  57. package/lib/utils/toFloatingUIPlacement.js +26 -26
  58. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  59. package/lib/utils/toggleScrollListener.js +13 -13
  60. package/lib/utils/toggleScrollListener.js.map +1 -1
  61. package/lib/utils/useCallbackRef.js +31 -31
  62. package/lib/utils/useCallbackRef.js.map +1 -1
  63. package/lib/utils/writeArrowUpdates.js +11 -16
  64. package/lib/utils/writeArrowUpdates.js.map +1 -1
  65. package/lib/utils/writeContainerupdates.js +38 -46
  66. package/lib/utils/writeContainerupdates.js.map +1 -1
  67. package/lib-commonjs/constants.js.map +1 -1
  68. package/lib-commonjs/createArrowStyles.js.map +1 -1
  69. package/lib-commonjs/createPositionManager.js.map +1 -1
  70. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  71. package/lib-commonjs/index.js.map +1 -1
  72. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  73. package/lib-commonjs/middleware/flip.js.map +1 -1
  74. package/lib-commonjs/middleware/index.js.map +1 -1
  75. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  76. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  77. package/lib-commonjs/middleware/offset.js.map +1 -1
  78. package/lib-commonjs/middleware/shift.js.map +1 -1
  79. package/lib-commonjs/types.js.map +1 -1
  80. package/lib-commonjs/usePositioning.js.map +1 -1
  81. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  82. package/lib-commonjs/utils/debounce.js.map +1 -1
  83. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  84. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  85. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  86. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  87. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  88. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  89. package/lib-commonjs/utils/index.js.map +1 -1
  90. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  91. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  92. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  93. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  94. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  95. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  96. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  97. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  98. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  99. package/package.json +4 -4
@@ -1,61 +1,62 @@
1
1
  // Look up table for shorthand to avoid parsing strings
2
2
  const shorthandLookup = {
3
- above: {
4
- position: 'above',
5
- align: 'center'
6
- },
7
- 'above-start': {
8
- position: 'above',
9
- align: 'start'
10
- },
11
- 'above-end': {
12
- position: 'above',
13
- align: 'end'
14
- },
15
- below: {
16
- position: 'below',
17
- align: 'center'
18
- },
19
- 'below-start': {
20
- position: 'below',
21
- align: 'start'
22
- },
23
- 'below-end': {
24
- position: 'below',
25
- align: 'end'
26
- },
27
- before: {
28
- position: 'before',
29
- align: 'center'
30
- },
31
- 'before-top': {
32
- position: 'before',
33
- align: 'top'
34
- },
35
- 'before-bottom': {
36
- position: 'before',
37
- align: 'bottom'
38
- },
39
- after: {
40
- position: 'after',
41
- align: 'center'
42
- },
43
- 'after-top': {
44
- position: 'after',
45
- align: 'top'
46
- },
47
- 'after-bottom': {
48
- position: 'after',
49
- align: 'bottom'
50
- }
3
+ above: {
4
+ position: 'above',
5
+ align: 'center'
6
+ },
7
+ 'above-start': {
8
+ position: 'above',
9
+ align: 'start'
10
+ },
11
+ 'above-end': {
12
+ position: 'above',
13
+ align: 'end'
14
+ },
15
+ below: {
16
+ position: 'below',
17
+ align: 'center'
18
+ },
19
+ 'below-start': {
20
+ position: 'below',
21
+ align: 'start'
22
+ },
23
+ 'below-end': {
24
+ position: 'below',
25
+ align: 'end'
26
+ },
27
+ before: {
28
+ position: 'before',
29
+ align: 'center'
30
+ },
31
+ 'before-top': {
32
+ position: 'before',
33
+ align: 'top'
34
+ },
35
+ 'before-bottom': {
36
+ position: 'before',
37
+ align: 'bottom'
38
+ },
39
+ after: {
40
+ position: 'after',
41
+ align: 'center'
42
+ },
43
+ 'after-top': {
44
+ position: 'after',
45
+ align: 'top'
46
+ },
47
+ 'after-bottom': {
48
+ position: 'after',
49
+ align: 'bottom'
50
+ }
51
51
  };
52
52
  export function resolvePositioningShorthand(shorthand) {
53
- if (shorthand === undefined || shorthand === null) {
54
- return {};
55
- }
56
- if (typeof shorthand === 'string') {
57
- return shorthandLookup[shorthand];
58
- }
59
- return shorthand;
53
+ if (shorthand === undefined || shorthand === null) {
54
+ return {};
55
+ }
56
+ if (typeof shorthand === 'string') {
57
+ return shorthandLookup[shorthand];
58
+ }
59
+ return shorthand;
60
60
  }
61
+
61
62
  //# sourceMappingURL=resolvePositioningShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["shorthandLookup","above","position","align","below","before","after","resolvePositioningShorthand","shorthand","undefined"],"sources":["../../src/utils/resolvePositioningShorthand.ts"],"sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"],"mappings":"AAEA;AACA,MAAMA,eAAA,GAAmG;EACvGC,KAAA,EAAO;IAAEC,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,eAAe;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAQ;EACnD,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/CC,KAAA,EAAO;IAAEF,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,eAAe;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAQ;EACnD,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/CE,MAAA,EAAQ;IAAEH,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAS;EAC9C,cAAc;IAAED,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAM;EACjD,iBAAiB;IAAED,QAAA,EAAU;IAAUC,KAAA,EAAO;EAAS;EACvDG,KAAA,EAAO;IAAEJ,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;EAC5C,aAAa;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAM;EAC/C,gBAAgB;IAAED,QAAA,EAAU;IAASC,KAAA,EAAO;EAAS;AACvD;AAEA,OAAO,SAASI,4BACdC,SAAkD,EACtB;EAC5B,IAAIA,SAAA,KAAcC,SAAA,IAAaD,SAAA,KAAc,IAAI,EAAE;IACjD,OAAO,CAAC;EACV;EAEA,IAAI,OAAOA,SAAA,KAAc,UAAU;IACjC,OAAOR,eAAe,CAACQ,SAAA,CAAU;EACnC;EAEA,OAAOA,SAAA;AACT"}
1
+ {"version":3,"sources":["../../src/utils/resolvePositioningShorthand.ts"],"sourcesContent":["import type { PositioningShorthand, PositioningShorthandValue, PositioningProps } from '../types';\n\n// Look up table for shorthand to avoid parsing strings\nconst shorthandLookup: Record<PositioningShorthandValue, Pick<PositioningProps, 'position' | 'align'>> = {\n above: { position: 'above', align: 'center' },\n 'above-start': { position: 'above', align: 'start' },\n 'above-end': { position: 'above', align: 'end' },\n below: { position: 'below', align: 'center' },\n 'below-start': { position: 'below', align: 'start' },\n 'below-end': { position: 'below', align: 'end' },\n before: { position: 'before', align: 'center' },\n 'before-top': { position: 'before', align: 'top' },\n 'before-bottom': { position: 'before', align: 'bottom' },\n after: { position: 'after', align: 'center' },\n 'after-top': { position: 'after', align: 'top' },\n 'after-bottom': { position: 'after', align: 'bottom' },\n};\n\nexport function resolvePositioningShorthand(\n shorthand: PositioningShorthand | undefined | null,\n): Readonly<PositioningProps> {\n if (shorthand === undefined || shorthand === null) {\n return {};\n }\n\n if (typeof shorthand === 'string') {\n return shorthandLookup[shorthand];\n }\n\n return shorthand as Readonly<PositioningProps>;\n}\n"],"names":["shorthandLookup","above","position","align","below","before","after","resolvePositioningShorthand","shorthand","undefined"],"mappings":"AAEA,uDAAuD;AACvD,MAAMA,kBAAmG;IACvGC,OAAO;QAAEC,UAAU;QAASC,OAAO;IAAS;IAC5C,eAAe;QAAED,UAAU;QAASC,OAAO;IAAQ;IACnD,aAAa;QAAED,UAAU;QAASC,OAAO;IAAM;IAC/CC,OAAO;QAAEF,UAAU;QAASC,OAAO;IAAS;IAC5C,eAAe;QAAED,UAAU;QAASC,OAAO;IAAQ;IACnD,aAAa;QAAED,UAAU;QAASC,OAAO;IAAM;IAC/CE,QAAQ;QAAEH,UAAU;QAAUC,OAAO;IAAS;IAC9C,cAAc;QAAED,UAAU;QAAUC,OAAO;IAAM;IACjD,iBAAiB;QAAED,UAAU;QAAUC,OAAO;IAAS;IACvDG,OAAO;QAAEJ,UAAU;QAASC,OAAO;IAAS;IAC5C,aAAa;QAAED,UAAU;QAASC,OAAO;IAAM;IAC/C,gBAAgB;QAAED,UAAU;QAASC,OAAO;IAAS;AACvD;AAEA,OAAO,SAASI,4BACdC,SAAkD,EACtB;IAC5B,IAAIA,cAAcC,aAAaD,cAAc,IAAI,EAAE;QACjD,OAAO,CAAC;IACV,CAAC;IAED,IAAI,OAAOA,cAAc,UAAU;QACjC,OAAOR,eAAe,CAACQ,UAAU;IACnC,CAAC;IAED,OAAOA;AACT,CAAC"}
@@ -1,23 +1,20 @@
1
1
  export function toFloatingUIPadding(padding, isRtl) {
2
- if (typeof padding === 'number') {
3
- return padding;
4
- }
5
- const {
6
- start,
7
- end,
8
- ...verticalPadding
9
- } = padding;
10
- const paddingObject = verticalPadding;
11
- const left = isRtl ? 'end' : 'start';
12
- const right = isRtl ? 'start' : 'end';
13
- // assign properties explicitly since undefined values are actually handled by floating UI
14
- // TODO create floating UI issue
15
- if (padding[left]) {
16
- paddingObject.left = padding[left];
17
- }
18
- if (padding[right]) {
19
- paddingObject.right = padding[right];
20
- }
21
- return paddingObject;
2
+ if (typeof padding === 'number') {
3
+ return padding;
4
+ }
5
+ const { start , end , ...verticalPadding } = padding;
6
+ const paddingObject = verticalPadding;
7
+ const left = isRtl ? 'end' : 'start';
8
+ const right = isRtl ? 'start' : 'end';
9
+ // assign properties explicitly since undefined values are actually handled by floating UI
10
+ // TODO create floating UI issue
11
+ if (padding[left]) {
12
+ paddingObject.left = padding[left];
13
+ }
14
+ if (padding[right]) {
15
+ paddingObject.right = padding[right];
16
+ }
17
+ return paddingObject;
22
18
  }
19
+
23
20
  //# sourceMappingURL=toFloatingUIPadding.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["toFloatingUIPadding","padding","isRtl","start","end","verticalPadding","paddingObject","left","right"],"sources":["../../src/utils/toFloatingUIPadding.ts"],"sourcesContent":["import type { SideObject } from '@floating-ui/dom';\nimport { PositioningOptions } from '../types';\n\nexport function toFloatingUIPadding(\n padding: NonNullable<PositioningOptions['overflowBoundaryPadding']>,\n isRtl: boolean,\n): number | Partial<SideObject> {\n if (typeof padding === 'number') {\n return padding;\n }\n\n const { start, end, ...verticalPadding } = padding;\n\n const paddingObject: Partial<SideObject> = verticalPadding;\n\n const left = isRtl ? 'end' : 'start';\n const right = isRtl ? 'start' : 'end';\n\n // assign properties explicitly since undefined values are actually handled by floating UI\n // TODO create floating UI issue\n if (padding[left]) {\n paddingObject.left = padding[left];\n }\n\n if (padding[right]) {\n paddingObject.right = padding[right];\n }\n\n return paddingObject;\n}\n"],"mappings":"AAGA,OAAO,SAASA,oBACdC,OAAmE,EACnEC,KAAc,EACgB;EAC9B,IAAI,OAAOD,OAAA,KAAY,UAAU;IAC/B,OAAOA,OAAA;EACT;EAEA,MAAM;IAAEE,KAAA;IAAOC,GAAA;IAAK,GAAGC;EAAA,CAAiB,GAAGJ,OAAA;EAE3C,MAAMK,aAAA,GAAqCD,eAAA;EAE3C,MAAME,IAAA,GAAOL,KAAA,GAAQ,QAAQ,OAAO;EACpC,MAAMM,KAAA,GAAQN,KAAA,GAAQ,UAAU,KAAK;EAErC;EACA;EACA,IAAID,OAAO,CAACM,IAAA,CAAK,EAAE;IACjBD,aAAA,CAAcC,IAAI,GAAGN,OAAO,CAACM,IAAA,CAAK;EACpC;EAEA,IAAIN,OAAO,CAACO,KAAA,CAAM,EAAE;IAClBF,aAAA,CAAcE,KAAK,GAAGP,OAAO,CAACO,KAAA,CAAM;EACtC;EAEA,OAAOF,aAAA;AACT"}
1
+ {"version":3,"sources":["../../src/utils/toFloatingUIPadding.ts"],"sourcesContent":["import type { SideObject } from '@floating-ui/dom';\nimport { PositioningOptions } from '../types';\n\nexport function toFloatingUIPadding(\n padding: NonNullable<PositioningOptions['overflowBoundaryPadding']>,\n isRtl: boolean,\n): number | Partial<SideObject> {\n if (typeof padding === 'number') {\n return padding;\n }\n\n const { start, end, ...verticalPadding } = padding;\n\n const paddingObject: Partial<SideObject> = verticalPadding;\n\n const left = isRtl ? 'end' : 'start';\n const right = isRtl ? 'start' : 'end';\n\n // assign properties explicitly since undefined values are actually handled by floating UI\n // TODO create floating UI issue\n if (padding[left]) {\n paddingObject.left = padding[left];\n }\n\n if (padding[right]) {\n paddingObject.right = padding[right];\n }\n\n return paddingObject;\n}\n"],"names":["toFloatingUIPadding","padding","isRtl","start","end","verticalPadding","paddingObject","left","right"],"mappings":"AAGA,OAAO,SAASA,oBACdC,OAAmE,EACnEC,KAAc,EACgB;IAC9B,IAAI,OAAOD,YAAY,UAAU;QAC/B,OAAOA;IACT,CAAC;IAED,MAAM,EAAEE,MAAK,EAAEC,IAAG,EAAE,GAAGC,iBAAiB,GAAGJ;IAE3C,MAAMK,gBAAqCD;IAE3C,MAAME,OAAOL,QAAQ,QAAQ,OAAO;IACpC,MAAMM,QAAQN,QAAQ,UAAU,KAAK;IAErC,0FAA0F;IAC1F,gCAAgC;IAChC,IAAID,OAAO,CAACM,KAAK,EAAE;QACjBD,cAAcC,IAAI,GAAGN,OAAO,CAACM,KAAK;IACpC,CAAC;IAED,IAAIN,OAAO,CAACO,MAAM,EAAE;QAClBF,cAAcE,KAAK,GAAGP,OAAO,CAACO,MAAM;IACtC,CAAC;IAED,OAAOF;AACT,CAAC"}
@@ -1,34 +1,34 @@
1
- const getPositionMap = rtl => ({
2
- above: 'top',
3
- below: 'bottom',
4
- before: rtl ? 'right' : 'left',
5
- after: rtl ? 'left' : 'right'
6
- });
1
+ const getPositionMap = (rtl)=>({
2
+ above: 'top',
3
+ below: 'bottom',
4
+ before: rtl ? 'right' : 'left',
5
+ after: rtl ? 'left' : 'right'
6
+ });
7
7
  // Floating UI automatically flips alignment
8
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;
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
20
  };
21
21
  /**
22
22
  * Maps internal positioning values to Floating UI placement
23
23
  * @see positioningHelper.test.ts for expected placement values
24
- */
25
- export const toFloatingUIPlacement = (align, position, rtl) => {
26
- const alignment = shouldAlignToCenter(position, align) ? 'center' : align;
27
- const computedPosition = position && getPositionMap(rtl)[position];
28
- const computedAlignment = alignment && getAlignmentMap()[alignment];
29
- if (computedPosition && computedAlignment) {
30
- return `${computedPosition}-${computedAlignment}`;
31
- }
32
- return computedPosition;
24
+ */ export const toFloatingUIPlacement = (align, position, rtl)=>{
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}`;
30
+ }
31
+ return computedPosition;
33
32
  };
33
+
34
34
  //# sourceMappingURL=toFloatingUIPlacement.js.map
@@ -1 +1 @@
1
- {"version":3,"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"],"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"],"mappings":"AAMA,MAAMA,cAAA,GAAkBC,GAAA,KAAwD;EAC9EC,KAAA,EAAO;EACPC,KAAA,EAAO;EACPC,MAAA,EAAQH,GAAA,GAAM,UAAU,MAAM;EAC9BI,KAAA,EAAOJ,GAAA,GAAM,SAAS;AACxB;AAEA;AACA;AACA,MAAMK,eAAA,GAAkBA,CAAA,MAAsD;EAC5EC,KAAA,EAAO;EACPC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,MAAA,EAAQ;EACRC,MAAA,EAAQC;AACV;AAEA,MAAMC,mBAAA,GAAsBA,CAACC,CAAA,EAAcC,CAAA,KAA2B;EACpE,MAAMC,oBAAA,GAAuBF,CAAA,KAAM,WAAWA,CAAA,KAAM;EACpD,MAAMG,iBAAA,GAAoBF,CAAA,KAAM,SAASA,CAAA,KAAM;EAE/C,OAAOC,oBAAC,IAAwBC,iBAAA,IAAuB,CAACD,oBAAA,IAAwB,CAACC,iBAAA;AACnF;AAEA;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAACC,KAAA,EAAmBC,QAAA,EAAqBnB,GAAA,KAAyC;EACrH,MAAMoB,SAAA,GAAYR,mBAAA,CAAoBO,QAAA,EAAUD,KAAA,IAAS,WAAWA,KAAK;EAEzE,MAAMG,gBAAA,GAAmBF,QAAA,IAAYpB,cAAA,CAAeC,GAAA,CAAI,CAACmB,QAAA,CAAS;EAClE,MAAMG,iBAAA,GAAoBF,SAAA,IAAaf,eAAA,EAAiB,CAACe,SAAA,CAAU;EAEnE,IAAIC,gBAAA,IAAoBC,iBAAA,EAAmB;IACzC,OAAQ,GAAED,gBAAiB,IAAGC,iBAAkB,EAAC;EACnD;EAEA,OAAOD,gBAAA;AACT"}
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,MAAM;QAC9BI,OAAOJ,MAAM,SAAS,OAAO;IAC/B,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,IAA2B;IACpE,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,MAAyC;IACrH,MAAMoB,YAAYR,oBAAoBO,UAAUD,SAAS,WAAWA,KAAK;IAEzE,MAAMG,mBAAmBF,YAAYpB,eAAeC,IAAI,CAACmB,SAAS;IAClE,MAAMG,oBAAoBF,aAAaf,iBAAiB,CAACe,UAAU;IAEnE,IAAIC,oBAAoBC,mBAAmB;QACzC,OAAO,CAAC,EAAED,iBAAiB,CAAC,EAAEC,kBAAkB,CAAC;IACnD,CAAC;IAED,OAAOD;AACT,EAAE"}
@@ -5,18 +5,18 @@ import { getScrollParent } from './getScrollParent';
5
5
  * Cleans up the event listeners for the previous element and adds them for the new scroll parent.
6
6
  * @param next Next element
7
7
  * @param prev Previous element
8
- */
9
- export function toggleScrollListener(next, prev, handler) {
10
- if (next === prev) {
11
- return;
12
- }
13
- if (isHTMLElement(prev)) {
14
- const prevScrollParent = getScrollParent(prev);
15
- prevScrollParent.removeEventListener('scroll', handler);
16
- }
17
- if (isHTMLElement(next)) {
18
- const scrollParent = getScrollParent(next);
19
- scrollParent.addEventListener('scroll', handler);
20
- }
8
+ */ export function toggleScrollListener(next, prev, handler) {
9
+ if (next === prev) {
10
+ return;
11
+ }
12
+ if (isHTMLElement(prev)) {
13
+ const prevScrollParent = getScrollParent(prev);
14
+ prevScrollParent.removeEventListener('scroll', handler);
15
+ }
16
+ if (isHTMLElement(next)) {
17
+ const scrollParent = getScrollParent(next);
18
+ scrollParent.addEventListener('scroll', handler);
19
+ }
21
20
  }
21
+
22
22
  //# sourceMappingURL=toggleScrollListener.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isHTMLElement","getScrollParent","toggleScrollListener","next","prev","handler","prevScrollParent","removeEventListener","scrollParent","addEventListener"],"sources":["../../src/utils/toggleScrollListener.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositioningVirtualElement } from '../types';\nimport { getScrollParent } from './getScrollParent';\n\n/**\n * Toggles event listeners for scroll parent.\n * Cleans up the event listeners for the previous element and adds them for the new scroll parent.\n * @param next Next element\n * @param prev Previous element\n */\nexport function toggleScrollListener(\n next: HTMLElement | PositioningVirtualElement | null,\n prev: HTMLElement | PositioningVirtualElement | null,\n handler: EventListener,\n) {\n if (next === prev) {\n return;\n }\n\n if (isHTMLElement(prev)) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener('scroll', handler);\n }\n if (isHTMLElement(next)) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener('scroll', handler);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ;AAE9B,SAASC,eAAe,QAAQ;AAEhC;;;;;;AAMA,OAAO,SAASC,qBACdC,IAAoD,EACpDC,IAAoD,EACpDC,OAAsB,EACtB;EACA,IAAIF,IAAA,KAASC,IAAA,EAAM;IACjB;EACF;EAEA,IAAIJ,aAAA,CAAcI,IAAA,GAAO;IACvB,MAAME,gBAAA,GAAmBL,eAAA,CAAgBG,IAAA;IACzCE,gBAAA,CAAiBC,mBAAmB,CAAC,UAAUF,OAAA;EACjD;EACA,IAAIL,aAAA,CAAcG,IAAA,GAAO;IACvB,MAAMK,YAAA,GAAeP,eAAA,CAAgBE,IAAA;IACrCK,YAAA,CAAaC,gBAAgB,CAAC,UAAUJ,OAAA;EAC1C;AACF"}
1
+ {"version":3,"sources":["../../src/utils/toggleScrollListener.ts"],"sourcesContent":["import { isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositioningVirtualElement } from '../types';\nimport { getScrollParent } from './getScrollParent';\n\n/**\n * Toggles event listeners for scroll parent.\n * Cleans up the event listeners for the previous element and adds them for the new scroll parent.\n * @param next Next element\n * @param prev Previous element\n */\nexport function toggleScrollListener(\n next: HTMLElement | PositioningVirtualElement | null,\n prev: HTMLElement | PositioningVirtualElement | null,\n handler: EventListener,\n) {\n if (next === prev) {\n return;\n }\n\n if (isHTMLElement(prev)) {\n const prevScrollParent = getScrollParent(prev);\n prevScrollParent.removeEventListener('scroll', handler);\n }\n if (isHTMLElement(next)) {\n const scrollParent = getScrollParent(next);\n scrollParent.addEventListener('scroll', handler);\n }\n}\n"],"names":["isHTMLElement","getScrollParent","toggleScrollListener","next","prev","handler","prevScrollParent","removeEventListener","scrollParent","addEventListener"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA4B;AAE1D,SAASC,eAAe,QAAQ,oBAAoB;AAEpD;;;;;CAKC,GACD,OAAO,SAASC,qBACdC,IAAoD,EACpDC,IAAoD,EACpDC,OAAsB,EACtB;IACA,IAAIF,SAASC,MAAM;QACjB;IACF,CAAC;IAED,IAAIJ,cAAcI,OAAO;QACvB,MAAME,mBAAmBL,gBAAgBG;QACzCE,iBAAiBC,mBAAmB,CAAC,UAAUF;IACjD,CAAC;IACD,IAAIL,cAAcG,OAAO;QACvB,MAAMK,eAAeP,gBAAgBE;QACrCK,aAAaC,gBAAgB,CAAC,UAAUJ;IAC1C,CAAC;AACH,CAAC"}
@@ -16,36 +16,36 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
16
16
  * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
17
17
  * ref.current = 1;
18
18
  * // prints 0 -> 1
19
- */
20
- export function useCallbackRef(initialValue, callback, skipInitialResolve) {
21
- const isFirst = React.useRef(true);
22
- const [ref] = React.useState(() => ({
23
- // value
24
- value: initialValue,
25
- // last callback
26
- callback,
27
- // "memoized" public interface
28
- facade: {
29
- get current() {
30
- return ref.value;
31
- },
32
- set current(value) {
33
- const last = ref.value;
34
- if (last !== value) {
35
- ref.value = value;
36
- if (skipInitialResolve && isFirst.current) {
37
- return;
38
- }
39
- ref.callback(value, last);
40
- }
41
- }
42
- }
43
- }));
44
- useIsomorphicLayoutEffect(() => {
45
- isFirst.current = false;
46
- }, []);
47
- // update callback
48
- ref.callback = callback;
49
- return ref.facade;
19
+ */ export function useCallbackRef(initialValue, callback, skipInitialResolve) {
20
+ const isFirst = React.useRef(true);
21
+ const [ref] = React.useState(()=>({
22
+ // value
23
+ value: initialValue,
24
+ // last callback
25
+ callback,
26
+ // "memoized" public interface
27
+ facade: {
28
+ get current () {
29
+ return ref.value;
30
+ },
31
+ set current (value){
32
+ const last = ref.value;
33
+ if (last !== value) {
34
+ ref.value = value;
35
+ if (skipInitialResolve && isFirst.current) {
36
+ return;
37
+ }
38
+ ref.callback(value, last);
39
+ }
40
+ }
41
+ }
42
+ }));
43
+ useIsomorphicLayoutEffect(()=>{
44
+ isFirst.current = false;
45
+ }, []);
46
+ // update callback
47
+ ref.callback = callback;
48
+ return ref.facade;
50
49
  }
50
+
51
51
  //# sourceMappingURL=useCallbackRef.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useIsomorphicLayoutEffect","useCallbackRef","initialValue","callback","skipInitialResolve","isFirst","useRef","ref","useState","value","facade","current","last"],"sources":["../../src/utils/useCallbackRef.ts"],"sourcesContent":["import * 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): 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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,yBAAyB,QAAQ;AAE1C;;;;;;;;;;;;;;;;;AAiBA,OAAO,SAASC,eACdC,YAAsB,EACtBC,QAA2D,EAC3DC,kBAA4B,EACM;EAClC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,MAAM,CAAC,IAAI;EACjC,MAAM,CAACC,GAAA,CAAI,GAAGR,KAAA,CAAMS,QAAQ,CAAC,OAAO;IAClC;IACAC,KAAA,EAAOP,YAAA;IACP;IACAC,QAAA;IACA;IACAO,MAAA,EAAQ;MACN,IAAIC,QAAA,EAAU;QACZ,OAAOJ,GAAA,CAAIE,KAAK;MAClB;MACA,IAAIE,QAAQF,KAAA,EAAO;QACjB,MAAMG,IAAA,GAAOL,GAAA,CAAIE,KAAK;QAEtB,IAAIG,IAAA,KAASH,KAAA,EAAO;UAClBF,GAAA,CAAIE,KAAK,GAAGA,KAAA;UAEZ,IAAIL,kBAAA,IAAsBC,OAAA,CAAQM,OAAO,EAAE;YACzC;UACF;UAEAJ,GAAA,CAAIJ,QAAQ,CAACM,KAAA,EAAOG,IAAA;QACtB;MACF;IACF;EACF;EAEAZ,yBAAA,CAA0B,MAAM;IAC9BK,OAAA,CAAQM,OAAO,GAAG,KAAK;EACzB,GAAG,EAAE;EAEL;EACAJ,GAAA,CAAIJ,QAAQ,GAAGA,QAAA;EAEf,OAAOI,GAAA,CAAIG,MAAM;AACnB"}
1
+ {"version":3,"sources":["../../src/utils/useCallbackRef.ts"],"sourcesContent":["import * 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): 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,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,eACdC,YAAsB,EACtBC,QAA2D,EAC3DC,kBAA4B,EACM;IAClC,MAAMC,UAAUN,MAAMO,MAAM,CAAC,IAAI;IACjC,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,CAAC;wBAEDJ,IAAIJ,QAAQ,CAACM,OAAOG;oBACtB,CAAC;gBACH;YACF;QACF,CAAA;IAEAZ,0BAA0B,IAAM;QAC9BK,QAAQM,OAAO,GAAG,KAAK;IACzB,GAAG,EAAE;IAEL,kBAAkB;IAClBJ,IAAIJ,QAAQ,GAAGA;IAEf,OAAOI,IAAIG,MAAM;AACnB,CAAC"}
@@ -1,20 +1,15 @@
1
1
  /**
2
2
  * Writes all DOM element updates after position is computed
3
- */export function writeArrowUpdates(options) {
4
- const {
5
- arrow,
6
- middlewareData
7
- } = options;
8
- if (!middlewareData.arrow || !arrow) {
9
- return;
10
- }
11
- const {
12
- x: arrowX,
13
- y: arrowY
14
- } = middlewareData.arrow;
15
- Object.assign(arrow.style, {
16
- left: `${arrowX}px`,
17
- top: `${arrowY}px`
18
- });
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}px`,
11
+ top: `${arrowY}px`
12
+ });
19
13
  }
14
+
20
15
  //# sourceMappingURL=writeArrowUpdates.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","top"],"sources":["../../src/utils/writeArrowUpdates.ts"],"sourcesContent":["import { 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 }) {\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}px`,\n top: `${arrowY}px`,\n });\n}\n"],"mappings":"AAEA;;GAGA,OAAO,SAASA,kBAAkBC,OAAsE,EAAE;EACxG,MAAM;IAAEC,KAAA;IAAOC;EAAc,CAAE,GAAGF,OAAA;EAClC,IAAI,CAACE,cAAA,CAAeD,KAAK,IAAI,CAACA,KAAA,EAAO;IACnC;EACF;EAEA,MAAM;IAAEE,CAAA,EAAGC,MAAA;IAAQC,CAAA,EAAGC;EAAM,CAAE,GAAGJ,cAAA,CAAeD,KAAK;EAErDM,MAAA,CAAOC,MAAM,CAACP,KAAA,CAAMQ,KAAK,EAAE;IACzBC,IAAA,EAAO,GAAEN,MAAO,IAAG;IACnBO,GAAA,EAAM,GAAEL,MAAO;EACjB;AACF"}
1
+ {"version":3,"sources":["../../src/utils/writeArrowUpdates.ts"],"sourcesContent":["import { 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 }) {\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}px`,\n top: `${arrowY}px`,\n });\n}\n"],"names":["writeArrowUpdates","options","arrow","middlewareData","x","arrowX","y","arrowY","Object","assign","style","left","top"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,kBAAkBC,OAAsE,EAAE;IACxG,MAAM,EAAEC,MAAK,EAAEC,eAAc,EAAE,GAAGF;IAClC,IAAI,CAACE,eAAeD,KAAK,IAAI,CAACA,OAAO;QACnC;IACF,CAAC;IAED,MAAM,EAAEE,GAAGC,OAAM,EAAEC,GAAGC,OAAM,EAAE,GAAGJ,eAAeD,KAAK;IAErDM,OAAOC,MAAM,CAACP,MAAMQ,KAAK,EAAE;QACzBC,MAAM,CAAC,EAAEN,OAAO,EAAE,CAAC;QACnBO,KAAK,CAAC,EAAEL,OAAO,EAAE,CAAC;IACpB;AACF,CAAC"}
@@ -1,53 +1,45 @@
1
1
  import { DATA_POSITIONING_ESCAPED, DATA_POSITIONING_HIDDEN, DATA_POSITIONING_INTERSECTING, DATA_POSITIONING_PLACEMENT } from '../constants';
2
2
  /**
3
3
  * Writes all container element position updates after the position is computed
4
- */
5
- export function writeContainerUpdates(options) {
6
- var _middlewareData_hide, _middlewareData_hide1, _container_ownerDocument_defaultView;
7
- const {
8
- container,
9
- placement,
10
- middlewareData,
11
- strategy,
12
- lowPPI,
13
- coordinates,
14
- useTransform = true
15
- } = options;
16
- if (!container) {
17
- return;
18
- }
19
- container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);
20
- container.removeAttribute(DATA_POSITIONING_INTERSECTING);
21
- if (middlewareData.intersectionObserver.intersecting) {
22
- container.setAttribute(DATA_POSITIONING_INTERSECTING, '');
23
- }
24
- container.removeAttribute(DATA_POSITIONING_ESCAPED);
25
- if ((_middlewareData_hide = middlewareData.hide) === null || _middlewareData_hide === void 0 ? void 0 : _middlewareData_hide.escaped) {
26
- container.setAttribute(DATA_POSITIONING_ESCAPED, '');
27
- }
28
- container.removeAttribute(DATA_POSITIONING_HIDDEN);
29
- if ((_middlewareData_hide1 = middlewareData.hide) === null || _middlewareData_hide1 === void 0 ? void 0 : _middlewareData_hide1.referenceHidden) {
30
- container.setAttribute(DATA_POSITIONING_HIDDEN, '');
31
- }
32
- // Round so that the coordinates land on device pixels.
33
- // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like
34
- // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.
35
- // See https://github.com/microsoft/fluentui/issues/26764 for more info.
36
- const devicePixelRatio = ((_container_ownerDocument_defaultView = container.ownerDocument.defaultView) === null || _container_ownerDocument_defaultView === void 0 ? void 0 : _container_ownerDocument_defaultView.devicePixelRatio) || 1;
37
- const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;
38
- const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;
39
- Object.assign(container.style, {
40
- position: strategy
41
- });
42
- if (useTransform) {
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;
43
30
  Object.assign(container.style, {
44
- transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`
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`
45
42
  });
46
- return;
47
- }
48
- Object.assign(container.style, {
49
- left: `${x}px`,
50
- top: `${y}px`
51
- });
52
43
  }
44
+
53
45
  //# sourceMappingURL=writeContainerupdates.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","_middlewareData_hide","_middlewareData_hide1","_container_ownerDocument_defaultView","container","placement","middlewareData","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"],"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}) {\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"],"mappings":"AACA,SACEA,wBAAwB,EACxBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,0BAA0B,QACrB;AAEP;;;AAGA,OAAO,SAASC,sBAAsBC,OAarC,EAAE;MAYGC,oBAAA,EAKAC,qBAAA,EAQqBC,oCAAA;EAxBzB,MAAM;IAAEC,SAAA;IAAWC,SAAA;IAAWC,cAAA;IAAgBC,QAAA;IAAUC,MAAA;IAAQC,WAAA;IAAaC,YAAA,GAAe;EAAI,CAAE,GAAGV,OAAA;EACrG,IAAI,CAACI,SAAA,EAAW;IACd;EACF;EACAA,SAAA,CAAUO,YAAY,CAACb,0BAAA,EAA4BO,SAAA;EACnDD,SAAA,CAAUQ,eAAe,CAACf,6BAAA;EAC1B,IAAIS,cAAA,CAAeO,oBAAoB,CAACC,YAAY,EAAE;IACpDV,SAAA,CAAUO,YAAY,CAACd,6BAAA,EAA+B;EACxD;EAEAO,SAAA,CAAUQ,eAAe,CAACjB,wBAAA;EAC1B,IAAI,CAAAM,oBAAA,GAAAK,cAAA,CAAeS,IAAI,cAAnBd,oBAAA,uBAAAA,oBAAA,CAAqBe,OAAO,EAAE;IAChCZ,SAAA,CAAUO,YAAY,CAAChB,wBAAA,EAA0B;EACnD;EAEAS,SAAA,CAAUQ,eAAe,CAAChB,uBAAA;EAC1B,IAAI,CAAAM,qBAAA,GAAAI,cAAA,CAAeS,IAAI,cAAnBb,qBAAA,uBAAAA,qBAAA,CAAqBe,eAAe,EAAE;IACxCb,SAAA,CAAUO,YAAY,CAACf,uBAAA,EAAyB;EAClD;EAEA;EACA;EACA;EACA;EACA,MAAMsB,gBAAA,GAAmB,EAAAf,oCAAA,GAAAC,SAAA,CAAUe,aAAa,CAACC,WAAW,cAAnCjB,oCAAA,uBAAAA,oCAAA,CAAqCe,gBAAgB,KAAI;EAClF,MAAMG,CAAA,GAAIC,IAAA,CAAKC,KAAK,CAACd,WAAA,CAAYY,CAAC,GAAGH,gBAAA,IAAoBA,gBAAA;EACzD,MAAMM,CAAA,GAAIF,IAAA,CAAKC,KAAK,CAACd,WAAA,CAAYe,CAAC,GAAGN,gBAAA,IAAoBA,gBAAA;EAEzDO,MAAA,CAAOC,MAAM,CAACtB,SAAA,CAAUuB,KAAK,EAAE;IAC7BC,QAAA,EAAUrB;EACZ;EAEA,IAAIG,YAAA,EAAc;IAChBe,MAAA,CAAOC,MAAM,CAACtB,SAAA,CAAUuB,KAAK,EAAE;MAC7BE,SAAA,EAAWrB,MAAA,GAAU,aAAYa,CAAE,OAAMG,CAAE,KAAI,GAAI,eAAcH,CAAE,OAAMG,CAAE;IAC7E;IACA;EACF;EAEAC,MAAA,CAAOC,MAAM,CAACtB,SAAA,CAAUuB,KAAK,EAAE;IAC7BG,IAAA,EAAO,GAAET,CAAE,IAAG;IACdU,GAAA,EAAM,GAAEP,CAAE;EACZ;AACF"}
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}) {\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,eAAe;AAEtB;;CAEC,GACD,OAAO,SAASC,sBAAsBC,OAarC,EAAE;QAYGC,sBAKAA,uBAQqBC;IAxBzB,MAAM,EAAEA,UAAS,EAAEC,UAAS,EAAEF,eAAc,EAAEG,SAAQ,EAAEC,OAAM,EAAEC,YAAW,EAAEC,cAAe,IAAI,CAAA,EAAE,GAAGP;IACrG,IAAI,CAACE,WAAW;QACd;IACF,CAAC;IACDA,UAAUM,YAAY,CAACV,4BAA4BK;IACnDD,UAAUO,eAAe,CAACZ;IAC1B,IAAII,eAAeS,oBAAoB,CAACC,YAAY,EAAE;QACpDT,UAAUM,YAAY,CAACX,+BAA+B;IACxD,CAAC;IAEDK,UAAUO,eAAe,CAACd;IAC1B,IAAIM,CAAAA,uBAAAA,eAAeW,IAAI,cAAnBX,kCAAAA,KAAAA,IAAAA,qBAAqBY,OAAO,EAAE;QAChCX,UAAUM,YAAY,CAACb,0BAA0B;IACnD,CAAC;IAEDO,UAAUO,eAAe,CAACb;IAC1B,IAAIK,CAAAA,wBAAAA,eAAeW,IAAI,cAAnBX,mCAAAA,KAAAA,IAAAA,sBAAqBa,eAAe,EAAE;QACxCZ,UAAUM,YAAY,CAACZ,yBAAyB;IAClD,CAAC;IAED,uDAAuD;IACvD,oHAAoH;IACpH,wFAAwF;IACxF,wEAAwE;IACxE,MAAMmB,mBAAmBb,CAAAA,CAAAA,uCAAAA,UAAUc,aAAa,CAACC,WAAW,cAAnCf,kDAAAA,KAAAA,IAAAA,qCAAqCa,gBAAgB,AAAD,KAAK;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,CAAC;IAEDC,OAAOC,MAAM,CAACrB,UAAUsB,KAAK,EAAE;QAC7BG,MAAM,CAAC,EAAET,EAAE,EAAE,CAAC;QACdU,KAAK,CAAC,EAAEP,EAAE,EAAE,CAAC;IACf;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/constants.js"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n//# sourceMappingURL=constants.js.map"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT"],"mappings":";;;;;;;;;;;IAAaA,6BAA6B,MAA7BA;IACAC,wBAAwB,MAAxBA;IACAC,uBAAuB,MAAvBA;IACAC,0BAA0B,MAA1BA;;AAHN,MAAMH,gCAAgC;AACtC,MAAMC,2BAA2B;AACjC,MAAMC,0BAA0B;AAChC,MAAMC,6BAA6B,yBAC1C,qCAAqC"}
1
+ {"version":3,"sources":["../lib/constants.js"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\n\n//# sourceMappingURL=constants.js.map"],"names":["DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_PLACEMENT"],"mappings":";;;;;;;;;;;IAAaA,6BAA6B,MAA7BA;IACAC,wBAAwB,MAAxBA;IACAC,uBAAuB,MAAvBA;IACAC,0BAA0B,MAA1BA;;AAHN,MAAMH,gCAAgC;AACtC,MAAMC,2BAA2B;AACjC,MAAMC,0BAA0B;AAChC,MAAMC,6BAA6B,yBAE1C,qCAAqC"}