@schema-render/core-react
Version:
Through a set of simple JSON Schema, efficiently build a set of forms.
35 lines (34 loc) • 1.15 kB
JavaScript
/* eslint-disable */ // @ts-nocheck
/**
* fork from https://github.com/JedWatson/classnames/blob/main/index.js
*/ const hasOwn = {}.hasOwnProperty;
function classNames() {
const classes = [];
for(let i = 0; i < arguments.length; i++){
const arg = arguments[i];
if (!arg) continue;
const argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg)) {
if (arg.length) {
const inner = classNames.apply(null, arg);
if (inner) {
classes.push(inner);
}
}
} else if (argType === 'object') {
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
classes.push(arg.toString());
continue;
}
for(const key in arg){
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
export default classNames;