taro-css-to-react-native 3.4.11 → 3.4.12

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.
@@ -54,6 +54,24 @@ var valueForTypeToken = function valueForTypeToken(type) {
54
54
  };
55
55
  };
56
56
 
57
+ var functionValueForTypeToken = function functionValueForTypeToken(type) {
58
+ return function (node) {
59
+ if (node.type === type) {
60
+ // handle rgb(a) function value
61
+ if (/^rgba?$/i.test(node.value)) {
62
+ var result = node.nodes.filter(function (token) {
63
+ return token.type === 'word';
64
+ }).map(function (token) {
65
+ return token.value;
66
+ });
67
+ return "".concat(node.value, "(").concat(result.join(', '), ")");
68
+ }
69
+ }
70
+
71
+ return null;
72
+ };
73
+ };
74
+
57
75
  var regExpToken = function regExpToken(regExp) {
58
76
  var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String;
59
77
  return function (node) {
@@ -82,6 +100,7 @@ var tokens = {
82
100
  return node.type === 'div' && node.value === ',';
83
101
  }),
84
102
  WORD: valueForTypeToken('word'),
103
+ FUNC: functionValueForTypeToken('function'),
85
104
  NONE: regExpToken(noneRe),
86
105
  AUTO: regExpToken(autoRe),
87
106
  NUMBER: regExpToken(numberRe, Number),
@@ -12,6 +12,7 @@ var _util = require("./util");
12
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
13
 
14
14
  var WORD = _tokenTypes.tokens.WORD,
15
+ FUNC = _tokenTypes.tokens.FUNC,
15
16
  COLOR = _tokenTypes.tokens.COLOR,
16
17
  LENGTH = _tokenTypes.tokens.LENGTH,
17
18
  UNSUPPORTED_LENGTH_UNIT = _tokenTypes.tokens.UNSUPPORTED_LENGTH_UNIT;
@@ -44,7 +45,7 @@ exports.borderBottom = borderBottom;
44
45
  var borderLeft = borderDirectionFactory('Left');
45
46
  exports.borderLeft = borderLeft;
46
47
  var borderColor = (0, _util.directionFactory)({
47
- types: [WORD],
48
+ types: [WORD, FUNC],
48
49
  prefix: 'border',
49
50
  suffix: 'Color'
50
51
  });
package/dist/index.js CHANGED
@@ -65,6 +65,11 @@ var transformDecls = function transformDecls(styles, declarations, result) {
65
65
 
66
66
  if (typeof options.scalable === 'boolean' && !options.scalable && /(\d+)px/.test(value)) {
67
67
  value = value.replace(/(\d+)px/g, '$1PX');
68
+ } // expect value is legal so that remove !import
69
+
70
+
71
+ if (/!import/i.test(value)) {
72
+ value = value.replace(/!import/, '');
68
73
  }
69
74
 
70
75
  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.11",
4
+ "version": "3.4.12",
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": "d748791e8a7edc372d4d758611effedb0dc6c9f7"
66
+ "gitHead": "1c77a3abd807a1c088825751eddd8dad260dafc2"
67
67
  }
@@ -38,6 +38,20 @@ const noopToken = predicate => node => (predicate(node) ? '<token>' : null)
38
38
 
39
39
  const valueForTypeToken = type => node => (node.type === type ? node.value : null)
40
40
 
41
+ const functionValueForTypeToken = type => node => {
42
+ if (node.type === type) {
43
+ // handle rgb(a) function value
44
+ if (/^rgba?$/i.test(node.value)) {
45
+ const result = node.nodes
46
+ .filter(token => token.type === 'word')
47
+ .map(token => token.value)
48
+
49
+ return `${node.value}(${result.join(', ')})`
50
+ }
51
+ }
52
+ return null
53
+ }
54
+
41
55
  export const regExpToken = (regExp, transform = String) => node => {
42
56
  if (node.type !== 'word') return null
43
57
 
@@ -57,6 +71,7 @@ export const tokens = {
57
71
  SLASH: noopToken(node => node.type === 'div' && node.value === '/'),
58
72
  COMMA: noopToken(node => node.type === 'div' && node.value === ','),
59
73
  WORD: valueForTypeToken('word'),
74
+ FUNC: functionValueForTypeToken('function'),
60
75
  NONE: regExpToken(noneRe),
61
76
  AUTO: regExpToken(autoRe),
62
77
  NUMBER: regExpToken(numberRe, Number),
@@ -3,6 +3,7 @@ import { directionFactory, anyOrderFactory } from './util'
3
3
 
4
4
  const {
5
5
  WORD,
6
+ FUNC,
6
7
  COLOR,
7
8
  LENGTH,
8
9
  UNSUPPORTED_LENGTH_UNIT
@@ -34,7 +35,7 @@ export const borderBottom = borderDirectionFactory('Bottom')
34
35
  export const borderLeft = borderDirectionFactory('Left')
35
36
 
36
37
  export const borderColor = directionFactory({
37
- types: [WORD],
38
+ types: [WORD, FUNC],
38
39
  prefix: 'border',
39
40
  suffix: 'Color'
40
41
  })
package/src/index.js CHANGED
@@ -59,6 +59,10 @@ const transformDecls = (styles, declarations, result, options = {}) => {
59
59
  ) {
60
60
  value = value.replace(/(\d+)px/g, '$1PX')
61
61
  }
62
+ // expect value is legal so that remove !import
63
+ if (/!import/i.test(value)) {
64
+ value = value.replace(/!import/, '')
65
+ }
62
66
 
63
67
  if (shorthandBorderProps.indexOf(property) > -1) {
64
68
  // transform single value shorthand border properties back to