1
- import TextStylesPropTypes from 'react-native/Libraries/Text/TextStylePropTypes' ;
2
- import DeprecatedViewStylePropTypes from 'react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes' ;
3
- import DeprecatedImageStylesPropTypes from 'react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes' ;
1
+ // PropTypes have been deprecated since 0.58. This is why these array are now hardcoded. This lets us preserve
2
+ // a style checking at runtime while keeping the module compatible with all react-native versions.
3
+ const ImageStylePropTypes = [ 'display' , 'width' , 'height' , 'start' , 'end' , 'top' , 'left' , 'right' , 'bottom' , 'minWidth' , 'maxWidth' , 'minHeight' , 'maxHeight' , 'margin' , 'marginVertical' , 'marginHorizontal' , 'marginTop' , 'marginBottom' , 'marginLeft' , 'marginRight' , 'marginStart' , 'marginEnd' , 'padding' , 'paddingVertical' , 'paddingHorizontal' , 'paddingTop' , 'paddingBottom' , 'paddingLeft' , 'paddingRight' , 'paddingStart' , 'paddingEnd' , 'borderWidth' , 'borderTopWidth' , 'borderStartWidth' , 'borderEndWidth' , 'borderRightWidth' , 'borderBottomWidth' , 'borderLeftWidth' , 'position' , 'flexDirection' , 'flexWrap' , 'justifyContent' , 'alignItems' , 'alignSelf' , 'alignContent' , 'overflow' , 'flex' , 'flexGrow' , 'flexShrink' , 'flexBasis' , 'aspectRatio' , 'zIndex' , 'direction' , 'shadowColor' , 'shadowOffset' , 'shadowOpacity' , 'shadowRadius' , 'transform' , 'transformMatrix' , 'decomposedMatrix' , 'scaleX' , 'scaleY' , 'rotation' , 'translateX' , 'translateY' , 'resizeMode' , 'backfaceVisibility' , 'backgroundColor' , 'borderColor' , 'borderRadius' , 'tintColor' , 'opacity' , 'overlayColor' , 'borderTopLeftRadius' , 'borderTopRightRadius' , 'borderBottomLeftRadius' , 'borderBottomRightRadius' ] ;
4
+ const ViewStylePropTypes = [ 'display' , 'width' , 'height' , 'start' , 'end' , 'top' , 'left' , 'right' , 'bottom' , 'minWidth' , 'maxWidth' , 'minHeight' , 'maxHeight' , 'margin' , 'marginVertical' , 'marginHorizontal' , 'marginTop' , 'marginBottom' , 'marginLeft' , 'marginRight' , 'marginStart' , 'marginEnd' , 'padding' , 'paddingVertical' , 'paddingHorizontal' , 'paddingTop' , 'paddingBottom' , 'paddingLeft' , 'paddingRight' , 'paddingStart' , 'paddingEnd' , 'borderWidth' , 'borderTopWidth' , 'borderStartWidth' , 'borderEndWidth' , 'borderRightWidth' , 'borderBottomWidth' , 'borderLeftWidth' , 'position' , 'flexDirection' , 'flexWrap' , 'justifyContent' , 'alignItems' , 'alignSelf' , 'alignContent' , 'overflow' , 'flex' , 'flexGrow' , 'flexShrink' , 'flexBasis' , 'aspectRatio' , 'zIndex' , 'direction' , 'shadowColor' , 'shadowOffset' , 'shadowOpacity' , 'shadowRadius' , 'transform' , 'transformMatrix' , 'decomposedMatrix' , 'scaleX' , 'scaleY' , 'rotation' , 'translateX' , 'translateY' , 'backfaceVisibility' , 'backgroundColor' , 'borderColor' , 'borderTopColor' , 'borderRightColor' , 'borderBottomColor' , 'borderLeftColor' , 'borderStartColor' , 'borderEndColor' , 'borderRadius' , 'borderTopLeftRadius' , 'borderTopRightRadius' , 'borderTopStartRadius' , 'borderTopEndRadius' , 'borderBottomLeftRadius' , 'borderBottomRightRadius' , 'borderBottomStartRadius' , 'borderBottomEndRadius' , 'borderStyle' , 'opacity' , 'elevation' ] ;
5
+ const TextStylePropTypes = [ 'display' , 'width' , 'height' , 'start' , 'end' , 'top' , 'left' , 'right' , 'bottom' , 'minWidth' , 'maxWidth' , 'minHeight' , 'maxHeight' , 'margin' , 'marginVertical' , 'marginHorizontal' , 'marginTop' , 'marginBottom' , 'marginLeft' , 'marginRight' , 'marginStart' , 'marginEnd' , 'padding' , 'paddingVertical' , 'paddingHorizontal' , 'paddingTop' , 'paddingBottom' , 'paddingLeft' , 'paddingRight' , 'paddingStart' , 'paddingEnd' , 'borderWidth' , 'borderTopWidth' , 'borderStartWidth' , 'borderEndWidth' , 'borderRightWidth' , 'borderBottomWidth' , 'borderLeftWidth' , 'position' , 'flexDirection' , 'flexWrap' , 'justifyContent' , 'alignItems' , 'alignSelf' , 'alignContent' , 'overflow' , 'flex' , 'flexGrow' , 'flexShrink' , 'flexBasis' , 'aspectRatio' , 'zIndex' , 'direction' , 'shadowColor' , 'shadowOffset' , 'shadowOpacity' , 'shadowRadius' , 'transform' , 'transformMatrix' , 'decomposedMatrix' , 'scaleX' , 'scaleY' , 'rotation' , 'translateX' , 'translateY' , 'backfaceVisibility' , 'backgroundColor' , 'borderColor' , 'borderTopColor' , 'borderRightColor' , 'borderBottomColor' , 'borderLeftColor' , 'borderStartColor' , 'borderEndColor' , 'borderRadius' , 'borderTopLeftRadius' , 'borderTopRightRadius' , 'borderTopStartRadius' , 'borderTopEndRadius' , 'borderBottomLeftRadius' , 'borderBottomRightRadius' , 'borderBottomStartRadius' , 'borderBottomEndRadius' , 'borderStyle' , 'opacity' , 'elevation' , 'color' , 'fontFamily' , 'fontSize' , 'fontStyle' , 'fontWeight' , 'fontVariant' , 'textShadowOffset' , 'textShadowRadius' , 'textShadowColor' , 'letterSpacing' , 'lineHeight' , 'textAlign' , 'textAlignVertical' , 'includeFontPadding' , 'textDecorationLine' , 'textDecorationStyle' , 'textDecorationColor' , 'textTransform' , 'writingDirection' ]
4
6
5
7
// Filter prop-types that are only applicable to <Text> and not <View>
6
- export let TextOnlyPropTypes = { } ;
7
- Object . keys ( TextStylesPropTypes ) . forEach ( ( prop ) => {
8
- if ( ! DeprecatedViewStylePropTypes [ prop ] ) {
9
- TextOnlyPropTypes [ prop ] = TextStylesPropTypes [ prop ] ;
10
- }
11
- } ) ;
8
+ export const TextOnlyPropTypes = TextStylePropTypes . filter ( ( prop ) => ViewStylePropTypes . indexOf ( prop ) === - 1 ) ;
12
9
13
10
// These tags should ALWAYS be mapped to View wrappers
14
11
export const BLOCK_TAGS = [ 'address' , 'article' , 'aside' , 'footer' , 'hgroup' , 'nav' , 'section' , 'blockquote' , 'dd' ,
@@ -41,7 +38,8 @@ export const ABSOLUTE_FONT_SIZE = {
41
38
'larger' : 16 ,
42
39
'length' : null ,
43
40
'initial' : null ,
44
- 'inherit' : null
41
+ 'inherit' : null ,
42
+ 'unset' : null
45
43
} ;
46
44
47
45
export const IGNORED_TAGS = [ 'head' , 'scripts' , 'audio' , 'video' , 'track' , 'embed' , 'object' , 'param' , 'source' , 'canvas' , 'noscript' ,
@@ -57,20 +55,12 @@ export const PERC_SUPPORTED_STYLES = [
57
55
'padding' , 'paddingBottom' , 'paddingTop' , 'paddingLeft' , 'paddingRight' , 'paddingHorizontal' , 'paddingVertical'
58
56
] ;
59
57
60
- // We have to do some munging here as the objects are wrapped
61
- const RNTextStylePropTypes = Object . keys ( TextStylesPropTypes )
62
- . reduce ( ( acc , k ) => { acc [ k ] = TextStylesPropTypes [ k ] ; return acc ; } , { } ) ;
63
- const RNViewStylePropTypes = Object . keys ( DeprecatedViewStylePropTypes )
64
- . reduce ( ( acc , k ) => { acc [ k ] = DeprecatedViewStylePropTypes [ k ] ; return acc ; } , { } ) ;
65
- const RNImageStylePropTypes = Object . keys ( DeprecatedImageStylesPropTypes )
66
- . reduce ( ( acc , k ) => { acc [ k ] = DeprecatedImageStylesPropTypes [ k ] ; return acc ; } , { } ) ;
67
-
68
58
export const STYLESETS = Object . freeze ( { VIEW : 'view' , TEXT : 'text' , IMAGE : 'image' } ) ;
69
-
70
- export const stylePropTypes = { } ;
71
- stylePropTypes [ STYLESETS . VIEW ] = Object . assign ( { } , RNViewStylePropTypes ) ;
72
- stylePropTypes [ STYLESETS . TEXT ] = Object . assign ( { } , RNViewStylePropTypes , RNTextStylePropTypes ) ;
73
- stylePropTypes [ STYLESETS . IMAGE ] = Object . assign ( { } , RNViewStylePropTypes , RNImageStylePropTypes ) ;
59
+ export const stylePropTypes = {
60
+ [ STYLESETS . VIEW ] : ViewStylePropTypes ,
61
+ [ STYLESETS . TEXT ] : TextStylePropTypes ,
62
+ [ STYLESETS . IMAGE ] : ImageStylePropTypes
63
+ } ;
74
64
75
65
/**
76
66
* Returns an array with the tagname of every parent of a node.
0 commit comments