ant-design/components/select/useBuiltinPlacements.tsx
二货爱吃白萝卜 4299d774ac
chore: optimize Select like component popup logic (#41619)
* chore: bump trigger ver

* chore: support auto flip + shift

* test: update snapshot

* chore: use in TreeSelect & Cascader
2023-04-04 13:43:53 +08:00

38 lines
772 B
TypeScript

import type { AlignType, BuildInPlacements } from '@rc-component/trigger';
const sharedConfig = {
overflow: {
adjustX: true,
adjustY: true,
shiftY: true,
},
htmlRegion: 'visible' as const,
};
const defaultBuiltInPlacements: Record<string, AlignType> = {
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],
},
};
export default function useBuiltinPlacements(buildInPlacements?: BuildInPlacements) {
return buildInPlacements || defaultBuiltInPlacements;
}