/* ================================================================================ applyClassName ================================================================================ */ /** * A helper for getting string from `className` that can be a function. * When it's a function, it calls it with `context`. */ export function applyClassName( className: string | ((context: T) => string) | undefined, context: T, ) { return typeof className === 'function' ? className(context) : className; } /* ================================================================================ buildClassNameObject ================================================================================ */ export function buildClassNameObject>( className: string | T | undefined, mainClass: keyof T, ) { return typeof className === 'string' ? ({ [mainClass]: className } as Partial) : className || ({} as Partial); }