import { SxProps, Theme } from "@mui/material"; export function selectStyles( ...sxs: (SxProps | (boolean | SxProps)[] | undefined)[] ): SxProps { const final: SxProps[] = []; for (const sx of sxs) { if (Array.isArray(sx)) { if ((sx as (boolean | SxProps)[]).filter((v) => typeof v === "boolean").every((v) => v)) { // If every entry is true final.concat( (sx as (boolean | SxProps)[]).filter((v) => typeof v !== "boolean") as SxProps[], ); } } else if (sx !== undefined) { final.push(sx); } } return Object.assign({}, ...final.reverse()); } // Shorthand for select styles helper export const ss = selectStyles;