1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var concatStyleSets_1 = require("./concatStyleSets");
|
4 | var extractStyleParts_1 = require("./extractStyleParts");
|
5 | var StyleOptionsState_1 = require("./StyleOptionsState");
|
6 | var styleToClassName_1 = require("./styleToClassName");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function mergeStyleSets() {
|
16 | var styleSets = [];
|
17 | for (var _i = 0; _i < arguments.length; _i++) {
|
18 | styleSets[_i] = arguments[_i];
|
19 | }
|
20 | return mergeCssSets(styleSets, StyleOptionsState_1.getStyleOptions());
|
21 | }
|
22 | exports.mergeStyleSets = mergeStyleSets;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | function mergeCssSets(styleSets, options) {
|
33 | var _a, _b;
|
34 | var classNameSet = { subComponentStyles: {} };
|
35 | var styleSet = styleSets[0];
|
36 | if (!styleSet && styleSets.length <= 1) {
|
37 | return { subComponentStyles: {} };
|
38 | }
|
39 | var concatenatedStyleSet = concatStyleSets_1.concatStyleSets.apply(void 0, styleSets);
|
40 | var registrations = [];
|
41 | for (var styleSetArea in concatenatedStyleSet) {
|
42 | if (concatenatedStyleSet.hasOwnProperty(styleSetArea)) {
|
43 | if (styleSetArea === 'subComponentStyles') {
|
44 | classNameSet.subComponentStyles = concatenatedStyleSet.subComponentStyles || {};
|
45 | continue;
|
46 | }
|
47 | var styles = concatenatedStyleSet[styleSetArea];
|
48 | var _c = extractStyleParts_1.extractStyleParts(styles), classes = _c.classes, objects = _c.objects;
|
49 | if ((_a = objects) === null || _a === void 0 ? void 0 : _a.length) {
|
50 | var registration = styleToClassName_1.styleToRegistration(options || {}, { displayName: styleSetArea }, objects);
|
51 | if (registration) {
|
52 | registrations.push(registration);
|
53 | classNameSet[styleSetArea] = classes.concat([registration.className]).join(' ');
|
54 | }
|
55 | }
|
56 | else {
|
57 | classNameSet[styleSetArea] = classes.join(' ');
|
58 | }
|
59 | }
|
60 | }
|
61 | for (var _i = 0, registrations_1 = registrations; _i < registrations_1.length; _i++) {
|
62 | var registration = registrations_1[_i];
|
63 | if (registration) {
|
64 | styleToClassName_1.applyRegistration(registration, (_b = options) === null || _b === void 0 ? void 0 : _b.specificityMultiplier);
|
65 | }
|
66 | }
|
67 | return classNameSet;
|
68 | }
|
69 | exports.mergeCssSets = mergeCssSets;
|
70 |
|
\ | No newline at end of file |