mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
19 lines
416 B
TypeScript
19 lines
416 B
TypeScript
import type { Placement } from '@floating-ui/react'
|
|
|
|
type ParsedPlacement = {
|
|
side: 'top' | 'bottom' | 'left' | 'right'
|
|
align: 'start' | 'center' | 'end'
|
|
}
|
|
|
|
export function parsePlacement(placement: Placement): ParsedPlacement {
|
|
const [side, align] = placement.split('-') as [
|
|
ParsedPlacement['side'],
|
|
ParsedPlacement['align'] | undefined,
|
|
]
|
|
|
|
return {
|
|
side,
|
|
align: align ?? 'center',
|
|
}
|
|
}
|