FrontPastel/node_modules/@mui/utils/composeClasses/composeClasses.js

21 lines
686 B
JavaScript

export default function composeClasses(slots, getUtilityClass, classes = undefined) {
const output = {};
Object.keys(slots).forEach(
// `Object.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
slot => {
output[slot] = slots[slot].reduce((acc, key) => {
if (key) {
const utilityClass = getUtilityClass(key);
if (utilityClass !== '') {
acc.push(utilityClass);
}
if (classes && classes[key]) {
acc.push(classes[key]);
}
}
return acc;
}, []).join(' ');
});
return output;
}