@react-pdf/stylesheet 3.0.0 → 4.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.
@@ -0,0 +1,804 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fns = require('@react-pdf/fns');
6
+ var parse$1 = require('postcss-value-parser/lib/parse');
7
+ var parseUnit = require('postcss-value-parser/lib/unit');
8
+ var hlsToHex = require('hsl-to-hex');
9
+ var colorString = require('color-string');
10
+ var _extends = require('@babel/runtime/helpers/extends');
11
+ var matchMedia = require('media-engine');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var parse__default = /*#__PURE__*/_interopDefaultLegacy(parse$1);
16
+ var parseUnit__default = /*#__PURE__*/_interopDefaultLegacy(parseUnit);
17
+ var hlsToHex__default = /*#__PURE__*/_interopDefaultLegacy(hlsToHex);
18
+ var colorString__default = /*#__PURE__*/_interopDefaultLegacy(colorString);
19
+ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
20
+ var matchMedia__default = /*#__PURE__*/_interopDefaultLegacy(matchMedia);
21
+
22
+ var flexDefaults = [1, 1, 0];
23
+
24
+ var expandFlex = function expandFlex(key, value) {
25
+ var matches = ("" + value).split(' ');
26
+ var flexGrow = matches[0] || flexDefaults[0];
27
+ var flexShrink = matches[1] || flexDefaults[1];
28
+ var flexBasis = matches[2] || flexDefaults[2];
29
+ return {
30
+ flexGrow: flexGrow,
31
+ flexShrink: flexShrink,
32
+ flexBasis: flexBasis
33
+ };
34
+ };
35
+
36
+ /* eslint-disable no-plusplus */
37
+ var BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh';
38
+
39
+ var logError = function logError(style, value) {
40
+ console.error("\n @react-pdf/stylesheet parsing error:\n\n " + style + ": " + value + ",\n " + ' '.repeat(style.length + 2) + "^\n Unsupported " + style + " value format\n ");
41
+ };
42
+
43
+ var expandBoxModel = function expandBoxModel(_temp) {
44
+ var _ref = _temp === void 0 ? {} : _temp,
45
+ expandsTo = _ref.expandsTo,
46
+ _ref$maxValues = _ref.maxValues,
47
+ maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
48
+ _ref$autoSupported = _ref.autoSupported,
49
+ autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
50
+
51
+ return function (model, value) {
52
+ var _ref2;
53
+
54
+ var nodes = parse__default["default"]("" + value);
55
+ var parts = [];
56
+
57
+ for (var i = 0; i < nodes.length; i++) {
58
+ var node = nodes[i]; // value contains `calc`, `url` or other css function
59
+ // `,`, `/` or strings that unsupported by margin and padding
60
+
61
+ if (node.type === 'function' || node.type === 'string' || node.type === 'div') {
62
+ logError(model, value);
63
+ return {};
64
+ }
65
+
66
+ if (node.type === 'word') {
67
+ if (node.value === 'auto' && autoSupported) {
68
+ parts.push(node.value);
69
+ } else {
70
+ var result = parseUnit__default["default"](node.value); // when unit isn't specified this condition is true
71
+
72
+ if (result && BOX_MODEL_UNITS.includes(result.unit)) {
73
+ parts.push(node.value);
74
+ } else {
75
+ logError(model, value);
76
+ return {};
77
+ }
78
+ }
79
+ }
80
+ } // checks that we have enough parsed values
81
+
82
+
83
+ if (parts.length > maxValues) {
84
+ logError(model, value);
85
+ return {};
86
+ }
87
+
88
+ var first = parts[0];
89
+
90
+ if (expandsTo) {
91
+ var second = parts[1] || parts[0];
92
+ var third = parts[2] || parts[0];
93
+ var fourth = parts[3] || parts[1] || parts[0];
94
+ return expandsTo({
95
+ first: first,
96
+ second: second,
97
+ third: third,
98
+ fourth: fourth
99
+ });
100
+ }
101
+
102
+ return _ref2 = {}, _ref2[model] = first, _ref2;
103
+ };
104
+ };
105
+
106
+ var processMargin = expandBoxModel({
107
+ expandsTo: function expandsTo(_ref) {
108
+ var first = _ref.first,
109
+ second = _ref.second,
110
+ third = _ref.third,
111
+ fourth = _ref.fourth;
112
+ return {
113
+ marginTop: first,
114
+ marginRight: second,
115
+ marginBottom: third,
116
+ marginLeft: fourth
117
+ };
118
+ },
119
+ maxValues: 4,
120
+ autoSupported: true
121
+ });
122
+ var processMarginVertical = expandBoxModel({
123
+ expandsTo: function expandsTo(_ref2) {
124
+ var first = _ref2.first,
125
+ second = _ref2.second;
126
+ return {
127
+ marginTop: first,
128
+ marginBottom: second
129
+ };
130
+ },
131
+ maxValues: 2,
132
+ autoSupported: true
133
+ });
134
+ var processMarginHorizontal = expandBoxModel({
135
+ expandsTo: function expandsTo(_ref3) {
136
+ var first = _ref3.first,
137
+ second = _ref3.second;
138
+ return {
139
+ marginRight: first,
140
+ marginLeft: second
141
+ };
142
+ },
143
+ maxValues: 2,
144
+ autoSupported: true
145
+ });
146
+ var processMarginSingle = expandBoxModel({
147
+ autoSupported: true
148
+ });
149
+
150
+ var BORDER_SHORTHAND_REGEX = /(-?\d+(\.\d+)?(px|in|mm|cm|pt|vw|vh|px)?)\s(\S+)\s(.+)/;
151
+
152
+ var matchBorderShorthand = function matchBorderShorthand(value) {
153
+ return value.match(BORDER_SHORTHAND_REGEX) || [];
154
+ };
155
+
156
+ var expandBorders = function expandBorders(key, value) {
157
+ var match = matchBorderShorthand("" + value);
158
+
159
+ if (match) {
160
+ var color = match[5] || value;
161
+ var style = match[4] || value;
162
+ var width = match[1] || value;
163
+
164
+ if (key.match(/(Top|Right|Bottom|Left)$/)) {
165
+ var _ref;
166
+
167
+ return _ref = {}, _ref[key + "Color"] = color, _ref[key + "Style"] = style, _ref[key + "Width"] = width, _ref;
168
+ }
169
+
170
+ if (key.match(/Color$/)) {
171
+ return {
172
+ borderTopColor: color,
173
+ borderRightColor: color,
174
+ borderBottomColor: color,
175
+ borderLeftColor: color
176
+ };
177
+ }
178
+
179
+ if (key.match(/Style$/)) {
180
+ return {
181
+ borderTopStyle: style,
182
+ borderRightStyle: style,
183
+ borderBottomStyle: style,
184
+ borderLeftStyle: style
185
+ };
186
+ }
187
+
188
+ if (key.match(/Width$/)) {
189
+ return {
190
+ borderTopWidth: width,
191
+ borderRightWidth: width,
192
+ borderBottomWidth: width,
193
+ borderLeftWidth: width
194
+ };
195
+ }
196
+
197
+ if (key.match(/Radius$/)) {
198
+ return {
199
+ borderTopLeftRadius: value,
200
+ borderTopRightRadius: value,
201
+ borderBottomRightRadius: value,
202
+ borderBottomLeftRadius: value
203
+ };
204
+ }
205
+
206
+ return {
207
+ borderTopColor: color,
208
+ borderTopStyle: style,
209
+ borderTopWidth: width,
210
+ borderRightColor: color,
211
+ borderRightStyle: style,
212
+ borderRightWidth: width,
213
+ borderBottomColor: color,
214
+ borderBottomStyle: style,
215
+ borderBottomWidth: width,
216
+ borderLeftColor: color,
217
+ borderLeftStyle: style,
218
+ borderLeftWidth: width
219
+ };
220
+ }
221
+
222
+ return value;
223
+ };
224
+
225
+ var processPadding = expandBoxModel({
226
+ expandsTo: function expandsTo(_ref) {
227
+ var first = _ref.first,
228
+ second = _ref.second,
229
+ third = _ref.third,
230
+ fourth = _ref.fourth;
231
+ return {
232
+ paddingTop: first,
233
+ paddingRight: second,
234
+ paddingBottom: third,
235
+ paddingLeft: fourth
236
+ };
237
+ },
238
+ maxValues: 4
239
+ });
240
+ var processPaddingVertical = expandBoxModel({
241
+ expandsTo: function expandsTo(_ref2) {
242
+ var first = _ref2.first,
243
+ second = _ref2.second;
244
+ return {
245
+ paddingTop: first,
246
+ paddingBottom: second
247
+ };
248
+ },
249
+ maxValues: 2
250
+ });
251
+ var processPaddingHorizontal = expandBoxModel({
252
+ expandsTo: function expandsTo(_ref3) {
253
+ var first = _ref3.first,
254
+ second = _ref3.second;
255
+ return {
256
+ paddingRight: first,
257
+ paddingLeft: second
258
+ };
259
+ },
260
+ maxValues: 2
261
+ });
262
+ var processPaddingSingle = expandBoxModel();
263
+
264
+ var expandObjectPosition = function expandObjectPosition(key, value) {
265
+ var match = ("" + value).split(' ');
266
+ return {
267
+ objectPositionX: (match === null || match === void 0 ? void 0 : match[0]) || value,
268
+ objectPositionY: (match === null || match === void 0 ? void 0 : match[1]) || value
269
+ };
270
+ };
271
+
272
+ var Y_AXIS_SHORTHANDS = {
273
+ top: true,
274
+ bottom: true
275
+ };
276
+
277
+ var sortTransformOriginPair = function sortTransformOriginPair(a, b) {
278
+ if (Y_AXIS_SHORTHANDS[a]) return 1;
279
+ if (Y_AXIS_SHORTHANDS[b]) return -1;
280
+ return 0;
281
+ };
282
+
283
+ var getTransformOriginPair = function getTransformOriginPair(values) {
284
+ if (!values || values.length === 0) return ['center', 'center'];
285
+ var pair = values.length === 1 ? [values[0], 'center'] : values;
286
+ return pair.sort(sortTransformOriginPair);
287
+ }; // Transforms shorthand transformOrigin values
288
+
289
+
290
+ var expandTransformOrigin = function expandTransformOrigin(key, value) {
291
+ var match = ("" + value).split(' ');
292
+ var pair = getTransformOriginPair(match);
293
+ return {
294
+ transformOriginX: pair[0],
295
+ transformOriginY: pair[1]
296
+ };
297
+ };
298
+
299
+ var shorthands = {
300
+ flex: expandFlex,
301
+ margin: processMargin,
302
+ marginHorizontal: processMarginHorizontal,
303
+ marginVertical: processMarginVertical,
304
+ marginTop: processMarginSingle,
305
+ marginRight: processMarginSingle,
306
+ marginBottom: processMarginSingle,
307
+ marginLeft: processMarginSingle,
308
+ padding: processPadding,
309
+ paddingHorizontal: processPaddingHorizontal,
310
+ paddingVertical: processPaddingVertical,
311
+ paddingTop: processPaddingSingle,
312
+ paddingRight: processPaddingSingle,
313
+ paddingBottom: processPaddingSingle,
314
+ paddingLeft: processPaddingSingle,
315
+ border: expandBorders,
316
+ borderTop: expandBorders,
317
+ borderRight: expandBorders,
318
+ borderBottom: expandBorders,
319
+ borderLeft: expandBorders,
320
+ borderColor: expandBorders,
321
+ borderRadius: expandBorders,
322
+ borderStyle: expandBorders,
323
+ borderWidth: expandBorders,
324
+ objectPosition: expandObjectPosition,
325
+ transformOrigin: expandTransformOrigin
326
+ };
327
+ /**
328
+ * Transforms style key-value
329
+ *
330
+ * @param {String} key style key
331
+ * @param {String} value style value
332
+ * @returns {String | Number} transformed style values
333
+ */
334
+
335
+ var expandStyle = function expandStyle(key, value) {
336
+ var _ref;
337
+
338
+ return shorthands[key] ? shorthands[key](key, value) : (_ref = {}, _ref[key] = value, _ref);
339
+ };
340
+ /**
341
+ * Expand the shorthand properties.
342
+ *
343
+ * @param { Object } style object
344
+ * @returns { Object } expanded style object
345
+ */
346
+
347
+
348
+ var expand = function expand(style) {
349
+ if (!style) return style;
350
+ var propsArray = Object.keys(style);
351
+ var resolvedStyle = {};
352
+
353
+ for (var i = 0; i < propsArray.length; i += 1) {
354
+ var key = propsArray[i];
355
+ var value = style[key];
356
+ var extended = expandStyle(key, value);
357
+ var keys = Object.keys(extended);
358
+
359
+ for (var j = 0; j < keys.length; j += 1) {
360
+ var propName = keys[j];
361
+ var propValue = extended[propName];
362
+ resolvedStyle[propName] = propValue;
363
+ }
364
+ }
365
+
366
+ return resolvedStyle;
367
+ };
368
+
369
+ /**
370
+ * Remove nil values from array
371
+ *
372
+ * @param {Array} array
373
+ * @returns {Array} array without nils
374
+ */
375
+
376
+ var compact = function compact(array) {
377
+ return array.filter(Boolean);
378
+ };
379
+ /**
380
+ * Merges style objects array
381
+ *
382
+ * @param {Array} style objects array
383
+ * @returns {Object} merged style object
384
+ */
385
+
386
+
387
+ var mergeStyles = function mergeStyles(styles) {
388
+ return styles.reduce(function (acc, style) {
389
+ var s = Array.isArray(style) ? flatten(style) : style;
390
+ Object.keys(s).forEach(function (key) {
391
+ if (s[key] !== null && s[key] !== undefined) {
392
+ acc[key] = s[key];
393
+ }
394
+ });
395
+ return acc;
396
+ }, {});
397
+ };
398
+ /**
399
+ * Flattens an array of style objects, into one aggregated style object.
400
+ *
401
+ * @param {Array} style objects array
402
+ * @returns {Object} flatted style object
403
+ */
404
+
405
+
406
+ var flatten = fns.compose(mergeStyles, compact, fns.castArray);
407
+
408
+ /**
409
+ * Parses scalar value in value and unit pairs
410
+ *
411
+ * @param {String} scalar value
412
+ * @returns {Object} parsed value
413
+ */
414
+ var parseValue = function parseValue(value) {
415
+ var match = /^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw|px)?$/g.exec(value);
416
+ return match ? {
417
+ value: parseFloat(match[1], 10),
418
+ unit: match[2] || 'pt'
419
+ } : {
420
+ value: value,
421
+ unit: undefined
422
+ };
423
+ };
424
+ /**
425
+ * Transform given scalar value
426
+ *
427
+ * @param {Object} container
428
+ * @param {String} styles value
429
+ * @returns {Object} transformed value
430
+ */
431
+
432
+
433
+ var transformUnit = function transformUnit(container, value) {
434
+ var scalar = parseValue(value);
435
+ var dpi = container.dpi || 72;
436
+ var mmFactor = 1 / 25.4 * dpi;
437
+ var cmFactor = 1 / 2.54 * dpi;
438
+
439
+ switch (scalar.unit) {
440
+ case 'in':
441
+ return scalar.value * dpi;
442
+
443
+ case 'mm':
444
+ return scalar.value * mmFactor;
445
+
446
+ case 'cm':
447
+ return scalar.value * cmFactor;
448
+
449
+ case 'vh':
450
+ return scalar.value * (container.height / 100);
451
+
452
+ case 'vw':
453
+ return scalar.value * (container.width / 100);
454
+
455
+ default:
456
+ return scalar.value;
457
+ }
458
+ };
459
+
460
+ var isRgb = function isRgb(value) {
461
+ return /rgba?/g.test(value);
462
+ };
463
+
464
+ var isHsl = function isHsl(value) {
465
+ return /hsla?/g.test(value);
466
+ };
467
+ /**
468
+ * Transform rgb color to hexa
469
+ *
470
+ * @param {String} styles value
471
+ * @returns {Object} transformed value
472
+ */
473
+
474
+
475
+ var parseRgb = function parseRgb(value) {
476
+ var rgb = colorString__default["default"].get.rgb(value);
477
+ return colorString__default["default"].to.hex(rgb);
478
+ };
479
+ /**
480
+ * Transform Hsl color to hexa
481
+ *
482
+ * @param {String} styles value
483
+ * @returns {Object} transformed value
484
+ */
485
+
486
+
487
+ var parseHsl = function parseHsl(value) {
488
+ var hsl = colorString__default["default"].get.hsl(value).map(Math.round);
489
+ var hex = hlsToHex__default["default"].apply(void 0, hsl);
490
+ return hex.toUpperCase();
491
+ };
492
+ /**
493
+ * Transform given color to hexa
494
+ *
495
+ * @param {String} styles value
496
+ * @returns {Object} transformed value
497
+ */
498
+
499
+
500
+ var transformColor = function transformColor(value) {
501
+ if (isRgb(value)) return parseRgb(value);
502
+ if (isHsl(value)) return parseHsl(value);
503
+ return value;
504
+ };
505
+
506
+ var parse = function parse(transformString) {
507
+ var transforms = transformString.trim().split(/\) |\)/); // Handle "initial", "inherit", "unset".
508
+
509
+ if (transforms.length === 1) {
510
+ return [[transforms[0], true]];
511
+ }
512
+
513
+ var parsed = [];
514
+
515
+ for (var i = 0; i < transforms.length; i += 1) {
516
+ var transform = transforms[i];
517
+
518
+ if (transform) {
519
+ var _transform$split = transform.split('('),
520
+ name = _transform$split[0],
521
+ rawValue = _transform$split[1];
522
+
523
+ var splitChar = rawValue.indexOf(',') >= 0 ? ',' : ' ';
524
+ var value = rawValue.split(splitChar).map(function (val) {
525
+ return val.trim();
526
+ });
527
+ parsed.push({
528
+ operation: name,
529
+ value: value
530
+ });
531
+ }
532
+ }
533
+
534
+ return parsed;
535
+ };
536
+
537
+ var parseAngle = function parseAngle(value) {
538
+ var unitsRegexp = /(-?\d*\.?\d*)(\w*)?/i;
539
+
540
+ var _unitsRegexp$exec = unitsRegexp.exec(value),
541
+ angle = _unitsRegexp$exec[1],
542
+ unit = _unitsRegexp$exec[2];
543
+
544
+ var number = Number.parseFloat(angle);
545
+ return unit === 'rad' ? number * 180 / Math.PI : number;
546
+ };
547
+
548
+ var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
549
+ var operation = _ref.operation,
550
+ value = _ref.value;
551
+
552
+ switch (operation) {
553
+ case 'scale':
554
+ {
555
+ var _value$map = value.map(function (num) {
556
+ return Number.parseFloat(num);
557
+ }),
558
+ scaleX = _value$map[0],
559
+ _value$map$ = _value$map[1],
560
+ scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
561
+
562
+ return {
563
+ operation: 'scale',
564
+ value: [scaleX, scaleY]
565
+ };
566
+ }
567
+
568
+ case 'scaleX':
569
+ {
570
+ return {
571
+ operation: 'scale',
572
+ value: [Number.parseFloat(value), 1]
573
+ };
574
+ }
575
+
576
+ case 'scaleY':
577
+ {
578
+ return {
579
+ operation: 'scale',
580
+ value: [1, Number.parseFloat(value)]
581
+ };
582
+ }
583
+
584
+ case 'rotate':
585
+ {
586
+ return {
587
+ operation: 'rotate',
588
+ value: [parseAngle(value)]
589
+ };
590
+ }
591
+
592
+ case 'translate':
593
+ {
594
+ return {
595
+ operation: 'translate',
596
+ value: value.map(function (num) {
597
+ return Number.parseFloat(num);
598
+ })
599
+ };
600
+ }
601
+
602
+ case 'translateX':
603
+ {
604
+ return {
605
+ operation: 'translate',
606
+ value: [Number.parseFloat(value), 0]
607
+ };
608
+ }
609
+
610
+ case 'translateY':
611
+ {
612
+ return {
613
+ operation: 'translate',
614
+ value: [0, Number.parseFloat(value)]
615
+ };
616
+ }
617
+
618
+ case 'skew':
619
+ {
620
+ return {
621
+ operation: 'skew',
622
+ value: value.map(parseAngle)
623
+ };
624
+ }
625
+
626
+ case 'skewX':
627
+ {
628
+ return {
629
+ operation: 'skew',
630
+ value: [parseAngle(value), 0]
631
+ };
632
+ }
633
+
634
+ case 'skewY':
635
+ {
636
+ return {
637
+ operation: 'skew',
638
+ value: [0, parseAngle(value)]
639
+ };
640
+ }
641
+
642
+ default:
643
+ {
644
+ return {
645
+ operation: operation,
646
+ value: value.map(function (num) {
647
+ return Number.parseFloat(num);
648
+ })
649
+ };
650
+ }
651
+ }
652
+ };
653
+
654
+ var normalize = function normalize(operations) {
655
+ return operations.map(function (operation) {
656
+ return normalizeTransformOperation(operation);
657
+ });
658
+ };
659
+
660
+ var processTransform = function processTransform(value) {
661
+ if (typeof value !== 'string') return value;
662
+ return normalize(parse(value));
663
+ };
664
+
665
+ var FONT_WEIGHTS = {
666
+ thin: 100,
667
+ hairline: 100,
668
+ ultralight: 200,
669
+ extralight: 200,
670
+ light: 300,
671
+ normal: 400,
672
+ medium: 500,
673
+ semibold: 600,
674
+ demibold: 600,
675
+ bold: 700,
676
+ ultrabold: 800,
677
+ extrabold: 800,
678
+ heavy: 900,
679
+ black: 900
680
+ };
681
+
682
+ var processFontWeight = function processFontWeight(value) {
683
+ if (!value) return FONT_WEIGHTS.normal;
684
+ if (typeof value === 'number') return value;
685
+ var lv = value.toLowerCase();
686
+ if (FONT_WEIGHTS[lv]) return FONT_WEIGHTS[lv];
687
+ return value;
688
+ };
689
+
690
+ var matchNumber = function matchNumber(value) {
691
+ return typeof value === 'string' && /^-?\d*\.?\d*$/.test(value);
692
+ };
693
+
694
+ var castFloat = function castFloat(value) {
695
+ if (typeof value !== 'string') return value;
696
+ if (matchNumber(value)) return parseFloat(value, 10);
697
+ return value;
698
+ };
699
+
700
+ var offsetKeyword = function offsetKeyword(value) {
701
+ switch (value) {
702
+ case 'top':
703
+ case 'left':
704
+ return '0%';
705
+
706
+ case 'right':
707
+ case 'bottom':
708
+ return '100%';
709
+
710
+ case 'center':
711
+ return '50%';
712
+
713
+ default:
714
+ return null;
715
+ }
716
+ };
717
+
718
+ var transformObjectPosition = function transformObjectPosition(value) {
719
+ return offsetKeyword(value) || castFloat(value);
720
+ };
721
+
722
+ var transformTransformOrigin = function transformTransformOrigin(value) {
723
+ return offsetKeyword(value) || castFloat(value);
724
+ };
725
+
726
+ var handlers = {
727
+ transform: processTransform,
728
+ fontWeight: processFontWeight,
729
+ objectPositionX: transformObjectPosition,
730
+ objectPositionY: transformObjectPosition,
731
+ transformOriginX: transformTransformOrigin,
732
+ transformOriginY: transformTransformOrigin
733
+ };
734
+
735
+ var transformStyle = function transformStyle(key, value, container) {
736
+ var result = handlers[key] ? handlers[key](value) : value;
737
+ return transformColor(transformUnit(container, castFloat(result)));
738
+ };
739
+ /**
740
+ * Transform styles values
741
+ *
742
+ * @param {Object} styles object
743
+ * @returns {Object} transformed styles
744
+ */
745
+
746
+
747
+ var transform = function transform(container) {
748
+ return function (style) {
749
+ if (!style) return style;
750
+ var propsArray = Object.keys(style);
751
+ var resolvedStyle = {};
752
+
753
+ for (var i = 0; i < propsArray.length; i += 1) {
754
+ var key = propsArray[i];
755
+ var value = style[key];
756
+ var transformed = transformStyle(key, value, container);
757
+ resolvedStyle[key] = transformed;
758
+ }
759
+
760
+ return resolvedStyle;
761
+ };
762
+ };
763
+
764
+ /**
765
+ * Resolves media queries in styles object
766
+ *
767
+ * @param {Object} container
768
+ * @param {Object} styles object
769
+ */
770
+
771
+ var resolveMediaQueries = function resolveMediaQueries(container, styles) {
772
+ return Object.keys(styles).reduce(function (acc, key) {
773
+ var _extends2;
774
+
775
+ if (/@media/.test(key)) {
776
+ var _matchMedia;
777
+
778
+ return _extends__default["default"]({}, acc, matchMedia__default["default"]((_matchMedia = {}, _matchMedia[key] = styles[key], _matchMedia), container));
779
+ }
780
+
781
+ return _extends__default["default"]({}, acc, (_extends2 = {}, _extends2[key] = styles[key], _extends2));
782
+ }, {});
783
+ };
784
+
785
+ /**
786
+ * Resolves styles
787
+ *
788
+ * @param {Object} container
789
+ * @param {Object} style object
790
+ * @returns {Object} resolved style object
791
+ */
792
+
793
+ var resolveStyles = function resolveStyles(container, style) {
794
+ var computeMediaQueries = function computeMediaQueries(value) {
795
+ return resolveMediaQueries(container, value);
796
+ };
797
+
798
+ return fns.compose(transform(container), expand, computeMediaQueries, flatten)(style);
799
+ }; // Utils exported for SVG processing
800
+
801
+ exports["default"] = resolveStyles;
802
+ exports.flatten = flatten;
803
+ exports.processTransform = processTransform;
804
+ exports.transformColor = transformColor;