import * as R from 'ramda' ; import { AlignEdge } from '../types' ; export { AlignEdge } ; export type AlignHorizontal = 'left' | 'center' | 'right' ; export type AlignVertical = 'top' | 'middle' | 'bottom' ; const HORIZONTAL = [ 'left' , 'center' , 'right' ] ; const VERTICAL = [ 'top' , 'middle' , 'bottom' ] ; const contains = ( array , value ) => R . any ( item => item === value , array ) ; const isVertical = ( value ) => contains ( VERTICAL , value ) ; const isHorizontal = ( value ) => contains ( HORIZONTAL , value ) ; /**
 * Extracts the edge alignments from the given value.
 */ export function edges ( value , defaultHorizontal , defaultVertical ) { const parts = value . split ( ' ' ) ; if ( parts . length < 2 ) { if ( isHorizontal ( parts [ 0 ] ) ) { parts [ 1 ] = defaultVertical ; } if ( isVertical ( parts [ 0 ] ) ) { parts [ 1 ] = defaultHorizontal ; } } const horizontal = ( isHorizontal ( parts [ 0 ] ) ? parts [ 0 ] : parts [ 1 ] ) as AlignHorizontal ; const vertical = ( isVertical ( parts [ 0 ] ) ? parts [ 0 ] : parts [ 1 ] ) as AlignVertical ; return { horizontal , vertical } ; }