UNPKG

2.88 kBJavaScriptView Raw
1var _excluded = ["children", "className", "close", "closeAriaLabel", "cssModule", "tag", "toggle", "wrapTag"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules, tagPropType } from './utils';
9var propTypes = {
10 children: PropTypes.node,
11 className: PropTypes.string,
12 close: PropTypes.object,
13 closeAriaLabel: PropTypes.string,
14 cssModule: PropTypes.object,
15 tag: tagPropType,
16 toggle: PropTypes.func,
17 wrapTag: tagPropType
18};
19function OffcanvasHeader(props) {
20 var closeButton;
21 var children = props.children,
22 className = props.className,
23 close = props.close,
24 _props$closeAriaLabel = props.closeAriaLabel,
25 closeAriaLabel = _props$closeAriaLabel === void 0 ? 'Close' : _props$closeAriaLabel,
26 cssModule = props.cssModule,
27 _props$tag = props.tag,
28 Tag = _props$tag === void 0 ? 'h5' : _props$tag,
29 toggle = props.toggle,
30 _props$wrapTag = props.wrapTag,
31 WrapTag = _props$wrapTag === void 0 ? 'div' : _props$wrapTag,
32 attributes = _objectWithoutProperties(props, _excluded);
33 var classes = mapToCssModules(classNames(className, 'offcanvas-header'), cssModule);
34 if (!close && toggle) {
35 closeButton = /*#__PURE__*/React.createElement("button", {
36 type: "button",
37 onClick: toggle,
38 className: mapToCssModules('btn-close', cssModule),
39 "aria-label": closeAriaLabel
40 });
41 }
42 return /*#__PURE__*/React.createElement(WrapTag, _extends({}, attributes, {
43 className: classes
44 }), /*#__PURE__*/React.createElement(Tag, {
45 className: mapToCssModules('offcanvas-title', cssModule)
46 }, children), close || closeButton);
47}
48OffcanvasHeader.propTypes = propTypes;
49export default OffcanvasHeader;
\No newline at end of file