ant-design/components/select/mergedBuiltinPlacements.ts
lijianan 0b6356d984
chore: rename file .tsx => .ts ()
* chore: rename file .tsx => .ts

* fix: fix

* test: add test case
2024-01-03 08:45:11 +08:00

50 lines
1.1 KiB
TypeScript

import type { AlignType, BuildInPlacements } from '@rc-component/trigger';
import type { PopupOverflow } from '../config-provider/context';
const getBuiltInPlacements = (popupOverflow?: PopupOverflow): Record<string, AlignType> => {
const htmlRegion: AlignType['htmlRegion'] = popupOverflow === 'scroll' ? 'scroll' : 'visible';
const sharedConfig: AlignType = {
overflow: {
adjustX: true,
adjustY: true,
shiftY: true,
},
htmlRegion,
dynamicInset: true,
};
return {
bottomLeft: {
...sharedConfig,
points: ['tl', 'bl'],
offset: [0, 4],
},
bottomRight: {
...sharedConfig,
points: ['tr', 'br'],
offset: [0, 4],
},
topLeft: {
...sharedConfig,
points: ['bl', 'tl'],
offset: [0, -4],
},
topRight: {
...sharedConfig,
points: ['br', 'tr'],
offset: [0, -4],
},
};
};
function mergedBuiltinPlacements(
buildInPlacements?: BuildInPlacements,
popupOverflow?: PopupOverflow,
) {
return buildInPlacements || getBuiltInPlacements(popupOverflow);
}
export default mergedBuiltinPlacements;