PanelContent.js
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _classnames2 = _interopRequireDefault(require("classnames"));
/* eslint-disable no-underscore-dangle */
/* eslint-disable react/prop-types */
var PanelContent = React.forwardRef(function (props, ref) {
var _classnames;
var prefixCls = props.prefixCls,
forceRender = props.forceRender,
className = props.className,
style = props.style,
children = props.children,
isActive = props.isActive,
role = props.role;
var _React$useState = React.useState(isActive || forceRender),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
rendered = _React$useState2[0],
setRendered = _React$useState2[1];
React.useEffect(function () {
if (forceRender || isActive) {
setRendered(true);
}
}, [forceRender, isActive]);
if (!rendered) {
return null;
}
return React.createElement("div", {
ref: ref,
className: (0, _classnames2.default)("".concat(prefixCls, "-content"), (_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(prefixCls, "-content-active"), isActive), (0, _defineProperty2.default)(_classnames, "".concat(prefixCls, "-content-inactive"), !isActive), _classnames), className),
style: style,
role: role
}, React.createElement("div", {
className: "".concat(prefixCls, "-content-box")
}, children));
});
PanelContent.displayName = 'PanelContent';
var _default = PanelContent;
exports.default = _default;