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