mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
||
|
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
||
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import classNames from 'classnames';
|
||
|
import { TabContext } from './TabContext';
|
||
|
import { mapToCssModules, omit, tagPropType } from './utils';
|
||
|
var propTypes = {
|
||
|
tag: tagPropType,
|
||
|
activeTab: PropTypes.any,
|
||
|
className: PropTypes.string,
|
||
|
cssModule: PropTypes.object
|
||
|
};
|
||
|
var defaultProps = {
|
||
|
tag: 'div'
|
||
|
};
|
||
|
|
||
|
var TabContent = /*#__PURE__*/function (_Component) {
|
||
|
_inheritsLoose(TabContent, _Component);
|
||
|
|
||
|
TabContent.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
|
||
|
if (prevState.activeTab !== nextProps.activeTab) {
|
||
|
return {
|
||
|
activeTab: nextProps.activeTab
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
};
|
||
|
|
||
|
function TabContent(props) {
|
||
|
var _this;
|
||
|
|
||
|
_this = _Component.call(this, props) || this;
|
||
|
_this.state = {
|
||
|
activeTab: _this.props.activeTab
|
||
|
};
|
||
|
return _this;
|
||
|
}
|
||
|
|
||
|
var _proto = TabContent.prototype;
|
||
|
|
||
|
_proto.render = function render() {
|
||
|
var _this$props = this.props,
|
||
|
className = _this$props.className,
|
||
|
cssModule = _this$props.cssModule,
|
||
|
Tag = _this$props.tag;
|
||
|
var attributes = omit(this.props, Object.keys(propTypes));
|
||
|
var classes = mapToCssModules(classNames('tab-content', className), cssModule);
|
||
|
return /*#__PURE__*/React.createElement(TabContext.Provider, {
|
||
|
value: {
|
||
|
activeTabId: this.state.activeTab
|
||
|
}
|
||
|
}, /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
|
||
|
className: classes
|
||
|
})));
|
||
|
};
|
||
|
|
||
|
return TabContent;
|
||
|
}(Component);
|
||
|
|
||
|
export default TabContent;
|
||
|
TabContent.propTypes = propTypes;
|
||
|
TabContent.defaultProps = defaultProps;
|