62 lines
1.3 KiB
JavaScript
62 lines
1.3 KiB
JavaScript
import { isClient, unrefElement } from '@vueuse/core';
|
|
|
|
const buildPopperOptions = (props, modifiers = []) => {
|
|
const { placement, strategy, popperOptions } = props;
|
|
const options = {
|
|
placement,
|
|
strategy,
|
|
...popperOptions,
|
|
modifiers: [...genModifiers(props), ...modifiers]
|
|
};
|
|
deriveExtraModifiers(options, popperOptions == null ? void 0 : popperOptions.modifiers);
|
|
return options;
|
|
};
|
|
const unwrapMeasurableEl = ($el) => {
|
|
if (!isClient)
|
|
return;
|
|
return unrefElement($el);
|
|
};
|
|
function genModifiers(options) {
|
|
const { offset, gpuAcceleration, fallbackPlacements } = options;
|
|
return [
|
|
{
|
|
name: "offset",
|
|
options: {
|
|
offset: [0, offset != null ? offset : 12]
|
|
}
|
|
},
|
|
{
|
|
name: "preventOverflow",
|
|
options: {
|
|
padding: {
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: "flip",
|
|
options: {
|
|
padding: 5,
|
|
fallbackPlacements
|
|
}
|
|
},
|
|
{
|
|
name: "computeStyles",
|
|
options: {
|
|
gpuAcceleration
|
|
}
|
|
}
|
|
];
|
|
}
|
|
function deriveExtraModifiers(options, modifiers) {
|
|
if (modifiers) {
|
|
options.modifiers = [...options.modifiers, ...modifiers != null ? modifiers : []];
|
|
}
|
|
}
|
|
|
|
export { buildPopperOptions, unwrapMeasurableEl };
|
|
//# sourceMappingURL=utils.mjs.map
|