@material-ui/unstyled
Version:
Unstyled React components with which to implement custom design systems.
19 lines (17 loc) • 595 B
JavaScript
export default function composeClasses(slots, getUtilityClass, classes) {
var output = {};
Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`.
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208
function (slot) {
output[slot] = slots[slot].reduce(function (acc, key) {
if (key) {
if (classes && classes[key]) {
acc.push(classes[key]);
}
acc.push(getUtilityClass(key));
}
return acc;
}, []).join(' ');
});
return output;
}