1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslib_1 = require("tslib");
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function concatStyleSets() {
|
9 | var styleSets = [];
|
10 | for (var _i = 0; _i < arguments.length; _i++) {
|
11 | styleSets[_i] = arguments[_i];
|
12 | }
|
13 | if (styleSets && styleSets.length === 1 && styleSets[0] && !styleSets[0].subComponentStyles) {
|
14 | return styleSets[0];
|
15 | }
|
16 | var mergedSet = {};
|
17 |
|
18 | var workingSubcomponentStyles = {};
|
19 | for (var _a = 0, styleSets_1 = styleSets; _a < styleSets_1.length; _a++) {
|
20 | var currentSet = styleSets_1[_a];
|
21 | if (currentSet) {
|
22 | for (var prop in currentSet) {
|
23 | if (currentSet.hasOwnProperty(prop)) {
|
24 | if (prop === 'subComponentStyles' && currentSet.subComponentStyles !== undefined) {
|
25 |
|
26 | var currentComponentStyles = currentSet.subComponentStyles;
|
27 | for (var subCompProp in currentComponentStyles) {
|
28 | if (currentComponentStyles.hasOwnProperty(subCompProp)) {
|
29 | if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) {
|
30 | workingSubcomponentStyles[subCompProp].push(currentComponentStyles[subCompProp]);
|
31 | }
|
32 | else {
|
33 | workingSubcomponentStyles[subCompProp] = [currentComponentStyles[subCompProp]];
|
34 | }
|
35 | }
|
36 | }
|
37 | continue;
|
38 | }
|
39 |
|
40 |
|
41 | var mergedValue = mergedSet[prop];
|
42 | var currentValue = currentSet[prop];
|
43 | if (mergedValue === undefined) {
|
44 | mergedSet[prop] = currentValue;
|
45 | }
|
46 | else {
|
47 | mergedSet[prop] = tslib_1.__spreadArrays((Array.isArray(mergedValue) ? mergedValue : [mergedValue]), (Array.isArray(currentValue) ? currentValue : [currentValue]));
|
48 | }
|
49 | }
|
50 | }
|
51 | }
|
52 | }
|
53 | if (Object.keys(workingSubcomponentStyles).length > 0) {
|
54 | mergedSet.subComponentStyles = {};
|
55 | var mergedSubStyles = mergedSet.subComponentStyles;
|
56 | var _loop_1 = function (subCompProp) {
|
57 | if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) {
|
58 | var workingSet_1 = workingSubcomponentStyles[subCompProp];
|
59 | mergedSubStyles[subCompProp] = function (styleProps) {
|
60 | return concatStyleSets.apply(void 0, workingSet_1.map(function (styleFunctionOrObject) {
|
61 | return typeof styleFunctionOrObject === 'function' ? styleFunctionOrObject(styleProps) : styleFunctionOrObject;
|
62 | }));
|
63 | };
|
64 | }
|
65 | };
|
66 |
|
67 | for (var subCompProp in workingSubcomponentStyles) {
|
68 | _loop_1(subCompProp);
|
69 | }
|
70 | }
|
71 | return mergedSet;
|
72 | }
|
73 | exports.concatStyleSets = concatStyleSets;
|
74 |
|
\ | No newline at end of file |