@talend/react-bootstrap
Version:
Bootstrap 3 components built with React
44 lines • 1.32 kB
JavaScript
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { bsClass, bsStyles, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
import { State } from './utils/StyleConfig';
import CloseButton from './CloseButton';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const propTypes = {
onDismiss: PropTypes.func,
closeLabel: PropTypes.string
};
const defaultProps = {
closeLabel: 'Close alert'
};
class Alert extends React.Component {
render() {
const {
onDismiss,
closeLabel,
className,
children,
...props
} = this.props;
const [bsProps, elementProps] = splitBsProps(props);
const dismissable = !!onDismiss;
const classes = {
...getClassSet(bsProps),
[prefix(bsProps, 'dismissable')]: dismissable
};
return /*#__PURE__*/_jsxs("div", {
...elementProps,
role: "alert",
className: classNames(className, classes),
children: [dismissable && /*#__PURE__*/_jsx(CloseButton, {
onClick: onDismiss,
label: closeLabel
}), children]
});
}
}
Alert.propTypes = propTypes;
Alert.defaultProps = defaultProps;
export default bsStyles(Object.values(State), State.INFO, bsClass('alert', Alert));
//# sourceMappingURL=Alert.js.map