@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
49 lines (45 loc) • 1.3 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import React__default from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { usePrefix } from '../internal/usePrefix.js';
/**
* @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
* @returns
*/
const wrapComponent = _ref => {
let {
name,
className: getClassName,
type
} = _ref;
/**
*
* @param {{ className?: string, [x: string]: any}} param0
* @returns
*/
function Component(_ref2) {
let {
className: baseClassName,
...other
} = _ref2;
const prefix = usePrefix();
const componentClass = cx(typeof getClassName === 'function' ? getClassName(prefix) : getClassName, baseClassName);
return /*#__PURE__*/React__default.createElement(type, {
...other,
// Prevent Weird quirk where `cx` will evaluate to an empty string, '',
// and so we have empty `class` attributes in the resulting markup
// eslint-disable-next-line no-extra-boolean-cast
className: !!componentClass ? componentClass : undefined
});
}
Component.displayName = name;
Component.propTypes = {
className: PropTypes.string
};
return Component;
};
var wrapComponent$1 = wrapComponent;
export { wrapComponent$1 as default };