@coreui/vue-pro
Version:
UI Components Library for Vue.js
47 lines (45 loc) • 1.46 kB
JavaScript
const getAlignmentClassNames = (alignment) => {
const classNames = [];
if (typeof alignment === 'object') {
for (const key in alignment) {
classNames.push(`dropdown-menu${key === 'xs' ? '' : `-${key}`}-${alignment[key]}`);
}
}
if (typeof alignment === 'string') {
classNames.push(`dropdown-menu-${alignment}`);
}
return classNames;
};
const getPlacement = (placement, direction, alignment, isRTL) => {
let _placement = placement;
if (direction === 'dropup') {
_placement = isRTL ? 'top-end' : 'top-start';
}
if (direction === 'dropup-center') {
_placement = 'top';
}
if (direction === 'dropend') {
_placement = isRTL ? 'left-start' : 'right-start';
}
if (direction === 'dropstart') {
_placement = isRTL ? 'right-start' : 'left-start';
}
if (alignment === 'end') {
_placement = isRTL ? 'bottom-start' : 'bottom-end';
}
return _placement;
};
const getReferenceElement = (reference, dropdownToggleRef, dropdownRef) => {
if (reference === 'parent') {
return dropdownRef.value;
}
if (reference instanceof HTMLElement) {
return reference;
}
if (reference instanceof Object && 'value' in reference) {
return reference.value;
}
return dropdownToggleRef.value;
};
export { getAlignmentClassNames, getPlacement, getReferenceElement };
//# sourceMappingURL=utils.js.map