@react-pdf/stylesheet 4.2.5 → 5.0.0

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.
Files changed (3) hide show
  1. package/lib/index.js +213 -221
  2. package/package.json +4 -12
  3. package/lib/index.cjs +0 -768
package/lib/index.js CHANGED
@@ -3,44 +3,49 @@ import parse$1 from 'postcss-value-parser/lib/parse.js';
3
3
  import parseUnit from 'postcss-value-parser/lib/unit.js';
4
4
  import hlsToHex from 'hsl-to-hex';
5
5
  import colorString from 'color-string';
6
- import _extends from '@babel/runtime/helpers/extends';
7
6
  import matchMedia from 'media-engine';
8
7
 
9
8
  // https://developer.mozilla.org/en-US/docs/Web/CSS/flex#values
10
9
 
11
10
  // TODO: change flex defaults to [0, 1, 'auto'] as in spec in next major release
12
- var flexDefaults = [1, 1, 0];
11
+ const flexDefaults = [1, 1, 0];
13
12
  /**
14
13
  * @type {(number | 'auto')[]}
15
14
  */
16
- var flexAuto = [1, 1, 'auto'];
17
- var expandFlex = function expandFlex(key, value) {
15
+ const flexAuto = [1, 1, 'auto'];
16
+ const expandFlex = (key, value) => {
18
17
  /**
19
18
  * @type {(number | 'auto')[]}
20
19
  */
21
- var defaults = flexDefaults;
22
- var matches = [];
20
+ let defaults = flexDefaults;
21
+ let matches = [];
23
22
  if (value === 'auto') {
24
23
  defaults = flexAuto;
25
24
  } else {
26
- matches = ("" + value).split(' ');
25
+ matches = `${value}`.split(' ');
27
26
  }
28
- var flexGrow = matches[0] || defaults[0];
29
- var flexShrink = matches[1] || defaults[1];
30
- var flexBasis = matches[2] || defaults[2];
27
+ const flexGrow = matches[0] || defaults[0];
28
+ const flexShrink = matches[1] || defaults[1];
29
+ const flexBasis = matches[2] || defaults[2];
31
30
  return {
32
- flexGrow: flexGrow,
33
- flexShrink: flexShrink,
34
- flexBasis: flexBasis
31
+ flexGrow,
32
+ flexShrink,
33
+ flexBasis
35
34
  };
36
35
  };
37
36
 
38
37
  /* eslint-disable no-plusplus */
39
38
  // This file is ran directly with Node - needs to have .js extension
40
39
  // eslint-disable-next-line import/extensions
41
- var BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh';
42
- var logError = function logError(style, value) {
43
- console.error("\n @react-pdf/stylesheet parsing error:\n\n " + style + ": " + value + ",\n " + ' '.repeat(style.length + 2) + "^\n Unsupported " + style + " value format\n ");
40
+ const BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh';
41
+ const logError = (style, value) => {
42
+ console.error(`
43
+ @react-pdf/stylesheet parsing error:
44
+
45
+ ${style}: ${value},
46
+ ${' '.repeat(style.length + 2)}^
47
+ Unsupported ${style} value format
48
+ `);
44
49
  };
45
50
 
46
51
  /**
@@ -49,19 +54,17 @@ var logError = function logError(style, value) {
49
54
  * @param {number} [options.maxValues]
50
55
  * @param {boolean} [options.autoSupported]
51
56
  */
52
- var expandBoxModel = function expandBoxModel(_temp) {
53
- var _ref = _temp === void 0 ? {} : _temp,
54
- expandsTo = _ref.expandsTo,
55
- _ref$maxValues = _ref.maxValues,
56
- maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
57
- _ref$autoSupported = _ref.autoSupported,
58
- autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
59
- return function (model, value) {
60
- var _ref2;
61
- var nodes = parse$1("" + value);
62
- var parts = [];
63
- for (var i = 0; i < nodes.length; i++) {
64
- var node = nodes[i];
57
+ const expandBoxModel = function (_temp) {
58
+ let {
59
+ expandsTo,
60
+ maxValues = 1,
61
+ autoSupported = false
62
+ } = _temp === void 0 ? {} : _temp;
63
+ return (model, value) => {
64
+ const nodes = parse$1(`${value}`);
65
+ const parts = [];
66
+ for (let i = 0; i < nodes.length; i++) {
67
+ const node = nodes[i];
65
68
 
66
69
  // value contains `calc`, `url` or other css function
67
70
  // `,`, `/` or strings that unsupported by margin and padding
@@ -73,7 +76,7 @@ var expandBoxModel = function expandBoxModel(_temp) {
73
76
  if (node.value === 'auto' && autoSupported) {
74
77
  parts.push(node.value);
75
78
  } else {
76
- var result = parseUnit(node.value);
79
+ const result = parseUnit(node.value);
77
80
 
78
81
  // when unit isn't specified this condition is true
79
82
  if (result && BOX_MODEL_UNITS.includes(result.unit)) {
@@ -91,28 +94,32 @@ var expandBoxModel = function expandBoxModel(_temp) {
91
94
  logError(model, value);
92
95
  return {};
93
96
  }
94
- var first = parts[0];
97
+ const first = parts[0];
95
98
  if (expandsTo) {
96
- var second = parts[1] || parts[0];
97
- var third = parts[2] || parts[0];
98
- var fourth = parts[3] || parts[1] || parts[0];
99
+ const second = parts[1] || parts[0];
100
+ const third = parts[2] || parts[0];
101
+ const fourth = parts[3] || parts[1] || parts[0];
99
102
  return expandsTo({
100
- first: first,
101
- second: second,
102
- third: third,
103
- fourth: fourth
103
+ first,
104
+ second,
105
+ third,
106
+ fourth
104
107
  });
105
108
  }
106
- return _ref2 = {}, _ref2[model] = first, _ref2;
109
+ return {
110
+ [model]: first
111
+ };
107
112
  };
108
113
  };
109
114
 
110
- var processMargin = expandBoxModel({
111
- expandsTo: function expandsTo(_ref) {
112
- var first = _ref.first,
113
- second = _ref.second,
114
- third = _ref.third,
115
- fourth = _ref.fourth;
115
+ const processMargin = expandBoxModel({
116
+ expandsTo: _ref => {
117
+ let {
118
+ first,
119
+ second,
120
+ third,
121
+ fourth
122
+ } = _ref;
116
123
  return {
117
124
  marginTop: first,
118
125
  marginRight: second,
@@ -123,10 +130,12 @@ var processMargin = expandBoxModel({
123
130
  maxValues: 4,
124
131
  autoSupported: true
125
132
  });
126
- var processMarginVertical = expandBoxModel({
127
- expandsTo: function expandsTo(_ref2) {
128
- var first = _ref2.first,
129
- second = _ref2.second;
133
+ const processMarginVertical = expandBoxModel({
134
+ expandsTo: _ref2 => {
135
+ let {
136
+ first,
137
+ second
138
+ } = _ref2;
130
139
  return {
131
140
  marginTop: first,
132
141
  marginBottom: second
@@ -135,10 +144,12 @@ var processMarginVertical = expandBoxModel({
135
144
  maxValues: 2,
136
145
  autoSupported: true
137
146
  });
138
- var processMarginHorizontal = expandBoxModel({
139
- expandsTo: function expandsTo(_ref3) {
140
- var first = _ref3.first,
141
- second = _ref3.second;
147
+ const processMarginHorizontal = expandBoxModel({
148
+ expandsTo: _ref3 => {
149
+ let {
150
+ first,
151
+ second
152
+ } = _ref3;
142
153
  return {
143
154
  marginRight: first,
144
155
  marginLeft: second
@@ -147,23 +158,24 @@ var processMarginHorizontal = expandBoxModel({
147
158
  maxValues: 2,
148
159
  autoSupported: true
149
160
  });
150
- var processMarginSingle = expandBoxModel({
161
+ const processMarginSingle = expandBoxModel({
151
162
  autoSupported: true
152
163
  });
153
164
 
154
- var BORDER_SHORTHAND_REGEX = /(-?\d+(\.\d+)?(px|in|mm|cm|pt|vw|vh|px)?)\s(\S+)\s(.+)/;
155
- var matchBorderShorthand = function matchBorderShorthand(value) {
156
- return value.match(BORDER_SHORTHAND_REGEX) || [];
157
- };
158
- var expandBorders = function expandBorders(key, value) {
159
- var match = matchBorderShorthand("" + value);
165
+ const BORDER_SHORTHAND_REGEX = /(-?\d+(\.\d+)?(px|in|mm|cm|pt|vw|vh|px)?)\s(\S+)\s(.+)/;
166
+ const matchBorderShorthand = value => value.match(BORDER_SHORTHAND_REGEX) || [];
167
+ const expandBorders = (key, value) => {
168
+ const match = matchBorderShorthand(`${value}`);
160
169
  if (match) {
161
- var color = match[5] || value;
162
- var style = match[4] || value;
163
- var width = match[1] || value;
170
+ const color = match[5] || value;
171
+ const style = match[4] || value;
172
+ const width = match[1] || value;
164
173
  if (key.match(/(Top|Right|Bottom|Left)$/)) {
165
- var _ref;
166
- return _ref = {}, _ref[key + "Color"] = color, _ref[key + "Style"] = style, _ref[key + "Width"] = width, _ref;
174
+ return {
175
+ [`${key}Color`]: color,
176
+ [`${key}Style`]: style,
177
+ [`${key}Width`]: width
178
+ };
167
179
  }
168
180
  if (key.match(/Color$/)) {
169
181
  return {
@@ -215,12 +227,14 @@ var expandBorders = function expandBorders(key, value) {
215
227
  return value;
216
228
  };
217
229
 
218
- var processPadding = expandBoxModel({
219
- expandsTo: function expandsTo(_ref) {
220
- var first = _ref.first,
221
- second = _ref.second,
222
- third = _ref.third,
223
- fourth = _ref.fourth;
230
+ const processPadding = expandBoxModel({
231
+ expandsTo: _ref => {
232
+ let {
233
+ first,
234
+ second,
235
+ third,
236
+ fourth
237
+ } = _ref;
224
238
  return {
225
239
  paddingTop: first,
226
240
  paddingRight: second,
@@ -230,10 +244,12 @@ var processPadding = expandBoxModel({
230
244
  },
231
245
  maxValues: 4
232
246
  });
233
- var processPaddingVertical = expandBoxModel({
234
- expandsTo: function expandsTo(_ref2) {
235
- var first = _ref2.first,
236
- second = _ref2.second;
247
+ const processPaddingVertical = expandBoxModel({
248
+ expandsTo: _ref2 => {
249
+ let {
250
+ first,
251
+ second
252
+ } = _ref2;
237
253
  return {
238
254
  paddingTop: first,
239
255
  paddingBottom: second
@@ -241,10 +257,12 @@ var processPaddingVertical = expandBoxModel({
241
257
  },
242
258
  maxValues: 2
243
259
  });
244
- var processPaddingHorizontal = expandBoxModel({
245
- expandsTo: function expandsTo(_ref3) {
246
- var first = _ref3.first,
247
- second = _ref3.second;
260
+ const processPaddingHorizontal = expandBoxModel({
261
+ expandsTo: _ref3 => {
262
+ let {
263
+ first,
264
+ second
265
+ } = _ref3;
248
266
  return {
249
267
  paddingRight: first,
250
268
  paddingLeft: second
@@ -252,50 +270,50 @@ var processPaddingHorizontal = expandBoxModel({
252
270
  },
253
271
  maxValues: 2
254
272
  });
255
- var processPaddingSingle = expandBoxModel();
273
+ const processPaddingSingle = expandBoxModel();
256
274
 
257
- var expandObjectPosition = function expandObjectPosition(key, value) {
258
- var match = ("" + value).split(' ');
275
+ const expandObjectPosition = (key, value) => {
276
+ const match = `${value}`.split(' ');
259
277
  return {
260
278
  objectPositionX: (match === null || match === void 0 ? void 0 : match[0]) || value,
261
279
  objectPositionY: (match === null || match === void 0 ? void 0 : match[1]) || value
262
280
  };
263
281
  };
264
282
 
265
- var Y_AXIS_SHORTHANDS = {
283
+ const Y_AXIS_SHORTHANDS = {
266
284
  top: true,
267
285
  bottom: true
268
286
  };
269
- var sortTransformOriginPair = function sortTransformOriginPair(a, b) {
287
+ const sortTransformOriginPair = (a, b) => {
270
288
  if (Y_AXIS_SHORTHANDS[a]) return 1;
271
289
  if (Y_AXIS_SHORTHANDS[b]) return -1;
272
290
  return 0;
273
291
  };
274
- var getTransformOriginPair = function getTransformOriginPair(values) {
292
+ const getTransformOriginPair = values => {
275
293
  if (!values || values.length === 0) return ['center', 'center'];
276
- var pair = values.length === 1 ? [values[0], 'center'] : values;
294
+ const pair = values.length === 1 ? [values[0], 'center'] : values;
277
295
  return pair.sort(sortTransformOriginPair);
278
296
  };
279
297
 
280
298
  // Transforms shorthand transformOrigin values
281
- var expandTransformOrigin = function expandTransformOrigin(key, value) {
282
- var match = ("" + value).split(' ');
283
- var pair = getTransformOriginPair(match);
299
+ const expandTransformOrigin = (key, value) => {
300
+ const match = `${value}`.split(' ');
301
+ const pair = getTransformOriginPair(match);
284
302
  return {
285
303
  transformOriginX: pair[0],
286
304
  transformOriginY: pair[1]
287
305
  };
288
306
  };
289
307
 
290
- var expandGap = function expandGap(key, value) {
291
- var match = ("" + value).split(' ');
308
+ const expandGap = (key, value) => {
309
+ const match = `${value}`.split(' ');
292
310
  return {
293
311
  rowGap: (match === null || match === void 0 ? void 0 : match[0]) || value,
294
312
  columnGap: (match === null || match === void 0 ? void 0 : match[1]) || value
295
313
  };
296
314
  };
297
315
 
298
- var shorthands = {
316
+ const shorthands = {
299
317
  flex: expandFlex,
300
318
  gap: expandGap,
301
319
  margin: processMargin,
@@ -332,9 +350,10 @@ var shorthands = {
332
350
  * @param {string} value style value
333
351
  * @returns {string | Number} transformed style values
334
352
  */
335
- var expandStyle = function expandStyle(key, value) {
336
- var _ref;
337
- return shorthands[key] ? shorthands[key](key, value) : (_ref = {}, _ref[key] = value, _ref);
353
+ const expandStyle = (key, value) => {
354
+ return shorthands[key] ? shorthands[key](key, value) : {
355
+ [key]: value
356
+ };
338
357
  };
339
358
 
340
359
  /**
@@ -343,18 +362,18 @@ var expandStyle = function expandStyle(key, value) {
343
362
  * @param {Object} style object
344
363
  * @returns {Object} expanded style object
345
364
  */
346
- var expand = function expand(style) {
365
+ const expand = style => {
347
366
  if (!style) return style;
348
- var propsArray = Object.keys(style);
349
- var resolvedStyle = {};
350
- for (var i = 0; i < propsArray.length; i += 1) {
351
- var key = propsArray[i];
352
- var value = style[key];
353
- var extended = expandStyle(key, value);
354
- var keys = Object.keys(extended);
355
- for (var j = 0; j < keys.length; j += 1) {
356
- var propName = keys[j];
357
- var propValue = extended[propName];
367
+ const propsArray = Object.keys(style);
368
+ const resolvedStyle = {};
369
+ for (let i = 0; i < propsArray.length; i += 1) {
370
+ const key = propsArray[i];
371
+ const value = style[key];
372
+ const extended = expandStyle(key, value);
373
+ const keys = Object.keys(extended);
374
+ for (let j = 0; j < keys.length; j += 1) {
375
+ const propName = keys[j];
376
+ const propValue = extended[propName];
358
377
  resolvedStyle[propName] = propValue;
359
378
  }
360
379
  }
@@ -368,9 +387,7 @@ var expand = function expand(style) {
368
387
  * @param {(T | null | undefined)[]} array
369
388
  * @returns {T[]} array without nils
370
389
  */
371
- var compact = function compact(array) {
372
- return array.filter(Boolean);
373
- };
390
+ const compact = array => array.filter(Boolean);
374
391
 
375
392
  /**
376
393
  * Merges style objects array
@@ -378,17 +395,15 @@ var compact = function compact(array) {
378
395
  * @param {Object[]} styles style objects array
379
396
  * @returns {Object} merged style object
380
397
  */
381
- var mergeStyles = function mergeStyles(styles) {
382
- return styles.reduce(function (acc, style) {
383
- var s = Array.isArray(style) ? flatten(style) : style;
384
- Object.keys(s).forEach(function (key) {
385
- if (s[key] !== null && s[key] !== undefined) {
386
- acc[key] = s[key];
387
- }
388
- });
389
- return acc;
390
- }, {});
391
- };
398
+ const mergeStyles = styles => styles.reduce((acc, style) => {
399
+ const s = Array.isArray(style) ? flatten(style) : style;
400
+ Object.keys(s).forEach(key => {
401
+ if (s[key] !== null && s[key] !== undefined) {
402
+ acc[key] = s[key];
403
+ }
404
+ });
405
+ return acc;
406
+ }, {});
392
407
 
393
408
  /**
394
409
  * Flattens an array of style objects, into one aggregated style object.
@@ -396,7 +411,7 @@ var mergeStyles = function mergeStyles(styles) {
396
411
  * @param {Object[]} styles style objects array
397
412
  * @returns {Object} flattened style object
398
413
  */
399
- var flatten = compose(mergeStyles, compact, castArray);
414
+ const flatten = compose(mergeStyles, compact, castArray);
400
415
 
401
416
  /**
402
417
  * Parses scalar value in value and unit pairs
@@ -404,13 +419,13 @@ var flatten = compose(mergeStyles, compact, castArray);
404
419
  * @param {string} value scalar value
405
420
  * @returns {Object} parsed value
406
421
  */
407
- var parseValue = function parseValue(value) {
408
- var match = /^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw|px)?$/g.exec(value);
422
+ const parseValue = value => {
423
+ const match = /^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw|px)?$/g.exec(value);
409
424
  return match ? {
410
425
  value: parseFloat(match[1]),
411
426
  unit: match[2] || 'pt'
412
427
  } : {
413
- value: value,
428
+ value,
414
429
  unit: undefined
415
430
  };
416
431
  };
@@ -422,11 +437,11 @@ var parseValue = function parseValue(value) {
422
437
  * @param {string} value styles value
423
438
  * @returns {Object} transformed value
424
439
  */
425
- var transformUnit = function transformUnit(container, value) {
426
- var scalar = parseValue(value);
427
- var dpi = container.dpi || 72;
428
- var mmFactor = 1 / 25.4 * dpi;
429
- var cmFactor = 1 / 2.54 * dpi;
440
+ const transformUnit = (container, value) => {
441
+ const scalar = parseValue(value);
442
+ const dpi = 72; // Removed: container.dpi || 72
443
+ const mmFactor = 1 / 25.4 * dpi;
444
+ const cmFactor = 1 / 2.54 * dpi;
430
445
  switch (scalar.unit) {
431
446
  case 'in':
432
447
  return scalar.value * dpi;
@@ -443,12 +458,8 @@ var transformUnit = function transformUnit(container, value) {
443
458
  }
444
459
  };
445
460
 
446
- var isRgb = function isRgb(value) {
447
- return /rgba?/g.test(value);
448
- };
449
- var isHsl = function isHsl(value) {
450
- return /hsla?/g.test(value);
451
- };
461
+ const isRgb = value => /rgba?/g.test(value);
462
+ const isHsl = value => /hsla?/g.test(value);
452
463
 
453
464
  /**
454
465
  * Transform rgb color to hexa
@@ -456,8 +467,8 @@ var isHsl = function isHsl(value) {
456
467
  * @param {string} value styles value
457
468
  * @returns {Object} transformed value
458
469
  */
459
- var parseRgb = function parseRgb(value) {
460
- var rgb = colorString.get.rgb(value);
470
+ const parseRgb = value => {
471
+ const rgb = colorString.get.rgb(value);
461
472
  return colorString.to.hex(rgb);
462
473
  };
463
474
 
@@ -467,9 +478,9 @@ var parseRgb = function parseRgb(value) {
467
478
  * @param {string} value styles value
468
479
  * @returns {Object} transformed value
469
480
  */
470
- var parseHsl = function parseHsl(value) {
471
- var hsl = colorString.get.hsl(value).map(Math.round);
472
- var hex = hlsToHex.apply(void 0, hsl);
481
+ const parseHsl = value => {
482
+ const hsl = colorString.get.hsl(value).map(Math.round);
483
+ const hex = hlsToHex(...hsl);
473
484
  return hex.toUpperCase();
474
485
  };
475
486
 
@@ -479,58 +490,49 @@ var parseHsl = function parseHsl(value) {
479
490
  * @param {string} value styles value
480
491
  * @returns {Object} transformed value
481
492
  */
482
- var transformColor = function transformColor(value) {
493
+ const transformColor = value => {
483
494
  if (isRgb(value)) return parseRgb(value);
484
495
  if (isHsl(value)) return parseHsl(value);
485
496
  return value;
486
497
  };
487
498
 
488
- var parse = function parse(transformString) {
489
- var transforms = transformString.trim().split(/\) |\)/);
499
+ const parse = transformString => {
500
+ const transforms = transformString.trim().split(/\) |\)/);
490
501
 
491
502
  // Handle "initial", "inherit", "unset".
492
503
  if (transforms.length === 1) {
493
504
  return [[transforms[0], true]];
494
505
  }
495
- var parsed = [];
496
- for (var i = 0; i < transforms.length; i += 1) {
497
- var transform = transforms[i];
506
+ const parsed = [];
507
+ for (let i = 0; i < transforms.length; i += 1) {
508
+ const transform = transforms[i];
498
509
  if (transform) {
499
- var _transform$split = transform.split('('),
500
- name = _transform$split[0],
501
- rawValue = _transform$split[1];
502
- var splitChar = rawValue.indexOf(',') >= 0 ? ',' : ' ';
503
- var value = rawValue.split(splitChar).map(function (val) {
504
- return val.trim();
505
- });
510
+ const [name, rawValue] = transform.split('(');
511
+ const splitChar = rawValue.indexOf(',') >= 0 ? ',' : ' ';
512
+ const value = rawValue.split(splitChar).map(val => val.trim());
506
513
  parsed.push({
507
514
  operation: name,
508
- value: value
515
+ value
509
516
  });
510
517
  }
511
518
  }
512
519
  return parsed;
513
520
  };
514
- var parseAngle = function parseAngle(value) {
515
- var unitsRegexp = /(-?\d*\.?\d*)(\w*)?/i;
516
- var _unitsRegexp$exec = unitsRegexp.exec(value),
517
- angle = _unitsRegexp$exec[1],
518
- unit = _unitsRegexp$exec[2];
519
- var number = Number.parseFloat(angle);
521
+ const parseAngle = value => {
522
+ const unitsRegexp = /(-?\d*\.?\d*)(\w*)?/i;
523
+ const [, angle, unit] = unitsRegexp.exec(value);
524
+ const number = Number.parseFloat(angle);
520
525
  return unit === 'rad' ? number * 180 / Math.PI : number;
521
526
  };
522
- var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
523
- var operation = _ref.operation,
524
- value = _ref.value;
527
+ const normalizeTransformOperation = _ref => {
528
+ let {
529
+ operation,
530
+ value
531
+ } = _ref;
525
532
  switch (operation) {
526
533
  case 'scale':
527
534
  {
528
- var _value$map = value.map(function (num) {
529
- return Number.parseFloat(num);
530
- }),
531
- scaleX = _value$map[0],
532
- _value$map$ = _value$map[1],
533
- scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
535
+ const [scaleX, scaleY = scaleX] = value.map(num => Number.parseFloat(num));
534
536
  return {
535
537
  operation: 'scale',
536
538
  value: [scaleX, scaleY]
@@ -561,9 +563,7 @@ var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
561
563
  {
562
564
  return {
563
565
  operation: 'translate',
564
- value: value.map(function (num) {
565
- return Number.parseFloat(num);
566
- })
566
+ value: value.map(num => Number.parseFloat(num))
567
567
  };
568
568
  }
569
569
  case 'translateX':
@@ -604,25 +604,21 @@ var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
604
604
  default:
605
605
  {
606
606
  return {
607
- operation: operation,
608
- value: value.map(function (num) {
609
- return Number.parseFloat(num);
610
- })
607
+ operation,
608
+ value: value.map(num => Number.parseFloat(num))
611
609
  };
612
610
  }
613
611
  }
614
612
  };
615
- var normalize = function normalize(operations) {
616
- return operations.map(function (operation) {
617
- return normalizeTransformOperation(operation);
618
- });
613
+ const normalize = operations => {
614
+ return operations.map(operation => normalizeTransformOperation(operation));
619
615
  };
620
- var processTransform = function processTransform(value) {
616
+ const processTransform = value => {
621
617
  if (typeof value !== 'string') return value;
622
618
  return normalize(parse(value));
623
619
  };
624
620
 
625
- var FONT_WEIGHTS = {
621
+ const FONT_WEIGHTS = {
626
622
  thin: 100,
627
623
  hairline: 100,
628
624
  ultralight: 200,
@@ -638,24 +634,22 @@ var FONT_WEIGHTS = {
638
634
  heavy: 900,
639
635
  black: 900
640
636
  };
641
- var processFontWeight = function processFontWeight(value) {
637
+ const processFontWeight = value => {
642
638
  if (!value) return FONT_WEIGHTS.normal;
643
639
  if (typeof value === 'number') return value;
644
- var lv = value.toLowerCase();
640
+ const lv = value.toLowerCase();
645
641
  if (FONT_WEIGHTS[lv]) return FONT_WEIGHTS[lv];
646
642
  return value;
647
643
  };
648
644
 
649
- var matchNumber = function matchNumber(value) {
650
- return typeof value === 'string' && /^-?\d*\.?\d*$/.test(value);
651
- };
652
- var castFloat = function castFloat(value) {
645
+ const matchNumber = value => typeof value === 'string' && /^-?\d*\.?\d*$/.test(value);
646
+ const castFloat = value => {
653
647
  if (typeof value !== 'string') return value;
654
648
  if (matchNumber(value)) return parseFloat(value);
655
649
  return value;
656
650
  };
657
651
 
658
- var offsetKeyword = function offsetKeyword(value) {
652
+ const offsetKeyword = value => {
659
653
  switch (value) {
660
654
  case 'top':
661
655
  case 'left':
@@ -670,15 +664,11 @@ var offsetKeyword = function offsetKeyword(value) {
670
664
  }
671
665
  };
672
666
 
673
- var transformObjectPosition = function transformObjectPosition(value) {
674
- return offsetKeyword(value) || castFloat(value);
675
- };
667
+ const transformObjectPosition = value => offsetKeyword(value) || castFloat(value);
676
668
 
677
- var transformTransformOrigin = function transformTransformOrigin(value) {
678
- return offsetKeyword(value) || castFloat(value);
679
- };
669
+ const transformTransformOrigin = value => offsetKeyword(value) || castFloat(value);
680
670
 
681
- var handlers = {
671
+ const handlers = {
682
672
  transform: processTransform,
683
673
  fontWeight: processFontWeight,
684
674
  objectPositionX: transformObjectPosition,
@@ -686,8 +676,8 @@ var handlers = {
686
676
  transformOriginX: transformTransformOrigin,
687
677
  transformOriginY: transformTransformOrigin
688
678
  };
689
- var transformStyle = function transformStyle(key, value, container) {
690
- var result = handlers[key] ? handlers[key](value) : value;
679
+ const transformStyle = (key, value, container) => {
680
+ const result = handlers[key] ? handlers[key](value) : value;
691
681
  return transformColor(transformUnit(container, castFloat(result)));
692
682
  };
693
683
 
@@ -703,19 +693,17 @@ var transformStyle = function transformStyle(key, value, container) {
703
693
  * @param {Object} container
704
694
  * @returns {Transform} transform function
705
695
  */
706
- var transform = function transform(container) {
707
- return function (style) {
708
- if (!style) return style;
709
- var propsArray = Object.keys(style);
710
- var resolvedStyle = {};
711
- for (var i = 0; i < propsArray.length; i += 1) {
712
- var key = propsArray[i];
713
- var value = style[key];
714
- var transformed = transformStyle(key, value, container);
715
- resolvedStyle[key] = transformed;
716
- }
717
- return resolvedStyle;
718
- };
696
+ const transform = container => style => {
697
+ if (!style) return style;
698
+ const propsArray = Object.keys(style);
699
+ const resolvedStyle = {};
700
+ for (let i = 0; i < propsArray.length; i += 1) {
701
+ const key = propsArray[i];
702
+ const value = style[key];
703
+ const transformed = transformStyle(key, value, container);
704
+ resolvedStyle[key] = transformed;
705
+ }
706
+ return resolvedStyle;
719
707
  };
720
708
 
721
709
  /**
@@ -724,14 +712,20 @@ var transform = function transform(container) {
724
712
  * @param {Object} container
725
713
  * @param {Object} styles object
726
714
  */
727
- var resolveMediaQueries = function resolveMediaQueries(container, styles) {
728
- return Object.keys(styles).reduce(function (acc, key) {
729
- var _extends2;
715
+ const resolveMediaQueries = (container, styles) => {
716
+ return Object.keys(styles).reduce((acc, key) => {
730
717
  if (/@media/.test(key)) {
731
- var _matchMedia;
732
- return _extends({}, acc, matchMedia((_matchMedia = {}, _matchMedia[key] = styles[key], _matchMedia), container));
718
+ return {
719
+ ...acc,
720
+ ...matchMedia({
721
+ [key]: styles[key]
722
+ }, container)
723
+ };
733
724
  }
734
- return _extends({}, acc, (_extends2 = {}, _extends2[key] = styles[key], _extends2));
725
+ return {
726
+ ...acc,
727
+ [key]: styles[key]
728
+ };
735
729
  }, {});
736
730
  };
737
731
 
@@ -742,10 +736,8 @@ var resolveMediaQueries = function resolveMediaQueries(container, styles) {
742
736
  * @param {Object} style object
743
737
  * @returns {Object} resolved style object
744
738
  */
745
- var resolveStyles = function resolveStyles(container, style) {
746
- var computeMediaQueries = function computeMediaQueries(value) {
747
- return resolveMediaQueries(container, value);
748
- };
739
+ const resolveStyles = (container, style) => {
740
+ const computeMediaQueries = value => resolveMediaQueries(container, value);
749
741
  return compose(transform(container), expand, computeMediaQueries, flatten)(style);
750
742
  };
751
743