rsuite
Version:
A suite of react components
23 lines (19 loc) • 486 B
JavaScript
/**
* placementPolyfill('bottomLeft');
* output 'bottomStart'
*/
function placementPolyfill(placement, rtl) {
if (rtl === void 0) {
rtl = false;
}
if (typeof placement === 'string') {
if (rtl) {
placement = placement.replace(/left|right/, function (m) {
return m === 'left' ? 'right' : 'left';
});
}
return placement.replace(/Left|Top/, 'Start').replace(/Right|Bottom/, 'End');
}
return placement;
}
export default placementPolyfill;