02600eeeda5ab52f1c23e46ee32c65f8b3557d797b4fa808a2d8cae4eb8bb9a58df9eb4809363da5f8417fafe2d9aafcb4a2d1f90b4ff554a1f174be4c1816 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { isClient, unrefElement } from '@vueuse/core';
  2. const buildPopperOptions = (props, modifiers = []) => {
  3. const { placement, strategy, popperOptions } = props;
  4. const options = {
  5. placement,
  6. strategy,
  7. ...popperOptions,
  8. modifiers: [...genModifiers(props), ...modifiers]
  9. };
  10. deriveExtraModifiers(options, popperOptions == null ? void 0 : popperOptions.modifiers);
  11. return options;
  12. };
  13. const unwrapMeasurableEl = ($el) => {
  14. if (!isClient)
  15. return;
  16. return unrefElement($el);
  17. };
  18. function genModifiers(options) {
  19. const { offset, gpuAcceleration, fallbackPlacements } = options;
  20. return [
  21. {
  22. name: "offset",
  23. options: {
  24. offset: [0, offset != null ? offset : 12]
  25. }
  26. },
  27. {
  28. name: "preventOverflow",
  29. options: {
  30. padding: {
  31. top: 0,
  32. bottom: 0,
  33. left: 0,
  34. right: 0
  35. }
  36. }
  37. },
  38. {
  39. name: "flip",
  40. options: {
  41. padding: 5,
  42. fallbackPlacements
  43. }
  44. },
  45. {
  46. name: "computeStyles",
  47. options: {
  48. gpuAcceleration
  49. }
  50. }
  51. ];
  52. }
  53. function deriveExtraModifiers(options, modifiers) {
  54. if (modifiers) {
  55. options.modifiers = [...options.modifiers, ...modifiers != null ? modifiers : []];
  56. }
  57. }
  58. export { buildPopperOptions, unwrapMeasurableEl };
  59. //# sourceMappingURL=utils.mjs.map