choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
101 lines (82 loc) • 3.22 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
var PanelContent =
/*#__PURE__*/
function (_Component) {
_inherits(PanelContent, _Component);
var _super = _createSuper(PanelContent);
function PanelContent() {
_classCallCheck(this, PanelContent);
return _super.apply(this, arguments);
}
_createClass(PanelContent, [{
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps) {
return !this.props.isInactive || !nextProps.isInactive;
}
}, {
key: "render",
value: function render() {
var _classnames;
this._isActived = this.props.forceRender || this._isActived || !this.props.isInactive;
if (!this._isActived) {
return null;
}
var _this$props = this.props,
prefixCls = _this$props.prefixCls,
isInactive = _this$props.isInactive,
children = _this$props.children,
destroyInactivePanel = _this$props.destroyInactivePanel,
forceRender = _this$props.forceRender;
var contentCls = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(prefixCls, "-content"), true), _defineProperty(_classnames, "".concat(prefixCls, "-content-active"), !isInactive), _defineProperty(_classnames, "".concat(prefixCls, "-content-inactive"), isInactive), _classnames));
var child = !forceRender && isInactive && destroyInactivePanel ? null : React.createElement("div", {
className: "".concat(prefixCls, "-content-box")
}, children);
return React.createElement("div", {
className: contentCls,
role: "tabpanel"
}, child);
}
}]);
return PanelContent;
}(Component);
_defineProperty(PanelContent, "propTypes", {
prefixCls: PropTypes.string,
isInactive: PropTypes.bool,
children: PropTypes.any,
destroyInactivePanel: PropTypes.bool,
forceRender: PropTypes.bool
});
export { PanelContent as default };
//# sourceMappingURL=PanelContent.js.map