mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
2329880074
* chore: use dynamicInset * test: update snapshot * test: update snapshot * chore: bump rc-trigger * chore: update snapshot
48 lines
1.1 KiB
TypeScript
48 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],
|
|
},
|
|
};
|
|
};
|
|
|
|
export default function useBuiltinPlacements(
|
|
buildInPlacements?: BuildInPlacements,
|
|
popupOverflow?: PopupOverflow,
|
|
) {
|
|
return buildInPlacements || getBuiltInPlacements(popupOverflow);
|
|
}
|