@lunit/oui
Version:
Lunit Oncology UI components
25 lines (24 loc) • 854 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { CloseSmall } from '../../icons';
import StyledChip from './Chip.styled';
import { presetMap } from './Chip.utils';
function Chip({ preset, label, icon, onDelete, onClick, ...otherProps }) {
const overwrittenProps = {
label,
icon,
onDelete,
onClick,
};
// Remove undefined properties
Object.keys(overwrittenProps).forEach((key) => overwrittenProps[key] === undefined ? delete overwrittenProps[key] : {});
const newPreset = preset?.includes('failed') ? 'failed' : preset;
const customProps = {
disableRipple: true,
deleteIcon: _jsx(CloseSmall, {}),
...presetMap[newPreset || 'default'],
...overwrittenProps,
...otherProps,
};
return _jsx(StyledChip, { ...customProps });
}
export default Chip;