@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
18 lines (16 loc) • 771 B
JavaScript
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import { POSITIONS, ALIGNS } from "../consts";
var calculatePopoverPosition = function calculatePopoverPosition(preferredPosition, preferredHoriznotalPosition) {
var mappedPositions = Object.keys(POSITIONS).map(function (k) {
return POSITIONS[k];
});
var mappedAlignPositions = Object.keys(ALIGNS).map(function (k) {
return ALIGNS[k];
});
return [[preferredPosition].concat(_toConsumableArray(mappedPositions.filter(function (p) {
return p !== preferredPosition;
}))), [preferredHoriznotalPosition].concat(_toConsumableArray(mappedAlignPositions.filter(function (p) {
return p !== preferredHoriznotalPosition;
})))];
};
export default calculatePopoverPosition;