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