UNPKG

1.39 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var concatStyleSets_1 = require("./concatStyleSets");
4/**
5 * Concatenates style sets into one, but resolves functional sets using the given props.
6 * @param styleProps - Props used to resolve functional sets.
7 * @param allStyles - Style sets, which can be functions or objects.
8 */
9function concatStyleSetsWithProps(styleProps) {
10 var allStyles = [];
11 for (var _i = 1; _i < arguments.length; _i++) {
12 allStyles[_i - 1] = arguments[_i];
13 }
14 var result = [];
15 for (var _a = 0, allStyles_1 = allStyles; _a < allStyles_1.length; _a++) {
16 var styles = allStyles_1[_a];
17 if (styles) {
18 result.push(typeof styles === 'function' ? styles(styleProps) : styles);
19 }
20 }
21 if (result.length === 1) {
22 return result[0];
23 }
24 else if (result.length) {
25 // cliffkoh: I cannot figure out how to avoid the cast to any here.
26 // It is something to do with the use of Omit in IStyleSet.
27 // It might not be necessary once Omit becomes part of lib.d.ts (when we remove our own Omit and rely on
28 // the official version).
29 return concatStyleSets_1.concatStyleSets.apply(void 0, result);
30 }
31 return {};
32}
33exports.concatStyleSetsWithProps = concatStyleSetsWithProps;
34//# sourceMappingURL=concatStyleSetsWithProps.js.map
\No newline at end of file