38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
|
import { extractStyleParts } from './extractStyleParts';
|
||
|
import { isShadowConfig } from './shadowConfig';
|
||
|
import { getStyleOptions } from './StyleOptionsState';
|
||
|
import { Stylesheet } from './Stylesheet';
|
||
|
import { styleToClassName } from './styleToClassName';
|
||
|
/**
|
||
|
* Concatenation helper, which can merge class names together. Skips over falsey values.
|
||
|
*
|
||
|
* @public
|
||
|
*/
|
||
|
export function mergeStyles() {
|
||
|
var args = [];
|
||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
args[_i] = arguments[_i];
|
||
|
}
|
||
|
return mergeCss(args, getStyleOptions());
|
||
|
}
|
||
|
/**
|
||
|
* Concatenation helper, which can merge class names together. Skips over falsey values.
|
||
|
* Accepts a set of options that will be used when calculating styles.
|
||
|
*
|
||
|
* @public
|
||
|
*/
|
||
|
export function mergeCss(args, options) {
|
||
|
var styleArgs = args instanceof Array ? args : [args];
|
||
|
var opts = options || {};
|
||
|
var hasShadowConfig = isShadowConfig(styleArgs[0]);
|
||
|
if (hasShadowConfig) {
|
||
|
opts.shadowConfig = styleArgs[0];
|
||
|
}
|
||
|
opts.stylesheet = Stylesheet.getInstance(opts.shadowConfig);
|
||
|
var _a = extractStyleParts(opts.stylesheet, styleArgs), classes = _a.classes, objects = _a.objects;
|
||
|
if (objects.length) {
|
||
|
classes.push(styleToClassName(opts, objects));
|
||
|
}
|
||
|
return classes.join(' ');
|
||
|
}
|
||
|
//# sourceMappingURL=mergeStyles.js.map
|