You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
exports.toModifierMap = toModifierMap;
|
|
exports.toModifierArray = toModifierArray;
|
|
exports.default = mergeOptionsWithPopperConfig;
|
|
|
|
function toModifierMap(modifiers) {
|
|
const result = {};
|
|
|
|
if (!Array.isArray(modifiers)) {
|
|
return modifiers || result;
|
|
} // eslint-disable-next-line no-unused-expressions
|
|
|
|
|
|
modifiers == null ? void 0 : modifiers.forEach(m => {
|
|
result[m.name] = m;
|
|
});
|
|
return result;
|
|
}
|
|
|
|
function toModifierArray(map = {}) {
|
|
if (Array.isArray(map)) return map;
|
|
return Object.keys(map).map(k => {
|
|
map[k].name = k;
|
|
return map[k];
|
|
});
|
|
}
|
|
|
|
function mergeOptionsWithPopperConfig({
|
|
enabled,
|
|
enableEvents,
|
|
placement,
|
|
flip,
|
|
offset,
|
|
fixed,
|
|
containerPadding,
|
|
arrowElement,
|
|
popperConfig = {}
|
|
}) {
|
|
var _modifiers$preventOve, _modifiers$preventOve2, _modifiers$offset, _modifiers$arrow;
|
|
|
|
const modifiers = toModifierMap(popperConfig.modifiers);
|
|
return Object.assign({}, popperConfig, {
|
|
placement,
|
|
enabled,
|
|
strategy: fixed ? 'fixed' : popperConfig.strategy,
|
|
modifiers: toModifierArray(Object.assign({}, modifiers, {
|
|
eventListeners: {
|
|
enabled: enableEvents
|
|
},
|
|
preventOverflow: Object.assign({}, modifiers.preventOverflow, {
|
|
options: containerPadding ? Object.assign({
|
|
padding: containerPadding
|
|
}, (_modifiers$preventOve = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve.options) : (_modifiers$preventOve2 = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve2.options
|
|
}),
|
|
offset: {
|
|
options: Object.assign({
|
|
offset
|
|
}, (_modifiers$offset = modifiers.offset) == null ? void 0 : _modifiers$offset.options)
|
|
},
|
|
arrow: Object.assign({}, modifiers.arrow, {
|
|
enabled: !!arrowElement,
|
|
options: Object.assign({}, (_modifiers$arrow = modifiers.arrow) == null ? void 0 : _modifiers$arrow.options, {
|
|
element: arrowElement
|
|
})
|
|
}),
|
|
flip: Object.assign({
|
|
enabled: !!flip
|
|
}, modifiers.flip)
|
|
}))
|
|
});
|
|
} |