utils.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  2. require("../../../_virtual/_rolldown/runtime.js");
  3. let _vueuse_core = require("@vueuse/core");
  4. //#region ../../packages/components/popper/src/utils.ts
  5. const buildPopperOptions = (props, modifiers = []) => {
  6. const { placement, strategy, popperOptions } = props;
  7. const options = {
  8. placement,
  9. strategy,
  10. ...popperOptions,
  11. modifiers: [...genModifiers(props), ...modifiers]
  12. };
  13. deriveExtraModifiers(options, popperOptions?.modifiers);
  14. return options;
  15. };
  16. const unwrapMeasurableEl = ($el) => {
  17. if (!_vueuse_core.isClient) return;
  18. return (0, _vueuse_core.unrefElement)($el);
  19. };
  20. function genModifiers(options) {
  21. const { offset, gpuAcceleration, fallbackPlacements } = options;
  22. return [
  23. {
  24. name: "offset",
  25. options: { offset: [0, offset ?? 12] }
  26. },
  27. {
  28. name: "preventOverflow",
  29. options: { padding: {
  30. top: 0,
  31. bottom: 0,
  32. left: 0,
  33. right: 0
  34. } }
  35. },
  36. {
  37. name: "flip",
  38. options: {
  39. padding: 5,
  40. fallbackPlacements
  41. }
  42. },
  43. {
  44. name: "computeStyles",
  45. options: { gpuAcceleration }
  46. }
  47. ];
  48. }
  49. function deriveExtraModifiers(options, modifiers) {
  50. if (modifiers) options.modifiers = [...options.modifiers, ...modifiers ?? []];
  51. }
  52. //#endregion
  53. exports.buildPopperOptions = buildPopperOptions;
  54. exports.unwrapMeasurableEl = unwrapMeasurableEl;
  55. //# sourceMappingURL=utils.js.map