UNPKG

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