mirror of
https://github.com/harivansh-afk/RAG-ui.git
synced 2026-04-15 06:04:43 +00:00
26 lines
No EOL
668 B
TypeScript
26 lines
No EOL
668 B
TypeScript
type ClassValue = string | number | boolean | undefined | null;
|
|
type ClassArray = ClassValue[];
|
|
type ClassObject = { [key: string]: any };
|
|
type ClassInput = ClassValue | ClassArray | ClassObject;
|
|
|
|
export function cn(...inputs: ClassInput[]): string {
|
|
const classes = [];
|
|
|
|
for (const input of inputs) {
|
|
if (!input) continue;
|
|
|
|
if (typeof input === 'string') {
|
|
classes.push(input);
|
|
} else if (Array.isArray(input)) {
|
|
classes.push(cn(...input));
|
|
} else if (typeof input === 'object') {
|
|
for (const key in input) {
|
|
if (input[key]) {
|
|
classes.push(key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return classes.join(' ');
|
|
} |