import { StyleType } from '../../../theme' ; export const TextStyleProps = [ 'color' , 'fontFamily' , 'fontSize' , 'fontStyle' , 'fontWeight' , 'letterSpacing' , 'lineHeight' , 'textAlign' , 'textAlign' , 'textDecorationLine' , 'textDecorationStyle' , 'textDecorationColor' , 'textShadowColor' , 'textShadowColor' , 'textShadowOffset' , 'textShadowRadius' , 'textTransform' , 'writingDirection' , 'textAlignVertical' , 'includeFontPadding' , ] ; export const FlexStyleProps = [ 'alignContent' , 'alignItems' , 'alignSelf' , 'aspectRatio' , 'borderBottomWidth' , 'borderEndWidth' , 'borderLeftWidth' , 'borderRightWidth' , 'borderStartWidth' , 'borderTopWidth' , 'borderWidth' , 'bottom' , 'display' , 'end' , 'flex' , 'flexBasis' , 'flexDirection' , 'flexGrow' , 'flexShrink' , 'flexWrap' , 'height' , 'justifyContent' , 'left' , 'margin' , 'marginBottom' , 'marginEnd' , 'marginHorizontal' , 'marginLeft' , 'marginRight' , 'marginStart' , 'marginTop' , 'marginVertical' , 'maxHeight' , 'maxWidth' , 'minHeight' , 'minWidth' , 'overflow' , 'padding' , 'paddingBottom' , 'paddingEnd' , 'paddingHorizontal' , 'paddingLeft' , 'paddingRight' , 'paddingStart' , 'paddingTop' , 'paddingVertical' , 'position' , 'right' , 'start' , 'top' , 'width' , 'zIndex' , 'direction' , ] ; const FlexViewCrossStyleValues = [ 'borderBottomWidth' , 'borderLeftWidth' , 'borderRightWidth' , 'borderTopWidth' , 'borderWidth' , ] ; export const FlexViewCrossStyleProps = FlexStyleProps . filter ( ( el ) => ! FlexViewCrossStyleValues . includes ( el ) ) ; export interface Props { [ key ] : any ; } export interface RestProps { rest ? : Partial < Props > ; } export type AllOfProps = Partial < Props > ; export type AllWithRestProps = Partial < Props > & RestProps ; class NativePropsService { param source param from return public all ( source , from ) { if ( ! source ) { return { } ; } return from . reduce ( ( acc , prop ) : Partial < AllOfProps > => { return { ... acc , [ prop ] : source [ prop ] } ; } , { } ) ; } /**
     * Retrieves all props included in `from` array, rest props includes in under the `rest` key
     */ public allWithRest ( source , from ) { if ( ! source ) { return { rest : { } } ; } return Object . keys ( source ) . reduce ( ( acc , prop ) : Partial < AllWithRestProps > => { const { rest , ... allOf } = acc ; if ( from . includes ( prop ) ) { return { ... allOf , [ prop ] : source [ prop ] , rest } ; } return { ... allOf , rest : { ... rest , [ prop ] : source [ prop ] } } ; } , { } ) ; } param { StyleType } source param { string } key return { StyleType } public allWithPrefix ( source , key ) { return Object . keys ( source ) . filter ( ( styleName ) => styleName . includes ( key ) ) . reduce ( ( obj , styleKey ) => { return { ... obj , [ styleKey ] : source [ styleKey ] , } ; } , { } ) ; } } export const PropsService = new NativePropsService ( ) ;