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