@tarojs/rn-style-transformer 4.0.0-beta.78 → 4.0.0-beta.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +8 -0
- package/LICENSE +8 -1
- package/__tests__/config.spec.js +203 -0
- package/__tests__/index.spec.js +252 -0
- package/__tests__/platform.spec.js +78 -0
- package/__tests__/styles/b.css +3 -0
- package/__tests__/styles/b.less +3 -0
- package/__tests__/styles/b.rn.css +3 -0
- package/__tests__/styles/b.scss +3 -0
- package/__tests__/styles/b.styl +3 -0
- package/__tests__/styles/c.css +3 -0
- package/__tests__/styles/c.less +5 -0
- package/__tests__/styles/c.rn.scss +5 -0
- package/__tests__/styles/c.scss +5 -0
- package/__tests__/styles/d.rn.scss +3 -0
- package/__tests__/styles/d.scss +3 -0
- package/__tests__/styles/mixins.scss +18 -0
- package/__tests__/styles/nest.rn.less +3 -0
- package/__tests__/styles/variable.scss +1 -0
- package/babel.config.js +12 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/deprecatedPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/normalizeColor.js.map +1 -1
- package/dist/transforms/index.js +5 -5
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.js +1 -5
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.js +1 -1
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/reporterSkip.js.map +1 -1
- package/jest.config.js +8 -0
- package/package.json +31 -32
- package/src/config/rn-stylelint.json +5 -0
- package/src/index.ts +52 -0
- package/src/transforms/StyleSheet/ColorPropType.ts +76 -0
- package/src/transforms/StyleSheet/ImageResizeMode.ts +50 -0
- package/src/transforms/StyleSheet/ImageStylePropTypes.ts +62 -0
- package/src/transforms/StyleSheet/LayoutPropTypes.ts +559 -0
- package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +48 -0
- package/src/transforms/StyleSheet/StyleSheetValidation.ts +81 -0
- package/src/transforms/StyleSheet/TextStylePropTypes.ts +123 -0
- package/src/transforms/StyleSheet/TransformPropTypes.ts +109 -0
- package/src/transforms/StyleSheet/ViewStylePropTypes.ts +61 -0
- package/src/transforms/StyleSheet/deprecatedPropType.ts +31 -0
- package/src/transforms/StyleSheet/index.ts +5 -0
- package/src/transforms/StyleSheet/normalizeColor.ts +369 -0
- package/src/transforms/index.ts +229 -0
- package/src/transforms/less.ts +50 -0
- package/src/transforms/postcss.ts +95 -0
- package/src/transforms/sass.ts +148 -0
- package/src/transforms/stylus.ts +124 -0
- package/src/types/index.ts +242 -0
- package/src/utils/index.ts +229 -0
- package/src/utils/lessImport.ts +50 -0
- package/src/utils/reporterSkip.ts +27 -0
- package/tsconfig.json +12 -0
- package/dist/index.d.ts +0 -8
- package/dist/transforms/StyleSheet/ColorPropType.d.ts +0 -10
- package/dist/transforms/StyleSheet/ImageResizeMode.d.ts +0 -6
- package/dist/transforms/StyleSheet/ImageStylePropTypes.d.ts +0 -128
- package/dist/transforms/StyleSheet/LayoutPropTypes.d.ts +0 -388
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.d.ts +0 -45
- package/dist/transforms/StyleSheet/StyleSheetValidation.d.ts +0 -15
- package/dist/transforms/StyleSheet/TextStylePropTypes.d.ts +0 -191
- package/dist/transforms/StyleSheet/TransformPropTypes.d.ts +0 -67
- package/dist/transforms/StyleSheet/ViewStylePropTypes.d.ts +0 -136
- package/dist/transforms/StyleSheet/deprecatedPropType.d.ts +0 -13
- package/dist/transforms/StyleSheet/index.d.ts +0 -2
- package/dist/transforms/StyleSheet/normalizeColor.d.ts +0 -10
- package/dist/transforms/index.d.ts +0 -56
- package/dist/transforms/less.d.ts +0 -2
- package/dist/transforms/postcss.d.ts +0 -13
- package/dist/transforms/sass.d.ts +0 -2
- package/dist/transforms/stylus.d.ts +0 -3
- package/dist/types/index.d.ts +0 -206
- package/dist/utils/index.d.ts +0 -21
- package/dist/utils/lessImport.d.ts +0 -5
- package/dist/utils/reporterSkip.d.ts +0 -7
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict'
|
|
11
|
+
|
|
12
|
+
import normalizeColor from './normalizeColor'
|
|
13
|
+
|
|
14
|
+
const colorPropType = function (
|
|
15
|
+
isRequired,
|
|
16
|
+
props,
|
|
17
|
+
propName,
|
|
18
|
+
componentName,
|
|
19
|
+
location,
|
|
20
|
+
propFullName
|
|
21
|
+
) {
|
|
22
|
+
const color = props[propName]
|
|
23
|
+
if (color === undefined || color === null) {
|
|
24
|
+
if (isRequired) {
|
|
25
|
+
return new Error(
|
|
26
|
+
'Required ' +
|
|
27
|
+
location +
|
|
28
|
+
' `' +
|
|
29
|
+
(propFullName || propName) +
|
|
30
|
+
'` was not specified in `' +
|
|
31
|
+
componentName +
|
|
32
|
+
'`.'
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof color === 'number') {
|
|
39
|
+
// Developers should not use a number, but we are using the prop type
|
|
40
|
+
// both for user provided colors and for transformed ones. This isn't ideal
|
|
41
|
+
// and should be fixed but will do for now...
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (normalizeColor(color) === null) {
|
|
46
|
+
return new Error(
|
|
47
|
+
'Invalid ' +
|
|
48
|
+
location +
|
|
49
|
+
' `' +
|
|
50
|
+
(propFullName || propName) +
|
|
51
|
+
'` supplied to `' +
|
|
52
|
+
componentName +
|
|
53
|
+
'`: ' +
|
|
54
|
+
color +
|
|
55
|
+
'\n' +
|
|
56
|
+
`Valid color formats are
|
|
57
|
+
- '#f0f' (#rgb)
|
|
58
|
+
- '#f0fc' (#rgba)
|
|
59
|
+
- '#ff00ff' (#rrggbb)
|
|
60
|
+
- '#ff00ff00' (#rrggbbaa)
|
|
61
|
+
- 'rgb(255, 255, 255)'
|
|
62
|
+
- 'rgba(255, 255, 255, 1.0)'
|
|
63
|
+
- 'hsl(360, 100%, 100%)'
|
|
64
|
+
- 'hsla(360, 100%, 100%, 1.0)'
|
|
65
|
+
- 'transparent'
|
|
66
|
+
- 'red'
|
|
67
|
+
- 0xff00ff00 (0xrrggbbaa)
|
|
68
|
+
`
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ColorPropType = colorPropType.bind(null, false /* isRequired */)
|
|
74
|
+
ColorPropType.isRequired = colorPropType.bind(null, true /* isRequired */)
|
|
75
|
+
|
|
76
|
+
export default ColorPropType
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
|
11
|
+
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
|
12
|
+
* run Flow. */
|
|
13
|
+
import keyMirror from 'fbjs/lib/keyMirror'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ImageResizeMode - Enum for different image resizing modes, set via
|
|
17
|
+
* `resizeMode` style property on `<Image>` components.
|
|
18
|
+
*/
|
|
19
|
+
const ImageResizeMode = keyMirror({
|
|
20
|
+
/**
|
|
21
|
+
* contain - The image will be resized such that it will be completely
|
|
22
|
+
* visible, contained within the frame of the View.
|
|
23
|
+
*/
|
|
24
|
+
contain: null,
|
|
25
|
+
/**
|
|
26
|
+
* cover - The image will be resized such that the entire area of the view
|
|
27
|
+
* is covered by the image, potentially clipping parts of the image.
|
|
28
|
+
*/
|
|
29
|
+
cover: null,
|
|
30
|
+
/**
|
|
31
|
+
* stretch - The image will be stretched to fill the entire frame of the
|
|
32
|
+
* view without clipping. This may change the aspect ratio of the image,
|
|
33
|
+
* distorting it.
|
|
34
|
+
*/
|
|
35
|
+
stretch: null,
|
|
36
|
+
/**
|
|
37
|
+
* center - The image will be scaled down such that it is completely visible,
|
|
38
|
+
* if bigger than the area of the view.
|
|
39
|
+
* The image will not be scaled up.
|
|
40
|
+
*/
|
|
41
|
+
center: null,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* repeat - The image will be repeated to cover the frame of the View. The
|
|
45
|
+
* image will keep it's size and aspect ratio.
|
|
46
|
+
*/
|
|
47
|
+
repeat: null
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export default ImageResizeMode
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
'use strict'
|
|
11
|
+
|
|
12
|
+
import ColorPropType from './ColorPropType'
|
|
13
|
+
import ImageResizeMode from './ImageResizeMode'
|
|
14
|
+
import LayoutPropTypes from './LayoutPropTypes'
|
|
15
|
+
import * as ReactPropTypes from 'prop-types'
|
|
16
|
+
import ShadowPropTypesIOS from './ShadowPropTypesIOS'
|
|
17
|
+
import TransformPropTypes from './TransformPropTypes'
|
|
18
|
+
|
|
19
|
+
const ImageStylePropTypes = {
|
|
20
|
+
...LayoutPropTypes,
|
|
21
|
+
...ShadowPropTypesIOS,
|
|
22
|
+
...TransformPropTypes,
|
|
23
|
+
resizeMode: ReactPropTypes.oneOf(Object.keys(ImageResizeMode)),
|
|
24
|
+
backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']),
|
|
25
|
+
backgroundColor: ColorPropType,
|
|
26
|
+
borderColor: ColorPropType,
|
|
27
|
+
borderWidth: ReactPropTypes.number,
|
|
28
|
+
borderRadius: ReactPropTypes.number,
|
|
29
|
+
overflow: ReactPropTypes.oneOf(['visible', 'hidden']),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Changes the color of all the non-transparent pixels to the tintColor.
|
|
33
|
+
*/
|
|
34
|
+
tintColor: ColorPropType,
|
|
35
|
+
opacity: ReactPropTypes.number,
|
|
36
|
+
/**
|
|
37
|
+
* When the image has rounded corners, specifying an overlayColor will
|
|
38
|
+
* cause the remaining space in the corners to be filled with a solid color.
|
|
39
|
+
* This is useful in cases which are not supported by the Android
|
|
40
|
+
* implementation of rounded corners:
|
|
41
|
+
* - Certain resize modes, such as 'contain'
|
|
42
|
+
* - Animated GIFs
|
|
43
|
+
*
|
|
44
|
+
* A typical way to use this prop is with images displayed on a solid
|
|
45
|
+
* background and setting the `overlayColor` to the same color
|
|
46
|
+
* as the background.
|
|
47
|
+
*
|
|
48
|
+
* For details of how this works under the hood, see
|
|
49
|
+
* http://frescolib.org/docs/rounded-corners-and-circles.html
|
|
50
|
+
*
|
|
51
|
+
* @platform android
|
|
52
|
+
*/
|
|
53
|
+
overlayColor: ReactPropTypes.string,
|
|
54
|
+
|
|
55
|
+
// Android-Specific styles
|
|
56
|
+
borderTopLeftRadius: ReactPropTypes.number,
|
|
57
|
+
borderTopRightRadius: ReactPropTypes.number,
|
|
58
|
+
borderBottomLeftRadius: ReactPropTypes.number,
|
|
59
|
+
borderBottomRightRadius: ReactPropTypes.number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default ImageStylePropTypes
|