@fluentui/react-positioning 0.0.0-nightly-20220715-0418.1 → 0.0.0-nightly-20221007-1237.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 (121) hide show
  1. package/CHANGELOG.json +80 -10
  2. package/CHANGELOG.md +33 -8
  3. package/dist/index.d.ts +9 -16
  4. package/lib/constants.js +5 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/createArrowStyles.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js.map +1 -1
  8. package/lib/index.js.map +1 -1
  9. package/lib/middleware/coverTarget.js +40 -0
  10. package/lib/middleware/coverTarget.js.map +1 -0
  11. package/lib/middleware/flip.js +19 -0
  12. package/lib/middleware/flip.js.map +1 -0
  13. package/lib/middleware/index.js +7 -0
  14. package/lib/middleware/index.js.map +1 -0
  15. package/lib/middleware/intersecting.js +21 -0
  16. package/lib/middleware/intersecting.js.map +1 -0
  17. package/lib/middleware/maxSize.js +43 -0
  18. package/lib/middleware/maxSize.js.map +1 -0
  19. package/lib/middleware/offset.js +11 -0
  20. package/lib/middleware/offset.js.map +1 -0
  21. package/lib/middleware/shift.js +30 -0
  22. package/lib/middleware/shift.js.map +1 -0
  23. package/lib/types.js.map +1 -1
  24. package/lib/usePositioning.js +234 -336
  25. package/lib/usePositioning.js.map +1 -1
  26. package/lib/usePositioningMouseTarget.js.map +1 -1
  27. package/lib/utils/debounce.js +22 -0
  28. package/lib/utils/debounce.js.map +1 -0
  29. package/lib/utils/fromFloatingUIPlacement.js +43 -0
  30. package/lib/utils/fromFloatingUIPlacement.js.map +1 -0
  31. package/lib/utils/getBoundary.js +5 -1
  32. package/lib/utils/getBoundary.js.map +1 -1
  33. package/lib/utils/getFloatingUIOffset.js +36 -0
  34. package/lib/utils/getFloatingUIOffset.js.map +1 -0
  35. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  36. package/lib/utils/getScrollParent.js +6 -0
  37. package/lib/utils/getScrollParent.js.map +1 -1
  38. package/lib/utils/hasAutoFocusFilter.js +28 -0
  39. package/lib/utils/hasAutoFocusFilter.js.map +1 -0
  40. package/lib/utils/index.js +6 -2
  41. package/lib/utils/index.js.map +1 -1
  42. package/lib/utils/mergeArrowOffset.js +1 -1
  43. package/lib/utils/mergeArrowOffset.js.map +1 -1
  44. package/lib/utils/parseFloatingUIPlacement.js +14 -0
  45. package/lib/utils/parseFloatingUIPlacement.js.map +1 -0
  46. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  47. package/lib/utils/toFloatingUIPlacement.js +40 -0
  48. package/lib/utils/toFloatingUIPlacement.js.map +1 -0
  49. package/lib/utils/toggleScrollListener.js +24 -0
  50. package/lib/utils/toggleScrollListener.js.map +1 -0
  51. package/lib/utils/useCallbackRef.js.map +1 -1
  52. package/lib-commonjs/constants.js +11 -0
  53. package/lib-commonjs/constants.js.map +1 -0
  54. package/lib-commonjs/createArrowStyles.js.map +1 -1
  55. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  56. package/lib-commonjs/index.js.map +1 -1
  57. package/lib-commonjs/middleware/coverTarget.js +50 -0
  58. package/lib-commonjs/middleware/coverTarget.js.map +1 -0
  59. package/lib-commonjs/middleware/flip.js +30 -0
  60. package/lib-commonjs/middleware/flip.js.map +1 -0
  61. package/lib-commonjs/middleware/index.js +20 -0
  62. package/lib-commonjs/middleware/index.js.map +1 -0
  63. package/lib-commonjs/middleware/intersecting.js +31 -0
  64. package/lib-commonjs/middleware/intersecting.js.map +1 -0
  65. package/lib-commonjs/middleware/maxSize.js +54 -0
  66. package/lib-commonjs/middleware/maxSize.js.map +1 -0
  67. package/lib-commonjs/middleware/offset.js +22 -0
  68. package/lib-commonjs/middleware/offset.js.map +1 -0
  69. package/lib-commonjs/middleware/shift.js +41 -0
  70. package/lib-commonjs/middleware/shift.js.map +1 -0
  71. package/lib-commonjs/types.js.map +1 -1
  72. package/lib-commonjs/usePositioning.js +236 -337
  73. package/lib-commonjs/usePositioning.js.map +1 -1
  74. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  75. package/lib-commonjs/utils/debounce.js +31 -0
  76. package/lib-commonjs/utils/debounce.js.map +1 -0
  77. package/lib-commonjs/utils/fromFloatingUIPlacement.js +52 -0
  78. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -0
  79. package/lib-commonjs/utils/getBoundary.js +5 -1
  80. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  81. package/lib-commonjs/utils/getFloatingUIOffset.js +46 -0
  82. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -0
  83. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  84. package/lib-commonjs/utils/getScrollParent.js +10 -1
  85. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  86. package/lib-commonjs/utils/hasAutoFocusFilter.js +37 -0
  87. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -0
  88. package/lib-commonjs/utils/index.js +10 -2
  89. package/lib-commonjs/utils/index.js.map +1 -1
  90. package/lib-commonjs/utils/mergeArrowOffset.js +1 -1
  91. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  92. package/lib-commonjs/utils/parseFloatingUIPlacement.js +23 -0
  93. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -0
  94. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  95. package/lib-commonjs/utils/toFloatingUIPlacement.js +49 -0
  96. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -0
  97. package/lib-commonjs/utils/toggleScrollListener.js +34 -0
  98. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -0
  99. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  100. package/package.json +8 -12
  101. package/dist/tsdoc-metadata.json +0 -11
  102. package/lib/isIntersectingModifier.js +0 -26
  103. package/lib/isIntersectingModifier.js.map +0 -1
  104. package/lib/utils/fromPopperPlacement.js +0 -40
  105. package/lib/utils/fromPopperPlacement.js.map +0 -1
  106. package/lib/utils/getPopperOffset.js +0 -44
  107. package/lib/utils/getPopperOffset.js.map +0 -1
  108. package/lib/utils/parsePopperPlacement.js +0 -14
  109. package/lib/utils/parsePopperPlacement.js.map +0 -1
  110. package/lib/utils/positioningHelper.js +0 -49
  111. package/lib/utils/positioningHelper.js.map +0 -1
  112. package/lib-commonjs/isIntersectingModifier.js +0 -34
  113. package/lib-commonjs/isIntersectingModifier.js.map +0 -1
  114. package/lib-commonjs/utils/fromPopperPlacement.js +0 -50
  115. package/lib-commonjs/utils/fromPopperPlacement.js.map +0 -1
  116. package/lib-commonjs/utils/getPopperOffset.js +0 -54
  117. package/lib-commonjs/utils/getPopperOffset.js.map +0 -1
  118. package/lib-commonjs/utils/parsePopperPlacement.js +0 -23
  119. package/lib-commonjs/utils/parsePopperPlacement.js.map +0 -1
  120. package/lib-commonjs/utils/positioningHelper.js +0 -61
  121. package/lib-commonjs/utils/positioningHelper.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DATA_POSITIONING_PLACEMENT = exports.DATA_POSITIONING_HIDDEN = exports.DATA_POSITIONING_ESCAPED = exports.DATA_POSITIONING_INTERSECTING = void 0;
7
+ exports.DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';
8
+ exports.DATA_POSITIONING_ESCAPED = 'data-popper-escaped';
9
+ exports.DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';
10
+ exports.DATA_POSITIONING_PLACEMENT = 'data-popper-placement';
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;AAAa,OAAA,CAAA,6BAAA,GAAgC,6BAAhC;AACA,OAAA,CAAA,wBAAA,GAA2B,qBAA3B;AACA,OAAA,CAAA,uBAAA,GAA0B,8BAA1B;AACA,OAAA,CAAA,0BAAA,GAA6B,uBAA7B","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"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAsCA;;;;;;;;;;;;;;;;;;;;;;AAsBG;;;AACH,SAAgB,iBAAhB,CAAkC,OAAlC,EAAmE;EACjE,MAAM;IACJ,WADI;IAEJ,WAAW,GAAG,KAFV;IAGJ,WAAW,GAAG,OAHV;IAIJ,WAAW,GAAG,aAAA,CAAA,MAAA,CAAO;EAJjB,IAKF,OALJ;EAOA,OAAO;IACL,QAAQ,EAAE,UADL;IAEL,eAAe,EAAE,SAFZ;IAGL,UAAU,EAAE,QAHP;IAIL,MAAM,EAAE,CAAC,CAJJ;IAML,IAAI,WAAW,IAAI,uBAAuB,CAAC,WAAD,CAA1C,CANK;IAQL,YAAY;MACV,OAAO,EAAE,IADC;MAEV,UAAU,EAAE,SAFF;MAGV,QAAQ,EAAE,UAHA;MAIV,SAAS,EAAE,YAJD;MAKV,KAAK,EAAE,SALG;MAMV,MAAM,EAAE,SANE;MAOV,eAAe,EAAE,SAPP;MAQV,GAAG,OAAA,CAAA,UAAA,CAAW,WAAX,CACD,GAAG,WAAW,gBADb,EAED,GAAG,WAAW,gBAFb,EAGD,GAAG,WAAW,gBAHb,CARO;MAaV,GAAG,OAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CAbO;MAcV,uBAAuB,EAAE,aAAA,CAAA,MAAA,CAAO,iBAdtB;MAeV,SAAS,EAAE;IAfD,CARP;IA0BL;IACA,2CAA2C;MACzC,MAAM,EAAE,IAAI,WAAW,EADkB;MAEzC,WAAW;IAF8B,CA3BtC;IA+BL,6CAA6C;MAC3C,IAAI,EAAE,IAAI,WAAW,gBADsB;MAE3C,WAAW;IAFgC,CA/BxC;IAmCL,8CAA8C;MAC5C,GAAG,EAAE,IAAI,WAAW,EADwB;MAE5C,WAAW;IAFiC,CAnCzC;IAuCL,4CAA4C;MAC1C,KAAK,EAAE,IAAI,WAAW,gBADoB;MAE1C,WAAW;IAF+B;EAvCvC,CAAP;AA4CD;;AApDD,OAAA,CAAA,iBAAA,GAAA,iBAAA;AAsDA;;;;;;AAMG;;AACH,SAAgB,uBAAhB,CAAwC,WAAxC,EAA2D;EACzD;EACA;EACA,MAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,IAAzC;EACA,OAAO;IAAE,KAAK,EAAE,UAAT;IAAqB,MAAM,EAAE;EAA7B,CAAP;AACD;;AALD,OAAA,CAAA,uBAAA,GAAA,uBAAA","sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * @internal\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAsCA;;;;;;;;;;;;;;;;;;;;;;AAsBG;;;AACH,SAAgB,iBAAhB,CAAkC,OAAlC,EAAmE;EACjE,MAAM;IACJ,WADI;IAEJ,WAAW,GAAG,KAFV;IAGJ,WAAW,GAAG,OAHV;IAIJ,WAAW,GAAG,aAAA,CAAA,MAAA,CAAO;EAJjB,IAKF,OALJ;EAOA,OAAO;IACL,QAAQ,EAAE,UADL;IAEL,eAAe,EAAE,SAFZ;IAGL,UAAU,EAAE,QAHP;IAIL,MAAM,EAAE,CAAC,CAJJ;IAML,IAAI,WAAW,IAAI,uBAAuB,CAAC,WAAD,CAA1C,CANK;IAQL,YAAY;MACV,OAAO,EAAE,IADC;MAEV,UAAU,EAAE,SAFF;MAGV,QAAQ,EAAE,UAHA;MAIV,SAAS,EAAE,YAJD;MAKV,KAAK,EAAE,SALG;MAMV,MAAM,EAAE,SANE;MAOV,eAAe,EAAE,SAPP;MAQV,GAAG,OAAA,CAAA,UAAA,CAAW,WAAX,CACD,GAAG,WAAW,gBADb,EAED,GAAG,WAAW,gBAFb,EAGD,GAAG,WAAW,gBAHb,CARO;MAaV,GAAG,OAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CAbO;MAcV,uBAAuB,EAAE,aAAA,CAAA,MAAA,CAAO,iBAdtB;MAeV,SAAS,EAAE;IAfD,CARP;IA0BL;IACA,2CAA2C;MACzC,MAAM,EAAE,IAAI,WAAW,EADkB;MAEzC,WAAW;IAF8B,CA3BtC;IA+BL,6CAA6C;MAC3C,IAAI,EAAE,IAAI,WAAW,gBADsB;MAE3C,WAAW;IAFgC,CA/BxC;IAmCL,8CAA8C;MAC5C,GAAG,EAAE,IAAI,WAAW,EADwB;MAE5C,WAAW;IAFiC,CAnCzC;IAuCL,4CAA4C;MAC1C,KAAK,EAAE,IAAI,WAAW,gBADoB;MAE1C,WAAW;IAF+B;EAvCvC,CAAP;AA4CD;;AApDD,OAAA,CAAA,iBAAA,GAAA,iBAAA;AAsDA;;;;;;AAMG;;AACH,SAAgB,uBAAhB,CAAwC,WAAxC,EAA2D;EACzD;EACA;EACA,MAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,IAAzC;EACA,OAAO;IAAE,KAAK,EAAE,UAAT;IAAqB,MAAM,EAAE;EAA7B,CAAP;AACD;;AALD,OAAA,CAAA,uBAAA,GAAA,uBAAA","sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * @internal\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["createVirtualElementFromClick.ts"],"names":[],"mappings":";;;;;;AAEA;;;AAGG;;AACH,SAAgB,6BAAhB,CAA8C,WAA9C,EAAqE;EACnE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAzB;EACA,MAAM,GAAG,GAAG,WAAW,CAAC,OAAxB;EACA,MAAM,KAAK,GAAG,IAAI,GAAG,CAArB;EACA,MAAM,MAAM,GAAG,GAAG,GAAG,CAArB;;EAEA,SAAS,qBAAT,GAA8B;IAC5B,OAAO;MACL,IADK;MAEL,GAFK;MAGL,KAHK;MAIL,MAJK;MAKL,CAAC,EAAE,IALE;MAML,CAAC,EAAE,GANE;MAOL,MAAM,EAAE,CAPH;MAQL,KAAK,EAAE;IARF,CAAP;EAUD;;EAED,OAAO;IACL;EADK,CAAP;AAGD;;AAtBD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;;;;AAEA;;;AAGG;;AACH,SAAgB,6BAAhB,CAA8C,WAA9C,EAAqE;EACnE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAzB;EACA,MAAM,GAAG,GAAG,WAAW,CAAC,OAAxB;EACA,MAAM,KAAK,GAAG,IAAI,GAAG,CAArB;EACA,MAAM,MAAM,GAAG,GAAG,GAAG,CAArB;;EAEA,SAAS,qBAAT,GAA8B;IAC5B,OAAO;MACL,IADK;MAEL,GAFK;MAGL,KAHK;MAIL,MAJK;MAKL,CAAC,EAAE,IALE;MAML,CAAC,EAAE,GANE;MAOL,MAAM,EAAE,CAPH;MAQL,KAAK,EAAE;IARF,CAAP;EAUD;;EAED,OAAO;IACL;EADK,CAAP;AAGD;;AAtBD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,+BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,+BAAA,CAAA,6BAAA;EAA6B;AAA7B,CAAA;;AACT,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,yBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,uBAAA;EAAuB;AAAvB,CAAA;AAAyB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,iBAAA;EAAiB;AAAjB,CAAA;;AAElC,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,cAAA;EAAc;AAAd,CAAA;;AACT,IAAA,2BAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,2BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,2BAAA,CAAA,yBAAA;EAAyB;AAAzB,CAAA;;AACT,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n} from './types';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,+BAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,+BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,+BAAA,CAAA,6BAAA;EAA6B;AAA7B,CAAA;;AACT,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,yBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,uBAAA;EAAuB;AAAvB,CAAA;AAAyB,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,mBAAA,CAAA,iBAAA;EAAiB;AAAjB,CAAA;;AAElC,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,gBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,cAAA;EAAc;AAAd,CAAA;;AACT,IAAA,2BAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,2BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,2BAAA,CAAA,yBAAA;EAAyB;AAAzB,CAAA;;AACT,IAAA,OAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,6BAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,2BAAA;EAA2B;AAA3B,CAAA;AAA6B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,OAAA,CAAA,gBAAA;EAAgB;AAAhB,CAAA","sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport type {\n Alignment,\n AutoSize,\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningImperativeRef,\n PositioningProps,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n} from './types';\n"],"sourceRoot":""}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.coverTarget = void 0;
7
+
8
+ const index_1 = /*#__PURE__*/require("../utils/index");
9
+
10
+ function coverTarget() {
11
+ return {
12
+ name: 'coverTarget',
13
+ fn: middlewareArguments => {
14
+ const {
15
+ placement,
16
+ rects,
17
+ x,
18
+ y
19
+ } = middlewareArguments;
20
+ const basePlacement = index_1.parseFloatingUIPlacement(placement).side;
21
+ const newCoords = {
22
+ x,
23
+ y
24
+ };
25
+
26
+ switch (basePlacement) {
27
+ case 'bottom':
28
+ newCoords.y -= rects.reference.height;
29
+ break;
30
+
31
+ case 'top':
32
+ newCoords.y += rects.reference.height;
33
+ break;
34
+
35
+ case 'left':
36
+ newCoords.x += rects.reference.width;
37
+ break;
38
+
39
+ case 'right':
40
+ newCoords.x -= rects.reference.width;
41
+ break;
42
+ }
43
+
44
+ return newCoords;
45
+ }
46
+ };
47
+ }
48
+
49
+ exports.coverTarget = coverTarget;
50
+ //# sourceMappingURL=coverTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/coverTarget.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,SAAgB,WAAhB,GAA2B;EACzB,OAAO;IACL,IAAI,EAAE,aADD;IAEL,EAAE,EAAE,mBAAmB,IAAG;MACxB,MAAM;QAAE,SAAF;QAAa,KAAb;QAAoB,CAApB;QAAuB;MAAvB,IAA6B,mBAAnC;MACA,MAAM,aAAa,GAAG,OAAA,CAAA,wBAAA,CAAyB,SAAzB,EAAoC,IAA1D;MACA,MAAM,SAAS,GAAG;QAAE,CAAF;QAAK;MAAL,CAAlB;;MAEA,QAAQ,aAAR;QACE,KAAK,QAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,KAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,MAA/B;UACA;;QACF,KAAK,MAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;;QACF,KAAK,OAAL;UACE,SAAS,CAAC,CAAV,IAAe,KAAK,CAAC,SAAN,CAAgB,KAA/B;UACA;MAZJ;;MAeA,OAAO,SAAP;IACD;EAvBI,CAAP;AAyBD;;AA1BD,OAAA,CAAA,WAAA,GAAA,WAAA","sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"sourceRoot":""}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flip = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ const index_1 = /*#__PURE__*/require("../utils/index");
11
+
12
+ function flip(options) {
13
+ const {
14
+ hasScrollableElement,
15
+ flipBoundary,
16
+ container
17
+ } = options;
18
+ return dom_1.flip({ ...(hasScrollableElement && {
19
+ boundary: 'clippingAncestors'
20
+ }),
21
+ ...(flipBoundary && {
22
+ altBoundary: true,
23
+ boundary: index_1.getBoundary(container, flipBoundary)
24
+ }),
25
+ fallbackStrategy: 'bestFit'
26
+ });
27
+ }
28
+
29
+ exports.flip = flip;
30
+ //# sourceMappingURL=flip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/flip.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAOA,SAAgB,IAAhB,CAAqB,OAArB,EAAmD;EACjD,MAAM;IAAE,oBAAF;IAAwB,YAAxB;IAAsC;EAAtC,IAAoD,OAA1D;EAEA,OAAO,KAAA,CAAA,IAAA,CAAS,EACd,IAAI,oBAAoB,IAAI;MAAE,QAAQ,EAAE;IAAZ,CAA5B,CADc;IAEd,IAAI,YAAY,IAAI;MAAE,WAAW,EAAE,IAAf;MAAqB,QAAQ,EAAE,OAAA,CAAA,WAAA,CAAY,SAAZ,EAAuB,YAAvB;IAA/B,CAApB,CAFc;IAGd,gBAAgB,EAAE;EAHJ,CAAT,CAAP;AAKD;;AARD,OAAA,CAAA,IAAA,GAAA,IAAA","sourcesContent":["import { flip as baseFlip } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/index';\n\nexport interface FlipMiddlewareOptions extends Pick<PositioningOptions, 'flipBoundary'> {\n hasScrollableElement?: boolean;\n container: HTMLElement | null;\n}\n\nexport function flip(options: FlipMiddlewareOptions) {\n const { hasScrollableElement, flipBoundary, container } = options;\n\n return baseFlip({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(flipBoundary && { altBoundary: true, boundary: getBoundary(container, flipBoundary) }),\n fallbackStrategy: 'bestFit',\n });\n}\n"],"sourceRoot":""}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./coverTarget"), exports);
10
+
11
+ tslib_1.__exportStar(require("./flip"), exports);
12
+
13
+ tslib_1.__exportStar(require("./intersecting"), exports);
14
+
15
+ tslib_1.__exportStar(require("./maxSize"), exports);
16
+
17
+ tslib_1.__exportStar(require("./offset"), exports);
18
+
19
+ tslib_1.__exportStar(require("./shift"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"],"sourceRoot":""}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.intersecting = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ function intersecting() {
11
+ return {
12
+ name: 'intersectionObserver',
13
+ fn: async middlewareArguments => {
14
+ const floatingRect = middlewareArguments.rects.floating;
15
+ const altOverflow = await dom_1.detectOverflow(middlewareArguments, {
16
+ altBoundary: true
17
+ });
18
+ const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;
19
+ const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;
20
+ const isIntersecting = isIntersectingTop || isIntersectingBottom;
21
+ return {
22
+ data: {
23
+ intersecting: isIntersecting
24
+ }
25
+ };
26
+ }
27
+ };
28
+ }
29
+
30
+ exports.intersecting = intersecting;
31
+ //# sourceMappingURL=intersecting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/intersecting.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,SAAgB,YAAhB,GAA4B;EAC1B,OAAO;IACL,IAAI,EAAE,sBADD;IAEL,EAAE,EAAE,MAAM,mBAAN,IAA4B;MAC9B,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAApB,CAA0B,QAA/C;MACA,MAAM,WAAW,GAAG,MAAM,KAAA,CAAA,cAAA,CAAe,mBAAf,EAAoC;QAAE,WAAW,EAAE;MAAf,CAApC,CAA1B;MAEA,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAZ,GAAkB,YAAY,CAAC,MAA/B,IAAyC,WAAW,CAAC,GAAZ,GAAkB,CAArF;MACA,MAAM,oBAAoB,GAAG,WAAW,CAAC,MAAZ,GAAqB,YAAY,CAAC,MAAlC,IAA4C,WAAW,CAAC,MAAZ,GAAqB,CAA9F;MAEA,MAAM,cAAc,GAAG,iBAAiB,IAAI,oBAA5C;MAEA,OAAO;QACL,IAAI,EAAE;UACJ,YAAY,EAAE;QADV;MADD,CAAP;IAKD;EAhBI,CAAP;AAkBD;;AAnBD,OAAA,CAAA,YAAA,GAAA,YAAA","sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { detectOverflow } from '@floating-ui/dom';\n\nexport function intersecting(): Middleware {\n return {\n name: 'intersectionObserver',\n fn: async middlewareArguments => {\n const floatingRect = middlewareArguments.rects.floating;\n const altOverflow = await detectOverflow(middlewareArguments, { altBoundary: true });\n\n const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;\n const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;\n\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n\n return {\n data: {\n intersecting: isIntersecting,\n },\n };\n },\n };\n}\n"],"sourceRoot":""}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.maxSize = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ const index_1 = /*#__PURE__*/require("../utils/index");
11
+
12
+ function maxSize(autoSize) {
13
+ return {
14
+ name: 'maxSize',
15
+ fn: async middlewareArguments => {
16
+ const {
17
+ placement,
18
+ rects,
19
+ elements,
20
+ middlewareData
21
+ } = middlewareArguments;
22
+ const basePlacement = index_1.parseFloatingUIPlacement(placement).side;
23
+ const overflow = await dom_1.detectOverflow(middlewareArguments);
24
+ const {
25
+ x,
26
+ y
27
+ } = middlewareData.shift || {
28
+ x: 0,
29
+ y: 0
30
+ };
31
+ const {
32
+ width,
33
+ height
34
+ } = rects.floating;
35
+ const widthProp = basePlacement === 'left' ? 'left' : 'right';
36
+ const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
37
+ const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width');
38
+ const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height');
39
+
40
+ if (applyMaxWidth) {
41
+ elements.floating.style.maxWidth = `${width - overflow[widthProp] - x}px`;
42
+ }
43
+
44
+ if (applyMaxHeight) {
45
+ elements.floating.style.maxHeight = `${height - overflow[heightProp] - y}px`;
46
+ }
47
+
48
+ return {};
49
+ }
50
+ };
51
+ }
52
+
53
+ exports.maxSize = maxSize;
54
+ //# sourceMappingURL=maxSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/maxSize.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAGA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAEA,SAAgB,OAAhB,CAAwB,QAAxB,EAAgE;EAC9D,OAAO;IACL,IAAI,EAAE,SADD;IAEL,EAAE,EAAE,MAAM,mBAAN,IAA4B;MAC9B,MAAM;QAAE,SAAF;QAAa,KAAb;QAAoB,QAApB;QAA8B;MAA9B,IAAiD,mBAAvD;MACA,MAAM,aAAa,GAAG,OAAA,CAAA,wBAAA,CAAyB,SAAzB,EAAoC,IAA1D;MAEA,MAAM,QAAQ,GAAG,MAAM,KAAA,CAAA,cAAA,CAAe,mBAAf,CAAvB;MACA,MAAM;QAAE,CAAF;QAAK;MAAL,IAAW,cAAc,CAAC,KAAf,IAAwB;QAAE,CAAC,EAAE,CAAL;QAAQ,CAAC,EAAE;MAAX,CAAzC;MACA,MAAM;QAAE,KAAF;QAAS;MAAT,IAAoB,KAAK,CAAC,QAAhC;MAEA,MAAM,SAAS,GAAS,aAAa,KAAK,MAAlB,GAA2B,MAA3B,GAAoC,OAA5D;MACA,MAAM,UAAU,GAAS,aAAa,KAAK,KAAlB,GAA0B,KAA1B,GAAkC,QAA3D;MAEA,MAAM,aAAa,GACjB,QAAQ,KAAK,QAAb,IACA,QAAQ,KAAK,cADb,IAEC,QAAQ,CAAC,SAAD,CAAR,GAAsB,CAAtB,KAA4B,QAAQ,KAAK,IAAb,IAAqB,QAAQ,KAAK,OAA9D,CAHH;MAIA,MAAM,cAAc,GAClB,QAAQ,KAAK,QAAb,IACA,QAAQ,KAAK,eADb,IAEC,QAAQ,CAAC,UAAD,CAAR,GAAuB,CAAvB,KAA6B,QAAQ,KAAK,IAAb,IAAqB,QAAQ,KAAK,QAA/D,CAHH;;MAKA,IAAI,aAAJ,EAAmB;QACjB,QAAQ,CAAC,QAAT,CAAkB,KAAlB,CAAwB,QAAxB,GAAmC,GAAG,KAAK,GAAG,QAAQ,CAAC,SAAD,CAAhB,GAA8B,CAAC,IAArE;MACD;;MACD,IAAI,cAAJ,EAAoB;QAClB,QAAQ,CAAC,QAAT,CAAkB,KAAlB,CAAwB,SAAxB,GAAoC,GAAG,MAAM,GAAG,QAAQ,CAAC,UAAD,CAAjB,GAAgC,CAAC,IAAxE;MACD;;MAED,OAAO,EAAP;IACD;EA9BI,CAAP;AAgCD;;AAjCD,OAAA,CAAA,OAAA,GAAA,OAAA","sourcesContent":["import { detectOverflow } from '@floating-ui/dom';\nimport type { Middleware, Side } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function maxSize(autoSize: PositioningOptions['autoSize']): Middleware {\n return {\n name: 'maxSize',\n fn: async middlewareArguments => {\n const { placement, rects, elements, middlewareData } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n\n const overflow = await detectOverflow(middlewareArguments);\n const { x, y } = middlewareData.shift || { x: 0, y: 0 };\n const { width, height } = rects.floating;\n\n const widthProp: Side = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: Side = basePlacement === 'top' ? 'top' : 'bottom';\n\n const applyMaxWidth =\n autoSize === 'always' ||\n autoSize === 'width-always' ||\n (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width'));\n const applyMaxHeight =\n autoSize === 'always' ||\n autoSize === 'height-always' ||\n (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height'));\n\n if (applyMaxWidth) {\n elements.floating.style.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (applyMaxHeight) {\n elements.floating.style.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n\n return {};\n },\n };\n}\n"],"sourceRoot":""}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.offset = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ const getFloatingUIOffset_1 = /*#__PURE__*/require("../utils/getFloatingUIOffset");
11
+ /**
12
+ * Wraps floating UI offset middleware to to transform offset value
13
+ */
14
+
15
+
16
+ function offset(offsetValue) {
17
+ const floatingUIOffset = getFloatingUIOffset_1.getFloatingUIOffset(offsetValue);
18
+ return dom_1.offset(floatingUIOffset);
19
+ }
20
+
21
+ exports.offset = offset;
22
+ //# sourceMappingURL=offset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/offset.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,MAAA,qBAAA,gBAAA,OAAA,CAAA,8BAAA,CAAA;AAEA;;AAEG;;;AACH,SAAgB,MAAhB,CAAuB,WAAvB,EAAgE;EAC9D,MAAM,gBAAgB,GAAG,qBAAA,CAAA,mBAAA,CAAoB,WAApB,CAAzB;EACA,OAAO,KAAA,CAAA,MAAA,CAAW,gBAAX,CAAP;AACD;;AAHD,OAAA,CAAA,MAAA,GAAA,MAAA","sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n\n/**\n * Wraps floating UI offset middleware to to transform offset value\n */\nexport function offset(offsetValue: PositioningOptions['offset']) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"sourceRoot":""}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shift = void 0;
7
+
8
+ const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
9
+
10
+ const index_1 = /*#__PURE__*/require("../utils/index");
11
+ /**
12
+ * Wraps the floating UI shift middleware for easier usage of our options
13
+ */
14
+
15
+
16
+ function shift(options) {
17
+ const {
18
+ hasScrollableElement,
19
+ disableTether,
20
+ overflowBoundary,
21
+ container
22
+ } = options;
23
+ return dom_1.shift({ ...(hasScrollableElement && {
24
+ boundary: 'clippingAncestors'
25
+ }),
26
+ ...(disableTether && {
27
+ crossAxis: disableTether === 'all',
28
+ limiter: dom_1.limitShift({
29
+ crossAxis: disableTether !== 'all',
30
+ mainAxis: false
31
+ })
32
+ }),
33
+ ...(overflowBoundary && {
34
+ altBoundary: true,
35
+ boundary: index_1.getBoundary(container, overflowBoundary)
36
+ })
37
+ });
38
+ }
39
+
40
+ exports.shift = shift;
41
+ //# sourceMappingURL=shift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/middleware/shift.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAQA;;AAEG;;;AACH,SAAgB,KAAhB,CAAsB,OAAtB,EAAqD;EACnD,MAAM;IAAE,oBAAF;IAAwB,aAAxB;IAAuC,gBAAvC;IAAyD;EAAzD,IAAuE,OAA7E;EAEA,OAAO,KAAA,CAAA,KAAA,CAAU,EACf,IAAI,oBAAoB,IAAI;MAAE,QAAQ,EAAE;IAAZ,CAA5B,CADe;IAEf,IAAI,aAAa,IAAI;MACnB,SAAS,EAAE,aAAa,KAAK,KADV;MAEnB,OAAO,EAAE,KAAA,CAAA,UAAA,CAAW;QAAE,SAAS,EAAE,aAAa,KAAK,KAA/B;QAAsC,QAAQ,EAAE;MAAhD,CAAX;IAFU,CAArB,CAFe;IAMf,IAAI,gBAAgB,IAAI;MAAE,WAAW,EAAE,IAAf;MAAqB,QAAQ,EAAE,OAAA,CAAA,WAAA,CAAY,SAAZ,EAAuB,gBAAvB;IAA/B,CAAxB;EANe,CAAV,CAAP;AAQD;;AAXD,OAAA,CAAA,KAAA,GAAA,KAAA","sourcesContent":["import { shift as baseShift, limitShift } from '@floating-ui/dom';\nimport type { PositioningOptions } from '../types';\nimport { getBoundary } from '../utils/index';\n\nexport interface ShiftMiddlewareOptions extends Pick<PositioningOptions, 'overflowBoundary'> {\n hasScrollableElement?: boolean;\n disableTether?: PositioningOptions['unstable_disableTether'];\n container: HTMLElement | null;\n}\n\n/**\n * Wraps the floating UI shift middleware for easier usage of our options\n */\nexport function shift(options: ShiftMiddlewareOptions) {\n const { hasScrollableElement, disableTether, overflowBoundary, container } = options;\n\n return baseShift({\n ...(hasScrollableElement && { boundary: 'clippingAncestors' }),\n ...(disableTether && {\n crossAxis: disableTether === 'all',\n limiter: limitShift({ crossAxis: disableTether !== 'all', mainAxis: false }),\n }),\n ...(overflowBoundary && { altBoundary: true, boundary: getBoundary(container, overflowBoundary) }),\n });\n}\n"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}