taro-css-to-react-native 3.4.0 → 3.4.3

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.
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.borderWidth = exports.borderRadius = exports.borderColor = exports.borderLeft = exports.borderBottom = exports.borderRight = exports.borderTop = exports.border = void 0;
7
+
8
+ var _tokenTypes = require("../tokenTypes");
9
+
10
+ var _util = require("./util");
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ var WORD = _tokenTypes.tokens.WORD,
15
+ COLOR = _tokenTypes.tokens.COLOR,
16
+ LENGTH = _tokenTypes.tokens.LENGTH,
17
+ UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT;
18
+
19
+ function borderDirectionFactory() {
20
+ var _anyOrderFactory;
21
+
22
+ var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
23
+ var prefix = "border".concat(direction);
24
+ return (0, _util.anyOrderFactory)((_anyOrderFactory = {}, _defineProperty(_anyOrderFactory, "".concat(prefix, "Width"), {
25
+ tokens: [LENGTH, UNSUPPORTED_LENGTH_UNIT],
26
+ "default": 1
27
+ }), _defineProperty(_anyOrderFactory, "".concat(prefix, "Color"), {
28
+ tokens: [COLOR],
29
+ "default": 'black'
30
+ }), _defineProperty(_anyOrderFactory, "".concat(prefix, "Style"), {
31
+ tokens: [(0, _tokenTypes.regExpToken)(/^(solid|dashed|dotted)$/)],
32
+ "default": 'solid'
33
+ }), _anyOrderFactory));
34
+ }
35
+
36
+ var border = borderDirectionFactory();
37
+ exports.border = border;
38
+ var borderTop = borderDirectionFactory('Top');
39
+ exports.borderTop = borderTop;
40
+ var borderRight = borderDirectionFactory('Right');
41
+ exports.borderRight = borderRight;
42
+ var borderBottom = borderDirectionFactory('Bottom');
43
+ exports.borderBottom = borderBottom;
44
+ var borderLeft = borderDirectionFactory('Left');
45
+ exports.borderLeft = borderLeft;
46
+ var borderColor = (0, _util.directionFactory)({
47
+ types: [WORD],
48
+ prefix: 'border',
49
+ suffix: 'Color'
50
+ });
51
+ exports.borderColor = borderColor;
52
+ var borderRadius = (0, _util.directionFactory)({
53
+ directions: ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'],
54
+ prefix: 'border',
55
+ suffix: 'Radius'
56
+ });
57
+ exports.borderRadius = borderRadius;
58
+ var borderWidth = (0, _util.directionFactory)({
59
+ prefix: 'border',
60
+ suffix: 'Width'
61
+ });
62
+ exports.borderWidth = borderWidth;
@@ -23,6 +23,8 @@ var _textDecorationLine = _interopRequireDefault(require("./textDecorationLine")
23
23
 
24
24
  var _transform = _interopRequireDefault(require("./transform"));
25
25
 
26
+ var _border = require("./border");
27
+
26
28
  var _util = require("./util");
27
29
 
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -43,34 +45,6 @@ var background = function background(tokenStream) {
43
45
  };
44
46
  };
45
47
 
46
- var border = (0, _util.anyOrderFactory)({
47
- borderWidth: {
48
- tokens: [LENGTH, UNSUPPORTED_LENGTH_UNIT],
49
- "default": 1
50
- },
51
- borderColor: {
52
- tokens: [COLOR],
53
- "default": 'black'
54
- },
55
- borderStyle: {
56
- tokens: [(0, _tokenTypes.regExpToken)(/^(solid|dashed|dotted)$/)],
57
- "default": 'solid'
58
- }
59
- });
60
- var borderColor = (0, _util.directionFactory)({
61
- types: [WORD],
62
- prefix: 'border',
63
- suffix: 'Color'
64
- });
65
- var borderRadius = (0, _util.directionFactory)({
66
- directions: ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'],
67
- prefix: 'border',
68
- suffix: 'Radius'
69
- });
70
- var borderWidth = (0, _util.directionFactory)({
71
- prefix: 'border',
72
- suffix: 'Width'
73
- });
74
48
  var margin = (0, _util.directionFactory)({
75
49
  types: [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT, AUTO],
76
50
  prefix: 'margin'
@@ -102,10 +76,14 @@ var shadowOffset = (0, _util.shadowOffsetFactory)();
102
76
  var textShadowOffset = (0, _util.shadowOffsetFactory)();
103
77
  var _default = {
104
78
  background: background,
105
- border: border,
106
- borderColor: borderColor,
107
- borderRadius: borderRadius,
108
- borderWidth: borderWidth,
79
+ border: _border.border,
80
+ borderTop: _border.borderTop,
81
+ borderRight: _border.borderRight,
82
+ borderBottom: _border.borderBottom,
83
+ borderLeft: _border.borderLeft,
84
+ borderColor: _border.borderColor,
85
+ borderRadius: _border.borderRadius,
86
+ borderWidth: _border.borderWidth,
109
87
  boxShadow: _boxShadow["default"],
110
88
  flex: _flex["default"],
111
89
  flexFlow: flexFlow,
package/dist/index.js CHANGED
@@ -62,8 +62,8 @@ var transformDecls = function transformDecls(styles, declarations, result) {
62
62
  // do not be wrapped by scalePx2dp function
63
63
 
64
64
 
65
- if (isLengthUnit && typeof options.scalable === 'boolean' && !options.scalable && /(\d+)px/.test(value)) {
66
- value = value.replace(/(\d+)px/, '$1PX');
65
+ if (typeof options.scalable === 'boolean' && !options.scalable && /(\d+)px/.test(value)) {
66
+ value = value.replace(/(\d+)px/g, '$1PX');
67
67
  }
68
68
 
69
69
  if (shorthandBorderProps.indexOf(property) > -1) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "taro-css-to-react-native",
3
3
  "description": "Convert CSS text to a React Native stylesheet object",
4
- "version": "3.4.0",
4
+ "version": "3.4.3",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -63,5 +63,5 @@
63
63
  "CHANGELOG.md",
64
64
  "README.md"
65
65
  ],
66
- "gitHead": "a0e97bc937f878cc059f54748c9a3829fa3f4664"
66
+ "gitHead": "de55da7a845e9c09ba65528e74c7310e5082c2d5"
67
67
  }
@@ -0,0 +1,48 @@
1
+ import { regExpToken, tokens } from '../tokenTypes'
2
+ import { directionFactory, anyOrderFactory } from './util'
3
+
4
+ const {
5
+ WORD,
6
+ COLOR,
7
+ LENGTH,
8
+ UNSUPPORTED_LENGTH_UNIT
9
+ } = tokens
10
+
11
+ function borderDirectionFactory (direction = '') {
12
+ const prefix = `border${direction}`
13
+ return anyOrderFactory({
14
+ [`${prefix}Width`]: {
15
+ tokens: [LENGTH, UNSUPPORTED_LENGTH_UNIT],
16
+ default: 1
17
+ },
18
+ [`${prefix}Color`]: {
19
+ tokens: [COLOR],
20
+ default: 'black'
21
+ },
22
+ [`${prefix}Style`]: {
23
+ tokens: [regExpToken(/^(solid|dashed|dotted)$/)],
24
+ default: 'solid'
25
+ }
26
+ })
27
+ }
28
+
29
+ export const border = borderDirectionFactory()
30
+
31
+ export const borderTop = borderDirectionFactory('Top')
32
+ export const borderRight = borderDirectionFactory('Right')
33
+ export const borderBottom = borderDirectionFactory('Bottom')
34
+ export const borderLeft = borderDirectionFactory('Left')
35
+
36
+ export const borderColor = directionFactory({
37
+ types: [WORD],
38
+ prefix: 'border',
39
+ suffix: 'Color'
40
+ })
41
+
42
+ export const borderRadius = directionFactory({
43
+ directions: ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'],
44
+ prefix: 'border',
45
+ suffix: 'Radius'
46
+ })
47
+
48
+ export const borderWidth = directionFactory({ prefix: 'border', suffix: 'Width' })
@@ -7,6 +7,7 @@ import textShadow from './textShadow'
7
7
  import textDecoration from './textDecoration'
8
8
  import textDecorationLine from './textDecorationLine'
9
9
  import transform from './transform'
10
+ import { border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderRadius, borderWidth } from './border'
10
11
  import { directionFactory, anyOrderFactory, shadowOffsetFactory } from './util'
11
12
 
12
13
  const {
@@ -22,31 +23,6 @@ const {
22
23
  const background = tokenStream => ({
23
24
  $merge: { backgroundColor: tokenStream.expect(COLOR) }
24
25
  })
25
- const border = anyOrderFactory({
26
- borderWidth: {
27
- tokens: [LENGTH, UNSUPPORTED_LENGTH_UNIT],
28
- default: 1
29
- },
30
- borderColor: {
31
- tokens: [COLOR],
32
- default: 'black'
33
- },
34
- borderStyle: {
35
- tokens: [regExpToken(/^(solid|dashed|dotted)$/)],
36
- default: 'solid'
37
- }
38
- })
39
- const borderColor = directionFactory({
40
- types: [WORD],
41
- prefix: 'border',
42
- suffix: 'Color'
43
- })
44
- const borderRadius = directionFactory({
45
- directions: ['TopLeft', 'TopRight', 'BottomRight', 'BottomLeft'],
46
- prefix: 'border',
47
- suffix: 'Radius'
48
- })
49
- const borderWidth = directionFactory({ prefix: 'border', suffix: 'Width' })
50
26
  const margin = directionFactory({
51
27
  types: [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT, AUTO],
52
28
  prefix: 'margin'
@@ -70,6 +46,10 @@ const textShadowOffset = shadowOffsetFactory()
70
46
  export default {
71
47
  background,
72
48
  border,
49
+ borderTop,
50
+ borderRight,
51
+ borderBottom,
52
+ borderLeft,
73
53
  borderColor,
74
54
  borderRadius,
75
55
  borderWidth,
package/src/index.js CHANGED
@@ -52,12 +52,11 @@ const transformDecls = (styles, declarations, result, options = {}) => {
52
52
  // scalable option, when it is false, transform single value 'px' unit to 'PX'
53
53
  // do not be wrapped by scalePx2dp function
54
54
  if (
55
- isLengthUnit &&
56
55
  typeof options.scalable === 'boolean' &&
57
56
  !options.scalable &&
58
57
  /(\d+)px/.test(value)
59
58
  ) {
60
- value = value.replace(/(\d+)px/, '$1PX')
59
+ value = value.replace(/(\d+)px/g, '$1PX')
61
60
  }
62
61
 
63
62
  if (shorthandBorderProps.indexOf(property) > -1) {