@talend/react-bootstrap
Version:
Bootstrap 3 components built with React
48 lines • 1.36 kB
JavaScript
import PropTypes from 'prop-types';
import React from 'react';
import cn from 'classnames';
import elementType from 'react-prop-types/lib/elementType';
import { prefix, bsClass, splitBsProps } from './utils/bootstrapUtils';
import { jsx as _jsx } from "react/jsx-runtime";
const propTypes = {
componentClass: elementType
};
const defaultProps = {
componentClass: 'div'
};
const contextTypes = {
$bs_panel: PropTypes.shape({
headingId: PropTypes.string,
bsClass: PropTypes.string
})
};
class PanelHeading extends React.Component {
render() {
const {
children,
className,
componentClass: Component,
...props
} = this.props;
const {
headingId,
bsClass: _bsClass
} = this.context.$bs_panel || {};
const [bsProps, elementProps] = splitBsProps(props);
bsProps.bsClass = _bsClass || bsProps.bsClass;
if (headingId) {
elementProps.role = elementProps.role || 'tab';
elementProps.id = headingId;
}
return /*#__PURE__*/_jsx(Component, {
...elementProps,
className: cn(className, prefix(bsProps, 'heading')),
children: children
});
}
}
PanelHeading.propTypes = propTypes;
PanelHeading.defaultProps = defaultProps;
PanelHeading.contextTypes = contextTypes;
export default bsClass('panel', PanelHeading);
//# sourceMappingURL=PanelHeading.js.map